craftsperson-env


Namecraftsperson-env JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/celalakcelikk/craftsperson-env
Summary
upload_time2024-02-28 08:08:01
maintainer
docs_urlNone
authorCelal Akçelik
requires_python>=3.8
licenseMIT
keywords environment pyyaml yaml toml env json xml xmltodict python projects config package packaging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Craftsperson Environment

# What is it?
**craftsperson_env** reads configuration files in **yaml**, **env**, **toml**, **xml**, and **json** formats and adds them to the **'os.environ'** system. It formats the keys according to **naming-case-type**, **upper** or **lower**, and arranges them with a **specific join type in the upper-lower section**. Additionally, it specifies the data type when retrieving data from 'os.environ' to access data of that type.

# Where to get it
You can access the <a href="https://github.com/celalakcelikk/craftsperson-env">Github</a> repository from here.

Pip installers for the latest released version are available at the <a href="https://pypi.org/project/craftsperson-env">Python Package Index (PyPI)</a>

# Installation

```
python setup.py install
```
```
pip install craftsperson-env
```

# Import Library
```python
from craftsperson_env import CraftsEnvConfig
```

# Create Config Variable
```python
config = CraftsEnvConfig()
```

# Load File
**Description**
```
Help on method load_config_file in module craftsperson_env.main:

load_config_file(file_path: str, root_full_path: str = './', naming_case_type: str = None, naming_case_join_type: str = '', is_change_config_env_format: bool = False, config_env_replace_first_value: str = None, is_remove_xml_first_level: bool = False, extra_config_file_params: dict = {}) method of craftsperson_env.main.CraftsEnvConfig instance
    This function processes and uses a config file.
    
    Parameters
    ----------
    file_path : str
        This parameter specifies the file location path.
    root_full_path : str, optional
        This parameter retrieves the full path from the file. The default is './'.
    naming_case_type : str, optional
        This parameter specifies naming case types for env, yaml, json, xml, or toml. The default is None.
    naming_case_join_type : str, optional.
        This parameter specifies the join type, allowing values such as "", "-", or "_". The default is "".
    is_change_config_env_format: bool, optional.
        This parameter specifies whether the format of the env config file has been changed.
            The default value is False.
    config_env_replace_first_value: str, optional.
        This parameter specifies the replacement value for the first occurrence. The default is None.
    is_remove_xml_first_level : bool, optional
        This parameter determines whether to remove the first level. The default value is False.
    extra_config_file_params : dict, optional
        This parameter retrieves additional XML or TOML configuration parameters. The default value is {}.
    
    Returns
    -------
    None.
```

## Yaml File Use Case
```
version: 2.0
application:
  name: MyWebApp
  version: 1.2.3
  environment: production
  base_url: "https://mywebapp.example.com"
  allowed_hosts:
    - mywebapp.example.com
    - api.mywebapp.example.com
  options:
    use_ssl: true
    ssl_cert: "/path/to/cert"
json_format: "{'test': 1}"
```

```python
config.load_config_file(
    file_path="examples/yaml_config_file.yaml",
    root_full_path="examples/",
    naming_case_type="upper",
    naming_case_join_type=".",
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION.NAME',
     'APPLICATION.VERSION',
     'APPLICATION.ENVIRONMENT',
     'APPLICATION.BASE_URL',
     'APPLICATION.ALLOWED_HOSTS',
     'APPLICATION.OPTIONS.USE_SSL',
     'APPLICATION.OPTIONS.SSL_CERT',
     'JSON_FORMAT']

## Xml File Use Case
```
<config>
  <version>2.0</version>
  <application>
    <name>MyWebApp</name>
    <version>1.2.3</version>
    <environment>production</environment>
    <base_url>https://mywebapp.example.com</base_url>
    <allowed_hosts>
      <host>mywebapp.example.com</host>
      <host>api.mywebapp.example.com</host>
    </allowed_hosts>
    <options>
      <use_ssl>true</use_ssl>
      <ssl_cert>/path/to/cert</ssl_cert>
    </options>
  </application>
  <json_format>
    {'test': 1}
  </json_format>
