Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

Python configuration files in Python.

Project Description

Meh Banner

*Meh* is a Python configuration utility. I know there are already quite a few good ones out there but trust me, *Meh* is different. Instead of relying on some kind of data format like JSON it uses something which I can’t believe nobody has thought of yet: Python.

Usage

from Meh import Config, Option

config = Config()
config.add(Option("food", ["Steak", "Pizza", "Burgers"],
    validator=lambda x: type(x) is list))
config.add(Option("ages", {"@snoato" : 18, "@PhilipTrauner" : 16},
    validator=lambda x: type(x) is dict))
config.add(Option("bytestring", b"test"))
config += Option("another_number", 42.0, comment="hihi")
config -= Option("another_number", 42.0, comment="hihi")
config += Option("another_number", 42.0, comment="hihi")

CONFIG_PATH = "awesome_config.cfg"

try:
    config = config.load(CONFIG_PATH)
except IOError:
    config.dump(CONFIG_PATH)
    config = config.load(CONFIG_PATH)

print(config.food)
print(config.ages)
print(config.bytestring)
print(config.another_number)

# Changing values during runtime
config.food = ["Baked Beans", "Ramen"]
print(config.food)

Outputs:

['Steak', 'Pizza', 'Burgers']
{'@PhilipTrauner': 16, '@snoato': 18}
test
42.0
['Baked Beans', 'Ramen']

Creates:

food = ['Baked Beans', 'Ramen']
ages = {'@PhilipTrauner': 16, '@snoato': 18}
bytestring = "test"
another_number = 42.0 # hihi

Tidbits

Config(options=[], validation_failed=None)

  • options: Provide a list of options instead of calling add for all of them.
  • validation_failed: Provide a function accepting two parameters (name and value) that’s called when a validation fails (returns nothing). (Otherwise a ValidationError will be raised)

Option(name, default_value, validator=None, comment="")

  • validator: Provide a function accepting one parameter which checks if a value is correct (returns a boolean).
  • comment: A comment appended to the variable declaration in the config file itself.

Installation

git clone https://github.com/PhilipTrauner/Meh
cd Meh
python setup.py install

To-Do

  • pip release happening soon
Release History

Release History

This version
History Node

1.6

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Meh-1.6.tar.gz (4.6 kB) Copy SHA256 Checksum SHA256 Source Jul 26, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting