A Package designed for a better data management when it comes to both files and directories.
Reason this release was yanked:
Does not work; __init__ missing
Project description
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
b.find('LovePoem.txt') # This will only return the path of the first match.
# Finding more than one item inside a directory
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.
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
Built Distribution
File details
Details for the file BetterDataManagement-1.2.tar.gz
.
File metadata
- Download URL: BetterDataManagement-1.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bf02ea3fb3537619d2d1096ce6a797b2b16de875a5c9aa965781e619fdfe29e |
|
MD5 | cd3e623830bae9614c4bd89c3fdfa91a |
|
BLAKE2b-256 | d519c3d517d8d1df9780fdd959e193cb4a7de0749ffcd94993e0d53102c03855 |
File details
Details for the file BetterDataManagement-1.2-py3-none-any.whl
.
File metadata
- Download URL: BetterDataManagement-1.2-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cb87344e360f0cacb9f2fdcc85eed1376fe0810ac35dd690b95ce3eb502a1a8 |
|
MD5 | 86cc806dcad755b8ff85764589a3e82c |
|
BLAKE2b-256 | 61a715c2f943e8e1b20bd046a48dc29b5a46f44eb0b5e3c89150dd73b93a2685 |