Skip to main content

fejao-config-parser

PyPI version License Pipeline Coverage CVE Scan

This is a package for setting up the variables that you need to you on your project from a list of dictionaries.

I was tired of everytime that I needed to set a project that should have input/variables to be set from a configuration file, environment variables or from terminal to write this code again and again. Then the unit-test , lint, pep. And so on and on...

I hope that you also find this tiredsome work not needed anymore from using this package.

  • Links

  • Installing

    For using this package you need to install it with:

    pip install fejao-config-parser
    

    You can import it to your code with:

    from fejao_config_parser import my_config
    
  • Configuration

    • Structure

      You need to set a list of dictionaries such as:

      example_vaviables = [
        {
          <VARIABLE_1_CONFIGURATION>
        },
        {
          <VARIABLE_2_CONFIGURATION>
        },
        ...
        ...
        ...
        {
          <VARIABLE_N_CONFIGURATION>
        }
      ]
      
    • Dictionary entry for a variable

      Dictionary keys for setting a variable are:

      • name
        • The name of the variable that will be accessed at your project
        • This key is required to be set.
      • type
        • The type of this variable to be set, it will type-cast it as the type set here.
        • This key is required to be set.
        • Possible type of variables:
          • string
          • bool
          • int
          • float
          • list
          • dict
      • default
        • The default value of the variable to be set if any other methods were parsed.
        • This key is required to be set.
      • env_name
        • The name of the environment variable that should be read.
        • This key is NOT required to be set.
      • terminal_help
        • The name of the environment variable that should be read.
        • This key is NOT required to be set.
      • terminal_name
        • The variable name to be read from terminal. Example: example_string, it can be parsed at the terminal like --example_string <VAR_VALUE>
        • This key is NOT required to be set.
      • terminal_name_short
        • The variable short name to be read from terminal. Example: es, it can be parsed at the terminal like -es <VAR_VALUE>
        • This key is NOT required to be set.
    • Example

      example_variables = [
          {
            "name": "example_string",
            "type": "string",
            "default": "default_string_value",
            "env_name": "EXAMPLE_STRING",
            "terminal_help": "Example of a string terminal variable.",
            "terminal_name": "example_string",
            "terminal_name_short": "es",
          },
          {
            "name": "example_bool",
            "type": "bool",
            "default": False,
            "terminal_help": "Example of a boolean terminal variable.",
            "terminal_name": "example_bool",
            "terminal_name_short": "eb",
          },
          {
            "name": "example_int",
            "type": "int",
            "default": 42,
            "env_name": "EXAMPLE_INT",
          },
          {
            "name": "example_float",
            "type": "float",
            "default": 4.2,
          },
          {
            "name": "example_list",
            "type": "list",
            "default": ["1", "2", "3"],
            "env_name": "EXAMPLE_LIST",
            "terminal_help": "Example of a list terminal variable.",
            "terminal_name": "example_list",
            "terminal_name_short": "el",
          },
          {
            "name": "example_dictionary",
            "type": "dict",
            "default": {"key1": "value1", "key2": "value2"},
            "env_name": "EXAMPLE_DICTIONARY",
            "terminal_help": "Example of a dictionary terminal variable.",
            "terminal_name": "example_dictionary",
            "terminal_name_short": "ed",
          },
      ]
      
  • How to use it

    For calling the my_config function the possible keys are:

    • config

      • The list of dictionaries to be set as variables.
      • This key is required to be set.
    • config_file

      • The path of the configuration file to be used for reading the variables values.
      • This key is NOT required to be set.
      • Type of files that can be parsed:
        • yaml
        • json
        • toml
        • ini
          • Values should be set at the [default] section
          • Still don't know how till this date people keep using ini files.
    • description

      • Description of you project when running on terminal with the '--help' output.
      • This key is NOT required to be set.
    • debug

      • Boolean of setting up the output in terminal from the variables that were set using the package.
      • This key is NOT required to be set.
    • Example

      config = my_config(
        config=example_variables,
        config_file="/tmp/foo.yaml",
        description="My project is AMAZING and not done with vibe-coding",
        debug=True
      )
      
    • Accessing the variables

      For accessing the variables is easy as:

      from fejao_config_parser import my_config
      
      example_variables = [
          {
            "name": "example_string",
            "type": "string",
            "default": "default_string_value",
            "env_name": "EXAMPLE_STRING",
          }
      ]
      config = my_config(config=example_variables)
      
      print(f"example_string: {config.example_string}")
      ---> default_string_value
      
  • To Do

    This package at the moment it's not finished yet, just trying to publish on pypi.org at the moment

    • Finish README_PACKAGE.md file (The one to be publish on pypi.org)
    • Add the package code to git
    • Add lint tests
    • Add pep tests
    • Add unit-test
    • Document the code (for generating the mkdocs)
    • Add repository badges to the PyPi page
    • CI-CD for
      • testing
      • CVE tests
      • building
      • generate documentation
      • auto publishing
        • readthedocs
        • pypi

Download files

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

Source Distribution

fejao_config_parser-0.0.17.tar.gz (63.0 kB view details)

Uploaded Source

Built Distribution

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

fejao_config_parser-0.0.17-py3-none-any.whl (80.9 kB view details)

Uploaded Python 3

File details

Details for the file fejao_config_parser-0.0.17.tar.gz.

File metadata

  • Download URL: fejao_config_parser-0.0.17.tar.gz
  • Upload date:
  • Size: 63.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.10.15

File hashes

Hashes for fejao_config_parser-0.0.17.tar.gz
Algorithm Hash digest
SHA256 03f5130e3b3e0edd7e0592c97b65af0f11bb874743bff70b114c974f122aa8cd
MD5 fb58d041adbbcac3341fcf262c691f24
BLAKE2b-256 7997c53495731371c0e9dda067819f7890aaf8e5f7566c379ac0eb1181663cac

See more details on using hashes here.

File details

Details for the file fejao_config_parser-0.0.17-py3-none-any.whl.

File metadata

File hashes

Hashes for fejao_config_parser-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 29cacd7a0d1a0e5ef6348dc0133315e0727e945582a308c4ed7ec4a9c0830177
MD5 9bc501dfd0ca602a55947b6713cb4b07
BLAKE2b-256 27ae2184c1dac29f54595aa28ef7ba0d21e0b089bb4b60df02a5fe936d3d7ce3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.18

2 files

This release

0.0.17 This release

2 files

0.0.16

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

1 file

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

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