Skip to main content

GS PY Config

Configuration class

Python package codecov

Usage

Create your configuration class, extending config_guiosoft.ConfigClass

from config_guiosoft import ConfigClass
from datetime import datetime, time

class Config(ConfigClass):
  STRING_CONF = "DEFAULT VALUE"
  INT_CONF = 10
  FLOAT_CONF = 0.0
  BOOL_CONF = False  
  DATE = date.today()
  DATETIME = datetime.now()

config = Config()
print(config)
>>> __main__.Config(BOOL_CONF:False,DATE:datetime.date(2020, 7, 30),DATETIME:datetime.datetime(2020, 7, 30, 18, 39, 55, 374515),FLOAT_CONF:0.0,INT_CONF:10,STRING_CONF:'DEFAULT VALUE')

When this class is instantiated, it loads values from environment variables with same name. If the variable is undefined, default values will be used.

Advanced usage

You can use ConfigType for special field behavior.

from config_guiosoft import ConfigClass, ConfigType
from datetime import datetime, time

class SpecialConfig(ConfigClass):
    STRING_CONF = ConfigType(
        'STRING_CONF', str, 'DEFAULT_STRING', lambda value: len(value) > 1)
    INT_CONF = ConfigType(
        'INT_CONF', int, 100, range(1000))
    FLOAT_CONF = ConfigType(
        "FLOAT_CONF", float, 0.5, [0, 0.1, 0.5, 3.14])
    BOOL_CONF = ConfigType(
        "BOOL_CONF", bool, False)
    DEFAULT_CONF = ConfigType("DEFAULT_CONF")
    DATE = ConfigType(
        "DATE", date, date.today(), lambda value: value <= date.today())
    DATETIME = ConfigType(
        "DATETIME", datetime, datetime.now(),
        lambda value: value <= datetime.now())

# ConfigType constructor

ConfigType(env_name: str, type=str, default=None, validation: callable = None)
Field Description
env_name Environment variable name, string, required
type python type (str, int, float, bool, datetime, date)
default default value (must be compatible with type)
validation callable to validate data

Metadata

Release files for config-guiosoft 0.1.5

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

Source distribution (sdist)

Source distribution for config-guiosoft 0.1.5
File Size Uploaded Provenance Actions
config_guiosoft-0.1.5.tar.gz 7.1 kB Without provenance Details for config_guiosoft-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for config-guiosoft 0.1.5
File Interpreter ABI Platform Actions
config_guiosoft-0.1.5-py3-none-any.whl Python 3 none any Details for config_guiosoft-0.1.5-py3-none-any.whl

Total release size: 17.6 kB

Release files / config_guiosoft-0.1.5.tar.gz

Download URL config_guiosoft-0.1.5.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
11f87d6b7aed0a2b39d5e6aa3eb9863fd10d1e237fc616ee2c18ba1d3d273304
BLAKE2b-256 checksum
How to use checksums
9f2ba93dc2855b7ad9dddb7237d000b261a417866445d9154f000cb4d35445a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Release files / config_guiosoft-0.1.5-py3-none-any.whl

Download URL config_guiosoft-0.1.5-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3784217a3ce7e39489bef6fda54f67b066d0b4ed7bfd180bc5bcf8f89276966e
BLAKE2b-256 checksum
How to use checksums
386027b3c298c83ef7fdf903f21252e7a101ea0dc26fd1fcd6bcd617c6f4a617
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Security for config-guiosoft 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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