A FIFO folder management library that manages files using queue-like principles.
Project description
fifo_folder
A FIFO folder management library that manages files using queue-like principles.
Install
pip install fifo_folder
Example
Here's an example logger using fifo_folder
to limit the resources used by log files:
import os
from fifo_folder import FIFOFolder
LOG_DIR_PATH = "/path/to/your/log/folder/"
log_manager = FIFOFolder(
LOG_DIR_PATH, # path to the folder to manage
count_limit=100, # keep at most 100 files
total_size_limit=(1 << 30), # keep sum of file sizes no greater than 1GB
)
def log(file_name: str, text: str) -> None:
# create a new log file
file_path = os.path.join(LOG_DIR_PATH, file_name)
with open(file_path, "w") as file:
file.write(text)
log_manager.load_items() # load current files
removed_items = log_manager.manage() # removed extra files
if len(removed_items): # display removed files
print(
"removed log files:",
[os.path.basename(item.data.path) for item in removed_items]
)
Links
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
fifo_folder-0.3.0.tar.gz
(4.7 kB
view details)
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 fifo_folder-0.3.0.tar.gz.
File metadata
- Download URL: fifo_folder-0.3.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
328e415de5d301c3fc726a18d7ce56c2100d62e222d5cda582f066f5c6d6d489
|
|
| MD5 |
98af661e20d509ea289d3bfa8e591455
|
|
| BLAKE2b-256 |
89dcbd33914c95e9ed53fabf6f0868f9b4fce853c0197abde36f125cc245ece6
|
File details
Details for the file fifo_folder-0.3.0-py3-none-any.whl.
File metadata
- Download URL: fifo_folder-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c63ea97a20dbb1d68504eebd8dd099d5fc167d549b2bf218c1472cb217fac5b5
|
|
| MD5 |
a97ce856bcaec1be11c672ef42d08783
|
|
| BLAKE2b-256 |
a1e569977d8b199aa0dfd4f9565e23068bc2633f19ec5e715b5330f9ebd2e463
|