</config>
```
The **is_remove_xml_first_level** default value is **False**.
```python
config.load_config_file(
    file_path="xml_config_file.xml",
    root_full_path = "./",
    naming_case_type="upper",
    naming_case_join_type = ".",
    is_remove_xml_first_level=False,
    extra_config_file_params={}
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['CONFIG.VERSION',
     'CONFIG.APPLICATION.NAME',
     'CONFIG.APPLICATION.VERSION',
     'CONFIG.APPLICATION.ENVIRONMENT',
     'CONFIG.APPLICATION.BASE_URL',
     'CONFIG.APPLICATION.ALLOWED_HOSTS.HOST',
     'CONFIG.APPLICATION.OPTIONS.USE_SSL',
     'CONFIG.APPLICATION.OPTIONS.SSL_CERT',
     'CONFIG.JSON_FORMAT']
The **is_remove_xml_first_level** is **True**, which removes the first level.
```python
config.load_config_file(
    file_path="xml_config_file.xml",
    root_full_path = "./",
    naming_case_type="upper",
    naming_case_join_type = ".",
    is_remove_xml_first_level=True,
    extra_config_file_params={}
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['CONFIG.APPLICATION.NAME',
     'CONFIG.APPLICATION.VERSION',
     'CONFIG.APPLICATION.ENVIRONMENT',
     'CONFIG.APPLICATION.BASE_URL',
     'CONFIG.APPLICATION.ALLOWED_HOSTS.HOST',
     'CONFIG.APPLICATION.OPTIONS.USE_SSL',
     'CONFIG.APPLICATION.OPTIONS.SSL_CERT',
     'CONFIG.JSON_FORMAT',
     'APPLICATION.ALLOWED_HOSTS.HOST']

## Toml File Use Case
```
version = "2.0"
json_format = "{'test': 1}"

[application]
name = "MyWebApp"
version = "1.2.3"
environment = "production"
base_url = "https://mywebapp.example.com"
allowed_hosts = ["mywebapp.example.com", "api.mywebapp.example.com"]

[application.options]
use_ssl = true
ssl_cert = "/path/to/cert"
```
```python
config.load_config_file(
    file_path="toml_config_file.toml",
    root_full_path = "./",
    naming_case_type="upper",
    naming_case_join_type = ".",
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'JSON_FORMAT',
     'APPLICATION.NAME',
     'APPLICATION.VERSION',
     'APPLICATION.ENVIRONMENT',
     'APPLICATION.BASE_URL',
     'APPLICATION.ALLOWED_HOSTS',
     'APPLICATION.OPTIONS.USE_SSL',
     'APPLICATION.OPTIONS.SSL_CERT']

## Json File Use Case
```
{
    "version": "2.0",
    "application": {
      "name": "MyWebApp",
      "version": "1.2.3",
      "environment": "production",
      "base_url": "https://mywebapp.example.com",
      "allowed_hosts": ["mywebapp.example.com", "api.mywebapp.example.com"],
      "options": {
        "use_ssl": true,
        "ssl_cert": "/path/to/cert"
      }
    },
    "json_format": "{'test': 1}"
}
```
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="upper",
    naming_case_join_type = ".",
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION.NAME',
     'APPLICATION.VERSION',
     'APPLICATION.ENVIRONMENT',
     'APPLICATION.BASE_URL',
     'APPLICATION.ALLOWED_HOSTS',
     'APPLICATION.OPTIONS.USE_SSL',
     'APPLICATION.OPTIONS.SSL_CERT',
     'JSON_FORMAT']

## Env File Use Case
```
VERSION=2.0
APPLICATION_NAME=MyWebApp
APPLICATION_VERSION=1.2.3
APPLICATION_ENVIRONMENT=production
APPLICATION_BASE_URL=https://mywebapp.example.com
APPLICATION_ALLOWED_HOSTS=mywebapp.example.com,api.mywebapp.example.com
APPLICATION_OPTIONS_USE_SSL=true
APPLICATION_OPTIONS_SSL_CERT=/path/to/cert
JSON_FORMAT="{'test': 1}"
The **is_change_config_env_format** default value is **False**.
```
```python
config.load_config_file(
    file_path="env_config_file.env",
    root_full_path = "./",
    naming_case_type="upper",
    is_change_config_env_format=False,
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION_NAME',
     'APPLICATION_VERSION',
     'APPLICATION_ENVIRONMENT',
     'APPLICATION_BASE_URL',
     'APPLICATION_ALLOWED_HOSTS',
     'APPLICATION_OPTIONS_USE_SSL',
     'APPLICATION_OPTIONS_SSL_CERT',
     'JSON_FORMAT']

The **is_change_config_env_format** is **True**, which changes env format.

The **config_env_replace_first_value** is **"_"**, which replacement value for the first occurrence. 

```python
config.load_config_file(
    file_path="env_config_file.env",
    root_full_path = "./",
    naming_case_type="upper",
    naming_case_join_type=".",
    is_change_config_env_format=True,
    config_env_replace_first_value="_"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION.NAME',
     'APPLICATION.VERSION',
     'APPLICATION.ENVIRONMENT',
     'APPLICATION.BASE.URL',
     'APPLICATION.ALLOWED.HOSTS',
     'APPLICATION.OPTIONS.USE.SSL',
     'APPLICATION.OPTIONS.SSL.CERT',
     'JSON.FORMAT']

