Skip to main content

When projects start to grow, the need for a globally accessible configuration manager is obvious.

Having configurations mapped to dictionaries is really useful, but can create a problem with memory.

Guachi not only holds persistent dictionaries on disk, but it also maps INI style keys to dictioanry keys, and can fill in the default values if some of them are missing.

You do not need to know anything about how guachi stores the values, just treat it like a regular dictionary!

User Interaction

Let’s assume you are dealing with a Twitter application that uses a ini file. This is a sampla INI file and how it looks:

[DEFAULT]

app.twitter.username = alfredodeza
app.update.frequency = 60
app.load.startup = False

We have a username, a frequency and a different setting for the startup option.

Lets deal with that:

ini_file = ``/Users/alfredo/.twwiter.ini``
conf = ConfigMapper(config_db_path)
conf.set_config(ini_file)

That’s it! At this point, guachi has parsed the config file and stored the values.

Lets query them calling our keys:

>>> db_conf = conf.stored_config()
>>> db_conf['frequency']
60

Great, we now are making sure we have our data. We can actually get that value from anywhere in our twitter app by calling it this way:

db = ConfigMapper(config_db_path)
conf = db.stored_config()

frequency = conf['frequency']

Getting Deafults

Above we inspected an INI file with some changed values. But what happens when the user has none?

Since we set our defaults, we can be sure they are right there in case our app needs it in some sub-module:

>>> db = ConfigMapper(config_db_path)
>>> conf = db.stored_config()
>>> conf['load']
True

Updating Values

What if a user makes changes? We can always save and update what we read from the INI file at load time, to make sure we have the latest changes from the user:

conf = ConfigMapper(config_db_path)
conf.update_config(ini_file)

Documentation

Our full Documentation is hosted here. Go take a look for the full API.

http://guachi.googlecode.com/hg/docs/build/html/index.html

Metadata

Release files for guachi 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for guachi 0.0.6
File Size Uploaded
guachi-0.0.6.tar.gz 18.0 kB Details

Release files / guachi-0.0.6.tar.gz

Download URL guachi-0.0.6.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a77cbb09417bd09f2d989fedbc0a0a759f8aee1cb1731a89a816218f44e0e4fb
BLAKE2b-256 checksum
How to use checksums
fc1bff14ec04338cbf5558e1bd1f639ece257f69e6ef08a758c9072026f49852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.6 This release

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page