GOFIGURE
*Only PyYAML for YAML support
A dynamic configuration system with flexible access patterns for Python. Zero external dependencies except PyYAML.
✨ Features
- 🔄 Dual Access Patterns: Use both
config.keyandconfig['key']interchangeably - 💾 File Persistence: Automatic loading/saving with JSON and YAML support
- 🌳 Smart Nesting: Automatic handling of nested dictionaries with autovivification
- 🛡️ Namespace Protection: Intelligent method naming when your data conflicts
- ⚡ Autosave: Optional automatic persistence on configuration changes
- 🔒 Type Safe: Full typing support with comprehensive error handling
- 🎯 Zero Config: Works out of the box with sensible defaults
🚀 Quick Start
from gofigure import Gofig
# Load from file
config = Gofig.FromJSON('config.json')
# Dual access patterns
config.database.host = 'localhost' # Attribute access
config['database']['port'] = 5432 # Dict access
# Automatic nesting (autovivification)
config.api.endpoints.users = '/api/v1/users'
print(config.api.endpoints.users) # /api/v1/users
# Save changes
config.save()
# Autosave mode - changes persist immediately
config = Gofig.FromYAML('settings.yaml', autosave=True)
config.debug = True # Automatically saved!
📦 Installation
pip install gofigure
🔧 Advanced Usage
Autovivification Control
# Default: auto-create nested structures
config = Gofig(autovivify=True)
config.new.nested.key = "value" # Creates nested structure automatically
# Strict mode: only access existing keys
config = Gofig(autovivify=False, nullaccess=AttributeError)
config.nonexistent # Raises AttributeError
# Return None for missing keys
config = Gofig(autovivify=False, nullaccess=None)
print(config.missing) # None
Namespace Conflict Resolution
# Automatic resolution
config = Gofig({'save': 'important_data'})
config.Save() # Uses 'Save' instead of 'save'
# Standalone functions (always available)
from gofigure import save, reload
save(config)
reload(config)
# Extreme conflicts - use operators
config = Gofig({
'save': 'data', 'Save': 'data', 'persist': 'data'
}, manglenamespace=True)
config >> ... # Save via operator
config << ... # Reload via operator
Flexible Initialization
# Hierarchy: file → data → overrides
config = Gofig(
data={'defaults': True},
filepath='config.json',
autosave=True,
environment='production', # Override
debug=False # Override
)
Error Handling
from gofigure import UnsupportedFormat, NamespaceConflict
try:
config = Gofig.FromJSON('config.xml') # Wrong format
except UnsupportedFormat as e:
print(f"Format not supported: {e.fmt}")
print(f"Supported formats: {e.supported}")
📋 Supported Formats
| Format | Extensions | Status |
|---|---|---|
| JSON | .json |
✅ Full support |
| YAML | .yaml, .yml |
✅ Full support |
| TOML | .toml |
🚧 Coming soon |
🔬 Technical Features
- Smart Merging: Nested configurations merge intelligently
- Memory Efficient: Shared root references for nested objects
- Type Hints: Full typing support with generics
- Comprehensive Tests: 101 tests covering edge cases
- No Magic: Clear, predictable behavior
📝 Requirements
- Python 3.9+
- PyYAML 6.0+ (for YAML support)
📄 License
MIT License - see LICENSE file for details.
Built with ❤️ and zero unnecessary dependencies
Metadata
Release files for gofigure 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gofigure-0.2.5.tar.gz | 19.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gofigure-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.5 kB
Release files / gofigure-0.2.5.tar.gz
| Download URL | gofigure-0.2.5.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4c7cccede1fb49ef25b19542ecbe6c123c04847d900f449a66db89eaa321857
|
|
BLAKE2b-256 checksum How to use checksums |
8b34bbdd2048e1ed56a32319c7a30b096b2f2a317b866c65f81d131c1ba729f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / gofigure-0.2.5-py3-none-any.whl
| Download URL | gofigure-0.2.5-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d034fd35e528a47b31c0ea659f1d40160d7bf60640249f5f0ec7d317dd0dc56e
|
|
BLAKE2b-256 checksum How to use checksums |
050f22303677b675a2a8f540f3c8986545143bfc45a6493a572fdb0c423c9548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|