## Naming Case Type Use Case

### Pascal Case

```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="pascal"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['Version',
     'ApplicationName',
     'ApplicationVersion',
     'ApplicationEnvironment',
     'ApplicationBase_url',
     'ApplicationAllowed_hosts',
     'ApplicationOptionsUse_ssl',
     'ApplicationOptionsSsl_cert',
     'Json_format']

### Camel Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="camel"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['version',
     'applicationName',
     'applicationVersion',
     'applicationEnvironment',
     'applicationBase_url',
     'applicationAllowed_hosts',
     'applicationOptionsUse_ssl',
     'applicationOptionsSsl_cert',
     'json_format']

### Snake Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="snake"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['applicationOptionsSsl_cert',
     'json_format',
     'application_name',
     'application_version',
     'application_environment',
     'application_base_url',
     'application_allowed_hosts',
     'application_options_use_ssl',
     'application_options_ssl_cert']

### Kebab Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="kebab"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['version',
     'application-name',
     'application-version',
     'application-environment',
     'application-base_url',
     'application-allowed_hosts',
     'application-options-use_ssl',
     'application-options-ssl_cert',
     'json_format']

### Flat Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="flat"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['version',
     'applicationname',
     'applicationversion',
     'applicationenvironment',
     'applicationbase_url',
     'applicationallowed_hosts',
     'applicationoptionsuse_ssl',
     'applicationoptionsssl_cert',
     'json_format']

### Upper-Flat Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="upper-flat"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATIONNAME',
     'APPLICATIONVERSION',
     'APPLICATIONENVIRONMENT',
     'APPLICATIONBASE_URL',
     'APPLICATIONALLOWED_HOSTS',
     'APPLICATIONOPTIONSUSE_SSL',
     'APPLICATIONOPTIONSSSL_CERT',
     'JSON_FORMAT']

### Pascal-Snake Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="pascal-snake"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['Version',
     'Application_Name',
     'Application_Version',
     'Application_Environment',
     'Application_Base_url',
     'Application_Allowed_hosts',
     'Application_Options_Use_ssl',
     'Application_Options_Ssl_cert',
     'Json_format']

### Camel-Snake Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="camel-snake"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['version',
     'application_Name',
     'application_Version',
     'application_Environment',
     'application_Base_url',
     'application_Allowed_hosts',
     'application_Options_Use_ssl',
     'application_Options_Ssl_cert',
     'json_format']

### Screaming-Snake Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="screaming-snake"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION_NAME',
     'APPLICATION_VERSION',
     'APPLICATION_ENVIRONMENT',
     'APPLICATION_BASE_URL',
     'APPLICATION_ALLOWED_HOSTS',
     'APPLICATION_OPTIONS_USE_SSL',
     'APPLICATION_OPTIONS_SSL_CERT',
     'JSON_FORMAT']

### Train Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="train"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['Version',
     'Application-Name',
     'Application-Version',
     'Application-Environment',
     'Application-Base_url',
     'Application-Allowed_hosts',
     'Application-Options-Use_ssl',
     'Application-Options-Ssl_cert',
     'Json_format']

### Cobol Case
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="cobol"
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION-NAME',
     'APPLICATION-VERSION',
     'APPLICATION-ENVIRONMENT',
     'APPLICATION-BASE_URL',
     'APPLICATION-ALLOWED_HOSTS',
     'APPLICATION-OPTIONS-USE_SSL',
     'APPLICATION-OPTIONS-SSL_CERT',
     'JSON_FORMAT']

### Other Case: Upper
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="upper",
    naming_case_join_type = "."
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['VERSION',
     'APPLICATION.NAME',
     'APPLICATION.VERSION',
     'APPLICATION.ENVIRONMENT',
     'APPLICATION.BASE_URL',
     'APPLICATION.ALLOWED_HOSTS',
     'APPLICATION.OPTIONS.USE_SSL',
     'APPLICATION.OPTIONS.SSL_CERT',
     'JSON_FORMAT']

### Other Case: Lower
```python
config.load_config_file(
    file_path="json_config_file.json",
    root_full_path = "./",
    naming_case_type="lower",
    naming_case_join_type = "."
)
```
```python
import os
key_list = list(os.environ.keys())[-9:]
key_list
```
    ['version',
     'application.name',
     'application.version',
     'application.environment',
     'application.base_url',
     'application.allowed_hosts',
     'application.options.use_ssl',
     'application.options.ssl_cert',
     'json_format']

# Get the Value From the 'os.environ' System

**Description**
```
Help on function get in module craftsperson_env.__main__:

get(key: str, value_type: Any = <class 'str'>, default: Any = None) -> str
    This function retrieves the value associated with the key from the 'os.environ' system.
    
    Parameters
    ----------
    key: str
        This parameter retrieves the key from the 'os.environ' system.
    value_type: str, optional.
        This parameter accepts value types such as int, str, list, dict, and others. The default value is str.
    default: Any, optional.
        This parameter retrieves the default value if the key is not found in any environment variables.
            The default is None.
    
    Returns
    -------
    value:
        This returns the value of the given environment variable key.
```

Additionally, it specifies the data type when retrieving data from 'os.environ' to access data of that type. For example, value_type gets int, float, str, dict and other types.

```python
print("boolean:", config.get(key="application.options.use_ssl", value_type=bool, default=None))
print("float:", config.get(key="version", value_type=float, default=None))
print("str:", config.get(key="application.name", value_type=str, default=None))
print("json:", config.get(key="json_format", value_type=dict, default=None))
```
    boolean: True
    float: 2.0
    str: MyWebApp
    json: {'test': 1}


# Set and Update the Value in the 'os.environ' System.

**Description**
```
Help on function set in module craftsperson_env.__main__:

set(key: str, value: str) -> None
    This function sets a key-value pair in the 'os.environ' system.
    
    Parameters
    ----------
    key: str
        This parameter specifies the key to be set as an environment variable.
    value: str
        This parameter specifies the value that will be stored in
            the environment variable identified by the given key.
    
    Returns
    -------
    None.
