All Projects → PhilipTrauner → Meh

PhilipTrauner / Meh

Licence: MIT license
Python configuration files in Python. ¯\_(ツ)_/¯

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Meh

Forge
A Generic Low-Code Framework Built on a Config-Driven Tree Walker
Stars: ✭ 70 (+250%)
Mutual labels:  config, dynamic
Dynamic ORB SLAM2
Visual SLAM system that can identify and exclude dynamic objects.
Stars: ✭ 89 (+345%)
Mutual labels:  dynamic
Machfiles
The dotfiles you see in all my videos
Stars: ✭ 347 (+1635%)
Mutual labels:  config
Rails-4-ElasticSearch-dynamic-facets
Rails 4 ElasticSearch integration with dynamic facets
Stars: ✭ 16 (-20%)
Mutual labels:  dynamic
ODYM
Open Dynamic Material Systems Model
Stars: ✭ 36 (+80%)
Mutual labels:  dynamic
Config
Configuration files
Stars: ✭ 21 (+5%)
Mutual labels:  config
onion
Layer based configuration for golang
Stars: ✭ 104 (+420%)
Mutual labels:  config
tianyamingyu
Config files for my GitHub profile.
Stars: ✭ 41 (+105%)
Mutual labels:  config
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+330%)
Mutual labels:  config
DuktapeJava
Tiny Powerfull JavaScript Engine On Android Platform integrating with java
Stars: ✭ 74 (+270%)
Mutual labels:  dynamic
dynamic-datasource-starter
springboot 动态切换数据的基本思想与实现方法
Stars: ✭ 12 (-40%)
Mutual labels:  dynamic
tomlj
A Java parser for Tom's Obvious, Minimal Language (TOML).
Stars: ✭ 72 (+260%)
Mutual labels:  config
ConfigTools
把Excel配置表导出成Json格式, 可供服务器,客户端(Unity,Laya)使用, 可直接根据表结构生成对应的代码支持C#和TypeScript. Export Excel configuration table into Json format, which can be used by server and client (Unity, Laya), and directly generate code corresponding to table structure to support C # and TypeScript.
Stars: ✭ 59 (+195%)
Mutual labels:  config
Akshay-Vs
Config files for my GitHub profile.
Stars: ✭ 17 (-15%)
Mutual labels:  config
tfvars-annotations
[not-WIP] Update values in terraform.tfvars using annotations
Stars: ✭ 20 (+0%)
Mutual labels:  dynamic
simple json
Simple way to dynamically convert from and to JSON using build-time generators given a type.
Stars: ✭ 15 (-25%)
Mutual labels:  dynamic
props
config source library for golang, support properties/yaml/ini file、zookeeper\consul\etcd k/v k/props
Stars: ✭ 57 (+185%)
Mutual labels:  config
nestjs-config
NestJS Module for Nonfig services. Nonfig combines Configurations and Features. So you change features, and release swiftly, and measure to digital impact.
Stars: ✭ 40 (+100%)
Mutual labels:  config
anchor
Create Dynamic CLI's as your GitOps Marketplace
Stars: ✭ 38 (+90%)
Mutual labels:  dynamic
.macOS-emacs.d
😈My personal Emacs configuration on macOS
Stars: ✭ 108 (+440%)
Mutual labels:  config

Meh

Meh Banner

Python version support: 2.7, 3.4, 3.5 License: MIT

Meh is a Python configuration utility that uses Python as it's data format. It provides a pleasant and very "pythonic" interface to do all the things a configuration utility does, like default values, validators and comments.

Usage

from meh import Config, Option, ExceptionInConfigError

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, ExceptionInConfigError):
	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

Manual:

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

pip:

pip install meh

Honorable Mentions

To-Do

  • More test cases
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].