A simple os library for Python.
Project description
shiertier_os
English | 中文
Introduction
shiertier_os is a Python utility library designed to simplify the management of environment variables. It provides functions to get, set, and convert environment variables, making it easier to work with environment configurations in your applications.
Installation
You can install shiertier_os via pip:
pip install git+https://github.com/shiertier/shiertier_os.git
Please note that this project is still under development.
Usage
Getting Environment Variables
You can use the get_env function to retrieve environment variables. This function allows you to specify a default value if the environment variable is not set. If the value contains a comma, it will be converted to a list.
from shiertier_os import get_env
# Get an environment variable
value = get_env('MY_VAR', default_value='default')
print(value)
# Get an environment variable as a list
value_list = get_env('MY_LIST_VAR', default_value='item1,item2,item3')
print(value_list)
Setting Environment Variables
You can use the set_env function to set environment variables. If the value is a list, it will be converted to a string before being set.
from shiertier_os import set_env
# Set an environment variable
set_env('MY_VAR', 'new_value')
# Set an environment variable from a list
set_env('MY_LIST_VAR', ['item1', 'item2', 'item3'])
Getting Configuration Variables
You can use the get_var function to retrieve a configuration variable. This function first checks if the environment variable is set. If not, it returns the provided configuration value.
from shiertier_os import get_var
# Get a configuration variable
config_value = get_var('MY_VAR', 'default_config_value')
print(config_value)
Converting Between String and List
The library also provides utility functions to convert between strings and lists:
convert_str_to_list(s): Converts a comma-separated string to a list.convert_list_to_str(l): Converts a list to a comma-separated string.
from shiertier_os import convert_str_to_list, convert_list_to_str
# Convert a string to a list
my_list = convert_str_to_list('item1,item2,item3')
print(my_list)
# Convert a list to a string
my_string = convert_list_to_str(['item1', 'item2', 'item3'])
print(my_string)
License
This project is released under the MIT License. See the LICENSE file for details.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shiertier_os-0.0.3.tar.gz.
File metadata
- Download URL: shiertier_os-0.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f9e0cc8ec9bf7c206f27c779d0edc20156354a7c01468ef5959caca170d16af
|
|
| MD5 |
64ffd366b426517a4abf30a94a818cfe
|
|
| BLAKE2b-256 |
afab1dfd4128e79ba9ebed6bb4e68b6cf47626c97d1c70c06eab6b8093e45746
|
File details
Details for the file shiertier_os-0.0.3-py3-none-any.whl.
File metadata
- Download URL: shiertier_os-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
523bb0983ccf8f9003cac643d86c3f4c592770f6ff3b93ea75963d0052f24b55
|
|
| MD5 |
9f900e5280e26017fd883b60ee993c8e
|
|
| BLAKE2b-256 |
1732b1d4a80cb52a862fcd17df16d225a4547a9b80da39d87b9770777b716d90
|