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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyfigure-1.0.0.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/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for pyfigure-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c01c98573941ddcf88740b8dfcbe43f43d93a9e7878921836fdb3d73ce63a639
MD5 59c9928f159e6f6bbde402f17d4393ed
BLAKE2b-256 3921027ce05bf48dfa16cefe027ec5cfc0e0ae9506349e7b99eaace86a63ab63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyfigure-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for pyfigure-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b0a9f362ec04f302a3248f8c8d3ca9315e2180c535e0061c040321f272c1ff6
MD5 dd2f252db7b45adc980ec40a254b5af8
BLAKE2b-256 2320576526acff6147f6163ddd3500da5ae2f35c79bc67e7b1084e8b8c84b688

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