Skip to main content

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. Simple YAML File Reader

This utility reads a YAML file and returns a dictionary 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:

import aiml_py_common_utils as aiml

content = aiml.simple_read_yaml(path_to_yaml)

print(content["string"])  # Outputs: "Hello, World"
print(content["integer"])  # Outputs: 25

2. Box 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:

import aiml_py_common_utils as aiml

content = aiml.box_read_yaml(path_to_yaml)

print(content.string)  # Outputs: "Hello, World"
print(content.integer)  # Outputs: 25

3. 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
import aiml_py_common_utils as aiml

list_of_directories_paths = [
    Path("./dir_one"),
    Path("./dir_two"),
    Path("./dir_three")
]

aiml.create_directories(path_to_directories=list_of_directories_paths)

4. JSON File Writer

This utility saves a dict or list as a JSON file:

from pathlib import Path
import aiml_py_common_utils as aiml

example_dict = {
  "string": "Hello, World",
  "integer": 25,
  "floating_point": 3.14,
  "boolean": True,
  "null_value": None,
}

path_to_json = Path("path/to/example.json")
aiml.save_as_json(path=path_to_json)

5. Simple JSON File Reader

This utility loads a JSON file as dictionary/list. 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
import aiml_py_common_utils as aiml

path = Path("path/to/example.json")
content = load_json(path=path_to_json)
print(content["string"])  # Outputs: "Hello, World"
print(content["integer"])  # Outputs: 25

6. Binary File Writer

This utility saves a snapshot of data as a binary file:

from pathlib import Path
import aiml_py_common_utils as aiml

example_dict = {
  "string": "Hello, World",
  "integer": 25,
  "floating_point": 3.14,
  "boolean": True,
  "null_value": None,
}

path_to_bin = Path("path/to/example.bin")
aiml.save_bin(data=example_dict, path=path_to_bin)

7. Binary File Reader

This utility loads a snapshot of data from a binary file:

from pathlib import Path
import aiml_py_common_utils as aiml

path_to_bin = Path("path/to/example.bin")
loaded_bin_content = aiml.load_bin(path=path_to_bin)

8. File Size Calculator

This utility calculates the size of a file in kilobytes:

from pathlib import Path
import aiml_py_common_utils as aiml

filepath = Path("path/to/example.file")
size_in_kb = aiml.get_size(path=filepath)

9. Convert dict/json as string

This utility converts a dictionary or a list of dictionaries into a JSON string with specified indentation.

from pathlib import Path
from aiml_py_common_utils import stringify_json

json_as_string = stringify_json(data={"key": "value"})

Metadata

Release files for aiml-py-common-utils 0.0.3

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

Source distribution (sdist)

Source distribution for aiml-py-common-utils 0.0.3
File Size Uploaded
aiml_py_common_utils-0.0.3.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiml-py-common-utils 0.0.3
File Interpreter ABI Platform
aiml_py_common_utils-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / aiml_py_common_utils-0.0.3.tar.gz

Download URL aiml_py_common_utils-0.0.3.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e64aad02088452005bce56d26ab1eba3e309db333ce5cfa6c2fb004ca44baea9
BLAKE2b-256 checksum
How to use checksums
86d62b1fe6c0aba0d228dedd613378c5bdaf6a63c4b4fc5c361c322662387c15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / aiml_py_common_utils-0.0.3-py3-none-any.whl

Download URL aiml_py_common_utils-0.0.3-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbe13f8ec3674169c1287c591504549918fe793454578bfa3d83d3e010419df5
BLAKE2b-256 checksum
How to use checksums
232c1028f6c359ab0dbbf02456dd7a7a92581ec2400b7d9c233f4b2845695aed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

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