Skip to main content

Generate configuration files for classes.

Project description

pyfigure

Generate configuration files for classes.

Installation

pip install pyfigure

Usage

To generate a configuration file for a class, you must extend the class with Configurable, from the pyfigure module.

Then, to add options to the configuration, create a new Config class, and add variables of the Option class.

option_name: Option(
    default,
    type,
    parse,
    description,
)

Where the arguments are as follows:

argument description default value
default The default value of the option n/a
type The python type the option is str
parse A function that parses the given value, returns a new value or throws an exception lambda x: x
description A comment to explain what the option is for n/a

file.py

from pyfigure import Configurable, Option

class SomeClass(Configurable):

    class Config:
        string_option: Option("default", str, description="Any string works here.")
        integer_option: Option(24, int, description="Any integer here.")
        float_option: Option(15.55, float, description="Any float.")
    
    def __init__(self):
        super().__init__()
        print(self.config)
        # {'string_option': 'default', 'integer_option': 24, 'float_option': 15.55}

SomeClass()

This class, when initialized, will create a new file named:

file.toml

string_option = "default" # Any string works here.
integer_option = 24 # Any integer here.
float_option = 15.55 # Any float.

Need to place the file at a different location? Simply pass an argument in the super().__init__() function.

def __init__(self):
    super().__init__('new/location/file.toml')

To-Do

  • Rework the type checking system to utilize the typing library (Somehow).
  • Support nested dictionaries.

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

pyfigure-1.0.3.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.

pyfigure-1.0.3-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file pyfigure-1.0.3.tar.gz.

File metadata

  • Download URL: pyfigure-1.0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pyfigure-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ea3362946d3a50e202be6f45a744d6ffe2d95202e877bd95502ce981d55f582c
MD5 e26fc1eb00de50998f86f4d0cf7b4d35
BLAKE2b-256 e5ca46ae440ea2a3ef9944bba77ad41d946dbb1162cb56455ff8fe6085b9611e

See more details on using hashes here.

File details

Details for the file pyfigure-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyfigure-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pyfigure-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1a580f1eafdfdfae39348a928244258b02f32136798f6b834395f950009a4429
MD5 550da6cd6c3c301e6619594cff9e65cb
BLAKE2b-256 59bb275e2f3bdbb4d9810ff3b200436290e03812d84c5a1d80cac39b4226c7ce

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