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
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
fifo_folder-0.2.0.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file fifo_folder-0.2.0.tar.gz
.
File metadata
- Download URL: fifo_folder-0.2.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aeacf91d8cec8d4886223a0256a58d62db27c32aa32bc2b7a0d04dc008e1b63 |
|
MD5 | d66e564db7cfbe47c5fc8036f193cbba |
|
BLAKE2b-256 | ac258591b10e0249a1996410c085c3f7ad660b6b152d1e45327d94cac5b1a315 |
File details
Details for the file fifo_folder-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: fifo_folder-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15f7bcd22b93cd051e7188ff85ff5ed8103f3d8f1fa5c111fbbbbd9a8cbd6234 |
|
MD5 | 9b82d1f730112027d6065e70451fd536 |
|
BLAKE2b-256 | d6acd2baaa993bb92df8b61ec1ba9beebe8104028e3c8beae0a2b66fa59f7125 |