GithubHelp home page GithubHelp logo

ap-atul / yacp Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 9 KB

Yet Another Config Parser. Convert YAML, JSON, and CUSTOM files to python objects and back.

License: The Unlicense

Python 100.00%
parser yaml yacp yaml-parser json-parser json config-parser config-management deserialisation serialisation

yacp's Introduction

yacp

Yet Another Config Parser. Convert YAML, JSON, and Custom files to python objects and back.

Parsers

  • JsonParser uses inbuilt json module
  • YamlParser uses inbuilt yaml module
  • CustomParser uses a simple parser which requires a syntax to be passed.

Get the package

  1. Install using pip
pip3 install git+https://github.com/AP-Atul/yacp
  1. Clone and install
git clone https://github.com/AP-Atul/yacp
python3 setup.py install

Usage

  1. Buid a class with members (or without)
class Settings:
    def __init__(self):
        self._name = None
        self._age = None

settings = Settings()
  1. Loading a file into the object
## the parser type will be determined using the file name
settings = yacp.load(filename=YOUR_FILE, cls=OBJECT)
  1. Dumping an object
yacp.dump(filename=YOUR_FILE, cls=OBJECT)
  • For custom files use syntax attribute [NOTE: Primitive data types are preserved using regexps]
# syntax should contain two strings (key, val)
object = yacp.load(filename=FILE, cls=OBJECT, syntax="%s:%s")
yacp.dump(filename=FILE, cls=OBJECT, syntax="%s:%s")
  • Use override for class with no members [This will add attributes to the object that are not declared in the class but available in the file]
object = yacp.load(filename, cls, override=True)

yacp's People

Contributors

ap-atul avatar

Stargazers

 avatar  avatar  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.