Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shiertier_os-0.0.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shiertier_os-0.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file shiertier_os-0.0.1.tar.gz.

File metadata

  • Download URL: shiertier_os-0.0.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for shiertier_os-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7c4fc192ca08c5f9e150a81cbe6597f851bdd61232ad9b4c78d5caaacf5ddeaf
MD5 3b31bbf962e45ebfea6100e4814f976a
BLAKE2b-256 71ec1386164506af952de864ea96ae8ca32e503f359b01bfe41b30e2d12c586b

See more details on using hashes here.

File details

Details for the file shiertier_os-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: shiertier_os-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for shiertier_os-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c071319120266846f24312d5b40a70618ced5ee919f6509853fda4ecd945e44
MD5 f45c5b341dc1e5c0707e2663d628c38f
BLAKE2b-256 b1d4c4737ede4428d15152571b4ad32be485410a99077a2beb96f180a6e46a5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page