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.4.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.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyfigure-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 51a20f70c958fd11226d368a5309173d5bf9851092c63e82a1858891730d0451
MD5 040ef9b81afcaccdc107e5136073de39
BLAKE2b-256 8120f07d9410ef48a785f8a18100f6aacdb2b9299c75695486a74846dc46da5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyfigure-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 2.9 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4023902217e9f5c4d6e7ab3629c63b4591dfc69090ba3bce2f80cb1d4c45b17e
MD5 905b46dd518d269119dda4dd4e0fbdeb
BLAKE2b-256 791b787469835f7fcf78251f658e5051b0dbc73dfa240e95c302d2538edaa554

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