Input/Output transport utility objects
Project description
Input/Output Utility
The Input/Output transport utility objects created for load
the config data
from any file format types like .yaml
, .json
, or .toml
, and manage retention
and version of this config file lifecycle.
:round_pushpin: Installation
pip install -U ddeutil-io
Python version supported:
Python Version | Installation | Support Fixed Bug |
---|---|---|
>=3.9,<3.14 |
pip install -U ddeutil-io |
:heavy_check_mark: |
[!NOTE] This package need to install
ddeutil
for core package namespace.
:dart: Features
The features of this package is Input/Output utility objects.
Module | Name | Description | Remark |
---|---|---|---|
files | |||
Files
[!NOTE] The file objects use to read or write data with its format.
For example, I will represent YamlEnvFl
object that passing environment variable
to reading content before passing to the Yaml loader.
data:
get: HELLO ${HELLO}
import os
from ddeutil.io import YamlEnvFl
os.environ["HELLO"] = "WORLD"
content = YamlEnvFl('./.pre-commit-config.yaml').read(safe=True)
assert content['data']['get'] == "HELLO WORLD"
Config
Config Object is the dir system handler object that manage any files in that
input dir path like load
, save
, load_stage
, save_stage
, or files
.
from pathlib import Path
from ddeutil.io.config import ConfFl
config: ConfFl = ConfFl(path=Path('./conf'), compress="gzip")
data = config.load('config_file.yaml')
config.save_stage('./stage/file.json', data)
Register
The Register Object is the metadata generator object for the config data. If you passing name and configs to this object, it will find the config name in any stage storage and generate its metadata to you.
from ddeutil.io.register import Register
from ddeutil.io.param import Params
registry: Register = Register(
name='examples:conn_data_local_file',
params=Params.model_validate({
"stages": {
"raw": {"format": "{naming:%s}.{timestamp:%Y%m%d_%H%M%S}"},
},
}),
)
registry.move(stage="raw")
The raw data of this config was written in conn_file.yaml
file.
conf/
examples/
conn_file.yaml
When call move
method, it will transfer data from .yaml
file to json
file
with the data hashing algorithm.
data/
raw/
conn_file_20240101_000000.json
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 ddeutil_io-0.1.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e4b0f954a12caad3f4237b161e9d66868982ffd75813289edd53261f4aa1160 |
|
MD5 | 069327ba73c2cc6d62c9903a568c1e6b |
|
BLAKE2b-256 | e7f87cda8b3e14d806e9a7ff859018e0f520aed633cb80eb4f24b7fbafef6d19 |