Abstract implementation of backend modules.
Changed in version 0.2: The methods load_impl(), dump_impl() are deprecated and replaced with load_from_stream() and load_from_path(), dump_to_string() and dump_to_path() respectively.
Backend module must implement a parser class inherits Parser or its children classes of this module and override all or some of the methods as needed:
- load_from_string(): Load config from string
- load_from_stream(): Load config from a file or file-like object
- load_from_path(): Load config from file of given path
- dump_to_string(): Dump config as a string
- dump_to_stream(): Dump config to a file or file-like object
- dump_to_path(): Dump config to a file of given path
Make optional kwargs valid and optimized for each backend.
Parameters: |
|
---|
>>> mk_opt_args(("aaa", ), dict(aaa=1, bbb=2))
{'aaa': 1}
>>> mk_opt_args(("aaa", ), dict(bbb=2))
{}
Make dir to dump filepath if that dir does not exist.
Parameters: | filepath – path of file to dump |
---|
Lift func() to a method; it will be called with the first argument self ignored.
Parameters: | func – Any callable object |
---|
Bases: object
Abstract parser to provide basic implementation of some methods, interfaces and members.
alias of MergeableDict
Create an instance from any object.
Parser’s type
Parser’s priority
File extensions which this parser can process
Parameters: | filepath – Path to file to open to read data |
---|
Parameters: | filepath – Path to file to open to write data to |
---|
Load config from given string content.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Load config from given file path filepath.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Load config from given file like object stream.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Load config from given string content after some checks.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Load config from a file path or a file / file-like object path_or_stream after some checks.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Dump config cnf to a string.
Parameters: |
|
---|---|
Returns: | string represents the configuration |
Dump config cnf to a file filepath.
Parameters: |
|
---|
Dump config cnf to a file-like object stream.
TODO: How to process socket objects same as file objects ?
Parameters: |
|
---|
Dump config cnf to a string.
Parameters: |
|
---|---|
Returns: | string represents the configuration |
Dump config cnf to a filepath or file-like object path_or_stream.
Parameters: |
|
---|---|
Raises IOError, OSError, AttributeError: | |
When dump failed. |
Bases: anyconfig.backend.base.Parser
Abstract config parser provides a method to load configuration from string content to help implement parser of which backend lacks of such function.
Parser classes inherit this class have to override the method load_from_string() at least.
Load config from given stream stream.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Load config from given file path filepath.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Bases: anyconfig.backend.base.Parser
Abstract config parser provides a method to load configuration from string content to help implement parser of which backend lacks of such function.
Parser classes inherit this class have to override the method load_from_stream() at least.
Load config from given string cnf_content.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Load config from given file path filepath.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Bases: anyconfig.backend.base.Parser
Abstract config parser provides a method to dump configuration to a file or file-like object (stream) and a file of given path to help implement parser of which backend lacks of such functions.
Parser classes inherit this class have to override the method dump_to_string() at least.
Dump config cnf to a file filepath.
Parameters: |
|
---|
Dump config cnf to a file-like object stream.
TODO: How to process socket objects same as file objects ?
Parameters: |
|
---|
Bases: anyconfig.backend.base.Parser
Abstract config parser provides methods to dump configuration to a string content or a file of given path to help implement parser of which backend lacks of such functions.
Parser classes inherit this class have to override the method dump_to_stream() at least.
StringIO([s]) – Return a StringIO-like stream for reading or writing
Dump config cnf to a string.
Parameters: |
|
---|---|
Returns: | self.container object holding config parameters |
Dump config cnf to a file filepath.
Parameters: |
|
---|