Skip to main content

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

Metadata

Release files for fifo-folder 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fifo-folder 0.3.0
File Size Uploaded
fifo_folder-0.3.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fifo-folder 0.3.0
File Interpreter ABI Platform
fifo_folder-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / fifo_folder-0.3.0.tar.gz

Download URL fifo_folder-0.3.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
328e415de5d301c3fc726a18d7ce56c2100d62e222d5cda582f066f5c6d6d489
BLAKE2b-256 checksum
How to use checksums
89dcbd33914c95e9ed53fabf6f0868f9b4fce853c0197abde36f125cc245ece6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / fifo_folder-0.3.0-py3-none-any.whl

Download URL fifo_folder-0.3.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c63ea97a20dbb1d68504eebd8dd099d5fc167d549b2bf218c1472cb217fac5b5
BLAKE2b-256 checksum
How to use checksums
a1e569977d8b199aa0dfd4f9565e23068bc2633f19ec5e715b5330f9ebd2e463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page