Coder Social home page Coder Social logo

pymlconf's Introduction

pymlconf

PyPI Build Coverage Status Documentation Downloads Downloads Downloads

About

pymlconf (Python YAML Configuration Library) helps to easily manage and access to your application configurations which was already Written in YAML language.

Checkout Documentation for more info.

Installation

pip install pymlconf

Development

cd path/to/pymlconf
pip install -e .
pip install -r requirements-dev.txt

Running tests

pytest

Coverage

pytest --cov=pymlconf

Documentation

cd sphinx
make doctest
make html
or
make livehtml

pymlconf's People

Contributors

fizyk avatar irhonin avatar mohammadsheikhian avatar pylover avatar sharez avatar shayaniox avatar thenaterhood avatar wearpants avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pymlconf's Issues

Support Immutable config object

It would be nice if I could have the possibility to set that the config object is immutable once I loaded all needed configuration files. In that case, I can be sure that my configuration won't be changed during runtime.
Just an example of it could be used

from pymlconf import Root, freeze

config = Root()
for yml_file in CONFIG_PATHS:
    if yml_file.exists():
        config.loadfile(str(yml_file))
freeze(config)

config.foo = "bar"

TypeError is raised

pymlconf doesn't have a license

I couldn't help but notice that pymlconf doesn't specify a license. This makes it hard to know how your code can be used, as it doesn't tell us how (or if) we can redistribute or use it and means that it isn't open source from a legal standpoint. Please consider adding a license when you have a few minutes, many of us would greatly appreciate it! :)

If you're not sure what license to choose, this is a good resource to take a look at: http://choosealicense.com/licenses/

NotImplementedError raised when constructing ConfigManager from files

in pytest_sauce package, I use pymlconf underneath, to costruct ConfigManager out of files.
Unfortunately with 0.3.1 release I get this error

    return ConfigManager(files=configs)
  File "/home/.../local/lib/python2.7/site-packages/pymlconf/config_manager.py", line 47, in __init__
    self.load_files(files)
  File "/home/.../local/lib/python2.7/site-packages/pymlconf/config_manager.py", line 66, in load_files
    node.merge(load_yaml(f))
  File "/home/.../local/lib/python2.7/site-packages/pymlconf/mergable.py", line 26, in merge
    self._merge(to_merge)
  File "/home/.../local/lib/python2.7/site-packages/pymlconf/config_nodes.py", line 31, in _merge
    and self[k].can_merge(v):
  File "/home/.../local/lib/python2.7/site-packages/pymlconf/mergable.py", line 12, in can_merge
    raise NotImplementedError()
NotImplementedError

python 3 (3.2) compatibility

pymlconf is currently python3 incompatible, but would be great to have it compatible with python3 (3.2) or 3.3.

load_files() fails silently to load files

    def load_files(self, files, filename_as_namespace=False):
        """
        load files which contains yaml config entries.and merge it by current ConfigManager instance
        """
        for f in files:
            if not os.path.exists(f):
                continue

We will never know that given files were not loaded.
It would be nice to at least log something.

Release stable version

Hi, sincve 0.2.8 you've started release pymlconf with a suffix, which indicates non-stable package as per pep386.

Which latest pip and setuptools, it's no longer an option to install development fversion from pypi, if you have stable accessible.

It would be great if we would get stable 0.2.11 versions, so clean installation wouldn't fail on import error from pymlconf 0.2.8 :)

Configs with values with percent signs (%) can't be loadfile'd-> TypeError

Yaml values containing % can cause TypeErrors.

$ cat file.yaml
uri: "amqp://localhost:5672/%2F"

$ python
Python 3.7.4 (default, Oct  1 2019, 17:17:01)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymlconf import Root
>>> Root().loadfile('file.yaml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../site-packages/pymlconf/models.py", line 236, in loadfile
    loadedyaml = yaml_.load(filename, self.context)
  File ".../site-packages/pymlconf/yaml_.py", line 30, in load
    return loads(f.read(), context)
  File ".../site-packages/pymlconf/yaml_.py", line 20, in loads
    str_data = preprocess(str_data, context)
  File ".../site-packages/pymlconf/yaml_.py", line 15, in preprocess
    return data % context
TypeError: must be real number, not dict

Because %2F is considered string format specifier (if not escaped, e.g. with another %).

ImportError: No module named 'errors'

Pymlconf 0.3.14 on both Python 3.3 and 3.4 raises:

    from pymlconf import ConfigManager

  File "/home/travis/virtualenv/python3.3.5/lib/python3.3/site-packages/pymlconf-0.3.14-py3.3.egg/pymlconf/__init__.py", line 2, in <module>

    from pymlconf.config_nodes import Mergable, ConfigList, ConfigDict, ConfigNamespace

  File "/home/travis/virtualenv/python3.3.5/lib/python3.3/site-packages/pymlconf-0.3.14-py3.3.egg/pymlconf/config_nodes.py", line 5, in <module>

    from pymlconf.yaml_helper import load_string

  File "/home/travis/virtualenv/python3.3.5/lib/python3.3/site-packages/pymlconf-0.3.14-py3.3.egg/pymlconf/yaml_helper.py", line 5, in <module>

    from errors import ConfigFileSyntaxError

ImportError: No module named 'errors'

override whole branch in merge if value provided in second one

Hey, I though it worked that way, but apparently I'm missing something, so firstly, let me ask if that makes sense:

We have two configs:

key:
   subkey:
       another1: value
       another2: value
   subkey2: value

and

key:
    subkey: false

So, my proposition, is to be able to merge these two like:

key:
    subkey: false
    subkey2: value

So, the merge would have to be able to override in this case completely with value, and do not follow further the original ConfigDict tree

Example from docs supposed to work in python2?

Would be really good to have some more examples of over riding defaults, loading multiple config file or maybe an config file with Environments(dev/prod etc.) which returns correct config for env.

⟩ cat app.py
from pymlconf import DiferredRoot

settings = DiferredRoot()

context = {
    'here': 'path/to/here'
}

builtins = '''
  a: %(here)s
 '''

settings.initialzie(builtins, context)
print settings.a
    from pymlconf import DiferredRoot
  File "/usr/local/lib/python2.7/site-packages/pymlconf/__init__.py", line 2, in <module>
    from .models import Mergable, MergableList, MergableDict, Root, \
  File "/usr/local/lib/python2.7/site-packages/pymlconf/models.py", line 17
    class Mergable(metaclass=abc.ABCMeta):
                            ^
SyntaxError: invalid syntax

Defaulting to 'utf-8' encoding breaks pymlconf on Python 2

Python 2 does not have support for open() with encoding='utf-8. I'm using a package with depends on pymlconf on Python 2 and this change has broken my tests. Let me know if you need any more information to debug this.

.tox/py27/lib/python2.7/site-packages/pymlconf/config_manager.py:76: in __init__
    self.load_files(files)
.tox/py27/lib/python2.7/site-packages/pymlconf/config_manager.py:109: in load_files
    loaded_yaml = load_yaml(f, self.context, encoding=self.encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

file_path = '/home/ubuntu/<SNIP>'
macros = {}, encoding = 'utf-8'

    def load_yaml(file_path, macros=None, encoding='utf-8'):
>       stream = open(file_path, encoding=encoding)
E       TypeError: 'encoding' is an invalid keyword argument for this function

.tox/py27/lib/python2.7/site-packages/pymlconf/yaml_helper.py:29: TypeError

built-in config

A new parameter to load before the init_value , helps to implement builtin config pattern.

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.