A simple powerfull module for files handling
Project description
Zyntra
Zyntra is a powerfull python module to handle files using two main calsses:
FileObjclass to handle one file and allows you to make operations like:
- read,write,size,readlines,strippedlines,remove
- copy_to,move_to,write_json,read_json,renameto,...
FileGroupclass to handle a group of files and allow you to make:
- filter_by_size,filter_by_ext,read_all,write_all,remove_all
- filter_non_empty,filter_exists,total_size,...
- the module depends on the os, shutil, json modules... but it provides simplicity for handling files.
Updates
- Whats new in 1.2.0 ?
- changed name from
magicfilestozyntra - some errors has been corrected
- new functions added
Features
- Speed up file operations
- Simple human syntax
- Json Handling
- Continuous updates to the module
FileObj
file = FileObj("data.txt")
- We can do this methods :
exist() - Check if file exists
get_parent_dir() - Get file directory path
get_extension() - Get file extension
file_hash() - Get file hash
is_empty() - Check if file is empty
content() - Read file content
write() - Write data to file
lines() - Read lines
stripped_lines() - Read stripped lines
create() - Create the file if not exist
move_to() - Move file to another directory
copy_to() - Copy file to another directory
read_json() - Read json data -> dict
write_json() - Write json data
renameto() - Rename the file
self_remove() - Remove the file
size() - Get file size
created_at() - Return creation date
modified_at() - Return modification date
FileGroup
fg = FileGroup("file1.txt","file2.txt","file3.txt")
- We can do this methods :
files() - Return list of FileObj instances
make_zip() - Make zip archive for all files in the group
filter_non_empty() - Return list of non empty files
filter_by_ext() - Filter files by extension (Returns list)
total_size() - Return sum of files sizes in bytes
filter_exists() - Return list of exist files
read_all() - Read all files (Returns dict)
write_all() - Write to all files
remove_all() - Remove all files
create_all() - Create all files (if not exist)
move_all_to() - Move all files to directory
filter_by_size() - Filter files by size (min and max or equal)
- Example
f1 = FileObj("data.txt")
f1.create()
f1.write("Hello World")
f1.rename("data_tmp.txt")
print(f1.size())
printf(f1.file_hash())
# you can use many functions .....
f1.remove()
fg = FileGroup("test1.txt","test2.txt","test3.txt")
fg.create_all()
fg.write_all("Hello World")
fg.make_zip("archive1.zip")
data: dict = fg.read_all()
print(data["test1.txt"]) # file1 content
# you can use many functions .....
fg.remove_all()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zyntra-1.0.0.tar.gz.
File metadata
- Download URL: zyntra-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7271934f0127dc8cee54bbce36a116732dc9fe973e362322fa1bea03948af17d
|
|
| MD5 |
89befb5c13929c3bf80c6edfd9f77ee9
|
|
| BLAKE2b-256 |
af23d39f27e1698d8ce0ff3cc32e1434ee01750df24044c5750a6a593ee9b4a8
|
File details
Details for the file zyntra-1.0.0-py3-none-any.whl.
File metadata
- Download URL: zyntra-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b1662385ef5d342db88f31a6258838c33f2961837ad7981b5cb6756bd570061
|
|
| MD5 |
e12631589e98f27ff8b42a45f0059550
|
|
| BLAKE2b-256 |
8185eeabc55c6d96fd3ff2037c7804c0ef7de2dc52bf2f2a52469e22046188cf
|