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
typinglibrary. Somehow.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfigure-1.0.1.tar.gz.
File metadata
- Download URL: pyfigure-1.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e29294ba60caa70cc7d57c207afca16a880d0ee59252bf2ff0c1e1a53f24668
|
|
| MD5 |
9b859dd2500d798fab0e75efb0bb5cc6
|
|
| BLAKE2b-256 |
f1845c6932100c4a9348875e86322600207577708a3e4e411ab22167e4160020
|
File details
Details for the file pyfigure-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pyfigure-1.0.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
561b4a8b669c87ab6617c582e30222df9e70df112fd6e43d7826a0b884ee0fc1
|
|
| MD5 |
5b81b794d86c5d5d8b2d8fcf7588231f
|
|
| BLAKE2b-256 |
640138ffd3fc08f62f87c051228ca1da7b1f9fecab7a3d850e4d83f517093293
|