No project description provided
Project description
AIML Python Common Utilities
Visit Documentation - Click here
This repository provides a collection of utilities that are frequently used in various AIML applications.
Current Version Features
The current version includes the following utilities:
1. YAML File Reader
This utility reads a YAML file and returns a ConfigBox type object. For instance, given a YAML file with the following content:
# Scalars
string: "Hello, World"
integer: 25
floating_point: 3.14
boolean: true
null_value: null
# Sequences
sequence:
- item1
- item2
- item3
You can access the content of the YAML file as follows:
from aiml_py_common_utils import read_yaml
content = read_yaml(path_to_yaml)
print(content.string) # Outputs: "Hello, World"
print(content.integer) # Outputs: 25
2. Directory Creator
This utility allows you to create multiple directories. For example, to create directories named dir_one
, dir_two
, and dir_three
, you can use the function as follows:
from pathlib import Path
from aiml_py_common_utils import create_directories
list_of_directories_paths = [
Path("./dir_one"),
Path("./dir_two"),
Path("./dir_three")
]
create_directories(path_to_directories=list_of_directories_paths)
3. JSON File Writer
This utility saves a dictionary as a JSON file:
from pathlib import Path
from aiml_py_common_utils import save_dict2json
example_dict = {
"string": "Hello, World",
"integer": 25,
"floating_point": 3.14,
"boolean": True,
"null_value": None,
}
path_to_json = Path("path/to/example.json")
save_dict2json(path=path_to_json)
4. JSON File Reader
This utility loads a JSON file. For example, given a JSON file at a certain path containing:
{
"string": "Hello, World",
"integer": 25,
"floating_point": 3.14,
"boolean": true,
"null_value": null,
}
You can load the content of the JSON file as follows:
from pathlib import Path
from aiml_py_common_utils import load_json
path = Path("path/to/example.json")
content = load_json(path=path_to_json)
print(content.string) # Outputs: "Hello, World"
print(content.integer) # Outputs: 25
5. Binary File Writer
This utility saves a snapshot of data as a binary file:
from pathlib import Path
from aiml_py_common_utils import save_bin
example_dict = {
"string": "Hello, World",
"integer": 25,
"floating_point": 3.14,
"boolean": True,
"null_value": None,
}
path_to_bin = Path("path/to/example.bin")
save_bin(data=example_dict, path=path_to_bin)
6. Binary File Reader
This utility loads a snapshot of data from a binary file:
from pathlib import Path
from aiml_py_common_utils import load_bin
path_to_bin = Path("path/to/example.bin")
loaded_bin_content = load_bin(path=path_to_bin)
7. File Size Calculator
This utility calculates the size of a file in kilobytes:
from pathlib import Path
from aiml_py_common_utils import get_size
filepath = Path("path/to/example.file")
size_in_kb = get_size(path=filepath)
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
Hashes for aiml-py-common-utils-0.0.1b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24ed5b4f13020655a1444f729c8a330466ca482e54acfd464f7435169ae2eb09 |
|
MD5 | b481b303afb3a4254b71639c160357aa |
|
BLAKE2b-256 | 2cc72e65446bf7a0fd5e92dabedd66258ce9232b7f0a87f65b174a4dd00f5038 |
Hashes for aiml_py_common_utils-0.0.1b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e53398b7b5dc699790ac6b0378ad34792022a10a557ae62f29dde7664ad38fe6 |
|
MD5 | 14ac67dd71c3daa6c9a791292357a47f |
|
BLAKE2b-256 | 558263abcc45455867130e3eacb79d1e9d60bc461691e5cd60276810bd970ed6 |