NekoConf - A cute configuration manager for your JSON and YAML configuration files
Project description
NekoConf
NekoConf is a configuration management system for Python applications that provides a modern web UI, real-time updates, and a simple API for integration.
Table of Contents
Features
-
Configuration Management
- Support for YAML and JSON formats
- Dot notation access to nested values (e.g.,
server.host) - Deep merge updates for nested configurations
- Schema validation
-
Web UI
- Form-based visual editor
- JSON/YAML editors with syntax highlighting
- Real-time updates via WebSockets
- Dark and light theme support
-
Real-time Updates
- Observe configuration changes with callbacks
- Support for both synchronous and asynchronous observers
- WebSocket-based real-time notifications
-
Developer-Friendly API
- Simple Python API for integration
- Type-safe configuration access
- Async/await support
-
Authentication Support
- Secure web UI and API with API key protection
Installation
pip install nekoconf
or build from source
pip install -e .
Quick Start
Web UI
Start the web server to manage your configuration through a browser:
nekoconf server --config config.yaml
This starts a web server at http://127.0.0.1:8000 where you can view and edit your configuration.
Web UI Screenshots
NekoConf features a modern web interface with both dark and light themes:
Dark Theme
Light Theme
Command Line Interface
# View a configuration
nekoconf get --config config.yaml server.host
# Update a value
nekoconf set --config config.yaml server.port 8080
# Delete a value
nekoconf delete --config config.yaml unused.feature
# Import from another file
nekoconf import --config config.yaml other_config.json
# Create a new empty configuration file
nekoconf init --config new_config.yaml
# Validate against a schema
nekoconf validate --config config.yaml --schema schema.json
Python API
from nekoconf import NekoConfigClient
# Initialize with your configuration file
config = NekoConfigClient("config.yaml")
# Get values with type safety
host = config.get_str("server.host", "localhost")
port = config.get_int("server.port", 8080)
debug = config.get_bool("server.debug", False)
# Update values
config.set("server.host", "127.0.0.1")
# Observe changes
def on_config_change(config_data):
print("Configuration changed:", config_data)
config.observe(on_config_change)
Advanced Usage
Async Support
NekoConf supports asynchronous observers for configuration changes:
import asyncio
from nekoconf import NekoConfigClient
async def async_observer(config_data):
print("Configuration changed!")
await asyncio.sleep(0.1) # Async processing
print(f"Processed: {config_data}")
async def main():
config = NekoConfigClient("config.yaml")
config.observe(async_observer)
# Make a change
config.set("server.port", 9000)
# Wait for processing
await asyncio.sleep(0.2)
asyncio.run(main())
Schema Validation
Validate your configuration against a schema:
from nekoconf import NekoConfigClient
# Initialize with a schema
config = NekoConfigClient("config.yaml", schema_path="schema.json")
# Validate configuration
errors = config.validate()
if errors:
print("Validation errors:", errors)
Bulk Updates
Update multiple values at once:
from nekoconf import NekoConfigClient
config = NekoConfigClient("config.yaml")
# Update multiple values with deep merge
config.update({
"server": {
"host": "127.0.0.1",
"port": 9000
}
})
Framework Integration
FastAPI Example
from fastapi import FastAPI, Depends
from nekoconf import NekoConfigClient
app = FastAPI()
config = NekoConfigClient("config.yaml")
def get_config():
return config
@app.get("/api/config")
def read_config(config=Depends(get_config)):
return config.get_all()
Flask Example
from flask import Flask
from nekoconf import NekoConfigClient
app = Flask(__name__)
config = NekoConfigClient("config.yaml")
# Update Flask config when NekoConf changes
def sync_flask_config(config_data):
app.config.update(config_data)
config.observe(sync_flask_config)
Django Example
from django.apps import AppConfig
from nekoconf import NekoConfigClient
class MyAppConfig(AppConfig):
name = 'myapp'
def ready(self):
from django.conf import settings
config = NekoConfigClient("config.yaml")
# Update Django settings when configuration changes
def update_settings(config_data):
for key, value in config_data.items():
if hasattr(settings, key.upper()):
setattr(settings, key.upper(), value)
config.observe(update_settings)
API Reference
NekoConfigClient
The main interface for applications to interact with configuration:
# Core methods
config.get(key, default=None) # Get any value
config.get_str(key, default=None) # Get string value
config.get_int(key, default=None) # Get integer value
config.get_bool(key, default=None) # Get boolean value
config.get_float(key, default=None) # Get float value
config.get_dict(key, default=None) # Get dictionary value
config.get_list(key, default=None) # Get list value
# Update methods
config.set(key, value) # Set a value
config.delete(key) # Delete a value
config.update(data, deep_merge=True) # Update multiple values
# Observer pattern
config.observe(callback) # Register change observer
config.stop_observing(callback) # Remove observer
# Other operations
config.reload() # Reload from file
config.validate() # Validate against schema
config.get_all() # Get entire configuration
NekoConfigManager
Low-level class for managing configuration files:
manager = NekoConfigManager("config.yaml")
manager.load() # Load from file
manager.save() # Save to file
manager.register_observer(callback) # Add observer
NekoConf
Web server for managing configuration through a UI:
server = NekoConfigServer(config_manager)
server.run(host="127.0.0.1", port=8000)
Securing the Web Interface and API
You can secure the web interface and API with an API key:
from nekoconf import NekoConfigManager, NekoConfigServer
# Create a config manager
config = NekoConfigManager("config.yaml")
# Create a web server with authentication using an API key
server = NekoConfigServer(
config=config,
api_key="yoursecretapikey" # Set your API key here
)
# Run the server
server.run(host="0.0.0.0", port=8000)
Using the command line:
nekoconf server --config=config.yaml --api-key=yoursecretapikey
If no --api-key is provided, authentication will be disabled.
API Access with Authentication
When authentication is enabled, you need to provide the API key in the Authorization header as a Bearer token:
# Get the entire configuration
curl -H "Authorization: Bearer yoursecretapikey" http://localhost:8000/api/config
# Get a specific configuration value
curl -H "Authorization: Bearer yoursecretapikey" http://localhost:8000/api/config/server/host
# Update a configuration value
curl -H "Authorization: Bearer yoursecretapikey" -X POST \
-H "Content-Type: application/json" \
-d '{"value": "new_value"}' \
http://localhost:8000/api/config/server/host
# Reload the configuration from disk
curl -H "Authorization: Bearer yoursecretapikey" -X POST http://localhost:8000/api/config/reload
Development
Set up a development environment:
git clone https://github.com/nya-foundation/nekoconf.git
cd nekoconf
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
Run tests:
pytest
pytest --cov=nekoconf
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
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 nekoconf-0.1.6.tar.gz.
File metadata
- Download URL: nekoconf-0.1.6.tar.gz
- Upload date:
- Size: 35.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91fca8a5f146f48dd71adc957c4e90f8e38a89d5e7aa2986ae0caeb096c03f0f
|
|
| MD5 |
87992f97b610c061a7be09bafabd56fb
|
|
| BLAKE2b-256 |
73838b9dff4f009a8a14b0609bc47eac21bda38e4d162e2ccc9536827adebd9e
|
Provenance
The following attestation bundles were made for nekoconf-0.1.6.tar.gz:
Publisher:
publish.yml on Nya-Foundation/NekoConf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nekoconf-0.1.6.tar.gz -
Subject digest:
91fca8a5f146f48dd71adc957c4e90f8e38a89d5e7aa2986ae0caeb096c03f0f - Sigstore transparency entry: 203471093
- Sigstore integration time:
-
Permalink:
Nya-Foundation/NekoConf@819c4bb74854ebc0750b1f0bf971daea3c8dcdc0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nya-Foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@819c4bb74854ebc0750b1f0bf971daea3c8dcdc0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nekoconf-0.1.6-py3-none-any.whl.
File metadata
- Download URL: nekoconf-0.1.6-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feaf0ba6909769b6bb88a2d0b59539780fd8323d4946c0da80a8db9301788e0a
|
|
| MD5 |
5b29859098142fa52ea0ed69459db07e
|
|
| BLAKE2b-256 |
387b3268554cd8e939a97ef9d79c640349adbb0afc9a2e27943f6b0d773f2745
|
Provenance
The following attestation bundles were made for nekoconf-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on Nya-Foundation/NekoConf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nekoconf-0.1.6-py3-none-any.whl -
Subject digest:
feaf0ba6909769b6bb88a2d0b59539780fd8323d4946c0da80a8db9301788e0a - Sigstore transparency entry: 203471096
- Sigstore integration time:
-
Permalink:
Nya-Foundation/NekoConf@819c4bb74854ebc0750b1f0bf971daea3c8dcdc0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nya-Foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@819c4bb74854ebc0750b1f0bf971daea3c8dcdc0 -
Trigger Event:
push
-
Statement type: