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 |
|---|---|---|---|---|---|---|---|---|---|---|
idlesign/torrentool | torrentool/bencode.py | Bencode.encode | def encode(cls, value):
"""Encodes a value into bencoded bytes.
:param value: Python object to be encoded (str, int, list, dict).
:param str val_encoding: Encoding used by strings in a given object.
:rtype: bytes
"""
val_encoding = 'utf-8'
def encode_str(v):
... | python | def encode(cls, value):
"""Encodes a value into bencoded bytes.
:param value: Python object to be encoded (str, int, list, dict).
:param str val_encoding: Encoding used by strings in a given object.
:rtype: bytes
"""
val_encoding = 'utf-8'
def encode_str(v):
... | [
"def",
"encode",
"(",
"cls",
",",
"value",
")",
":",
"val_encoding",
"=",
"'utf-8'",
"def",
"encode_str",
"(",
"v",
")",
":",
"try",
":",
"v_enc",
"=",
"encode",
"(",
"v",
",",
"val_encoding",
")",
"except",
"UnicodeDecodeError",
":",
"if",
"PY3",
":",... | Encodes a value into bencoded bytes.
:param value: Python object to be encoded (str, int, list, dict).
:param str val_encoding: Encoding used by strings in a given object.
:rtype: bytes | [
"Encodes",
"a",
"value",
"into",
"bencoded",
"bytes",
"."
] | train | https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/bencode.py#L27-L81 |
idlesign/torrentool | torrentool/bencode.py | Bencode.decode | def decode(cls, encoded):
"""Decodes bencoded data introduced as bytes.
Returns decoded structure(s).
:param bytes encoded:
"""
def create_dict(items):
# Let's guarantee that dictionaries are sorted.
k_v_pair = zip(*[iter(items)] * 2)
return ... | python | def decode(cls, encoded):
"""Decodes bencoded data introduced as bytes.
Returns decoded structure(s).
:param bytes encoded:
"""
def create_dict(items):
# Let's guarantee that dictionaries are sorted.
k_v_pair = zip(*[iter(items)] * 2)
return ... | [
"def",
"decode",
"(",
"cls",
",",
"encoded",
")",
":",
"def",
"create_dict",
"(",
"items",
")",
":",
"# Let's guarantee that dictionaries are sorted.",
"k_v_pair",
"=",
"zip",
"(",
"*",
"[",
"iter",
"(",
"items",
")",
"]",
"*",
"2",
")",
"return",
"Ordered... | Decodes bencoded data introduced as bytes.
Returns decoded structure(s).
:param bytes encoded: | [
"Decodes",
"bencoded",
"data",
"introduced",
"as",
"bytes",
"."
] | train | https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/bencode.py#L84-L177 |
idlesign/torrentool | torrentool/bencode.py | Bencode.read_string | def read_string(cls, string):
"""Decodes a given bencoded string or bytestring.
Returns decoded structure(s).
:param str string:
:rtype: list
"""
if PY3 and not isinstance(string, byte_types):
string = string.encode()
return cls.decode(string) | python | def read_string(cls, string):
"""Decodes a given bencoded string or bytestring.
Returns decoded structure(s).
:param str string:
:rtype: list
"""
if PY3 and not isinstance(string, byte_types):
string = string.encode()
return cls.decode(string) | [
"def",
"read_string",
"(",
"cls",
",",
"string",
")",
":",
"if",
"PY3",
"and",
"not",
"isinstance",
"(",
"string",
",",
"byte_types",
")",
":",
"string",
"=",
"string",
".",
"encode",
"(",
")",
"return",
"cls",
".",
"decode",
"(",
"string",
")"
] | Decodes a given bencoded string or bytestring.
Returns decoded structure(s).
:param str string:
:rtype: list | [
"Decodes",
"a",
"given",
"bencoded",
"string",
"or",
"bytestring",
"."
] | train | https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/bencode.py#L180-L191 |
idlesign/torrentool | torrentool/bencode.py | Bencode.read_file | def read_file(cls, filepath):
"""Decodes bencoded data of a given file.
Returns decoded structure(s).
:param str filepath:
:rtype: list
"""
with open(filepath, mode='rb') as f:
contents = f.read()
return cls.decode(contents) | python | def read_file(cls, filepath):
"""Decodes bencoded data of a given file.
Returns decoded structure(s).
:param str filepath:
:rtype: list
"""
with open(filepath, mode='rb') as f:
contents = f.read()
return cls.decode(contents) | [
"def",
"read_file",
"(",
"cls",
",",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"mode",
"=",
"'rb'",
")",
"as",
"f",
":",
"contents",
"=",
"f",
".",
"read",
"(",
")",
"return",
"cls",
".",
"decode",
"(",
"contents",
")"
] | Decodes bencoded data of a given file.
Returns decoded structure(s).
:param str filepath:
:rtype: list | [
"Decodes",
"bencoded",
"data",
"of",
"a",
"given",
"file",
"."
] | train | https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/bencode.py#L194-L204 |
twaldear/flask-csp | flask_csp/csp.py | create_csp_header | def create_csp_header(cspDict):
""" create csp header string """
policy = ['%s %s' % (k, v) for k, v in cspDict.items() if v != '']
return '; '.join(policy) | python | def create_csp_header(cspDict):
""" create csp header string """
policy = ['%s %s' % (k, v) for k, v in cspDict.items() if v != '']
return '; '.join(policy) | [
"def",
"create_csp_header",
"(",
"cspDict",
")",
":",
"policy",
"=",
"[",
"'%s %s'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"cspDict",
".",
"items",
"(",
")",
"if",
"v",
"!=",
"''",
"]",
"return",
"'; '",
".",
"join",
"(",
"p... | create csp header string | [
"create",
"csp",
"header",
"string"
] | train | https://github.com/twaldear/flask-csp/blob/0f679af368299e36ee9008861fbd4e764abf4b86/flask_csp/csp.py#L36-L39 |
twaldear/flask-csp | flask_csp/csp.py | csp_header | def csp_header(csp={}):
""" Decorator to include csp header on app.route wrapper """
_csp = csp_default().read()
_csp.update(csp)
_header = ''
if 'report-only' in _csp and _csp['report-only'] is True:
_header = 'Content-Security-Policy-Report-Only'
else:
_header = 'Content-Securit... | python | def csp_header(csp={}):
""" Decorator to include csp header on app.route wrapper """
_csp = csp_default().read()
_csp.update(csp)
_header = ''
if 'report-only' in _csp and _csp['report-only'] is True:
_header = 'Content-Security-Policy-Report-Only'
else:
_header = 'Content-Securit... | [
"def",
"csp_header",
"(",
"csp",
"=",
"{",
"}",
")",
":",
"_csp",
"=",
"csp_default",
"(",
")",
".",
"read",
"(",
")",
"_csp",
".",
"update",
"(",
"csp",
")",
"_header",
"=",
"''",
"if",
"'report-only'",
"in",
"_csp",
"and",
"_csp",
"[",
"'report-o... | Decorator to include csp header on app.route wrapper | [
"Decorator",
"to",
"include",
"csp",
"header",
"on",
"app",
".",
"route",
"wrapper"
] | train | https://github.com/twaldear/flask-csp/blob/0f679af368299e36ee9008861fbd4e764abf4b86/flask_csp/csp.py#L41-L64 |
twaldear/flask-csp | flask_csp/csp.py | csp_default.read | def read(self):
""" read default csp settings from json file """
with open(self.default_file) as json_file:
try:
return json.load(json_file)
except Exception as e:
raise 'empty file' | python | def read(self):
""" read default csp settings from json file """
with open(self.default_file) as json_file:
try:
return json.load(json_file)
except Exception as e:
raise 'empty file' | [
"def",
"read",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"default_file",
")",
"as",
"json_file",
":",
"try",
":",
"return",
"json",
".",
"load",
"(",
"json_file",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"'empty file'"
] | read default csp settings from json file | [
"read",
"default",
"csp",
"settings",
"from",
"json",
"file"
] | train | https://github.com/twaldear/flask-csp/blob/0f679af368299e36ee9008861fbd4e764abf4b86/flask_csp/csp.py#L9-L15 |
twaldear/flask-csp | flask_csp/csp.py | csp_default.update | def update(self,updates={}):
"""
update csp_default.json with dict
if file empty add default-src and create dict
"""
try:
csp = self.read()
except:
csp = {'default-src':"'self'"}
self.write(csp)
csp.update(updates)
self.write(csp) | python | def update(self,updates={}):
"""
update csp_default.json with dict
if file empty add default-src and create dict
"""
try:
csp = self.read()
except:
csp = {'default-src':"'self'"}
self.write(csp)
csp.update(updates)
self.write(csp) | [
"def",
"update",
"(",
"self",
",",
"updates",
"=",
"{",
"}",
")",
":",
"try",
":",
"csp",
"=",
"self",
".",
"read",
"(",
")",
"except",
":",
"csp",
"=",
"{",
"'default-src'",
":",
"\"'self'\"",
"}",
"self",
".",
"write",
"(",
"csp",
")",
"csp",
... | update csp_default.json with dict
if file empty add default-src and create dict | [
"update",
"csp_default",
".",
"json",
"with",
"dict",
"if",
"file",
"empty",
"add",
"default",
"-",
"src",
"and",
"create",
"dict"
] | train | https://github.com/twaldear/flask-csp/blob/0f679af368299e36ee9008861fbd4e764abf4b86/flask_csp/csp.py#L17-L29 |
pinax/pinax-images | pinax/images/views.py | ImageSetUploadView.get_image_set | def get_image_set(self):
"""
Obtain existing ImageSet if `pk` is specified, otherwise
create a new ImageSet for the user.
"""
image_set_pk = self.kwargs.get("pk", None)
if image_set_pk is None:
return self.request.user.image_sets.create()
return get_ob... | python | def get_image_set(self):
"""
Obtain existing ImageSet if `pk` is specified, otherwise
create a new ImageSet for the user.
"""
image_set_pk = self.kwargs.get("pk", None)
if image_set_pk is None:
return self.request.user.image_sets.create()
return get_ob... | [
"def",
"get_image_set",
"(",
"self",
")",
":",
"image_set_pk",
"=",
"self",
".",
"kwargs",
".",
"get",
"(",
"\"pk\"",
",",
"None",
")",
"if",
"image_set_pk",
"is",
"None",
":",
"return",
"self",
".",
"request",
".",
"user",
".",
"image_sets",
".",
"cre... | Obtain existing ImageSet if `pk` is specified, otherwise
create a new ImageSet for the user. | [
"Obtain",
"existing",
"ImageSet",
"if",
"pk",
"is",
"specified",
"otherwise",
"create",
"a",
"new",
"ImageSet",
"for",
"the",
"user",
"."
] | train | https://github.com/pinax/pinax-images/blob/7c7212f8dd741b7374c787a99adcf6d852b783da/pinax/images/views.py#L22-L30 |
opentracing-contrib/python-tornado | tornado_opentracing/application.py | tracer_config | def tracer_config(__init__, app, args, kwargs):
"""
Wraps the Tornado web application initialization so that the
TornadoTracing instance is created around an OpenTracing-compatible tracer.
"""
__init__(*args, **kwargs)
tracing = app.settings.get('opentracing_tracing')
tracer_callable = app.... | python | def tracer_config(__init__, app, args, kwargs):
"""
Wraps the Tornado web application initialization so that the
TornadoTracing instance is created around an OpenTracing-compatible tracer.
"""
__init__(*args, **kwargs)
tracing = app.settings.get('opentracing_tracing')
tracer_callable = app.... | [
"def",
"tracer_config",
"(",
"__init__",
",",
"app",
",",
"args",
",",
"kwargs",
")",
":",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"tracing",
"=",
"app",
".",
"settings",
".",
"get",
"(",
"'opentracing_tracing'",
")",
"tracer_callable... | Wraps the Tornado web application initialization so that the
TornadoTracing instance is created around an OpenTracing-compatible tracer. | [
"Wraps",
"the",
"Tornado",
"web",
"application",
"initialization",
"so",
"that",
"the",
"TornadoTracing",
"instance",
"is",
"created",
"around",
"an",
"OpenTracing",
"-",
"compatible",
"tracer",
"."
] | train | https://github.com/opentracing-contrib/python-tornado/blob/2c87f423c316805c6140d7f0613c800dd05b47dc/tornado_opentracing/application.py#L31-L64 |
opentracing-contrib/python-tornado | tornado_opentracing/tracing.py | TornadoTracing.trace | def trace(self, *attributes):
"""
Function decorator that traces functions
NOTE: Must be placed before the Tornado decorators
@param attributes any number of request attributes
(strings) to be set as tags on the created span
"""
@wrapt.decorator
def wrapp... | python | def trace(self, *attributes):
"""
Function decorator that traces functions
NOTE: Must be placed before the Tornado decorators
@param attributes any number of request attributes
(strings) to be set as tags on the created span
"""
@wrapt.decorator
def wrapp... | [
"def",
"trace",
"(",
"self",
",",
"*",
"attributes",
")",
":",
"@",
"wrapt",
".",
"decorator",
"def",
"wrapper",
"(",
"wrapped",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"self",
".",
"_trace_all",
":",
"return",
"wrapped",
"(",
"*... | Function decorator that traces functions
NOTE: Must be placed before the Tornado decorators
@param attributes any number of request attributes
(strings) to be set as tags on the created span | [
"Function",
"decorator",
"that",
"traces",
"functions",
"NOTE",
":",
"Must",
"be",
"placed",
"before",
"the",
"Tornado",
"decorators"
] | train | https://github.com/opentracing-contrib/python-tornado/blob/2c87f423c316805c6140d7f0613c800dd05b47dc/tornado_opentracing/tracing.py#L61-L99 |
opentracing-contrib/python-tornado | tornado_opentracing/tracing.py | TornadoTracing._apply_tracing | def _apply_tracing(self, handler, attributes):
"""
Helper function to avoid rewriting for middleware and decorator.
Returns a new span from the request with logged attributes and
correct operation name from the func.
"""
operation_name = self._get_operation_name(handler)
... | python | def _apply_tracing(self, handler, attributes):
"""
Helper function to avoid rewriting for middleware and decorator.
Returns a new span from the request with logged attributes and
correct operation name from the func.
"""
operation_name = self._get_operation_name(handler)
... | [
"def",
"_apply_tracing",
"(",
"self",
",",
"handler",
",",
"attributes",
")",
":",
"operation_name",
"=",
"self",
".",
"_get_operation_name",
"(",
"handler",
")",
"headers",
"=",
"handler",
".",
"request",
".",
"headers",
"request",
"=",
"handler",
".",
"req... | Helper function to avoid rewriting for middleware and decorator.
Returns a new span from the request with logged attributes and
correct operation name from the func. | [
"Helper",
"function",
"to",
"avoid",
"rewriting",
"for",
"middleware",
"and",
"decorator",
".",
"Returns",
"a",
"new",
"span",
"from",
"the",
"request",
"with",
"logged",
"attributes",
"and",
"correct",
"operation",
"name",
"from",
"the",
"func",
"."
] | train | https://github.com/opentracing-contrib/python-tornado/blob/2c87f423c316805c6140d7f0613c800dd05b47dc/tornado_opentracing/tracing.py#L109-L147 |
opentracing-contrib/python-tornado | tornado_opentracing/handlers.py | execute | def execute(func, handler, args, kwargs):
"""
Wrap the handler ``_execute`` method to trace incoming requests,
extracting the context from the headers, if available.
"""
tracing = handler.settings.get('opentracing_tracing')
with tracer_stack_context():
if tracing._trace_all:
... | python | def execute(func, handler, args, kwargs):
"""
Wrap the handler ``_execute`` method to trace incoming requests,
extracting the context from the headers, if available.
"""
tracing = handler.settings.get('opentracing_tracing')
with tracer_stack_context():
if tracing._trace_all:
... | [
"def",
"execute",
"(",
"func",
",",
"handler",
",",
"args",
",",
"kwargs",
")",
":",
"tracing",
"=",
"handler",
".",
"settings",
".",
"get",
"(",
"'opentracing_tracing'",
")",
"with",
"tracer_stack_context",
"(",
")",
":",
"if",
"tracing",
".",
"_trace_all... | Wrap the handler ``_execute`` method to trace incoming requests,
extracting the context from the headers, if available. | [
"Wrap",
"the",
"handler",
"_execute",
"method",
"to",
"trace",
"incoming",
"requests",
"extracting",
"the",
"context",
"from",
"the",
"headers",
"if",
"available",
"."
] | train | https://github.com/opentracing-contrib/python-tornado/blob/2c87f423c316805c6140d7f0613c800dd05b47dc/tornado_opentracing/handlers.py#L20-L32 |
opentracing-contrib/python-tornado | tornado_opentracing/handlers.py | on_finish | def on_finish(func, handler, args, kwargs):
"""
Wrap the handler ``on_finish`` method to finish the Span for the
given request, if available.
"""
tracing = handler.settings.get('opentracing_tracing')
tracing._finish_tracing(handler)
return func(*args, **kwargs) | python | def on_finish(func, handler, args, kwargs):
"""
Wrap the handler ``on_finish`` method to finish the Span for the
given request, if available.
"""
tracing = handler.settings.get('opentracing_tracing')
tracing._finish_tracing(handler)
return func(*args, **kwargs) | [
"def",
"on_finish",
"(",
"func",
",",
"handler",
",",
"args",
",",
"kwargs",
")",
":",
"tracing",
"=",
"handler",
".",
"settings",
".",
"get",
"(",
"'opentracing_tracing'",
")",
"tracing",
".",
"_finish_tracing",
"(",
"handler",
")",
"return",
"func",
"(",... | Wrap the handler ``on_finish`` method to finish the Span for the
given request, if available. | [
"Wrap",
"the",
"handler",
"on_finish",
"method",
"to",
"finish",
"the",
"Span",
"for",
"the",
"given",
"request",
"if",
"available",
"."
] | train | https://github.com/opentracing-contrib/python-tornado/blob/2c87f423c316805c6140d7f0613c800dd05b47dc/tornado_opentracing/handlers.py#L35-L43 |
opentracing-contrib/python-tornado | tornado_opentracing/handlers.py | log_exception | def log_exception(func, handler, args, kwargs):
"""
Wrap the handler ``log_exception`` method to finish the Span for the
given request, if available. This method is called when an Exception
is not handled in the user code.
"""
# safe-guard: expected arguments -> log_exception(self, typ, value, t... | python | def log_exception(func, handler, args, kwargs):
"""
Wrap the handler ``log_exception`` method to finish the Span for the
given request, if available. This method is called when an Exception
is not handled in the user code.
"""
# safe-guard: expected arguments -> log_exception(self, typ, value, t... | [
"def",
"log_exception",
"(",
"func",
",",
"handler",
",",
"args",
",",
"kwargs",
")",
":",
"# safe-guard: expected arguments -> log_exception(self, typ, value, tb)",
"value",
"=",
"args",
"[",
"1",
"]",
"if",
"len",
"(",
"args",
")",
"==",
"3",
"else",
"None",
... | Wrap the handler ``log_exception`` method to finish the Span for the
given request, if available. This method is called when an Exception
is not handled in the user code. | [
"Wrap",
"the",
"handler",
"log_exception",
"method",
"to",
"finish",
"the",
"Span",
"for",
"the",
"given",
"request",
"if",
"available",
".",
"This",
"method",
"is",
"called",
"when",
"an",
"Exception",
"is",
"not",
"handled",
"in",
"the",
"user",
"code",
... | train | https://github.com/opentracing-contrib/python-tornado/blob/2c87f423c316805c6140d7f0613c800dd05b47dc/tornado_opentracing/handlers.py#L46-L61 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode.schema_root | def schema_root(self) -> "SchemaTreeNode":
"""Return the root node of the receiver's schema."""
sn = self
while sn.parent:
sn = sn.parent
return sn | python | def schema_root(self) -> "SchemaTreeNode":
"""Return the root node of the receiver's schema."""
sn = self
while sn.parent:
sn = sn.parent
return sn | [
"def",
"schema_root",
"(",
"self",
")",
"->",
"\"SchemaTreeNode\"",
":",
"sn",
"=",
"self",
"while",
"sn",
".",
"parent",
":",
"sn",
"=",
"sn",
".",
"parent",
"return",
"sn"
] | Return the root node of the receiver's schema. | [
"Return",
"the",
"root",
"node",
"of",
"the",
"receiver",
"s",
"schema",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L113-L118 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode.content_type | def content_type(self) -> ContentType:
"""Return receiver's content type."""
return self._ctype if self._ctype else self.parent.content_type() | python | def content_type(self) -> ContentType:
"""Return receiver's content type."""
return self._ctype if self._ctype else self.parent.content_type() | [
"def",
"content_type",
"(",
"self",
")",
"->",
"ContentType",
":",
"return",
"self",
".",
"_ctype",
"if",
"self",
".",
"_ctype",
"else",
"self",
".",
"parent",
".",
"content_type",
"(",
")"
] | Return receiver's content type. | [
"Return",
"receiver",
"s",
"content",
"type",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L120-L122 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode.data_parent | def data_parent(self) -> Optional["InternalNode"]:
"""Return the closest ancestor data node."""
parent = self.parent
while parent:
if isinstance(parent, DataNode):
return parent
parent = parent.parent | python | def data_parent(self) -> Optional["InternalNode"]:
"""Return the closest ancestor data node."""
parent = self.parent
while parent:
if isinstance(parent, DataNode):
return parent
parent = parent.parent | [
"def",
"data_parent",
"(",
"self",
")",
"->",
"Optional",
"[",
"\"InternalNode\"",
"]",
":",
"parent",
"=",
"self",
".",
"parent",
"while",
"parent",
":",
"if",
"isinstance",
"(",
"parent",
",",
"DataNode",
")",
":",
"return",
"parent",
"parent",
"=",
"p... | Return the closest ancestor data node. | [
"Return",
"the",
"closest",
"ancestor",
"data",
"node",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L124-L130 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode.iname | def iname(self) -> InstanceName:
"""Return the instance name corresponding to the receiver."""
dp = self.data_parent()
return (self.name if dp and self.ns == dp.ns
else self.ns + ":" + self.name) | python | def iname(self) -> InstanceName:
"""Return the instance name corresponding to the receiver."""
dp = self.data_parent()
return (self.name if dp and self.ns == dp.ns
else self.ns + ":" + self.name) | [
"def",
"iname",
"(",
"self",
")",
"->",
"InstanceName",
":",
"dp",
"=",
"self",
".",
"data_parent",
"(",
")",
"return",
"(",
"self",
".",
"name",
"if",
"dp",
"and",
"self",
".",
"ns",
"==",
"dp",
".",
"ns",
"else",
"self",
".",
"ns",
"+",
"\":\""... | Return the instance name corresponding to the receiver. | [
"Return",
"the",
"instance",
"name",
"corresponding",
"to",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L132-L136 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode.data_path | def data_path(self) -> DataPath:
"""Return the receiver's data path."""
dp = self.data_parent()
return (dp.data_path() if dp else "") + "/" + self.iname() | python | def data_path(self) -> DataPath:
"""Return the receiver's data path."""
dp = self.data_parent()
return (dp.data_path() if dp else "") + "/" + self.iname() | [
"def",
"data_path",
"(",
"self",
")",
"->",
"DataPath",
":",
"dp",
"=",
"self",
".",
"data_parent",
"(",
")",
"return",
"(",
"dp",
".",
"data_path",
"(",
")",
"if",
"dp",
"else",
"\"\"",
")",
"+",
"\"/\"",
"+",
"self",
".",
"iname",
"(",
")"
] | Return the receiver's data path. | [
"Return",
"the",
"receiver",
"s",
"data",
"path",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L138-L141 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode._node_digest | def _node_digest(self) -> Dict[str, Any]:
"""Return dictionary of receiver's properties suitable for clients."""
res = {"kind": self._yang_class()}
if self.mandatory:
res["mandatory"] = True
if self.description:
res["description"] = self.description
return... | python | def _node_digest(self) -> Dict[str, Any]:
"""Return dictionary of receiver's properties suitable for clients."""
res = {"kind": self._yang_class()}
if self.mandatory:
res["mandatory"] = True
if self.description:
res["description"] = self.description
return... | [
"def",
"_node_digest",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"res",
"=",
"{",
"\"kind\"",
":",
"self",
".",
"_yang_class",
"(",
")",
"}",
"if",
"self",
".",
"mandatory",
":",
"res",
"[",
"\"mandatory\"",
"]",
"=",
"True"... | Return dictionary of receiver's properties suitable for clients. | [
"Return",
"dictionary",
"of",
"receiver",
"s",
"properties",
"suitable",
"for",
"clients",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L173-L180 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode._iname2qname | def _iname2qname(self, iname: InstanceName) -> QualName:
"""Translate instance name to qualified name in the receiver's context.
"""
p, s, loc = iname.partition(":")
return (loc, p) if s else (p, self.ns) | python | def _iname2qname(self, iname: InstanceName) -> QualName:
"""Translate instance name to qualified name in the receiver's context.
"""
p, s, loc = iname.partition(":")
return (loc, p) if s else (p, self.ns) | [
"def",
"_iname2qname",
"(",
"self",
",",
"iname",
":",
"InstanceName",
")",
"->",
"QualName",
":",
"p",
",",
"s",
",",
"loc",
"=",
"iname",
".",
"partition",
"(",
"\":\"",
")",
"return",
"(",
"loc",
",",
"p",
")",
"if",
"s",
"else",
"(",
"p",
","... | Translate instance name to qualified name in the receiver's context. | [
"Translate",
"instance",
"name",
"to",
"qualified",
"name",
"in",
"the",
"receiver",
"s",
"context",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L201-L205 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode._handle_substatements | def _handle_substatements(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Dispatch actions for substatements of `stmt`."""
for s in stmt.substatements:
if s.prefix:
key = (
sctx.schema_data.modules[sctx.text_mid].prefix_map[s.prefix][0]
... | python | def _handle_substatements(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Dispatch actions for substatements of `stmt`."""
for s in stmt.substatements:
if s.prefix:
key = (
sctx.schema_data.modules[sctx.text_mid].prefix_map[s.prefix][0]
... | [
"def",
"_handle_substatements",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"for",
"s",
"in",
"stmt",
".",
"substatements",
":",
"if",
"s",
".",
"prefix",
":",
"key",
"=",
"(",
"sctx",
".",
"... | Dispatch actions for substatements of `stmt`. | [
"Dispatch",
"actions",
"for",
"substatements",
"of",
"stmt",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L210-L221 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode._follow_leafref | def _follow_leafref(
self, xpath: "Expr", init: "TerminalNode") -> Optional["DataNode"]:
"""Return the data node referred to by a leafref path.
Args:
xpath: XPath expression compiled from a leafref path.
init: initial context node
"""
if isinstance(xp... | python | def _follow_leafref(
self, xpath: "Expr", init: "TerminalNode") -> Optional["DataNode"]:
"""Return the data node referred to by a leafref path.
Args:
xpath: XPath expression compiled from a leafref path.
init: initial context node
"""
if isinstance(xp... | [
"def",
"_follow_leafref",
"(",
"self",
",",
"xpath",
":",
"\"Expr\"",
",",
"init",
":",
"\"TerminalNode\"",
")",
"->",
"Optional",
"[",
"\"DataNode\"",
"]",
":",
"if",
"isinstance",
"(",
"xpath",
",",
"LocationPath",
")",
":",
"lft",
"=",
"self",
".",
"_... | Return the data node referred to by a leafref path.
Args:
xpath: XPath expression compiled from a leafref path.
init: initial context node | [
"Return",
"the",
"data",
"node",
"referred",
"to",
"by",
"a",
"leafref",
"path",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L223-L246 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode._tree_line | def _tree_line(self, no_type: bool = False) -> str:
"""Return the receiver's contribution to tree diagram."""
return self._tree_line_prefix() + " " + self.iname() | python | def _tree_line(self, no_type: bool = False) -> str:
"""Return the receiver's contribution to tree diagram."""
return self._tree_line_prefix() + " " + self.iname() | [
"def",
"_tree_line",
"(",
"self",
",",
"no_type",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"return",
"self",
".",
"_tree_line_prefix",
"(",
")",
"+",
"\" \"",
"+",
"self",
".",
"iname",
"(",
")"
] | Return the receiver's contribution to tree diagram. | [
"Return",
"the",
"receiver",
"s",
"contribution",
"to",
"tree",
"diagram",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L287-L289 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaNode._nacm_default_deny_stmt | def _nacm_default_deny_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Set NACM default access."""
if not hasattr(self, 'default_deny'):
return
if stmt.keyword == "default-deny-all":
self.default_deny = DefaultDeny.all
elif stmt.keyword == "default-de... | python | def _nacm_default_deny_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Set NACM default access."""
if not hasattr(self, 'default_deny'):
return
if stmt.keyword == "default-deny-all":
self.default_deny = DefaultDeny.all
elif stmt.keyword == "default-de... | [
"def",
"_nacm_default_deny_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'default_deny'",
")",
":",
"return",
"if",
"stmt",
".",
"keyword",
"==",
"... | Set NACM default access. | [
"Set",
"NACM",
"default",
"access",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L294-L301 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode.get_child | def get_child(self, name: YangIdentifier,
ns: YangIdentifier = None) -> Optional[SchemaNode]:
"""Return receiver's schema child.
Args:
name: Child's name.
ns: Child's namespace (= `self.ns` if absent).
"""
ns = ns if ns else self.ns
todo... | python | def get_child(self, name: YangIdentifier,
ns: YangIdentifier = None) -> Optional[SchemaNode]:
"""Return receiver's schema child.
Args:
name: Child's name.
ns: Child's namespace (= `self.ns` if absent).
"""
ns = ns if ns else self.ns
todo... | [
"def",
"get_child",
"(",
"self",
",",
"name",
":",
"YangIdentifier",
",",
"ns",
":",
"YangIdentifier",
"=",
"None",
")",
"->",
"Optional",
"[",
"SchemaNode",
"]",
":",
"ns",
"=",
"ns",
"if",
"ns",
"else",
"self",
".",
"ns",
"todo",
"=",
"[",
"]",
"... | Return receiver's schema child.
Args:
name: Child's name.
ns: Child's namespace (= `self.ns` if absent). | [
"Return",
"receiver",
"s",
"schema",
"child",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L351-L369 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode.get_schema_descendant | def get_schema_descendant(
self, route: SchemaRoute) -> Optional[SchemaNode]:
"""Return descendant schema node or ``None`` if not found.
Args:
route: Schema route to the descendant node
(relative to the receiver).
"""
node = self
for p ... | python | def get_schema_descendant(
self, route: SchemaRoute) -> Optional[SchemaNode]:
"""Return descendant schema node or ``None`` if not found.
Args:
route: Schema route to the descendant node
(relative to the receiver).
"""
node = self
for p ... | [
"def",
"get_schema_descendant",
"(",
"self",
",",
"route",
":",
"SchemaRoute",
")",
"->",
"Optional",
"[",
"SchemaNode",
"]",
":",
"node",
"=",
"self",
"for",
"p",
"in",
"route",
":",
"node",
"=",
"node",
".",
"get_child",
"(",
"*",
"p",
")",
"if",
"... | Return descendant schema node or ``None`` if not found.
Args:
route: Schema route to the descendant node
(relative to the receiver). | [
"Return",
"descendant",
"schema",
"node",
"or",
"None",
"if",
"not",
"found",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L371-L384 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode.get_data_child | def get_data_child(self, name: YangIdentifier,
ns: YangIdentifier = None) -> Optional["DataNode"]:
"""Return data node directly under the receiver."""
ns = ns if ns else self.ns
todo = []
for child in self.children:
if child.name == name and child.ns ==... | python | def get_data_child(self, name: YangIdentifier,
ns: YangIdentifier = None) -> Optional["DataNode"]:
"""Return data node directly under the receiver."""
ns = ns if ns else self.ns
todo = []
for child in self.children:
if child.name == name and child.ns ==... | [
"def",
"get_data_child",
"(",
"self",
",",
"name",
":",
"YangIdentifier",
",",
"ns",
":",
"YangIdentifier",
"=",
"None",
")",
"->",
"Optional",
"[",
"\"DataNode\"",
"]",
":",
"ns",
"=",
"ns",
"if",
"ns",
"else",
"self",
".",
"ns",
"todo",
"=",
"[",
"... | Return data node directly under the receiver. | [
"Return",
"data",
"node",
"directly",
"under",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L386-L401 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode.filter_children | def filter_children(self, ctype: ContentType = None) -> List[SchemaNode]:
"""Return receiver's children based on content type.
Args:
ctype: Content type.
"""
if ctype is None:
ctype = self.content_type()
return [c for c in self.children if
... | python | def filter_children(self, ctype: ContentType = None) -> List[SchemaNode]:
"""Return receiver's children based on content type.
Args:
ctype: Content type.
"""
if ctype is None:
ctype = self.content_type()
return [c for c in self.children if
... | [
"def",
"filter_children",
"(",
"self",
",",
"ctype",
":",
"ContentType",
"=",
"None",
")",
"->",
"List",
"[",
"SchemaNode",
"]",
":",
"if",
"ctype",
"is",
"None",
":",
"ctype",
"=",
"self",
".",
"content_type",
"(",
")",
"return",
"[",
"c",
"for",
"c... | Return receiver's children based on content type.
Args:
ctype: Content type. | [
"Return",
"receiver",
"s",
"children",
"based",
"on",
"content",
"type",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L403-L413 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode.data_children | def data_children(self) -> List["DataNode"]:
"""Return the set of all data nodes directly under the receiver."""
res = []
for child in self.children:
if isinstance(child, DataNode):
res.append(child)
elif not isinstance(child, SchemaTreeNode):
... | python | def data_children(self) -> List["DataNode"]:
"""Return the set of all data nodes directly under the receiver."""
res = []
for child in self.children:
if isinstance(child, DataNode):
res.append(child)
elif not isinstance(child, SchemaTreeNode):
... | [
"def",
"data_children",
"(",
"self",
")",
"->",
"List",
"[",
"\"DataNode\"",
"]",
":",
"res",
"=",
"[",
"]",
"for",
"child",
"in",
"self",
".",
"children",
":",
"if",
"isinstance",
"(",
"child",
",",
"DataNode",
")",
":",
"res",
".",
"append",
"(",
... | Return the set of all data nodes directly under the receiver. | [
"Return",
"the",
"set",
"of",
"all",
"data",
"nodes",
"directly",
"under",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L415-L423 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode.from_raw | def from_raw(self, rval: RawObject, jptr: JSONPointer = "") -> ObjectValue:
"""Override the superclass method."""
if not isinstance(rval, dict):
raise RawTypeError(jptr, "object")
res = ObjectValue()
for qn in rval:
if qn.startswith("@"):
if qn != ... | python | def from_raw(self, rval: RawObject, jptr: JSONPointer = "") -> ObjectValue:
"""Override the superclass method."""
if not isinstance(rval, dict):
raise RawTypeError(jptr, "object")
res = ObjectValue()
for qn in rval:
if qn.startswith("@"):
if qn != ... | [
"def",
"from_raw",
"(",
"self",
",",
"rval",
":",
"RawObject",
",",
"jptr",
":",
"JSONPointer",
"=",
"\"\"",
")",
"->",
"ObjectValue",
":",
"if",
"not",
"isinstance",
"(",
"rval",
",",
"dict",
")",
":",
"raise",
"RawTypeError",
"(",
"jptr",
",",
"\"obj... | Override the superclass method. | [
"Override",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L425-L445 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._validate | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if scope.value & ValidationScope.syntax.value: # schema
self._check_schema_pattern(inst, ctype)
for m in inst:
inst._memb... | python | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if scope.value & ValidationScope.syntax.value: # schema
self._check_schema_pattern(inst, ctype)
for m in inst:
inst._memb... | [
"def",
"_validate",
"(",
"self",
",",
"inst",
":",
"\"InstanceNode\"",
",",
"scope",
":",
"ValidationScope",
",",
"ctype",
":",
"ContentType",
")",
"->",
"None",
":",
"if",
"scope",
".",
"value",
"&",
"ValidationScope",
".",
"syntax",
".",
"value",
":",
... | Extend the superclass method. | [
"Extend",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L471-L478 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._child_inst_names | def _child_inst_names(self) -> Set[InstanceName]:
"""Return the set of instance names under the receiver."""
return frozenset([c.iname() for c in self.data_children()]) | python | def _child_inst_names(self) -> Set[InstanceName]:
"""Return the set of instance names under the receiver."""
return frozenset([c.iname() for c in self.data_children()]) | [
"def",
"_child_inst_names",
"(",
"self",
")",
"->",
"Set",
"[",
"InstanceName",
"]",
":",
"return",
"frozenset",
"(",
"[",
"c",
".",
"iname",
"(",
")",
"for",
"c",
"in",
"self",
".",
"data_children",
"(",
")",
"]",
")"
] | Return the set of instance names under the receiver. | [
"Return",
"the",
"set",
"of",
"instance",
"names",
"under",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L484-L486 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._make_schema_patterns | def _make_schema_patterns(self) -> None:
"""Build schema pattern for the receiver and its data descendants."""
self.schema_pattern = self._schema_pattern()
for dc in self.data_children():
if isinstance(dc, InternalNode):
dc._make_schema_patterns() | python | def _make_schema_patterns(self) -> None:
"""Build schema pattern for the receiver and its data descendants."""
self.schema_pattern = self._schema_pattern()
for dc in self.data_children():
if isinstance(dc, InternalNode):
dc._make_schema_patterns() | [
"def",
"_make_schema_patterns",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"schema_pattern",
"=",
"self",
".",
"_schema_pattern",
"(",
")",
"for",
"dc",
"in",
"self",
".",
"data_children",
"(",
")",
":",
"if",
"isinstance",
"(",
"dc",
",",
"Intern... | Build schema pattern for the receiver and its data descendants. | [
"Build",
"schema",
"pattern",
"for",
"the",
"receiver",
"and",
"its",
"data",
"descendants",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L506-L511 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._handle_child | def _handle_child(
self, node: SchemaNode, stmt: Statement, sctx: SchemaContext) -> None:
"""Add child node to the receiver and handle substatements."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
node.name = stmt.argument
node.ns = sctx.defau... | python | def _handle_child(
self, node: SchemaNode, stmt: Statement, sctx: SchemaContext) -> None:
"""Add child node to the receiver and handle substatements."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
node.name = stmt.argument
node.ns = sctx.defau... | [
"def",
"_handle_child",
"(",
"self",
",",
"node",
":",
"SchemaNode",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"if",
"not",
"sctx",
".",
"schema_data",
".",
"if_features",
"(",
"stmt",
",",
"sctx",
".",
"... | Add child node to the receiver and handle substatements. | [
"Add",
"child",
"node",
"to",
"the",
"receiver",
"and",
"handle",
"substatements",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L549-L558 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._augment_stmt | def _augment_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **augment** statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
path = sctx.schema_data.sni2route(stmt.argument, sctx)
target = self.get_schema_descendant(path)
... | python | def _augment_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **augment** statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
path = sctx.schema_data.sni2route(stmt.argument, sctx)
target = self.get_schema_descendant(path)
... | [
"def",
"_augment_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"if",
"not",
"sctx",
".",
"schema_data",
".",
"if_features",
"(",
"stmt",
",",
"sctx",
".",
"text_mid",
")",
":",
"return",
"... | Handle **augment** statement. | [
"Handle",
"**",
"augment",
"**",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L560-L570 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._refine_stmt | def _refine_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **refine** statement."""
target = self.get_schema_descendant(
sctx.schema_data.sni2route(stmt.argument, sctx))
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
target.parent.children.... | python | def _refine_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **refine** statement."""
target = self.get_schema_descendant(
sctx.schema_data.sni2route(stmt.argument, sctx))
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
target.parent.children.... | [
"def",
"_refine_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"target",
"=",
"self",
".",
"get_schema_descendant",
"(",
"sctx",
".",
"schema_data",
".",
"sni2route",
"(",
"stmt",
".",
"argumen... | Handle **refine** statement. | [
"Handle",
"**",
"refine",
"**",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L572-L579 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._uses_stmt | def _uses_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle uses statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
grp, gid = sctx.schema_data.get_definition(stmt, sctx)
if stmt.find1("when"):
sn = GroupNode()
... | python | def _uses_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle uses statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
grp, gid = sctx.schema_data.get_definition(stmt, sctx)
if stmt.find1("when"):
sn = GroupNode()
... | [
"def",
"_uses_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"if",
"not",
"sctx",
".",
"schema_data",
".",
"if_features",
"(",
"stmt",
",",
"sctx",
".",
"text_mid",
")",
":",
"return",
"grp... | Handle uses statement. | [
"Handle",
"uses",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L581-L595 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._container_stmt | def _container_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle container statement."""
self._handle_child(ContainerNode(), stmt, sctx) | python | def _container_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle container statement."""
self._handle_child(ContainerNode(), stmt, sctx) | [
"def",
"_container_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"ContainerNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle container statement. | [
"Handle",
"container",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L597-L599 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._identity_stmt | def _identity_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle identity statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
id = (stmt.argument, sctx.schema_data.namespace(sctx.text_mid))
adj = sctx.schema_data.identity_adjs.setde... | python | def _identity_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle identity statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
id = (stmt.argument, sctx.schema_data.namespace(sctx.text_mid))
adj = sctx.schema_data.identity_adjs.setde... | [
"def",
"_identity_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"if",
"not",
"sctx",
".",
"schema_data",
".",
"if_features",
"(",
"stmt",
",",
"sctx",
".",
"text_mid",
")",
":",
"return",
... | Handle identity statement. | [
"Handle",
"identity",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L601-L613 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._list_stmt | def _list_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle list statement."""
self._handle_child(ListNode(), stmt, sctx) | python | def _list_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle list statement."""
self._handle_child(ListNode(), stmt, sctx) | [
"def",
"_list_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"ListNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle list statement. | [
"Handle",
"list",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L615-L617 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._choice_stmt | def _choice_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle choice statement."""
self._handle_child(ChoiceNode(), stmt, sctx) | python | def _choice_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle choice statement."""
self._handle_child(ChoiceNode(), stmt, sctx) | [
"def",
"_choice_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"ChoiceNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle choice statement. | [
"Handle",
"choice",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L619-L621 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._case_stmt | def _case_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle case statement."""
self._handle_child(CaseNode(), stmt, sctx) | python | def _case_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle case statement."""
self._handle_child(CaseNode(), stmt, sctx) | [
"def",
"_case_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"CaseNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle case statement. | [
"Handle",
"case",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L623-L625 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._leaf_stmt | def _leaf_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle leaf statement."""
node = LeafNode()
node.type = DataType._resolve_type(
stmt.find1("type", required=True), sctx)
self._handle_child(node, stmt, sctx) | python | def _leaf_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle leaf statement."""
node = LeafNode()
node.type = DataType._resolve_type(
stmt.find1("type", required=True), sctx)
self._handle_child(node, stmt, sctx) | [
"def",
"_leaf_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"node",
"=",
"LeafNode",
"(",
")",
"node",
".",
"type",
"=",
"DataType",
".",
"_resolve_type",
"(",
"stmt",
".",
"find1",
"(",
... | Handle leaf statement. | [
"Handle",
"leaf",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L627-L632 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._leaf_list_stmt | def _leaf_list_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle leaf-list statement."""
node = LeafListNode()
node.type = DataType._resolve_type(
stmt.find1("type", required=True), sctx)
self._handle_child(node, stmt, sctx) | python | def _leaf_list_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle leaf-list statement."""
node = LeafListNode()
node.type = DataType._resolve_type(
stmt.find1("type", required=True), sctx)
self._handle_child(node, stmt, sctx) | [
"def",
"_leaf_list_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"node",
"=",
"LeafListNode",
"(",
")",
"node",
".",
"type",
"=",
"DataType",
".",
"_resolve_type",
"(",
"stmt",
".",
"find1",... | Handle leaf-list statement. | [
"Handle",
"leaf",
"-",
"list",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L634-L639 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._rpc_action_stmt | def _rpc_action_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle rpc or action statement."""
self._handle_child(RpcActionNode(), stmt, sctx) | python | def _rpc_action_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle rpc or action statement."""
self._handle_child(RpcActionNode(), stmt, sctx) | [
"def",
"_rpc_action_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"RpcActionNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle rpc or action statement. | [
"Handle",
"rpc",
"or",
"action",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L641-L643 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._notification_stmt | def _notification_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle notification statement."""
self._handle_child(NotificationNode(), stmt, sctx) | python | def _notification_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle notification statement."""
self._handle_child(NotificationNode(), stmt, sctx) | [
"def",
"_notification_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"NotificationNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle notification statement. | [
"Handle",
"notification",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L645-L647 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._anydata_stmt | def _anydata_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle anydata statement."""
self._handle_child(AnydataNode(), stmt, sctx) | python | def _anydata_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle anydata statement."""
self._handle_child(AnydataNode(), stmt, sctx) | [
"def",
"_anydata_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"_handle_child",
"(",
"AnydataNode",
"(",
")",
",",
"stmt",
",",
"sctx",
")"
] | Handle anydata statement. | [
"Handle",
"anydata",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L649-L651 |
CZ-NIC/yangson | yangson/schemanode.py | InternalNode._ascii_tree | def _ascii_tree(self, indent: str, no_types: bool, val_count: bool) -> str:
"""Return the receiver's subtree as ASCII art."""
def suffix(sn):
return f" {{{sn.val_count}}}\n" if val_count else "\n"
if not self.children:
return ""
cs = []
for c in self.child... | python | def _ascii_tree(self, indent: str, no_types: bool, val_count: bool) -> str:
"""Return the receiver's subtree as ASCII art."""
def suffix(sn):
return f" {{{sn.val_count}}}\n" if val_count else "\n"
if not self.children:
return ""
cs = []
for c in self.child... | [
"def",
"_ascii_tree",
"(",
"self",
",",
"indent",
":",
"str",
",",
"no_types",
":",
"bool",
",",
"val_count",
":",
"bool",
")",
"->",
"str",
":",
"def",
"suffix",
"(",
"sn",
")",
":",
"return",
"f\" {{{sn.val_count}}}\\n\"",
"if",
"val_count",
"else",
"\... | Return the receiver's subtree as ASCII art. | [
"Return",
"the",
"receiver",
"s",
"subtree",
"as",
"ASCII",
"art",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L653-L668 |
CZ-NIC/yangson | yangson/schemanode.py | SchemaTreeNode._annotation_stmt | def _annotation_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle annotation statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
dst = stmt.find1("description")
self.annotations[(stmt.argument, sctx.default_ns)] = Annotation(
... | python | def _annotation_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle annotation statement."""
if not sctx.schema_data.if_features(stmt, sctx.text_mid):
return
dst = stmt.find1("description")
self.annotations[(stmt.argument, sctx.default_ns)] = Annotation(
... | [
"def",
"_annotation_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"if",
"not",
"sctx",
".",
"schema_data",
".",
"if_features",
"(",
"stmt",
",",
"sctx",
".",
"text_mid",
")",
":",
"return",
... | Handle annotation statement. | [
"Handle",
"annotation",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L713-L720 |
CZ-NIC/yangson | yangson/schemanode.py | DataNode.orphan_instance | def orphan_instance(self, rval: RawValue) -> "ObjectMember":
"""Return an isolated instance of the receiver.
Args:
rval: Raw value to be used for the returned instance.
"""
val = self.from_raw(rval)
return ObjectMember(self.iname(), {}, val, None, self, datetime.now(... | python | def orphan_instance(self, rval: RawValue) -> "ObjectMember":
"""Return an isolated instance of the receiver.
Args:
rval: Raw value to be used for the returned instance.
"""
val = self.from_raw(rval)
return ObjectMember(self.iname(), {}, val, None, self, datetime.now(... | [
"def",
"orphan_instance",
"(",
"self",
",",
"rval",
":",
"RawValue",
")",
"->",
"\"ObjectMember\"",
":",
"val",
"=",
"self",
".",
"from_raw",
"(",
"rval",
")",
"return",
"ObjectMember",
"(",
"self",
".",
"iname",
"(",
")",
",",
"{",
"}",
",",
"val",
... | Return an isolated instance of the receiver.
Args:
rval: Raw value to be used for the returned instance. | [
"Return",
"an",
"isolated",
"instance",
"of",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L731-L738 |
CZ-NIC/yangson | yangson/schemanode.py | DataNode.split_instance_route | def split_instance_route(self, route: "InstanceRoute") -> Optional[Tuple[
"InstanceRoute", "InstanceRoute"]]:
"""Split `route` into the part up to receiver and the rest.
Args:
route: Absolute instance route (the receiver should correspond to an
instance node on t... | python | def split_instance_route(self, route: "InstanceRoute") -> Optional[Tuple[
"InstanceRoute", "InstanceRoute"]]:
"""Split `route` into the part up to receiver and the rest.
Args:
route: Absolute instance route (the receiver should correspond to an
instance node on t... | [
"def",
"split_instance_route",
"(",
"self",
",",
"route",
":",
"\"InstanceRoute\"",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"\"InstanceRoute\"",
",",
"\"InstanceRoute\"",
"]",
"]",
":",
"sroute",
"=",
"[",
"]",
"sn",
"=",
"self",
"while",
"sn",
":",
"sro... | Split `route` into the part up to receiver and the rest.
Args:
route: Absolute instance route (the receiver should correspond to an
instance node on this route).
Returns:
A tuple consisting of
- the part of `route` from the root up to and includi... | [
"Split",
"route",
"into",
"the",
"part",
"up",
"to",
"receiver",
"and",
"the",
"rest",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L740-L774 |
CZ-NIC/yangson | yangson/schemanode.py | DataNode._validate | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if scope.value & ValidationScope.semantics.value:
self._check_must(inst) # must expressions
super()._validate(inst, scope, ctype... | python | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if scope.value & ValidationScope.semantics.value:
self._check_must(inst) # must expressions
super()._validate(inst, scope, ctype... | [
"def",
"_validate",
"(",
"self",
",",
"inst",
":",
"\"InstanceNode\"",
",",
"scope",
":",
"ValidationScope",
",",
"ctype",
":",
"ContentType",
")",
"->",
"None",
":",
"if",
"scope",
".",
"value",
"&",
"ValidationScope",
".",
"semantics",
".",
"value",
":",... | Extend the superclass method. | [
"Extend",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L776-L781 |
CZ-NIC/yangson | yangson/schemanode.py | TerminalNode.content_type | def content_type(self) -> ContentType:
"""Override superclass method."""
if self._ctype:
return self._ctype
return (ContentType.config if self.parent.config else
ContentType.nonconfig) | python | def content_type(self) -> ContentType:
"""Override superclass method."""
if self._ctype:
return self._ctype
return (ContentType.config if self.parent.config else
ContentType.nonconfig) | [
"def",
"content_type",
"(",
"self",
")",
"->",
"ContentType",
":",
"if",
"self",
".",
"_ctype",
":",
"return",
"self",
".",
"_ctype",
"return",
"(",
"ContentType",
".",
"config",
"if",
"self",
".",
"parent",
".",
"config",
"else",
"ContentType",
".",
"no... | Override superclass method. | [
"Override",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L819-L824 |
CZ-NIC/yangson | yangson/schemanode.py | TerminalNode.from_raw | def from_raw(self, rval: RawScalar, jptr: JSONPointer = "") -> ScalarValue:
"""Override the superclass method."""
res = self.type.from_raw(rval)
if res is None:
raise RawTypeError(jptr, self.type.yang_type() + " value")
return res | python | def from_raw(self, rval: RawScalar, jptr: JSONPointer = "") -> ScalarValue:
"""Override the superclass method."""
res = self.type.from_raw(rval)
if res is None:
raise RawTypeError(jptr, self.type.yang_type() + " value")
return res | [
"def",
"from_raw",
"(",
"self",
",",
"rval",
":",
"RawScalar",
",",
"jptr",
":",
"JSONPointer",
"=",
"\"\"",
")",
"->",
"ScalarValue",
":",
"res",
"=",
"self",
".",
"type",
".",
"from_raw",
"(",
"rval",
")",
"if",
"res",
"is",
"None",
":",
"raise",
... | Override the superclass method. | [
"Override",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L826-L831 |
CZ-NIC/yangson | yangson/schemanode.py | TerminalNode._validate | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if (scope.value & ValidationScope.syntax.value and
inst.value not in self.type):
raise YangTypeError(inst.json_pointer(), self.... | python | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if (scope.value & ValidationScope.syntax.value and
inst.value not in self.type):
raise YangTypeError(inst.json_pointer(), self.... | [
"def",
"_validate",
"(",
"self",
",",
"inst",
":",
"\"InstanceNode\"",
",",
"scope",
":",
"ValidationScope",
",",
"ctype",
":",
"ContentType",
")",
"->",
"None",
":",
"if",
"(",
"scope",
".",
"value",
"&",
"ValidationScope",
".",
"syntax",
".",
"value",
... | Extend the superclass method. | [
"Extend",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L841-L857 |
CZ-NIC/yangson | yangson/schemanode.py | ContainerNode._tree_line | def _tree_line(self, no_type: bool = False) -> str:
"""Return the receiver's contribution to tree diagram."""
return super()._tree_line() + ("!" if self.presence else "") | python | def _tree_line(self, no_type: bool = False) -> str:
"""Return the receiver's contribution to tree diagram."""
return super()._tree_line() + ("!" if self.presence else "") | [
"def",
"_tree_line",
"(",
"self",
",",
"no_type",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"return",
"super",
"(",
")",
".",
"_tree_line",
"(",
")",
"+",
"(",
"\"!\"",
"if",
"self",
".",
"presence",
"else",
"\"\"",
")"
] | Return the receiver's contribution to tree diagram. | [
"Return",
"the",
"receiver",
"s",
"contribution",
"to",
"tree",
"diagram",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L931-L933 |
CZ-NIC/yangson | yangson/schemanode.py | SequenceNode._validate | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if isinstance(inst, ArrayEntry):
super()._validate(inst, scope, ctype)
else:
if scope.value & ValidationScope.semantics.val... | python | def _validate(self, inst: "InstanceNode", scope: ValidationScope,
ctype: ContentType) -> None:
"""Extend the superclass method."""
if isinstance(inst, ArrayEntry):
super()._validate(inst, scope, ctype)
else:
if scope.value & ValidationScope.semantics.val... | [
"def",
"_validate",
"(",
"self",
",",
"inst",
":",
"\"InstanceNode\"",
",",
"scope",
":",
"ValidationScope",
",",
"ctype",
":",
"ContentType",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"inst",
",",
"ArrayEntry",
")",
":",
"super",
"(",
")",
".",
... | Extend the superclass method. | [
"Extend",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L951-L961 |
CZ-NIC/yangson | yangson/schemanode.py | SequenceNode.from_raw | def from_raw(self, rval: RawList, jptr: JSONPointer = "") -> ArrayValue:
"""Override the superclass method."""
if not isinstance(rval, list):
raise RawTypeError(jptr, "array")
res = ArrayValue()
i = 0
for en in rval:
i += 1
res.append(self.entr... | python | def from_raw(self, rval: RawList, jptr: JSONPointer = "") -> ArrayValue:
"""Override the superclass method."""
if not isinstance(rval, list):
raise RawTypeError(jptr, "array")
res = ArrayValue()
i = 0
for en in rval:
i += 1
res.append(self.entr... | [
"def",
"from_raw",
"(",
"self",
",",
"rval",
":",
"RawList",
",",
"jptr",
":",
"JSONPointer",
"=",
"\"\"",
")",
"->",
"ArrayValue",
":",
"if",
"not",
"isinstance",
"(",
"rval",
",",
"list",
")",
":",
"raise",
"RawTypeError",
"(",
"jptr",
",",
"\"array\... | Override the superclass method. | [
"Override",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L992-L1001 |
CZ-NIC/yangson | yangson/schemanode.py | SequenceNode.entry_from_raw | def entry_from_raw(self, rval: RawEntry, jptr: JSONPointer = "") -> EntryValue:
"""Transform a raw (leaf-)list entry into the cooked form.
Args:
rval: raw entry (scalar or object)
jptr: JSON pointer of the entry
Raises:
NonexistentSchemaNode: If a member ins... | python | def entry_from_raw(self, rval: RawEntry, jptr: JSONPointer = "") -> EntryValue:
"""Transform a raw (leaf-)list entry into the cooked form.
Args:
rval: raw entry (scalar or object)
jptr: JSON pointer of the entry
Raises:
NonexistentSchemaNode: If a member ins... | [
"def",
"entry_from_raw",
"(",
"self",
",",
"rval",
":",
"RawEntry",
",",
"jptr",
":",
"JSONPointer",
"=",
"\"\"",
")",
"->",
"EntryValue",
":",
"return",
"super",
"(",
")",
".",
"from_raw",
"(",
"rval",
",",
"jptr",
")"
] | Transform a raw (leaf-)list entry into the cooked form.
Args:
rval: raw entry (scalar or object)
jptr: JSON pointer of the entry
Raises:
NonexistentSchemaNode: If a member inside `rval` is not defined
in the schema.
RawTypeError: If a sca... | [
"Transform",
"a",
"raw",
"(",
"leaf",
"-",
")",
"list",
"entry",
"into",
"the",
"cooked",
"form",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1003-L1015 |
CZ-NIC/yangson | yangson/schemanode.py | ListNode._check_list_props | def _check_list_props(self, inst: "InstanceNode") -> None:
"""Check uniqueness of keys and "unique" properties, if applicable."""
if self.keys:
self._check_keys(inst)
for u in self.unique:
self._check_unique(u, inst) | python | def _check_list_props(self, inst: "InstanceNode") -> None:
"""Check uniqueness of keys and "unique" properties, if applicable."""
if self.keys:
self._check_keys(inst)
for u in self.unique:
self._check_unique(u, inst) | [
"def",
"_check_list_props",
"(",
"self",
",",
"inst",
":",
"\"InstanceNode\"",
")",
"->",
"None",
":",
"if",
"self",
".",
"keys",
":",
"self",
".",
"_check_keys",
"(",
"inst",
")",
"for",
"u",
"in",
"self",
".",
"unique",
":",
"self",
".",
"_check_uniq... | Check uniqueness of keys and "unique" properties, if applicable. | [
"Check",
"uniqueness",
"of",
"keys",
"and",
"unique",
"properties",
"if",
"applicable",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1033-L1038 |
CZ-NIC/yangson | yangson/schemanode.py | ListNode._tree_line | def _tree_line(self, no_type: bool = False) -> str:
"""Return the receiver's contribution to tree diagram."""
keys = (" [" + " ".join([k[0] for k in self.keys]) + "]"
if self.keys else "")
return super()._tree_line() + keys | python | def _tree_line(self, no_type: bool = False) -> str:
"""Return the receiver's contribution to tree diagram."""
keys = (" [" + " ".join([k[0] for k in self.keys]) + "]"
if self.keys else "")
return super()._tree_line() + keys | [
"def",
"_tree_line",
"(",
"self",
",",
"no_type",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"keys",
"=",
"(",
"\" [\"",
"+",
"\" \"",
".",
"join",
"(",
"[",
"k",
"[",
"0",
"]",
"for",
"k",
"in",
"self",
".",
"keys",
"]",
")",
"+",
"\"... | Return the receiver's contribution to tree diagram. | [
"Return",
"the",
"receiver",
"s",
"contribution",
"to",
"tree",
"diagram",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1090-L1094 |
CZ-NIC/yangson | yangson/schemanode.py | ListNode.orphan_entry | def orphan_entry(self, rval: RawObject) -> "ArrayEntry":
"""Return an isolated entry of the receiver.
Args:
rval: Raw object to be used for the returned entry.
"""
val = self.entry_from_raw(rval)
return ArrayEntry(0, EmptyList(), EmptyList(), val, None, self,
... | python | def orphan_entry(self, rval: RawObject) -> "ArrayEntry":
"""Return an isolated entry of the receiver.
Args:
rval: Raw object to be used for the returned entry.
"""
val = self.entry_from_raw(rval)
return ArrayEntry(0, EmptyList(), EmptyList(), val, None, self,
... | [
"def",
"orphan_entry",
"(",
"self",
",",
"rval",
":",
"RawObject",
")",
"->",
"\"ArrayEntry\"",
":",
"val",
"=",
"self",
".",
"entry_from_raw",
"(",
"rval",
")",
"return",
"ArrayEntry",
"(",
"0",
",",
"EmptyList",
"(",
")",
",",
"EmptyList",
"(",
")",
... | Return an isolated entry of the receiver.
Args:
rval: Raw object to be used for the returned entry. | [
"Return",
"an",
"isolated",
"entry",
"of",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1096-L1104 |
CZ-NIC/yangson | yangson/schemanode.py | ChoiceNode._active_case | def _active_case(self, value: ObjectValue) -> Optional["CaseNode"]:
"""Return receiver's case that's active in an instance node value."""
for c in self.children:
for cc in c.data_children():
if cc.iname() in value:
return c | python | def _active_case(self, value: ObjectValue) -> Optional["CaseNode"]:
"""Return receiver's case that's active in an instance node value."""
for c in self.children:
for cc in c.data_children():
if cc.iname() in value:
return c | [
"def",
"_active_case",
"(",
"self",
",",
"value",
":",
"ObjectValue",
")",
"->",
"Optional",
"[",
"\"CaseNode\"",
"]",
":",
"for",
"c",
"in",
"self",
".",
"children",
":",
"for",
"cc",
"in",
"c",
".",
"data_children",
"(",
")",
":",
"if",
"cc",
".",
... | Return receiver's case that's active in an instance node value. | [
"Return",
"receiver",
"s",
"case",
"that",
"s",
"active",
"in",
"an",
"instance",
"node",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1138-L1143 |
CZ-NIC/yangson | yangson/schemanode.py | LeafListNode.default | def default(self) -> Optional[ScalarValue]:
"""Default value of the receiver, if any."""
if self.mandatory:
return None
if self._default is not None:
return self._default
return (None if self.type.default is None
else ArrayValue([self.type.default]... | python | def default(self) -> Optional[ScalarValue]:
"""Default value of the receiver, if any."""
if self.mandatory:
return None
if self._default is not None:
return self._default
return (None if self.type.default is None
else ArrayValue([self.type.default]... | [
"def",
"default",
"(",
"self",
")",
"->",
"Optional",
"[",
"ScalarValue",
"]",
":",
"if",
"self",
".",
"mandatory",
":",
"return",
"None",
"if",
"self",
".",
"_default",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_default",
"return",
"(",
"None"... | Default value of the receiver, if any. | [
"Default",
"value",
"of",
"the",
"receiver",
"if",
"any",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1246-L1253 |
CZ-NIC/yangson | yangson/schemanode.py | AnyContentNode.from_raw | def from_raw(self, rval: RawValue, jptr: JSONPointer = "") -> Value:
"""Override the superclass method."""
def convert(val):
if isinstance(val, list):
res = ArrayValue([convert(x) for x in val])
elif isinstance(val, dict):
res = ObjectValue({x: con... | python | def from_raw(self, rval: RawValue, jptr: JSONPointer = "") -> Value:
"""Override the superclass method."""
def convert(val):
if isinstance(val, list):
res = ArrayValue([convert(x) for x in val])
elif isinstance(val, dict):
res = ObjectValue({x: con... | [
"def",
"from_raw",
"(",
"self",
",",
"rval",
":",
"RawValue",
",",
"jptr",
":",
"JSONPointer",
"=",
"\"\"",
")",
"->",
"Value",
":",
"def",
"convert",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"res",
"=",
"ArrayVa... | Override the superclass method. | [
"Override",
"the",
"superclass",
"method",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1297-L1307 |
CZ-NIC/yangson | yangson/schemanode.py | RpcActionNode._input_stmt | def _input_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle RPC or action input statement."""
self.get_child("input")._handle_substatements(stmt, sctx) | python | def _input_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle RPC or action input statement."""
self.get_child("input")._handle_substatements(stmt, sctx) | [
"def",
"_input_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"get_child",
"(",
"\"input\"",
")",
".",
"_handle_substatements",
"(",
"stmt",
",",
"sctx",
")"
] | Handle RPC or action input statement. | [
"Handle",
"RPC",
"or",
"action",
"input",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1354-L1356 |
CZ-NIC/yangson | yangson/schemanode.py | RpcActionNode._output_stmt | def _output_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle RPC or action output statement."""
self.get_child("output")._handle_substatements(stmt, sctx) | python | def _output_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle RPC or action output statement."""
self.get_child("output")._handle_substatements(stmt, sctx) | [
"def",
"_output_stmt",
"(",
"self",
",",
"stmt",
":",
"Statement",
",",
"sctx",
":",
"SchemaContext",
")",
"->",
"None",
":",
"self",
".",
"get_child",
"(",
"\"output\"",
")",
".",
"_handle_substatements",
"(",
"stmt",
",",
"sctx",
")"
] | Handle RPC or action output statement. | [
"Handle",
"RPC",
"or",
"action",
"output",
"statement",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1358-L1360 |
CZ-NIC/yangson | yangson/instance.py | LinkedList.from_list | def from_list(cls, vals: List[Value] = [], reverse: bool = False) -> "LinkedList":
"""Create an instance from a standard list.
Args:
vals: Python list of instance values.
"""
res = EmptyList()
for v in (vals if reverse else vals[::-1]):
res = cls(v, res)
... | python | def from_list(cls, vals: List[Value] = [], reverse: bool = False) -> "LinkedList":
"""Create an instance from a standard list.
Args:
vals: Python list of instance values.
"""
res = EmptyList()
for v in (vals if reverse else vals[::-1]):
res = cls(v, res)
... | [
"def",
"from_list",
"(",
"cls",
",",
"vals",
":",
"List",
"[",
"Value",
"]",
"=",
"[",
"]",
",",
"reverse",
":",
"bool",
"=",
"False",
")",
"->",
"\"LinkedList\"",
":",
"res",
"=",
"EmptyList",
"(",
")",
"for",
"v",
"in",
"(",
"vals",
"if",
"reve... | Create an instance from a standard list.
Args:
vals: Python list of instance values. | [
"Create",
"an",
"instance",
"from",
"a",
"standard",
"list",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L56-L65 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.path | def path(self) -> Tuple[InstanceKey]:
"""Return the list of keys on the path from root to the receiver."""
res = []
inst: InstanceNode = self
while inst.parinst:
res.insert(0, inst._key)
inst = inst.parinst
return tuple(res) | python | def path(self) -> Tuple[InstanceKey]:
"""Return the list of keys on the path from root to the receiver."""
res = []
inst: InstanceNode = self
while inst.parinst:
res.insert(0, inst._key)
inst = inst.parinst
return tuple(res) | [
"def",
"path",
"(",
"self",
")",
"->",
"Tuple",
"[",
"InstanceKey",
"]",
":",
"res",
"=",
"[",
"]",
"inst",
":",
"InstanceNode",
"=",
"self",
"while",
"inst",
".",
"parinst",
":",
"res",
".",
"insert",
"(",
"0",
",",
"inst",
".",
"_key",
")",
"in... | Return the list of keys on the path from root to the receiver. | [
"Return",
"the",
"list",
"of",
"keys",
"on",
"the",
"path",
"from",
"root",
"to",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L151-L158 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.put_member | def put_member(self, name: InstanceName, value: Value,
raw: bool = False) -> "InstanceNode":
"""Return receiver's member with a new value.
If the member is permitted by the schema but doesn't exist, it
is created.
Args:
name: Instance name of the member.
... | python | def put_member(self, name: InstanceName, value: Value,
raw: bool = False) -> "InstanceNode":
"""Return receiver's member with a new value.
If the member is permitted by the schema but doesn't exist, it
is created.
Args:
name: Instance name of the member.
... | [
"def",
"put_member",
"(",
"self",
",",
"name",
":",
"InstanceName",
",",
"value",
":",
"Value",
",",
"raw",
":",
"bool",
"=",
"False",
")",
"->",
"\"InstanceNode\"",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"value",
",",
"ObjectValue",
")",
":... | Return receiver's member with a new value.
If the member is permitted by the schema but doesn't exist, it
is created.
Args:
name: Instance name of the member.
value: New value of the member.
raw: Flag to be set if `value` is raw.
Raises:
... | [
"Return",
"receiver",
"s",
"member",
"with",
"a",
"new",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L213-L235 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.delete_item | def delete_item(self, key: InstanceKey) -> "InstanceNode":
"""Delete an item (member or entry) from receiver's value.
Args:
key: Key of the item (instance name or index).
Raises:
NonexistentInstance: If receiver's value doesn't contain the item.
InstanceValu... | python | def delete_item(self, key: InstanceKey) -> "InstanceNode":
"""Delete an item (member or entry) from receiver's value.
Args:
key: Key of the item (instance name or index).
Raises:
NonexistentInstance: If receiver's value doesn't contain the item.
InstanceValu... | [
"def",
"delete_item",
"(",
"self",
",",
"key",
":",
"InstanceKey",
")",
"->",
"\"InstanceNode\"",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"value",
",",
"StructuredValue",
")",
":",
"raise",
"InstanceValueError",
"(",
"self",
".",
"json_pointer",
"(... | Delete an item (member or entry) from receiver's value.
Args:
key: Key of the item (instance name or index).
Raises:
NonexistentInstance: If receiver's value doesn't contain the item.
InstanceValueError: If the receiver's value is a scalar. | [
"Delete",
"an",
"item",
"(",
"member",
"or",
"entry",
")",
"from",
"receiver",
"s",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L237-L255 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.up | def up(self) -> "InstanceNode":
"""Return an instance node corresponding to the receiver's parent.
Raises:
NonexistentInstance: If there is no parent.
"""
ts = max(self.timestamp, self.parinst.timestamp)
return self.parinst._copy(self._zip(), ts) | python | def up(self) -> "InstanceNode":
"""Return an instance node corresponding to the receiver's parent.
Raises:
NonexistentInstance: If there is no parent.
"""
ts = max(self.timestamp, self.parinst.timestamp)
return self.parinst._copy(self._zip(), ts) | [
"def",
"up",
"(",
"self",
")",
"->",
"\"InstanceNode\"",
":",
"ts",
"=",
"max",
"(",
"self",
".",
"timestamp",
",",
"self",
".",
"parinst",
".",
"timestamp",
")",
"return",
"self",
".",
"parinst",
".",
"_copy",
"(",
"self",
".",
"_zip",
"(",
")",
"... | Return an instance node corresponding to the receiver's parent.
Raises:
NonexistentInstance: If there is no parent. | [
"Return",
"an",
"instance",
"node",
"corresponding",
"to",
"the",
"receiver",
"s",
"parent",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L257-L264 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.top | def top(self) -> "InstanceNode":
"""Return an instance node corresponding to the root of the data tree."""
inst = self
while inst.parinst:
inst = inst.up()
return inst | python | def top(self) -> "InstanceNode":
"""Return an instance node corresponding to the root of the data tree."""
inst = self
while inst.parinst:
inst = inst.up()
return inst | [
"def",
"top",
"(",
"self",
")",
"->",
"\"InstanceNode\"",
":",
"inst",
"=",
"self",
"while",
"inst",
".",
"parinst",
":",
"inst",
"=",
"inst",
".",
"up",
"(",
")",
"return",
"inst"
] | Return an instance node corresponding to the root of the data tree. | [
"Return",
"an",
"instance",
"node",
"corresponding",
"to",
"the",
"root",
"of",
"the",
"data",
"tree",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L266-L271 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.update | def update(self, value: Union[RawValue, Value],
raw: bool = False) -> "InstanceNode":
"""Update the receiver's value.
Args:
value: New value.
raw: Flag to be set if `value` is raw.
Returns:
Copy of the receiver with the updated value.
... | python | def update(self, value: Union[RawValue, Value],
raw: bool = False) -> "InstanceNode":
"""Update the receiver's value.
Args:
value: New value.
raw: Flag to be set if `value` is raw.
Returns:
Copy of the receiver with the updated value.
... | [
"def",
"update",
"(",
"self",
",",
"value",
":",
"Union",
"[",
"RawValue",
",",
"Value",
"]",
",",
"raw",
":",
"bool",
"=",
"False",
")",
"->",
"\"InstanceNode\"",
":",
"newval",
"=",
"self",
".",
"schema_node",
".",
"from_raw",
"(",
"value",
",",
"s... | Update the receiver's value.
Args:
value: New value.
raw: Flag to be set if `value` is raw.
Returns:
Copy of the receiver with the updated value. | [
"Update",
"the",
"receiver",
"s",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L273-L286 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.goto | def goto(self, iroute: "InstanceRoute") -> "InstanceNode":
"""Move the focus to an instance inside the receiver's value.
Args:
iroute: Instance route (relative to the receiver).
Returns:
The instance node corresponding to the target instance.
Raises:
... | python | def goto(self, iroute: "InstanceRoute") -> "InstanceNode":
"""Move the focus to an instance inside the receiver's value.
Args:
iroute: Instance route (relative to the receiver).
Returns:
The instance node corresponding to the target instance.
Raises:
... | [
"def",
"goto",
"(",
"self",
",",
"iroute",
":",
"\"InstanceRoute\"",
")",
"->",
"\"InstanceNode\"",
":",
"inst",
"=",
"self",
"for",
"sel",
"in",
"iroute",
":",
"inst",
"=",
"sel",
".",
"goto_step",
"(",
"inst",
")",
"return",
"inst"
] | Move the focus to an instance inside the receiver's value.
Args:
iroute: Instance route (relative to the receiver).
Returns:
The instance node corresponding to the target instance.
Raises:
InstanceValueError: If `iroute` is incompatible with the receiver's
... | [
"Move",
"the",
"focus",
"to",
"an",
"instance",
"inside",
"the",
"receiver",
"s",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L288-L307 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.peek | def peek(self, iroute: "InstanceRoute") -> Optional[Value]:
"""Return a value within the receiver's subtree.
Args:
iroute: Instance route (relative to the receiver).
"""
val = self.value
sn = self.schema_node
for sel in iroute:
val, sn = sel.peek_... | python | def peek(self, iroute: "InstanceRoute") -> Optional[Value]:
"""Return a value within the receiver's subtree.
Args:
iroute: Instance route (relative to the receiver).
"""
val = self.value
sn = self.schema_node
for sel in iroute:
val, sn = sel.peek_... | [
"def",
"peek",
"(",
"self",
",",
"iroute",
":",
"\"InstanceRoute\"",
")",
"->",
"Optional",
"[",
"Value",
"]",
":",
"val",
"=",
"self",
".",
"value",
"sn",
"=",
"self",
".",
"schema_node",
"for",
"sel",
"in",
"iroute",
":",
"val",
",",
"sn",
"=",
"... | Return a value within the receiver's subtree.
Args:
iroute: Instance route (relative to the receiver). | [
"Return",
"a",
"value",
"within",
"the",
"receiver",
"s",
"subtree",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L309-L321 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.validate | def validate(self, scope: ValidationScope = ValidationScope.all,
ctype: ContentType = ContentType.config) -> None:
"""Validate the receiver's value.
Args:
scope: Scope of the validation (syntax, semantics or all).
ctype: Receiver's content type.
Raises:... | python | def validate(self, scope: ValidationScope = ValidationScope.all,
ctype: ContentType = ContentType.config) -> None:
"""Validate the receiver's value.
Args:
scope: Scope of the validation (syntax, semantics or all).
ctype: Receiver's content type.
Raises:... | [
"def",
"validate",
"(",
"self",
",",
"scope",
":",
"ValidationScope",
"=",
"ValidationScope",
".",
"all",
",",
"ctype",
":",
"ContentType",
"=",
"ContentType",
".",
"config",
")",
"->",
"None",
":",
"self",
".",
"schema_node",
".",
"_validate",
"(",
"self"... | Validate the receiver's value.
Args:
scope: Scope of the validation (syntax, semantics or all).
ctype: Receiver's content type.
Raises:
SchemaError: If the value doesn't conform to the schema.
SemanticError: If the value violates a semantic constraint.
... | [
"Validate",
"the",
"receiver",
"s",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L323-L336 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.add_defaults | def add_defaults(self, ctype: ContentType = None) -> "InstanceNode":
"""Return the receiver with defaults added recursively to its value.
Args:
ctype: Content type of the defaults to be added. If it is
``None``, the content type will be the same as receiver's.
"""
... | python | def add_defaults(self, ctype: ContentType = None) -> "InstanceNode":
"""Return the receiver with defaults added recursively to its value.
Args:
ctype: Content type of the defaults to be added. If it is
``None``, the content type will be the same as receiver's.
"""
... | [
"def",
"add_defaults",
"(",
"self",
",",
"ctype",
":",
"ContentType",
"=",
"None",
")",
"->",
"\"InstanceNode\"",
":",
"val",
"=",
"self",
".",
"value",
"if",
"not",
"(",
"isinstance",
"(",
"val",
",",
"StructuredValue",
")",
"and",
"self",
".",
"is_inte... | Return the receiver with defaults added recursively to its value.
Args:
ctype: Content type of the defaults to be added. If it is
``None``, the content type will be the same as receiver's. | [
"Return",
"the",
"receiver",
"with",
"defaults",
"added",
"recursively",
"to",
"its",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L338-L365 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode.raw_value | def raw_value(self) -> RawValue:
"""Return receiver's value in a raw form (ready for JSON encoding)."""
if isinstance(self.value, ObjectValue):
return {m: self._member(m).raw_value() for m in self.value}
if isinstance(self.value, ArrayValue):
return [en.raw_value() for en... | python | def raw_value(self) -> RawValue:
"""Return receiver's value in a raw form (ready for JSON encoding)."""
if isinstance(self.value, ObjectValue):
return {m: self._member(m).raw_value() for m in self.value}
if isinstance(self.value, ArrayValue):
return [en.raw_value() for en... | [
"def",
"raw_value",
"(",
"self",
")",
"->",
"RawValue",
":",
"if",
"isinstance",
"(",
"self",
".",
"value",
",",
"ObjectValue",
")",
":",
"return",
"{",
"m",
":",
"self",
".",
"_member",
"(",
"m",
")",
".",
"raw_value",
"(",
")",
"for",
"m",
"in",
... | Return receiver's value in a raw form (ready for JSON encoding). | [
"Return",
"receiver",
"s",
"value",
"in",
"a",
"raw",
"form",
"(",
"ready",
"for",
"JSON",
"encoding",
")",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L367-L373 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode._node_set | def _node_set(self) -> List["InstanceNode"]:
"""XPath - return the list of all receiver's nodes."""
return list(self) if isinstance(self.value, ArrayValue) else [self] | python | def _node_set(self) -> List["InstanceNode"]:
"""XPath - return the list of all receiver's nodes."""
return list(self) if isinstance(self.value, ArrayValue) else [self] | [
"def",
"_node_set",
"(",
"self",
")",
"->",
"List",
"[",
"\"InstanceNode\"",
"]",
":",
"return",
"list",
"(",
"self",
")",
"if",
"isinstance",
"(",
"self",
".",
"value",
",",
"ArrayValue",
")",
"else",
"[",
"self",
"]"
] | XPath - return the list of all receiver's nodes. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"all",
"receiver",
"s",
"nodes",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L418-L420 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode._children | def _children(self, qname:
Union[QualName, bool] = None) -> List["InstanceNode"]:
"""XPath - return the list of receiver's children."""
sn = self.schema_node
if not isinstance(sn, InternalNode):
return []
if qname:
cn = sn.get_data_child(*qname)
... | python | def _children(self, qname:
Union[QualName, bool] = None) -> List["InstanceNode"]:
"""XPath - return the list of receiver's children."""
sn = self.schema_node
if not isinstance(sn, InternalNode):
return []
if qname:
cn = sn.get_data_child(*qname)
... | [
"def",
"_children",
"(",
"self",
",",
"qname",
":",
"Union",
"[",
"QualName",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"\"InstanceNode\"",
"]",
":",
"sn",
"=",
"self",
".",
"schema_node",
"if",
"not",
"isinstance",
"(",
"sn",
",",
"Inte... | XPath - return the list of receiver's children. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"receiver",
"s",
"children",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L422-L450 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode._descendants | def _descendants(self, qname: Union[QualName, bool] = None,
with_self: bool = False) -> List["InstanceNode"]:
"""XPath - return the list of receiver's descendants."""
res = ([] if not with_self or (qname and self.qual_name != qname)
else [self])
for c in self.... | python | def _descendants(self, qname: Union[QualName, bool] = None,
with_self: bool = False) -> List["InstanceNode"]:
"""XPath - return the list of receiver's descendants."""
res = ([] if not with_self or (qname and self.qual_name != qname)
else [self])
for c in self.... | [
"def",
"_descendants",
"(",
"self",
",",
"qname",
":",
"Union",
"[",
"QualName",
",",
"bool",
"]",
"=",
"None",
",",
"with_self",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"\"InstanceNode\"",
"]",
":",
"res",
"=",
"(",
"[",
"]",
"if",
"not... | XPath - return the list of receiver's descendants. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"receiver",
"s",
"descendants",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L452-L461 |
CZ-NIC/yangson | yangson/instance.py | InstanceNode._deref | def _deref(self) -> List["InstanceNode"]:
"""XPath: return the list of nodes that the receiver refers to."""
return ([] if self.is_internal() else
self.schema_node.type._deref(self)) | python | def _deref(self) -> List["InstanceNode"]:
"""XPath: return the list of nodes that the receiver refers to."""
return ([] if self.is_internal() else
self.schema_node.type._deref(self)) | [
"def",
"_deref",
"(",
"self",
")",
"->",
"List",
"[",
"\"InstanceNode\"",
"]",
":",
"return",
"(",
"[",
"]",
"if",
"self",
".",
"is_internal",
"(",
")",
"else",
"self",
".",
"schema_node",
".",
"type",
".",
"_deref",
"(",
"self",
")",
")"
] | XPath: return the list of nodes that the receiver refers to. | [
"XPath",
":",
"return",
"the",
"list",
"of",
"nodes",
"that",
"the",
"receiver",
"refers",
"to",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L477-L480 |
CZ-NIC/yangson | yangson/instance.py | ObjectMember.qual_name | def qual_name(self) -> QualName:
"""Return the receiver's qualified name."""
p, s, loc = self._key.partition(":")
return (loc, p) if s else (p, self.namespace) | python | def qual_name(self) -> QualName:
"""Return the receiver's qualified name."""
p, s, loc = self._key.partition(":")
return (loc, p) if s else (p, self.namespace) | [
"def",
"qual_name",
"(",
"self",
")",
"->",
"QualName",
":",
"p",
",",
"s",
",",
"loc",
"=",
"self",
".",
"_key",
".",
"partition",
"(",
"\":\"",
")",
"return",
"(",
"loc",
",",
"p",
")",
"if",
"s",
"else",
"(",
"p",
",",
"self",
".",
"namespac... | Return the receiver's qualified name. | [
"Return",
"the",
"receiver",
"s",
"qualified",
"name",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L524-L527 |
CZ-NIC/yangson | yangson/instance.py | ObjectMember.sibling | def sibling(self, name: InstanceName) -> "ObjectMember":
"""Return an instance node corresponding to a sibling member.
Args:
name: Instance name of the sibling member.
Raises:
NonexistentSchemaNode: If member `name` is not permitted by the
schema.
... | python | def sibling(self, name: InstanceName) -> "ObjectMember":
"""Return an instance node corresponding to a sibling member.
Args:
name: Instance name of the sibling member.
Raises:
NonexistentSchemaNode: If member `name` is not permitted by the
schema.
... | [
"def",
"sibling",
"(",
"self",
",",
"name",
":",
"InstanceName",
")",
"->",
"\"ObjectMember\"",
":",
"ssn",
"=",
"self",
".",
"parinst",
".",
"_member_schema_node",
"(",
"name",
")",
"try",
":",
"sibs",
"=",
"self",
".",
"siblings",
".",
"copy",
"(",
"... | Return an instance node corresponding to a sibling member.
Args:
name: Instance name of the sibling member.
Raises:
NonexistentSchemaNode: If member `name` is not permitted by the
schema.
NonexistentInstance: If sibling member `name` doesn't exist. | [
"Return",
"an",
"instance",
"node",
"corresponding",
"to",
"a",
"sibling",
"member",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L529-L549 |
CZ-NIC/yangson | yangson/instance.py | ObjectMember.look_up | def look_up(self, **keys: Dict[InstanceName, ScalarValue]) -> "ArrayEntry":
"""Return the entry with matching keys.
Args:
keys: Keys and values specified as keyword arguments.
Raises:
InstanceValueError: If the receiver's value is not a YANG list.
Nonexisten... | python | def look_up(self, **keys: Dict[InstanceName, ScalarValue]) -> "ArrayEntry":
"""Return the entry with matching keys.
Args:
keys: Keys and values specified as keyword arguments.
Raises:
InstanceValueError: If the receiver's value is not a YANG list.
Nonexisten... | [
"def",
"look_up",
"(",
"self",
",",
"*",
"*",
"keys",
":",
"Dict",
"[",
"InstanceName",
",",
"ScalarValue",
"]",
")",
"->",
"\"ArrayEntry\"",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"schema_node",
",",
"ListNode",
")",
":",
"raise",
"InstanceVa... | Return the entry with matching keys.
Args:
keys: Keys and values specified as keyword arguments.
Raises:
InstanceValueError: If the receiver's value is not a YANG list.
NonexistentInstance: If no entry with matching keys exists. | [
"Return",
"the",
"entry",
"with",
"matching",
"keys",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L551-L577 |
CZ-NIC/yangson | yangson/instance.py | ObjectMember._zip | def _zip(self) -> ObjectValue:
"""Zip the receiver into an object and return it."""
res = ObjectValue(self.siblings.copy(), self.timestamp)
res[self.name] = self.value
return res | python | def _zip(self) -> ObjectValue:
"""Zip the receiver into an object and return it."""
res = ObjectValue(self.siblings.copy(), self.timestamp)
res[self.name] = self.value
return res | [
"def",
"_zip",
"(",
"self",
")",
"->",
"ObjectValue",
":",
"res",
"=",
"ObjectValue",
"(",
"self",
".",
"siblings",
".",
"copy",
"(",
")",
",",
"self",
".",
"timestamp",
")",
"res",
"[",
"self",
".",
"name",
"]",
"=",
"self",
".",
"value",
"return"... | Zip the receiver into an object and return it. | [
"Zip",
"the",
"receiver",
"into",
"an",
"object",
"and",
"return",
"it",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L579-L583 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry.update | def update(self, value: Union[RawValue, Value],
raw: bool = False) -> "ArrayEntry":
"""Update the receiver's value.
This method overrides the superclass method.
"""
return super().update(self._cook_value(value, raw), False) | python | def update(self, value: Union[RawValue, Value],
raw: bool = False) -> "ArrayEntry":
"""Update the receiver's value.
This method overrides the superclass method.
"""
return super().update(self._cook_value(value, raw), False) | [
"def",
"update",
"(",
"self",
",",
"value",
":",
"Union",
"[",
"RawValue",
",",
"Value",
"]",
",",
"raw",
":",
"bool",
"=",
"False",
")",
"->",
"\"ArrayEntry\"",
":",
"return",
"super",
"(",
")",
".",
"update",
"(",
"self",
".",
"_cook_value",
"(",
... | Update the receiver's value.
This method overrides the superclass method. | [
"Update",
"the",
"receiver",
"s",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L634-L640 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry.previous | def previous(self) -> "ArrayEntry":
"""Return an instance node corresponding to the previous entry.
Raises:
NonexistentInstance: If the receiver is the first entry of the
parent array.
"""
try:
newval, nbef = self.before.pop()
except Index... | python | def previous(self) -> "ArrayEntry":
"""Return an instance node corresponding to the previous entry.
Raises:
NonexistentInstance: If the receiver is the first entry of the
parent array.
"""
try:
newval, nbef = self.before.pop()
except Index... | [
"def",
"previous",
"(",
"self",
")",
"->",
"\"ArrayEntry\"",
":",
"try",
":",
"newval",
",",
"nbef",
"=",
"self",
".",
"before",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"raise",
"NonexistentInstance",
"(",
"self",
".",
"json_pointer",
"(",
")"... | Return an instance node corresponding to the previous entry.
Raises:
NonexistentInstance: If the receiver is the first entry of the
parent array. | [
"Return",
"an",
"instance",
"node",
"corresponding",
"to",
"the",
"previous",
"entry",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L642-L655 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry.next | def next(self) -> "ArrayEntry":
"""Return an instance node corresponding to the next entry.
Raises:
NonexistentInstance: If the receiver is the last entry of the parent array.
"""
try:
newval, naft = self.after.pop()
except IndexError:
raise N... | python | def next(self) -> "ArrayEntry":
"""Return an instance node corresponding to the next entry.
Raises:
NonexistentInstance: If the receiver is the last entry of the parent array.
"""
try:
newval, naft = self.after.pop()
except IndexError:
raise N... | [
"def",
"next",
"(",
"self",
")",
"->",
"\"ArrayEntry\"",
":",
"try",
":",
"newval",
",",
"naft",
"=",
"self",
".",
"after",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"raise",
"NonexistentInstance",
"(",
"self",
".",
"json_pointer",
"(",
")",
"... | Return an instance node corresponding to the next entry.
Raises:
NonexistentInstance: If the receiver is the last entry of the parent array. | [
"Return",
"an",
"instance",
"node",
"corresponding",
"to",
"the",
"next",
"entry",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L657-L669 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry.insert_before | def insert_before(self, value: Union[RawValue, Value],
raw: bool = False) -> "ArrayEntry":
"""Insert a new entry before the receiver.
Args:
value: The value of the new entry.
raw: Flag to be set if `value` is raw.
Returns:
An instance n... | python | def insert_before(self, value: Union[RawValue, Value],
raw: bool = False) -> "ArrayEntry":
"""Insert a new entry before the receiver.
Args:
value: The value of the new entry.
raw: Flag to be set if `value` is raw.
Returns:
An instance n... | [
"def",
"insert_before",
"(",
"self",
",",
"value",
":",
"Union",
"[",
"RawValue",
",",
"Value",
"]",
",",
"raw",
":",
"bool",
"=",
"False",
")",
"->",
"\"ArrayEntry\"",
":",
"return",
"ArrayEntry",
"(",
"self",
".",
"index",
",",
"self",
".",
"before",... | Insert a new entry before the receiver.
Args:
value: The value of the new entry.
raw: Flag to be set if `value` is raw.
Returns:
An instance node of the new inserted entry. | [
"Insert",
"a",
"new",
"entry",
"before",
"the",
"receiver",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L671-L684 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry._zip | def _zip(self) -> ArrayValue:
"""Zip the receiver into an array and return it."""
res = list(self.before)
res.reverse()
res.append(self.value)
res.extend(list(self.after))
return ArrayValue(res, self.timestamp) | python | def _zip(self) -> ArrayValue:
"""Zip the receiver into an array and return it."""
res = list(self.before)
res.reverse()
res.append(self.value)
res.extend(list(self.after))
return ArrayValue(res, self.timestamp) | [
"def",
"_zip",
"(",
"self",
")",
"->",
"ArrayValue",
":",
"res",
"=",
"list",
"(",
"self",
".",
"before",
")",
"res",
".",
"reverse",
"(",
")",
"res",
".",
"append",
"(",
"self",
".",
"value",
")",
"res",
".",
"extend",
"(",
"list",
"(",
"self",
... | Zip the receiver into an array and return it. | [
"Zip",
"the",
"receiver",
"into",
"an",
"array",
"and",
"return",
"it",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L705-L711 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry._ancestors_or_self | def _ancestors_or_self(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's ancestors including itself."""
res = [] if qname and self.qual_name != qname else [self]
return res + self.up()._ancestors(qname) | python | def _ancestors_or_self(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's ancestors including itself."""
res = [] if qname and self.qual_name != qname else [self]
return res + self.up()._ancestors(qname) | [
"def",
"_ancestors_or_self",
"(",
"self",
",",
"qname",
":",
"Union",
"[",
"QualName",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"InstanceNode",
"]",
":",
"res",
"=",
"[",
"]",
"if",
"qname",
"and",
"self",
".",
"qual_name",
"!=",
"qname... | XPath - return the list of receiver's ancestors including itself. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"receiver",
"s",
"ancestors",
"including",
"itself",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L723-L727 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry._ancestors | def _ancestors(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's ancestors."""
return self.up()._ancestors(qname) | python | def _ancestors(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's ancestors."""
return self.up()._ancestors(qname) | [
"def",
"_ancestors",
"(",
"self",
",",
"qname",
":",
"Union",
"[",
"QualName",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"InstanceNode",
"]",
":",
"return",
"self",
".",
"up",
"(",
")",
".",
"_ancestors",
"(",
"qname",
")"
] | XPath - return the list of receiver's ancestors. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"receiver",
"s",
"ancestors",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L729-L732 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry._preceding_siblings | def _preceding_siblings(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's preceding siblings."""
if qname and self.qual_name != qname:
return []
res = []
en = self
for _ in self.before:
... | python | def _preceding_siblings(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's preceding siblings."""
if qname and self.qual_name != qname:
return []
res = []
en = self
for _ in self.before:
... | [
"def",
"_preceding_siblings",
"(",
"self",
",",
"qname",
":",
"Union",
"[",
"QualName",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"InstanceNode",
"]",
":",
"if",
"qname",
"and",
"self",
".",
"qual_name",
"!=",
"qname",
":",
"return",
"[",
... | XPath - return the list of receiver's preceding siblings. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"receiver",
"s",
"preceding",
"siblings",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L734-L744 |
CZ-NIC/yangson | yangson/instance.py | ArrayEntry._following_siblings | def _following_siblings(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's following siblings."""
if qname and self.qual_name != qname:
return []
res = []
en = self
for _ in self.after:
e... | python | def _following_siblings(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
"""XPath - return the list of receiver's following siblings."""
if qname and self.qual_name != qname:
return []
res = []
en = self
for _ in self.after:
e... | [
"def",
"_following_siblings",
"(",
"self",
",",
"qname",
":",
"Union",
"[",
"QualName",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"InstanceNode",
"]",
":",
"if",
"qname",
"and",
"self",
".",
"qual_name",
"!=",
"qname",
":",
"return",
"[",
... | XPath - return the list of receiver's following siblings. | [
"XPath",
"-",
"return",
"the",
"list",
"of",
"receiver",
"s",
"following",
"siblings",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L746-L756 |
CZ-NIC/yangson | yangson/instance.py | MemberName.peek_step | def peek_step(self, val: ObjectValue,
sn: "DataNode") -> Tuple[Value, "DataNode"]:
"""Return member value addressed by the receiver + its schema node.
Args:
val: Current value (object).
sn: Current schema node.
"""
cn = sn.get_data_child(self.n... | python | def peek_step(self, val: ObjectValue,
sn: "DataNode") -> Tuple[Value, "DataNode"]:
"""Return member value addressed by the receiver + its schema node.
Args:
val: Current value (object).
sn: Current schema node.
"""
cn = sn.get_data_child(self.n... | [
"def",
"peek_step",
"(",
"self",
",",
"val",
":",
"ObjectValue",
",",
"sn",
":",
"\"DataNode\"",
")",
"->",
"Tuple",
"[",
"Value",
",",
"\"DataNode\"",
"]",
":",
"cn",
"=",
"sn",
".",
"get_data_child",
"(",
"self",
".",
"name",
",",
"self",
".",
"nam... | Return member value addressed by the receiver + its schema node.
Args:
val: Current value (object).
sn: Current schema node. | [
"Return",
"member",
"value",
"addressed",
"by",
"the",
"receiver",
"+",
"its",
"schema",
"node",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L799-L811 |
CZ-NIC/yangson | yangson/instance.py | ActionName.peek_step | def peek_step(self, val: ObjectValue,
sn: "DataNode") -> Tuple[None, "DataNode"]:
"""Fail because there is no action instance."""
cn = sn.get_child(self.name, self.namespace)
return (None, cn) | python | def peek_step(self, val: ObjectValue,
sn: "DataNode") -> Tuple[None, "DataNode"]:
"""Fail because there is no action instance."""
cn = sn.get_child(self.name, self.namespace)
return (None, cn) | [
"def",
"peek_step",
"(",
"self",
",",
"val",
":",
"ObjectValue",
",",
"sn",
":",
"\"DataNode\"",
")",
"->",
"Tuple",
"[",
"None",
",",
"\"DataNode\"",
"]",
":",
"cn",
"=",
"sn",
".",
"get_child",
"(",
"self",
".",
"name",
",",
"self",
".",
"namespace... | Fail because there is no action instance. | [
"Fail",
"because",
"there",
"is",
"no",
"action",
"instance",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/instance.py#L825-L829 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.