UtilityLib
UtilityLib is a unified library of basic modules that provides a collection of ready-to-use functions for various file system oprerations and data processing.
Installation
- You can install UtilityLib via pip or by copying the UtilityLib directory into your project.
- Using pip:
pip install UtilityLib - Using pip+GitHub:
pip install git+https://github.com/yourusername/UtilityLib.git
Usage/Examples
Here are some examples demonstrating how to use UtilityLib's key features:
Initialize UtilityLib's ProjectManager or any other class in the chain
UtilityLib provides flexible import options for different use cases:
# Initialize it with setting current working directory as base_path provided
from UtilityLib import ProjectManager
MyProj = ProjectManager(path_base="path/to/your/project/dir")
# Or change directory in runtime
MyProj.path_base = 'path/to/some-other/directory'
print(MyProj.config_version, MyProj.config_subversion, MyProj.path_base)
File Path Operations
# Change current working directory
# List all files (Refer UtilityLib.lib.path.EntityPath for more options )
_proj_path = MyProj.path_base
# Walk Files and Dirs using iterator (memory efficient) or list them all
_walk_dirs = _proj_path.walk_dirs
_walk_files = _proj_path.walk_filess
# List direct files and directories/folders in project
_all_files = _proj_path.files
_all_dirs = _proj_path.dirs
# Get tree of the directory (Linux's tree equivalent)
print(_proj_path.tree) # use _proj_path.tree_gen (generator method) if you think there are too many files
# Pick matching file or search multiple files
_my_single_excel_file = _proj_path.get_match('*Excel-2025*.xlsx')
_my_jpg_files = _proj_path.search("*2025*.jpg")
# Tip: rename, move, or copy using (refer )
# Create new path on go, it returns UtilityLib.lib.path.EntityPath object
_my_new_sub_path: EntityPath = (MyProj.path_base / 'New-Dir' / 'Sub-Dir').validate()
# Use EntityPath delete method to delete files or folders. You need to turn off is_protected to delete else it raises warning
_my_new_sub_path.delete(is_protected=False)
Some quick file operations
_mfpo = _my_file_path_obj = (MyProj.path_base / 'My-Excel-File.xlsx')
print(_mfpo.stem, _mfpo.name, _mfpo.suffix) # Prints file names and extension
print(_mfpo.with_suffix('.2025-05-2022.xlsx')) # Changes file extension
print(_mfpo.created) # Prints date of the file creation
print(_mfpo.updated) #
print(_mfpo.exists()) # Does file exists?
print(_mfpo.copy('/New/Location/Copy-dir/'))
print(_mfpo.copy('/New/Location/Copy-dir/with-new-name.xlsx'))
print(_mfpo.move('/New/Location/Move-dir/with-new-name.xlsx'))
Project Configuration Management
from UtilityLib import ProjectManager
# Initialize project manager with cross-platform paths
MyProj = ProjectManager(
path_bases=("/mnt/D/DataDrive", "D:/path-windows"),
version=2,
subversion=202211 # To load specific sub config
)
# Add new configuration values
MyProj.config.database.connection_string = "sqlite:///data.db"
MyProj.config.processing.batch_size = 1000
# Update existing configuration
MyProj.update_config()
# Save configuration with new subversion
MyProj.update_config(subversion=20221103)
File Compression and Cleanup
# Create compressed archive
MyProj.add_tgz_files("/data/WOS-Downloads.tgz", csv_files)
# Clean up original directory
MyProj.delete_path("/data/WOS-Downloads")
Classes and Modules
Metadata
Release files for UtilityLib 2.21.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| utilitylib-2.21.4.tar.gz | 77.3 kB | Without provenance | Details for utilitylib-2.21.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| utilitylib-2.21.4-py3-none-any.whl | Python 3 | none | any | Details for utilitylib-2.21.4-py3-none-any.whl |
Total release size: 162.0 kB
Release files / utilitylib-2.21.4.tar.gz
| Download URL | utilitylib-2.21.4.tar.gz |
|---|---|
| Size | 77.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3f7df801415757b59c12af591123825cf61fc4d50687a30bfe07351b1cc06ae
|
|
BLAKE2b-256 checksum How to use checksums |
00c2f435259ae24d3f09a541abbab09eecf33877b883c8d27a8498efd6f84779
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / utilitylib-2.21.4-py3-none-any.whl
| Download URL | utilitylib-2.21.4-py3-none-any.whl |
|---|---|
| Size | 84.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b706f61b7371aee1c081afc1cc67dcea3a88e827d14947c2866bac20855054cb
|
|
BLAKE2b-256 checksum How to use checksums |
621a86131e1ff7f09a5dfee10e86662815bc1c1282ada71b4b121a9b33877fd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for UtilityLib 2.21.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.