confcogs
confcogs is a lightweight Python library for managing .cogs configuration files. It allows you to easily add, edit, fetch, and remove key-value pairs in .cogs files.
Installation
Install confcogs using pip:
pip install confcogs
Usage
Import the Library
import confcogs
Setting the Path
Set the path to your .cogs file:
path = 'settings/load.cogs'
Adding Key-Value Pairs
Add new key-value pairs:
confcogs.acog(path, 'loaded', 'True')
confcogs.acog(path, 'debug', 'False')
Fetching a Value
Retrieve a value from the .cogs file:
value = confcogs.fcog(path, 'loaded')
Editing a Value
Edit an existing value:
confcogs.ecog(path, 'debug', 'True')
Removing a Key
Remove a key-value pair:
confcogs.rcog(path, 'debug')
Loading All Configurations
Load the entire .cogs file as a dictionary:
config = confcogs.lcog(path)
Example
Here’s a complete example:
import confcogs
path = 'settings/load.cogs'
confcogs.acog(path, 'loaded', 'True')
confcogs.acog(path, 'debug', 'False')
print(confcogs.fcog(path, 'loaded'))
confcogs.ecog(path, 'debug', 'True')
confcogs.rcog(path, 'debug')
print(confcogs.lcog(path))
File Format
.cogs files use a simple key-value format:
key: 'value';
Example:
loaded: 'True';
debug: 'False';
License
This project is licensed under the MIT License. See the LICENSE file for details.