Git Product home page Git Product logo

ezconfig's Introduction

EzConfig

Easy to use expandable configuration reader in Python

How to use:

  1. Download both ezconf.py and merrors.py and place them into your project folder.
  2. Create a new config with basic values given in the example_config.json
  3. Enjoy!

Example (located in tests.py):

# Import EzConfig
import ezconf
# Create config object
config = ezconf.config()
# Read the config file
print("\nLoad config")
config.read("example_config.json")
# Get non-nested values
print("\nGet non-nested value\n")
print(config.get("name"))
# Get nested values
print("\nGet nested value\n")
print(config.get("extra-info","packages"))
# Add more nested values
print("\nCreat new main nested value")
config.add("Message Data","")
config.nested("Message Data","message count","30")
print("\nAdding second nested entry")
config.nested("Message Data","last message","14/10/2020")
config.nested("Message Data","last user to send a message","Test")
# Get pretty json
print("\nGet pretty print\n")
print(config.pretty())
# Add object
config.add("Tests","none")
# check results
print(config.pretty())

Example of the config.json:

{
"name": "Example Application",
"version": "0.0.1",
"run_script": "tests.py",
"author": "Linkus",
"license": "Apache 2",
"extra-info":{
  "packages": "merrors, ezconfig",
  "desc": "Easier configs for python"
}
}

Result image

ezconfig's People

Contributors

huski3 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.