
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Class that gives you the mini help to avoid to write open(file_path,'r')
or open(file_path,'w')
every time ypu want to work with some text file.
You can easily install archiwith
using pip:
pip install archiwith
or via git:
git clone https://github.com/niCodeLine/archiwith.git
or just copy-paste it into your code.
To use the mini helper simply import the class and call it stating the file path of the text file you want to open. Then use it with the with
method. Here's a simple example:
from archiwith import Archiwith
# Stating the file path
reader = Archiwith('path/to/your/file').abrir()
# Using the with method
with reader as file:
# Do something with the file
Another way and opening a binari:
# Stating the file path
reader = Archiwith('path/to/your/file')
# Reading as binari file
with reader.abrir(binari=True) as file:
# Do something with the file
If the file is text-readeable you can just:
# Stating the file path
reader = Archiwith('path/to/your/file')
text = reader.leer()
or shorter:
# Stating the file path
text = Archiwith('path/to/your/file').leer()
# Stating the file path
writer = Archiwith('path/to/your/file').escribir()
# Using the with method
with writer as file:
# Write the file
This implementation speeds up file handling by allowing access to file names as attributes, eliminating the need to manually write them out one by one. For example, lets say your folder has a structure like this:
your_folder/
ā
āāā firstcode.py
āāā another_folder/
āāā outputs.txt
āāā tests.txt
āāā my programs.py
You can access to the names via:
from archiwith import ObjectiFiles
path = 'path/to/your_folder'
files = ObjectiFiles(path)
This will create the files
object with the valid files as attributes and nameing them with a f_file_name__ext
form. So:
>>> files.f_tests__txt
'tests.txt'
>>> files.f_my_programs__py
'my programs.py'
If you have suggestions enabled in your code editor (command I in VS Code), you will get the names when typing files.f
. The f
prefix comes from File and is to get a clearer view of what are the files in the autocomplete suggestions.
That would be it.
Contributions are welcome! If you have improvements or fixes, please send a pull request or open an issue in the GitHub repository.
This project is licensed under the MIT License. See the LICENSE
file for more details.
Nico Spok - nicospok@hotmail.com GitHub: niCodeLine
FAQs
File opener and closener when managed via `with`.
We found that archiwith demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.