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
CZ-NIC/yangson
yangson/instance.py
EntryIndex.peek_step
def peek_step(self, val: ArrayValue, sn: "DataNode") -> Tuple[Optional[Value], "DataNode"]: """Return entry value addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node. """ try: retur...
python
def peek_step(self, val: ArrayValue, sn: "DataNode") -> Tuple[Optional[Value], "DataNode"]: """Return entry value addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node. """ try: retur...
[ "def", "peek_step", "(", "self", ",", "val", ":", "ArrayValue", ",", "sn", ":", "\"DataNode\"", ")", "->", "Tuple", "[", "Optional", "[", "Value", "]", ",", "\"DataNode\"", "]", ":", "try", ":", "return", "val", "[", "self", ".", "index", "]", ",", ...
Return entry value addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node.
[ "Return", "entry", "value", "addressed", "by", "the", "receiver", "+", "its", "schema", "node", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L854-L865
CZ-NIC/yangson
yangson/instance.py
EntryValue.parse_value
def parse_value(self, sn: "DataNode") -> ScalarValue: """Let schema node's type parse the receiver's value.""" res = sn.type.parse_value(self.value) if res is None: raise InvalidKeyValue(self.value) return res
python
def parse_value(self, sn: "DataNode") -> ScalarValue: """Let schema node's type parse the receiver's value.""" res = sn.type.parse_value(self.value) if res is None: raise InvalidKeyValue(self.value) return res
[ "def", "parse_value", "(", "self", ",", "sn", ":", "\"DataNode\"", ")", "->", "ScalarValue", ":", "res", "=", "sn", ".", "type", ".", "parse_value", "(", "self", ".", "value", ")", "if", "res", "is", "None", ":", "raise", "InvalidKeyValue", "(", "self"...
Let schema node's type parse the receiver's value.
[ "Let", "schema", "node", "s", "type", "parse", "the", "receiver", "s", "value", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L894-L899
CZ-NIC/yangson
yangson/instance.py
EntryValue.peek_step
def peek_step(self, val: ArrayValue, sn: "DataNode") -> Tuple[Value, "DataNode"]: """Return entry value addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node. """ try: return (val[val...
python
def peek_step(self, val: ArrayValue, sn: "DataNode") -> Tuple[Value, "DataNode"]: """Return entry value addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node. """ try: return (val[val...
[ "def", "peek_step", "(", "self", ",", "val", ":", "ArrayValue", ",", "sn", ":", "\"DataNode\"", ")", "->", "Tuple", "[", "Value", ",", "\"DataNode\"", "]", ":", "try", ":", "return", "(", "val", "[", "val", ".", "index", "(", "self", ".", "parse_valu...
Return entry value addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node.
[ "Return", "entry", "value", "addressed", "by", "the", "receiver", "+", "its", "schema", "node", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L901-L912
CZ-NIC/yangson
yangson/instance.py
EntryValue.goto_step
def goto_step(self, inst: InstanceNode) -> InstanceNode: """Return member instance of `inst` addressed by the receiver. Args: inst: Current instance. """ try: return inst._entry( inst.value.index(self.parse_value(inst.schema_node))) except...
python
def goto_step(self, inst: InstanceNode) -> InstanceNode: """Return member instance of `inst` addressed by the receiver. Args: inst: Current instance. """ try: return inst._entry( inst.value.index(self.parse_value(inst.schema_node))) except...
[ "def", "goto_step", "(", "self", ",", "inst", ":", "InstanceNode", ")", "->", "InstanceNode", ":", "try", ":", "return", "inst", ".", "_entry", "(", "inst", ".", "value", ".", "index", "(", "self", ".", "parse_value", "(", "inst", ".", "schema_node", "...
Return member instance of `inst` addressed by the receiver. Args: inst: Current instance.
[ "Return", "member", "instance", "of", "inst", "addressed", "by", "the", "receiver", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L914-L925
CZ-NIC/yangson
yangson/instance.py
EntryKeys.parse_keys
def parse_keys(self, sn: "DataNode") -> Dict[InstanceName, ScalarValue]: """Parse key dictionary in the context of a schema node. Args: sn: Schema node corresponding to a list. """ res = {} for k in self.keys: knod = sn.get_data_child(*k) if k...
python
def parse_keys(self, sn: "DataNode") -> Dict[InstanceName, ScalarValue]: """Parse key dictionary in the context of a schema node. Args: sn: Schema node corresponding to a list. """ res = {} for k in self.keys: knod = sn.get_data_child(*k) if k...
[ "def", "parse_keys", "(", "self", ",", "sn", ":", "\"DataNode\"", ")", "->", "Dict", "[", "InstanceName", ",", "ScalarValue", "]", ":", "res", "=", "{", "}", "for", "k", "in", "self", ".", "keys", ":", "knod", "=", "sn", ".", "get_data_child", "(", ...
Parse key dictionary in the context of a schema node. Args: sn: Schema node corresponding to a list.
[ "Parse", "key", "dictionary", "in", "the", "context", "of", "a", "schema", "node", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L951-L966
CZ-NIC/yangson
yangson/instance.py
EntryKeys.peek_step
def peek_step(self, val: ArrayValue, sn: "DataNode") -> Tuple[ObjectValue, "DataNode"]: """Return the entry addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node. """ keys = self.parse_keys(sn) ...
python
def peek_step(self, val: ArrayValue, sn: "DataNode") -> Tuple[ObjectValue, "DataNode"]: """Return the entry addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node. """ keys = self.parse_keys(sn) ...
[ "def", "peek_step", "(", "self", ",", "val", ":", "ArrayValue", ",", "sn", ":", "\"DataNode\"", ")", "->", "Tuple", "[", "ObjectValue", ",", "\"DataNode\"", "]", ":", "keys", "=", "self", ".", "parse_keys", "(", "sn", ")", "for", "en", "in", "val", "...
Return the entry addressed by the receiver + its schema node. Args: val: Current value (array). sn: Current schema node.
[ "Return", "the", "entry", "addressed", "by", "the", "receiver", "+", "its", "schema", "node", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L968-L988
CZ-NIC/yangson
yangson/instance.py
EntryKeys.goto_step
def goto_step(self, inst: InstanceNode) -> InstanceNode: """Return member instance of `inst` addressed by the receiver. Args: inst: Current instance. """ return inst.look_up(**self.parse_keys(inst.schema_node))
python
def goto_step(self, inst: InstanceNode) -> InstanceNode: """Return member instance of `inst` addressed by the receiver. Args: inst: Current instance. """ return inst.look_up(**self.parse_keys(inst.schema_node))
[ "def", "goto_step", "(", "self", ",", "inst", ":", "InstanceNode", ")", "->", "InstanceNode", ":", "return", "inst", ".", "look_up", "(", "*", "*", "self", ".", "parse_keys", "(", "inst", ".", "schema_node", ")", ")" ]
Return member instance of `inst` addressed by the receiver. Args: inst: Current instance.
[ "Return", "member", "instance", "of", "inst", "addressed", "by", "the", "receiver", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L990-L996
CZ-NIC/yangson
yangson/instance.py
ResourceIdParser.parse
def parse(self) -> InstanceRoute: """Parse resource identifier.""" res = InstanceRoute() if self.at_end(): return res if self.peek() == "/": self.offset += 1 if self.at_end(): return res sn = self.schema_node while True: ...
python
def parse(self) -> InstanceRoute: """Parse resource identifier.""" res = InstanceRoute() if self.at_end(): return res if self.peek() == "/": self.offset += 1 if self.at_end(): return res sn = self.schema_node while True: ...
[ "def", "parse", "(", "self", ")", "->", "InstanceRoute", ":", "res", "=", "InstanceRoute", "(", ")", "if", "self", ".", "at_end", "(", ")", ":", "return", "res", "if", "self", ".", "peek", "(", ")", "==", "\"/\"", ":", "self", ".", "offset", "+=", ...
Parse resource identifier.
[ "Parse", "resource", "identifier", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L1011-L1041
CZ-NIC/yangson
yangson/instance.py
ResourceIdParser._key_values
def _key_values(self, sn: "SequenceNode") -> Union[EntryKeys, EntryValue]: """Parse leaf-list value or list keys.""" try: keys = self.up_to("/") except EndOfInput: keys = self.remaining() if not keys: raise UnexpectedInput(self, "entry value or keys") ...
python
def _key_values(self, sn: "SequenceNode") -> Union[EntryKeys, EntryValue]: """Parse leaf-list value or list keys.""" try: keys = self.up_to("/") except EndOfInput: keys = self.remaining() if not keys: raise UnexpectedInput(self, "entry value or keys") ...
[ "def", "_key_values", "(", "self", ",", "sn", ":", "\"SequenceNode\"", ")", "->", "Union", "[", "EntryKeys", ",", "EntryValue", "]", ":", "try", ":", "keys", "=", "self", ".", "up_to", "(", "\"/\"", ")", "except", "EndOfInput", ":", "keys", "=", "self"...
Parse leaf-list value or list keys.
[ "Parse", "leaf", "-", "list", "value", "or", "list", "keys", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L1043-L1064
CZ-NIC/yangson
yangson/instance.py
InstanceIdParser.parse
def parse(self) -> InstanceRoute: """Parse instance identifier.""" res = InstanceRoute() while True: self.char("/") res.append(MemberName(*self.prefixed_name())) try: next = self.peek() except EndOfInput: return res ...
python
def parse(self) -> InstanceRoute: """Parse instance identifier.""" res = InstanceRoute() while True: self.char("/") res.append(MemberName(*self.prefixed_name())) try: next = self.peek() except EndOfInput: return res ...
[ "def", "parse", "(", "self", ")", "->", "InstanceRoute", ":", "res", "=", "InstanceRoute", "(", ")", "while", "True", ":", "self", ".", "char", "(", "\"/\"", ")", "res", ".", "append", "(", "MemberName", "(", "*", "self", ".", "prefixed_name", "(", "...
Parse instance identifier.
[ "Parse", "instance", "identifier", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L1070-L1097
CZ-NIC/yangson
yangson/statement.py
Statement.find1
def find1(self, kw: YangIdentifier, arg: str = None, pref: YangIdentifier = None, required: bool = False) -> Optional["Statement"]: """Return first substatement with the given parameters. Args: kw: Statement keyword (local part for extensions). arg: A...
python
def find1(self, kw: YangIdentifier, arg: str = None, pref: YangIdentifier = None, required: bool = False) -> Optional["Statement"]: """Return first substatement with the given parameters. Args: kw: Statement keyword (local part for extensions). arg: A...
[ "def", "find1", "(", "self", ",", "kw", ":", "YangIdentifier", ",", "arg", ":", "str", "=", "None", ",", "pref", ":", "YangIdentifier", "=", "None", ",", "required", ":", "bool", "=", "False", ")", "->", "Optional", "[", "\"Statement\"", "]", ":", "f...
Return first substatement with the given parameters. Args: kw: Statement keyword (local part for extensions). arg: Argument (all arguments will match if ``None``). pref: Keyword prefix (``None`` for built-in statements). required: Should an exception be raised on...
[ "Return", "first", "substatement", "with", "the", "given", "parameters", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L70-L90
CZ-NIC/yangson
yangson/statement.py
Statement.find_all
def find_all(self, kw: YangIdentifier, pref: YangIdentifier = None) -> List["Statement"]: """Return the list all substatements with the given keyword and prefix. Args: kw: Statement keyword (local part for extensions). pref: Keyword prefix (``None`` for built-in...
python
def find_all(self, kw: YangIdentifier, pref: YangIdentifier = None) -> List["Statement"]: """Return the list all substatements with the given keyword and prefix. Args: kw: Statement keyword (local part for extensions). pref: Keyword prefix (``None`` for built-in...
[ "def", "find_all", "(", "self", ",", "kw", ":", "YangIdentifier", ",", "pref", ":", "YangIdentifier", "=", "None", ")", "->", "List", "[", "\"Statement\"", "]", ":", "return", "[", "c", "for", "c", "in", "self", ".", "substatements", "if", "c", ".", ...
Return the list all substatements with the given keyword and prefix. Args: kw: Statement keyword (local part for extensions). pref: Keyword prefix (``None`` for built-in statements).
[ "Return", "the", "list", "all", "substatements", "with", "the", "given", "keyword", "and", "prefix", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L92-L101
CZ-NIC/yangson
yangson/statement.py
Statement.get_definition
def get_definition(self, name: YangIdentifier, kw: YangIdentifier) -> Optional["Statement"]: """Search ancestor statements for a definition. Args: name: Name of a grouping or datatype (with no prefix). kw: ``grouping`` or ``typedef``. Raises: ...
python
def get_definition(self, name: YangIdentifier, kw: YangIdentifier) -> Optional["Statement"]: """Search ancestor statements for a definition. Args: name: Name of a grouping or datatype (with no prefix). kw: ``grouping`` or ``typedef``. Raises: ...
[ "def", "get_definition", "(", "self", ",", "name", ":", "YangIdentifier", ",", "kw", ":", "YangIdentifier", ")", "->", "Optional", "[", "\"Statement\"", "]", ":", "stmt", "=", "self", ".", "superstmt", "while", "stmt", ":", "res", "=", "stmt", ".", "find...
Search ancestor statements for a definition. Args: name: Name of a grouping or datatype (with no prefix). kw: ``grouping`` or ``typedef``. Raises: DefinitionNotFound: If the definition is not found.
[ "Search", "ancestor", "statements", "for", "a", "definition", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L103-L120
CZ-NIC/yangson
yangson/statement.py
Statement.get_error_info
def get_error_info(self) -> Tuple[Optional[str], Optional[str]]: """Return receiver's error tag and error message if present.""" etag = self.find1("error-app-tag") emsg = self.find1("error-message") return (etag.argument if etag else None, emsg.argument if emsg else None)
python
def get_error_info(self) -> Tuple[Optional[str], Optional[str]]: """Return receiver's error tag and error message if present.""" etag = self.find1("error-app-tag") emsg = self.find1("error-message") return (etag.argument if etag else None, emsg.argument if emsg else None)
[ "def", "get_error_info", "(", "self", ")", "->", "Tuple", "[", "Optional", "[", "str", "]", ",", "Optional", "[", "str", "]", "]", ":", "etag", "=", "self", ".", "find1", "(", "\"error-app-tag\"", ")", "emsg", "=", "self", ".", "find1", "(", "\"error...
Return receiver's error tag and error message if present.
[ "Return", "receiver", "s", "error", "tag", "and", "error", "message", "if", "present", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L122-L126
CZ-NIC/yangson
yangson/statement.py
ModuleParser.parse
def parse(self) -> Statement: """Parse a complete YANG module or submodule. Args: mtext: YANG module text. Raises: EndOfInput: If past the end of input. ModuleNameMismatch: If parsed module name doesn't match `self.name`. ModuleRevisionMismatch: ...
python
def parse(self) -> Statement: """Parse a complete YANG module or submodule. Args: mtext: YANG module text. Raises: EndOfInput: If past the end of input. ModuleNameMismatch: If parsed module name doesn't match `self.name`. ModuleRevisionMismatch: ...
[ "def", "parse", "(", "self", ")", "->", "Statement", ":", "self", ".", "opt_separator", "(", ")", "start", "=", "self", ".", "offset", "res", "=", "self", ".", "statement", "(", ")", "if", "res", ".", "keyword", "not", "in", "[", "\"module\"", ",", ...
Parse a complete YANG module or submodule. Args: mtext: YANG module text. Raises: EndOfInput: If past the end of input. ModuleNameMismatch: If parsed module name doesn't match `self.name`. ModuleRevisionMismatch: If parsed revision date doesn't match `se...
[ "Parse", "a", "complete", "YANG", "module", "or", "submodule", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L147-L175
CZ-NIC/yangson
yangson/statement.py
ModuleParser.unescape
def unescape(cls, text: str) -> str: """Replace escape sequence with corresponding characters. Args: text: Text to unescape. """ chop = text.split("\\", 1) try: return (chop[0] if len(chop) == 1 else chop[0] + cls.unescape_map[chop[1][...
python
def unescape(cls, text: str) -> str: """Replace escape sequence with corresponding characters. Args: text: Text to unescape. """ chop = text.split("\\", 1) try: return (chop[0] if len(chop) == 1 else chop[0] + cls.unescape_map[chop[1][...
[ "def", "unescape", "(", "cls", ",", "text", ":", "str", ")", "->", "str", ":", "chop", "=", "text", ".", "split", "(", "\"\\\\\"", ",", "1", ")", "try", ":", "return", "(", "chop", "[", "0", "]", "if", "len", "(", "chop", ")", "==", "1", "els...
Replace escape sequence with corresponding characters. Args: text: Text to unescape.
[ "Replace", "escape", "sequence", "with", "corresponding", "characters", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L182-L194
CZ-NIC/yangson
yangson/statement.py
ModuleParser.opt_separator
def opt_separator(self) -> bool: """Parse an optional separator and return ``True`` if found. Raises: EndOfInput: If past the end of input. """ start = self.offset self.dfa([ { # state 0: whitespace "": lambda: -1, " ": la...
python
def opt_separator(self) -> bool: """Parse an optional separator and return ``True`` if found. Raises: EndOfInput: If past the end of input. """ start = self.offset self.dfa([ { # state 0: whitespace "": lambda: -1, " ": la...
[ "def", "opt_separator", "(", "self", ")", "->", "bool", ":", "start", "=", "self", ".", "offset", "self", ".", "dfa", "(", "[", "{", "# state 0: whitespace", "\"\"", ":", "lambda", ":", "-", "1", ",", "\" \"", ":", "lambda", ":", "0", ",", "\"\\t\"",...
Parse an optional separator and return ``True`` if found. Raises: EndOfInput: If past the end of input.
[ "Parse", "an", "optional", "separator", "and", "return", "True", "if", "found", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L196-L234
CZ-NIC/yangson
yangson/statement.py
ModuleParser.keyword
def keyword(self) -> Tuple[Optional[str], str]: """Parse a YANG statement keyword. Raises: EndOfInput: If past the end of input. UnexpectedInput: If no syntactically correct keyword is found. """ i1 = self.yang_identifier() if self.peek() == ":": ...
python
def keyword(self) -> Tuple[Optional[str], str]: """Parse a YANG statement keyword. Raises: EndOfInput: If past the end of input. UnexpectedInput: If no syntactically correct keyword is found. """ i1 = self.yang_identifier() if self.peek() == ":": ...
[ "def", "keyword", "(", "self", ")", "->", "Tuple", "[", "Optional", "[", "str", "]", ",", "str", "]", ":", "i1", "=", "self", ".", "yang_identifier", "(", ")", "if", "self", ".", "peek", "(", ")", "==", "\":\"", ":", "self", ".", "offset", "+=", ...
Parse a YANG statement keyword. Raises: EndOfInput: If past the end of input. UnexpectedInput: If no syntactically correct keyword is found.
[ "Parse", "a", "YANG", "statement", "keyword", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L247-L259
CZ-NIC/yangson
yangson/statement.py
ModuleParser.statement
def statement(self) -> Statement: """Parse YANG statement. Raises: EndOfInput: If past the end of input. UnexpectedInput: If no syntactically correct statement is found. """ pref, kw = self.keyword() pres = self.opt_separator() next = self.peek() ...
python
def statement(self) -> Statement: """Parse YANG statement. Raises: EndOfInput: If past the end of input. UnexpectedInput: If no syntactically correct statement is found. """ pref, kw = self.keyword() pres = self.opt_separator() next = self.peek() ...
[ "def", "statement", "(", "self", ")", "->", "Statement", ":", "pref", ",", "kw", "=", "self", ".", "keyword", "(", ")", "pres", "=", "self", ".", "opt_separator", "(", ")", "next", "=", "self", ".", "peek", "(", ")", "if", "next", "==", "\";\"", ...
Parse YANG statement. Raises: EndOfInput: If past the end of input. UnexpectedInput: If no syntactically correct statement is found.
[ "Parse", "YANG", "statement", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L261-L289
CZ-NIC/yangson
yangson/statement.py
ModuleParser.argument
def argument(self) -> bool: """Parse statement argument. Return ``True`` if the argument is followed by block of substatements. """ next = self.peek() if next == "'": quoted = True self.sq_argument() elif next == '"': quoted = True ...
python
def argument(self) -> bool: """Parse statement argument. Return ``True`` if the argument is followed by block of substatements. """ next = self.peek() if next == "'": quoted = True self.sq_argument() elif next == '"': quoted = True ...
[ "def", "argument", "(", "self", ")", "->", "bool", ":", "next", "=", "self", ".", "peek", "(", ")", "if", "next", "==", "\"'\"", ":", "quoted", "=", "True", "self", ".", "sq_argument", "(", ")", "elif", "next", "==", "'\"'", ":", "quoted", "=", "...
Parse statement argument. Return ``True`` if the argument is followed by block of substatements.
[ "Parse", "statement", "argument", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L291-L320
CZ-NIC/yangson
yangson/statement.py
ModuleParser.dq_argument
def dq_argument(self) -> str: """Parse double-quoted argument. Raises: EndOfInput: If past the end of input. """ def escape(): self._escape = True return 1 self._escape = False # any escaped chars? self.offset += 1 ...
python
def dq_argument(self) -> str: """Parse double-quoted argument. Raises: EndOfInput: If past the end of input. """ def escape(): self._escape = True return 1 self._escape = False # any escaped chars? self.offset += 1 ...
[ "def", "dq_argument", "(", "self", ")", "->", "str", ":", "def", "escape", "(", ")", ":", "self", ".", "_escape", "=", "True", "return", "1", "self", ".", "_escape", "=", "False", "# any escaped chars?", "self", ".", "offset", "+=", "1", "start", "=", ...
Parse double-quoted argument. Raises: EndOfInput: If past the end of input.
[ "Parse", "double", "-", "quoted", "argument", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L331-L354
CZ-NIC/yangson
yangson/statement.py
ModuleParser.unq_argument
def unq_argument(self) -> str: """Parse unquoted argument. Raises: EndOfInput: If past the end of input. """ start = self.offset self.dfa([ { # state 0: argument "": lambda: 0, ";": lambda: -1, " ": lambda:...
python
def unq_argument(self) -> str: """Parse unquoted argument. Raises: EndOfInput: If past the end of input. """ start = self.offset self.dfa([ { # state 0: argument "": lambda: 0, ";": lambda: -1, " ": lambda:...
[ "def", "unq_argument", "(", "self", ")", "->", "str", ":", "start", "=", "self", ".", "offset", "self", ".", "dfa", "(", "[", "{", "# state 0: argument", "\"\"", ":", "lambda", ":", "0", ",", "\";\"", ":", "lambda", ":", "-", "1", ",", "\" \"", ":"...
Parse unquoted argument. Raises: EndOfInput: If past the end of input.
[ "Parse", "unquoted", "argument", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L356-L379
CZ-NIC/yangson
yangson/statement.py
ModuleParser.substatements
def substatements(self) -> List[Statement]: """Parse substatements. Raises: EndOfInput: If past the end of input. """ res = [] self.opt_separator() while self.peek() != "}": res.append(self.statement()) self.opt_separator() sel...
python
def substatements(self) -> List[Statement]: """Parse substatements. Raises: EndOfInput: If past the end of input. """ res = [] self.opt_separator() while self.peek() != "}": res.append(self.statement()) self.opt_separator() sel...
[ "def", "substatements", "(", "self", ")", "->", "List", "[", "Statement", "]", ":", "res", "=", "[", "]", "self", ".", "opt_separator", "(", ")", "while", "self", ".", "peek", "(", ")", "!=", "\"}\"", ":", "res", ".", "append", "(", "self", ".", ...
Parse substatements. Raises: EndOfInput: If past the end of input.
[ "Parse", "substatements", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L381-L393
CZ-NIC/yangson
yangson/schemadata.py
SchemaData._from_yang_library
def _from_yang_library(self, yang_lib: Dict[str, Any]) -> None: """Set the schema structures from YANG library data. Args: yang_lib: Dictionary with YANG library data. Raises: BadYangLibraryData: If YANG library data is invalid. FeaturePrerequisiteError: If ...
python
def _from_yang_library(self, yang_lib: Dict[str, Any]) -> None: """Set the schema structures from YANG library data. Args: yang_lib: Dictionary with YANG library data. Raises: BadYangLibraryData: If YANG library data is invalid. FeaturePrerequisiteError: If ...
[ "def", "_from_yang_library", "(", "self", ",", "yang_lib", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "try", ":", "for", "item", "in", "yang_lib", "[", "\"ietf-yang-library:modules-state\"", "]", "[", "\"module\"", "]", ":", "name", ...
Set the schema structures from YANG library data. Args: yang_lib: Dictionary with YANG library data. Raises: BadYangLibraryData: If YANG library data is invalid. FeaturePrerequisiteError: If a pre-requisite feature isn't supported. Multip...
[ "Set", "the", "schema", "structures", "from", "YANG", "library", "data", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L103-L150
CZ-NIC/yangson
yangson/schemadata.py
SchemaData._load_module
def _load_module(self, name: YangIdentifier, rev: RevisionDate) -> Statement: """Read and parse a YANG module or submodule.""" for d in self.module_search_path: run = 0 while run < 2: fn = f"{d}/{name}" if rev and run == 0: ...
python
def _load_module(self, name: YangIdentifier, rev: RevisionDate) -> Statement: """Read and parse a YANG module or submodule.""" for d in self.module_search_path: run = 0 while run < 2: fn = f"{d}/{name}" if rev and run == 0: ...
[ "def", "_load_module", "(", "self", ",", "name", ":", "YangIdentifier", ",", "rev", ":", "RevisionDate", ")", "->", "Statement", ":", "for", "d", "in", "self", ".", "module_search_path", ":", "run", "=", "0", "while", "run", "<", "2", ":", "fn", "=", ...
Read and parse a YANG module or submodule.
[ "Read", "and", "parse", "a", "YANG", "module", "or", "submodule", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L152-L169
CZ-NIC/yangson
yangson/schemadata.py
SchemaData._check_feature_dependences
def _check_feature_dependences(self): """Verify feature dependences.""" for mid in self.modules: for fst in self.modules[mid].statement.find_all("feature"): fn, fid = self.resolve_pname(fst.argument, mid) if fn not in self.modules[fid].features: ...
python
def _check_feature_dependences(self): """Verify feature dependences.""" for mid in self.modules: for fst in self.modules[mid].statement.find_all("feature"): fn, fid = self.resolve_pname(fst.argument, mid) if fn not in self.modules[fid].features: ...
[ "def", "_check_feature_dependences", "(", "self", ")", ":", "for", "mid", "in", "self", ".", "modules", ":", "for", "fst", "in", "self", ".", "modules", "[", "mid", "]", ".", "statement", ".", "find_all", "(", "\"feature\"", ")", ":", "fn", ",", "fid",...
Verify feature dependences.
[ "Verify", "feature", "dependences", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L208-L216
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.namespace
def namespace(self, mid: ModuleId) -> YangIdentifier: """Return the namespace corresponding to a module or submodule. Args: mid: Module identifier. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. """ try: mdata = se...
python
def namespace(self, mid: ModuleId) -> YangIdentifier: """Return the namespace corresponding to a module or submodule. Args: mid: Module identifier. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. """ try: mdata = se...
[ "def", "namespace", "(", "self", ",", "mid", ":", "ModuleId", ")", "->", "YangIdentifier", ":", "try", ":", "mdata", "=", "self", ".", "modules", "[", "mid", "]", "except", "KeyError", ":", "raise", "ModuleNotRegistered", "(", "*", "mid", ")", "from", ...
Return the namespace corresponding to a module or submodule. Args: mid: Module identifier. Raises: ModuleNotRegistered: If `mid` is not registered in the data model.
[ "Return", "the", "namespace", "corresponding", "to", "a", "module", "or", "submodule", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L218-L231
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.last_revision
def last_revision(self, mod: YangIdentifier) -> ModuleId: """Return the last revision of a module that's part of the data model. Args: mod: Name of a module or submodule. Raises: ModuleNotRegistered: If the module `mod` is not present in the data model. ...
python
def last_revision(self, mod: YangIdentifier) -> ModuleId: """Return the last revision of a module that's part of the data model. Args: mod: Name of a module or submodule. Raises: ModuleNotRegistered: If the module `mod` is not present in the data model. ...
[ "def", "last_revision", "(", "self", ",", "mod", ":", "YangIdentifier", ")", "->", "ModuleId", ":", "revs", "=", "[", "mn", "for", "mn", "in", "self", ".", "modules", "if", "mn", "[", "0", "]", "==", "mod", "]", "if", "not", "revs", ":", "raise", ...
Return the last revision of a module that's part of the data model. Args: mod: Name of a module or submodule. Raises: ModuleNotRegistered: If the module `mod` is not present in the data model.
[ "Return", "the", "last", "revision", "of", "a", "module", "that", "s", "part", "of", "the", "data", "model", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L233-L246
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.prefix2ns
def prefix2ns(self, prefix: YangIdentifier, mid: ModuleId) -> YangIdentifier: """Return the namespace corresponding to a prefix. Args: prefix: Prefix associated with a module and its namespace. mid: Identifier of the module in which the prefix is declared. Raises: ...
python
def prefix2ns(self, prefix: YangIdentifier, mid: ModuleId) -> YangIdentifier: """Return the namespace corresponding to a prefix. Args: prefix: Prefix associated with a module and its namespace. mid: Identifier of the module in which the prefix is declared. Raises: ...
[ "def", "prefix2ns", "(", "self", ",", "prefix", ":", "YangIdentifier", ",", "mid", ":", "ModuleId", ")", "->", "YangIdentifier", ":", "try", ":", "mdata", "=", "self", ".", "modules", "[", "mid", "]", "except", "KeyError", ":", "raise", "ModuleNotRegistere...
Return the namespace corresponding to a prefix. Args: prefix: Prefix associated with a module and its namespace. mid: Identifier of the module in which the prefix is declared. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. Unk...
[ "Return", "the", "namespace", "corresponding", "to", "a", "prefix", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L248-L266
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.resolve_pname
def resolve_pname(self, pname: PrefName, mid: ModuleId) -> Tuple[YangIdentifier, ModuleId]: """Return the name and module identifier in which the name is defined. Args: pname: Name with an optional prefix. mid: Identifier of the module in which `pname` appe...
python
def resolve_pname(self, pname: PrefName, mid: ModuleId) -> Tuple[YangIdentifier, ModuleId]: """Return the name and module identifier in which the name is defined. Args: pname: Name with an optional prefix. mid: Identifier of the module in which `pname` appe...
[ "def", "resolve_pname", "(", "self", ",", "pname", ":", "PrefName", ",", "mid", ":", "ModuleId", ")", "->", "Tuple", "[", "YangIdentifier", ",", "ModuleId", "]", ":", "p", ",", "s", ",", "loc", "=", "pname", ".", "partition", "(", "\":\"", ")", "try"...
Return the name and module identifier in which the name is defined. Args: pname: Name with an optional prefix. mid: Identifier of the module in which `pname` appears. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. UnknownPrefi...
[ "Return", "the", "name", "and", "module", "identifier", "in", "which", "the", "name", "is", "defined", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L268-L288
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.translate_pname
def translate_pname(self, pname: PrefName, mid: ModuleId) -> QualName: """Translate a prefixed name to a qualified name. Args: pname: Name with an optional prefix. mid: Identifier of the module in which `pname` appears. Raises: ModuleNotRegistered: If `mid` is...
python
def translate_pname(self, pname: PrefName, mid: ModuleId) -> QualName: """Translate a prefixed name to a qualified name. Args: pname: Name with an optional prefix. mid: Identifier of the module in which `pname` appears. Raises: ModuleNotRegistered: If `mid` is...
[ "def", "translate_pname", "(", "self", ",", "pname", ":", "PrefName", ",", "mid", ":", "ModuleId", ")", "->", "QualName", ":", "loc", ",", "nid", "=", "self", ".", "resolve_pname", "(", "pname", ",", "mid", ")", "return", "(", "loc", ",", "self", "."...
Translate a prefixed name to a qualified name. Args: pname: Name with an optional prefix. mid: Identifier of the module in which `pname` appears. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. UnknownPrefix: If the prefix specif...
[ "Translate", "a", "prefixed", "name", "to", "a", "qualified", "name", ".", "Args", ":", "pname", ":", "Name", "with", "an", "optional", "prefix", ".", "mid", ":", "Identifier", "of", "the", "module", "in", "which", "pname", "appears", ".", "Raises", ":",...
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L290-L300
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.translate_node_id
def translate_node_id(self, ni: PrefName, sctx: SchemaContext) -> QualName: """Translate node identifier to a qualified name. Args: ni: Node identifier (with optional prefix). sctx: SchemaContext. Raises: ModuleNotRegistered: If `mid` is not registered in th...
python
def translate_node_id(self, ni: PrefName, sctx: SchemaContext) -> QualName: """Translate node identifier to a qualified name. Args: ni: Node identifier (with optional prefix). sctx: SchemaContext. Raises: ModuleNotRegistered: If `mid` is not registered in th...
[ "def", "translate_node_id", "(", "self", ",", "ni", ":", "PrefName", ",", "sctx", ":", "SchemaContext", ")", "->", "QualName", ":", "p", ",", "s", ",", "loc", "=", "ni", ".", "partition", "(", "\":\"", ")", "if", "not", "s", ":", "return", "(", "ni...
Translate node identifier to a qualified name. Args: ni: Node identifier (with optional prefix). sctx: SchemaContext. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. UnknownPrefix: If the prefix specified in `ni` is not declare...
[ "Translate", "node", "identifier", "to", "a", "qualified", "name", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L302-L323
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.prefix
def prefix(self, imod: YangIdentifier, mid: ModuleId) -> YangIdentifier: """Return the prefix corresponding to an implemented module. Args: imod: Name of an implemented module. mid: Identifier of the context module. Raises: ModuleNotImplemented: If `imod` is...
python
def prefix(self, imod: YangIdentifier, mid: ModuleId) -> YangIdentifier: """Return the prefix corresponding to an implemented module. Args: imod: Name of an implemented module. mid: Identifier of the context module. Raises: ModuleNotImplemented: If `imod` is...
[ "def", "prefix", "(", "self", ",", "imod", ":", "YangIdentifier", ",", "mid", ":", "ModuleId", ")", "->", "YangIdentifier", ":", "try", ":", "did", "=", "(", "imod", ",", "self", ".", "implement", "[", "imod", "]", ")", "except", "KeyError", ":", "ra...
Return the prefix corresponding to an implemented module. Args: imod: Name of an implemented module. mid: Identifier of the context module. Raises: ModuleNotImplemented: If `imod` is not implemented. ModuleNotRegistered: If `mid` is not registered in YAN...
[ "Return", "the", "prefix", "corresponding", "to", "an", "implemented", "module", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L325-L348
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.sni2route
def sni2route(self, sni: SchemaNodeId, sctx: SchemaContext) -> SchemaRoute: """Translate schema node identifier to a schema route. Args: sni: Schema node identifier (absolute or relative). sctx: Schema context. Raises: ModuleNotRegistered: If `mid` is not re...
python
def sni2route(self, sni: SchemaNodeId, sctx: SchemaContext) -> SchemaRoute: """Translate schema node identifier to a schema route. Args: sni: Schema node identifier (absolute or relative). sctx: Schema context. Raises: ModuleNotRegistered: If `mid` is not re...
[ "def", "sni2route", "(", "self", ",", "sni", ":", "SchemaNodeId", ",", "sctx", ":", "SchemaContext", ")", "->", "SchemaRoute", ":", "nlist", "=", "sni", ".", "split", "(", "\"/\"", ")", "res", "=", "[", "]", "for", "qn", "in", "(", "nlist", "[", "1...
Translate schema node identifier to a schema route. Args: sni: Schema node identifier (absolute or relative). sctx: Schema context. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. UnknownPrefix: If a prefix specified in `sni` i...
[ "Translate", "schema", "node", "identifier", "to", "a", "schema", "route", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L350-L365
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.path2route
def path2route(path: SchemaPath) -> SchemaRoute: """Translate a schema/data path to a schema/data route. Args: path: Schema path. Raises: InvalidSchemaPath: Invalid path. """ if path == "/" or path == "": return [] nlist = path.split(...
python
def path2route(path: SchemaPath) -> SchemaRoute: """Translate a schema/data path to a schema/data route. Args: path: Schema path. Raises: InvalidSchemaPath: Invalid path. """ if path == "/" or path == "": return [] nlist = path.split(...
[ "def", "path2route", "(", "path", ":", "SchemaPath", ")", "->", "SchemaRoute", ":", "if", "path", "==", "\"/\"", "or", "path", "==", "\"\"", ":", "return", "[", "]", "nlist", "=", "path", ".", "split", "(", "\"/\"", ")", "prevns", "=", "None", "res",...
Translate a schema/data path to a schema/data route. Args: path: Schema path. Raises: InvalidSchemaPath: Invalid path.
[ "Translate", "a", "schema", "/", "data", "path", "to", "a", "schema", "/", "data", "route", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L368-L393
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.get_definition
def get_definition(self, stmt: Statement, sctx: SchemaContext) -> Tuple[Statement, SchemaContext]: """Find the statement defining a grouping or derived type. Args: stmt: YANG "uses" or "type" statement. sctx: Schema context where the definition is used. ...
python
def get_definition(self, stmt: Statement, sctx: SchemaContext) -> Tuple[Statement, SchemaContext]: """Find the statement defining a grouping or derived type. Args: stmt: YANG "uses" or "type" statement. sctx: Schema context where the definition is used. ...
[ "def", "get_definition", "(", "self", ",", "stmt", ":", "Statement", ",", "sctx", ":", "SchemaContext", ")", "->", "Tuple", "[", "Statement", ",", "SchemaContext", "]", ":", "if", "stmt", ".", "keyword", "==", "\"uses\"", ":", "kw", "=", "\"grouping\"", ...
Find the statement defining a grouping or derived type. Args: stmt: YANG "uses" or "type" statement. sctx: Schema context where the definition is used. Returns: A tuple consisting of the definition statement ('grouping' or 'typedef') and schema context o...
[ "Find", "the", "statement", "defining", "a", "grouping", "or", "derived", "type", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L395-L434
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.is_derived_from
def is_derived_from(self, identity: QualName, base: QualName) -> bool: """Return ``True`` if `identity` is derived from `base`.""" try: bases = self.identity_adjs[identity].bases except KeyError: return False if base in bases: return True for i...
python
def is_derived_from(self, identity: QualName, base: QualName) -> bool: """Return ``True`` if `identity` is derived from `base`.""" try: bases = self.identity_adjs[identity].bases except KeyError: return False if base in bases: return True for i...
[ "def", "is_derived_from", "(", "self", ",", "identity", ":", "QualName", ",", "base", ":", "QualName", ")", "->", "bool", ":", "try", ":", "bases", "=", "self", ".", "identity_adjs", "[", "identity", "]", ".", "bases", "except", "KeyError", ":", "return"...
Return ``True`` if `identity` is derived from `base`.
[ "Return", "True", "if", "identity", "is", "derived", "from", "base", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L436-L447
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.derived_from
def derived_from(self, identity: QualName) -> MutableSet[QualName]: """Return list of identities transitively derived from `identity`.""" try: res = self.identity_adjs[identity].derivs except KeyError: return set() for id in res.copy(): res |= self.der...
python
def derived_from(self, identity: QualName) -> MutableSet[QualName]: """Return list of identities transitively derived from `identity`.""" try: res = self.identity_adjs[identity].derivs except KeyError: return set() for id in res.copy(): res |= self.der...
[ "def", "derived_from", "(", "self", ",", "identity", ":", "QualName", ")", "->", "MutableSet", "[", "QualName", "]", ":", "try", ":", "res", "=", "self", ".", "identity_adjs", "[", "identity", "]", ".", "derivs", "except", "KeyError", ":", "return", "set...
Return list of identities transitively derived from `identity`.
[ "Return", "list", "of", "identities", "transitively", "derived", "from", "identity", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L449-L457
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.derived_from_all
def derived_from_all(self, identities: List[QualName]) -> MutableSet[QualName]: """Return list of identities transitively derived from all `identity`.""" if not identities: return set() res = self.derived_from(identities[0]) for id in identities[1:]: res &= self.d...
python
def derived_from_all(self, identities: List[QualName]) -> MutableSet[QualName]: """Return list of identities transitively derived from all `identity`.""" if not identities: return set() res = self.derived_from(identities[0]) for id in identities[1:]: res &= self.d...
[ "def", "derived_from_all", "(", "self", ",", "identities", ":", "List", "[", "QualName", "]", ")", "->", "MutableSet", "[", "QualName", "]", ":", "if", "not", "identities", ":", "return", "set", "(", ")", "res", "=", "self", ".", "derived_from", "(", "...
Return list of identities transitively derived from all `identity`.
[ "Return", "list", "of", "identities", "transitively", "derived", "from", "all", "identity", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L459-L466
CZ-NIC/yangson
yangson/schemadata.py
SchemaData.if_features
def if_features(self, stmt: Statement, mid: ModuleId) -> bool: """Evaluate ``if-feature`` substatements on a statement, if any. Args: stmt: Yang statement that is tested on if-features. mid: Identifier of the module in which `stmt` is present. Raises: Module...
python
def if_features(self, stmt: Statement, mid: ModuleId) -> bool: """Evaluate ``if-feature`` substatements on a statement, if any. Args: stmt: Yang statement that is tested on if-features. mid: Identifier of the module in which `stmt` is present. Raises: Module...
[ "def", "if_features", "(", "self", ",", "stmt", ":", "Statement", ",", "mid", ":", "ModuleId", ")", "->", "bool", ":", "iffs", "=", "stmt", ".", "find_all", "(", "\"if-feature\"", ")", "if", "not", "iffs", ":", "return", "True", "for", "i", "in", "if...
Evaluate ``if-feature`` substatements on a statement, if any. Args: stmt: Yang statement that is tested on if-features. mid: Identifier of the module in which `stmt` is present. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. I...
[ "Evaluate", "if", "-", "feature", "substatements", "on", "a", "statement", "if", "any", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L468-L488
CZ-NIC/yangson
yangson/schemadata.py
FeatureExprParser.parse
def parse(self) -> bool: """Parse and evaluate a complete feature expression. Raises: InvalidFeatureExpression: If the if-feature expression is not syntactically correct. UnknownPrefix: If a prefix of a feature name is not declared. """ self.skip_...
python
def parse(self) -> bool: """Parse and evaluate a complete feature expression. Raises: InvalidFeatureExpression: If the if-feature expression is not syntactically correct. UnknownPrefix: If a prefix of a feature name is not declared. """ self.skip_...
[ "def", "parse", "(", "self", ")", "->", "bool", ":", "self", ".", "skip_ws", "(", ")", "res", "=", "self", ".", "_feature_disj", "(", ")", "self", ".", "skip_ws", "(", ")", "if", "not", "self", ".", "at_end", "(", ")", ":", "raise", "InvalidFeature...
Parse and evaluate a complete feature expression. Raises: InvalidFeatureExpression: If the if-feature expression is not syntactically correct. UnknownPrefix: If a prefix of a feature name is not declared.
[ "Parse", "and", "evaluate", "a", "complete", "feature", "expression", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L509-L522
CZ-NIC/yangson
yangson/parser.py
Parser.char
def char(self, c: str) -> None: """Parse the specified character. Args: c: One-character string. Raises: EndOfInput: If past the end of `self.input`. UnexpectedInput: If the next character is different from `c`. """ if self.peek() == c: ...
python
def char(self, c: str) -> None: """Parse the specified character. Args: c: One-character string. Raises: EndOfInput: If past the end of `self.input`. UnexpectedInput: If the next character is different from `c`. """ if self.peek() == c: ...
[ "def", "char", "(", "self", ",", "c", ":", "str", ")", "->", "None", ":", "if", "self", ".", "peek", "(", ")", "==", "c", ":", "self", ".", "offset", "+=", "1", "else", ":", "raise", "UnexpectedInput", "(", "self", ",", "f\"char '{c}'\"", ")" ]
Parse the specified character. Args: c: One-character string. Raises: EndOfInput: If past the end of `self.input`. UnexpectedInput: If the next character is different from `c`.
[ "Parse", "the", "specified", "character", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L83-L96
CZ-NIC/yangson
yangson/parser.py
Parser.dfa
def dfa(self, ttab: TransitionTable, init: int = 0) -> int: """Run a DFA and return the final (negative) state. Args: ttab: Transition table (with possible side-effects). init: Initial state. Raises: EndOfInput: If past the end of `self.input`. """ ...
python
def dfa(self, ttab: TransitionTable, init: int = 0) -> int: """Run a DFA and return the final (negative) state. Args: ttab: Transition table (with possible side-effects). init: Initial state. Raises: EndOfInput: If past the end of `self.input`. """ ...
[ "def", "dfa", "(", "self", ",", "ttab", ":", "TransitionTable", ",", "init", ":", "int", "=", "0", ")", "->", "int", ":", "state", "=", "init", "while", "True", ":", "disp", "=", "ttab", "[", "state", "]", "ch", "=", "self", ".", "peek", "(", "...
Run a DFA and return the final (negative) state. Args: ttab: Transition table (with possible side-effects). init: Initial state. Raises: EndOfInput: If past the end of `self.input`.
[ "Run", "a", "DFA", "and", "return", "the", "final", "(", "negative", ")", "state", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L98-L115
CZ-NIC/yangson
yangson/parser.py
Parser.line_column
def line_column(self) -> Tuple[int, int]: """Return line and column coordinates.""" ln = self.input.count("\n", 0, self.offset) c = (self.offset if ln == 0 else self.offset - self.input.rfind("\n", 0, self.offset) - 1) return (ln + 1, c)
python
def line_column(self) -> Tuple[int, int]: """Return line and column coordinates.""" ln = self.input.count("\n", 0, self.offset) c = (self.offset if ln == 0 else self.offset - self.input.rfind("\n", 0, self.offset) - 1) return (ln + 1, c)
[ "def", "line_column", "(", "self", ")", "->", "Tuple", "[", "int", ",", "int", "]", ":", "ln", "=", "self", ".", "input", ".", "count", "(", "\"\\n\"", ",", "0", ",", "self", ".", "offset", ")", "c", "=", "(", "self", ".", "offset", "if", "ln",...
Return line and column coordinates.
[ "Return", "line", "and", "column", "coordinates", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L117-L122
CZ-NIC/yangson
yangson/parser.py
Parser.match_regex
def match_regex(self, regex: Pattern, required: bool = False, meaning: str = "") -> str: """Parse input based on a regular expression . Args: regex: Compiled regular expression object. required: Should the exception be raised on unexpected input? ...
python
def match_regex(self, regex: Pattern, required: bool = False, meaning: str = "") -> str: """Parse input based on a regular expression . Args: regex: Compiled regular expression object. required: Should the exception be raised on unexpected input? ...
[ "def", "match_regex", "(", "self", ",", "regex", ":", "Pattern", ",", "required", ":", "bool", "=", "False", ",", "meaning", ":", "str", "=", "\"\"", ")", "->", "str", ":", "mo", "=", "regex", ".", "match", "(", "self", ".", "input", ",", "self", ...
Parse input based on a regular expression . Args: regex: Compiled regular expression object. required: Should the exception be raised on unexpected input? meaning: Meaning of `regex` (for use in error messages). Raises: UnexpectedInput: If no syntactical...
[ "Parse", "input", "based", "on", "a", "regular", "expression", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L124-L141
CZ-NIC/yangson
yangson/parser.py
Parser.one_of
def one_of(self, chset: str) -> str: """Parse one character form the specified set. Args: chset: string of characters to try as alternatives. Returns: The character that was actually matched. Raises: UnexpectedInput: If the next character is not in ...
python
def one_of(self, chset: str) -> str: """Parse one character form the specified set. Args: chset: string of characters to try as alternatives. Returns: The character that was actually matched. Raises: UnexpectedInput: If the next character is not in ...
[ "def", "one_of", "(", "self", ",", "chset", ":", "str", ")", "->", "str", ":", "res", "=", "self", ".", "peek", "(", ")", "if", "res", "in", "chset", ":", "self", ".", "offset", "+=", "1", "return", "res", "raise", "UnexpectedInput", "(", "self", ...
Parse one character form the specified set. Args: chset: string of characters to try as alternatives. Returns: The character that was actually matched. Raises: UnexpectedInput: If the next character is not in `chset`.
[ "Parse", "one", "character", "form", "the", "specified", "set", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L143-L159
CZ-NIC/yangson
yangson/parser.py
Parser.peek
def peek(self) -> str: """Return the next character without advancing offset. Raises: EndOfInput: If past the end of `self.input`. """ try: return self.input[self.offset] except IndexError: raise EndOfInput(self)
python
def peek(self) -> str: """Return the next character without advancing offset. Raises: EndOfInput: If past the end of `self.input`. """ try: return self.input[self.offset] except IndexError: raise EndOfInput(self)
[ "def", "peek", "(", "self", ")", "->", "str", ":", "try", ":", "return", "self", ".", "input", "[", "self", ".", "offset", "]", "except", "IndexError", ":", "raise", "EndOfInput", "(", "self", ")" ]
Return the next character without advancing offset. Raises: EndOfInput: If past the end of `self.input`.
[ "Return", "the", "next", "character", "without", "advancing", "offset", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L161-L170
CZ-NIC/yangson
yangson/parser.py
Parser.prefixed_name
def prefixed_name(self) -> Tuple[YangIdentifier, Optional[YangIdentifier]]: """Parse identifier with an optional colon-separated prefix.""" i1 = self.yang_identifier() try: next = self.peek() except EndOfInput: return (i1, None) if next != ":": ...
python
def prefixed_name(self) -> Tuple[YangIdentifier, Optional[YangIdentifier]]: """Parse identifier with an optional colon-separated prefix.""" i1 = self.yang_identifier() try: next = self.peek() except EndOfInput: return (i1, None) if next != ":": ...
[ "def", "prefixed_name", "(", "self", ")", "->", "Tuple", "[", "YangIdentifier", ",", "Optional", "[", "YangIdentifier", "]", "]", ":", "i1", "=", "self", ".", "yang_identifier", "(", ")", "try", ":", "next", "=", "self", ".", "peek", "(", ")", "except"...
Parse identifier with an optional colon-separated prefix.
[ "Parse", "identifier", "with", "an", "optional", "colon", "-", "separated", "prefix", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L172-L182
CZ-NIC/yangson
yangson/parser.py
Parser.remaining
def remaining(self) -> str: """Return the remaining part of the input string.""" res = self.input[self.offset:] self.offset = len(self.input) return res
python
def remaining(self) -> str: """Return the remaining part of the input string.""" res = self.input[self.offset:] self.offset = len(self.input) return res
[ "def", "remaining", "(", "self", ")", "->", "str", ":", "res", "=", "self", ".", "input", "[", "self", ".", "offset", ":", "]", "self", ".", "offset", "=", "len", "(", "self", ".", "input", ")", "return", "res" ]
Return the remaining part of the input string.
[ "Return", "the", "remaining", "part", "of", "the", "input", "string", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L184-L188
CZ-NIC/yangson
yangson/parser.py
Parser.up_to
def up_to(self, term: str) -> str: """Parse and return segment terminated by the first occurence of a string. Args: term: Terminating string. Raises: EndOfInput: If `term` does not occur in the rest of the input text. """ end = self.input.find(term, self...
python
def up_to(self, term: str) -> str: """Parse and return segment terminated by the first occurence of a string. Args: term: Terminating string. Raises: EndOfInput: If `term` does not occur in the rest of the input text. """ end = self.input.find(term, self...
[ "def", "up_to", "(", "self", ",", "term", ":", "str", ")", "->", "str", ":", "end", "=", "self", ".", "input", ".", "find", "(", "term", ",", "self", ".", "offset", ")", "if", "end", "<", "0", ":", "raise", "EndOfInput", "(", "self", ")", "res"...
Parse and return segment terminated by the first occurence of a string. Args: term: Terminating string. Raises: EndOfInput: If `term` does not occur in the rest of the input text.
[ "Parse", "and", "return", "segment", "terminated", "by", "the", "first", "occurence", "of", "a", "string", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/parser.py#L213-L227
CZ-NIC/yangson
yangson/constraint.py
Intervals.restrict_with
def restrict_with(self, expr: str, error_tag: str = None, error_message: str = None) -> None: """Combine the receiver with new intervals. Args: expr: "range" or "length" expression. error_tag: error tag of the new expression. error_message: erro...
python
def restrict_with(self, expr: str, error_tag: str = None, error_message: str = None) -> None: """Combine the receiver with new intervals. Args: expr: "range" or "length" expression. error_tag: error tag of the new expression. error_message: erro...
[ "def", "restrict_with", "(", "self", ",", "expr", ":", "str", ",", "error_tag", ":", "str", "=", "None", ",", "error_message", ":", "str", "=", "None", ")", "->", "None", ":", "def", "parse", "(", "x", ":", "str", ")", "->", "Number", ":", "res", ...
Combine the receiver with new intervals. Args: expr: "range" or "length" expression. error_tag: error tag of the new expression. error_message: error message for the new expression. Raises: InvalidArgument: If parsing of `expr` fails.
[ "Combine", "the", "receiver", "with", "new", "intervals", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/constraint.py#L84-L126
coin-or/GiMPy
src/gimpy/tree.py
Tree.add_root
def add_root(self, root, **attrs): ''' API: add_root(self, root, **attrs) Description: Adds root node to the tree with name root and returns root Node instance. Input: root: Root node name. attrs: Root node attributes. Post: ...
python
def add_root(self, root, **attrs): ''' API: add_root(self, root, **attrs) Description: Adds root node to the tree with name root and returns root Node instance. Input: root: Root node name. attrs: Root node attributes. Post: ...
[ "def", "add_root", "(", "self", ",", "root", ",", "*", "*", "attrs", ")", ":", "attrs", "[", "'level'", "]", "=", "0", "self", ".", "root", "=", "self", ".", "add_node", "(", "root", ",", "*", "*", "attrs", ")", "return", "self", ".", "root" ]
API: add_root(self, root, **attrs) Description: Adds root node to the tree with name root and returns root Node instance. Input: root: Root node name. attrs: Root node attributes. Post: Changes self.root. Return: Ret...
[ "API", ":", "add_root", "(", "self", "root", "**", "attrs", ")", "Description", ":", "Adds", "root", "node", "to", "the", "tree", "with", "name", "root", "and", "returns", "root", "Node", "instance", ".", "Input", ":", "root", ":", "Root", "node", "nam...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L66-L82
coin-or/GiMPy
src/gimpy/tree.py
Tree.add_child
def add_child(self, n, parent, **attrs): ''' API: add_child(self, n, parent, **attrs) Description: Adds child n to node parent and return Node n. Pre: Node with name parent should exist. Input: n: Child node name. parent: Parent nod...
python
def add_child(self, n, parent, **attrs): ''' API: add_child(self, n, parent, **attrs) Description: Adds child n to node parent and return Node n. Pre: Node with name parent should exist. Input: n: Child node name. parent: Parent nod...
[ "def", "add_child", "(", "self", ",", "n", ",", "parent", ",", "*", "*", "attrs", ")", ":", "attrs", "[", "'level'", "]", "=", "self", ".", "get_node", "(", "parent", ")", ".", "get_attr", "(", "'level'", ")", "+", "1", "attrs", "[", "'parent'", ...
API: add_child(self, n, parent, **attrs) Description: Adds child n to node parent and return Node n. Pre: Node with name parent should exist. Input: n: Child node name. parent: Parent node name. attrs: Attributes of node being added. ...
[ "API", ":", "add_child", "(", "self", "n", "parent", "**", "attrs", ")", "Description", ":", "Adds", "child", "n", "to", "node", "parent", "and", "return", "Node", "n", ".", "Pre", ":", "Node", "with", "name", "parent", "should", "exist", ".", "Input",...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L84-L104
coin-or/GiMPy
src/gimpy/tree.py
Tree.dfs
def dfs(self, root = None, display = None): ''' API: dfs(self, root = None, display = None) Description: Searches tree starting from node named root using depth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. ...
python
def dfs(self, root = None, display = None): ''' API: dfs(self, root = None, display = None) Description: Searches tree starting from node named root using depth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. ...
[ "def", "dfs", "(", "self", ",", "root", "=", "None", ",", "display", "=", "None", ")", ":", "if", "root", "==", "None", ":", "root", "=", "self", ".", "root", "if", "display", "==", "None", ":", "display", "=", "self", ".", "attr", "[", "'display...
API: dfs(self, root = None, display = None) Description: Searches tree starting from node named root using depth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. Pre: Node indicated by root argument should ex...
[ "API", ":", "dfs", "(", "self", "root", "=", "None", "display", "=", "None", ")", "Description", ":", "Searches", "tree", "starting", "from", "node", "named", "root", "using", "depth", "-", "first", "strategy", "if", "root", "argument", "is", "provided", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L106-L123
coin-or/GiMPy
src/gimpy/tree.py
Tree.bfs
def bfs(self, root = None, display = None): ''' API: bfs(self, root = None, display = None) Description: Searches tree starting from node named root using breadth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. ...
python
def bfs(self, root = None, display = None): ''' API: bfs(self, root = None, display = None) Description: Searches tree starting from node named root using breadth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. ...
[ "def", "bfs", "(", "self", ",", "root", "=", "None", ",", "display", "=", "None", ")", ":", "if", "root", "==", "None", ":", "root", "=", "self", ".", "root", "if", "display", "==", "None", ":", "display", "=", "self", ".", "attr", "[", "'display...
API: bfs(self, root = None, display = None) Description: Searches tree starting from node named root using breadth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. Pre: Node indicated by root argument should ...
[ "API", ":", "bfs", "(", "self", "root", "=", "None", "display", "=", "None", ")", "Description", ":", "Searches", "tree", "starting", "from", "node", "named", "root", "using", "breadth", "-", "first", "strategy", "if", "root", "argument", "is", "provided",...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L125-L142
coin-or/GiMPy
src/gimpy/tree.py
Tree.traverse
def traverse(self, root = None, display = None, q = Stack()): ''' API: traverse(self, root = None, display = None, q = Stack()) Description: Traverses tree starting from node named root. Used strategy (BFS, DFS) is controlled by argument q. It is a DFS if q is Queue(), BF...
python
def traverse(self, root = None, display = None, q = Stack()): ''' API: traverse(self, root = None, display = None, q = Stack()) Description: Traverses tree starting from node named root. Used strategy (BFS, DFS) is controlled by argument q. It is a DFS if q is Queue(), BF...
[ "def", "traverse", "(", "self", ",", "root", "=", "None", ",", "display", "=", "None", ",", "q", "=", "Stack", "(", ")", ")", ":", "if", "root", "==", "None", ":", "root", "=", "self", ".", "root", "if", "display", "==", "None", ":", "display", ...
API: traverse(self, root = None, display = None, q = Stack()) Description: Traverses tree starting from node named root. Used strategy (BFS, DFS) is controlled by argument q. It is a DFS if q is Queue(), BFS if q is Stack(). Starts search from root argument if it is given. ...
[ "API", ":", "traverse", "(", "self", "root", "=", "None", "display", "=", "None", "q", "=", "Stack", "()", ")", "Description", ":", "Traverses", "tree", "starting", "from", "node", "named", "root", ".", "Used", "strategy", "(", "BFS", "DFS", ")", "is",...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L144-L177
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.add_right_child
def add_right_child(self, n, parent, **attrs): ''' API: add_right_child(self, n, parent, **attrs) Description: Adds right child n to node parent. Pre: Right child of parent should not exist. Input: n: Node name. parent: Parent node ...
python
def add_right_child(self, n, parent, **attrs): ''' API: add_right_child(self, n, parent, **attrs) Description: Adds right child n to node parent. Pre: Right child of parent should not exist. Input: n: Node name. parent: Parent node ...
[ "def", "add_right_child", "(", "self", ",", "n", ",", "parent", ",", "*", "*", "attrs", ")", ":", "if", "self", ".", "get_right_child", "(", "parent", ")", "is", "not", "None", ":", "msg", "=", "\"Right child already exists for node \"", "+", "str", "(", ...
API: add_right_child(self, n, parent, **attrs) Description: Adds right child n to node parent. Pre: Right child of parent should not exist. Input: n: Node name. parent: Parent node name. attrs: Attributes of node n.
[ "API", ":", "add_right_child", "(", "self", "n", "parent", "**", "attrs", ")", "Description", ":", "Adds", "right", "child", "n", "to", "node", "parent", ".", "Pre", ":", "Right", "child", "of", "parent", "should", "not", "exist", ".", "Input", ":", "n...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L209-L226
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.add_left_child
def add_left_child(self, n, parent, **attrs): ''' API: add_left_child(self, n, parent, **attrs) Description: Adds left child n to node parent. Pre: Left child of parent should not exist. Input: n: Node name. parent: Parent node name...
python
def add_left_child(self, n, parent, **attrs): ''' API: add_left_child(self, n, parent, **attrs) Description: Adds left child n to node parent. Pre: Left child of parent should not exist. Input: n: Node name. parent: Parent node name...
[ "def", "add_left_child", "(", "self", ",", "n", ",", "parent", ",", "*", "*", "attrs", ")", ":", "if", "self", ".", "get_left_child", "(", "parent", ")", "is", "not", "None", ":", "msg", "=", "\"Right child already exists for node \"", "+", "str", "(", "...
API: add_left_child(self, n, parent, **attrs) Description: Adds left child n to node parent. Pre: Left child of parent should not exist. Input: n: Node name. parent: Parent node name. attrs: Attributes of node n.
[ "API", ":", "add_left_child", "(", "self", "n", "parent", "**", "attrs", ")", "Description", ":", "Adds", "left", "child", "n", "to", "node", "parent", ".", "Pre", ":", "Left", "child", "of", "parent", "should", "not", "exist", ".", "Input", ":", "n", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L228-L245
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.get_right_child
def get_right_child(self, n): ''' API: get_right_child(self, n) Description: Returns right child of node n. n can be Node() instance or string (name of node). Pre: Node n should be present in the tree. Input: n: Node name or Node() ...
python
def get_right_child(self, n): ''' API: get_right_child(self, n) Description: Returns right child of node n. n can be Node() instance or string (name of node). Pre: Node n should be present in the tree. Input: n: Node name or Node() ...
[ "def", "get_right_child", "(", "self", ",", "n", ")", ":", "if", "isinstance", "(", "n", ",", "Node", ")", ":", "return", "n", ".", "get_attr", "(", "'Rchild'", ")", "return", "self", ".", "get_node_attr", "(", "n", ",", "'Rchild'", ")" ]
API: get_right_child(self, n) Description: Returns right child of node n. n can be Node() instance or string (name of node). Pre: Node n should be present in the tree. Input: n: Node name or Node() instance. Return: Returns name...
[ "API", ":", "get_right_child", "(", "self", "n", ")", "Description", ":", "Returns", "right", "child", "of", "node", "n", ".", "n", "can", "be", "Node", "()", "instance", "or", "string", "(", "name", "of", "node", ")", ".", "Pre", ":", "Node", "n", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L247-L262
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.get_left_child
def get_left_child(self, n): ''' API: get_left_child(self, n) Description: Returns left child of node n. n can be Node() instance or string (name of node). Pre: Node n should be present in the tree. Input: n: Node name or Node() ins...
python
def get_left_child(self, n): ''' API: get_left_child(self, n) Description: Returns left child of node n. n can be Node() instance or string (name of node). Pre: Node n should be present in the tree. Input: n: Node name or Node() ins...
[ "def", "get_left_child", "(", "self", ",", "n", ")", ":", "if", "isinstance", "(", "n", ",", "Node", ")", ":", "return", "n", ".", "get_attr", "(", "'Lchild'", ")", "return", "self", ".", "get_node_attr", "(", "n", ",", "'Lchild'", ")" ]
API: get_left_child(self, n) Description: Returns left child of node n. n can be Node() instance or string (name of node). Pre: Node n should be present in the tree. Input: n: Node name or Node() instance. Return: Returns name o...
[ "API", ":", "get_left_child", "(", "self", "n", ")", "Description", ":", "Returns", "left", "child", "of", "node", "n", ".", "n", "can", "be", "Node", "()", "instance", "or", "string", "(", "name", "of", "node", ")", ".", "Pre", ":", "Node", "n", "...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L264-L279
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.del_node
def del_node(self, n): ''' API: del_node(self, n) Description: Removes node n from tree. Pre: Node n should be present in the tree. Input: n: Node name. ''' parent = self.get_node_attr(n, 'parent') if self.get_node_attr(...
python
def del_node(self, n): ''' API: del_node(self, n) Description: Removes node n from tree. Pre: Node n should be present in the tree. Input: n: Node name. ''' parent = self.get_node_attr(n, 'parent') if self.get_node_attr(...
[ "def", "del_node", "(", "self", ",", "n", ")", ":", "parent", "=", "self", ".", "get_node_attr", "(", "n", ",", "'parent'", ")", "if", "self", ".", "get_node_attr", "(", "n", ",", "'direction'", ")", "==", "'R'", ":", "self", ".", "set_node_attr", "(...
API: del_node(self, n) Description: Removes node n from tree. Pre: Node n should be present in the tree. Input: n: Node name.
[ "API", ":", "del_node", "(", "self", "n", ")", "Description", ":", "Removes", "node", "n", "from", "tree", ".", "Pre", ":", "Node", "n", "should", "be", "present", "in", "the", "tree", ".", "Input", ":", "n", ":", "Node", "name", "." ]
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L281-L296
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.print_nodes
def print_nodes(self, order = 'in', priority = 'L', display = None, root = None): ''' API: print_nodes(self, order = 'in', priority = 'L', display = None, root = None) Description: A recursive function that prints nodes to stdout starting from ...
python
def print_nodes(self, order = 'in', priority = 'L', display = None, root = None): ''' API: print_nodes(self, order = 'in', priority = 'L', display = None, root = None) Description: A recursive function that prints nodes to stdout starting from ...
[ "def", "print_nodes", "(", "self", ",", "order", "=", "'in'", ",", "priority", "=", "'L'", ",", "display", "=", "None", ",", "root", "=", "None", ")", ":", "old_display", "=", "None", "if", "root", "==", "None", ":", "root", "=", "self", ".", "root...
API: print_nodes(self, order = 'in', priority = 'L', display = None, root = None) Description: A recursive function that prints nodes to stdout starting from root. Input: order: Order of printing. Acceptable arguments are 'pre', 'in', '...
[ "API", ":", "print_nodes", "(", "self", "order", "=", "in", "priority", "=", "L", "display", "=", "None", "root", "=", "None", ")", "Description", ":", "A", "recursive", "function", "that", "prints", "nodes", "to", "stdout", "starting", "from", "root", "...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L298-L345
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.dfs
def dfs(self, root = None, display = None, priority = 'L'): ''' API: dfs(self, root=None, display=None, priority='L', order='in') Description: Searches tree starting from node named root using depth-first strategy if root argument is provided. Starts search from root node...
python
def dfs(self, root = None, display = None, priority = 'L'): ''' API: dfs(self, root=None, display=None, priority='L', order='in') Description: Searches tree starting from node named root using depth-first strategy if root argument is provided. Starts search from root node...
[ "def", "dfs", "(", "self", ",", "root", "=", "None", ",", "display", "=", "None", ",", "priority", "=", "'L'", ")", ":", "if", "root", "==", "None", ":", "root", "=", "self", ".", "root", "self", ".", "traverse", "(", "root", ",", "display", ",",...
API: dfs(self, root=None, display=None, priority='L', order='in') Description: Searches tree starting from node named root using depth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. Input: root: Starting no...
[ "API", ":", "dfs", "(", "self", "root", "=", "None", "display", "=", "None", "priority", "=", "L", "order", "=", "in", ")", "Description", ":", "Searches", "tree", "starting", "from", "node", "named", "root", "using", "depth", "-", "first", "strategy", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L347-L362
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.bfs
def bfs(self, root = None, display = None, priority = 'L'): ''' API: bfs(self, root=None, display=None, priority='L', order='in') Description: Searches tree starting from node named root using breadth-first strategy if root argument is provided. Starts search from root no...
python
def bfs(self, root = None, display = None, priority = 'L'): ''' API: bfs(self, root=None, display=None, priority='L', order='in') Description: Searches tree starting from node named root using breadth-first strategy if root argument is provided. Starts search from root no...
[ "def", "bfs", "(", "self", ",", "root", "=", "None", ",", "display", "=", "None", ",", "priority", "=", "'L'", ")", ":", "if", "root", "==", "None", ":", "root", "=", "self", ".", "root", "self", ".", "traverse", "(", "root", ",", "display", ",",...
API: bfs(self, root=None, display=None, priority='L', order='in') Description: Searches tree starting from node named root using breadth-first strategy if root argument is provided. Starts search from root node of the tree otherwise. Input: root: Starting ...
[ "API", ":", "bfs", "(", "self", "root", "=", "None", "display", "=", "None", "priority", "=", "L", "order", "=", "in", ")", "Description", ":", "Searches", "tree", "starting", "from", "node", "named", "root", "using", "breadth", "-", "first", "strategy",...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L364-L379
coin-or/GiMPy
src/gimpy/tree.py
BinaryTree.traverse
def traverse(self, root = None, display = None, q = Stack(), priority = 'L'): ''' API: traverse(self, root=None, display=None, q=Stack(), priority='L', order='in') Description: Traverses tree starting from node named root if root argument is ...
python
def traverse(self, root = None, display = None, q = Stack(), priority = 'L'): ''' API: traverse(self, root=None, display=None, q=Stack(), priority='L', order='in') Description: Traverses tree starting from node named root if root argument is ...
[ "def", "traverse", "(", "self", ",", "root", "=", "None", ",", "display", "=", "None", ",", "q", "=", "Stack", "(", ")", ",", "priority", "=", "'L'", ")", ":", "old_display", "=", "None", "if", "root", "==", "None", ":", "root", "=", "self", ".",...
API: traverse(self, root=None, display=None, q=Stack(), priority='L', order='in') Description: Traverses tree starting from node named root if root argument is provided. Starts search from root node of the tree otherwise. Search strategy is determined by...
[ "API", ":", "traverse", "(", "self", "root", "=", "None", "display", "=", "None", "q", "=", "Stack", "()", "priority", "=", "L", "order", "=", "in", ")", "Description", ":", "Traverses", "tree", "starting", "from", "node", "named", "root", "if", "root"...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/tree.py#L381-L431
CZ-NIC/yangson
tools/python/mkylib.py
module_entry
def module_entry(yfile): """Add entry for one file containing YANG module text. Args: yfile (file): File containing a YANG module or submodule. """ ytxt = yfile.read() mp = ModuleParser(ytxt) mst = mp.statement() submod = mst.keyword == "submodule" import_only = True rev = "...
python
def module_entry(yfile): """Add entry for one file containing YANG module text. Args: yfile (file): File containing a YANG module or submodule. """ ytxt = yfile.read() mp = ModuleParser(ytxt) mst = mp.statement() submod = mst.keyword == "submodule" import_only = True rev = "...
[ "def", "module_entry", "(", "yfile", ")", ":", "ytxt", "=", "yfile", ".", "read", "(", ")", "mp", "=", "ModuleParser", "(", "ytxt", ")", "mst", "=", "mp", ".", "statement", "(", ")", "submod", "=", "mst", ".", "keyword", "==", "\"submodule\"", "impor...
Add entry for one file containing YANG module text. Args: yfile (file): File containing a YANG module or submodule.
[ "Add", "entry", "for", "one", "file", "containing", "YANG", "module", "text", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/tools/python/mkylib.py#L27-L63
CZ-NIC/yangson
yangson/schpattern.py
ConditionalPattern.nullable
def nullable(self, ctype: ContentType) -> bool: """Override the superclass method.""" return (not self.check_when() or self.pattern.nullable(ctype))
python
def nullable(self, ctype: ContentType) -> bool: """Override the superclass method.""" return (not self.check_when() or self.pattern.nullable(ctype))
[ "def", "nullable", "(", "self", ",", "ctype", ":", "ContentType", ")", "->", "bool", ":", "return", "(", "not", "self", ".", "check_when", "(", ")", "or", "self", ".", "pattern", ".", "nullable", "(", "ctype", ")", ")" ]
Override the superclass method.
[ "Override", "the", "superclass", "method", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schpattern.py#L138-L140
CZ-NIC/yangson
yangson/schpattern.py
ConditionalPattern.deriv
def deriv(self, x: str, ctype: ContentType) -> SchemaPattern: """Return derivative of the receiver.""" return (self.pattern.deriv(x, ctype) if self.check_when() else NotAllowed())
python
def deriv(self, x: str, ctype: ContentType) -> SchemaPattern: """Return derivative of the receiver.""" return (self.pattern.deriv(x, ctype) if self.check_when() else NotAllowed())
[ "def", "deriv", "(", "self", ",", "x", ":", "str", ",", "ctype", ":", "ContentType", ")", "->", "SchemaPattern", ":", "return", "(", "self", ".", "pattern", ".", "deriv", "(", "x", ",", "ctype", ")", "if", "self", ".", "check_when", "(", ")", "else...
Return derivative of the receiver.
[ "Return", "derivative", "of", "the", "receiver", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schpattern.py#L142-L145
CZ-NIC/yangson
yangson/schpattern.py
Member.deriv
def deriv(self, x: str, ctype: ContentType) -> SchemaPattern: """Return derivative of the receiver.""" return (Empty() if self.name == x and self._active(ctype) else NotAllowed())
python
def deriv(self, x: str, ctype: ContentType) -> SchemaPattern: """Return derivative of the receiver.""" return (Empty() if self.name == x and self._active(ctype) else NotAllowed())
[ "def", "deriv", "(", "self", ",", "x", ":", "str", ",", "ctype", ":", "ContentType", ")", "->", "SchemaPattern", ":", "return", "(", "Empty", "(", ")", "if", "self", ".", "name", "==", "x", "and", "self", ".", "_active", "(", "ctype", ")", "else", ...
Return derivative of the receiver.
[ "Return", "derivative", "of", "the", "receiver", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schpattern.py#L175-L179
CZ-NIC/yangson
yangson/schpattern.py
Alternative.nullable
def nullable(self, ctype: ContentType) -> bool: """Override the superclass method.""" return self.left.nullable(ctype) or self.right.nullable(ctype)
python
def nullable(self, ctype: ContentType) -> bool: """Override the superclass method.""" return self.left.nullable(ctype) or self.right.nullable(ctype)
[ "def", "nullable", "(", "self", ",", "ctype", ":", "ContentType", ")", "->", "bool", ":", "return", "self", ".", "left", ".", "nullable", "(", "ctype", ")", "or", "self", ".", "right", ".", "nullable", "(", "ctype", ")" ]
Override the superclass method.
[ "Override", "the", "superclass", "method", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schpattern.py#L210-L212
CZ-NIC/yangson
yangson/schpattern.py
Alternative.deriv
def deriv(self, x: str, ctype: ContentType) -> SchemaPattern: """Return derivative of the receiver.""" return Alternative.combine(self.left.deriv(x, ctype), self.right.deriv(x, ctype))
python
def deriv(self, x: str, ctype: ContentType) -> SchemaPattern: """Return derivative of the receiver.""" return Alternative.combine(self.left.deriv(x, ctype), self.right.deriv(x, ctype))
[ "def", "deriv", "(", "self", ",", "x", ":", "str", ",", "ctype", ":", "ContentType", ")", "->", "SchemaPattern", ":", "return", "Alternative", ".", "combine", "(", "self", ".", "left", ".", "deriv", "(", "x", ",", "ctype", ")", ",", "self", ".", "r...
Return derivative of the receiver.
[ "Return", "derivative", "of", "the", "receiver", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schpattern.py#L214-L217
CZ-NIC/yangson
yangson/datamodel.py
DataModel.from_file
def from_file(cls, name: str, mod_path: Tuple[str] = (".",), description: str = None) -> "DataModel": """Initialize the data model from a file with YANG library data. Args: name: Name of a file with YANG library data. mod_path: Tuple of directories where to loo...
python
def from_file(cls, name: str, mod_path: Tuple[str] = (".",), description: str = None) -> "DataModel": """Initialize the data model from a file with YANG library data. Args: name: Name of a file with YANG library data. mod_path: Tuple of directories where to loo...
[ "def", "from_file", "(", "cls", ",", "name", ":", "str", ",", "mod_path", ":", "Tuple", "[", "str", "]", "=", "(", "\".\"", ",", ")", ",", "description", ":", "str", "=", "None", ")", "->", "\"DataModel\"", ":", "with", "open", "(", "name", ",", ...
Initialize the data model from a file with YANG library data. Args: name: Name of a file with YANG library data. mod_path: Tuple of directories where to look for YANG modules. description: Optional description of the data model. Returns: The data model ...
[ "Initialize", "the", "data", "model", "from", "a", "file", "with", "YANG", "library", "data", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L41-L58
CZ-NIC/yangson
yangson/datamodel.py
DataModel.module_set_id
def module_set_id(self) -> str: """Compute unique id of YANG modules comprising the data model. Returns: String consisting of hexadecimal digits. """ fnames = sorted(["@".join(m) for m in self.schema_data.modules]) return hashlib.sha1("".join(fnames).encode("ascii"))...
python
def module_set_id(self) -> str: """Compute unique id of YANG modules comprising the data model. Returns: String consisting of hexadecimal digits. """ fnames = sorted(["@".join(m) for m in self.schema_data.modules]) return hashlib.sha1("".join(fnames).encode("ascii"))...
[ "def", "module_set_id", "(", "self", ")", "->", "str", ":", "fnames", "=", "sorted", "(", "[", "\"@\"", ".", "join", "(", "m", ")", "for", "m", "in", "self", ".", "schema_data", ".", "modules", "]", ")", "return", "hashlib", ".", "sha1", "(", "\"\"...
Compute unique id of YANG modules comprising the data model. Returns: String consisting of hexadecimal digits.
[ "Compute", "unique", "id", "of", "YANG", "modules", "comprising", "the", "data", "model", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L91-L98
CZ-NIC/yangson
yangson/datamodel.py
DataModel.from_raw
def from_raw(self, robj: RawObject) -> RootNode: """Create an instance node from a raw data tree. Args: robj: Dictionary representing a raw data tree. Returns: Root instance node. """ cooked = self.schema.from_raw(robj) return RootNode(cooked, se...
python
def from_raw(self, robj: RawObject) -> RootNode: """Create an instance node from a raw data tree. Args: robj: Dictionary representing a raw data tree. Returns: Root instance node. """ cooked = self.schema.from_raw(robj) return RootNode(cooked, se...
[ "def", "from_raw", "(", "self", ",", "robj", ":", "RawObject", ")", "->", "RootNode", ":", "cooked", "=", "self", ".", "schema", ".", "from_raw", "(", "robj", ")", "return", "RootNode", "(", "cooked", ",", "self", ".", "schema", ",", "cooked", ".", "...
Create an instance node from a raw data tree. Args: robj: Dictionary representing a raw data tree. Returns: Root instance node.
[ "Create", "an", "instance", "node", "from", "a", "raw", "data", "tree", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L100-L110
CZ-NIC/yangson
yangson/datamodel.py
DataModel.get_schema_node
def get_schema_node(self, path: SchemaPath) -> Optional[SchemaNode]: """Return the schema node addressed by a schema path. Args: path: Schema path. Returns: Schema node if found in the schema, or ``None``. Raises: InvalidSchemaPath: If the schema pa...
python
def get_schema_node(self, path: SchemaPath) -> Optional[SchemaNode]: """Return the schema node addressed by a schema path. Args: path: Schema path. Returns: Schema node if found in the schema, or ``None``. Raises: InvalidSchemaPath: If the schema pa...
[ "def", "get_schema_node", "(", "self", ",", "path", ":", "SchemaPath", ")", "->", "Optional", "[", "SchemaNode", "]", ":", "return", "self", ".", "schema", ".", "get_schema_descendant", "(", "self", ".", "schema_data", ".", "path2route", "(", "path", ")", ...
Return the schema node addressed by a schema path. Args: path: Schema path. Returns: Schema node if found in the schema, or ``None``. Raises: InvalidSchemaPath: If the schema path is invalid.
[ "Return", "the", "schema", "node", "addressed", "by", "a", "schema", "path", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L112-L125
CZ-NIC/yangson
yangson/datamodel.py
DataModel.get_data_node
def get_data_node(self, path: DataPath) -> Optional[DataNode]: """Return the data node addressed by a data path. Args: path: Data path. Returns: Data node if found in the schema, or ``None``. Raises: InvalidSchemaPath: If the schema path is invalid....
python
def get_data_node(self, path: DataPath) -> Optional[DataNode]: """Return the data node addressed by a data path. Args: path: Data path. Returns: Data node if found in the schema, or ``None``. Raises: InvalidSchemaPath: If the schema path is invalid....
[ "def", "get_data_node", "(", "self", ",", "path", ":", "DataPath", ")", "->", "Optional", "[", "DataNode", "]", ":", "addr", "=", "self", ".", "schema_data", ".", "path2route", "(", "path", ")", "node", "=", "self", ".", "schema", "for", "p", "in", "...
Return the data node addressed by a data path. Args: path: Data path. Returns: Data node if found in the schema, or ``None``. Raises: InvalidSchemaPath: If the schema path is invalid.
[ "Return", "the", "data", "node", "addressed", "by", "a", "data", "path", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L127-L145
CZ-NIC/yangson
yangson/datamodel.py
DataModel.ascii_tree
def ascii_tree(self, no_types: bool = False, val_count: bool = False) -> str: """Generate ASCII art representation of the schema tree. Args: no_types: Suppress output of data type info. val_count: Show accumulated validation counts. Returns: String with the ...
python
def ascii_tree(self, no_types: bool = False, val_count: bool = False) -> str: """Generate ASCII art representation of the schema tree. Args: no_types: Suppress output of data type info. val_count: Show accumulated validation counts. Returns: String with the ...
[ "def", "ascii_tree", "(", "self", ",", "no_types", ":", "bool", "=", "False", ",", "val_count", ":", "bool", "=", "False", ")", "->", "str", ":", "return", "self", ".", "schema", ".", "_ascii_tree", "(", "\"\"", ",", "no_types", ",", "val_count", ")" ]
Generate ASCII art representation of the schema tree. Args: no_types: Suppress output of data type info. val_count: Show accumulated validation counts. Returns: String with the ASCII tree.
[ "Generate", "ASCII", "art", "representation", "of", "the", "schema", "tree", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L147-L157
CZ-NIC/yangson
yangson/datamodel.py
DataModel.schema_digest
def schema_digest(self) -> str: """Generate schema digest (to be used primarily by clients). Returns: Condensed information about the schema in JSON format. """ res = self.schema._node_digest() res["config"] = True return json.dumps(res)
python
def schema_digest(self) -> str: """Generate schema digest (to be used primarily by clients). Returns: Condensed information about the schema in JSON format. """ res = self.schema._node_digest() res["config"] = True return json.dumps(res)
[ "def", "schema_digest", "(", "self", ")", "->", "str", ":", "res", "=", "self", ".", "schema", ".", "_node_digest", "(", ")", "res", "[", "\"config\"", "]", "=", "True", "return", "json", ".", "dumps", "(", "res", ")" ]
Generate schema digest (to be used primarily by clients). Returns: Condensed information about the schema in JSON format.
[ "Generate", "schema", "digest", "(", "to", "be", "used", "primarily", "by", "clients", ")", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datamodel.py#L169-L177
CZ-NIC/yangson
yangson/xpathparser.py
XPathParser._qname
def _qname(self) -> Optional[QualName]: """Parse XML QName.""" if self.test_string("*"): self.skip_ws() return False ident = self.yang_identifier() ws = self.skip_ws() try: next = self.peek() except EndOfInput: return ident,...
python
def _qname(self) -> Optional[QualName]: """Parse XML QName.""" if self.test_string("*"): self.skip_ws() return False ident = self.yang_identifier() ws = self.skip_ws() try: next = self.peek() except EndOfInput: return ident,...
[ "def", "_qname", "(", "self", ")", "->", "Optional", "[", "QualName", "]", ":", "if", "self", ".", "test_string", "(", "\"*\"", ")", ":", "self", ".", "skip_ws", "(", ")", "return", "False", "ident", "=", "self", ".", "yang_identifier", "(", ")", "ws...
Parse XML QName.
[ "Parse", "XML", "QName", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/xpathparser.py#L303-L323
coin-or/GiMPy
src/gimpy/global_constants.py
needs_quotes
def needs_quotes(s): """Checks whether a string is a dot language ID. It will check whether the string is solely composed by the characters allowed in an ID or not. If the string is one of the reserved keywords it will need quotes too but the user will need to add them manually. """ # If...
python
def needs_quotes(s): """Checks whether a string is a dot language ID. It will check whether the string is solely composed by the characters allowed in an ID or not. If the string is one of the reserved keywords it will need quotes too but the user will need to add them manually. """ # If...
[ "def", "needs_quotes", "(", "s", ")", ":", "# If the name is a reserved keyword it will need quotes but pydot", "# can't tell when it's being used as a keyword or when it's simply", "# a name. Hence the user needs to supply the quotes when an element", "# would use a reserved keyword as name. This...
Checks whether a string is a dot language ID. It will check whether the string is solely composed by the characters allowed in an ID or not. If the string is one of the reserved keywords it will need quotes too but the user will need to add them manually.
[ "Checks", "whether", "a", "string", "is", "a", "dot", "language", "ID", ".", "It", "will", "check", "whether", "the", "string", "is", "solely", "composed", "by", "the", "characters", "allowed", "in", "an", "ID", "or", "not", ".", "If", "the", "string", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/global_constants.py#L147-L172
CZ-NIC/yangson
yangson/__main__.py
main
def main(ylib: str = None, path: str = None, scope: ValidationScope = ValidationScope.all, ctype: ContentType = ContentType.config, set_id: bool = False, tree: bool = False, no_types: bool = False, digest: bool = False, validate: str = None) -> int: """Entry-point for a validatio...
python
def main(ylib: str = None, path: str = None, scope: ValidationScope = ValidationScope.all, ctype: ContentType = ContentType.config, set_id: bool = False, tree: bool = False, no_types: bool = False, digest: bool = False, validate: str = None) -> int: """Entry-point for a validatio...
[ "def", "main", "(", "ylib", ":", "str", "=", "None", ",", "path", ":", "str", "=", "None", ",", "scope", ":", "ValidationScope", "=", "ValidationScope", ".", "all", ",", "ctype", ":", "ContentType", "=", "ContentType", ".", "config", ",", "set_id", ":"...
Entry-point for a validation script. Args: ylib: Name of the file with YANG library path: Colon-separated list of directories to search for YANG modules. scope: Validation scope (syntax, semantics or all). ctype: Content type of the data instance (config, nonconfig or all) ...
[ "Entry", "-", "point", "for", "a", "validation", "script", "." ]
train
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/__main__.py#L34-L165
coin-or/GiMPy
src/gimpy/graph.py
Node.to_string
def to_string(self): ''' API: to_string(self) Description: Returns string representation of node in dot language. Return: String representation of node. ''' node = list() node.append(quote_if_necessary(str(self.name))) node.append(' [')...
python
def to_string(self): ''' API: to_string(self) Description: Returns string representation of node in dot language. Return: String representation of node. ''' node = list() node.append(quote_if_necessary(str(self.name))) node.append(' [')...
[ "def", "to_string", "(", "self", ")", ":", "node", "=", "list", "(", ")", "node", ".", "append", "(", "quote_if_necessary", "(", "str", "(", "self", ".", "name", ")", ")", ")", "node", ".", "append", "(", "' ['", ")", "flag", "=", "False", "for", ...
API: to_string(self) Description: Returns string representation of node in dot language. Return: String representation of node.
[ "API", ":", "to_string", "(", "self", ")", "Description", ":", "Returns", "string", "representation", "of", "node", "in", "dot", "language", ".", "Return", ":", "String", "representation", "of", "node", "." ]
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L160-L181
coin-or/GiMPy
src/gimpy/graph.py
Graph.add_node
def add_node(self, name, **attr): ''' API: add_node(self, name, **attr) Description: Adds node to the graph. Pre: Graph should not contain a node with this name. We do not allow multiple nodes with the same name. Input: name: Name of th...
python
def add_node(self, name, **attr): ''' API: add_node(self, name, **attr) Description: Adds node to the graph. Pre: Graph should not contain a node with this name. We do not allow multiple nodes with the same name. Input: name: Name of th...
[ "def", "add_node", "(", "self", ",", "name", ",", "*", "*", "attr", ")", ":", "if", "name", "in", "self", ".", "neighbors", ":", "raise", "MultipleNodeException", "self", ".", "neighbors", "[", "name", "]", "=", "list", "(", ")", "if", "self", ".", ...
API: add_node(self, name, **attr) Description: Adds node to the graph. Pre: Graph should not contain a node with this name. We do not allow multiple nodes with the same name. Input: name: Name of the node. attr: Node attributes. Pos...
[ "API", ":", "add_node", "(", "self", "name", "**", "attr", ")", "Description", ":", "Adds", "node", "to", "the", "graph", ".", "Pre", ":", "Graph", "should", "not", "contain", "a", "node", "with", "this", "name", ".", "We", "do", "not", "allow", "mul...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L286-L308
coin-or/GiMPy
src/gimpy/graph.py
Graph.del_node
def del_node(self, name): ''' API: del_node(self, name) Description: Removes node from Graph. Input: name: Name of the node. Pre: Graph should contain a node with this name. Post: self.neighbors, self.nodes and self.in_neighbors...
python
def del_node(self, name): ''' API: del_node(self, name) Description: Removes node from Graph. Input: name: Name of the node. Pre: Graph should contain a node with this name. Post: self.neighbors, self.nodes and self.in_neighbors...
[ "def", "del_node", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "neighbors", ":", "raise", "Exception", "(", "'Node %s does not exist!'", "%", "str", "(", "name", ")", ")", "for", "n", "in", "self", ".", "neighbors", "[",...
API: del_node(self, name) Description: Removes node from Graph. Input: name: Name of the node. Pre: Graph should contain a node with this name. Post: self.neighbors, self.nodes and self.in_neighbors are updated.
[ "API", ":", "del_node", "(", "self", "name", ")", "Description", ":", "Removes", "node", "from", "Graph", ".", "Input", ":", "name", ":", "Name", "of", "the", "node", ".", "Pre", ":", "Graph", "should", "contain", "a", "node", "with", "this", "name", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L310-L336
coin-or/GiMPy
src/gimpy/graph.py
Graph.add_edge
def add_edge(self, name1, name2, **attr): ''' API: add_edge(self, name1, name2, **attr) Description: Adds edge to the graph. Sets edge attributes using attr argument. Input: name1: Name of the source node (if directed). name2: Name of the sink node (if dir...
python
def add_edge(self, name1, name2, **attr): ''' API: add_edge(self, name1, name2, **attr) Description: Adds edge to the graph. Sets edge attributes using attr argument. Input: name1: Name of the source node (if directed). name2: Name of the sink node (if dir...
[ "def", "add_edge", "(", "self", ",", "name1", ",", "name2", ",", "*", "*", "attr", ")", ":", "if", "(", "name1", ",", "name2", ")", "in", "self", ".", "edge_attr", ":", "raise", "MultipleEdgeException", "if", "self", ".", "graph_type", "is", "UNDIRECTE...
API: add_edge(self, name1, name2, **attr) Description: Adds edge to the graph. Sets edge attributes using attr argument. Input: name1: Name of the source node (if directed). name2: Name of the sink node (if directed). attr: Edge attributes. Pre: ...
[ "API", ":", "add_edge", "(", "self", "name1", "name2", "**", "attr", ")", "Description", ":", "Adds", "edge", "to", "the", "graph", ".", "Sets", "edge", "attributes", "using", "attr", "argument", ".", "Input", ":", "name1", ":", "Name", "of", "the", "s...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L338-L370
coin-or/GiMPy
src/gimpy/graph.py
Graph.del_edge
def del_edge(self, e): ''' API: del_edge(self, e) Description: Removes edge from graph. Input: e: Tuple that represents edge, in (source,sink) form. Pre: Graph should contain this edge. Post: self.edge_attr, self.neighbors and s...
python
def del_edge(self, e): ''' API: del_edge(self, e) Description: Removes edge from graph. Input: e: Tuple that represents edge, in (source,sink) form. Pre: Graph should contain this edge. Post: self.edge_attr, self.neighbors and s...
[ "def", "del_edge", "(", "self", ",", "e", ")", ":", "if", "self", ".", "graph_type", "is", "DIRECTED_GRAPH", ":", "try", ":", "del", "self", ".", "edge_attr", "[", "e", "]", "except", "KeyError", ":", "raise", "Exception", "(", "'Edge %s does not exists!'"...
API: del_edge(self, e) Description: Removes edge from graph. Input: e: Tuple that represents edge, in (source,sink) form. Pre: Graph should contain this edge. Post: self.edge_attr, self.neighbors and self.in_neighbors are updated.
[ "API", ":", "del_edge", "(", "self", "e", ")", "Description", ":", "Removes", "edge", "from", "graph", ".", "Input", ":", "e", ":", "Tuple", "that", "represents", "edge", "in", "(", "source", "sink", ")", "form", ".", "Pre", ":", "Graph", "should", "...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L372-L400
coin-or/GiMPy
src/gimpy/graph.py
Graph.check_edge
def check_edge(self, name1, name2): ''' API: check_edge(self, name1, name2) Description: Return True if edge exists, False otherwise. Input: name1: name of the source node. name2: name of the sink node. Return: Returns True if edge exis...
python
def check_edge(self, name1, name2): ''' API: check_edge(self, name1, name2) Description: Return True if edge exists, False otherwise. Input: name1: name of the source node. name2: name of the sink node. Return: Returns True if edge exis...
[ "def", "check_edge", "(", "self", ",", "name1", ",", "name2", ")", ":", "if", "self", ".", "graph_type", "is", "DIRECTED_GRAPH", ":", "return", "(", "name1", ",", "name2", ")", "in", "self", ".", "edge_attr", "else", ":", "return", "(", "(", "name1", ...
API: check_edge(self, name1, name2) Description: Return True if edge exists, False otherwise. Input: name1: name of the source node. name2: name of the sink node. Return: Returns True if edge exists, False otherwise.
[ "API", ":", "check_edge", "(", "self", "name1", "name2", ")", "Description", ":", "Return", "True", "if", "edge", "exists", "False", "otherwise", ".", "Input", ":", "name1", ":", "name", "of", "the", "source", "node", ".", "name2", ":", "name", "of", "...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L429-L444
coin-or/GiMPy
src/gimpy/graph.py
Graph.get_edge_attr
def get_edge_attr(self, n, m, attr): ''' API: get_edge_attr(self, n, m, attr) Description: Returns attribute attr of edge (n,m). Input: n: Source node name. m: Sink node name. attr: Attribute of edge. Pre: Graph should have ...
python
def get_edge_attr(self, n, m, attr): ''' API: get_edge_attr(self, n, m, attr) Description: Returns attribute attr of edge (n,m). Input: n: Source node name. m: Sink node name. attr: Attribute of edge. Pre: Graph should have ...
[ "def", "get_edge_attr", "(", "self", ",", "n", ",", "m", ",", "attr", ")", ":", "if", "self", ".", "graph_type", "is", "DIRECTED_GRAPH", ":", "return", "self", ".", "edge_attr", "[", "(", "n", ",", "m", ")", "]", "[", "attr", "]", "else", ":", "t...
API: get_edge_attr(self, n, m, attr) Description: Returns attribute attr of edge (n,m). Input: n: Source node name. m: Sink node name. attr: Attribute of edge. Pre: Graph should have this edge. Return: Value of edge attr...
[ "API", ":", "get_edge_attr", "(", "self", "n", "m", "attr", ")", "Description", ":", "Returns", "attribute", "attr", "of", "edge", "(", "n", "m", ")", ".", "Input", ":", "n", ":", "Source", "node", "name", ".", "m", ":", "Sink", "node", "name", "."...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L501-L521
coin-or/GiMPy
src/gimpy/graph.py
Graph.set_node_attr
def set_node_attr(self, name, attr, value): ''' API: set_node_attr(self, name, attr) Description: Sets attr attribute of node named name to value. Input: name: Name of node. attr: Attribute of node to set. Pre: Graph should have this no...
python
def set_node_attr(self, name, attr, value): ''' API: set_node_attr(self, name, attr) Description: Sets attr attribute of node named name to value. Input: name: Name of node. attr: Attribute of node to set. Pre: Graph should have this no...
[ "def", "set_node_attr", "(", "self", ",", "name", ",", "attr", ",", "value", ")", ":", "self", ".", "get_node", "(", "name", ")", ".", "set_attr", "(", "attr", ",", "value", ")" ]
API: set_node_attr(self, name, attr) Description: Sets attr attribute of node named name to value. Input: name: Name of node. attr: Attribute of node to set. Pre: Graph should have this node. Post: Node attribute will be updated.
[ "API", ":", "set_node_attr", "(", "self", "name", "attr", ")", "Description", ":", "Sets", "attr", "attribute", "of", "node", "named", "name", "to", "value", ".", "Input", ":", "name", ":", "Name", "of", "node", ".", "attr", ":", "Attribute", "of", "no...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L523-L536
coin-or/GiMPy
src/gimpy/graph.py
Graph.set_edge_attr
def set_edge_attr(self, n, m, attr, value): ''' API: set_edge_attr(self, n, m, attr, value) Description: Sets attr attribute of edge (n,m) to value. Input: n: Source node name. m: Sink node name. attr: Attribute of edge to set. valu...
python
def set_edge_attr(self, n, m, attr, value): ''' API: set_edge_attr(self, n, m, attr, value) Description: Sets attr attribute of edge (n,m) to value. Input: n: Source node name. m: Sink node name. attr: Attribute of edge to set. valu...
[ "def", "set_edge_attr", "(", "self", ",", "n", ",", "m", ",", "attr", ",", "value", ")", ":", "if", "self", ".", "graph_type", "is", "DIRECTED_GRAPH", ":", "self", ".", "edge_attr", "[", "(", "n", ",", "m", ")", "]", "[", "attr", "]", "=", "value...
API: set_edge_attr(self, n, m, attr, value) Description: Sets attr attribute of edge (n,m) to value. Input: n: Source node name. m: Sink node name. attr: Attribute of edge to set. value: New value of attribute. Pre: Graph should...
[ "API", ":", "set_edge_attr", "(", "self", "n", "m", "attr", "value", ")", "Description", ":", "Sets", "attr", "attribute", "of", "edge", "(", "n", "m", ")", "to", "value", ".", "Input", ":", "n", ":", "Source", "node", "name", ".", "m", ":", "Sink"...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L538-L559
coin-or/GiMPy
src/gimpy/graph.py
Graph.edge_to_string
def edge_to_string(self, e): ''' API: edge_to_string(self, e) Description: Return string that represents edge e in dot language. Input: e: Edge tuple in (source,sink) format. Pre: Graph should have this edge. Return: String that...
python
def edge_to_string(self, e): ''' API: edge_to_string(self, e) Description: Return string that represents edge e in dot language. Input: e: Edge tuple in (source,sink) format. Pre: Graph should have this edge. Return: String that...
[ "def", "edge_to_string", "(", "self", ",", "e", ")", ":", "edge", "=", "list", "(", ")", "edge", ".", "append", "(", "quote_if_necessary", "(", "str", "(", "e", "[", "0", "]", ")", ")", ")", "edge", ".", "append", "(", "self", ".", "edge_connect_sy...
API: edge_to_string(self, e) Description: Return string that represents edge e in dot language. Input: e: Edge tuple in (source,sink) format. Pre: Graph should have this edge. Return: String that represents given edge.
[ "API", ":", "edge_to_string", "(", "self", "e", ")", "Description", ":", "Return", "string", "that", "represents", "edge", "e", "in", "dot", "language", ".", "Input", ":", "e", ":", "Edge", "tuple", "in", "(", "source", "sink", ")", "format", ".", "Pre...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L603-L630
coin-or/GiMPy
src/gimpy/graph.py
Graph.to_string
def to_string(self): ''' API: to_string(self) Description: This method is based on pydot Graph class with the same name. Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string form. Return: ...
python
def to_string(self): ''' API: to_string(self) Description: This method is based on pydot Graph class with the same name. Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string form. Return: ...
[ "def", "to_string", "(", "self", ")", ":", "graph", "=", "list", "(", ")", "processed_edges", "=", "{", "}", "graph", ".", "append", "(", "'%s %s {\\n'", "%", "(", "self", ".", "graph_type", ",", "self", ".", "name", ")", ")", "for", "a", "in", "se...
API: to_string(self) Description: This method is based on pydot Graph class with the same name. Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string form. Return: String that represents graph in dot l...
[ "API", ":", "to_string", "(", "self", ")", "Description", ":", "This", "method", "is", "based", "on", "pydot", "Graph", "class", "with", "the", "same", "name", ".", "Returns", "a", "string", "representation", "of", "the", "graph", "in", "dot", "language", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L632-L697
coin-or/GiMPy
src/gimpy/graph.py
Graph.label_components
def label_components(self, display = None): ''' API: label_components(self, display=None) Description: This method labels the nodes of an undirected graph with component numbers so that each node has the same label as all nodes in the same component. It will display the a...
python
def label_components(self, display = None): ''' API: label_components(self, display=None) Description: This method labels the nodes of an undirected graph with component numbers so that each node has the same label as all nodes in the same component. It will display the a...
[ "def", "label_components", "(", "self", ",", "display", "=", "None", ")", ":", "if", "self", ".", "graph_type", "==", "DIRECTED_GRAPH", ":", "raise", "Exception", "(", "\"label_components only works for \"", ",", "\"undirected graphs\"", ")", "self", ".", "num_com...
API: label_components(self, display=None) Description: This method labels the nodes of an undirected graph with component numbers so that each node has the same label as all nodes in the same component. It will display the algortihm if display argument is provided. Input:...
[ "API", ":", "label_components", "(", "self", "display", "=", "None", ")", "Description", ":", "This", "method", "labels", "the", "nodes", "of", "an", "undirected", "graph", "with", "component", "numbers", "so", "that", "each", "node", "has", "the", "same", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L699-L727
coin-or/GiMPy
src/gimpy/graph.py
Graph.tarjan
def tarjan(self): ''' API: tarjan(self) Description: Implements Tarjan's algorithm for determining strongly connected set of nodes. Pre: self.graph_type should be DIRECTED_GRAPH. Post: Nodes will have 'component' attribute that will have co...
python
def tarjan(self): ''' API: tarjan(self) Description: Implements Tarjan's algorithm for determining strongly connected set of nodes. Pre: self.graph_type should be DIRECTED_GRAPH. Post: Nodes will have 'component' attribute that will have co...
[ "def", "tarjan", "(", "self", ")", ":", "index", "=", "0", "component", "=", "0", "q", "=", "[", "]", "for", "n", "in", "self", ".", "get_node_list", "(", ")", ":", "if", "self", ".", "get_node_attr", "(", "n", ",", "'index'", ")", "is", "None", ...
API: tarjan(self) Description: Implements Tarjan's algorithm for determining strongly connected set of nodes. Pre: self.graph_type should be DIRECTED_GRAPH. Post: Nodes will have 'component' attribute that will have component number as value. C...
[ "API", ":", "tarjan", "(", "self", ")", "Description", ":", "Implements", "Tarjan", "s", "algorithm", "for", "determining", "strongly", "connected", "set", "of", "nodes", ".", "Pre", ":", "self", ".", "graph_type", "should", "be", "DIRECTED_GRAPH", ".", "Pos...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L729-L746
coin-or/GiMPy
src/gimpy/graph.py
Graph.strong_connect
def strong_connect(self, q, node, index, component): ''' API: strong_connect (self, q, node, index, component) Description: Used by tarjan method. This method should not be called directly by user. Input: q: Node list. node: Node that is being conn...
python
def strong_connect(self, q, node, index, component): ''' API: strong_connect (self, q, node, index, component) Description: Used by tarjan method. This method should not be called directly by user. Input: q: Node list. node: Node that is being conn...
[ "def", "strong_connect", "(", "self", ",", "q", ",", "node", ",", "index", ",", "component", ")", ":", "self", ".", "set_node_attr", "(", "node", ",", "'index'", ",", "index", ")", "self", ".", "set_node_attr", "(", "node", ",", "'lowlink'", ",", "inde...
API: strong_connect (self, q, node, index, component) Description: Used by tarjan method. This method should not be called directly by user. Input: q: Node list. node: Node that is being connected to nodes in q. index: Index used by tarjan method. ...
[ "API", ":", "strong_connect", "(", "self", "q", "node", "index", "component", ")", "Description", ":", "Used", "by", "tarjan", "method", ".", "This", "method", "should", "not", "be", "called", "directly", "by", "user", ".", "Input", ":", "q", ":", "Node"...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L748-L790
coin-or/GiMPy
src/gimpy/graph.py
Graph.dfs
def dfs(self, root, disc_count = 0, finish_count = 1, component = None, transpose = False, display = None, pred = None): ''' API: dfs(self, root, disc_count = 0, finish_count = 1, component=None, transpose=False) Description: Make a depth-first search starting fro...
python
def dfs(self, root, disc_count = 0, finish_count = 1, component = None, transpose = False, display = None, pred = None): ''' API: dfs(self, root, disc_count = 0, finish_count = 1, component=None, transpose=False) Description: Make a depth-first search starting fro...
[ "def", "dfs", "(", "self", ",", "root", ",", "disc_count", "=", "0", ",", "finish_count", "=", "1", ",", "component", "=", "None", ",", "transpose", "=", "False", ",", "display", "=", "None", ",", "pred", "=", "None", ")", ":", "if", "pred", "==", ...
API: dfs(self, root, disc_count = 0, finish_count = 1, component=None, transpose=False) Description: Make a depth-first search starting from node with name root. Input: root: Starting node name. disc_count: Discovery time. finish_count: Finishing t...
[ "API", ":", "dfs", "(", "self", "root", "disc_count", "=", "0", "finish_count", "=", "1", "component", "=", "None", "transpose", "=", "False", ")", "Description", ":", "Make", "a", "depth", "-", "first", "search", "starting", "from", "node", "with", "nam...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L808-L877
coin-or/GiMPy
src/gimpy/graph.py
Graph.bfs
def bfs(self, root, display = None, component = None): ''' API: bfs(self, root, display = None, component=None) Description: Make a breadth-first search starting from node with name root. Input: root: Starting node name. display: display method. ...
python
def bfs(self, root, display = None, component = None): ''' API: bfs(self, root, display = None, component=None) Description: Make a breadth-first search starting from node with name root. Input: root: Starting node name. display: display method. ...
[ "def", "bfs", "(", "self", ",", "root", ",", "display", "=", "None", ",", "component", "=", "None", ")", ":", "self", ".", "search", "(", "root", ",", "display", "=", "display", ",", "component", "=", "component", ",", "q", "=", "Queue", "(", ")", ...
API: bfs(self, root, display = None, component=None) Description: Make a breadth-first search starting from node with name root. Input: root: Starting node name. display: display method. component: component number. Post: Nodes will have 'c...
[ "API", ":", "bfs", "(", "self", "root", "display", "=", "None", "component", "=", "None", ")", "Description", ":", "Make", "a", "breadth", "-", "first", "search", "starting", "from", "node", "with", "name", "root", ".", "Input", ":", "root", ":", "Star...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L879-L892
coin-or/GiMPy
src/gimpy/graph.py
Graph.search
def search(self, source, destination = None, display = None, component = None, q = None, algo = 'DFS', reverse = False, **kargs): ''' API: search(self, source, destination = None, display = None, component = None, q = Stack(), algo = 'DFS', rev...
python
def search(self, source, destination = None, display = None, component = None, q = None, algo = 'DFS', reverse = False, **kargs): ''' API: search(self, source, destination = None, display = None, component = None, q = Stack(), algo = 'DFS', rev...
[ "def", "search", "(", "self", ",", "source", ",", "destination", "=", "None", ",", "display", "=", "None", ",", "component", "=", "None", ",", "q", "=", "None", ",", "algo", "=", "'DFS'", ",", "reverse", "=", "False", ",", "*", "*", "kargs", ")", ...
API: search(self, source, destination = None, display = None, component = None, q = Stack(), algo = 'DFS', reverse = False, **kargs) Description: Generic search method. Changes behavior (dfs,bfs,dijkstra,prim) according to algo argument. if destination is no...
[ "API", ":", "search", "(", "self", "source", "destination", "=", "None", "display", "=", "None", "component", "=", "None", "q", "=", "Stack", "()", "algo", "=", "DFS", "reverse", "=", "False", "**", "kargs", ")", "Description", ":", "Generic", "search", ...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L894-L1013
coin-or/GiMPy
src/gimpy/graph.py
Graph.process_node_search
def process_node_search(self, node, q, **kwargs): ''' API: process_node_search(self, node, q, **kwargs) Description: Used by search() method. Process nodes along the search. Should not be called by user directly. Input: node: Name of the node being processed. ...
python
def process_node_search(self, node, q, **kwargs): ''' API: process_node_search(self, node, q, **kwargs) Description: Used by search() method. Process nodes along the search. Should not be called by user directly. Input: node: Name of the node being processed. ...
[ "def", "process_node_search", "(", "self", ",", "node", ",", "q", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "q", ",", "PriorityQueue", ")", ":", "self", ".", "get_node", "(", "node", ")", ".", "set_attr", "(", "'priority'", ",", "q"...
API: process_node_search(self, node, q, **kwargs) Description: Used by search() method. Process nodes along the search. Should not be called by user directly. Input: node: Name of the node being processed. q: Queue data structure. kwargs: Keyword argum...
[ "API", ":", "process_node_search", "(", "self", "node", "q", "**", "kwargs", ")", "Description", ":", "Used", "by", "search", "()", "method", ".", "Process", "nodes", "along", "the", "search", ".", "Should", "not", "be", "called", "by", "user", "directly",...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1015-L1029
coin-or/GiMPy
src/gimpy/graph.py
Graph.process_edge_dijkstra
def process_edge_dijkstra(self, current, neighbor, pred, q, component): ''' API: process_edge_dijkstra(self, current, neighbor, pred, q, component) Description: Used by search() method if the algo argument is 'Dijkstra'. Processes edges along Dijkstra's algorithm. User does not n...
python
def process_edge_dijkstra(self, current, neighbor, pred, q, component): ''' API: process_edge_dijkstra(self, current, neighbor, pred, q, component) Description: Used by search() method if the algo argument is 'Dijkstra'. Processes edges along Dijkstra's algorithm. User does not n...
[ "def", "process_edge_dijkstra", "(", "self", ",", "current", ",", "neighbor", ",", "pred", ",", "q", ",", "component", ")", ":", "if", "current", "is", "None", ":", "self", ".", "get_node", "(", "neighbor", ")", ".", "set_attr", "(", "'color'", ",", "'...
API: process_edge_dijkstra(self, current, neighbor, pred, q, component) Description: Used by search() method if the algo argument is 'Dijkstra'. Processes edges along Dijkstra's algorithm. User does not need to call this method directly. Input: current: Name of the cu...
[ "API", ":", "process_edge_dijkstra", "(", "self", "current", "neighbor", "pred", "q", "component", ")", "Description", ":", "Used", "by", "search", "()", "method", "if", "the", "algo", "argument", "is", "Dijkstra", ".", "Processes", "edges", "along", "Dijkstra...
train
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1031-L1062