repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.register
def register(self, *pclss): """ :param pclss: A list of :class:`Processor` or its children classes """ for pcls in pclss: if pcls.cid() not in self._processors: self._processors[pcls.cid()] = pcls
python
def register(self, *pclss): """ :param pclss: A list of :class:`Processor` or its children classes """ for pcls in pclss: if pcls.cid() not in self._processors: self._processors[pcls.cid()] = pcls
[ "def", "register", "(", "self", ",", "*", "pclss", ")", ":", "for", "pcls", "in", "pclss", ":", "if", "pcls", ".", "cid", "(", ")", "not", "in", "self", ".", "_processors", ":", "self", ".", "_processors", "[", "pcls", ".", "cid", "(", ")", "]", ...
:param pclss: A list of :class:`Processor` or its children classes
[ ":", "param", "pclss", ":", "A", "list", "of", ":", "class", ":", "Processor", "or", "its", "children", "classes" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L243-L249
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.list
def list(self, sort=False): """ :param sort: Result will be sorted if it's True :return: A list of :class:`Processor` or its children classes """ prs = self._processors.values() if sort: return sorted(prs, key=operator.methodcaller("cid")) return prs
python
def list(self, sort=False): """ :param sort: Result will be sorted if it's True :return: A list of :class:`Processor` or its children classes """ prs = self._processors.values() if sort: return sorted(prs, key=operator.methodcaller("cid")) return prs
[ "def", "list", "(", "self", ",", "sort", "=", "False", ")", ":", "prs", "=", "self", ".", "_processors", ".", "values", "(", ")", "if", "sort", ":", "return", "sorted", "(", "prs", ",", "key", "=", "operator", ".", "methodcaller", "(", "\"cid\"", "...
:param sort: Result will be sorted if it's True :return: A list of :class:`Processor` or its children classes
[ ":", "param", "sort", ":", "Result", "will", "be", "sorted", "if", "it", "s", "True", ":", "return", ":", "A", "list", "of", ":", "class", ":", "Processor", "or", "its", "children", "classes" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L257-L266
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.list_by_cid
def list_by_cid(self): """ :return: A list of :class:`Processor` or its children classes grouped by each cid, [(cid, [:class:`Processor`)]] """ prs = self._processors return sorted(((cid, [prs[cid]]) for cid in sorted(prs.keys())), ke...
python
def list_by_cid(self): """ :return: A list of :class:`Processor` or its children classes grouped by each cid, [(cid, [:class:`Processor`)]] """ prs = self._processors return sorted(((cid, [prs[cid]]) for cid in sorted(prs.keys())), ke...
[ "def", "list_by_cid", "(", "self", ")", ":", "prs", "=", "self", ".", "_processors", "return", "sorted", "(", "(", "(", "cid", ",", "[", "prs", "[", "cid", "]", "]", ")", "for", "cid", "in", "sorted", "(", "prs", ".", "keys", "(", ")", ")", ")"...
:return: A list of :class:`Processor` or its children classes grouped by each cid, [(cid, [:class:`Processor`)]]
[ ":", "return", ":", "A", "list", "of", ":", "class", ":", "Processor", "or", "its", "children", "classes", "grouped", "by", "each", "cid", "[", "(", "cid", "[", ":", "class", ":", "Processor", ")", "]]" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L268-L276
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.list_by_x
def list_by_x(self, item=None): """ :param item: Grouping key, one of "cid", "type" and "extensions" :return: A list of :class:`Processor` or its children classes grouped by given 'item', [(cid, [:class:`Processor`)]] by default """ prs = self._processors ...
python
def list_by_x(self, item=None): """ :param item: Grouping key, one of "cid", "type" and "extensions" :return: A list of :class:`Processor` or its children classes grouped by given 'item', [(cid, [:class:`Processor`)]] by default """ prs = self._processors ...
[ "def", "list_by_x", "(", "self", ",", "item", "=", "None", ")", ":", "prs", "=", "self", ".", "_processors", "if", "item", "is", "None", "or", "item", "==", "\"cid\"", ":", "# Default.", "res", "=", "[", "(", "cid", ",", "[", "prs", "[", "cid", "...
:param item: Grouping key, one of "cid", "type" and "extensions" :return: A list of :class:`Processor` or its children classes grouped by given 'item', [(cid, [:class:`Processor`)]] by default
[ ":", "param", "item", ":", "Grouping", "key", "one", "of", "cid", "type", "and", "extensions", ":", "return", ":", "A", "list", "of", ":", "class", ":", "Processor", "or", "its", "children", "classes", "grouped", "by", "given", "item", "[", "(", "cid",...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L286-L304
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.list_x
def list_x(self, key=None): """ :param key: Which of key to return from "cid", "type", and "extention" :return: A list of x 'key' """ if key in ("cid", "type"): return sorted(set(operator.methodcaller(key)(p) for p in self._processors.val...
python
def list_x(self, key=None): """ :param key: Which of key to return from "cid", "type", and "extention" :return: A list of x 'key' """ if key in ("cid", "type"): return sorted(set(operator.methodcaller(key)(p) for p in self._processors.val...
[ "def", "list_x", "(", "self", ",", "key", "=", "None", ")", ":", "if", "key", "in", "(", "\"cid\"", ",", "\"type\"", ")", ":", "return", "sorted", "(", "set", "(", "operator", ".", "methodcaller", "(", "key", ")", "(", "p", ")", "for", "p", "in",...
:param key: Which of key to return from "cid", "type", and "extention" :return: A list of x 'key'
[ ":", "param", "key", ":", "Which", "of", "key", "to", "return", "from", "cid", "type", "and", "extention", ":", "return", ":", "A", "list", "of", "x", "key" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L306-L319
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.findall
def findall(self, obj, forced_type=None, cls=anyconfig.models.processor.Processor): """ :param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to f...
python
def findall(self, obj, forced_type=None, cls=anyconfig.models.processor.Processor): """ :param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to f...
[ "def", "findall", "(", "self", ",", "obj", ",", "forced_type", "=", "None", ",", "cls", "=", "anyconfig", ".", "models", ".", "processor", ".", "Processor", ")", ":", "return", "[", "p", "(", ")", "for", "p", "in", "findall", "(", "obj", ",", "self...
:param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to find :param cls: A class object to compare with 'ptype' :return: A list of instances of processor classe...
[ ":", "param", "obj", ":", "a", "file", "path", "file", "file", "-", "like", "object", "pathlib", ".", "Path", "object", "or", "an", "anyconfig", ".", "globals", ".", "IOInfo", "(", "namedtuple", ")", "object", ":", "param", "forced_type", ":", "Forced", ...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L321-L334
ssato/python-anyconfig
src/anyconfig/processors.py
Processors.find
def find(self, obj, forced_type=None, cls=anyconfig.models.processor.Processor): """ :param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to find ...
python
def find(self, obj, forced_type=None, cls=anyconfig.models.processor.Processor): """ :param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to find ...
[ "def", "find", "(", "self", ",", "obj", ",", "forced_type", "=", "None", ",", "cls", "=", "anyconfig", ".", "models", ".", "processor", ".", "Processor", ")", ":", "return", "find", "(", "obj", ",", "self", ".", "list", "(", ")", ",", "forced_type", ...
:param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to find :param cls: A class object to compare with 'ptype' :return: an instance of processor class to proce...
[ ":", "param", "obj", ":", "a", "file", "path", "file", "file", "-", "like", "object", "pathlib", ".", "Path", "object", "or", "an", "anyconfig", ".", "globals", ".", "IOInfo", "(", "namedtuple", ")", "object", ":", "param", "forced_type", ":", "Forced", ...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L336-L348
ssato/python-anyconfig
src/anyconfig/backend/yaml/ruamel_yaml.py
yml_fnc
def yml_fnc(fname, *args, **options): """ :param fname: "load" or "dump", not checked but it should be OK. see also :func:`yml_load` and :func:`yml_dump` :param args: [stream] for load or [cnf, stream] for dump :param options: keyword args may contain "ac_safe" to load/dump safely ""...
python
def yml_fnc(fname, *args, **options): """ :param fname: "load" or "dump", not checked but it should be OK. see also :func:`yml_load` and :func:`yml_dump` :param args: [stream] for load or [cnf, stream] for dump :param options: keyword args may contain "ac_safe" to load/dump safely ""...
[ "def", "yml_fnc", "(", "fname", ",", "*", "args", ",", "*", "*", "options", ")", ":", "options", "=", "common", ".", "filter_from_options", "(", "\"ac_dict\"", ",", "options", ")", "if", "\"ac_safe\"", "in", "options", ":", "options", "[", "\"typ\"", "]"...
:param fname: "load" or "dump", not checked but it should be OK. see also :func:`yml_load` and :func:`yml_dump` :param args: [stream] for load or [cnf, stream] for dump :param options: keyword args may contain "ac_safe" to load/dump safely
[ ":", "param", "fname", ":", "load", "or", "dump", "not", "checked", "but", "it", "should", "be", "OK", ".", "see", "also", ":", "func", ":", "yml_load", "and", ":", "func", ":", "yml_dump", ":", "param", "args", ":", "[", "stream", "]", "for", "loa...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/ruamel_yaml.py#L73-L93
ssato/python-anyconfig
src/anyconfig/backend/yaml/ruamel_yaml.py
yml_load
def yml_load(stream, container, **options): """.. seealso:: :func:`anyconfig.backend.yaml.pyyaml.yml_load` """ ret = yml_fnc("load", stream, **options) if ret is None: return container() return ret
python
def yml_load(stream, container, **options): """.. seealso:: :func:`anyconfig.backend.yaml.pyyaml.yml_load` """ ret = yml_fnc("load", stream, **options) if ret is None: return container() return ret
[ "def", "yml_load", "(", "stream", ",", "container", ",", "*", "*", "options", ")", ":", "ret", "=", "yml_fnc", "(", "\"load\"", ",", "stream", ",", "*", "*", "options", ")", "if", "ret", "is", "None", ":", "return", "container", "(", ")", "return", ...
.. seealso:: :func:`anyconfig.backend.yaml.pyyaml.yml_load`
[ "..", "seealso", "::", ":", "func", ":", "anyconfig", ".", "backend", ".", "yaml", ".", "pyyaml", ".", "yml_load" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/ruamel_yaml.py#L96-L103
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_iterparse
def _iterparse(xmlfile): """ Avoid bug in python 3.{2,3}. See http://bugs.python.org/issue9257. :param xmlfile: XML file or file-like object """ try: return ET.iterparse(xmlfile, events=("start-ns", )) except TypeError: return ET.iterparse(xmlfile, events=(b"start-ns", ))
python
def _iterparse(xmlfile): """ Avoid bug in python 3.{2,3}. See http://bugs.python.org/issue9257. :param xmlfile: XML file or file-like object """ try: return ET.iterparse(xmlfile, events=("start-ns", )) except TypeError: return ET.iterparse(xmlfile, events=(b"start-ns", ))
[ "def", "_iterparse", "(", "xmlfile", ")", ":", "try", ":", "return", "ET", ".", "iterparse", "(", "xmlfile", ",", "events", "=", "(", "\"start-ns\"", ",", ")", ")", "except", "TypeError", ":", "return", "ET", ".", "iterparse", "(", "xmlfile", ",", "eve...
Avoid bug in python 3.{2,3}. See http://bugs.python.org/issue9257. :param xmlfile: XML file or file-like object
[ "Avoid", "bug", "in", "python", "3", ".", "{", "2", "3", "}", ".", "See", "http", ":", "//", "bugs", ".", "python", ".", "org", "/", "issue9257", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L82-L91
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_tweak_ns
def _tweak_ns(tag, **options): """ :param tag: XML tag element :param nspaces: A namespaces dict, {uri: prefix} :param options: Extra keyword options may contain 'nspaces' keyword option provide a namespace dict, {uri: prefix} >>> _tweak_ns("a", nspaces={}) 'a' >>> _tweak_ns("a", ns...
python
def _tweak_ns(tag, **options): """ :param tag: XML tag element :param nspaces: A namespaces dict, {uri: prefix} :param options: Extra keyword options may contain 'nspaces' keyword option provide a namespace dict, {uri: prefix} >>> _tweak_ns("a", nspaces={}) 'a' >>> _tweak_ns("a", ns...
[ "def", "_tweak_ns", "(", "tag", ",", "*", "*", "options", ")", ":", "nspaces", "=", "options", ".", "get", "(", "\"nspaces\"", ",", "None", ")", "if", "nspaces", "is", "not", "None", ":", "matched", "=", "_ET_NS_RE", ".", "match", "(", "tag", ")", ...
:param tag: XML tag element :param nspaces: A namespaces dict, {uri: prefix} :param options: Extra keyword options may contain 'nspaces' keyword option provide a namespace dict, {uri: prefix} >>> _tweak_ns("a", nspaces={}) 'a' >>> _tweak_ns("a", nspaces={"http://example.com/ns/val/": "val"}...
[ ":", "param", "tag", ":", "XML", "tag", "element", ":", "param", "nspaces", ":", "A", "namespaces", "dict", "{", "uri", ":", "prefix", "}", ":", "param", "options", ":", "Extra", "keyword", "options", "may", "contain", "nspaces", "keyword", "option", "pr...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L110-L134
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_dicts_have_unique_keys
def _dicts_have_unique_keys(dics): """ :param dics: [<dict or dict-like object>], must not be [] or [{...}] :return: True if all keys of each dict of 'dics' are unique # Enable the followings if to allow dics is [], [{...}]: # >>> all(_dicts_have_unique_keys([d]) for [d] # ... in ({}, {'a':...
python
def _dicts_have_unique_keys(dics): """ :param dics: [<dict or dict-like object>], must not be [] or [{...}] :return: True if all keys of each dict of 'dics' are unique # Enable the followings if to allow dics is [], [{...}]: # >>> all(_dicts_have_unique_keys([d]) for [d] # ... in ({}, {'a':...
[ "def", "_dicts_have_unique_keys", "(", "dics", ")", ":", "key_itr", "=", "anyconfig", ".", "compat", ".", "from_iterable", "(", "d", ".", "keys", "(", ")", "for", "d", "in", "dics", ")", "return", "len", "(", "set", "(", "key_itr", ")", ")", "==", "s...
:param dics: [<dict or dict-like object>], must not be [] or [{...}] :return: True if all keys of each dict of 'dics' are unique # Enable the followings if to allow dics is [], [{...}]: # >>> all(_dicts_have_unique_keys([d]) for [d] # ... in ({}, {'a': 0}, {'a': 1, 'b': 0})) # True # >>> _d...
[ ":", "param", "dics", ":", "[", "<dict", "or", "dict", "-", "like", "object", ">", "]", "must", "not", "be", "[]", "or", "[", "{", "...", "}", "]", ":", "return", ":", "True", "if", "all", "keys", "of", "each", "dict", "of", "dics", "are", "uni...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L137-L157
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_merge_dicts
def _merge_dicts(dics, container=dict): """ :param dics: [<dict/-like object must not have same keys each other>] :param container: callble to make a container object :return: <container> object >>> _merge_dicts(({}, )) {} >>> _merge_dicts(({'a': 1}, )) {'a': 1} >>> sorted(kv for kv...
python
def _merge_dicts(dics, container=dict): """ :param dics: [<dict/-like object must not have same keys each other>] :param container: callble to make a container object :return: <container> object >>> _merge_dicts(({}, )) {} >>> _merge_dicts(({'a': 1}, )) {'a': 1} >>> sorted(kv for kv...
[ "def", "_merge_dicts", "(", "dics", ",", "container", "=", "dict", ")", ":", "dic_itr", "=", "anyconfig", ".", "compat", ".", "from_iterable", "(", "d", ".", "items", "(", ")", "for", "d", "in", "dics", ")", "return", "container", "(", "anyconfig", "."...
:param dics: [<dict/-like object must not have same keys each other>] :param container: callble to make a container object :return: <container> object >>> _merge_dicts(({}, )) {} >>> _merge_dicts(({'a': 1}, )) {'a': 1} >>> sorted(kv for kv in _merge_dicts(({'a': 1}, {'b': 2})).items()) ...
[ ":", "param", "dics", ":", "[", "<dict", "/", "-", "like", "object", "must", "not", "have", "same", "keys", "each", "other", ">", "]", ":", "param", "container", ":", "callble", "to", "make", "a", "container", "object", ":", "return", ":", "<container"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L160-L174
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_parse_text
def _parse_text(val, **options): """ :return: Parsed value or value itself depends on 'ac_parse_value' """ if val and options.get("ac_parse_value", False): return anyconfig.parser.parse_single(val) return val
python
def _parse_text(val, **options): """ :return: Parsed value or value itself depends on 'ac_parse_value' """ if val and options.get("ac_parse_value", False): return anyconfig.parser.parse_single(val) return val
[ "def", "_parse_text", "(", "val", ",", "*", "*", "options", ")", ":", "if", "val", "and", "options", ".", "get", "(", "\"ac_parse_value\"", ",", "False", ")", ":", "return", "anyconfig", ".", "parser", ".", "parse_single", "(", "val", ")", "return", "v...
:return: Parsed value or value itself depends on 'ac_parse_value'
[ ":", "return", ":", "Parsed", "value", "or", "value", "itself", "depends", "on", "ac_parse_value" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L177-L184
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_process_elem_text
def _process_elem_text(elem, dic, subdic, text="@text", **options): """ :param elem: ET Element object which has elem.text :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param options: Keyword options, see the descr...
python
def _process_elem_text(elem, dic, subdic, text="@text", **options): """ :param elem: ET Element object which has elem.text :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param options: Keyword options, see the descr...
[ "def", "_process_elem_text", "(", "elem", ",", "dic", ",", "subdic", ",", "text", "=", "\"@text\"", ",", "*", "*", "options", ")", ":", "elem", ".", "text", "=", "elem", ".", "text", ".", "strip", "(", ")", "if", "elem", ".", "text", ":", "etext", ...
:param elem: ET Element object which has elem.text :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param options: Keyword options, see the description of :func:`elem_to_container` for more details. :return: None...
[ ":", "param", "elem", ":", "ET", "Element", "object", "which", "has", "elem", ".", "text", ":", "param", "dic", ":", "<container", ">", "(", "dict", "[", "-", "like", "]", ")", "object", "converted", "from", "elem", ":", "param", "subdic", ":", "Sub"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L187-L204
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_parse_attrs
def _parse_attrs(elem, container=dict, **options): """ :param elem: ET Element object has attributes (elem.attrib) :param container: callble to make a container object :return: Parsed value or value itself depends on 'ac_parse_value' """ adic = dict((_tweak_ns(a, **options), v) for a, v in elem....
python
def _parse_attrs(elem, container=dict, **options): """ :param elem: ET Element object has attributes (elem.attrib) :param container: callble to make a container object :return: Parsed value or value itself depends on 'ac_parse_value' """ adic = dict((_tweak_ns(a, **options), v) for a, v in elem....
[ "def", "_parse_attrs", "(", "elem", ",", "container", "=", "dict", ",", "*", "*", "options", ")", ":", "adic", "=", "dict", "(", "(", "_tweak_ns", "(", "a", ",", "*", "*", "options", ")", ",", "v", ")", "for", "a", ",", "v", "in", "elem", ".", ...
:param elem: ET Element object has attributes (elem.attrib) :param container: callble to make a container object :return: Parsed value or value itself depends on 'ac_parse_value'
[ ":", "param", "elem", ":", "ET", "Element", "object", "has", "attributes", "(", "elem", ".", "attrib", ")", ":", "param", "container", ":", "callble", "to", "make", "a", "container", "object", ":", "return", ":", "Parsed", "value", "or", "value", "itself...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L207-L218
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_process_elem_attrs
def _process_elem_attrs(elem, dic, subdic, container=dict, attrs="@attrs", **options): """ :param elem: ET Element object or None :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param options: ...
python
def _process_elem_attrs(elem, dic, subdic, container=dict, attrs="@attrs", **options): """ :param elem: ET Element object or None :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param options: ...
[ "def", "_process_elem_attrs", "(", "elem", ",", "dic", ",", "subdic", ",", "container", "=", "dict", ",", "attrs", "=", "\"@attrs\"", ",", "*", "*", "options", ")", ":", "adic", "=", "_parse_attrs", "(", "elem", ",", "container", "=", "container", ",", ...
:param elem: ET Element object or None :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param options: Keyword options, see the description of :func:`elem_to_container` for more details. :return: None but updatin...
[ ":", "param", "elem", ":", "ET", "Element", "object", "or", "None", ":", "param", "dic", ":", "<container", ">", "(", "dict", "[", "-", "like", "]", ")", "object", "converted", "from", "elem", ":", "param", "subdic", ":", "Sub", "<container", ">", "o...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L221-L237
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_process_children_elems
def _process_children_elems(elem, dic, subdic, container=dict, children="@children", **options): """ :param elem: ET Element object or None :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param co...
python
def _process_children_elems(elem, dic, subdic, container=dict, children="@children", **options): """ :param elem: ET Element object or None :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param co...
[ "def", "_process_children_elems", "(", "elem", ",", "dic", ",", "subdic", ",", "container", "=", "dict", ",", "children", "=", "\"@children\"", ",", "*", "*", "options", ")", ":", "cdics", "=", "[", "elem_to_container", "(", "c", ",", "container", "=", "...
:param elem: ET Element object or None :param dic: <container> (dict[-like]) object converted from elem :param subdic: Sub <container> object converted from elem :param container: callble to make a container object :param children: Tag for children nodes :param options: Keyword options, see ...
[ ":", "param", "elem", ":", "ET", "Element", "object", "or", "None", ":", "param", "dic", ":", "<container", ">", "(", "dict", "[", "-", "like", "]", ")", "object", "converted", "from", "elem", ":", "param", "subdic", ":", "Sub", "<container", ">", "o...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L240-L264
ssato/python-anyconfig
src/anyconfig/backend/xml.py
elem_to_container
def elem_to_container(elem, container=dict, **options): """ Convert XML ElementTree Element to a collection of container objects. Elements are transformed to a node under special tagged nodes, attrs, text and children, to store the type of these elements basically, however, in some special cases li...
python
def elem_to_container(elem, container=dict, **options): """ Convert XML ElementTree Element to a collection of container objects. Elements are transformed to a node under special tagged nodes, attrs, text and children, to store the type of these elements basically, however, in some special cases li...
[ "def", "elem_to_container", "(", "elem", ",", "container", "=", "dict", ",", "*", "*", "options", ")", ":", "dic", "=", "container", "(", ")", "if", "elem", "is", "None", ":", "return", "dic", "elem", ".", "tag", "=", "_tweak_ns", "(", "elem", ".", ...
Convert XML ElementTree Element to a collection of container objects. Elements are transformed to a node under special tagged nodes, attrs, text and children, to store the type of these elements basically, however, in some special cases like the followings, these nodes are attached to the parent node d...
[ "Convert", "XML", "ElementTree", "Element", "to", "a", "collection", "of", "container", "objects", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L267-L307
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_complement_tag_options
def _complement_tag_options(options): """ :param options: Keyword options :: dict >>> ref = _TAGS.copy() >>> ref["text"] = "#text" >>> opts = _complement_tag_options({"tags": {"text": ref["text"]}}) >>> del opts["tags"] # To simplify comparison. >>> sorted(opts.items()) [('attrs', '@at...
python
def _complement_tag_options(options): """ :param options: Keyword options :: dict >>> ref = _TAGS.copy() >>> ref["text"] = "#text" >>> opts = _complement_tag_options({"tags": {"text": ref["text"]}}) >>> del opts["tags"] # To simplify comparison. >>> sorted(opts.items()) [('attrs', '@at...
[ "def", "_complement_tag_options", "(", "options", ")", ":", "if", "not", "all", "(", "nt", "in", "options", "for", "nt", "in", "_TAGS", ")", ":", "tags", "=", "options", ".", "get", "(", "\"tags\"", ",", "{", "}", ")", "for", "ntype", ",", "tag", "...
:param options: Keyword options :: dict >>> ref = _TAGS.copy() >>> ref["text"] = "#text" >>> opts = _complement_tag_options({"tags": {"text": ref["text"]}}) >>> del opts["tags"] # To simplify comparison. >>> sorted(opts.items()) [('attrs', '@attrs'), ('children', '@children'), ('text', '#text'...
[ ":", "param", "options", ":", "Keyword", "options", "::", "dict" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L310-L326
ssato/python-anyconfig
src/anyconfig/backend/xml.py
root_to_container
def root_to_container(root, container=dict, nspaces=None, **options): """ Convert XML ElementTree Root Element to a collection of container objects. :param root: etree root object or None :param container: callble to make a container object :param nspaces: A namespaces dict, {uri: prefix} or None ...
python
def root_to_container(root, container=dict, nspaces=None, **options): """ Convert XML ElementTree Root Element to a collection of container objects. :param root: etree root object or None :param container: callble to make a container object :param nspaces: A namespaces dict, {uri: prefix} or None ...
[ "def", "root_to_container", "(", "root", ",", "container", "=", "dict", ",", "nspaces", "=", "None", ",", "*", "*", "options", ")", ":", "tree", "=", "container", "(", ")", "if", "root", "is", "None", ":", "return", "tree", "if", "nspaces", "is", "no...
Convert XML ElementTree Root Element to a collection of container objects. :param root: etree root object or None :param container: callble to make a container object :param nspaces: A namespaces dict, {uri: prefix} or None :param options: Keyword options, - tags: Dict of tags for special node...
[ "Convert", "XML", "ElementTree", "Root", "Element", "to", "a", "collection", "of", "container", "objects", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L329-L350
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_elem_set_attrs
def _elem_set_attrs(obj, parent, to_str): """ :param obj: Container instance gives attributes of XML Element :param parent: XML ElementTree parent node object :param to_str: Callable to convert value to string or None :param options: Keyword options, see :func:`container_to_etree` :return: None...
python
def _elem_set_attrs(obj, parent, to_str): """ :param obj: Container instance gives attributes of XML Element :param parent: XML ElementTree parent node object :param to_str: Callable to convert value to string or None :param options: Keyword options, see :func:`container_to_etree` :return: None...
[ "def", "_elem_set_attrs", "(", "obj", ",", "parent", ",", "to_str", ")", ":", "for", "attr", ",", "val", "in", "anyconfig", ".", "compat", ".", "iteritems", "(", "obj", ")", ":", "parent", ".", "set", "(", "attr", ",", "to_str", "(", "val", ")", ")...
:param obj: Container instance gives attributes of XML Element :param parent: XML ElementTree parent node object :param to_str: Callable to convert value to string or None :param options: Keyword options, see :func:`container_to_etree` :return: None but parent will be modified
[ ":", "param", "obj", ":", "Container", "instance", "gives", "attributes", "of", "XML", "Element", ":", "param", "parent", ":", "XML", "ElementTree", "parent", "node", "object", ":", "param", "to_str", ":", "Callable", "to", "convert", "value", "to", "string"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L361-L371
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_elem_from_descendants
def _elem_from_descendants(children_nodes, **options): """ :param children_nodes: A list of child dict objects :param options: Keyword options, see :func:`container_to_etree` """ for child in children_nodes: # child should be a dict-like object. for ckey, cval in anyconfig.compat.iteritems(...
python
def _elem_from_descendants(children_nodes, **options): """ :param children_nodes: A list of child dict objects :param options: Keyword options, see :func:`container_to_etree` """ for child in children_nodes: # child should be a dict-like object. for ckey, cval in anyconfig.compat.iteritems(...
[ "def", "_elem_from_descendants", "(", "children_nodes", ",", "*", "*", "options", ")", ":", "for", "child", "in", "children_nodes", ":", "# child should be a dict-like object.", "for", "ckey", ",", "cval", "in", "anyconfig", ".", "compat", ".", "iteritems", "(", ...
:param children_nodes: A list of child dict objects :param options: Keyword options, see :func:`container_to_etree`
[ ":", "param", "children_nodes", ":", "A", "list", "of", "child", "dict", "objects", ":", "param", "options", ":", "Keyword", "options", "see", ":", "func", ":", "container_to_etree" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L374-L383
ssato/python-anyconfig
src/anyconfig/backend/xml.py
_get_or_update_parent
def _get_or_update_parent(key, val, to_str, parent=None, **options): """ :param key: Key of current child (dict{,-like} object) :param val: Value of current child (dict{,-like} object or [dict{,...}]) :param to_str: Callable to convert value to string :param parent: XML ElementTree parent node objec...
python
def _get_or_update_parent(key, val, to_str, parent=None, **options): """ :param key: Key of current child (dict{,-like} object) :param val: Value of current child (dict{,-like} object or [dict{,...}]) :param to_str: Callable to convert value to string :param parent: XML ElementTree parent node objec...
[ "def", "_get_or_update_parent", "(", "key", ",", "val", ",", "to_str", ",", "parent", "=", "None", ",", "*", "*", "options", ")", ":", "elem", "=", "ET", ".", "Element", "(", "key", ")", "vals", "=", "val", "if", "anyconfig", ".", "utils", ".", "is...
:param key: Key of current child (dict{,-like} object) :param val: Value of current child (dict{,-like} object or [dict{,...}]) :param to_str: Callable to convert value to string :param parent: XML ElementTree parent node object or None :param options: Keyword options, see :func:`container_to_etree`
[ ":", "param", "key", ":", "Key", "of", "current", "child", "(", "dict", "{", "-", "like", "}", "object", ")", ":", "param", "val", ":", "Value", "of", "current", "child", "(", "dict", "{", "-", "like", "}", "object", "or", "[", "dict", "{", "..."...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L386-L404
ssato/python-anyconfig
src/anyconfig/backend/xml.py
container_to_etree
def container_to_etree(obj, parent=None, to_str=None, **options): """ Convert a dict-like object to XML ElementTree. :param obj: Container instance to convert to :param parent: XML ElementTree parent node object or None :param to_str: Callable to convert value to string or None :param options: ...
python
def container_to_etree(obj, parent=None, to_str=None, **options): """ Convert a dict-like object to XML ElementTree. :param obj: Container instance to convert to :param parent: XML ElementTree parent node object or None :param to_str: Callable to convert value to string or None :param options: ...
[ "def", "container_to_etree", "(", "obj", ",", "parent", "=", "None", ",", "to_str", "=", "None", ",", "*", "*", "options", ")", ":", "if", "to_str", "is", "None", ":", "to_str", "=", "_to_str_fn", "(", "*", "*", "options", ")", "if", "not", "anyconfi...
Convert a dict-like object to XML ElementTree. :param obj: Container instance to convert to :param parent: XML ElementTree parent node object or None :param to_str: Callable to convert value to string or None :param options: Keyword options, - tags: Dict of tags for special nodes to keep XML i...
[ "Convert", "a", "dict", "-", "like", "object", "to", "XML", "ElementTree", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L410-L445
ssato/python-anyconfig
src/anyconfig/backend/xml.py
etree_write
def etree_write(tree, stream): """ Write XML ElementTree 'root' content into 'stream'. :param tree: XML ElementTree object :param stream: File or file-like object can write to """ try: tree.write(stream, encoding="utf-8", xml_declaration=True) except TypeError: tree.write(st...
python
def etree_write(tree, stream): """ Write XML ElementTree 'root' content into 'stream'. :param tree: XML ElementTree object :param stream: File or file-like object can write to """ try: tree.write(stream, encoding="utf-8", xml_declaration=True) except TypeError: tree.write(st...
[ "def", "etree_write", "(", "tree", ",", "stream", ")", ":", "try", ":", "tree", ".", "write", "(", "stream", ",", "encoding", "=", "\"utf-8\"", ",", "xml_declaration", "=", "True", ")", "except", "TypeError", ":", "tree", ".", "write", "(", "stream", "...
Write XML ElementTree 'root' content into 'stream'. :param tree: XML ElementTree object :param stream: File or file-like object can write to
[ "Write", "XML", "ElementTree", "root", "content", "into", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L448-L458
ssato/python-anyconfig
src/anyconfig/backend/xml.py
Parser.load_from_string
def load_from_string(self, content, container, **opts): """ Load config from XML snippet (a string 'content'). :param content: XML snippet string of str (python 2) or bytes (python 3) type :param container: callble to make a container object :param opts: optional key...
python
def load_from_string(self, content, container, **opts): """ Load config from XML snippet (a string 'content'). :param content: XML snippet string of str (python 2) or bytes (python 3) type :param container: callble to make a container object :param opts: optional key...
[ "def", "load_from_string", "(", "self", ",", "content", ",", "container", ",", "*", "*", "opts", ")", ":", "root", "=", "ET", ".", "fromstring", "(", "content", ")", "if", "anyconfig", ".", "compat", ".", "IS_PYTHON_3", ":", "stream", "=", "BytesIO", "...
Load config from XML snippet (a string 'content'). :param content: XML snippet string of str (python 2) or bytes (python 3) type :param container: callble to make a container object :param opts: optional keyword parameters passed to :return: Dict-like object holding config ...
[ "Load", "config", "from", "XML", "snippet", "(", "a", "string", "content", ")", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L474-L492
ssato/python-anyconfig
src/anyconfig/backend/xml.py
Parser.load_from_path
def load_from_path(self, filepath, container, **opts): """ :param filepath: XML file path :param container: callble to make a container object :param opts: optional keyword parameters to be sanitized :return: Dict-like object holding config parameters """ root = ...
python
def load_from_path(self, filepath, container, **opts): """ :param filepath: XML file path :param container: callble to make a container object :param opts: optional keyword parameters to be sanitized :return: Dict-like object holding config parameters """ root = ...
[ "def", "load_from_path", "(", "self", ",", "filepath", ",", "container", ",", "*", "*", "opts", ")", ":", "root", "=", "ET", ".", "parse", "(", "filepath", ")", ".", "getroot", "(", ")", "nspaces", "=", "_namespaces_from_file", "(", "filepath", ")", "r...
:param filepath: XML file path :param container: callble to make a container object :param opts: optional keyword parameters to be sanitized :return: Dict-like object holding config parameters
[ ":", "param", "filepath", ":", "XML", "file", "path", ":", "param", "container", ":", "callble", "to", "make", "a", "container", "object", ":", "param", "opts", ":", "optional", "keyword", "parameters", "to", "be", "sanitized" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L494-L505
ssato/python-anyconfig
src/anyconfig/backend/xml.py
Parser.load_from_stream
def load_from_stream(self, stream, container, **opts): """ :param stream: XML file or file-like object :param container: callble to make a container object :param opts: optional keyword parameters to be sanitized :return: Dict-like object holding config parameters """ ...
python
def load_from_stream(self, stream, container, **opts): """ :param stream: XML file or file-like object :param container: callble to make a container object :param opts: optional keyword parameters to be sanitized :return: Dict-like object holding config parameters """ ...
[ "def", "load_from_stream", "(", "self", ",", "stream", ",", "container", ",", "*", "*", "opts", ")", ":", "root", "=", "ET", ".", "parse", "(", "stream", ")", ".", "getroot", "(", ")", "path", "=", "anyconfig", ".", "utils", ".", "get_path_from_stream"...
:param stream: XML file or file-like object :param container: callble to make a container object :param opts: optional keyword parameters to be sanitized :return: Dict-like object holding config parameters
[ ":", "param", "stream", ":", "XML", "file", "or", "file", "-", "like", "object", ":", "param", "container", ":", "callble", "to", "make", "a", "container", "object", ":", "param", "opts", ":", "optional", "keyword", "parameters", "to", "be", "sanitized" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L507-L519
ssato/python-anyconfig
src/anyconfig/backend/xml.py
Parser.dump_to_string
def dump_to_string(self, cnf, **opts): """ :param cnf: Configuration data to dump :param opts: optional keyword parameters :return: string represents the configuration """ tree = container_to_etree(cnf, **opts) buf = BytesIO() etree_write(tree, buf) ...
python
def dump_to_string(self, cnf, **opts): """ :param cnf: Configuration data to dump :param opts: optional keyword parameters :return: string represents the configuration """ tree = container_to_etree(cnf, **opts) buf = BytesIO() etree_write(tree, buf) ...
[ "def", "dump_to_string", "(", "self", ",", "cnf", ",", "*", "*", "opts", ")", ":", "tree", "=", "container_to_etree", "(", "cnf", ",", "*", "*", "opts", ")", "buf", "=", "BytesIO", "(", ")", "etree_write", "(", "tree", ",", "buf", ")", "return", "b...
:param cnf: Configuration data to dump :param opts: optional keyword parameters :return: string represents the configuration
[ ":", "param", "cnf", ":", "Configuration", "data", "to", "dump", ":", "param", "opts", ":", "optional", "keyword", "parameters" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L521-L531
ssato/python-anyconfig
src/anyconfig/backend/xml.py
Parser.dump_to_stream
def dump_to_stream(self, cnf, stream, **opts): """ :param cnf: Configuration data to dump :param stream: Config file or file like object write to :param opts: optional keyword parameters """ tree = container_to_etree(cnf, **opts) etree_write(tree, stream)
python
def dump_to_stream(self, cnf, stream, **opts): """ :param cnf: Configuration data to dump :param stream: Config file or file like object write to :param opts: optional keyword parameters """ tree = container_to_etree(cnf, **opts) etree_write(tree, stream)
[ "def", "dump_to_stream", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "opts", ")", ":", "tree", "=", "container_to_etree", "(", "cnf", ",", "*", "*", "opts", ")", "etree_write", "(", "tree", ",", "stream", ")" ]
:param cnf: Configuration data to dump :param stream: Config file or file like object write to :param opts: optional keyword parameters
[ ":", "param", "cnf", ":", "Configuration", "data", "to", "dump", ":", "param", "stream", ":", "Config", "file", "or", "file", "like", "object", "write", "to", ":", "param", "opts", ":", "optional", "keyword", "parameters" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L533-L540
ssato/python-anyconfig
src/anyconfig/backend/yaml/common.py
filter_from_options
def filter_from_options(key, options): """ :param key: Key str in options :param options: Mapping object :return: New mapping object from 'options' in which the item with 'key' filtered >>> filter_from_options('a', dict(a=1, b=2)) {'b': 2} """ return anyconfig.utils.filter_optio...
python
def filter_from_options(key, options): """ :param key: Key str in options :param options: Mapping object :return: New mapping object from 'options' in which the item with 'key' filtered >>> filter_from_options('a', dict(a=1, b=2)) {'b': 2} """ return anyconfig.utils.filter_optio...
[ "def", "filter_from_options", "(", "key", ",", "options", ")", ":", "return", "anyconfig", ".", "utils", ".", "filter_options", "(", "[", "k", "for", "k", "in", "options", ".", "keys", "(", ")", "if", "k", "!=", "key", "]", ",", "options", ")" ]
:param key: Key str in options :param options: Mapping object :return: New mapping object from 'options' in which the item with 'key' filtered >>> filter_from_options('a', dict(a=1, b=2)) {'b': 2}
[ ":", "param", "key", ":", "Key", "str", "in", "options", ":", "param", "options", ":", "Mapping", "object", ":", "return", ":", "New", "mapping", "object", "from", "options", "in", "which", "the", "item", "with", "key", "filtered" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/common.py#L12-L23
ssato/python-anyconfig
src/anyconfig/backend/yaml/pyyaml.py
_customized_loader
def _customized_loader(container, loader=Loader, mapping_tag=_MAPPING_TAG): """ Create or update loader with making given callble 'container' to make mapping objects such as dict and OrderedDict, used to construct python object from yaml mapping node internally. :param container: Set container used...
python
def _customized_loader(container, loader=Loader, mapping_tag=_MAPPING_TAG): """ Create or update loader with making given callble 'container' to make mapping objects such as dict and OrderedDict, used to construct python object from yaml mapping node internally. :param container: Set container used...
[ "def", "_customized_loader", "(", "container", ",", "loader", "=", "Loader", ",", "mapping_tag", "=", "_MAPPING_TAG", ")", ":", "def", "construct_mapping", "(", "loader", ",", "node", ",", "deep", "=", "False", ")", ":", "\"\"\"Construct python object from yaml ma...
Create or update loader with making given callble 'container' to make mapping objects such as dict and OrderedDict, used to construct python object from yaml mapping node internally. :param container: Set container used internally
[ "Create", "or", "update", "loader", "with", "making", "given", "callble", "container", "to", "make", "mapping", "objects", "such", "as", "dict", "and", "OrderedDict", "used", "to", "construct", "python", "object", "from", "yaml", "mapping", "node", "internally",...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/pyyaml.py#L58-L104
ssato/python-anyconfig
src/anyconfig/backend/yaml/pyyaml.py
_customized_dumper
def _customized_dumper(container, dumper=Dumper): """ Coutnerpart of :func:`_customized_loader` for dumpers. """ def container_representer(dumper, data, mapping_tag=_MAPPING_TAG): """Container representer. """ return dumper.represent_mapping(mapping_tag, data.items()) def us...
python
def _customized_dumper(container, dumper=Dumper): """ Coutnerpart of :func:`_customized_loader` for dumpers. """ def container_representer(dumper, data, mapping_tag=_MAPPING_TAG): """Container representer. """ return dumper.represent_mapping(mapping_tag, data.items()) def us...
[ "def", "_customized_dumper", "(", "container", ",", "dumper", "=", "Dumper", ")", ":", "def", "container_representer", "(", "dumper", ",", "data", ",", "mapping_tag", "=", "_MAPPING_TAG", ")", ":", "\"\"\"Container representer.\n \"\"\"", "return", "dumper", ...
Coutnerpart of :func:`_customized_loader` for dumpers.
[ "Coutnerpart", "of", ":", "func", ":", "_customized_loader", "for", "dumpers", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/pyyaml.py#L107-L128
ssato/python-anyconfig
src/anyconfig/backend/yaml/pyyaml.py
yml_fnc
def yml_fnc(fname, *args, **options): """An wrapper of yaml.safe_load, yaml.load, yaml.safe_dump and yaml.dump. :param fname: "load" or "dump", not checked but it should be OK. see also :func:`yml_load` and :func:`yml_dump` :param args: [stream] for load or [cnf, stream] for dump :param...
python
def yml_fnc(fname, *args, **options): """An wrapper of yaml.safe_load, yaml.load, yaml.safe_dump and yaml.dump. :param fname: "load" or "dump", not checked but it should be OK. see also :func:`yml_load` and :func:`yml_dump` :param args: [stream] for load or [cnf, stream] for dump :param...
[ "def", "yml_fnc", "(", "fname", ",", "*", "args", ",", "*", "*", "options", ")", ":", "key", "=", "\"ac_safe\"", "fnc", "=", "getattr", "(", "yaml", ",", "r\"safe_\"", "+", "fname", "if", "options", ".", "get", "(", "key", ")", "else", "fname", ")"...
An wrapper of yaml.safe_load, yaml.load, yaml.safe_dump and yaml.dump. :param fname: "load" or "dump", not checked but it should be OK. see also :func:`yml_load` and :func:`yml_dump` :param args: [stream] for load or [cnf, stream] for dump :param options: keyword args may contain "ac_safe" ...
[ "An", "wrapper", "of", "yaml", ".", "safe_load", "yaml", ".", "load", "yaml", ".", "safe_dump", "and", "yaml", ".", "dump", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/pyyaml.py#L131-L142
ssato/python-anyconfig
src/anyconfig/backend/yaml/pyyaml.py
yml_load
def yml_load(stream, container, yml_fnc=yml_fnc, **options): """An wrapper of yaml.safe_load and yaml.load. :param stream: a file or file-like object to load YAML content :param container: callble to make a container object :return: Mapping object """ if options.get("ac_safe", False): ...
python
def yml_load(stream, container, yml_fnc=yml_fnc, **options): """An wrapper of yaml.safe_load and yaml.load. :param stream: a file or file-like object to load YAML content :param container: callble to make a container object :return: Mapping object """ if options.get("ac_safe", False): ...
[ "def", "yml_load", "(", "stream", ",", "container", ",", "yml_fnc", "=", "yml_fnc", ",", "*", "*", "options", ")", ":", "if", "options", ".", "get", "(", "\"ac_safe\"", ",", "False", ")", ":", "options", "=", "{", "}", "# yaml.safe_load does not process Lo...
An wrapper of yaml.safe_load and yaml.load. :param stream: a file or file-like object to load YAML content :param container: callble to make a container object :return: Mapping object
[ "An", "wrapper", "of", "yaml", ".", "safe_load", "and", "yaml", ".", "load", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/pyyaml.py#L145-L167
ssato/python-anyconfig
src/anyconfig/backend/yaml/pyyaml.py
yml_dump
def yml_dump(data, stream, yml_fnc=yml_fnc, **options): """An wrapper of yaml.safe_dump and yaml.dump. :param data: Some data to dump :param stream: a file or file-like object to dump YAML data """ _is_dict = anyconfig.utils.is_dict_like(data) if options.get("ac_safe", False): options ...
python
def yml_dump(data, stream, yml_fnc=yml_fnc, **options): """An wrapper of yaml.safe_dump and yaml.dump. :param data: Some data to dump :param stream: a file or file-like object to dump YAML data """ _is_dict = anyconfig.utils.is_dict_like(data) if options.get("ac_safe", False): options ...
[ "def", "yml_dump", "(", "data", ",", "stream", ",", "yml_fnc", "=", "yml_fnc", ",", "*", "*", "options", ")", ":", "_is_dict", "=", "anyconfig", ".", "utils", ".", "is_dict_like", "(", "data", ")", "if", "options", ".", "get", "(", "\"ac_safe\"", ",", ...
An wrapper of yaml.safe_dump and yaml.dump. :param data: Some data to dump :param stream: a file or file-like object to dump YAML data
[ "An", "wrapper", "of", "yaml", ".", "safe_dump", "and", "yaml", ".", "dump", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/yaml/pyyaml.py#L170-L190
ssato/python-anyconfig
src/anyconfig/dicts.py
_split_path
def _split_path(path, seps=PATH_SEPS): """ Parse path expression and return list of path items. :param path: Path expression may contain separator chars. :param seps: Separator char candidates. :return: A list of keys to fetch object[s] later. >>> assert _split_path('') == [] >>> assert _s...
python
def _split_path(path, seps=PATH_SEPS): """ Parse path expression and return list of path items. :param path: Path expression may contain separator chars. :param seps: Separator char candidates. :return: A list of keys to fetch object[s] later. >>> assert _split_path('') == [] >>> assert _s...
[ "def", "_split_path", "(", "path", ",", "seps", "=", "PATH_SEPS", ")", ":", "if", "not", "path", ":", "return", "[", "]", "for", "sep", "in", "seps", ":", "if", "sep", "in", "path", ":", "if", "path", "==", "sep", ":", "# Special case, '/' or '.' only....
Parse path expression and return list of path items. :param path: Path expression may contain separator chars. :param seps: Separator char candidates. :return: A list of keys to fetch object[s] later. >>> assert _split_path('') == [] >>> assert _split_path('/') == [''] # JSON Pointer spec expects...
[ "Parse", "path", "expression", "and", "return", "list", "of", "path", "items", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L50-L74
ssato/python-anyconfig
src/anyconfig/dicts.py
mk_nested_dic
def mk_nested_dic(path, val, seps=PATH_SEPS): """ Make a nested dict iteratively. :param path: Path expression to make a nested dict :param val: Value to set :param seps: Separator char candidates >>> mk_nested_dic("a.b.c", 1) {'a': {'b': {'c': 1}}} >>> mk_nested_dic("/a/b/c", 1) {...
python
def mk_nested_dic(path, val, seps=PATH_SEPS): """ Make a nested dict iteratively. :param path: Path expression to make a nested dict :param val: Value to set :param seps: Separator char candidates >>> mk_nested_dic("a.b.c", 1) {'a': {'b': {'c': 1}}} >>> mk_nested_dic("/a/b/c", 1) {...
[ "def", "mk_nested_dic", "(", "path", ",", "val", ",", "seps", "=", "PATH_SEPS", ")", ":", "ret", "=", "None", "for", "key", "in", "reversed", "(", "_split_path", "(", "path", ",", "seps", ")", ")", ":", "ret", "=", "{", "key", ":", "val", "if", "...
Make a nested dict iteratively. :param path: Path expression to make a nested dict :param val: Value to set :param seps: Separator char candidates >>> mk_nested_dic("a.b.c", 1) {'a': {'b': {'c': 1}}} >>> mk_nested_dic("/a/b/c", 1) {'a': {'b': {'c': 1}}}
[ "Make", "a", "nested", "dict", "iteratively", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L77-L94
ssato/python-anyconfig
src/anyconfig/dicts.py
get
def get(dic, path, seps=PATH_SEPS, idx_reg=_JSNP_GET_ARRAY_IDX_REG): """getter for nested dicts. :param dic: a dict[-like] object :param path: Path expression to point object wanted :param seps: Separator char candidates :return: A tuple of (result_object, error_message) >>> d = {'a': {'b': {'...
python
def get(dic, path, seps=PATH_SEPS, idx_reg=_JSNP_GET_ARRAY_IDX_REG): """getter for nested dicts. :param dic: a dict[-like] object :param path: Path expression to point object wanted :param seps: Separator char candidates :return: A tuple of (result_object, error_message) >>> d = {'a': {'b': {'...
[ "def", "get", "(", "dic", ",", "path", ",", "seps", "=", "PATH_SEPS", ",", "idx_reg", "=", "_JSNP_GET_ARRAY_IDX_REG", ")", ":", "items", "=", "[", "_jsnp_unescape", "(", "p", ")", "for", "p", "in", "_split_path", "(", "path", ",", "seps", ")", "]", "...
getter for nested dicts. :param dic: a dict[-like] object :param path: Path expression to point object wanted :param seps: Separator char candidates :return: A tuple of (result_object, error_message) >>> d = {'a': {'b': {'c': 0, 'd': [1, 2]}}, '': 3} >>> assert get(d, '/') == (3, '') # key be...
[ "getter", "for", "nested", "dicts", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L97-L131
ssato/python-anyconfig
src/anyconfig/dicts.py
set_
def set_(dic, path, val, seps=PATH_SEPS): """setter for nested dicts. :param dic: a dict[-like] object support recursive merge operations :param path: Path expression to point object wanted :param seps: Separator char candidates >>> d = dict(a=1, b=dict(c=2, )) >>> set_(d, 'a.b.d', 3) >>> ...
python
def set_(dic, path, val, seps=PATH_SEPS): """setter for nested dicts. :param dic: a dict[-like] object support recursive merge operations :param path: Path expression to point object wanted :param seps: Separator char candidates >>> d = dict(a=1, b=dict(c=2, )) >>> set_(d, 'a.b.d', 3) >>> ...
[ "def", "set_", "(", "dic", ",", "path", ",", "val", ",", "seps", "=", "PATH_SEPS", ")", ":", "merge", "(", "dic", ",", "mk_nested_dic", "(", "path", ",", "val", ",", "seps", ")", ",", "ac_merge", "=", "MS_DICTS", ")" ]
setter for nested dicts. :param dic: a dict[-like] object support recursive merge operations :param path: Path expression to point object wanted :param seps: Separator char candidates >>> d = dict(a=1, b=dict(c=2, )) >>> set_(d, 'a.b.d', 3) >>> d['a']['b']['d'] 3
[ "setter", "for", "nested", "dicts", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L134-L146
ssato/python-anyconfig
src/anyconfig/dicts.py
_update_with_replace
def _update_with_replace(self, other, key, val=None, **options): """ Replace value of a mapping object 'self' with 'other' has if both have same keys on update. Otherwise, just keep the value of 'self'. :param self: mapping object to update with 'other' :param other: mapping object to update 'self'...
python
def _update_with_replace(self, other, key, val=None, **options): """ Replace value of a mapping object 'self' with 'other' has if both have same keys on update. Otherwise, just keep the value of 'self'. :param self: mapping object to update with 'other' :param other: mapping object to update 'self'...
[ "def", "_update_with_replace", "(", "self", ",", "other", ",", "key", ",", "val", "=", "None", ",", "*", "*", "options", ")", ":", "self", "[", "key", "]", "=", "other", "[", "key", "]", "if", "val", "is", "None", "else", "val" ]
Replace value of a mapping object 'self' with 'other' has if both have same keys on update. Otherwise, just keep the value of 'self'. :param self: mapping object to update with 'other' :param other: mapping object to update 'self' :param key: key of mapping object to update :param val: value to upd...
[ "Replace", "value", "of", "a", "mapping", "object", "self", "with", "other", "has", "if", "both", "have", "same", "keys", "on", "update", ".", "Otherwise", "just", "keep", "the", "value", "of", "self", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L161-L173
ssato/python-anyconfig
src/anyconfig/dicts.py
_merge_list
def _merge_list(self, key, lst): """ :param key: self[key] will be updated :param lst: Other list to merge """ self[key] += [x for x in lst if x not in self[key]]
python
def _merge_list(self, key, lst): """ :param key: self[key] will be updated :param lst: Other list to merge """ self[key] += [x for x in lst if x not in self[key]]
[ "def", "_merge_list", "(", "self", ",", "key", ",", "lst", ")", ":", "self", "[", "key", "]", "+=", "[", "x", "for", "x", "in", "lst", "if", "x", "not", "in", "self", "[", "key", "]", "]" ]
:param key: self[key] will be updated :param lst: Other list to merge
[ ":", "param", "key", ":", "self", "[", "key", "]", "will", "be", "updated", ":", "param", "lst", ":", "Other", "list", "to", "merge" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L192-L197
ssato/python-anyconfig
src/anyconfig/dicts.py
_update_with_merge
def _update_with_merge(self, other, key, val=None, merge_lists=False, **options): """ Merge the value of self with other's recursively. Behavior of merge will be vary depends on types of original and new values. - mapping vs. mapping -> merge recursively - list vs. list -> va...
python
def _update_with_merge(self, other, key, val=None, merge_lists=False, **options): """ Merge the value of self with other's recursively. Behavior of merge will be vary depends on types of original and new values. - mapping vs. mapping -> merge recursively - list vs. list -> va...
[ "def", "_update_with_merge", "(", "self", ",", "other", ",", "key", ",", "val", "=", "None", ",", "merge_lists", "=", "False", ",", "*", "*", "options", ")", ":", "if", "val", "is", "None", ":", "val", "=", "other", "[", "key", "]", "if", "key", ...
Merge the value of self with other's recursively. Behavior of merge will be vary depends on types of original and new values. - mapping vs. mapping -> merge recursively - list vs. list -> vary depends on 'merge_lists'. see its description. :param other: a dict[-like] object or a list of (key, value) t...
[ "Merge", "the", "value", "of", "self", "with", "other", "s", "recursively", ".", "Behavior", "of", "merge", "will", "be", "vary", "depends", "on", "types", "of", "original", "and", "new", "values", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L208-L240
ssato/python-anyconfig
src/anyconfig/dicts.py
_update_with_merge_lists
def _update_with_merge_lists(self, other, key, val=None, **options): """ Similar to _update_with_merge but merge lists always. :param self: mapping object to update with 'other' :param other: mapping object to update 'self' :param key: key of mapping object to update :param val: value to update...
python
def _update_with_merge_lists(self, other, key, val=None, **options): """ Similar to _update_with_merge but merge lists always. :param self: mapping object to update with 'other' :param other: mapping object to update 'self' :param key: key of mapping object to update :param val: value to update...
[ "def", "_update_with_merge_lists", "(", "self", ",", "other", ",", "key", ",", "val", "=", "None", ",", "*", "*", "options", ")", ":", "_update_with_merge", "(", "self", ",", "other", ",", "key", ",", "val", "=", "val", ",", "merge_lists", "=", "True",...
Similar to _update_with_merge but merge lists always. :param self: mapping object to update with 'other' :param other: mapping object to update 'self' :param key: key of mapping object to update :param val: value to update self alternatively :return: None but 'self' will be updated
[ "Similar", "to", "_update_with_merge", "but", "merge", "lists", "always", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L243-L254
ssato/python-anyconfig
src/anyconfig/dicts.py
_get_update_fn
def _get_update_fn(strategy): """ Select dict-like class based on merge strategy and orderness of keys. :param merge: Specify strategy from MERGE_STRATEGIES of how to merge dicts. :return: Callable to update objects """ if strategy is None: strategy = MS_DICTS try: return _M...
python
def _get_update_fn(strategy): """ Select dict-like class based on merge strategy and orderness of keys. :param merge: Specify strategy from MERGE_STRATEGIES of how to merge dicts. :return: Callable to update objects """ if strategy is None: strategy = MS_DICTS try: return _M...
[ "def", "_get_update_fn", "(", "strategy", ")", ":", "if", "strategy", "is", "None", ":", "strategy", "=", "MS_DICTS", "try", ":", "return", "_MERGE_FNS", "[", "strategy", "]", "except", "KeyError", ":", "if", "callable", "(", "strategy", ")", ":", "return"...
Select dict-like class based on merge strategy and orderness of keys. :param merge: Specify strategy from MERGE_STRATEGIES of how to merge dicts. :return: Callable to update objects
[ "Select", "dict", "-", "like", "class", "based", "on", "merge", "strategy", "and", "orderness", "of", "keys", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L263-L278
ssato/python-anyconfig
src/anyconfig/dicts.py
merge
def merge(self, other, ac_merge=MS_DICTS, **options): """ Update (merge) a mapping object 'self' with other mapping object or an iterable yields (key, value) tuples based on merge strategy 'ac_merge'. :param others: a list of dict[-like] objects or (key, value) tuples :param another: optional keywo...
python
def merge(self, other, ac_merge=MS_DICTS, **options): """ Update (merge) a mapping object 'self' with other mapping object or an iterable yields (key, value) tuples based on merge strategy 'ac_merge'. :param others: a list of dict[-like] objects or (key, value) tuples :param another: optional keywo...
[ "def", "merge", "(", "self", ",", "other", ",", "ac_merge", "=", "MS_DICTS", ",", "*", "*", "options", ")", ":", "_update_fn", "=", "_get_update_fn", "(", "ac_merge", ")", "if", "hasattr", "(", "other", ",", "\"keys\"", ")", ":", "for", "key", "in", ...
Update (merge) a mapping object 'self' with other mapping object or an iterable yields (key, value) tuples based on merge strategy 'ac_merge'. :param others: a list of dict[-like] objects or (key, value) tuples :param another: optional keyword arguments to update self more :param ac_merge: Merge strate...
[ "Update", "(", "merge", ")", "a", "mapping", "object", "self", "with", "other", "mapping", "object", "or", "an", "iterable", "yields", "(", "key", "value", ")", "tuples", "based", "on", "merge", "strategy", "ac_merge", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L281-L300
ssato/python-anyconfig
src/anyconfig/dicts.py
_make_recur
def _make_recur(obj, make_fn, ac_ordered=False, ac_dict=None, **options): """ :param obj: A mapping objects or other primitive object :param make_fn: Function to make/convert to :param ac_ordered: Use OrderedDict instead of dict to keep order of items :param ac_dict: Callable to convert 'obj' to map...
python
def _make_recur(obj, make_fn, ac_ordered=False, ac_dict=None, **options): """ :param obj: A mapping objects or other primitive object :param make_fn: Function to make/convert to :param ac_ordered: Use OrderedDict instead of dict to keep order of items :param ac_dict: Callable to convert 'obj' to map...
[ "def", "_make_recur", "(", "obj", ",", "make_fn", ",", "ac_ordered", "=", "False", ",", "ac_dict", "=", "None", ",", "*", "*", "options", ")", ":", "if", "ac_dict", "is", "None", ":", "ac_dict", "=", "anyconfig", ".", "compat", ".", "OrderedDict", "if"...
:param obj: A mapping objects or other primitive object :param make_fn: Function to make/convert to :param ac_ordered: Use OrderedDict instead of dict to keep order of items :param ac_dict: Callable to convert 'obj' to mapping object :param options: Optional keyword arguments. :return: Mapping obje...
[ ":", "param", "obj", ":", "A", "mapping", "objects", "or", "other", "primitive", "object", ":", "param", "make_fn", ":", "Function", "to", "make", "/", "convert", "to", ":", "param", "ac_ordered", ":", "Use", "OrderedDict", "instead", "of", "dict", "to", ...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L303-L317
ssato/python-anyconfig
src/anyconfig/dicts.py
_make_iter
def _make_iter(obj, make_fn, **options): """ :param obj: A mapping objects or other primitive object :param make_fn: Function to make/convert to :param options: Optional keyword arguments. :return: Mapping object """ return type(obj)(make_fn(v, **options) for v in obj)
python
def _make_iter(obj, make_fn, **options): """ :param obj: A mapping objects or other primitive object :param make_fn: Function to make/convert to :param options: Optional keyword arguments. :return: Mapping object """ return type(obj)(make_fn(v, **options) for v in obj)
[ "def", "_make_iter", "(", "obj", ",", "make_fn", ",", "*", "*", "options", ")", ":", "return", "type", "(", "obj", ")", "(", "make_fn", "(", "v", ",", "*", "*", "options", ")", "for", "v", "in", "obj", ")" ]
:param obj: A mapping objects or other primitive object :param make_fn: Function to make/convert to :param options: Optional keyword arguments. :return: Mapping object
[ ":", "param", "obj", ":", "A", "mapping", "objects", "or", "other", "primitive", "object", ":", "param", "make_fn", ":", "Function", "to", "make", "/", "convert", "to", ":", "param", "options", ":", "Optional", "keyword", "arguments", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L320-L328
ssato/python-anyconfig
src/anyconfig/dicts.py
convert_to
def convert_to(obj, ac_ordered=False, ac_dict=None, **options): """ Convert a mapping objects to a dict or object of 'to_type' recursively. Borrowed basic idea and implementation from bunch.unbunchify. (bunch is distributed under MIT license same as this.) :param obj: A mapping objects or other pri...
python
def convert_to(obj, ac_ordered=False, ac_dict=None, **options): """ Convert a mapping objects to a dict or object of 'to_type' recursively. Borrowed basic idea and implementation from bunch.unbunchify. (bunch is distributed under MIT license same as this.) :param obj: A mapping objects or other pri...
[ "def", "convert_to", "(", "obj", ",", "ac_ordered", "=", "False", ",", "ac_dict", "=", "None", ",", "*", "*", "options", ")", ":", "options", ".", "update", "(", "ac_ordered", "=", "ac_ordered", ",", "ac_dict", "=", "ac_dict", ")", "if", "anyconfig", "...
Convert a mapping objects to a dict or object of 'to_type' recursively. Borrowed basic idea and implementation from bunch.unbunchify. (bunch is distributed under MIT license same as this.) :param obj: A mapping objects or other primitive object :param ac_ordered: Use OrderedDict instead of dict to keep...
[ "Convert", "a", "mapping", "objects", "to", "a", "dict", "or", "object", "of", "to_type", "recursively", ".", "Borrowed", "basic", "idea", "and", "implementation", "from", "bunch", ".", "unbunchify", ".", "(", "bunch", "is", "distributed", "under", "MIT", "l...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/dicts.py#L331-L356
ssato/python-anyconfig
src/anyconfig/backend/properties.py
_parseline
def _parseline(line): """ Parse a line of Java properties file. :param line: A string to parse, must not start with ' ', '#' or '!' (comment) :return: A tuple of (key, value), both key and value may be None >>> _parseline(" ") (None, '') >>> _parseline("aaa:") ('aaa', '') >...
python
def _parseline(line): """ Parse a line of Java properties file. :param line: A string to parse, must not start with ' ', '#' or '!' (comment) :return: A tuple of (key, value), both key and value may be None >>> _parseline(" ") (None, '') >>> _parseline("aaa:") ('aaa', '') >...
[ "def", "_parseline", "(", "line", ")", ":", "pair", "=", "re", ".", "split", "(", "r\"(?:\\s+)?(?:(?<!\\\\)[=:])\"", ",", "line", ".", "strip", "(", ")", ",", "1", ")", "key", "=", "pair", "[", "0", "]", ".", "rstrip", "(", ")", "if", "len", "(", ...
Parse a line of Java properties file. :param line: A string to parse, must not start with ' ', '#' or '!' (comment) :return: A tuple of (key, value), both key and value may be None >>> _parseline(" ") (None, '') >>> _parseline("aaa:") ('aaa', '') >>> _parseline(" aaa:") ('aaa',...
[ "Parse", "a", "line", "of", "Java", "properties", "file", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/properties.py#L46-L74
ssato/python-anyconfig
src/anyconfig/backend/properties.py
_pre_process_line
def _pre_process_line(line, comment_markers=_COMMENT_MARKERS): """ Preprocess a line in properties; strip comments, etc. :param line: A string not starting w/ any white spaces and ending w/ line breaks. It may be empty. see also: :func:`load`. :param comment_markers: Comment markers, e....
python
def _pre_process_line(line, comment_markers=_COMMENT_MARKERS): """ Preprocess a line in properties; strip comments, etc. :param line: A string not starting w/ any white spaces and ending w/ line breaks. It may be empty. see also: :func:`load`. :param comment_markers: Comment markers, e....
[ "def", "_pre_process_line", "(", "line", ",", "comment_markers", "=", "_COMMENT_MARKERS", ")", ":", "if", "not", "line", ":", "return", "None", "if", "any", "(", "c", "in", "line", "for", "c", "in", "comment_markers", ")", ":", "if", "line", ".", "starts...
Preprocess a line in properties; strip comments, etc. :param line: A string not starting w/ any white spaces and ending w/ line breaks. It may be empty. see also: :func:`load`. :param comment_markers: Comment markers, e.g. '#' (hash) >>> _pre_process_line('') is None True >>> s0 = ...
[ "Preprocess", "a", "line", "in", "properties", ";", "strip", "comments", "etc", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/properties.py#L77-L103
ssato/python-anyconfig
src/anyconfig/backend/properties.py
load
def load(stream, container=dict, comment_markers=_COMMENT_MARKERS): """ Load and parse Java properties file given as a fiel or file-like object 'stream'. :param stream: A file or file like object of Java properties files :param container: Factory function to create a dict-like object to sto...
python
def load(stream, container=dict, comment_markers=_COMMENT_MARKERS): """ Load and parse Java properties file given as a fiel or file-like object 'stream'. :param stream: A file or file like object of Java properties files :param container: Factory function to create a dict-like object to sto...
[ "def", "load", "(", "stream", ",", "container", "=", "dict", ",", "comment_markers", "=", "_COMMENT_MARKERS", ")", ":", "ret", "=", "container", "(", ")", "prev", "=", "\"\"", "for", "line", "in", "stream", ".", "readlines", "(", ")", ":", "line", "=",...
Load and parse Java properties file given as a fiel or file-like object 'stream'. :param stream: A file or file like object of Java properties files :param container: Factory function to create a dict-like object to store properties :param comment_markers: Comment markers, e.g. '#' (hash) :...
[ "Load", "and", "parse", "Java", "properties", "file", "given", "as", "a", "fiel", "or", "file", "-", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/properties.py#L136-L193
ssato/python-anyconfig
src/anyconfig/template.py
copen
def copen(filepath, flag='r', encoding=None): """ FIXME: How to test this ? >>> c = copen(__file__) >>> c is not None True """ if encoding is None: encoding = locale.getdefaultlocale()[1] return codecs.open(filepath, flag, encoding)
python
def copen(filepath, flag='r', encoding=None): """ FIXME: How to test this ? >>> c = copen(__file__) >>> c is not None True """ if encoding is None: encoding = locale.getdefaultlocale()[1] return codecs.open(filepath, flag, encoding)
[ "def", "copen", "(", "filepath", ",", "flag", "=", "'r'", ",", "encoding", "=", "None", ")", ":", "if", "encoding", "is", "None", ":", "encoding", "=", "locale", ".", "getdefaultlocale", "(", ")", "[", "1", "]", "return", "codecs", ".", "open", "(", ...
FIXME: How to test this ? >>> c = copen(__file__) >>> c is not None True
[ "FIXME", ":", "How", "to", "test", "this", "?" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/template.py#L50-L62
ssato/python-anyconfig
src/anyconfig/template.py
make_template_paths
def make_template_paths(template_file, paths=None): """ Make up a list of template search paths from given 'template_file' (absolute or relative path to the template file) and/or 'paths' (a list of template search paths given by user). NOTE: User-given 'paths' will take higher priority over a dir o...
python
def make_template_paths(template_file, paths=None): """ Make up a list of template search paths from given 'template_file' (absolute or relative path to the template file) and/or 'paths' (a list of template search paths given by user). NOTE: User-given 'paths' will take higher priority over a dir o...
[ "def", "make_template_paths", "(", "template_file", ",", "paths", "=", "None", ")", ":", "tmpldir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "template_file", ")", ")", "return", "[", "tmpldir", "]", "if", "pa...
Make up a list of template search paths from given 'template_file' (absolute or relative path to the template file) and/or 'paths' (a list of template search paths given by user). NOTE: User-given 'paths' will take higher priority over a dir of template_file. :param template_file: Absolute or rela...
[ "Make", "up", "a", "list", "of", "template", "search", "paths", "from", "given", "template_file", "(", "absolute", "or", "relative", "path", "to", "the", "template", "file", ")", "and", "/", "or", "paths", "(", "a", "list", "of", "template", "search", "p...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/template.py#L65-L89
ssato/python-anyconfig
src/anyconfig/template.py
render_s
def render_s(tmpl_s, ctx=None, paths=None, filters=None): """ Compile and render given template string 'tmpl_s' with context 'context'. :param tmpl_s: Template string :param ctx: Context dict needed to instantiate templates :param paths: Template search paths :param filters: Custom filters to a...
python
def render_s(tmpl_s, ctx=None, paths=None, filters=None): """ Compile and render given template string 'tmpl_s' with context 'context'. :param tmpl_s: Template string :param ctx: Context dict needed to instantiate templates :param paths: Template search paths :param filters: Custom filters to a...
[ "def", "render_s", "(", "tmpl_s", ",", "ctx", "=", "None", ",", "paths", "=", "None", ",", "filters", "=", "None", ")", ":", "if", "paths", "is", "None", ":", "paths", "=", "[", "os", ".", "curdir", "]", "env", "=", "tmpl_env", "(", "paths", ")",...
Compile and render given template string 'tmpl_s' with context 'context'. :param tmpl_s: Template string :param ctx: Context dict needed to instantiate templates :param paths: Template search paths :param filters: Custom filters to add into template engine :return: Compiled result (str) >>> re...
[ "Compile", "and", "render", "given", "template", "string", "tmpl_s", "with", "context", "context", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/template.py#L92-L122
ssato/python-anyconfig
src/anyconfig/template.py
render_impl
def render_impl(template_file, ctx=None, paths=None, filters=None): """ :param template_file: Absolute or relative path to the template file :param ctx: Context dict needed to instantiate templates :param filters: Custom filters to add into template engine :return: Compiled result (str) """ ...
python
def render_impl(template_file, ctx=None, paths=None, filters=None): """ :param template_file: Absolute or relative path to the template file :param ctx: Context dict needed to instantiate templates :param filters: Custom filters to add into template engine :return: Compiled result (str) """ ...
[ "def", "render_impl", "(", "template_file", ",", "ctx", "=", "None", ",", "paths", "=", "None", ",", "filters", "=", "None", ")", ":", "env", "=", "tmpl_env", "(", "make_template_paths", "(", "template_file", ",", "paths", ")", ")", "if", "env", "is", ...
:param template_file: Absolute or relative path to the template file :param ctx: Context dict needed to instantiate templates :param filters: Custom filters to add into template engine :return: Compiled result (str)
[ ":", "param", "template_file", ":", "Absolute", "or", "relative", "path", "to", "the", "template", "file", ":", "param", "ctx", ":", "Context", "dict", "needed", "to", "instantiate", "templates", ":", "param", "filters", ":", "Custom", "filters", "to", "add"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/template.py#L125-L143
ssato/python-anyconfig
src/anyconfig/template.py
render
def render(filepath, ctx=None, paths=None, ask=False, filters=None): """ Compile and render template and return the result as a string. :param template_file: Absolute or relative path to the template file :param ctx: Context dict needed to instantiate templates :param paths: Template search paths ...
python
def render(filepath, ctx=None, paths=None, ask=False, filters=None): """ Compile and render template and return the result as a string. :param template_file: Absolute or relative path to the template file :param ctx: Context dict needed to instantiate templates :param paths: Template search paths ...
[ "def", "render", "(", "filepath", ",", "ctx", "=", "None", ",", "paths", "=", "None", ",", "ask", "=", "False", ",", "filters", "=", "None", ")", ":", "try", ":", "return", "render_impl", "(", "filepath", ",", "ctx", ",", "paths", ",", "filters", "...
Compile and render template and return the result as a string. :param template_file: Absolute or relative path to the template file :param ctx: Context dict needed to instantiate templates :param paths: Template search paths :param ask: Ask user for missing template location if True :param filters:...
[ "Compile", "and", "render", "template", "and", "return", "the", "result", "as", "a", "string", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/template.py#L146-L172
ssato/python-anyconfig
src/anyconfig/template.py
try_render
def try_render(filepath=None, content=None, **options): """ Compile and render template and return the result as a string. :param filepath: Absolute or relative path to the template file :param content: Template content (str) :param options: Keyword options passed to :func:`render` defined above. ...
python
def try_render(filepath=None, content=None, **options): """ Compile and render template and return the result as a string. :param filepath: Absolute or relative path to the template file :param content: Template content (str) :param options: Keyword options passed to :func:`render` defined above. ...
[ "def", "try_render", "(", "filepath", "=", "None", ",", "content", "=", "None", ",", "*", "*", "options", ")", ":", "if", "filepath", "is", "None", "and", "content", "is", "None", ":", "raise", "ValueError", "(", "\"Either 'path' or 'content' must be some valu...
Compile and render template and return the result as a string. :param filepath: Absolute or relative path to the template file :param content: Template content (str) :param options: Keyword options passed to :func:`render` defined above. :return: Compiled result (str) or None
[ "Compile", "and", "render", "template", "and", "return", "the", "result", "as", "a", "string", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/template.py#L175-L198
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_parse
def _parse(val_s, sep=_SEP): """ FIXME: May be too naive implementation. :param val_s: A string represents some value to parse :param sep: separator between values >>> _parse(r'"foo string"') 'foo string' >>> _parse("a, b, c") ['a', 'b', 'c'] >>> _parse("aaa") 'aaa' """ ...
python
def _parse(val_s, sep=_SEP): """ FIXME: May be too naive implementation. :param val_s: A string represents some value to parse :param sep: separator between values >>> _parse(r'"foo string"') 'foo string' >>> _parse("a, b, c") ['a', 'b', 'c'] >>> _parse("aaa") 'aaa' """ ...
[ "def", "_parse", "(", "val_s", ",", "sep", "=", "_SEP", ")", ":", "if", "(", "val_s", ".", "startswith", "(", "'\"'", ")", "and", "val_s", ".", "endswith", "(", "'\"'", ")", ")", "or", "(", "val_s", ".", "startswith", "(", "\"'\"", ")", "and", "v...
FIXME: May be too naive implementation. :param val_s: A string represents some value to parse :param sep: separator between values >>> _parse(r'"foo string"') 'foo string' >>> _parse("a, b, c") ['a', 'b', 'c'] >>> _parse("aaa") 'aaa'
[ "FIXME", ":", "May", "be", "too", "naive", "implementation", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L52-L72
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_to_s
def _to_s(val, sep=", "): """Convert any to string. :param val: An object :param sep: separator between values >>> _to_s([1, 2, 3]) '1, 2, 3' >>> _to_s("aaa") 'aaa' """ if anyconfig.utils.is_iterable(val): return sep.join(str(x) for x in val) return str(val)
python
def _to_s(val, sep=", "): """Convert any to string. :param val: An object :param sep: separator between values >>> _to_s([1, 2, 3]) '1, 2, 3' >>> _to_s("aaa") 'aaa' """ if anyconfig.utils.is_iterable(val): return sep.join(str(x) for x in val) return str(val)
[ "def", "_to_s", "(", "val", ",", "sep", "=", "\", \"", ")", ":", "if", "anyconfig", ".", "utils", ".", "is_iterable", "(", "val", ")", ":", "return", "sep", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "val", ")", "return", "str", ...
Convert any to string. :param val: An object :param sep: separator between values >>> _to_s([1, 2, 3]) '1, 2, 3' >>> _to_s("aaa") 'aaa'
[ "Convert", "any", "to", "string", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L75-L89
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_parsed_items
def _parsed_items(items, sep=_SEP, **options): """ :param items: List of pairs, [(key, value)], or generator yields pairs :param sep: Seprator string :return: Generator to yield (key, value) pair of 'dic' """ parse = _parse if options.get("ac_parse_value") else anyconfig.utils.noop for key, ...
python
def _parsed_items(items, sep=_SEP, **options): """ :param items: List of pairs, [(key, value)], or generator yields pairs :param sep: Seprator string :return: Generator to yield (key, value) pair of 'dic' """ parse = _parse if options.get("ac_parse_value") else anyconfig.utils.noop for key, ...
[ "def", "_parsed_items", "(", "items", ",", "sep", "=", "_SEP", ",", "*", "*", "options", ")", ":", "parse", "=", "_parse", "if", "options", ".", "get", "(", "\"ac_parse_value\"", ")", "else", "anyconfig", ".", "utils", ".", "noop", "for", "key", ",", ...
:param items: List of pairs, [(key, value)], or generator yields pairs :param sep: Seprator string :return: Generator to yield (key, value) pair of 'dic'
[ ":", "param", "items", ":", "List", "of", "pairs", "[", "(", "key", "value", ")", "]", "or", "generator", "yields", "pairs", ":", "param", "sep", ":", "Seprator", "string", ":", "return", ":", "Generator", "to", "yield", "(", "key", "value", ")", "pa...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L92-L100
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_make_parser
def _make_parser(**kwargs): """ :return: (keyword args to be used, parser object) """ # Optional arguements for configparser.SafeConfigParser{,readfp} kwargs_0 = filter_options(("defaults", "dict_type", "allow_no_value"), kwargs) kwargs_1 = filter_options(("filename...
python
def _make_parser(**kwargs): """ :return: (keyword args to be used, parser object) """ # Optional arguements for configparser.SafeConfigParser{,readfp} kwargs_0 = filter_options(("defaults", "dict_type", "allow_no_value"), kwargs) kwargs_1 = filter_options(("filename...
[ "def", "_make_parser", "(", "*", "*", "kwargs", ")", ":", "# Optional arguements for configparser.SafeConfigParser{,readfp}", "kwargs_0", "=", "filter_options", "(", "(", "\"defaults\"", ",", "\"dict_type\"", ",", "\"allow_no_value\"", ")", ",", "kwargs", ")", "kwargs_1...
:return: (keyword args to be used, parser object)
[ ":", "return", ":", "(", "keyword", "args", "to", "be", "used", "parser", "object", ")" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L103-L121
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_load
def _load(stream, container, sep=_SEP, dkey=DEFAULTSECT, **kwargs): """ :param stream: File or file-like object provides ini-style conf :param container: any callable to make container :param sep: Seprator string :param dkey: Default section name :return: Dict or dict-like object represents con...
python
def _load(stream, container, sep=_SEP, dkey=DEFAULTSECT, **kwargs): """ :param stream: File or file-like object provides ini-style conf :param container: any callable to make container :param sep: Seprator string :param dkey: Default section name :return: Dict or dict-like object represents con...
[ "def", "_load", "(", "stream", ",", "container", ",", "sep", "=", "_SEP", ",", "dkey", "=", "DEFAULTSECT", ",", "*", "*", "kwargs", ")", ":", "(", "kwargs_1", ",", "psr", ")", "=", "_make_parser", "(", "*", "*", "kwargs", ")", "if", "IS_PYTHON_3", ...
:param stream: File or file-like object provides ini-style conf :param container: any callable to make container :param sep: Seprator string :param dkey: Default section name :return: Dict or dict-like object represents config values
[ ":", "param", "stream", ":", "File", "or", "file", "-", "like", "object", "provides", "ini", "-", "style", "conf", ":", "param", "container", ":", "any", "callable", "to", "make", "container", ":", "param", "sep", ":", "Seprator", "string", ":", "param",...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L124-L149
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_dumps_itr
def _dumps_itr(cnf, dkey=DEFAULTSECT): """ :param cnf: Configuration data to dump """ for sect, params in iteritems(cnf): yield "[%s]" % sect for key, val in iteritems(params): if sect != dkey and dkey in cnf and cnf[dkey].get(key) == val: continue # It shou...
python
def _dumps_itr(cnf, dkey=DEFAULTSECT): """ :param cnf: Configuration data to dump """ for sect, params in iteritems(cnf): yield "[%s]" % sect for key, val in iteritems(params): if sect != dkey and dkey in cnf and cnf[dkey].get(key) == val: continue # It shou...
[ "def", "_dumps_itr", "(", "cnf", ",", "dkey", "=", "DEFAULTSECT", ")", ":", "for", "sect", ",", "params", "in", "iteritems", "(", "cnf", ")", ":", "yield", "\"[%s]\"", "%", "sect", "for", "key", ",", "val", "in", "iteritems", "(", "params", ")", ":",...
:param cnf: Configuration data to dump
[ ":", "param", "cnf", ":", "Configuration", "data", "to", "dump" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L152-L165
ssato/python-anyconfig
src/anyconfig/backend/ini.py
_dumps
def _dumps(cnf, **kwargs): """ :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: String representation of 'cnf' object in INI format """ return os.linesep.join(l for l in _dumps_itr(cnf))
python
def _dumps(cnf, **kwargs): """ :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: String representation of 'cnf' object in INI format """ return os.linesep.join(l for l in _dumps_itr(cnf))
[ "def", "_dumps", "(", "cnf", ",", "*", "*", "kwargs", ")", ":", "return", "os", ".", "linesep", ".", "join", "(", "l", "for", "l", "in", "_dumps_itr", "(", "cnf", ")", ")" ]
:param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: String representation of 'cnf' object in INI format
[ ":", "param", "cnf", ":", "Configuration", "data", "to", "dump", ":", "param", "kwargs", ":", "optional", "keyword", "parameters", "to", "be", "sanitized", "::", "dict" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L168-L175
ssato/python-anyconfig
src/anyconfig/query.py
query
def query(data, **options): """ Filter data with given JMESPath expression. See also: https://github.com/jmespath/jmespath.py and http://jmespath.org. :param data: Target object (a dict or a dict-like object) to query :param options: Keyword option may include 'ac_query' which is a string ...
python
def query(data, **options): """ Filter data with given JMESPath expression. See also: https://github.com/jmespath/jmespath.py and http://jmespath.org. :param data: Target object (a dict or a dict-like object) to query :param options: Keyword option may include 'ac_query' which is a string ...
[ "def", "query", "(", "data", ",", "*", "*", "options", ")", ":", "expression", "=", "options", ".", "get", "(", "\"ac_query\"", ",", "None", ")", "if", "expression", "is", "None", "or", "not", "expression", ":", "return", "data", "try", ":", "pexp", ...
Filter data with given JMESPath expression. See also: https://github.com/jmespath/jmespath.py and http://jmespath.org. :param data: Target object (a dict or a dict-like object) to query :param options: Keyword option may include 'ac_query' which is a string represents JMESPath expression. ...
[ "Filter", "data", "with", "given", "JMESPath", "expression", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/query.py#L22-L49
ssato/python-anyconfig
src/anyconfig/utils.py
groupby
def groupby(itr, key_fn=None): """ An wrapper function around itertools.groupby to sort each results. :param itr: Iterable object, a list/tuple/genrator, etc. :param key_fn: Key function to sort 'itr'. >>> import operator >>> itr = [("a", 1), ("b", -1), ("c", 1)] >>> res = groupby(itr, ope...
python
def groupby(itr, key_fn=None): """ An wrapper function around itertools.groupby to sort each results. :param itr: Iterable object, a list/tuple/genrator, etc. :param key_fn: Key function to sort 'itr'. >>> import operator >>> itr = [("a", 1), ("b", -1), ("c", 1)] >>> res = groupby(itr, ope...
[ "def", "groupby", "(", "itr", ",", "key_fn", "=", "None", ")", ":", "return", "itertools", ".", "groupby", "(", "sorted", "(", "itr", ",", "key", "=", "key_fn", ")", ",", "key", "=", "key_fn", ")" ]
An wrapper function around itertools.groupby to sort each results. :param itr: Iterable object, a list/tuple/genrator, etc. :param key_fn: Key function to sort 'itr'. >>> import operator >>> itr = [("a", 1), ("b", -1), ("c", 1)] >>> res = groupby(itr, operator.itemgetter(1)) >>> [(key, tuple(g...
[ "An", "wrapper", "function", "around", "itertools", ".", "groupby", "to", "sort", "each", "results", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L22-L35
ssato/python-anyconfig
src/anyconfig/utils.py
get_file_extension
def get_file_extension(file_path): """ >>> get_file_extension("/a/b/c") '' >>> get_file_extension("/a/b.txt") 'txt' >>> get_file_extension("/a/b/c.tar.xz") 'xz' """ _ext = os.path.splitext(file_path)[-1] if _ext: return _ext[1:] if _ext.startswith('.') else _ext retu...
python
def get_file_extension(file_path): """ >>> get_file_extension("/a/b/c") '' >>> get_file_extension("/a/b.txt") 'txt' >>> get_file_extension("/a/b/c.tar.xz") 'xz' """ _ext = os.path.splitext(file_path)[-1] if _ext: return _ext[1:] if _ext.startswith('.') else _ext retu...
[ "def", "get_file_extension", "(", "file_path", ")", ":", "_ext", "=", "os", ".", "path", ".", "splitext", "(", "file_path", ")", "[", "-", "1", "]", "if", "_ext", ":", "return", "_ext", "[", "1", ":", "]", "if", "_ext", ".", "startswith", "(", "'.'...
>>> get_file_extension("/a/b/c") '' >>> get_file_extension("/a/b.txt") 'txt' >>> get_file_extension("/a/b/c.tar.xz") 'xz'
[ ">>>", "get_file_extension", "(", "/", "a", "/", "b", "/", "c", ")", ">>>", "get_file_extension", "(", "/", "a", "/", "b", ".", "txt", ")", "txt", ">>>", "get_file_extension", "(", "/", "a", "/", "b", "/", "c", ".", "tar", ".", "xz", ")", "xz" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L38-L51
ssato/python-anyconfig
src/anyconfig/utils.py
is_iterable
def is_iterable(obj): """ >>> is_iterable([]) True >>> is_iterable(()) True >>> is_iterable([x for x in range(10)]) True >>> is_iterable((1, 2, 3)) True >>> g = (x for x in range(10)) >>> is_iterable(g) True >>> is_iterable("abc") False >>> is_iterable(0) ...
python
def is_iterable(obj): """ >>> is_iterable([]) True >>> is_iterable(()) True >>> is_iterable([x for x in range(10)]) True >>> is_iterable((1, 2, 3)) True >>> g = (x for x in range(10)) >>> is_iterable(g) True >>> is_iterable("abc") False >>> is_iterable(0) ...
[ "def", "is_iterable", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "(", "list", ",", "tuple", ",", "types", ".", "GeneratorType", ")", ")", "or", "(", "not", "isinstance", "(", "obj", ",", "(", "int", ",", "str", ",", "dict", ")",...
>>> is_iterable([]) True >>> is_iterable(()) True >>> is_iterable([x for x in range(10)]) True >>> is_iterable((1, 2, 3)) True >>> g = (x for x in range(10)) >>> is_iterable(g) True >>> is_iterable("abc") False >>> is_iterable(0) False >>> is_iterable({}) ...
[ ">>>", "is_iterable", "(", "[]", ")", "True", ">>>", "is_iterable", "((", "))", "True", ">>>", "is_iterable", "(", "[", "x", "for", "x", "in", "range", "(", "10", ")", "]", ")", "True", ">>>", "is_iterable", "((", "1", "2", "3", "))", "True", ">>>"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L61-L83
ssato/python-anyconfig
src/anyconfig/utils.py
is_ioinfo
def is_ioinfo(obj, keys=None): """ :return: True if given 'obj' is a 'IOInfo' namedtuple object. >>> assert not is_ioinfo(1) >>> assert not is_ioinfo("aaa") >>> assert not is_ioinfo({}) >>> assert not is_ioinfo(('a', 1, {})) >>> inp = anyconfig.globals.IOInfo("/etc/hosts", "path", "/etc/ho...
python
def is_ioinfo(obj, keys=None): """ :return: True if given 'obj' is a 'IOInfo' namedtuple object. >>> assert not is_ioinfo(1) >>> assert not is_ioinfo("aaa") >>> assert not is_ioinfo({}) >>> assert not is_ioinfo(('a', 1, {})) >>> inp = anyconfig.globals.IOInfo("/etc/hosts", "path", "/etc/ho...
[ "def", "is_ioinfo", "(", "obj", ",", "keys", "=", "None", ")", ":", "if", "keys", "is", "None", ":", "keys", "=", "anyconfig", ".", "globals", ".", "IOI_KEYS", "if", "isinstance", "(", "obj", ",", "tuple", ")", "and", "getattr", "(", "obj", ",", "\...
:return: True if given 'obj' is a 'IOInfo' namedtuple object. >>> assert not is_ioinfo(1) >>> assert not is_ioinfo("aaa") >>> assert not is_ioinfo({}) >>> assert not is_ioinfo(('a', 1, {})) >>> inp = anyconfig.globals.IOInfo("/etc/hosts", "path", "/etc/hosts", ... ...
[ ":", "return", ":", "True", "if", "given", "obj", "is", "a", "IOInfo", "namedtuple", "object", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L157-L176
ssato/python-anyconfig
src/anyconfig/utils.py
is_path_like_object
def is_path_like_object(obj, marker='*'): """ Is given object 'obj' a path string, a pathlib.Path, a file / file-like (stream) or IOInfo namedtuple object? :param obj: a path string, pathlib.Path object, a file / file-like or 'IOInfo' object :return: True if 'obj' is a path...
python
def is_path_like_object(obj, marker='*'): """ Is given object 'obj' a path string, a pathlib.Path, a file / file-like (stream) or IOInfo namedtuple object? :param obj: a path string, pathlib.Path object, a file / file-like or 'IOInfo' object :return: True if 'obj' is a path...
[ "def", "is_path_like_object", "(", "obj", ",", "marker", "=", "'*'", ")", ":", "return", "(", "(", "is_path", "(", "obj", ")", "and", "marker", "not", "in", "obj", ")", "or", "(", "is_path_obj", "(", "obj", ")", "and", "marker", "not", "in", "obj", ...
Is given object 'obj' a path string, a pathlib.Path, a file / file-like (stream) or IOInfo namedtuple object? :param obj: a path string, pathlib.Path object, a file / file-like or 'IOInfo' object :return: True if 'obj' is a path string or a pathlib.Path object or a file (st...
[ "Is", "given", "object", "obj", "a", "path", "string", "a", "pathlib", ".", "Path", "a", "file", "/", "file", "-", "like", "(", "stream", ")", "or", "IOInfo", "namedtuple", "object?" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L192-L217
ssato/python-anyconfig
src/anyconfig/utils.py
is_paths
def is_paths(maybe_paths, marker='*'): """ Does given object 'maybe_paths' consist of path or path pattern strings? """ return ((is_path(maybe_paths) and marker in maybe_paths) or # Path str (is_path_obj(maybe_paths) and marker in maybe_paths.as_posix()) or (is_iterable(maybe_pa...
python
def is_paths(maybe_paths, marker='*'): """ Does given object 'maybe_paths' consist of path or path pattern strings? """ return ((is_path(maybe_paths) and marker in maybe_paths) or # Path str (is_path_obj(maybe_paths) and marker in maybe_paths.as_posix()) or (is_iterable(maybe_pa...
[ "def", "is_paths", "(", "maybe_paths", ",", "marker", "=", "'*'", ")", ":", "return", "(", "(", "is_path", "(", "maybe_paths", ")", "and", "marker", "in", "maybe_paths", ")", "or", "# Path str", "(", "is_path_obj", "(", "maybe_paths", ")", "and", "marker",...
Does given object 'maybe_paths' consist of path or path pattern strings?
[ "Does", "given", "object", "maybe_paths", "consist", "of", "path", "or", "path", "pattern", "strings?" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L220-L227
ssato/python-anyconfig
src/anyconfig/utils.py
get_path_from_stream
def get_path_from_stream(strm): """ Try to get file path from given file or file-like object 'strm'. :param strm: A file or file-like object :return: Path of given file or file-like object or None :raises: ValueError >>> assert __file__ == get_path_from_stream(open(__file__, 'r')) >>> asse...
python
def get_path_from_stream(strm): """ Try to get file path from given file or file-like object 'strm'. :param strm: A file or file-like object :return: Path of given file or file-like object or None :raises: ValueError >>> assert __file__ == get_path_from_stream(open(__file__, 'r')) >>> asse...
[ "def", "get_path_from_stream", "(", "strm", ")", ":", "if", "not", "is_file_stream", "(", "strm", ")", ":", "raise", "ValueError", "(", "\"Given object does not look a file/file-like \"", "\"object: %r\"", "%", "strm", ")", "path", "=", "getattr", "(", "strm", ","...
Try to get file path from given file or file-like object 'strm'. :param strm: A file or file-like object :return: Path of given file or file-like object or None :raises: ValueError >>> assert __file__ == get_path_from_stream(open(__file__, 'r')) >>> assert get_path_from_stream(anyconfig.compat.Str...
[ "Try", "to", "get", "file", "path", "from", "given", "file", "or", "file", "-", "like", "object", "strm", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L230-L256
ssato/python-anyconfig
src/anyconfig/utils.py
_try_to_get_extension
def _try_to_get_extension(obj): """ Try to get file extension from given path or file object. :param obj: a file, file-like object or something :return: File extension or None >>> _try_to_get_extension("a.py") 'py' """ if is_path(obj): path = obj elif is_path_obj(obj): ...
python
def _try_to_get_extension(obj): """ Try to get file extension from given path or file object. :param obj: a file, file-like object or something :return: File extension or None >>> _try_to_get_extension("a.py") 'py' """ if is_path(obj): path = obj elif is_path_obj(obj): ...
[ "def", "_try_to_get_extension", "(", "obj", ")", ":", "if", "is_path", "(", "obj", ")", ":", "path", "=", "obj", "elif", "is_path_obj", "(", "obj", ")", ":", "return", "obj", ".", "suffix", "[", "1", ":", "]", "elif", "is_file_stream", "(", "obj", ")...
Try to get file extension from given path or file object. :param obj: a file, file-like object or something :return: File extension or None >>> _try_to_get_extension("a.py") 'py'
[ "Try", "to", "get", "file", "extension", "from", "given", "path", "or", "file", "object", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L259-L290
ssato/python-anyconfig
src/anyconfig/utils.py
are_same_file_types
def are_same_file_types(objs): """ Are given (maybe) file objs same type (extension) ? :param objs: A list of file path or file(-like) objects >>> are_same_file_types([]) False >>> are_same_file_types(["a.conf"]) True >>> are_same_file_types(["a.conf", "b.conf"]) True >>> are_s...
python
def are_same_file_types(objs): """ Are given (maybe) file objs same type (extension) ? :param objs: A list of file path or file(-like) objects >>> are_same_file_types([]) False >>> are_same_file_types(["a.conf"]) True >>> are_same_file_types(["a.conf", "b.conf"]) True >>> are_s...
[ "def", "are_same_file_types", "(", "objs", ")", ":", "if", "not", "objs", ":", "return", "False", "ext", "=", "_try_to_get_extension", "(", "objs", "[", "0", "]", ")", "if", "ext", "is", "None", ":", "return", "False", "return", "all", "(", "_try_to_get_...
Are given (maybe) file objs same type (extension) ? :param objs: A list of file path or file(-like) objects >>> are_same_file_types([]) False >>> are_same_file_types(["a.conf"]) True >>> are_same_file_types(["a.conf", "b.conf"]) True >>> are_same_file_types(["a.yml", "b.yml"]) True...
[ "Are", "given", "(", "maybe", ")", "file", "objs", "same", "type", "(", "extension", ")", "?" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L293-L320
ssato/python-anyconfig
src/anyconfig/utils.py
_expand_paths_itr
def _expand_paths_itr(paths, marker='*'): """Iterator version of :func:`expand_paths`. """ for path in paths: if is_path(path): if marker in path: # glob path pattern for ppath in sglob(path): yield ppath else: yield path ...
python
def _expand_paths_itr(paths, marker='*'): """Iterator version of :func:`expand_paths`. """ for path in paths: if is_path(path): if marker in path: # glob path pattern for ppath in sglob(path): yield ppath else: yield path ...
[ "def", "_expand_paths_itr", "(", "paths", ",", "marker", "=", "'*'", ")", ":", "for", "path", "in", "paths", ":", "if", "is_path", "(", "path", ")", ":", "if", "marker", "in", "path", ":", "# glob path pattern", "for", "ppath", "in", "sglob", "(", "pat...
Iterator version of :func:`expand_paths`.
[ "Iterator", "version", "of", ":", "func", ":", "expand_paths", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L323-L342
ssato/python-anyconfig
src/anyconfig/utils.py
expand_paths
def expand_paths(paths, marker='*'): """ :param paths: A glob path pattern string or pathlib.Path object holding such path, or a list consists of path strings or glob path pattern strings or pathlib.Path object holding such ones, or file objects :param marker: Glob marker character o...
python
def expand_paths(paths, marker='*'): """ :param paths: A glob path pattern string or pathlib.Path object holding such path, or a list consists of path strings or glob path pattern strings or pathlib.Path object holding such ones, or file objects :param marker: Glob marker character o...
[ "def", "expand_paths", "(", "paths", ",", "marker", "=", "'*'", ")", ":", "if", "is_path", "(", "paths", ")", "and", "marker", "in", "paths", ":", "return", "sglob", "(", "paths", ")", "if", "is_path_obj", "(", "paths", ")", "and", "marker", "in", "p...
:param paths: A glob path pattern string or pathlib.Path object holding such path, or a list consists of path strings or glob path pattern strings or pathlib.Path object holding such ones, or file objects :param marker: Glob marker character or string, e.g. '*' :return: List of path str...
[ ":", "param", "paths", ":", "A", "glob", "path", "pattern", "string", "or", "pathlib", ".", "Path", "object", "holding", "such", "path", "or", "a", "list", "consists", "of", "path", "strings", "or", "glob", "path", "pattern", "strings", "or", "pathlib", ...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L345-L374
ssato/python-anyconfig
src/anyconfig/utils.py
is_list_like
def is_list_like(obj): """ >>> is_list_like([]) True >>> is_list_like(()) True >>> is_list_like([x for x in range(10)]) True >>> is_list_like((1, 2, 3)) True >>> g = (x for x in range(10)) >>> is_list_like(g) True >>> is_list_like("abc") False >>> is_list_like...
python
def is_list_like(obj): """ >>> is_list_like([]) True >>> is_list_like(()) True >>> is_list_like([x for x in range(10)]) True >>> is_list_like((1, 2, 3)) True >>> g = (x for x in range(10)) >>> is_list_like(g) True >>> is_list_like("abc") False >>> is_list_like...
[ "def", "is_list_like", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "_LIST_LIKE_TYPES", ")", "and", "not", "(", "isinstance", "(", "obj", ",", "anyconfig", ".", "compat", ".", "STR_TYPES", ")", "or", "is_dict_like", "(", "obj", ")", ")"...
>>> is_list_like([]) True >>> is_list_like(()) True >>> is_list_like([x for x in range(10)]) True >>> is_list_like((1, 2, 3)) True >>> g = (x for x in range(10)) >>> is_list_like(g) True >>> is_list_like("abc") False >>> is_list_like(0) False >>> is_list_like(...
[ ">>>", "is_list_like", "(", "[]", ")", "True", ">>>", "is_list_like", "((", "))", "True", ">>>", "is_list_like", "(", "[", "x", "for", "x", "in", "range", "(", "10", ")", "]", ")", "True", ">>>", "is_list_like", "((", "1", "2", "3", "))", "True", "...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L417-L438
ssato/python-anyconfig
src/anyconfig/utils.py
filter_options
def filter_options(keys, options): """ Filter 'options' with given 'keys'. :param keys: key names of optional keyword arguments :param options: optional keyword arguments to filter with 'keys' >>> filter_options(("aaa", ), dict(aaa=1, bbb=2)) {'aaa': 1} >>> filter_options(("aaa", ), dict(b...
python
def filter_options(keys, options): """ Filter 'options' with given 'keys'. :param keys: key names of optional keyword arguments :param options: optional keyword arguments to filter with 'keys' >>> filter_options(("aaa", ), dict(aaa=1, bbb=2)) {'aaa': 1} >>> filter_options(("aaa", ), dict(b...
[ "def", "filter_options", "(", "keys", ",", "options", ")", ":", "return", "dict", "(", "(", "k", ",", "options", "[", "k", "]", ")", "for", "k", "in", "keys", "if", "k", "in", "options", ")" ]
Filter 'options' with given 'keys'. :param keys: key names of optional keyword arguments :param options: optional keyword arguments to filter with 'keys' >>> filter_options(("aaa", ), dict(aaa=1, bbb=2)) {'aaa': 1} >>> filter_options(("aaa", ), dict(bbb=2)) {}
[ "Filter", "options", "with", "given", "keys", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L441-L453
ssato/python-anyconfig
src/anyconfig/utils.py
memoize
def memoize(fnc): """memoization function. >>> import random >>> imax = 100 >>> def fnc1(arg=True): ... return arg and random.choice((True, False)) >>> fnc2 = memoize(fnc1) >>> (ret1, ret2) = (fnc1(), fnc2()) >>> assert any(fnc1() != ret1 for i in range(imax)) >>> assert all(fnc...
python
def memoize(fnc): """memoization function. >>> import random >>> imax = 100 >>> def fnc1(arg=True): ... return arg and random.choice((True, False)) >>> fnc2 = memoize(fnc1) >>> (ret1, ret2) = (fnc1(), fnc2()) >>> assert any(fnc1() != ret1 for i in range(imax)) >>> assert all(fnc...
[ "def", "memoize", "(", "fnc", ")", ":", "cache", "=", "dict", "(", ")", "@", "functools", ".", "wraps", "(", "fnc", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Decorated one\"\"\"", "key", "=", "repr", "(", "a...
memoization function. >>> import random >>> imax = 100 >>> def fnc1(arg=True): ... return arg and random.choice((True, False)) >>> fnc2 = memoize(fnc1) >>> (ret1, ret2) = (fnc1(), fnc2()) >>> assert any(fnc1() != ret1 for i in range(imax)) >>> assert all(fnc2() == ret2 for i in rang...
[ "memoization", "function", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L456-L479
ssato/python-anyconfig
src/anyconfig/api.py
_try_validate
def _try_validate(cnf, schema, **options): """ :param cnf: Mapping object represents configuration data :param schema: JSON schema object :param options: Keyword options passed to :func:`jsonschema.validate` :return: Given 'cnf' as it is if validation succeeds else None """ valid = True ...
python
def _try_validate(cnf, schema, **options): """ :param cnf: Mapping object represents configuration data :param schema: JSON schema object :param options: Keyword options passed to :func:`jsonschema.validate` :return: Given 'cnf' as it is if validation succeeds else None """ valid = True ...
[ "def", "_try_validate", "(", "cnf", ",", "schema", ",", "*", "*", "options", ")", ":", "valid", "=", "True", "if", "schema", ":", "(", "valid", ",", "msg", ")", "=", "validate", "(", "cnf", ",", "schema", ",", "*", "*", "options", ")", "if", "msg...
:param cnf: Mapping object represents configuration data :param schema: JSON schema object :param options: Keyword options passed to :func:`jsonschema.validate` :return: Given 'cnf' as it is if validation succeeds else None
[ ":", "param", "cnf", ":", "Mapping", "object", "represents", "configuration", "data", ":", "param", "schema", ":", "JSON", "schema", "object", ":", "param", "options", ":", "Keyword", "options", "passed", "to", ":", "func", ":", "jsonschema", ".", "validate"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L145-L162
ssato/python-anyconfig
src/anyconfig/api.py
_maybe_schema
def _maybe_schema(**options): """ :param options: Optional keyword arguments such as - ac_template: Assume configuration file may be a template file and try to compile it AAR if True - ac_context: Mapping object presents context to instantiate template - ac_schema: JSON schema...
python
def _maybe_schema(**options): """ :param options: Optional keyword arguments such as - ac_template: Assume configuration file may be a template file and try to compile it AAR if True - ac_context: Mapping object presents context to instantiate template - ac_schema: JSON schema...
[ "def", "_maybe_schema", "(", "*", "*", "options", ")", ":", "ac_schema", "=", "options", ".", "get", "(", "\"ac_schema\"", ",", "None", ")", "if", "ac_schema", "is", "not", "None", ":", "# Try to detect the appropriate parser to load the schema data as it", "# may b...
:param options: Optional keyword arguments such as - ac_template: Assume configuration file may be a template file and try to compile it AAR if True - ac_context: Mapping object presents context to instantiate template - ac_schema: JSON schema file path to validate configuration files...
[ ":", "param", "options", ":", "Optional", "keyword", "arguments", "such", "as" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L199-L219
ssato/python-anyconfig
src/anyconfig/api.py
open
def open(path, mode=None, ac_parser=None, **options): """ Open given configuration file with appropriate open flag. :param path: Configuration file path :param mode: Can be 'r' and 'rb' for reading (default) or 'w', 'wb' for writing. Please note that even if you specify 'r' or 'w', it w...
python
def open(path, mode=None, ac_parser=None, **options): """ Open given configuration file with appropriate open flag. :param path: Configuration file path :param mode: Can be 'r' and 'rb' for reading (default) or 'w', 'wb' for writing. Please note that even if you specify 'r' or 'w', it w...
[ "def", "open", "(", "path", ",", "mode", "=", "None", ",", "ac_parser", "=", "None", ",", "*", "*", "options", ")", ":", "psr", "=", "find", "(", "path", ",", "forced_type", "=", "ac_parser", ")", "if", "mode", "is", "not", "None", "and", "mode", ...
Open given configuration file with appropriate open flag. :param path: Configuration file path :param mode: Can be 'r' and 'rb' for reading (default) or 'w', 'wb' for writing. Please note that even if you specify 'r' or 'w', it will be changed to 'rb' or 'wb' if selected backend, xml an...
[ "Open", "given", "configuration", "file", "with", "appropriate", "open", "flag", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L223-L246
ssato/python-anyconfig
src/anyconfig/api.py
_single_load
def _single_load(input_, ac_parser=None, ac_template=False, ac_context=None, **options): """ :param input_: File path or file or file-like object or pathlib.Path object represents the file or a namedtuple 'anyconfig.globals.IOInfo' object represents some input to load so...
python
def _single_load(input_, ac_parser=None, ac_template=False, ac_context=None, **options): """ :param input_: File path or file or file-like object or pathlib.Path object represents the file or a namedtuple 'anyconfig.globals.IOInfo' object represents some input to load so...
[ "def", "_single_load", "(", "input_", ",", "ac_parser", "=", "None", ",", "ac_template", "=", "False", ",", "ac_context", "=", "None", ",", "*", "*", "options", ")", ":", "ioi", "=", "anyconfig", ".", "ioinfo", ".", "make", "(", "input_", ")", "psr", ...
:param input_: File path or file or file-like object or pathlib.Path object represents the file or a namedtuple 'anyconfig.globals.IOInfo' object represents some input to load some data from :param ac_parser: Forced parser type or parser object itself :param ac_template: Assume c...
[ ":", "param", "input_", ":", "File", "path", "or", "file", "or", "file", "-", "like", "object", "or", "pathlib", ".", "Path", "object", "represents", "the", "file", "or", "a", "namedtuple", "anyconfig", ".", "globals", ".", "IOInfo", "object", "represents"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L249-L287
ssato/python-anyconfig
src/anyconfig/api.py
single_load
def single_load(input_, ac_parser=None, ac_template=False, ac_context=None, **options): r""" Load single configuration file. .. note:: :func:`load` is a preferable alternative and this API should be used only if there is a need to emphasize given input 'input\_' is single ...
python
def single_load(input_, ac_parser=None, ac_template=False, ac_context=None, **options): r""" Load single configuration file. .. note:: :func:`load` is a preferable alternative and this API should be used only if there is a need to emphasize given input 'input\_' is single ...
[ "def", "single_load", "(", "input_", ",", "ac_parser", "=", "None", ",", "ac_template", "=", "False", ",", "ac_context", "=", "None", ",", "*", "*", "options", ")", ":", "cnf", "=", "_single_load", "(", "input_", ",", "ac_parser", "=", "ac_parser", ",", ...
r""" Load single configuration file. .. note:: :func:`load` is a preferable alternative and this API should be used only if there is a need to emphasize given input 'input\_' is single one. :param input\_: File path or file or file-like object or pathlib.Path object represent...
[ "r", "Load", "single", "configuration", "file", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L290-L348
ssato/python-anyconfig
src/anyconfig/api.py
multi_load
def multi_load(inputs, ac_parser=None, ac_template=False, ac_context=None, **options): r""" Load multiple config files. .. note:: :func:`load` is a preferable alternative and this API should be used only if there is a need to emphasize given inputs are multiple ones. The ...
python
def multi_load(inputs, ac_parser=None, ac_template=False, ac_context=None, **options): r""" Load multiple config files. .. note:: :func:`load` is a preferable alternative and this API should be used only if there is a need to emphasize given inputs are multiple ones. The ...
[ "def", "multi_load", "(", "inputs", ",", "ac_parser", "=", "None", ",", "ac_template", "=", "False", ",", "ac_context", "=", "None", ",", "*", "*", "options", ")", ":", "marker", "=", "options", ".", "setdefault", "(", "\"ac_marker\"", ",", "options", "....
r""" Load multiple config files. .. note:: :func:`load` is a preferable alternative and this API should be used only if there is a need to emphasize given inputs are multiple ones. The first argument 'inputs' may be a list of a file paths or a glob pattern specifying them or a pathlib.P...
[ "r", "Load", "multiple", "config", "files", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L351-L432
ssato/python-anyconfig
src/anyconfig/api.py
load
def load(path_specs, ac_parser=None, ac_dict=None, ac_template=False, ac_context=None, **options): r""" Load single or multiple config files or multiple config files specified in given paths pattern or pathlib.Path object represents config files or a namedtuple 'anyconfig.globals.IOInfo' object...
python
def load(path_specs, ac_parser=None, ac_dict=None, ac_template=False, ac_context=None, **options): r""" Load single or multiple config files or multiple config files specified in given paths pattern or pathlib.Path object represents config files or a namedtuple 'anyconfig.globals.IOInfo' object...
[ "def", "load", "(", "path_specs", ",", "ac_parser", "=", "None", ",", "ac_dict", "=", "None", ",", "ac_template", "=", "False", ",", "ac_context", "=", "None", ",", "*", "*", "options", ")", ":", "marker", "=", "options", ".", "setdefault", "(", "\"ac_...
r""" Load single or multiple config files or multiple config files specified in given paths pattern or pathlib.Path object represents config files or a namedtuple 'anyconfig.globals.IOInfo' object represents some inputs. :param path_specs: A list of file path or a glob pattern such as r'/a/b/\*...
[ "r", "Load", "single", "or", "multiple", "config", "files", "or", "multiple", "config", "files", "specified", "in", "given", "paths", "pattern", "or", "pathlib", ".", "Path", "object", "represents", "config", "files", "or", "a", "namedtuple", "anyconfig", ".",...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L435-L477
ssato/python-anyconfig
src/anyconfig/api.py
loads
def loads(content, ac_parser=None, ac_dict=None, ac_template=False, ac_context=None, **options): """ :param content: Configuration file's content (a string) :param ac_parser: Forced parser type or ID or parser object :param ac_dict: callable (function or class) to make mapping object w...
python
def loads(content, ac_parser=None, ac_dict=None, ac_template=False, ac_context=None, **options): """ :param content: Configuration file's content (a string) :param ac_parser: Forced parser type or ID or parser object :param ac_dict: callable (function or class) to make mapping object w...
[ "def", "loads", "(", "content", ",", "ac_parser", "=", "None", ",", "ac_dict", "=", "None", ",", "ac_template", "=", "False", ",", "ac_context", "=", "None", ",", "*", "*", "options", ")", ":", "if", "ac_parser", "is", "None", ":", "LOGGER", ".", "wa...
:param content: Configuration file's content (a string) :param ac_parser: Forced parser type or ID or parser object :param ac_dict: callable (function or class) to make mapping object will be returned as a result or None. If not given or ac_dict is None, default mapping object used to st...
[ ":", "param", "content", ":", "Configuration", "file", "s", "content", "(", "a", "string", ")", ":", "param", "ac_parser", ":", "Forced", "parser", "type", "or", "ID", "or", "parser", "object", ":", "param", "ac_dict", ":", "callable", "(", "function", "...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L480-L523
ssato/python-anyconfig
src/anyconfig/api.py
dump
def dump(data, out, ac_parser=None, **options): """ Save 'data' to 'out'. :param data: A mapping object may have configurations data to dump :param out: An output file path, a file, a file-like object, :class:`pathlib.Path` object represents the file or a namedtuple 'anyconfig.globals.I...
python
def dump(data, out, ac_parser=None, **options): """ Save 'data' to 'out'. :param data: A mapping object may have configurations data to dump :param out: An output file path, a file, a file-like object, :class:`pathlib.Path` object represents the file or a namedtuple 'anyconfig.globals.I...
[ "def", "dump", "(", "data", ",", "out", ",", "ac_parser", "=", "None", ",", "*", "*", "options", ")", ":", "ioi", "=", "anyconfig", ".", "ioinfo", ".", "make", "(", "out", ")", "psr", "=", "find", "(", "ioi", ",", "forced_type", "=", "ac_parser", ...
Save 'data' to 'out'. :param data: A mapping object may have configurations data to dump :param out: An output file path, a file, a file-like object, :class:`pathlib.Path` object represents the file or a namedtuple 'anyconfig.globals.IOInfo' object represents output to dump some data to...
[ "Save", "data", "to", "out", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L526-L545
ssato/python-anyconfig
src/anyconfig/api.py
dumps
def dumps(data, ac_parser=None, **options): """ Return string representation of 'data' in forced type format. :param data: Config data object to dump :param ac_parser: Forced parser type or ID or parser object :param options: see :func:`dump` :return: Backend-specific string representation for...
python
def dumps(data, ac_parser=None, **options): """ Return string representation of 'data' in forced type format. :param data: Config data object to dump :param ac_parser: Forced parser type or ID or parser object :param options: see :func:`dump` :return: Backend-specific string representation for...
[ "def", "dumps", "(", "data", ",", "ac_parser", "=", "None", ",", "*", "*", "options", ")", ":", "psr", "=", "find", "(", "None", ",", "forced_type", "=", "ac_parser", ")", "return", "psr", ".", "dumps", "(", "data", ",", "*", "*", "options", ")" ]
Return string representation of 'data' in forced type format. :param data: Config data object to dump :param ac_parser: Forced parser type or ID or parser object :param options: see :func:`dump` :return: Backend-specific string representation for the given data :raises: ValueError, UnknownProcesso...
[ "Return", "string", "representation", "of", "data", "in", "forced", "type", "format", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L548-L560
ssato/python-anyconfig
src/anyconfig/api.py
query
def query(data, expression, **options): """ API just wraps :func:`anyconfig.query.query`. :param data: Config data object to query :param expression: JMESPath expression to query data :param options: Ignored in current implementation :return: Query result object may be a primitive (int, str, e...
python
def query(data, expression, **options): """ API just wraps :func:`anyconfig.query.query`. :param data: Config data object to query :param expression: JMESPath expression to query data :param options: Ignored in current implementation :return: Query result object may be a primitive (int, str, e...
[ "def", "query", "(", "data", ",", "expression", ",", "*", "*", "options", ")", ":", "return", "anyconfig", ".", "query", ".", "query", "(", "data", ",", "ac_query", "=", "expression", ")" ]
API just wraps :func:`anyconfig.query.query`. :param data: Config data object to query :param expression: JMESPath expression to query data :param options: Ignored in current implementation :return: Query result object may be a primitive (int, str, etc.) or dict.
[ "API", "just", "wraps", ":", "func", ":", "anyconfig", ".", "query", ".", "query", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L563-L573
ssato/python-anyconfig
src/anyconfig/init.py
getLogger
def getLogger(name="anyconfig"): """ See: "Configuring Logging for a Library" in python standard logging howto, e.g. https://docs.python.org/2/howto/logging.html#library-config. """ logger = logging.getLogger(name) logger.addHandler(anyconfig.compat.NullHandler()) return logger
python
def getLogger(name="anyconfig"): """ See: "Configuring Logging for a Library" in python standard logging howto, e.g. https://docs.python.org/2/howto/logging.html#library-config. """ logger = logging.getLogger(name) logger.addHandler(anyconfig.compat.NullHandler()) return logger
[ "def", "getLogger", "(", "name", "=", "\"anyconfig\"", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "addHandler", "(", "anyconfig", ".", "compat", ".", "NullHandler", "(", ")", ")", "return", "logger" ]
See: "Configuring Logging for a Library" in python standard logging howto, e.g. https://docs.python.org/2/howto/logging.html#library-config.
[ "See", ":", "Configuring", "Logging", "for", "a", "Library", "in", "python", "standard", "logging", "howto", "e", ".", "g", ".", "https", ":", "//", "docs", ".", "python", ".", "org", "/", "2", "/", "howto", "/", "logging", ".", "html#library", "-", ...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/init.py#L13-L21
ssato/python-anyconfig
src/anyconfig/parser.py
parse_single
def parse_single(str_): """ Very simple parser to parse expressions represent some single values. :param str_: a string to parse :return: Int | Bool | String >>> parse_single(None) '' >>> parse_single("0") 0 >>> parse_single("123") 123 >>> parse_single("True") True ...
python
def parse_single(str_): """ Very simple parser to parse expressions represent some single values. :param str_: a string to parse :return: Int | Bool | String >>> parse_single(None) '' >>> parse_single("0") 0 >>> parse_single("123") 123 >>> parse_single("True") True ...
[ "def", "parse_single", "(", "str_", ")", ":", "if", "str_", "is", "None", ":", "return", "''", "str_", "=", "str_", ".", "strip", "(", ")", "if", "not", "str_", ":", "return", "''", "if", "BOOL_PATTERN", ".", "match", "(", "str_", ")", "is", "not",...
Very simple parser to parse expressions represent some single values. :param str_: a string to parse :return: Int | Bool | String >>> parse_single(None) '' >>> parse_single("0") 0 >>> parse_single("123") 123 >>> parse_single("True") True >>> parse_single("a string") 'a ...
[ "Very", "simple", "parser", "to", "parse", "expressions", "represent", "some", "single", "values", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/parser.py#L17-L60
ssato/python-anyconfig
src/anyconfig/parser.py
parse_list
def parse_list(str_, sep=","): """ Simple parser to parse expressions reprensent some list values. :param str_: a string to parse :param sep: Char to separate items of list :return: [Int | Bool | String] >>> parse_list("") [] >>> parse_list("1") [1] >>> parse_list("a,b") ['...
python
def parse_list(str_, sep=","): """ Simple parser to parse expressions reprensent some list values. :param str_: a string to parse :param sep: Char to separate items of list :return: [Int | Bool | String] >>> parse_list("") [] >>> parse_list("1") [1] >>> parse_list("a,b") ['...
[ "def", "parse_list", "(", "str_", ",", "sep", "=", "\",\"", ")", ":", "return", "[", "parse_single", "(", "x", ")", "for", "x", "in", "str_", ".", "split", "(", "sep", ")", "if", "x", "]" ]
Simple parser to parse expressions reprensent some list values. :param str_: a string to parse :param sep: Char to separate items of list :return: [Int | Bool | String] >>> parse_list("") [] >>> parse_list("1") [1] >>> parse_list("a,b") ['a', 'b'] >>> parse_list("1,2") [1, ...
[ "Simple", "parser", "to", "parse", "expressions", "reprensent", "some", "list", "values", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/parser.py#L63-L82
ssato/python-anyconfig
src/anyconfig/parser.py
attr_val_itr
def attr_val_itr(str_, avs_sep=":", vs_sep=",", as_sep=";"): """ Atrribute and value pair parser. :param str_: String represents a list of pairs of attribute and value :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_sep: char to separate at...
python
def attr_val_itr(str_, avs_sep=":", vs_sep=",", as_sep=";"): """ Atrribute and value pair parser. :param str_: String represents a list of pairs of attribute and value :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_sep: char to separate at...
[ "def", "attr_val_itr", "(", "str_", ",", "avs_sep", "=", "\":\"", ",", "vs_sep", "=", "\",\"", ",", "as_sep", "=", "\";\"", ")", ":", "for", "rel", "in", "parse_list", "(", "str_", ",", "as_sep", ")", ":", "if", "avs_sep", "not", "in", "rel", "or", ...
Atrribute and value pair parser. :param str_: String represents a list of pairs of attribute and value :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_sep: char to separate attributes
[ "Atrribute", "and", "value", "pair", "parser", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/parser.py#L85-L104
ssato/python-anyconfig
src/anyconfig/parser.py
parse_attrlist_0
def parse_attrlist_0(str_, avs_sep=":", vs_sep=",", as_sep=";"): """ Simple parser to parse expressions in the form of [ATTR1:VAL0,VAL1,...;ATTR2:VAL0,VAL2,..]. :param str_: input string :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as...
python
def parse_attrlist_0(str_, avs_sep=":", vs_sep=",", as_sep=";"): """ Simple parser to parse expressions in the form of [ATTR1:VAL0,VAL1,...;ATTR2:VAL0,VAL2,..]. :param str_: input string :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as...
[ "def", "parse_attrlist_0", "(", "str_", ",", "avs_sep", "=", "\":\"", ",", "vs_sep", "=", "\",\"", ",", "as_sep", "=", "\";\"", ")", ":", "return", "[", "(", "a", ",", "vs", ")", "for", "a", ",", "vs", "in", "attr_val_itr", "(", "str_", ",", "avs_s...
Simple parser to parse expressions in the form of [ATTR1:VAL0,VAL1,...;ATTR2:VAL0,VAL2,..]. :param str_: input string :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_sep: char to separate attributes :return: a list of tuples of ...
[ "Simple", "parser", "to", "parse", "expressions", "in", "the", "form", "of", "[", "ATTR1", ":", "VAL0", "VAL1", "...", ";", "ATTR2", ":", "VAL0", "VAL2", "..", "]", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/parser.py#L107-L131
ssato/python-anyconfig
src/anyconfig/parser.py
parse_attrlist
def parse_attrlist(str_, avs_sep=":", vs_sep=",", as_sep=";"): """ Simple parser to parse expressions in the form of [ATTR1:VAL0,VAL1,...;ATTR2:VAL0,VAL2,..]. :param str_: input string :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_s...
python
def parse_attrlist(str_, avs_sep=":", vs_sep=",", as_sep=";"): """ Simple parser to parse expressions in the form of [ATTR1:VAL0,VAL1,...;ATTR2:VAL0,VAL2,..]. :param str_: input string :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_s...
[ "def", "parse_attrlist", "(", "str_", ",", "avs_sep", "=", "\":\"", ",", "vs_sep", "=", "\",\"", ",", "as_sep", "=", "\";\"", ")", ":", "return", "dict", "(", "parse_attrlist_0", "(", "str_", ",", "avs_sep", ",", "vs_sep", ",", "as_sep", ")", ")" ]
Simple parser to parse expressions in the form of [ATTR1:VAL0,VAL1,...;ATTR2:VAL0,VAL2,..]. :param str_: input string :param avs_sep: char to separate attribute and values :param vs_sep: char to separate values :param as_sep: char to separate attributes >>> parse_attrlist("requires:bash,zsh...
[ "Simple", "parser", "to", "parse", "expressions", "in", "the", "form", "of", "[", "ATTR1", ":", "VAL0", "VAL1", "...", ";", "ATTR2", ":", "VAL0", "VAL2", "..", "]", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/parser.py#L134-L147
ssato/python-anyconfig
src/anyconfig/parser.py
parse
def parse(str_, lsep=",", avsep=":", vssep=",", avssep=";"): """Generic parser""" if avsep in str_: return parse_attrlist(str_, avsep, vssep, avssep) if lsep in str_: return parse_list(str_, lsep) return parse_single(str_)
python
def parse(str_, lsep=",", avsep=":", vssep=",", avssep=";"): """Generic parser""" if avsep in str_: return parse_attrlist(str_, avsep, vssep, avssep) if lsep in str_: return parse_list(str_, lsep) return parse_single(str_)
[ "def", "parse", "(", "str_", ",", "lsep", "=", "\",\"", ",", "avsep", "=", "\":\"", ",", "vssep", "=", "\",\"", ",", "avssep", "=", "\";\"", ")", ":", "if", "avsep", "in", "str_", ":", "return", "parse_attrlist", "(", "str_", ",", "avsep", ",", "vs...
Generic parser
[ "Generic", "parser" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/parser.py#L150-L157
ssato/python-anyconfig
src/anyconfig/cli.py
to_log_level
def to_log_level(level): """ :param level: Logging level in int = 0 .. 2 >>> to_log_level(0) == logging.WARN True >>> to_log_level(5) # doctest: +IGNORE_EXCEPTION_DETAIL, +ELLIPSIS Traceback (most recent call last): ... ValueError: wrong log level passed: 5 >>> """ if l...
python
def to_log_level(level): """ :param level: Logging level in int = 0 .. 2 >>> to_log_level(0) == logging.WARN True >>> to_log_level(5) # doctest: +IGNORE_EXCEPTION_DETAIL, +ELLIPSIS Traceback (most recent call last): ... ValueError: wrong log level passed: 5 >>> """ if l...
[ "def", "to_log_level", "(", "level", ")", ":", "if", "level", "<", "0", "or", "level", ">=", "3", ":", "raise", "ValueError", "(", "\"wrong log level passed: \"", "+", "str", "(", "level", ")", ")", "return", "[", "logging", ".", "WARN", ",", "logging", ...
:param level: Logging level in int = 0 .. 2 >>> to_log_level(0) == logging.WARN True >>> to_log_level(5) # doctest: +IGNORE_EXCEPTION_DETAIL, +ELLIPSIS Traceback (most recent call last): ... ValueError: wrong log level passed: 5 >>>
[ ":", "param", "level", ":", "Logging", "level", "in", "int", "=", "0", "..", "2" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L74-L89