Skip to main content

A simple powerfull module for files handling

Project description

Zyntra

Zyntra is a powerfull python module to handle files using two main calsses:

  • FileObj class to handle one file and allows you to make operations like:
  1. read,write,size,readlines,strippedlines,remove
  2. copy_to,move_to,write_json,read_json,renameto,...

  • FileGroup class to handle a group of files and allow you to make:
  1. filter_by_size,filter_by_ext,read_all,write_all,remove_all
  2. 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.1.0 ?
  1. some errors has been corrected
  2. some improvements for filter_by_ext
  3. new submodule zyntra.exts contatins a sets for all popular file extensions
from zyntra.exts import EXT_VIDEO,EXT_IMAGES,EXT_DOCS,......
from zyntra import FileGroup
from zyntra.exts import EXT_VIDEO

fg = FileGroup("f1.mkv","f2.mp4","f3.txt","f4.jpg","f5.mov","f6.txt")

videos = fg.filter_by_ext(EXT_VIDEO)
print(videos)
  • Output :
[<FileObj name='f1.mkv'>, <FileObj name='f2.mp4'>, <FileObj name='f5.mov'>]

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()

Other

# zyntra.exts submodule

  • contains a sets for all file extensins

EXT_TEXT for text files txt,json...

EXT_DOCS for documents pdf,xlsx,doc,docx...

EXT_IMAGES for images png,jpg,gif,heic...

EXT_AUDIO for audio files mp3,wav,ogg...

EXT_VIDEO for video files mp4,mkv,avi,...

EXT_ARCHIVES for archives zip,rar,tar,7z,...

EXT_CODE for code files html,cpp,py,go,c,rs....

EXT_DATABASE for database files db,sqlite3,...

EXT_EXECUTABLES for executables exe,sh,rpm,apk,deb,...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zyntra-1.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zyntra-1.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file zyntra-1.1.0.tar.gz.

File metadata

  • Download URL: zyntra-1.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for zyntra-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a8345106cefde9999b94d5bd2459db0ebda519a4c5418317134dff5e8b204141
MD5 ad2b7a48ecea547c199602bfd313ce8b
BLAKE2b-256 ba4507e8f9d521706c23cea6701e134a88901bc25444ddf94e7099b7725f7c32

See more details on using hashes here.

File details

Details for the file zyntra-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: zyntra-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for zyntra-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aeacb9e39f57ceafdb1410c4a5cbc1a8a8cc0b7231474f161d8a9f94c7288975
MD5 d3dadb7243b87a2f478c18c118b076d9
BLAKE2b-256 066f6dd68ccdc6053ccd01d04c093b5702b134ea5b7323661f8e705ce2f1f9d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page