```

```python
config.set(key="int_value", value="1923")
```
```python
print("int:", config.get(key="int_value", value_type=int, default=None))
```
    int: 1923


# Author's Social Media

* Gmail: celalakcelikk@gmail.com
* Linkedin: https://www.linkedin.com/in/celalakcelik/
* Github: https://github.com/celalakcelikk
* Kaggle: https://www.kaggle.com/celalakcelik


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/celalakcelikk/craftsperson-env",
    "name": "craftsperson-env",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "environment,PyYAML,yaml,toml,env,json,xml,xmltodict,Python,projects,Config,package,packaging",
    "author": "Celal Ak\u00e7elik",
    "author_email": "celalakcelikk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5d/a6/715392741164f3de9a94baddc0851e4d419e312f7f34f45b80b7b44d5e2e/craftsperson-env-1.0.2.tar.gz",
    "platform": null,
    "description": "# Craftsperson Environment\n\n# What is it?\n**craftsperson_env** reads configuration files in **yaml**, **env**, **toml**, **xml**, and **json** formats and adds them to the **'os.environ'** system. It formats the keys according to **naming-case-type**, **upper** or **lower**, and arranges them with a **specific join type in the upper-lower section**. Additionally, it specifies the data type when retrieving data from 'os.environ' to access data of that type.\n\n# Where to get it\nYou can access the <a href=\"https://github.com/celalakcelikk/craftsperson-env\">Github</a> repository from here.\n\nPip installers for the latest released version are available at the <a href=\"https://pypi.org/project/craftsperson-env\">Python Package Index (PyPI)</a>\n\n# Installation\n\n```\npython setup.py install\n```\n```\npip install craftsperson-env\n```\n\n# Import Library\n```python\nfrom craftsperson_env import CraftsEnvConfig\n```\n\n# Create Config Variable\n```python\nconfig = CraftsEnvConfig()\n```\n\n# Load File\n**Description**\n```\nHelp on method load_config_file in module craftsperson_env.main:\n\nload_config_file(file_path: str, root_full_path: str = './', naming_case_type: str = None, naming_case_join_type: str = '', is_change_config_env_format: bool = False, config_env_replace_first_value: str = None, is_remove_xml_first_level: bool = False, extra_config_file_params: dict = {}) method of craftsperson_env.main.CraftsEnvConfig instance\n    This function processes and uses a config file.\n    \n    Parameters\n    ----------\n    file_path : str\n        This parameter specifies the file location path.\n    root_full_path : str, optional\n        This parameter retrieves the full path from the file. The default is './'.\n    naming_case_type : str, optional\n        This parameter specifies naming case types for env, yaml, json, xml, or toml. The default is None.\n    naming_case_join_type : str, optional.\n        This parameter specifies the join type, allowing values such as \"\", \"-\", or \"_\". The default is \"\".\n    is_change_config_env_format: bool, optional.\n        This parameter specifies whether the format of the env config file has been changed.\n            The default value is False.\n    config_env_replace_first_value: str, optional.\n        This parameter specifies the replacement value for the first occurrence. The default is None.\n    is_remove_xml_first_level : bool, optional\n        This parameter determines whether to remove the first level. The default value is False.\n    extra_config_file_params : dict, optional\n        This parameter retrieves additional XML or TOML configuration parameters. The default value is {}.\n    \n    Returns\n    -------\n    None.\n```\n\n## Yaml File Use Case\n```\nversion: 2.0\napplication:\n  name: MyWebApp\n  version: 1.2.3\n  environment: production\n  base_url: \"https://mywebapp.example.com\"\n  allowed_hosts:\n    - mywebapp.example.com\n    - api.mywebapp.example.com\n  options:\n    use_ssl: true\n    ssl_cert: \"/path/to/cert\"\njson_format: \"{'test': 1}\"\n```\n\n```python\nconfig.load_config_file(\n    file_path=\"examples/yaml_config_file.yaml\",\n    root_full_path=\"examples/\",\n    naming_case_type=\"upper\",\n    naming_case_join_type=\".\",\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION.NAME',\n     'APPLICATION.VERSION',\n     'APPLICATION.ENVIRONMENT',\n     'APPLICATION.BASE_URL',\n     'APPLICATION.ALLOWED_HOSTS',\n     'APPLICATION.OPTIONS.USE_SSL',\n     'APPLICATION.OPTIONS.SSL_CERT',\n     'JSON_FORMAT']\n\n## Xml File Use Case\n```\n<config>\n  <version>2.0</version>\n  <application>\n    <name>MyWebApp</name>\n    <version>1.2.3</version>\n    <environment>production</environment>\n    <base_url>https://mywebapp.example.com</base_url>\n    <allowed_hosts>\n      <host>mywebapp.example.com</host>\n      <host>api.mywebapp.example.com</host>\n    </allowed_hosts>\n    <options>\n      <use_ssl>true</use_ssl>\n      <ssl_cert>/path/to/cert</ssl_cert>\n    </options>\n  </application>\n  <json_format>\n    {'test': 1}\n  </json_format>\n</config>\n```\nThe **is_remove_xml_first_level** default value is **False**.\n```python\nconfig.load_config_file(\n    file_path=\"xml_config_file.xml\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    naming_case_join_type = \".\",\n    is_remove_xml_first_level=False,\n    extra_config_file_params={}\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['CONFIG.VERSION',\n     'CONFIG.APPLICATION.NAME',\n     'CONFIG.APPLICATION.VERSION',\n     'CONFIG.APPLICATION.ENVIRONMENT',\n     'CONFIG.APPLICATION.BASE_URL',\n     'CONFIG.APPLICATION.ALLOWED_HOSTS.HOST',\n     'CONFIG.APPLICATION.OPTIONS.USE_SSL',\n     'CONFIG.APPLICATION.OPTIONS.SSL_CERT',\n     'CONFIG.JSON_FORMAT']\nThe **is_remove_xml_first_level** is **True**, which removes the first level.\n```python\nconfig.load_config_file(\n    file_path=\"xml_config_file.xml\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    naming_case_join_type = \".\",\n    is_remove_xml_first_level=True,\n    extra_config_file_params={}\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['CONFIG.APPLICATION.NAME',\n     'CONFIG.APPLICATION.VERSION',\n     'CONFIG.APPLICATION.ENVIRONMENT',\n     'CONFIG.APPLICATION.BASE_URL',\n     'CONFIG.APPLICATION.ALLOWED_HOSTS.HOST',\n     'CONFIG.APPLICATION.OPTIONS.USE_SSL',\n     'CONFIG.APPLICATION.OPTIONS.SSL_CERT',\n     'CONFIG.JSON_FORMAT',\n     'APPLICATION.ALLOWED_HOSTS.HOST']\n\n## Toml File Use Case\n```\nversion = \"2.0\"\njson_format = \"{'test': 1}\"\n\n[application]\nname = \"MyWebApp\"\nversion = \"1.2.3\"\nenvironment = \"production\"\nbase_url = \"https://mywebapp.example.com\"\nallowed_hosts = [\"mywebapp.example.com\", \"api.mywebapp.example.com\"]\n\n[application.options]\nuse_ssl = true\nssl_cert = \"/path/to/cert\"\n```\n```python\nconfig.load_config_file(\n    file_path=\"toml_config_file.toml\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    naming_case_join_type = \".\",\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'JSON_FORMAT',\n     'APPLICATION.NAME',\n     'APPLICATION.VERSION',\n     'APPLICATION.ENVIRONMENT',\n     'APPLICATION.BASE_URL',\n     'APPLICATION.ALLOWED_HOSTS',\n     'APPLICATION.OPTIONS.USE_SSL',\n     'APPLICATION.OPTIONS.SSL_CERT']\n\n## Json File Use Case\n```\n{\n    \"version\": \"2.0\",\n    \"application\": {\n      \"name\": \"MyWebApp\",\n      \"version\": \"1.2.3\",\n      \"environment\": \"production\",\n      \"base_url\": \"https://mywebapp.example.com\",\n      \"allowed_hosts\": [\"mywebapp.example.com\", \"api.mywebapp.example.com\"],\n      \"options\": {\n        \"use_ssl\": true,\n        \"ssl_cert\": \"/path/to/cert\"\n      }\n    },\n    \"json_format\": \"{'test': 1}\"\n}\n```\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    naming_case_join_type = \".\",\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION.NAME',\n     'APPLICATION.VERSION',\n     'APPLICATION.ENVIRONMENT',\n     'APPLICATION.BASE_URL',\n     'APPLICATION.ALLOWED_HOSTS',\n     'APPLICATION.OPTIONS.USE_SSL',\n     'APPLICATION.OPTIONS.SSL_CERT',\n     'JSON_FORMAT']\n\n## Env File Use Case\n```\nVERSION=2.0\nAPPLICATION_NAME=MyWebApp\nAPPLICATION_VERSION=1.2.3\nAPPLICATION_ENVIRONMENT=production\nAPPLICATION_BASE_URL=https://mywebapp.example.com\nAPPLICATION_ALLOWED_HOSTS=mywebapp.example.com,api.mywebapp.example.com\nAPPLICATION_OPTIONS_USE_SSL=true\nAPPLICATION_OPTIONS_SSL_CERT=/path/to/cert\nJSON_FORMAT=\"{'test': 1}\"\nThe **is_change_config_env_format** default value is **False**.\n```\n```python\nconfig.load_config_file(\n    file_path=\"env_config_file.env\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    is_change_config_env_format=False,\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION_NAME',\n     'APPLICATION_VERSION',\n     'APPLICATION_ENVIRONMENT',\n     'APPLICATION_BASE_URL',\n     'APPLICATION_ALLOWED_HOSTS',\n     'APPLICATION_OPTIONS_USE_SSL',\n     'APPLICATION_OPTIONS_SSL_CERT',\n     'JSON_FORMAT']\n\nThe **is_change_config_env_format** is **True**, which changes env format.\n\nThe **config_env_replace_first_value** is **\"_\"**, which replacement value for the first occurrence. \n\n```python\nconfig.load_config_file(\n    file_path=\"env_config_file.env\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    naming_case_join_type=\".\",\n    is_change_config_env_format=True,\n    config_env_replace_first_value=\"_\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION.NAME',\n     'APPLICATION.VERSION',\n     'APPLICATION.ENVIRONMENT',\n     'APPLICATION.BASE.URL',\n     'APPLICATION.ALLOWED.HOSTS',\n     'APPLICATION.OPTIONS.USE.SSL',\n     'APPLICATION.OPTIONS.SSL.CERT',\n     'JSON.FORMAT']\n\n## Naming Case Type Use Case\n\n### Pascal Case\n\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"pascal\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['Version',\n     'ApplicationName',\n     'ApplicationVersion',\n     'ApplicationEnvironment',\n     'ApplicationBase_url',\n     'ApplicationAllowed_hosts',\n     'ApplicationOptionsUse_ssl',\n     'ApplicationOptionsSsl_cert',\n     'Json_format']\n\n### Camel Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"camel\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['version',\n     'applicationName',\n     'applicationVersion',\n     'applicationEnvironment',\n     'applicationBase_url',\n     'applicationAllowed_hosts',\n     'applicationOptionsUse_ssl',\n     'applicationOptionsSsl_cert',\n     'json_format']\n\n### Snake Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"snake\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['applicationOptionsSsl_cert',\n     'json_format',\n     'application_name',\n     'application_version',\n     'application_environment',\n     'application_base_url',\n     'application_allowed_hosts',\n     'application_options_use_ssl',\n     'application_options_ssl_cert']\n\n### Kebab Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"kebab\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['version',\n     'application-name',\n     'application-version',\n     'application-environment',\n     'application-base_url',\n     'application-allowed_hosts',\n     'application-options-use_ssl',\n     'application-options-ssl_cert',\n     'json_format']\n\n### Flat Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"flat\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['version',\n     'applicationname',\n     'applicationversion',\n     'applicationenvironment',\n     'applicationbase_url',\n     'applicationallowed_hosts',\n     'applicationoptionsuse_ssl',\n     'applicationoptionsssl_cert',\n     'json_format']\n\n### Upper-Flat Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper-flat\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATIONNAME',\n     'APPLICATIONVERSION',\n     'APPLICATIONENVIRONMENT',\n     'APPLICATIONBASE_URL',\n     'APPLICATIONALLOWED_HOSTS',\n     'APPLICATIONOPTIONSUSE_SSL',\n     'APPLICATIONOPTIONSSSL_CERT',\n     'JSON_FORMAT']\n\n### Pascal-Snake Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"pascal-snake\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['Version',\n     'Application_Name',\n     'Application_Version',\n     'Application_Environment',\n     'Application_Base_url',\n     'Application_Allowed_hosts',\n     'Application_Options_Use_ssl',\n     'Application_Options_Ssl_cert',\n     'Json_format']\n\n### Camel-Snake Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"camel-snake\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['version',\n     'application_Name',\n     'application_Version',\n     'application_Environment',\n     'application_Base_url',\n     'application_Allowed_hosts',\n     'application_Options_Use_ssl',\n     'application_Options_Ssl_cert',\n     'json_format']\n\n### Screaming-Snake Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"screaming-snake\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION_NAME',\n     'APPLICATION_VERSION',\n     'APPLICATION_ENVIRONMENT',\n     'APPLICATION_BASE_URL',\n     'APPLICATION_ALLOWED_HOSTS',\n     'APPLICATION_OPTIONS_USE_SSL',\n     'APPLICATION_OPTIONS_SSL_CERT',\n     'JSON_FORMAT']\n\n### Train Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"train\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['Version',\n     'Application-Name',\n     'Application-Version',\n     'Application-Environment',\n     'Application-Base_url',\n     'Application-Allowed_hosts',\n     'Application-Options-Use_ssl',\n     'Application-Options-Ssl_cert',\n     'Json_format']\n\n### Cobol Case\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"cobol\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION-NAME',\n     'APPLICATION-VERSION',\n     'APPLICATION-ENVIRONMENT',\n     'APPLICATION-BASE_URL',\n     'APPLICATION-ALLOWED_HOSTS',\n     'APPLICATION-OPTIONS-USE_SSL',\n     'APPLICATION-OPTIONS-SSL_CERT',\n     'JSON_FORMAT']\n\n### Other Case: Upper\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"upper\",\n    naming_case_join_type = \".\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['VERSION',\n     'APPLICATION.NAME',\n     'APPLICATION.VERSION',\n     'APPLICATION.ENVIRONMENT',\n     'APPLICATION.BASE_URL',\n     'APPLICATION.ALLOWED_HOSTS',\n     'APPLICATION.OPTIONS.USE_SSL',\n     'APPLICATION.OPTIONS.SSL_CERT',\n     'JSON_FORMAT']\n\n### Other Case: Lower\n```python\nconfig.load_config_file(\n    file_path=\"json_config_file.json\",\n    root_full_path = \"./\",\n    naming_case_type=\"lower\",\n    naming_case_join_type = \".\"\n)\n```\n```python\nimport os\nkey_list = list(os.environ.keys())[-9:]\nkey_list\n```\n    ['version',\n     'application.name',\n     'application.version',\n     'application.environment',\n     'application.base_url',\n     'application.allowed_hosts',\n     'application.options.use_ssl',\n     'application.options.ssl_cert',\n     'json_format']\n\n# Get the Value From the 'os.environ' System\n\n**Description**\n```\nHelp on function get in module craftsperson_env.__main__:\n\nget(key: str, value_type: Any = <class 'str'>, default: Any = None) -> str\n    This function retrieves the value associated with the key from the 'os.environ' system.\n    \n    Parameters\n    ----------\n    key: str\n        This parameter retrieves the key from the 'os.environ' system.\n    value_type: str, optional.\n        This parameter accepts value types such as int, str, list, dict, and others. The default value is str.\n    default: Any, optional.\n        This parameter retrieves the default value if the key is not found in any environment variables.\n            The default is None.\n    \n    Returns\n    -------\n    value:\n        This returns the value of the given environment variable key.\n```\n\nAdditionally, it specifies the data type when retrieving data from 'os.environ' to access data of that type. For example, value_type gets int, float, str, dict and other types.\n\n```python\nprint(\"boolean:\", config.get(key=\"application.options.use_ssl\", value_type=bool, default=None))\nprint(\"float:\", config.get(key=\"version\", value_type=float, default=None))\nprint(\"str:\", config.get(key=\"application.name\", value_type=str, default=None))\nprint(\"json:\", config.get(key=\"json_format\", value_type=dict, default=None))\n```\n    boolean: True\n    float: 2.0\n    str: MyWebApp\n    json: {'test': 1}\n\n\n# Set and Update the Value in the 'os.environ' System.\n\n**Description**\n```\nHelp on function set in module craftsperson_env.__main__:\n\nset(key: str, value: str) -> None\n    This function sets a key-value pair in the 'os.environ' system.\n    \n    Parameters\n    ----------\n    key: str\n        This parameter specifies the key to be set as an environment variable.\n    value: str\n        This parameter specifies the value that will be stored in\n            the environment variable identified by the given key.\n    \n    Returns\n    -------\n    None.\n```\n\n```python\nconfig.set(key=\"int_value\", value=\"1923\")\n```\n```python\nprint(\"int:\", config.get(key=\"int_value\", value_type=int, default=None))\n```\n    int: 1923\n\n\n# Author's Social Media\n\n* Gmail: celalakcelikk@gmail.com\n* Linkedin: https://www.linkedin.com/in/celalakcelik/\n* Github: https://github.com/celalakcelikk\n* Kaggle: https://www.kaggle.com/celalakcelik\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/celalakcelikk/craftsperson-env"
    },
    "split_keywords": [
        "environment",
        "pyyaml",
        "yaml",
        "toml",
        "env",
        "json",
        "xml",
        "xmltodict",
        "python",
        "projects",
        "config",
        "package",
        "packaging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68997fd0db81612ce421cc4c4ddd364d231b8635069d0795714af6a682f45023",
                "md5": "8bfccedd411a4da7e72d55cd6f117187",
                "sha256": "d7b8bf83ed9f437b049fa5df08e3e92738254913767c0cda9eac5e70547292a5"
            },
            "downloads": -1,
            "filename": "craftsperson_env-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8bfccedd411a4da7e72d55cd6f117187",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9090,
            "upload_time": "2024-02-28T08:07:59",
            "upload_time_iso_8601": "2024-02-28T08:07:59.396931Z",
            "url": "https://files.pythonhosted.org/packages/68/99/7fd0db81612ce421cc4c4ddd364d231b8635069d0795714af6a682f45023/craftsperson_env-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5da6715392741164f3de9a94baddc0851e4d419e312f7f34f45b80b7b44d5e2e",
                "md5": "47a50da9993d60e735fdc17c32cabcbb",
                "sha256": "8ca960f1bff12db6bbb65521a7561f77bc77c5286976278969a2ac2e77ded162"
            },
            "downloads": -1,
            "filename": "craftsperson-env-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "47a50da9993d60e735fdc17c32cabcbb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11146,
            "upload_time": "2024-02-28T08:08:01",
            "upload_time_iso_8601": "2024-02-28T08:08:01.630950Z",
            "url": "https://files.pythonhosted.org/packages/5d/a6/715392741164f3de9a94baddc0851e4d419e312f7f34f45b80b7b44d5e2e/craftsperson-env-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-28 08:08:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "celalakcelikk",
    "github_project": "craftsperson-env",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "craftsperson-env"
}
        
Elapsed time: 0.24427s