A simple feature managment tool library
Project description
pyconfix
pyconfix is a Python-based configuration management tool with a text-based user interface built using curses. It allows you to manage complex configurations, including nested groups and dependencies between options. This library aims to provide a more user-friendly, configurable, and expandable alternative to menuconfig.
Features
- Load and save configurations from JSON files
- Support for multiple option types: boolean, integer, string, multiple choice, and groups
- Search functionality to quickly find and modify options
- Dependencies between options to control visibility and availability
Installation
Clone the repository and navigate to the project directory:
git clone https://github.com/NemesisWasAlienToo/pyconfix.git
cd pyconfix
Install the required dependencies (if any). This project uses standard libraries, so no additional dependencies are required.
Usage
Run the pyconfix by executing the pyconfix.py script:
python example.py
JSON Configuration Example
The configuration is defined in JSON format. Here is an example of a configuration file (config.json):
{
"name": "Main Config",
"options": [
{
"name": "Enable Feature A",
"type": "bool",
"default": true,
"dependencies": []
},
{
"name": "LogLevel",
"type": "multiple_choice",
"default": 1,
"choices": ["DEBUG", "INFO", "WARN", "ERROR"],
"dependencies": [
"Enable Feature A"
]
},
{
"name": "Feature A Level",
"type": "int",
"default": 0,
"dependencies": [
"Enable Feature A"
]
},
{
"name": "Feature S Level",
"type": "string",
"default": "Hello",
"dependencies": [
"Enable Feature A"
]
},
{
"name": "Group 1",
"type": "group",
"default": [],
"dependencies": [
"Enable Feature A"
],
"options": [
{
"name": "Enable Sub Feature B",
"type": "bool",
"default": false,
"dependencies": []
},
{
"name": "Group 2",
"type": "group",
"default": [],
"dependencies": [],
"options": [
{
"name": "Enable Sub Feature C",
"type": "bool",
"default": false,
"dependencies": []
}
]
}
]
}
],
"include": [
"extra_config.json"
]
}
Configuration Fields Breakdown
-
name: The name of the configuration.
"name": "Main Config"
-
options: A list of configuration options.
- name: The name of the option.
- type: The type of the option (
bool,int,string,multiple_choice,group). - default: The default value of the option.
- dependencies: A list of dependencies. The option is visible and available only if all dependencies are met.
- choices: For
multiple_choiceoptions, a list of possible choices. - options: For
groupoptions, a list of sub-options.
Example:
{ "name": "Enable Feature A", "type": "bool", "default": true, "dependencies": [] }
-
include: A list of additional JSON files to include.
"include": [ "extra_config.json" ]
Adding New Options
To add new options, you can define them in the options list within the configuration JSON file. Here are the types of options you can add:
Boolean Option
Represents a boolean value (true/false).
{
"name": "Enable Feature X",
"type": "bool",
"default": false,
"dependencies": []
}
Integer Option
Represents an integer value.
{
"name": "Feature X Level",
"type": "int",
"default": 0,
"dependencies": []
}
String Option
Represents a string value.
{
"name": "Feature X Name",
"type": "string",
"default": "Default Name",
"dependencies": []
}
Multiple Choice Option
Represents a choice from a predefined list of values.
{
"name": "LogLevel",
"type": "multiple_choice",
"default": 1,
"choices": ["DEBUG", "INFO", "WARN", "ERROR"],
"dependencies": []
}
Group Option
Represents a group of nested options.
{
"name": "Group X",
"type": "group",
"default": [],
"dependencies": [],
"options": [
{
"name": "Enable Sub Feature Y",
"type": "bool",
"default": false,
"dependencies": []
}
]
}
Example Code
Here's an example of how to define a custom save function and run the pyconfix:
import json
import library.pyconfix as pyconfix
def main():
def custom_save(config_data):
with open("custom_output_config.json", 'w') as f:
json.dump(config_data, f, indent=4)
print("Custom config saved")
config = pyconfix.pyconfix(config_files=["config.json"], custom_save_func=custom_save)
config.run()
if __name__ == "__main__":
main()
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
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 pyconfix-0.3.3.tar.gz.
File metadata
- Download URL: pyconfix-0.3.3.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e42ddf034e002b4cbd186fefea6530de8577d730fd1f551ef86343c5c72e90b
|
|
| MD5 |
1b5a27c1fac55b23d6a486850da1c8a7
|
|
| BLAKE2b-256 |
b9703aeb0105fa171ed241fa17e5c1a4e63db4d2aa60c0494f6e7c49c75cddc6
|
File details
Details for the file pyconfix-0.3.3-py3-none-any.whl.
File metadata
- Download URL: pyconfix-0.3.3-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82d5ee463cbaae19f1256f7993f95ecbc1089f33a06131d700dd8a5541ffee02
|
|
| MD5 |
5a527cd9f50ffe71185ae21c4d14f346
|
|
| BLAKE2b-256 |
ee3a5ba8fa2097d1cdeb79218fb9f240903e2fa816186e28eb53cee1aeb9a97f
|