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.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyfigure-1.0.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pyfigure-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1d73fbb505bdd462a1d5685fd97104b48a9da71ea33f95b3860dd101128b03f7
MD5 136111923ed845fab49bc33f18e05e7e
BLAKE2b-256 2d1b8fbd745a435a9c90a045d034081b7bc569ee09b293da5db6552b5e7fd1d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyfigure-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pyfigure-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 353861a539b0925e81a09f2dbf24ee6b69d4ba2fd006a3d14db83ab3e4bd7c38
MD5 74c73b61fa789e6004676b7a54d84e1b
BLAKE2b-256 703831808429f688a053f5205c71540a6bf35afc8693673879f9717a54223ded

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