🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

confcogs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confcogs

Lib for managing .cogs file

pipPyPI
Version
0.1.0
Maintainers
1

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')  # Output: 'True'

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)  # Output: {'loaded': 'True'}

Example

Here’s a complete example:

import confcogs

path = 'settings/load.cogs'

# Add key-value pairs
confcogs.acog(path, 'loaded', 'True')
confcogs.acog(path, 'debug', 'False')

# Fetch a value
print(confcogs.fcog(path, 'loaded'))  # Output: True

# Edit a value
confcogs.ecog(path, 'debug', 'True')

# Remove a key
confcogs.rcog(path, 'debug')

# Load all configurations
print(confcogs.lcog(path))  # Output: {'loaded': 'True'}

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts