Code Monkey home page Code Monkey logo

confiture's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

confiture's Issues

allow_unkown=True doesn't work with sections

I got the following error:

Traceback (most recent call last):
  File "test3.py", line 108, in <module>
    pconfig = config.parse()
  File "/home/antoine/Devel/dotconf/dotconf/__init__.py", line 28, in parse
    config = self._schema.validate(config)
  File "/home/antoine/Devel/dotconf/dotconf/schema/containers.py", line 403, in validate
    validated_section.register(child, name=name)
  File "/home/antoine/Devel/dotconf/dotconf/tree.py", line 106, in register
    raise TypeError('Child must be a ConfigValue or ConfigSection object')
TypeError: Child must be a ConfigValue or ConfigSection object

Seem because ConfigSection.iteritems() returns a list of section instead of expanding it.

Illegal line break character in configuration file

When working on windows and unix (e.g. writing configuration file under windows, but parsing it with python installed on cygwin), there is this inconsistence with different line breaks. For the mentioned example, the configuration file contains \r\n line breaks, but unix python does not allow this and we get the ParsingError:

Illegal character u'\r'

To prevent this, an easy solution is available. Just change the first line of from_filename function from

fconf = open(filename)

to

fconf = open(filename, 'Ur')

This allows universal line breaks and can treat any of the unix/mac/windows line break styles like described in: http://docs.python.org/2/library/functions.html#open

Traceback for section in configuration that is not in schema

If I write a section into the configuration that is not inside the schema, a traceback is raised at line 404 in containers.py.
Usually, for normal assignment values, an error like this is raised:

dotconf.schema.ValidationError: section path, unknown key <my-key>

But for an unknown section, the following traceback is raised from containers.py:

      raise ValidationError(msg, position=child.position)
  AttributeError: 'list' object has no attribute 'position'

Optional sections are not working

If a section with the meta

_meta = {'args': None, 'repeat': (0, 1)}

is declared in schema, the section has to be included in the configuration although it is optional. However, an error is raised in a code-area where missing attributes are checked (line 404 in containers.py).

For an optional section, I recommend that it is still a known key. This means that

parsed_conf.subsections('my-optional-section')

returns an empty list so that iterating over all (optional) sections is still possible but will simply do nothing.

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.