Skip to main content

The BDM ( Better Data Management ) Library is a Python Library designed to provide a better data management when it comes to files and directories.

Library Usage

The library includes two new objects; The Bdir and the Bfile, referring to Better Directory and Better File, respectively.

Better Directories

from betterdatamanagement.bdir import Bdir

# Using a better directory is simple.
b = Bdir("path_to_directory")  # Initializes

# Object Attributes
b.path  # path_to_directory (C://Path//to//dir//MyDir)
b.dirname  # MyDir
b.contents  # Returns a JSON Serializable structure of the directory tree

# Deleting the directory
b.remove()  # This not only deletes the directory and all its contents but also turns the class useless. All the attributes are set to None from then on.

# Renaming a directory
b.rename('ILikeThisDir')  # C://Path//to//dir//MyDir -> C://Path//to//dir//ILikeThisDir
# All the attributes are updates accordingly

# Finding a specific item inside a directory
# There is an "exact" parameter that makes it match the name you put in exactly. If set to False, it'll perform an "if key in filename" operation.
b.find('LovePoem.txt')  # This will only return the path of the first match.

# Finding more than one item inside a directory
# There is an "exact" parameter that makes it match the name you put in exactly. If set to False, it'll perform an "if key in filename" operation.
b.find_all('Poem.txt')  # Returns a list of all the paths of the matched items.

# Moving the directory
b.move_to("new_path")  # Moves the directory physically to a new location and updates all the attributes accordingly

# Copying the directory to a new location
b.copy_to("new_path")  # Copies the directory to a new location.
# Checks if the directory already exists there, and if so adds a serial to the copy
# Ex.: MyPoems-1, MyPoems-2 and so on

Bdir Contents Example

# Raw_Response.py

>>> b.contents
{'MyPoems': {'*path': 'C:\\Users\\Alex\\Desktop\\MyPoems', 'FriendlyPoems': {'*path': 'C:\\Users\\Alex\\Desktop\\MyPoems\\FriendlyPoems', 'Poem1.txt': 'C:\\Users\\Alex\\Desktop\\MyPoems\\FriendlyPoems\\Poem1.txt', 'Poem2.txt': 'C:\\Users\\Alex\\Desktop\\MyPoems\\FriendlyPoems\\Poem2.txt'}, 'LovePoems': {'*path': 'C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems', 'Poem1.txt': 'C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems\\Poem1.txt', 'Poem2.txt': 'C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems\\Poem2.txt', 'Poem3.txt': 'C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems\\Poem3.txt'}, 'No i am not a poet.txt': 'C:\\Users\\Alex\\Desktop\\MyPoems\\No i am not a poet.txt'}
// ContentsExample.json - Serialized JSON with (indent=4)

{
    "MyPoems": {
        "*path": "C:\\Users\\Alex\\Desktop\\MyPoems", //*path is the directory path
        "FriendlyPoems": {
            "*path": "C:\\Users\\Alex\\Desktop\\MyPoems\\FriendlyPoems",
            "Poem1.txt": "C:\\Users\\Alex\\Desktop\\MyPoems\\FriendlyPoems\\Poem1.txt",
            "Poem2.txt": "C:\\Users\\Alex\\Desktop\\MyPoems\\FriendlyPoems\\Poem2.txt"
        },
        "LovePoems": {
            "*path": "C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems",
            "Poem1.txt": "C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems\\Poem1.txt",
            "Poem2.txt": "C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems\\Poem2.txt",
            "Poem3.txt": "C:\\Users\\Alex\\Desktop\\MyPoems\\LovePoems\\Poem3.txt"
        },
        "No i am not a poet.txt": "C:\\Users\\Alex\\Desktop\\MyPoems\\No i am not a poet.txt"
    }
}

Better Files

from betterdatamanagement.bfile import Bfile

# Using a better file is simple
b = Bfile("path_to_file")

# Objects Attributes
b.path  # filepath (C://path//to//file//MyFile.txt)
b.filename  # MyFile
b.binary  # Boolean - Returns True if file is binary and False if not.
b.extension  # .txt

# Deleting the file
b.remove()

# Renaming the file
b.rename("Buttercup Lyrics.txt")  # C://path//to//file//MyFile.txt -> C://path//to//file//Buttercup Lyrics.txt
# All the attributes are updated accordingly

# Moving the file
b.move_to("new_path")  # Moves the file to the new path and updates all the attributes accordingly

# Copying the file to a new location
b.copy_to("new_path")  # Copies the file to a new location.
# Checks if the file already exists there, and if so adds a serial to the copy
# Ex.: Poem-1, Poem-2 and so on.

Quick Data Editing

It's recommended to use normal file editing if you wish to be more specific with the content. These methods are to be used for a quick edit.

# Writing data to the file
b.write("Text")  # Writes data to the file, this will overwrite any existant data within.
# It has binary support and is able to write binary data too.

# Appending data to the file
b.append("Text")  # Appends data to the file, this will add in any data at the end of the file.

# Retrieve the contents from the file
content, lines = b.get_contents()  # This method returns two values, the file content, and the file content in lines. (file.read, file.readlines())
# You may iterate over the lines for the content of each.

Metadata

Release files for BetterDataManagement 1.4.1

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

Source distribution (sdist)

Source distribution for BetterDataManagement 1.4.1
File Size Uploaded Provenance
BetterDataManagement-1.4.1.tar.gz 19.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for BetterDataManagement 1.4.1
File Interpreter ABI Platform
BetterDataManagement-1.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.9 kB

Release files / BetterDataManagement-1.4.1.tar.gz

Download URL BetterDataManagement-1.4.1.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
20be341b67a01fdb6dd338d1242a56bdc74abf0f26000138377f17df4bce6f1a
BLAKE2b-256 checksum
How to use checksums
67a6cb4c5e32d03bde4253a93dfbe51b9ac4a3b36098eb8b4f98708218754fd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / BetterDataManagement-1.4.1-py3-none-any.whl

Download URL BetterDataManagement-1.4.1-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
620943e9b9b5f470f0309a87b027aa2d24dee1fcccd5400d9f9d82a8a739aa9d
BLAKE2b-256 checksum
How to use checksums
f14977cb74258ba6ea0018fcce1774ab6a7ae16592a0be5b21408d4f1cf95450
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for BetterDataManagement 1.4.1

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.

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 release files No provenance

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