partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | ResourceAgent.queue_action | Function that specifies the interaction with a
:class:`.ResourceQueue` upon departure.
When departuring from a :class:`.ResourceQueue` (or a
:class:`.QueueServer`), this method is called. If the agent
does not already have a resource then it decrements the number
of servers at :... | queueing_tool/queues/queue_extentions.py | def queue_action(self, queue, *args, **kwargs):
"""Function that specifies the interaction with a
:class:`.ResourceQueue` upon departure.
When departuring from a :class:`.ResourceQueue` (or a
:class:`.QueueServer`), this method is called. If the agent
does not already have a res... | def queue_action(self, queue, *args, **kwargs):
"""Function that specifies the interaction with a
:class:`.ResourceQueue` upon departure.
When departuring from a :class:`.ResourceQueue` (or a
:class:`.QueueServer`), this method is called. If the agent
does not already have a res... | [
"Function",
"that",
"specifies",
"the",
"interaction",
"with",
"a",
":",
"class",
":",
".",
"ResourceQueue",
"upon",
"departure",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_extentions.py#L30-L54 | [
"def",
"queue_action",
"(",
"self",
",",
"queue",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"queue",
",",
"ResourceQueue",
")",
":",
"if",
"self",
".",
"_has_resource",
":",
"self",
".",
"_has_resource",
"=",
"False"... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | ResourceQueue.next_event | Simulates the queue forward one event.
This method behaves identically to a :class:`.LossQueue` if the
arriving/departing agent is anything other than a
:class:`.ResourceAgent`. The differences are;
Arriving:
* If the :class:`.ResourceAgent` has a resource then it deletes
... | queueing_tool/queues/queue_extentions.py | def next_event(self):
"""Simulates the queue forward one event.
This method behaves identically to a :class:`.LossQueue` if the
arriving/departing agent is anything other than a
:class:`.ResourceAgent`. The differences are;
Arriving:
* If the :class:`.ResourceAgent` ha... | def next_event(self):
"""Simulates the queue forward one event.
This method behaves identically to a :class:`.LossQueue` if the
arriving/departing agent is anything other than a
:class:`.ResourceAgent`. The differences are;
Arriving:
* If the :class:`.ResourceAgent` ha... | [
"Simulates",
"the",
"queue",
"forward",
"one",
"event",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_extentions.py#L111-L176 | [
"def",
"next_event",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_arrivals",
"[",
"0",
"]",
",",
"ResourceAgent",
")",
":",
"if",
"self",
".",
"_departures",
"[",
"0",
"]",
".",
"_time",
"<",
"self",
".",
"_arrivals",
"[",
"0",
"]... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | UnionFind.size | Returns the number of elements in the set that ``s`` belongs to.
Parameters
----------
s : object
An object
Returns
-------
out : int
The number of elements in the set that ``s`` belongs to. | queueing_tool/union_find.py | def size(self, s):
"""Returns the number of elements in the set that ``s`` belongs to.
Parameters
----------
s : object
An object
Returns
-------
out : int
The number of elements in the set that ``s`` belongs to.
"""
leade... | def size(self, s):
"""Returns the number of elements in the set that ``s`` belongs to.
Parameters
----------
s : object
An object
Returns
-------
out : int
The number of elements in the set that ``s`` belongs to.
"""
leade... | [
"Returns",
"the",
"number",
"of",
"elements",
"in",
"the",
"set",
"that",
"s",
"belongs",
"to",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/union_find.py#L32-L46 | [
"def",
"size",
"(",
"self",
",",
"s",
")",
":",
"leader",
"=",
"self",
".",
"find",
"(",
"s",
")",
"return",
"self",
".",
"_size",
"[",
"leader",
"]"
] | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | UnionFind.find | Locates the leader of the set to which the element ``s`` belongs.
Parameters
----------
s : object
An object that the ``UnionFind`` contains.
Returns
-------
object
The leader of the set that contains ``s``. | queueing_tool/union_find.py | def find(self, s):
"""Locates the leader of the set to which the element ``s`` belongs.
Parameters
----------
s : object
An object that the ``UnionFind`` contains.
Returns
-------
object
The leader of the set that contains ``s``.
... | def find(self, s):
"""Locates the leader of the set to which the element ``s`` belongs.
Parameters
----------
s : object
An object that the ``UnionFind`` contains.
Returns
-------
object
The leader of the set that contains ``s``.
... | [
"Locates",
"the",
"leader",
"of",
"the",
"set",
"to",
"which",
"the",
"element",
"s",
"belongs",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/union_find.py#L49-L73 | [
"def",
"find",
"(",
"self",
",",
"s",
")",
":",
"pSet",
"=",
"[",
"s",
"]",
"parent",
"=",
"self",
".",
"_leader",
"[",
"s",
"]",
"while",
"parent",
"!=",
"self",
".",
"_leader",
"[",
"parent",
"]",
":",
"pSet",
".",
"append",
"(",
"parent",
")... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | UnionFind.union | Merges the set that contains ``a`` with the set that contains ``b``.
Parameters
----------
a, b : objects
Two objects whose sets are to be merged. | queueing_tool/union_find.py | def union(self, a, b):
"""Merges the set that contains ``a`` with the set that contains ``b``.
Parameters
----------
a, b : objects
Two objects whose sets are to be merged.
"""
s1, s2 = self.find(a), self.find(b)
if s1 != s2:
r1, r2 = sel... | def union(self, a, b):
"""Merges the set that contains ``a`` with the set that contains ``b``.
Parameters
----------
a, b : objects
Two objects whose sets are to be merged.
"""
s1, s2 = self.find(a), self.find(b)
if s1 != s2:
r1, r2 = sel... | [
"Merges",
"the",
"set",
"that",
"contains",
"a",
"with",
"the",
"set",
"that",
"contains",
"b",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/union_find.py#L76-L95 | [
"def",
"union",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"s1",
",",
"s2",
"=",
"self",
".",
"find",
"(",
"a",
")",
",",
"self",
".",
"find",
"(",
"b",
")",
"if",
"s1",
"!=",
"s2",
":",
"r1",
",",
"r2",
"=",
"self",
".",
"_rank",
"[",
... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | generate_transition_matrix | Generates a random transition matrix for the graph ``g``.
Parameters
----------
g : :any:`networkx.DiGraph`, :class:`numpy.ndarray`, dict, etc.
Any object that :any:`DiGraph<networkx.DiGraph>` accepts.
seed : int (optional)
An integer used to initialize numpy's psuedo-random number
... | queueing_tool/graph/graph_generation.py | def generate_transition_matrix(g, seed=None):
"""Generates a random transition matrix for the graph ``g``.
Parameters
----------
g : :any:`networkx.DiGraph`, :class:`numpy.ndarray`, dict, etc.
Any object that :any:`DiGraph<networkx.DiGraph>` accepts.
seed : int (optional)
An integer... | def generate_transition_matrix(g, seed=None):
"""Generates a random transition matrix for the graph ``g``.
Parameters
----------
g : :any:`networkx.DiGraph`, :class:`numpy.ndarray`, dict, etc.
Any object that :any:`DiGraph<networkx.DiGraph>` accepts.
seed : int (optional)
An integer... | [
"Generates",
"a",
"random",
"transition",
"matrix",
"for",
"the",
"graph",
"g",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_generation.py#L11-L50 | [
"def",
"generate_transition_matrix",
"(",
"g",
",",
"seed",
"=",
"None",
")",
":",
"g",
"=",
"_test_graph",
"(",
"g",
")",
"if",
"isinstance",
"(",
"seed",
",",
"numbers",
".",
"Integral",
")",
":",
"np",
".",
"random",
".",
"seed",
"(",
"seed",
")",... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | generate_random_graph | Creates a random graph where the edges have different types.
This method calls :func:`.minimal_random_graph`, and then adds
a loop to each vertex with ``prob_loop`` probability. It then
calls :func:`.set_types_random` on the resulting graph.
Parameters
----------
num_vertices : int (optional, ... | queueing_tool/graph/graph_generation.py | def generate_random_graph(num_vertices=250, prob_loop=0.5, **kwargs):
"""Creates a random graph where the edges have different types.
This method calls :func:`.minimal_random_graph`, and then adds
a loop to each vertex with ``prob_loop`` probability. It then
calls :func:`.set_types_random` on the resul... | def generate_random_graph(num_vertices=250, prob_loop=0.5, **kwargs):
"""Creates a random graph where the edges have different types.
This method calls :func:`.minimal_random_graph`, and then adds
a loop to each vertex with ``prob_loop`` probability. It then
calls :func:`.set_types_random` on the resul... | [
"Creates",
"a",
"random",
"graph",
"where",
"the",
"edges",
"have",
"different",
"types",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_generation.py#L53-L115 | [
"def",
"generate_random_graph",
"(",
"num_vertices",
"=",
"250",
",",
"prob_loop",
"=",
"0.5",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"minimal_random_graph",
"(",
"num_vertices",
",",
"*",
"*",
"kwargs",
")",
"for",
"v",
"in",
"g",
".",
"nodes",
... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | generate_pagerank_graph | Creates a random graph where the vertex types are
selected using their pagerank.
Calls :func:`.minimal_random_graph` and then
:func:`.set_types_rank` where the ``rank`` keyword argument
is given by :func:`networkx.pagerank`.
Parameters
----------
num_vertices : int (optional, the default i... | queueing_tool/graph/graph_generation.py | def generate_pagerank_graph(num_vertices=250, **kwargs):
"""Creates a random graph where the vertex types are
selected using their pagerank.
Calls :func:`.minimal_random_graph` and then
:func:`.set_types_rank` where the ``rank`` keyword argument
is given by :func:`networkx.pagerank`.
Parameter... | def generate_pagerank_graph(num_vertices=250, **kwargs):
"""Creates a random graph where the vertex types are
selected using their pagerank.
Calls :func:`.minimal_random_graph` and then
:func:`.set_types_rank` where the ``rank`` keyword argument
is given by :func:`networkx.pagerank`.
Parameter... | [
"Creates",
"a",
"random",
"graph",
"where",
"the",
"vertex",
"types",
"are",
"selected",
"using",
"their",
"pagerank",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_generation.py#L118-L157 | [
"def",
"generate_pagerank_graph",
"(",
"num_vertices",
"=",
"250",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"minimal_random_graph",
"(",
"num_vertices",
",",
"*",
"*",
"kwargs",
")",
"r",
"=",
"np",
".",
"zeros",
"(",
"num_vertices",
")",
"for",
"k",... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | minimal_random_graph | Creates a connected graph with random vertex locations.
Parameters
----------
num_vertices : int
The number of vertices in the graph.
seed : int (optional)
An integer used to initialize numpy's psuedorandom number
generators.
**kwargs :
Unused.
Returns
-----... | queueing_tool/graph/graph_generation.py | def minimal_random_graph(num_vertices, seed=None, **kwargs):
"""Creates a connected graph with random vertex locations.
Parameters
----------
num_vertices : int
The number of vertices in the graph.
seed : int (optional)
An integer used to initialize numpy's psuedorandom number
... | def minimal_random_graph(num_vertices, seed=None, **kwargs):
"""Creates a connected graph with random vertex locations.
Parameters
----------
num_vertices : int
The number of vertices in the graph.
seed : int (optional)
An integer used to initialize numpy's psuedorandom number
... | [
"Creates",
"a",
"connected",
"graph",
"with",
"random",
"vertex",
"locations",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_generation.py#L160-L214 | [
"def",
"minimal_random_graph",
"(",
"num_vertices",
",",
"seed",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"seed",
",",
"numbers",
".",
"Integral",
")",
":",
"np",
".",
"random",
".",
"seed",
"(",
"seed",
")",
"points",
... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | set_types_random | Randomly sets ``edge_type`` (edge type) properties of the graph.
This function randomly assigns each edge a type. The probability of
an edge being a specific type is proscribed in the
``proportions``, ``loop_proportions`` variables.
Parameters
----------
g : :any:`networkx.DiGraph`, :class:`nu... | queueing_tool/graph/graph_generation.py | def set_types_random(g, proportions=None, loop_proportions=None, seed=None,
**kwargs):
"""Randomly sets ``edge_type`` (edge type) properties of the graph.
This function randomly assigns each edge a type. The probability of
an edge being a specific type is proscribed in the
``propor... | def set_types_random(g, proportions=None, loop_proportions=None, seed=None,
**kwargs):
"""Randomly sets ``edge_type`` (edge type) properties of the graph.
This function randomly assigns each edge a type. The probability of
an edge being a specific type is proscribed in the
``propor... | [
"Randomly",
"sets",
"edge_type",
"(",
"edge",
"type",
")",
"properties",
"of",
"the",
"graph",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_generation.py#L217-L305 | [
"def",
"set_types_random",
"(",
"g",
",",
"proportions",
"=",
"None",
",",
"loop_proportions",
"=",
"None",
",",
"seed",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"_test_graph",
"(",
"g",
")",
"if",
"isinstance",
"(",
"seed",
",",
"nu... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | set_types_rank | Creates a stylized graph. Sets edge and types using `pagerank`_.
This function sets the edge types of a graph to be either 1, 2, or
3. It sets the vertices to type 2 by selecting the top
``pType2 * g.number_of_nodes()`` vertices given by the
:func:`~networkx.pagerank` of the graph. A loop is added
... | queueing_tool/graph/graph_generation.py | def set_types_rank(g, rank, pType2=0.1, pType3=0.1, seed=None, **kwargs):
"""Creates a stylized graph. Sets edge and types using `pagerank`_.
This function sets the edge types of a graph to be either 1, 2, or
3. It sets the vertices to type 2 by selecting the top
``pType2 * g.number_of_nodes()`` vertic... | def set_types_rank(g, rank, pType2=0.1, pType3=0.1, seed=None, **kwargs):
"""Creates a stylized graph. Sets edge and types using `pagerank`_.
This function sets the edge types of a graph to be either 1, 2, or
3. It sets the vertices to type 2 by selecting the top
``pType2 * g.number_of_nodes()`` vertic... | [
"Creates",
"a",
"stylized",
"graph",
".",
"Sets",
"edge",
"and",
"types",
"using",
"pagerank",
"_",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_generation.py#L308-L405 | [
"def",
"set_types_rank",
"(",
"g",
",",
"rank",
",",
"pType2",
"=",
"0.1",
",",
"pType3",
"=",
"0.1",
",",
"seed",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"_test_graph",
"(",
"g",
")",
"if",
"isinstance",
"(",
"seed",
",",
"numb... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | strip_comment_marker | Strip # markers at the front of a block of comment text. | docs/sphinxext/numpydoc/comment_eater.py | def strip_comment_marker(text):
""" Strip # markers at the front of a block of comment text.
"""
lines = []
for line in text.splitlines():
lines.append(line.lstrip('#'))
text = textwrap.dedent('\n'.join(lines))
return text | def strip_comment_marker(text):
""" Strip # markers at the front of a block of comment text.
"""
lines = []
for line in text.splitlines():
lines.append(line.lstrip('#'))
text = textwrap.dedent('\n'.join(lines))
return text | [
"Strip",
"#",
"markers",
"at",
"the",
"front",
"of",
"a",
"block",
"of",
"comment",
"text",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L143-L150 | [
"def",
"strip_comment_marker",
"(",
"text",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"line",
"in",
"text",
".",
"splitlines",
"(",
")",
":",
"lines",
".",
"append",
"(",
"line",
".",
"lstrip",
"(",
"'#'",
")",
")",
"text",
"=",
"textwrap",
".",
"de... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | get_class_traits | Yield all of the documentation for trait definitions on a class object. | docs/sphinxext/numpydoc/comment_eater.py | def get_class_traits(klass):
""" Yield all of the documentation for trait definitions on a class object.
"""
# FIXME: gracefully handle errors here or in the caller?
source = inspect.getsource(klass)
cb = CommentBlocker()
cb.process_file(StringIO(source))
mod_ast = compiler.parse(source)
... | def get_class_traits(klass):
""" Yield all of the documentation for trait definitions on a class object.
"""
# FIXME: gracefully handle errors here or in the caller?
source = inspect.getsource(klass)
cb = CommentBlocker()
cb.process_file(StringIO(source))
mod_ast = compiler.parse(source)
... | [
"Yield",
"all",
"of",
"the",
"documentation",
"for",
"trait",
"definitions",
"on",
"a",
"class",
"object",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L153-L168 | [
"def",
"get_class_traits",
"(",
"klass",
")",
":",
"# FIXME: gracefully handle errors here or in the caller?",
"source",
"=",
"inspect",
".",
"getsource",
"(",
"klass",
")",
"cb",
"=",
"CommentBlocker",
"(",
")",
"cb",
".",
"process_file",
"(",
"StringIO",
"(",
"s... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | NonComment.add | Add lines to the block. | docs/sphinxext/numpydoc/comment_eater.py | def add(self, string, start, end, line):
""" Add lines to the block.
"""
if string.strip():
# Only add if not entirely whitespace.
self.start_lineno = min(self.start_lineno, start[0])
self.end_lineno = max(self.end_lineno, end[0]) | def add(self, string, start, end, line):
""" Add lines to the block.
"""
if string.strip():
# Only add if not entirely whitespace.
self.start_lineno = min(self.start_lineno, start[0])
self.end_lineno = max(self.end_lineno, end[0]) | [
"Add",
"lines",
"to",
"the",
"block",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L49-L55 | [
"def",
"add",
"(",
"self",
",",
"string",
",",
"start",
",",
"end",
",",
"line",
")",
":",
"if",
"string",
".",
"strip",
"(",
")",
":",
"# Only add if not entirely whitespace.",
"self",
".",
"start_lineno",
"=",
"min",
"(",
"self",
".",
"start_lineno",
"... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | CommentBlocker.process_file | Process a file object. | docs/sphinxext/numpydoc/comment_eater.py | def process_file(self, file):
""" Process a file object.
"""
if sys.version_info[0] >= 3:
nxt = file.__next__
else:
nxt = file.next
for token in tokenize.generate_tokens(nxt):
self.process_token(*token)
self.make_index() | def process_file(self, file):
""" Process a file object.
"""
if sys.version_info[0] >= 3:
nxt = file.__next__
else:
nxt = file.next
for token in tokenize.generate_tokens(nxt):
self.process_token(*token)
self.make_index() | [
"Process",
"a",
"file",
"object",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L75-L84 | [
"def",
"process_file",
"(",
"self",
",",
"file",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"nxt",
"=",
"file",
".",
"__next__",
"else",
":",
"nxt",
"=",
"file",
".",
"next",
"for",
"token",
"in",
"tokenize",
".",
... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | CommentBlocker.process_token | Process a single token. | docs/sphinxext/numpydoc/comment_eater.py | def process_token(self, kind, string, start, end, line):
""" Process a single token.
"""
if self.current_block.is_comment:
if kind == tokenize.COMMENT:
self.current_block.add(string, start, end, line)
else:
self.new_noncomment(start[0], end... | def process_token(self, kind, string, start, end, line):
""" Process a single token.
"""
if self.current_block.is_comment:
if kind == tokenize.COMMENT:
self.current_block.add(string, start, end, line)
else:
self.new_noncomment(start[0], end... | [
"Process",
"a",
"single",
"token",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L86-L98 | [
"def",
"process_token",
"(",
"self",
",",
"kind",
",",
"string",
",",
"start",
",",
"end",
",",
"line",
")",
":",
"if",
"self",
".",
"current_block",
".",
"is_comment",
":",
"if",
"kind",
"==",
"tokenize",
".",
"COMMENT",
":",
"self",
".",
"current_blo... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | CommentBlocker.new_noncomment | We are transitioning from a noncomment to a comment. | docs/sphinxext/numpydoc/comment_eater.py | def new_noncomment(self, start_lineno, end_lineno):
""" We are transitioning from a noncomment to a comment.
"""
block = NonComment(start_lineno, end_lineno)
self.blocks.append(block)
self.current_block = block | def new_noncomment(self, start_lineno, end_lineno):
""" We are transitioning from a noncomment to a comment.
"""
block = NonComment(start_lineno, end_lineno)
self.blocks.append(block)
self.current_block = block | [
"We",
"are",
"transitioning",
"from",
"a",
"noncomment",
"to",
"a",
"comment",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L100-L105 | [
"def",
"new_noncomment",
"(",
"self",
",",
"start_lineno",
",",
"end_lineno",
")",
":",
"block",
"=",
"NonComment",
"(",
"start_lineno",
",",
"end_lineno",
")",
"self",
".",
"blocks",
".",
"append",
"(",
"block",
")",
"self",
".",
"current_block",
"=",
"bl... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | CommentBlocker.new_comment | Possibly add a new comment.
Only adds a new comment if this comment is the only thing on the line.
Otherwise, it extends the noncomment block. | docs/sphinxext/numpydoc/comment_eater.py | def new_comment(self, string, start, end, line):
""" Possibly add a new comment.
Only adds a new comment if this comment is the only thing on the line.
Otherwise, it extends the noncomment block.
"""
prefix = line[:start[1]]
if prefix.strip():
# Oops! Trailin... | def new_comment(self, string, start, end, line):
""" Possibly add a new comment.
Only adds a new comment if this comment is the only thing on the line.
Otherwise, it extends the noncomment block.
"""
prefix = line[:start[1]]
if prefix.strip():
# Oops! Trailin... | [
"Possibly",
"add",
"a",
"new",
"comment",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L107-L121 | [
"def",
"new_comment",
"(",
"self",
",",
"string",
",",
"start",
",",
"end",
",",
"line",
")",
":",
"prefix",
"=",
"line",
"[",
":",
"start",
"[",
"1",
"]",
"]",
"if",
"prefix",
".",
"strip",
"(",
")",
":",
"# Oops! Trailing comment, not a comment block."... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | CommentBlocker.make_index | Make the index mapping lines of actual code to their associated
prefix comments. | docs/sphinxext/numpydoc/comment_eater.py | def make_index(self):
""" Make the index mapping lines of actual code to their associated
prefix comments.
"""
for prev, block in zip(self.blocks[:-1], self.blocks[1:]):
if not block.is_comment:
self.index[block.start_lineno] = prev | def make_index(self):
""" Make the index mapping lines of actual code to their associated
prefix comments.
"""
for prev, block in zip(self.blocks[:-1], self.blocks[1:]):
if not block.is_comment:
self.index[block.start_lineno] = prev | [
"Make",
"the",
"index",
"mapping",
"lines",
"of",
"actual",
"code",
"to",
"their",
"associated",
"prefix",
"comments",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L123-L129 | [
"def",
"make_index",
"(",
"self",
")",
":",
"for",
"prev",
",",
"block",
"in",
"zip",
"(",
"self",
".",
"blocks",
"[",
":",
"-",
"1",
"]",
",",
"self",
".",
"blocks",
"[",
"1",
":",
"]",
")",
":",
"if",
"not",
"block",
".",
"is_comment",
":",
... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | CommentBlocker.search_for_comment | Find the comment block just before the given line number.
Returns None (or the specified default) if there is no such block. | docs/sphinxext/numpydoc/comment_eater.py | def search_for_comment(self, lineno, default=None):
""" Find the comment block just before the given line number.
Returns None (or the specified default) if there is no such block.
"""
if not self.index:
self.make_index()
block = self.index.get(lineno, None)
... | def search_for_comment(self, lineno, default=None):
""" Find the comment block just before the given line number.
Returns None (or the specified default) if there is no such block.
"""
if not self.index:
self.make_index()
block = self.index.get(lineno, None)
... | [
"Find",
"the",
"comment",
"block",
"just",
"before",
"the",
"given",
"line",
"number",
"."
] | djordon/queueing-tool | python | https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/docs/sphinxext/numpydoc/comment_eater.py#L131-L140 | [
"def",
"search_for_comment",
"(",
"self",
",",
"lineno",
",",
"default",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"index",
":",
"self",
".",
"make_index",
"(",
")",
"block",
"=",
"self",
".",
"index",
".",
"get",
"(",
"lineno",
",",
"None",
... | ccd418cf647ac03a54f78ba5e3725903f541b808 |
valid | OpenWrt._generate_contents | Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None | netjsonconfig/backends/openwrt/openwrt.py | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
uci = self.render(files=False)
# create a list with all the packages (and remove empty entries)
packages = packages_patter... | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
uci = self.render(files=False)
# create a list with all the packages (and remove empty entries)
packages = packages_patter... | [
"Adds",
"configuration",
"files",
"to",
"tarfile",
"instance",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/openwrt.py#L30-L49 | [
"def",
"_generate_contents",
"(",
"self",
",",
"tar",
")",
":",
"uci",
"=",
"self",
".",
"render",
"(",
"files",
"=",
"False",
")",
"# create a list with all the packages (and remove empty entries)",
"packages",
"=",
"packages_pattern",
".",
"split",
"(",
"uci",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend._load | Loads config from string or dict | netjsonconfig/backends/base/backend.py | def _load(self, config):
"""
Loads config from string or dict
"""
if isinstance(config, six.string_types):
try:
config = json.loads(config)
except ValueError:
pass
if not isinstance(config, dict):
raise TypeError... | def _load(self, config):
"""
Loads config from string or dict
"""
if isinstance(config, six.string_types):
try:
config = json.loads(config)
except ValueError:
pass
if not isinstance(config, dict):
raise TypeError... | [
"Loads",
"config",
"from",
"string",
"or",
"dict"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L52-L64 | [
"def",
"_load",
"(",
"self",
",",
"config",
")",
":",
"if",
"isinstance",
"(",
"config",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
"config",
"=",
"json",
".",
"loads",
"(",
"config",
")",
"except",
"ValueError",
":",
"pass",
"if",
"not",... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend._merge_config | Merges config with templates | netjsonconfig/backends/base/backend.py | def _merge_config(self, config, templates):
"""
Merges config with templates
"""
if not templates:
return config
# type check
if not isinstance(templates, list):
raise TypeError('templates argument must be an instance of list')
# merge temp... | def _merge_config(self, config, templates):
"""
Merges config with templates
"""
if not templates:
return config
# type check
if not isinstance(templates, list):
raise TypeError('templates argument must be an instance of list')
# merge temp... | [
"Merges",
"config",
"with",
"templates"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L66-L80 | [
"def",
"_merge_config",
"(",
"self",
",",
"config",
",",
"templates",
")",
":",
"if",
"not",
"templates",
":",
"return",
"config",
"# type check",
"if",
"not",
"isinstance",
"(",
"templates",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"'templates argu... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend._render_files | Renders additional files specified in ``self.config['files']`` | netjsonconfig/backends/base/backend.py | def _render_files(self):
"""
Renders additional files specified in ``self.config['files']``
"""
output = ''
# render files
files = self.config.get('files', [])
# add delimiter
if files:
output += '\n{0}\n\n'.format(self.FILE_SECTION_DELIMITER)
... | def _render_files(self):
"""
Renders additional files specified in ``self.config['files']``
"""
output = ''
# render files
files = self.config.get('files', [])
# add delimiter
if files:
output += '\n{0}\n\n'.format(self.FILE_SECTION_DELIMITER)
... | [
"Renders",
"additional",
"files",
"specified",
"in",
"self",
".",
"config",
"[",
"files",
"]"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L92-L109 | [
"def",
"_render_files",
"(",
"self",
")",
":",
"output",
"=",
"''",
"# render files",
"files",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'files'",
",",
"[",
"]",
")",
"# add delimiter",
"if",
"files",
":",
"output",
"+=",
"'\\n{0}\\n\\n'",
".",
"form... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.render | Converts the configuration dictionary into the corresponding configuration format
:param files: whether to include "additional files" in the output or not;
defaults to ``True``
:returns: string with output | netjsonconfig/backends/base/backend.py | def render(self, files=True):
"""
Converts the configuration dictionary into the corresponding configuration format
:param files: whether to include "additional files" in the output or not;
defaults to ``True``
:returns: string with output
"""
self.... | def render(self, files=True):
"""
Converts the configuration dictionary into the corresponding configuration format
:param files: whether to include "additional files" in the output or not;
defaults to ``True``
:returns: string with output
"""
self.... | [
"Converts",
"the",
"configuration",
"dictionary",
"into",
"the",
"corresponding",
"configuration",
"format"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L117-L147 | [
"def",
"render",
"(",
"self",
",",
"files",
"=",
"True",
")",
":",
"self",
".",
"validate",
"(",
")",
"# convert NetJSON config to intermediate data structure",
"if",
"self",
".",
"intermediate_data",
"is",
"None",
":",
"self",
".",
"to_intermediate",
"(",
")",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.json | returns a string formatted as **NetJSON DeviceConfiguration**;
performs validation before returning output;
``*args`` and ``*kwargs`` will be passed to ``json.dumps``;
:returns: string | netjsonconfig/backends/base/backend.py | def json(self, validate=True, *args, **kwargs):
"""
returns a string formatted as **NetJSON DeviceConfiguration**;
performs validation before returning output;
``*args`` and ``*kwargs`` will be passed to ``json.dumps``;
:returns: string
"""
if validate:
... | def json(self, validate=True, *args, **kwargs):
"""
returns a string formatted as **NetJSON DeviceConfiguration**;
performs validation before returning output;
``*args`` and ``*kwargs`` will be passed to ``json.dumps``;
:returns: string
"""
if validate:
... | [
"returns",
"a",
"string",
"formatted",
"as",
"**",
"NetJSON",
"DeviceConfiguration",
"**",
";",
"performs",
"validation",
"before",
"returning",
"output",
";"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L149-L163 | [
"def",
"json",
"(",
"self",
",",
"validate",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"validate",
":",
"self",
".",
"validate",
"(",
")",
"# automatically adds NetJSON type",
"config",
"=",
"deepcopy",
"(",
"self",
".",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.generate | Returns a ``BytesIO`` instance representing an in-memory tar.gz archive
containing the native router configuration.
:returns: in-memory tar.gz archive, instance of ``BytesIO`` | netjsonconfig/backends/base/backend.py | def generate(self):
"""
Returns a ``BytesIO`` instance representing an in-memory tar.gz archive
containing the native router configuration.
:returns: in-memory tar.gz archive, instance of ``BytesIO``
"""
tar_bytes = BytesIO()
tar = tarfile.open(fileobj=tar_bytes,... | def generate(self):
"""
Returns a ``BytesIO`` instance representing an in-memory tar.gz archive
containing the native router configuration.
:returns: in-memory tar.gz archive, instance of ``BytesIO``
"""
tar_bytes = BytesIO()
tar = tarfile.open(fileobj=tar_bytes,... | [
"Returns",
"a",
"BytesIO",
"instance",
"representing",
"an",
"in",
"-",
"memory",
"tar",
".",
"gz",
"archive",
"containing",
"the",
"native",
"router",
"configuration",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L165-L187 | [
"def",
"generate",
"(",
"self",
")",
":",
"tar_bytes",
"=",
"BytesIO",
"(",
")",
"tar",
"=",
"tarfile",
".",
"open",
"(",
"fileobj",
"=",
"tar_bytes",
",",
"mode",
"=",
"'w'",
")",
"self",
".",
"_generate_contents",
"(",
"tar",
")",
"self",
".",
"_pr... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.write | Like ``generate`` but writes to disk.
:param name: file name, the tar.gz extension will be added automatically
:param path: directory where the file will be written to, defaults to ``./``
:returns: None | netjsonconfig/backends/base/backend.py | def write(self, name, path='./'):
"""
Like ``generate`` but writes to disk.
:param name: file name, the tar.gz extension will be added automatically
:param path: directory where the file will be written to, defaults to ``./``
:returns: None
"""
byte_object = self... | def write(self, name, path='./'):
"""
Like ``generate`` but writes to disk.
:param name: file name, the tar.gz extension will be added automatically
:param path: directory where the file will be written to, defaults to ``./``
:returns: None
"""
byte_object = self... | [
"Like",
"generate",
"but",
"writes",
"to",
"disk",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L192-L206 | [
"def",
"write",
"(",
"self",
",",
"name",
",",
"path",
"=",
"'./'",
")",
":",
"byte_object",
"=",
"self",
".",
"generate",
"(",
")",
"file_name",
"=",
"'{0}.tar.gz'",
".",
"format",
"(",
"name",
")",
"if",
"not",
"path",
".",
"endswith",
"(",
"'/'",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend._process_files | Adds files specified in self.config['files'] to tarfile instance.
:param tar: tarfile instance
:returns: None | netjsonconfig/backends/base/backend.py | def _process_files(self, tar):
"""
Adds files specified in self.config['files'] to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
# insert additional files
for file_item in self.config.get('files', []):
path = file_item['path']
... | def _process_files(self, tar):
"""
Adds files specified in self.config['files'] to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
# insert additional files
for file_item in self.config.get('files', []):
path = file_item['path']
... | [
"Adds",
"files",
"specified",
"in",
"self",
".",
"config",
"[",
"files",
"]",
"to",
"tarfile",
"instance",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L208-L224 | [
"def",
"_process_files",
"(",
"self",
",",
"tar",
")",
":",
"# insert additional files",
"for",
"file_item",
"in",
"self",
".",
"config",
".",
"get",
"(",
"'files'",
",",
"[",
"]",
")",
":",
"path",
"=",
"file_item",
"[",
"'path'",
"]",
"# remove leading s... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend._add_file | Adds a single file in tarfile instance.
:param tar: tarfile instance
:param name: string representing filename or path
:param contents: string representing file contents
:param mode: string representing file mode, defaults to 644
:returns: None | netjsonconfig/backends/base/backend.py | def _add_file(self, tar, name, contents, mode=DEFAULT_FILE_MODE):
"""
Adds a single file in tarfile instance.
:param tar: tarfile instance
:param name: string representing filename or path
:param contents: string representing file contents
:param mode: string representin... | def _add_file(self, tar, name, contents, mode=DEFAULT_FILE_MODE):
"""
Adds a single file in tarfile instance.
:param tar: tarfile instance
:param name: string representing filename or path
:param contents: string representing file contents
:param mode: string representin... | [
"Adds",
"a",
"single",
"file",
"in",
"tarfile",
"instance",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L226-L244 | [
"def",
"_add_file",
"(",
"self",
",",
"tar",
",",
"name",
",",
"contents",
",",
"mode",
"=",
"DEFAULT_FILE_MODE",
")",
":",
"byte_contents",
"=",
"BytesIO",
"(",
"contents",
".",
"encode",
"(",
"'utf8'",
")",
")",
"info",
"=",
"tarfile",
".",
"TarInfo",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.to_intermediate | Converts the NetJSON configuration dictionary (self.config)
to the intermediate data structure (self.intermediate_data) that will
be then used by the renderer class to generate the router configuration | netjsonconfig/backends/base/backend.py | def to_intermediate(self):
"""
Converts the NetJSON configuration dictionary (self.config)
to the intermediate data structure (self.intermediate_data) that will
be then used by the renderer class to generate the router configuration
"""
self.validate()
self.interm... | def to_intermediate(self):
"""
Converts the NetJSON configuration dictionary (self.config)
to the intermediate data structure (self.intermediate_data) that will
be then used by the renderer class to generate the router configuration
"""
self.validate()
self.interm... | [
"Converts",
"the",
"NetJSON",
"configuration",
"dictionary",
"(",
"self",
".",
"config",
")",
"to",
"the",
"intermediate",
"data",
"structure",
"(",
"self",
".",
"intermediate_data",
")",
"that",
"will",
"be",
"then",
"used",
"by",
"the",
"renderer",
"class",
... | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L246-L268 | [
"def",
"to_intermediate",
"(",
"self",
")",
":",
"self",
".",
"validate",
"(",
")",
"self",
".",
"intermediate_data",
"=",
"OrderedDict",
"(",
")",
"for",
"converter_class",
"in",
"self",
".",
"converters",
":",
"# skip unnecessary loop cycles",
"if",
"not",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.parse | Parses a native configuration and converts
it to a NetJSON configuration dictionary | netjsonconfig/backends/base/backend.py | def parse(self, native):
"""
Parses a native configuration and converts
it to a NetJSON configuration dictionary
"""
if not hasattr(self, 'parser') or not self.parser:
raise NotImplementedError('Parser class not specified')
parser = self.parser(native)
... | def parse(self, native):
"""
Parses a native configuration and converts
it to a NetJSON configuration dictionary
"""
if not hasattr(self, 'parser') or not self.parser:
raise NotImplementedError('Parser class not specified')
parser = self.parser(native)
... | [
"Parses",
"a",
"native",
"configuration",
"and",
"converts",
"it",
"to",
"a",
"NetJSON",
"configuration",
"dictionary"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L270-L280 | [
"def",
"parse",
"(",
"self",
",",
"native",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'parser'",
")",
"or",
"not",
"self",
".",
"parser",
":",
"raise",
"NotImplementedError",
"(",
"'Parser class not specified'",
")",
"parser",
"=",
"self",
".",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseBackend.to_netjson | Converts the intermediate data structure (self.intermediate_data)
to the NetJSON configuration dictionary (self.config) | netjsonconfig/backends/base/backend.py | def to_netjson(self):
"""
Converts the intermediate data structure (self.intermediate_data)
to the NetJSON configuration dictionary (self.config)
"""
self.__backup_intermediate_data()
self.config = OrderedDict()
for converter_class in self.converters:
... | def to_netjson(self):
"""
Converts the intermediate data structure (self.intermediate_data)
to the NetJSON configuration dictionary (self.config)
"""
self.__backup_intermediate_data()
self.config = OrderedDict()
for converter_class in self.converters:
... | [
"Converts",
"the",
"intermediate",
"data",
"structure",
"(",
"self",
".",
"intermediate_data",
")",
"to",
"the",
"NetJSON",
"configuration",
"dictionary",
"(",
"self",
".",
"config",
")"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/backend.py#L282-L299 | [
"def",
"to_netjson",
"(",
"self",
")",
":",
"self",
".",
"__backup_intermediate_data",
"(",
")",
"self",
".",
"config",
"=",
"OrderedDict",
"(",
")",
"for",
"converter_class",
"in",
"self",
".",
"converters",
":",
"if",
"not",
"converter_class",
".",
"should... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | merge_config | Merges ``config`` on top of ``template``.
Conflicting keys are handled in the following way:
* simple values (eg: ``str``, ``int``, ``float``, ecc) in ``config`` will
overwrite the ones in ``template``
* values of type ``list`` in both ``config`` and ``template`` will be
merged using to the ``... | netjsonconfig/utils.py | def merge_config(template, config, list_identifiers=None):
"""
Merges ``config`` on top of ``template``.
Conflicting keys are handled in the following way:
* simple values (eg: ``str``, ``int``, ``float``, ecc) in ``config`` will
overwrite the ones in ``template``
* values of type ``list`` i... | def merge_config(template, config, list_identifiers=None):
"""
Merges ``config`` on top of ``template``.
Conflicting keys are handled in the following way:
* simple values (eg: ``str``, ``int``, ``float``, ecc) in ``config`` will
overwrite the ones in ``template``
* values of type ``list`` i... | [
"Merges",
"config",
"on",
"top",
"of",
"template",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/utils.py#L8-L34 | [
"def",
"merge_config",
"(",
"template",
",",
"config",
",",
"list_identifiers",
"=",
"None",
")",
":",
"result",
"=",
"template",
".",
"copy",
"(",
")",
"for",
"key",
",",
"value",
"in",
"config",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | merge_list | Merges ``list2`` on top of ``list1``.
If both lists contain dictionaries which have keys specified
in ``identifiers`` which have equal values, those dicts will
be merged (dicts in ``list2`` will override dicts in ``list1``).
The remaining elements will be summed in order to create a list
which cont... | netjsonconfig/utils.py | def merge_list(list1, list2, identifiers=None):
"""
Merges ``list2`` on top of ``list1``.
If both lists contain dictionaries which have keys specified
in ``identifiers`` which have equal values, those dicts will
be merged (dicts in ``list2`` will override dicts in ``list1``).
The remaining elem... | def merge_list(list1, list2, identifiers=None):
"""
Merges ``list2`` on top of ``list1``.
If both lists contain dictionaries which have keys specified
in ``identifiers`` which have equal values, those dicts will
be merged (dicts in ``list2`` will override dicts in ``list1``).
The remaining elem... | [
"Merges",
"list2",
"on",
"top",
"of",
"list1",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/utils.py#L37-L69 | [
"def",
"merge_list",
"(",
"list1",
",",
"list2",
",",
"identifiers",
"=",
"None",
")",
":",
"identifiers",
"=",
"identifiers",
"or",
"[",
"]",
"dict_map",
"=",
"{",
"'list1'",
":",
"OrderedDict",
"(",
")",
",",
"'list2'",
":",
"OrderedDict",
"(",
")",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | evaluate_vars | Evaluates variables in ``data``
:param data: data structure containing variables, may be
``str``, ``dict`` or ``list``
:param context: ``dict`` containing variables
:returns: modified data structure | netjsonconfig/utils.py | def evaluate_vars(data, context=None):
"""
Evaluates variables in ``data``
:param data: data structure containing variables, may be
``str``, ``dict`` or ``list``
:param context: ``dict`` containing variables
:returns: modified data structure
"""
context = context or {}
... | def evaluate_vars(data, context=None):
"""
Evaluates variables in ``data``
:param data: data structure containing variables, may be
``str``, ``dict`` or ``list``
:param context: ``dict`` containing variables
:returns: modified data structure
"""
context = context or {}
... | [
"Evaluates",
"variables",
"in",
"data"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/utils.py#L79-L111 | [
"def",
"evaluate_vars",
"(",
"data",
",",
"context",
"=",
"None",
")",
":",
"context",
"=",
"context",
"or",
"{",
"}",
"if",
"isinstance",
"(",
"data",
",",
"(",
"dict",
",",
"list",
")",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | get_copy | Looks for a key in a dictionary, if found returns
a deepcopied value, otherwise returns default value | netjsonconfig/utils.py | def get_copy(dict_, key, default=None):
"""
Looks for a key in a dictionary, if found returns
a deepcopied value, otherwise returns default value
"""
value = dict_.get(key, default)
if value:
return deepcopy(value)
return value | def get_copy(dict_, key, default=None):
"""
Looks for a key in a dictionary, if found returns
a deepcopied value, otherwise returns default value
"""
value = dict_.get(key, default)
if value:
return deepcopy(value)
return value | [
"Looks",
"for",
"a",
"key",
"in",
"a",
"dictionary",
"if",
"found",
"returns",
"a",
"deepcopied",
"value",
"otherwise",
"returns",
"default",
"value"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/utils.py#L114-L122 | [
"def",
"get_copy",
"(",
"dict_",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"value",
"=",
"dict_",
".",
"get",
"(",
"key",
",",
"default",
")",
"if",
"value",
":",
"return",
"deepcopy",
"(",
"value",
")",
"return",
"value"
] | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseConverter.type_cast | Loops over item and performs type casting
according to supplied schema fragment | netjsonconfig/backends/base/converter.py | def type_cast(self, item, schema=None):
"""
Loops over item and performs type casting
according to supplied schema fragment
"""
if schema is None:
schema = self._schema
properties = schema['properties']
for key, value in item.items():
if ke... | def type_cast(self, item, schema=None):
"""
Loops over item and performs type casting
according to supplied schema fragment
"""
if schema is None:
schema = self._schema
properties = schema['properties']
for key, value in item.items():
if ke... | [
"Loops",
"over",
"item",
"and",
"performs",
"type",
"casting",
"according",
"to",
"supplied",
"schema",
"fragment"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/converter.py#L38-L58 | [
"def",
"type_cast",
"(",
"self",
",",
"item",
",",
"schema",
"=",
"None",
")",
":",
"if",
"schema",
"is",
"None",
":",
"schema",
"=",
"self",
".",
"_schema",
"properties",
"=",
"schema",
"[",
"'properties'",
"]",
"for",
"key",
",",
"value",
"in",
"it... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseConverter.to_intermediate | Converts the NetJSON configuration dictionary (``self.config``)
to intermediate data structure (``self.intermediate_datra``) | netjsonconfig/backends/base/converter.py | def to_intermediate(self):
"""
Converts the NetJSON configuration dictionary (``self.config``)
to intermediate data structure (``self.intermediate_datra``)
"""
result = OrderedDict()
# copy netjson dictionary
netjson = get_copy(self.netjson, self.netjson_key)
... | def to_intermediate(self):
"""
Converts the NetJSON configuration dictionary (``self.config``)
to intermediate data structure (``self.intermediate_datra``)
"""
result = OrderedDict()
# copy netjson dictionary
netjson = get_copy(self.netjson, self.netjson_key)
... | [
"Converts",
"the",
"NetJSON",
"configuration",
"dictionary",
"(",
"self",
".",
"config",
")",
"to",
"intermediate",
"data",
"structure",
"(",
"self",
".",
"intermediate_datra",
")"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/converter.py#L66-L81 | [
"def",
"to_intermediate",
"(",
"self",
")",
":",
"result",
"=",
"OrderedDict",
"(",
")",
"# copy netjson dictionary",
"netjson",
"=",
"get_copy",
"(",
"self",
".",
"netjson",
",",
"self",
".",
"netjson_key",
")",
"if",
"isinstance",
"(",
"netjson",
",",
"lis... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseConverter.to_netjson | Converts the intermediate data structure (``self.intermediate_datra``)
to a NetJSON configuration dictionary (``self.config``) | netjsonconfig/backends/base/converter.py | def to_netjson(self, remove_block=True):
"""
Converts the intermediate data structure (``self.intermediate_datra``)
to a NetJSON configuration dictionary (``self.config``)
"""
result = OrderedDict()
# copy list
intermediate_data = list(self.intermediate_data[self.... | def to_netjson(self, remove_block=True):
"""
Converts the intermediate data structure (``self.intermediate_datra``)
to a NetJSON configuration dictionary (``self.config``)
"""
result = OrderedDict()
# copy list
intermediate_data = list(self.intermediate_data[self.... | [
"Converts",
"the",
"intermediate",
"data",
"structure",
"(",
"self",
".",
"intermediate_datra",
")",
"to",
"a",
"NetJSON",
"configuration",
"dictionary",
"(",
"self",
".",
"config",
")"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/converter.py#L89-L110 | [
"def",
"to_netjson",
"(",
"self",
",",
"remove_block",
"=",
"True",
")",
":",
"result",
"=",
"OrderedDict",
"(",
")",
"# copy list",
"intermediate_data",
"=",
"list",
"(",
"self",
".",
"intermediate_data",
"[",
"self",
".",
"intermediate_key",
"]",
")",
"# i... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWisp._add_unique_file | adds a file in self.config['files'] only if not present already | netjsonconfig/backends/openwisp/openwisp.py | def _add_unique_file(self, item):
"""
adds a file in self.config['files'] only if not present already
"""
if item not in self.config['files']:
self.config['files'].append(item) | def _add_unique_file(self, item):
"""
adds a file in self.config['files'] only if not present already
"""
if item not in self.config['files']:
self.config['files'].append(item) | [
"adds",
"a",
"file",
"in",
"self",
".",
"config",
"[",
"files",
"]",
"only",
"if",
"not",
"present",
"already"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwisp/openwisp.py#L35-L40 | [
"def",
"_add_unique_file",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
"not",
"in",
"self",
".",
"config",
"[",
"'files'",
"]",
":",
"self",
".",
"config",
"[",
"'files'",
"]",
".",
"append",
"(",
"item",
")"
] | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWisp._get_install_context | returns the template context for install.sh and uninstall.sh | netjsonconfig/backends/openwisp/openwisp.py | def _get_install_context(self):
"""
returns the template context for install.sh and uninstall.sh
"""
config = self.config
# layer2 VPN list
l2vpn = []
for vpn in self.config.get('openvpn', []):
if vpn.get('dev_type') != 'tap':
continue
... | def _get_install_context(self):
"""
returns the template context for install.sh and uninstall.sh
"""
config = self.config
# layer2 VPN list
l2vpn = []
for vpn in self.config.get('openvpn', []):
if vpn.get('dev_type') != 'tap':
continue
... | [
"returns",
"the",
"template",
"context",
"for",
"install",
".",
"sh",
"and",
"uninstall",
".",
"sh"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwisp/openwisp.py#L42-L76 | [
"def",
"_get_install_context",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"config",
"# layer2 VPN list",
"l2vpn",
"=",
"[",
"]",
"for",
"vpn",
"in",
"self",
".",
"config",
".",
"get",
"(",
"'openvpn'",
",",
"[",
"]",
")",
":",
"if",
"vpn",
".... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWisp._add_install | generates install.sh and adds it to included files | netjsonconfig/backends/openwisp/openwisp.py | def _add_install(self, context):
"""
generates install.sh and adds it to included files
"""
contents = self._render_template('install.sh', context)
self.config.setdefault('files', []) # file list might be empty
# add install.sh to list of included files
self._add... | def _add_install(self, context):
"""
generates install.sh and adds it to included files
"""
contents = self._render_template('install.sh', context)
self.config.setdefault('files', []) # file list might be empty
# add install.sh to list of included files
self._add... | [
"generates",
"install",
".",
"sh",
"and",
"adds",
"it",
"to",
"included",
"files"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwisp/openwisp.py#L78-L89 | [
"def",
"_add_install",
"(",
"self",
",",
"context",
")",
":",
"contents",
"=",
"self",
".",
"_render_template",
"(",
"'install.sh'",
",",
"context",
")",
"self",
".",
"config",
".",
"setdefault",
"(",
"'files'",
",",
"[",
"]",
")",
"# file list might be empt... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWisp._add_uninstall | generates uninstall.sh and adds it to included files | netjsonconfig/backends/openwisp/openwisp.py | def _add_uninstall(self, context):
"""
generates uninstall.sh and adds it to included files
"""
contents = self._render_template('uninstall.sh', context)
self.config.setdefault('files', []) # file list might be empty
# add uninstall.sh to list of included files
s... | def _add_uninstall(self, context):
"""
generates uninstall.sh and adds it to included files
"""
contents = self._render_template('uninstall.sh', context)
self.config.setdefault('files', []) # file list might be empty
# add uninstall.sh to list of included files
s... | [
"generates",
"uninstall",
".",
"sh",
"and",
"adds",
"it",
"to",
"included",
"files"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwisp/openwisp.py#L91-L102 | [
"def",
"_add_uninstall",
"(",
"self",
",",
"context",
")",
":",
"contents",
"=",
"self",
".",
"_render_template",
"(",
"'uninstall.sh'",
",",
"context",
")",
"self",
".",
"config",
".",
"setdefault",
"(",
"'files'",
",",
"[",
"]",
")",
"# file list might be ... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWisp._add_tc_script | generates tc_script.sh and adds it to included files | netjsonconfig/backends/openwisp/openwisp.py | def _add_tc_script(self):
"""
generates tc_script.sh and adds it to included files
"""
# fill context
context = dict(tc_options=self.config.get('tc_options', []))
# import pdb; pdb.set_trace()
contents = self._render_template('tc_script.sh', context)
self.... | def _add_tc_script(self):
"""
generates tc_script.sh and adds it to included files
"""
# fill context
context = dict(tc_options=self.config.get('tc_options', []))
# import pdb; pdb.set_trace()
contents = self._render_template('tc_script.sh', context)
self.... | [
"generates",
"tc_script",
".",
"sh",
"and",
"adds",
"it",
"to",
"included",
"files"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwisp/openwisp.py#L130-L144 | [
"def",
"_add_tc_script",
"(",
"self",
")",
":",
"# fill context",
"context",
"=",
"dict",
"(",
"tc_options",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'tc_options'",
",",
"[",
"]",
")",
")",
"# import pdb; pdb.set_trace()",
"contents",
"=",
"self",
".",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWisp._generate_contents | Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None | netjsonconfig/backends/openwisp/openwisp.py | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
uci = self.render(files=False)
# create a list with all the packages (and remove empty entries)
packages = re.split('packa... | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
uci = self.render(files=False)
# create a list with all the packages (and remove empty entries)
packages = re.split('packa... | [
"Adds",
"configuration",
"files",
"to",
"tarfile",
"instance",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwisp/openwisp.py#L146-L176 | [
"def",
"_generate_contents",
"(",
"self",
",",
"tar",
")",
":",
"uci",
"=",
"self",
".",
"render",
"(",
"files",
"=",
"False",
")",
"# create a list with all the packages (and remove empty entries)",
"packages",
"=",
"re",
".",
"split",
"(",
"'package '",
",",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | BaseRenderer.render | Renders configuration by using the jinja2 templating engine | netjsonconfig/backends/base/renderer.py | def render(self):
"""
Renders configuration by using the jinja2 templating engine
"""
# get jinja2 template
template_name = '{0}.jinja2'.format(self.get_name())
template = self.template_env.get_template(template_name)
# render template and cleanup
context ... | def render(self):
"""
Renders configuration by using the jinja2 templating engine
"""
# get jinja2 template
template_name = '{0}.jinja2'.format(self.get_name())
template = self.template_env.get_template(template_name)
# render template and cleanup
context ... | [
"Renders",
"configuration",
"by",
"using",
"the",
"jinja2",
"templating",
"engine"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/base/renderer.py#L37-L47 | [
"def",
"render",
"(",
"self",
")",
":",
"# get jinja2 template",
"template_name",
"=",
"'{0}.jinja2'",
".",
"format",
"(",
"self",
".",
"get_name",
"(",
")",
")",
"template",
"=",
"self",
".",
"template_env",
".",
"get_template",
"(",
"template_name",
")",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_addresses | converts NetJSON address to
UCI intermediate data structure | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_addresses(self, interface):
"""
converts NetJSON address to
UCI intermediate data structure
"""
address_list = self.get_copy(interface, 'addresses')
# do not ignore interfaces if they do not contain any address
if not address_list:
r... | def __intermediate_addresses(self, interface):
"""
converts NetJSON address to
UCI intermediate data structure
"""
address_list = self.get_copy(interface, 'addresses')
# do not ignore interfaces if they do not contain any address
if not address_list:
r... | [
"converts",
"NetJSON",
"address",
"to",
"UCI",
"intermediate",
"data",
"structure"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L40-L81 | [
"def",
"__intermediate_addresses",
"(",
"self",
",",
"interface",
")",
":",
"address_list",
"=",
"self",
".",
"get_copy",
"(",
"interface",
",",
"'addresses'",
")",
"# do not ignore interfaces if they do not contain any address",
"if",
"not",
"address_list",
":",
"retur... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_interface | converts NetJSON interface to
UCI intermediate data structure | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_interface(self, interface, uci_name):
"""
converts NetJSON interface to
UCI intermediate data structure
"""
interface.update({
'.type': 'interface',
'.name': uci_name,
'ifname': interface.pop('name')
})
if 'ne... | def __intermediate_interface(self, interface, uci_name):
"""
converts NetJSON interface to
UCI intermediate data structure
"""
interface.update({
'.type': 'interface',
'.name': uci_name,
'ifname': interface.pop('name')
})
if 'ne... | [
"converts",
"NetJSON",
"interface",
"to",
"UCI",
"intermediate",
"data",
"structure"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L83-L112 | [
"def",
"__intermediate_interface",
"(",
"self",
",",
"interface",
",",
"uci_name",
")",
":",
"interface",
".",
"update",
"(",
"{",
"'.type'",
":",
"'interface'",
",",
"'.name'",
":",
"uci_name",
",",
"'ifname'",
":",
"interface",
".",
"pop",
"(",
"'name'",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_address | deletes NetJSON address keys | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_address(self, address):
"""
deletes NetJSON address keys
"""
for key in self._address_keys:
if key in address:
del address[key]
return address | def __intermediate_address(self, address):
"""
deletes NetJSON address keys
"""
for key in self._address_keys:
if key in address:
del address[key]
return address | [
"deletes",
"NetJSON",
"address",
"keys"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L116-L123 | [
"def",
"__intermediate_address",
"(",
"self",
",",
"address",
")",
":",
"for",
"key",
"in",
"self",
".",
"_address_keys",
":",
"if",
"key",
"in",
"address",
":",
"del",
"address",
"[",
"key",
"]",
"return",
"address"
] | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_bridge | converts NetJSON bridge to
UCI intermediate data structure | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_bridge(self, interface, i):
"""
converts NetJSON bridge to
UCI intermediate data structure
"""
# ensure type "bridge" is only given to one logical interface
if interface['type'] == 'bridge' and i < 2:
bridge_members = ' '.join(interface.pop(... | def __intermediate_bridge(self, interface, i):
"""
converts NetJSON bridge to
UCI intermediate data structure
"""
# ensure type "bridge" is only given to one logical interface
if interface['type'] == 'bridge' and i < 2:
bridge_members = ' '.join(interface.pop(... | [
"converts",
"NetJSON",
"bridge",
"to",
"UCI",
"intermediate",
"data",
"structure"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L125-L154 | [
"def",
"__intermediate_bridge",
"(",
"self",
",",
"interface",
",",
"i",
")",
":",
"# ensure type \"bridge\" is only given to one logical interface",
"if",
"interface",
"[",
"'type'",
"]",
"==",
"'bridge'",
"and",
"i",
"<",
"2",
":",
"bridge_members",
"=",
"' '",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_proto | determines UCI interface "proto" option | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_proto(self, interface, address):
"""
determines UCI interface "proto" option
"""
# proto defaults to static
address_proto = address.pop('proto', 'static')
if 'proto' not in interface:
return address_proto
else:
# allow ov... | def __intermediate_proto(self, interface, address):
"""
determines UCI interface "proto" option
"""
# proto defaults to static
address_proto = address.pop('proto', 'static')
if 'proto' not in interface:
return address_proto
else:
# allow ov... | [
"determines",
"UCI",
"interface",
"proto",
"option"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L156-L166 | [
"def",
"__intermediate_proto",
"(",
"self",
",",
"interface",
",",
"address",
")",
":",
"# proto defaults to static",
"address_proto",
"=",
"address",
".",
"pop",
"(",
"'proto'",
",",
"'static'",
")",
"if",
"'proto'",
"not",
"in",
"interface",
":",
"return",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_dns_servers | determines UCI interface "dns" option | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_dns_servers(self, uci, address):
"""
determines UCI interface "dns" option
"""
# allow override
if 'dns' in uci:
return uci['dns']
# ignore if using DHCP or if "proto" is none
if address['proto'] in ['dhcp', 'dhcpv6', 'none']:
... | def __intermediate_dns_servers(self, uci, address):
"""
determines UCI interface "dns" option
"""
# allow override
if 'dns' in uci:
return uci['dns']
# ignore if using DHCP or if "proto" is none
if address['proto'] in ['dhcp', 'dhcpv6', 'none']:
... | [
"determines",
"UCI",
"interface",
"dns",
"option"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L168-L180 | [
"def",
"__intermediate_dns_servers",
"(",
"self",
",",
"uci",
",",
"address",
")",
":",
"# allow override",
"if",
"'dns'",
"in",
"uci",
":",
"return",
"uci",
"[",
"'dns'",
"]",
"# ignore if using DHCP or if \"proto\" is none",
"if",
"address",
"[",
"'proto'",
"]",... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Interfaces.__intermediate_dns_search | determines UCI interface "dns_search" option | netjsonconfig/backends/openwrt/converters/interfaces.py | def __intermediate_dns_search(self, uci, address):
"""
determines UCI interface "dns_search" option
"""
# allow override
if 'dns_search' in uci:
return uci['dns_search']
# ignore if "proto" is none
if address['proto'] == 'none':
return None... | def __intermediate_dns_search(self, uci, address):
"""
determines UCI interface "dns_search" option
"""
# allow override
if 'dns_search' in uci:
return uci['dns_search']
# ignore if "proto" is none
if address['proto'] == 'none':
return None... | [
"determines",
"UCI",
"interface",
"dns_search",
"option"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L182-L194 | [
"def",
"__intermediate_dns_search",
"(",
"self",
",",
"uci",
",",
"address",
")",
":",
"# allow override",
"if",
"'dns_search'",
"in",
"uci",
":",
"return",
"uci",
"[",
"'dns_search'",
"]",
"# ignore if \"proto\" is none",
"if",
"address",
"[",
"'proto'",
"]",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | _list_errors | Returns a list of violated schema fragments and related error messages
:param e: ``jsonschema.exceptions.ValidationError`` instance | netjsonconfig/exceptions.py | def _list_errors(e):
"""
Returns a list of violated schema fragments and related error messages
:param e: ``jsonschema.exceptions.ValidationError`` instance
"""
error_list = []
for value, error in zip(e.validator_value, e.context):
error_list.append((value, error.message))
if err... | def _list_errors(e):
"""
Returns a list of violated schema fragments and related error messages
:param e: ``jsonschema.exceptions.ValidationError`` instance
"""
error_list = []
for value, error in zip(e.validator_value, e.context):
error_list.append((value, error.message))
if err... | [
"Returns",
"a",
"list",
"of",
"violated",
"schema",
"fragments",
"and",
"related",
"error",
"messages",
":",
"param",
"e",
":",
"jsonschema",
".",
"exceptions",
".",
"ValidationError",
"instance"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/exceptions.py#L4-L14 | [
"def",
"_list_errors",
"(",
"e",
")",
":",
"error_list",
"=",
"[",
"]",
"for",
"value",
",",
"error",
"in",
"zip",
"(",
"e",
".",
"validator_value",
",",
"e",
".",
"context",
")",
":",
"error_list",
".",
"append",
"(",
"(",
"value",
",",
"error",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Radios.__intermediate_hwmode | possible return values are: 11a, 11b, 11g | netjsonconfig/backends/openwrt/converters/radios.py | def __intermediate_hwmode(self, radio):
"""
possible return values are: 11a, 11b, 11g
"""
protocol = radio['protocol']
if protocol in ['802.11a', '802.11b', '802.11g']:
# return 11a, 11b or 11g
return protocol[4:]
# determine hwmode depending on ch... | def __intermediate_hwmode(self, radio):
"""
possible return values are: 11a, 11b, 11g
"""
protocol = radio['protocol']
if protocol in ['802.11a', '802.11b', '802.11g']:
# return 11a, 11b or 11g
return protocol[4:]
# determine hwmode depending on ch... | [
"possible",
"return",
"values",
"are",
":",
"11a",
"11b",
"11g"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/radios.py#L39-L55 | [
"def",
"__intermediate_hwmode",
"(",
"self",
",",
"radio",
")",
":",
"protocol",
"=",
"radio",
"[",
"'protocol'",
"]",
"if",
"protocol",
"in",
"[",
"'802.11a'",
",",
"'802.11b'",
",",
"'802.11g'",
"]",
":",
"# return 11a, 11b or 11g",
"return",
"protocol",
"["... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Radios.__intermediate_htmode | only for mac80211 driver | netjsonconfig/backends/openwrt/converters/radios.py | def __intermediate_htmode(self, radio):
"""
only for mac80211 driver
"""
protocol = radio.pop('protocol')
channel_width = radio.pop('channel_width')
# allow overriding htmode
if 'htmode' in radio:
return radio['htmode']
if protocol == '802.11n'... | def __intermediate_htmode(self, radio):
"""
only for mac80211 driver
"""
protocol = radio.pop('protocol')
channel_width = radio.pop('channel_width')
# allow overriding htmode
if 'htmode' in radio:
return radio['htmode']
if protocol == '802.11n'... | [
"only",
"for",
"mac80211",
"driver"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/radios.py#L57-L71 | [
"def",
"__intermediate_htmode",
"(",
"self",
",",
"radio",
")",
":",
"protocol",
"=",
"radio",
".",
"pop",
"(",
"'protocol'",
")",
"channel_width",
"=",
"radio",
".",
"pop",
"(",
"'channel_width'",
")",
"# allow overriding htmode",
"if",
"'htmode'",
"in",
"rad... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Radios.__netjson_protocol | determines NetJSON protocol radio attribute | netjsonconfig/backends/openwrt/converters/radios.py | def __netjson_protocol(self, radio):
"""
determines NetJSON protocol radio attribute
"""
htmode = radio.get('htmode')
hwmode = radio.get('hwmode', None)
if htmode.startswith('HT'):
return '802.11n'
elif htmode.startswith('VHT'):
return '802... | def __netjson_protocol(self, radio):
"""
determines NetJSON protocol radio attribute
"""
htmode = radio.get('htmode')
hwmode = radio.get('hwmode', None)
if htmode.startswith('HT'):
return '802.11n'
elif htmode.startswith('VHT'):
return '802... | [
"determines",
"NetJSON",
"protocol",
"radio",
"attribute"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/radios.py#L92-L102 | [
"def",
"__netjson_protocol",
"(",
"self",
",",
"radio",
")",
":",
"htmode",
"=",
"radio",
".",
"get",
"(",
"'htmode'",
")",
"hwmode",
"=",
"radio",
".",
"get",
"(",
"'hwmode'",
",",
"None",
")",
"if",
"htmode",
".",
"startswith",
"(",
"'HT'",
")",
":... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Radios.__netjson_channel_width | determines NetJSON channel_width radio attribute | netjsonconfig/backends/openwrt/converters/radios.py | def __netjson_channel_width(self, radio):
"""
determines NetJSON channel_width radio attribute
"""
htmode = radio.pop('htmode')
if htmode == 'NONE':
return 20
channel_width = htmode.replace('VHT', '').replace('HT', '')
# we need to override htmode
... | def __netjson_channel_width(self, radio):
"""
determines NetJSON channel_width radio attribute
"""
htmode = radio.pop('htmode')
if htmode == 'NONE':
return 20
channel_width = htmode.replace('VHT', '').replace('HT', '')
# we need to override htmode
... | [
"determines",
"NetJSON",
"channel_width",
"radio",
"attribute"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/radios.py#L115-L127 | [
"def",
"__netjson_channel_width",
"(",
"self",
",",
"radio",
")",
":",
"htmode",
"=",
"radio",
".",
"pop",
"(",
"'htmode'",
")",
"if",
"htmode",
"==",
"'NONE'",
":",
"return",
"20",
"channel_width",
"=",
"htmode",
".",
"replace",
"(",
"'VHT'",
",",
"''",... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenWrtRenderer.cleanup | Generates consistent OpenWRT/LEDE UCI output | netjsonconfig/backends/openwrt/renderer.py | def cleanup(self, output):
"""
Generates consistent OpenWRT/LEDE UCI output
"""
# correct indentation
output = output.replace(' ', '')\
.replace('\noption', '\n\toption')\
.replace('\nlist', '\n\tlist')
# convert True to 1 ... | def cleanup(self, output):
"""
Generates consistent OpenWRT/LEDE UCI output
"""
# correct indentation
output = output.replace(' ', '')\
.replace('\noption', '\n\toption')\
.replace('\nlist', '\n\tlist')
# convert True to 1 ... | [
"Generates",
"consistent",
"OpenWRT",
"/",
"LEDE",
"UCI",
"output"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/renderer.py#L8-L25 | [
"def",
"cleanup",
"(",
"self",
",",
"output",
")",
":",
"# correct indentation",
"output",
"=",
"output",
".",
"replace",
"(",
"' '",
",",
"''",
")",
".",
"replace",
"(",
"'\\noption'",
",",
"'\\n\\toption'",
")",
".",
"replace",
"(",
"'\\nlist'",
",",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenVpn._generate_contents | Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None | netjsonconfig/backends/openvpn/openvpn.py | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
text = self.render(files=False)
# create a list with all the packages (and remove empty entries)
vpn_instances = vpn_patte... | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
text = self.render(files=False)
# create a list with all the packages (and remove empty entries)
vpn_instances = vpn_patte... | [
"Adds",
"configuration",
"files",
"to",
"tarfile",
"instance",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openvpn/openvpn.py#L19-L41 | [
"def",
"_generate_contents",
"(",
"self",
",",
"tar",
")",
":",
"text",
"=",
"self",
".",
"render",
"(",
"files",
"=",
"False",
")",
"# create a list with all the packages (and remove empty entries)",
"vpn_instances",
"=",
"vpn_pattern",
".",
"split",
"(",
"text",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenVpn.auto_client | Returns a configuration dictionary representing an OpenVPN client configuration
that is compatible with the passed server configuration.
:param host: remote VPN server
:param server: dictionary representing a single OpenVPN server configuration
:param ca_path: optional string representi... | netjsonconfig/backends/openvpn/openvpn.py | def auto_client(cls, host, server, ca_path=None, ca_contents=None,
cert_path=None, cert_contents=None, key_path=None,
key_contents=None):
"""
Returns a configuration dictionary representing an OpenVPN client configuration
that is compatible with the passed... | def auto_client(cls, host, server, ca_path=None, ca_contents=None,
cert_path=None, cert_contents=None, key_path=None,
key_contents=None):
"""
Returns a configuration dictionary representing an OpenVPN client configuration
that is compatible with the passed... | [
"Returns",
"a",
"configuration",
"dictionary",
"representing",
"an",
"OpenVPN",
"client",
"configuration",
"that",
"is",
"compatible",
"with",
"the",
"passed",
"server",
"configuration",
"."
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openvpn/openvpn.py#L44-L110 | [
"def",
"auto_client",
"(",
"cls",
",",
"host",
",",
"server",
",",
"ca_path",
"=",
"None",
",",
"ca_contents",
"=",
"None",
",",
"cert_path",
"=",
"None",
",",
"cert_contents",
"=",
"None",
",",
"key_path",
"=",
"None",
",",
"key_contents",
"=",
"None",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | OpenVpn._auto_client_files | returns a list of NetJSON extra files for automatically generated clients
produces side effects in ``client`` dictionary | netjsonconfig/backends/openvpn/openvpn.py | def _auto_client_files(cls, client, ca_path=None, ca_contents=None, cert_path=None,
cert_contents=None, key_path=None, key_contents=None):
"""
returns a list of NetJSON extra files for automatically generated clients
produces side effects in ``client`` dictionary
... | def _auto_client_files(cls, client, ca_path=None, ca_contents=None, cert_path=None,
cert_contents=None, key_path=None, key_contents=None):
"""
returns a list of NetJSON extra files for automatically generated clients
produces side effects in ``client`` dictionary
... | [
"returns",
"a",
"list",
"of",
"NetJSON",
"extra",
"files",
"for",
"automatically",
"generated",
"clients",
"produces",
"side",
"effects",
"in",
"client",
"dictionary"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openvpn/openvpn.py#L113-L135 | [
"def",
"_auto_client_files",
"(",
"cls",
",",
"client",
",",
"ca_path",
"=",
"None",
",",
"ca_contents",
"=",
"None",
",",
"cert_path",
"=",
"None",
",",
"cert_contents",
"=",
"None",
",",
"key_path",
"=",
"None",
",",
"key_contents",
"=",
"None",
")",
"... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | get_install_requires | parse requirements.txt, ignore links, exclude comments | setup.py | def get_install_requires():
"""
parse requirements.txt, ignore links, exclude comments
"""
requirements = []
for line in open('requirements.txt').readlines():
# skip to next iteration if comment or empty line
if line.startswith('#') or line == '' or line.startswith('http') or line.st... | def get_install_requires():
"""
parse requirements.txt, ignore links, exclude comments
"""
requirements = []
for line in open('requirements.txt').readlines():
# skip to next iteration if comment or empty line
if line.startswith('#') or line == '' or line.startswith('http') or line.st... | [
"parse",
"requirements",
".",
"txt",
"ignore",
"links",
"exclude",
"comments"
] | openwisp/netjsonconfig | python | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/setup.py#L36-L50 | [
"def",
"get_install_requires",
"(",
")",
":",
"requirements",
"=",
"[",
"]",
"for",
"line",
"in",
"open",
"(",
"'requirements.txt'",
")",
".",
"readlines",
"(",
")",
":",
"# skip to next iteration if comment or empty line",
"if",
"line",
".",
"startswith",
"(",
... | c23ce9732720856e2f6dc54060db71a8182c7d4b |
valid | Report.events | Get all events for this report. Additional arguments may also be
specified that will be passed to the query function. | pypuppetdb/types.py | def events(self, **kwargs):
"""Get all events for this report. Additional arguments may also be
specified that will be passed to the query function.
"""
return self.__api.events(query=EqualsOperator("report", self.hash_),
**kwargs) | def events(self, **kwargs):
"""Get all events for this report. Additional arguments may also be
specified that will be passed to the query function.
"""
return self.__api.events(query=EqualsOperator("report", self.hash_),
**kwargs) | [
"Get",
"all",
"events",
"for",
"this",
"report",
".",
"Additional",
"arguments",
"may",
"also",
"be",
"specified",
"that",
"will",
"be",
"passed",
"to",
"the",
"query",
"function",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L211-L216 | [
"def",
"events",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__api",
".",
"events",
"(",
"query",
"=",
"EqualsOperator",
"(",
"\"report\"",
",",
"self",
".",
"hash_",
")",
",",
"*",
"*",
"kwargs",
")"
] | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | Node.facts | Get all facts of this node. Additional arguments may also be
specified that will be passed to the query function. | pypuppetdb/types.py | def facts(self, **kwargs):
"""Get all facts of this node. Additional arguments may also be
specified that will be passed to the query function.
"""
return self.__api.facts(query=EqualsOperator("certname", self.name),
**kwargs) | def facts(self, **kwargs):
"""Get all facts of this node. Additional arguments may also be
specified that will be passed to the query function.
"""
return self.__api.facts(query=EqualsOperator("certname", self.name),
**kwargs) | [
"Get",
"all",
"facts",
"of",
"this",
"node",
".",
"Additional",
"arguments",
"may",
"also",
"be",
"specified",
"that",
"will",
"be",
"passed",
"to",
"the",
"query",
"function",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L454-L459 | [
"def",
"facts",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__api",
".",
"facts",
"(",
"query",
"=",
"EqualsOperator",
"(",
"\"certname\"",
",",
"self",
".",
"name",
")",
",",
"*",
"*",
"kwargs",
")"
] | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | Node.fact | Get a single fact from this node. | pypuppetdb/types.py | def fact(self, name):
"""Get a single fact from this node."""
facts = self.facts(name=name)
return next(fact for fact in facts) | def fact(self, name):
"""Get a single fact from this node."""
facts = self.facts(name=name)
return next(fact for fact in facts) | [
"Get",
"a",
"single",
"fact",
"from",
"this",
"node",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L461-L464 | [
"def",
"fact",
"(",
"self",
",",
"name",
")",
":",
"facts",
"=",
"self",
".",
"facts",
"(",
"name",
"=",
"name",
")",
"return",
"next",
"(",
"fact",
"for",
"fact",
"in",
"facts",
")"
] | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | Node.resources | Get all resources of this node or all resources of the specified
type. Additional arguments may also be specified that will be passed
to the query function. | pypuppetdb/types.py | def resources(self, type_=None, title=None, **kwargs):
"""Get all resources of this node or all resources of the specified
type. Additional arguments may also be specified that will be passed
to the query function.
"""
if type_ is None:
resources = self.__api.resource... | def resources(self, type_=None, title=None, **kwargs):
"""Get all resources of this node or all resources of the specified
type. Additional arguments may also be specified that will be passed
to the query function.
"""
if type_ is None:
resources = self.__api.resource... | [
"Get",
"all",
"resources",
"of",
"this",
"node",
"or",
"all",
"resources",
"of",
"the",
"specified",
"type",
".",
"Additional",
"arguments",
"may",
"also",
"be",
"specified",
"that",
"will",
"be",
"passed",
"to",
"the",
"query",
"function",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L466-L486 | [
"def",
"resources",
"(",
"self",
",",
"type_",
"=",
"None",
",",
"title",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"type_",
"is",
"None",
":",
"resources",
"=",
"self",
".",
"__api",
".",
"resources",
"(",
"query",
"=",
"EqualsOperator",... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | Node.resource | Get a resource matching the supplied type and title. Additional
arguments may also be specified that will be passed to the query
function. | pypuppetdb/types.py | def resource(self, type_, title, **kwargs):
"""Get a resource matching the supplied type and title. Additional
arguments may also be specified that will be passed to the query
function.
"""
resources = self.__api.resources(
type_=type_,
title=title,
... | def resource(self, type_, title, **kwargs):
"""Get a resource matching the supplied type and title. Additional
arguments may also be specified that will be passed to the query
function.
"""
resources = self.__api.resources(
type_=type_,
title=title,
... | [
"Get",
"a",
"resource",
"matching",
"the",
"supplied",
"type",
"and",
"title",
".",
"Additional",
"arguments",
"may",
"also",
"be",
"specified",
"that",
"will",
"be",
"passed",
"to",
"the",
"query",
"function",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L488-L498 | [
"def",
"resource",
"(",
"self",
",",
"type_",
",",
"title",
",",
"*",
"*",
"kwargs",
")",
":",
"resources",
"=",
"self",
".",
"__api",
".",
"resources",
"(",
"type_",
"=",
"type_",
",",
"title",
"=",
"title",
",",
"query",
"=",
"EqualsOperator",
"(",... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | Node.reports | Get all reports for this node. Additional arguments may also be
specified that will be passed to the query function. | pypuppetdb/types.py | def reports(self, **kwargs):
"""Get all reports for this node. Additional arguments may also be
specified that will be passed to the query function.
"""
return self.__api.reports(
query=EqualsOperator("certname", self.name),
**kwargs) | def reports(self, **kwargs):
"""Get all reports for this node. Additional arguments may also be
specified that will be passed to the query function.
"""
return self.__api.reports(
query=EqualsOperator("certname", self.name),
**kwargs) | [
"Get",
"all",
"reports",
"for",
"this",
"node",
".",
"Additional",
"arguments",
"may",
"also",
"be",
"specified",
"that",
"will",
"be",
"passed",
"to",
"the",
"query",
"function",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L500-L506 | [
"def",
"reports",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__api",
".",
"reports",
"(",
"query",
"=",
"EqualsOperator",
"(",
"\"certname\"",
",",
"self",
".",
"name",
")",
",",
"*",
"*",
"kwargs",
")"
] | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.base_url | A base_url that will be used to construct the final
URL we're going to query against.
:returns: A URL of the form: ``proto://host:port``.
:rtype: :obj:`string` | pypuppetdb/api.py | def base_url(self):
"""A base_url that will be used to construct the final
URL we're going to query against.
:returns: A URL of the form: ``proto://host:port``.
:rtype: :obj:`string`
"""
return '{proto}://{host}:{port}{url_path}'.format(
proto=self.protocol,
... | def base_url(self):
"""A base_url that will be used to construct the final
URL we're going to query against.
:returns: A URL of the form: ``proto://host:port``.
:rtype: :obj:`string`
"""
return '{proto}://{host}:{port}{url_path}'.format(
proto=self.protocol,
... | [
"A",
"base_url",
"that",
"will",
"be",
"used",
"to",
"construct",
"the",
"final",
"URL",
"we",
"re",
"going",
"to",
"query",
"against",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L189-L201 | [
"def",
"base_url",
"(",
"self",
")",
":",
"return",
"'{proto}://{host}:{port}{url_path}'",
".",
"format",
"(",
"proto",
"=",
"self",
".",
"protocol",
",",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
",",
"url_path",
"=",
"sel... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI._url | The complete URL we will end up querying. Depending on the
endpoint we pass in this will result in different URL's with
different prefixes.
:param endpoint: The PuppetDB API endpoint we want to query.
:type endpoint: :obj:`string`
:param path: An additional path if we don't wis... | pypuppetdb/api.py | def _url(self, endpoint, path=None):
"""The complete URL we will end up querying. Depending on the
endpoint we pass in this will result in different URL's with
different prefixes.
:param endpoint: The PuppetDB API endpoint we want to query.
:type endpoint: :obj:`string`
... | def _url(self, endpoint, path=None):
"""The complete URL we will end up querying. Depending on the
endpoint we pass in this will result in different URL's with
different prefixes.
:param endpoint: The PuppetDB API endpoint we want to query.
:type endpoint: :obj:`string`
... | [
"The",
"complete",
"URL",
"we",
"will",
"end",
"up",
"querying",
".",
"Depending",
"on",
"the",
"endpoint",
"we",
"pass",
"in",
"this",
"will",
"result",
"in",
"different",
"URL",
"s",
"with",
"different",
"prefixes",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L224-L259 | [
"def",
"_url",
"(",
"self",
",",
"endpoint",
",",
"path",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'_url called with endpoint: {0} and path: {1}'",
".",
"format",
"(",
"endpoint",
",",
"path",
")",
")",
"try",
":",
"endpoint",
"=",
"ENDPOINTS",
"[... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI._query | This method actually querries PuppetDB. Provided an endpoint and an
optional path and/or query it will fire a request at PuppetDB. If
PuppetDB can be reached and answers within the timeout we'll decode
the response and give it back or raise for the HTTP Status Code
PuppetDB gave back.
... | pypuppetdb/api.py | def _query(self, endpoint, path=None, query=None,
order_by=None, limit=None, offset=None, include_total=False,
summarize_by=None, count_by=None, count_filter=None,
request_method='GET'):
"""This method actually querries PuppetDB. Provided an endpoint and an
o... | def _query(self, endpoint, path=None, query=None,
order_by=None, limit=None, offset=None, include_total=False,
summarize_by=None, count_by=None, count_filter=None,
request_method='GET'):
"""This method actually querries PuppetDB. Provided an endpoint and an
o... | [
"This",
"method",
"actually",
"querries",
"PuppetDB",
".",
"Provided",
"an",
"endpoint",
"and",
"an",
"optional",
"path",
"and",
"/",
"or",
"query",
"it",
"will",
"fire",
"a",
"request",
"at",
"PuppetDB",
".",
"If",
"PuppetDB",
"can",
"be",
"reached",
"and... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L261-L386 | [
"def",
"_query",
"(",
"self",
",",
"endpoint",
",",
"path",
"=",
"None",
",",
"query",
"=",
"None",
",",
"order_by",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"include_total",
"=",
"False",
",",
"summarize_by",
"=",
"No... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.nodes | Query for nodes by either name or query. If both aren't
provided this will return a list of all nodes. This method
also fetches the nodes status and event counts of the latest
report from puppetdb.
:param with_status: (optional) include the node status in the\
... | pypuppetdb/api.py | def nodes(self, unreported=2, with_status=False, **kwargs):
"""Query for nodes by either name or query. If both aren't
provided this will return a list of all nodes. This method
also fetches the nodes status and event counts of the latest
report from puppetdb.
:param with_status... | def nodes(self, unreported=2, with_status=False, **kwargs):
"""Query for nodes by either name or query. If both aren't
provided this will return a list of all nodes. This method
also fetches the nodes status and event counts of the latest
report from puppetdb.
:param with_status... | [
"Query",
"for",
"nodes",
"by",
"either",
"name",
"or",
"query",
".",
"If",
"both",
"aren",
"t",
"provided",
"this",
"will",
"return",
"a",
"list",
"of",
"all",
"nodes",
".",
"This",
"method",
"also",
"fetches",
"the",
"nodes",
"status",
"and",
"event",
... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L390-L486 | [
"def",
"nodes",
"(",
"self",
",",
"unreported",
"=",
"2",
",",
"with_status",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"nodes",
"=",
"self",
".",
"_query",
"(",
"'nodes'",
",",
"*",
"*",
"kwargs",
")",
"now",
"=",
"datetime",
".",
"datetime... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.node | Gets a single node from PuppetDB.
:param name: The name of the node search.
:type name: :obj:`string`
:return: An instance of Node
:rtype: :class:`pypuppetdb.types.Node` | pypuppetdb/api.py | def node(self, name):
"""Gets a single node from PuppetDB.
:param name: The name of the node search.
:type name: :obj:`string`
:return: An instance of Node
:rtype: :class:`pypuppetdb.types.Node`
"""
nodes = self.nodes(path=name)
return next(node for node... | def node(self, name):
"""Gets a single node from PuppetDB.
:param name: The name of the node search.
:type name: :obj:`string`
:return: An instance of Node
:rtype: :class:`pypuppetdb.types.Node`
"""
nodes = self.nodes(path=name)
return next(node for node... | [
"Gets",
"a",
"single",
"node",
"from",
"PuppetDB",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L488-L498 | [
"def",
"node",
"(",
"self",
",",
"name",
")",
":",
"nodes",
"=",
"self",
".",
"nodes",
"(",
"path",
"=",
"name",
")",
"return",
"next",
"(",
"node",
"for",
"node",
"in",
"nodes",
")"
] | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.edges | Get the known catalog edges, formed between two resources.
:param \*\*kwargs: The rest of the keyword arguments are passed
to the _query function.
:returns: A generating yielding Edges.
:rtype: :class:`pypuppetdb.types.Edge` | pypuppetdb/api.py | def edges(self, **kwargs):
"""Get the known catalog edges, formed between two resources.
:param \*\*kwargs: The rest of the keyword arguments are passed
to the _query function.
:returns: A generating yielding Edges.
:rtype: :class:`pypuppetdb.types.Edge`
... | def edges(self, **kwargs):
"""Get the known catalog edges, formed between two resources.
:param \*\*kwargs: The rest of the keyword arguments are passed
to the _query function.
:returns: A generating yielding Edges.
:rtype: :class:`pypuppetdb.types.Edge`
... | [
"Get",
"the",
"known",
"catalog",
"edges",
"formed",
"between",
"two",
"resources",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L500-L519 | [
"def",
"edges",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"edges",
"=",
"self",
".",
"_query",
"(",
"'edges'",
",",
"*",
"*",
"kwargs",
")",
"for",
"edge",
"in",
"edges",
":",
"identifier_source",
"=",
"edge",
"[",
"'source_type'",
"]",
"+",
... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.facts | Query for facts limited by either name, value and/or query.
:param name: (Optional) Only return facts that match this name.
:type name: :obj:`string`
:param value: (Optional) Only return facts of `name` that\
match this value. Use of this parameter requires the `name`\
p... | pypuppetdb/api.py | def facts(self, name=None, value=None, **kwargs):
"""Query for facts limited by either name, value and/or query.
:param name: (Optional) Only return facts that match this name.
:type name: :obj:`string`
:param value: (Optional) Only return facts of `name` that\
match this va... | def facts(self, name=None, value=None, **kwargs):
"""Query for facts limited by either name, value and/or query.
:param name: (Optional) Only return facts that match this name.
:type name: :obj:`string`
:param value: (Optional) Only return facts of `name` that\
match this va... | [
"Query",
"for",
"facts",
"limited",
"by",
"either",
"name",
"value",
"and",
"/",
"or",
"query",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L532-L561 | [
"def",
"facts",
"(",
"self",
",",
"name",
"=",
"None",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"not",
"None",
"and",
"value",
"is",
"not",
"None",
":",
"path",
"=",
"'{0}/{1}'",
".",
"format",
"(",
"name"... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.resources | Query for resources limited by either type and/or title or query.
This will yield a Resources object for every returned resource.
:param type_: (Optional) The resource type. This can be any resource
type referenced in\
'https://docs.puppetlabs.com/references/latest/type.html'
... | pypuppetdb/api.py | def resources(self, type_=None, title=None, **kwargs):
"""Query for resources limited by either type and/or title or query.
This will yield a Resources object for every returned resource.
:param type_: (Optional) The resource type. This can be any resource
type referenced in\
... | def resources(self, type_=None, title=None, **kwargs):
"""Query for resources limited by either type and/or title or query.
This will yield a Resources object for every returned resource.
:param type_: (Optional) The resource type. This can be any resource
type referenced in\
... | [
"Query",
"for",
"resources",
"limited",
"by",
"either",
"type",
"and",
"/",
"or",
"title",
"or",
"query",
".",
"This",
"will",
"yield",
"a",
"Resources",
"object",
"for",
"every",
"returned",
"resource",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L601-L641 | [
"def",
"resources",
"(",
"self",
",",
"type_",
"=",
"None",
",",
"title",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"None",
"if",
"type_",
"is",
"not",
"None",
":",
"type_",
"=",
"self",
".",
"_normalize_resource_type",
"(",
"type_... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.catalog | Get the available catalog for a given node.
:param node: (Required) The name of the PuppetDB node.
:type: :obj:`string`
:returns: An instance of Catalog
:rtype: :class:`pypuppetdb.types.Catalog` | pypuppetdb/api.py | def catalog(self, node):
"""Get the available catalog for a given node.
:param node: (Required) The name of the PuppetDB node.
:type: :obj:`string`
:returns: An instance of Catalog
:rtype: :class:`pypuppetdb.types.Catalog`
"""
catalogs = self.catalogs(path=node)... | def catalog(self, node):
"""Get the available catalog for a given node.
:param node: (Required) The name of the PuppetDB node.
:type: :obj:`string`
:returns: An instance of Catalog
:rtype: :class:`pypuppetdb.types.Catalog`
"""
catalogs = self.catalogs(path=node)... | [
"Get",
"the",
"available",
"catalog",
"for",
"a",
"given",
"node",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L643-L653 | [
"def",
"catalog",
"(",
"self",
",",
"node",
")",
":",
"catalogs",
"=",
"self",
".",
"catalogs",
"(",
"path",
"=",
"node",
")",
"return",
"next",
"(",
"x",
"for",
"x",
"in",
"catalogs",
")"
] | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.catalogs | Get the catalog information from the infrastructure based on path
and/or query results. It is strongly recommended to include query
and/or paging parameters for this endpoint to prevent large result
sets or PuppetDB performance bottlenecks.
:param \*\*kwargs: The rest of the keyword arg... | pypuppetdb/api.py | def catalogs(self, **kwargs):
"""Get the catalog information from the infrastructure based on path
and/or query results. It is strongly recommended to include query
and/or paging parameters for this endpoint to prevent large result
sets or PuppetDB performance bottlenecks.
:para... | def catalogs(self, **kwargs):
"""Get the catalog information from the infrastructure based on path
and/or query results. It is strongly recommended to include query
and/or paging parameters for this endpoint to prevent large result
sets or PuppetDB performance bottlenecks.
:para... | [
"Get",
"the",
"catalog",
"information",
"from",
"the",
"infrastructure",
"based",
"on",
"path",
"and",
"/",
"or",
"query",
"results",
".",
"It",
"is",
"strongly",
"recommended",
"to",
"include",
"query",
"and",
"/",
"or",
"paging",
"parameters",
"for",
"this... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L655-L680 | [
"def",
"catalogs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"catalogs",
"=",
"self",
".",
"_query",
"(",
"'catalogs'",
",",
"*",
"*",
"kwargs",
")",
"if",
"type",
"(",
"catalogs",
")",
"==",
"dict",
":",
"catalogs",
"=",
"[",
"catalogs",
","... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.events | A report is made up of events which can be queried either
individually or based on their associated report hash. It is strongly
recommended to include query and/or paging parameters for this
endpoint to prevent large result sets or PuppetDB performance
bottlenecks.
:param \*\*kw... | pypuppetdb/api.py | def events(self, **kwargs):
"""A report is made up of events which can be queried either
individually or based on their associated report hash. It is strongly
recommended to include query and/or paging parameters for this
endpoint to prevent large result sets or PuppetDB performance
... | def events(self, **kwargs):
"""A report is made up of events which can be queried either
individually or based on their associated report hash. It is strongly
recommended to include query and/or paging parameters for this
endpoint to prevent large result sets or PuppetDB performance
... | [
"A",
"report",
"is",
"made",
"up",
"of",
"events",
"which",
"can",
"be",
"queried",
"either",
"individually",
"or",
"based",
"on",
"their",
"associated",
"report",
"hash",
".",
"It",
"is",
"strongly",
"recommended",
"to",
"include",
"query",
"and",
"/",
"o... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L682-L712 | [
"def",
"events",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"events",
"=",
"self",
".",
"_query",
"(",
"'events'",
",",
"*",
"*",
"kwargs",
")",
"for",
"event",
"in",
"events",
":",
"yield",
"Event",
"(",
"node",
"=",
"event",
"[",
"'certname'... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.aggregate_event_counts | Get event counts from puppetdb aggregated into a single map.
:param summarize_by: (Required) The object type to be counted on.
Valid values are 'containing_class', 'resource'
and 'certname' or any comma-separated value
there... | pypuppetdb/api.py | def aggregate_event_counts(self, summarize_by, query=None,
count_by=None, count_filter=None):
"""Get event counts from puppetdb aggregated into a single map.
:param summarize_by: (Required) The object type to be counted on.
Valid values are 'c... | def aggregate_event_counts(self, summarize_by, query=None,
count_by=None, count_filter=None):
"""Get event counts from puppetdb aggregated into a single map.
:param summarize_by: (Required) The object type to be counted on.
Valid values are 'c... | [
"Get",
"event",
"counts",
"from",
"puppetdb",
"aggregated",
"into",
"a",
"single",
"map",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L742-L771 | [
"def",
"aggregate_event_counts",
"(",
"self",
",",
"summarize_by",
",",
"query",
"=",
"None",
",",
"count_by",
"=",
"None",
",",
"count_filter",
"=",
"None",
")",
":",
"return",
"self",
".",
"_query",
"(",
"'aggregate-event-counts'",
",",
"query",
"=",
"quer... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.reports | Get reports for our infrastructure. It is strongly recommended
to include query and/or paging parameters for this endpoint to
prevent large result sets and potential PuppetDB performance
bottlenecks.
:param \*\*kwargs: The rest of the keyword arguments are passed
... | pypuppetdb/api.py | def reports(self, **kwargs):
"""Get reports for our infrastructure. It is strongly recommended
to include query and/or paging parameters for this endpoint to
prevent large result sets and potential PuppetDB performance
bottlenecks.
:param \*\*kwargs: The rest of the keyword argu... | def reports(self, **kwargs):
"""Get reports for our infrastructure. It is strongly recommended
to include query and/or paging parameters for this endpoint to
prevent large result sets and potential PuppetDB performance
bottlenecks.
:param \*\*kwargs: The rest of the keyword argu... | [
"Get",
"reports",
"for",
"our",
"infrastructure",
".",
"It",
"is",
"strongly",
"recommended",
"to",
"include",
"query",
"and",
"/",
"or",
"paging",
"parameters",
"for",
"this",
"endpoint",
"to",
"prevent",
"large",
"result",
"sets",
"and",
"potential",
"Puppet... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L802-L836 | [
"def",
"reports",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"reports",
"=",
"self",
".",
"_query",
"(",
"'reports'",
",",
"*",
"*",
"kwargs",
")",
"for",
"report",
"in",
"reports",
":",
"yield",
"Report",
"(",
"api",
"=",
"self",
",",
"node",... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | BaseAPI.inventory | Get Node and Fact information with an alternative query syntax
for structured facts instead of using the facts, fact-contents and
factsets endpoints for many fact-related queries.
:param \*\*kwargs: The rest of the keyword arguments are passed
to the _query function.
... | pypuppetdb/api.py | def inventory(self, **kwargs):
"""Get Node and Fact information with an alternative query syntax
for structured facts instead of using the facts, fact-contents and
factsets endpoints for many fact-related queries.
:param \*\*kwargs: The rest of the keyword arguments are passed
... | def inventory(self, **kwargs):
"""Get Node and Fact information with an alternative query syntax
for structured facts instead of using the facts, fact-contents and
factsets endpoints for many fact-related queries.
:param \*\*kwargs: The rest of the keyword arguments are passed
... | [
"Get",
"Node",
"and",
"Fact",
"information",
"with",
"an",
"alternative",
"query",
"syntax",
"for",
"structured",
"facts",
"instead",
"of",
"using",
"the",
"facts",
"fact",
"-",
"contents",
"and",
"factsets",
"endpoints",
"for",
"many",
"fact",
"-",
"related",... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L838-L857 | [
"def",
"inventory",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"inventory",
"=",
"self",
".",
"_query",
"(",
"'inventory'",
",",
"*",
"*",
"kwargs",
")",
"for",
"inv",
"in",
"inventory",
":",
"yield",
"Inventory",
"(",
"node",
"=",
"inv",
"[",
... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | versioncmp | Compares two objects, x and y, and returns an integer according to the
outcome. The return value is negative if x < y, zero if x == y and
positive if x > y.
:param v1: The first object to compare.
:param v2: The second object to compare.
:returns: -1, 0 or 1.
:rtype: :obj:`int` | pypuppetdb/utils.py | def versioncmp(v1, v2):
"""Compares two objects, x and y, and returns an integer according to the
outcome. The return value is negative if x < y, zero if x == y and
positive if x > y.
:param v1: The first object to compare.
:param v2: The second object to compare.
:returns: -1, 0 or 1.
:rt... | def versioncmp(v1, v2):
"""Compares two objects, x and y, and returns an integer according to the
outcome. The return value is negative if x < y, zero if x == y and
positive if x > y.
:param v1: The first object to compare.
:param v2: The second object to compare.
:returns: -1, 0 or 1.
:rt... | [
"Compares",
"two",
"objects",
"x",
"and",
"y",
"and",
"returns",
"an",
"integer",
"according",
"to",
"the",
"outcome",
".",
"The",
"return",
"value",
"is",
"negative",
"if",
"x",
"<",
"y",
"zero",
"if",
"x",
"==",
"y",
"and",
"positive",
"if",
"x",
"... | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/utils.py#L47-L73 | [
"def",
"versioncmp",
"(",
"v1",
",",
"v2",
")",
":",
"def",
"normalize",
"(",
"v",
")",
":",
"\"\"\"Removes leading zeroes from right of a decimal point from v and\n returns an array of values separated by '.'\n\n :param v: The data to normalize.\n\n :returns: An lis... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | connect | Connect with PuppetDB. This will return an object allowing you
to query the API through its methods.
:param host: (Default: 'localhost;) Hostname or IP of PuppetDB.
:type host: :obj:`string`
:param port: (Default: '8080') Port on which to talk to PuppetDB.
:type port: :obj:`int`
:param ssl_ve... | pypuppetdb/__init__.py | def connect(host='localhost', port=8080, ssl_verify=False, ssl_key=None,
ssl_cert=None, timeout=10, protocol=None, url_path='/',
username=None, password=None, token=None):
"""Connect with PuppetDB. This will return an object allowing you
to query the API through its methods.
:param ... | def connect(host='localhost', port=8080, ssl_verify=False, ssl_key=None,
ssl_cert=None, timeout=10, protocol=None, url_path='/',
username=None, password=None, token=None):
"""Connect with PuppetDB. This will return an object allowing you
to query the API through its methods.
:param ... | [
"Connect",
"with",
"PuppetDB",
".",
"This",
"will",
"return",
"an",
"object",
"allowing",
"you",
"to",
"query",
"the",
"API",
"through",
"its",
"methods",
"."
] | voxpupuli/pypuppetdb | python | https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/__init__.py#L73-L122 | [
"def",
"connect",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"8080",
",",
"ssl_verify",
"=",
"False",
",",
"ssl_key",
"=",
"None",
",",
"ssl_cert",
"=",
"None",
",",
"timeout",
"=",
"10",
",",
"protocol",
"=",
"None",
",",
"url_path",
"=",
"'... | cedeecf48014b4ad5b8e2513ca8230c814f45603 |
valid | collection_callback | :type result: opendnp3.CommandPointResult | examples/master.py | def collection_callback(result=None):
"""
:type result: opendnp3.CommandPointResult
"""
print("Header: {0} | Index: {1} | State: {2} | Status: {3}".format(
result.headerIndex,
result.index,
opendnp3.CommandPointStateToString(result.state),
opendnp3.CommandStatusToString... | def collection_callback(result=None):
"""
:type result: opendnp3.CommandPointResult
"""
print("Header: {0} | Index: {1} | State: {2} | Status: {3}".format(
result.headerIndex,
result.index,
opendnp3.CommandPointStateToString(result.state),
opendnp3.CommandStatusToString... | [
":",
"type",
"result",
":",
"opendnp3",
".",
"CommandPointResult"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L247-L256 | [
"def",
"collection_callback",
"(",
"result",
"=",
"None",
")",
":",
"print",
"(",
"\"Header: {0} | Index: {1} | State: {2} | Status: {3}\"",
".",
"format",
"(",
"result",
".",
"headerIndex",
",",
"result",
".",
"index",
",",
"opendnp3",
".",
"CommandPointStateToStri... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | command_callback | :type result: opendnp3.ICommandTaskResult | examples/master.py | def command_callback(result=None):
"""
:type result: opendnp3.ICommandTaskResult
"""
print("Received command result with summary: {}".format(opendnp3.TaskCompletionToString(result.summary)))
result.ForeachItem(collection_callback) | def command_callback(result=None):
"""
:type result: opendnp3.ICommandTaskResult
"""
print("Received command result with summary: {}".format(opendnp3.TaskCompletionToString(result.summary)))
result.ForeachItem(collection_callback) | [
":",
"type",
"result",
":",
"opendnp3",
".",
"ICommandTaskResult"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L259-L264 | [
"def",
"command_callback",
"(",
"result",
"=",
"None",
")",
":",
"print",
"(",
"\"Received command result with summary: {}\"",
".",
"format",
"(",
"opendnp3",
".",
"TaskCompletionToString",
"(",
"result",
".",
"summary",
")",
")",
")",
"result",
".",
"ForeachItem"... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | main | The Master has been started from the command line. Execute ad-hoc tests if desired. | examples/master.py | def main():
"""The Master has been started from the command line. Execute ad-hoc tests if desired."""
# app = MyMaster()
app = MyMaster(log_handler=MyLogger(),
listener=AppChannelListener(),
soe_handler=SOEHandler(),
master_application=MasterApplicati... | def main():
"""The Master has been started from the command line. Execute ad-hoc tests if desired."""
# app = MyMaster()
app = MyMaster(log_handler=MyLogger(),
listener=AppChannelListener(),
soe_handler=SOEHandler(),
master_application=MasterApplicati... | [
"The",
"Master",
"has",
"been",
"started",
"from",
"the",
"command",
"line",
".",
"Execute",
"ad",
"-",
"hoc",
"tests",
"if",
"desired",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L274-L285 | [
"def",
"main",
"(",
")",
":",
"# app = MyMaster()",
"app",
"=",
"MyMaster",
"(",
"log_handler",
"=",
"MyLogger",
"(",
")",
",",
"listener",
"=",
"AppChannelListener",
"(",
")",
",",
"soe_handler",
"=",
"SOEHandler",
"(",
")",
",",
"master_application",
"=",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MyMaster.send_direct_operate_command | Direct operate a single command
:param command: command to operate
:param index: index of the command
:param callback: callback that will be invoked upon completion or failure
:param config: optional configuration that controls normal callbacks and allows the user to be specified for SA | examples/master.py | def send_direct_operate_command(self, command, index, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Direct operate a single command
:param command: command to operate
:param index: index of the comma... | def send_direct_operate_command(self, command, index, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Direct operate a single command
:param command: command to operate
:param index: index of the comma... | [
"Direct",
"operate",
"a",
"single",
"command"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L94-L104 | [
"def",
"send_direct_operate_command",
"(",
"self",
",",
"command",
",",
"index",
",",
"callback",
"=",
"asiodnp3",
".",
"PrintingCommandCallback",
".",
"Get",
"(",
")",
",",
"config",
"=",
"opendnp3",
".",
"TaskConfig",
"(",
")",
".",
"Default",
"(",
")",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MyMaster.send_direct_operate_command_set | Direct operate a set of commands
:param command_set: set of command headers
:param callback: callback that will be invoked upon completion or failure
:param config: optional configuration that controls normal callbacks and allows the user to be specified for SA | examples/master.py | def send_direct_operate_command_set(self, command_set, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Direct operate a set of commands
:param command_set: set of command headers
:param callback: c... | def send_direct_operate_command_set(self, command_set, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Direct operate a set of commands
:param command_set: set of command headers
:param callback: c... | [
"Direct",
"operate",
"a",
"set",
"of",
"commands"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L106-L115 | [
"def",
"send_direct_operate_command_set",
"(",
"self",
",",
"command_set",
",",
"callback",
"=",
"asiodnp3",
".",
"PrintingCommandCallback",
".",
"Get",
"(",
")",
",",
"config",
"=",
"opendnp3",
".",
"TaskConfig",
"(",
")",
".",
"Default",
"(",
")",
")",
":"... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MyMaster.send_select_and_operate_command | Select and operate a single command
:param command: command to operate
:param index: index of the command
:param callback: callback that will be invoked upon completion or failure
:param config: optional configuration that controls normal callbacks and allows the user to be specified fo... | examples/master.py | def send_select_and_operate_command(self, command, index, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Select and operate a single command
:param command: command to operate
:param index: index ... | def send_select_and_operate_command(self, command, index, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Select and operate a single command
:param command: command to operate
:param index: index ... | [
"Select",
"and",
"operate",
"a",
"single",
"command"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L117-L127 | [
"def",
"send_select_and_operate_command",
"(",
"self",
",",
"command",
",",
"index",
",",
"callback",
"=",
"asiodnp3",
".",
"PrintingCommandCallback",
".",
"Get",
"(",
")",
",",
"config",
"=",
"opendnp3",
".",
"TaskConfig",
"(",
")",
".",
"Default",
"(",
")"... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MyMaster.send_select_and_operate_command_set | Select and operate a set of commands
:param command_set: set of command headers
:param callback: callback that will be invoked upon completion or failure
:param config: optional configuration that controls normal callbacks and allows the user to be specified for SA | examples/master.py | def send_select_and_operate_command_set(self, command_set, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Select and operate a set of commands
:param command_set: set of command headers
:param... | def send_select_and_operate_command_set(self, command_set, callback=asiodnp3.PrintingCommandCallback.Get(),
config=opendnp3.TaskConfig().Default()):
"""
Select and operate a set of commands
:param command_set: set of command headers
:param... | [
"Select",
"and",
"operate",
"a",
"set",
"of",
"commands"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L129-L138 | [
"def",
"send_select_and_operate_command_set",
"(",
"self",
",",
"command_set",
",",
"callback",
"=",
"asiodnp3",
".",
"PrintingCommandCallback",
".",
"Get",
"(",
")",
",",
"config",
"=",
"opendnp3",
".",
"TaskConfig",
"(",
")",
".",
"Default",
"(",
")",
")",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | SOEHandler.Process | Process measurement data.
:param info: HeaderInfo
:param values: A collection of values received from the Outstation (various data types are possible). | examples/master.py | def Process(self, info, values):
"""
Process measurement data.
:param info: HeaderInfo
:param values: A collection of values received from the Outstation (various data types are possible).
"""
visitor_class_types = {
opendnp3.ICollectionIndexedBinary: Vis... | def Process(self, info, values):
"""
Process measurement data.
:param info: HeaderInfo
:param values: A collection of values received from the Outstation (various data types are possible).
"""
visitor_class_types = {
opendnp3.ICollectionIndexedBinary: Vis... | [
"Process",
"measurement",
"data",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L186-L208 | [
"def",
"Process",
"(",
"self",
",",
"info",
",",
"values",
")",
":",
"visitor_class_types",
"=",
"{",
"opendnp3",
".",
"ICollectionIndexedBinary",
":",
"VisitorIndexedBinary",
",",
"opendnp3",
".",
"ICollectionIndexedDoubleBitBinary",
":",
"VisitorIndexedDoubleBitBinary... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | main | The Outstation has been started from the command line. Execute ad-hoc tests if desired. | examples/outstation.py | def main():
"""The Outstation has been started from the command line. Execute ad-hoc tests if desired."""
app = OutstationApplication()
_log.debug('Initialization complete. In command loop.')
# Ad-hoc tests can be inserted here if desired. See outstation_cmd.py for examples.
app.shutdown()
_log.... | def main():
"""The Outstation has been started from the command line. Execute ad-hoc tests if desired."""
app = OutstationApplication()
_log.debug('Initialization complete. In command loop.')
# Ad-hoc tests can be inserted here if desired. See outstation_cmd.py for examples.
app.shutdown()
_log.... | [
"The",
"Outstation",
"has",
"been",
"started",
"from",
"the",
"command",
"line",
".",
"Execute",
"ad",
"-",
"hoc",
"tests",
"if",
"desired",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L284-L291 | [
"def",
"main",
"(",
")",
":",
"app",
"=",
"OutstationApplication",
"(",
")",
"_log",
".",
"debug",
"(",
"'Initialization complete. In command loop.'",
")",
"# Ad-hoc tests can be inserted here if desired. See outstation_cmd.py for examples.",
"app",
".",
"shutdown",
"(",
")... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationApplication.configure_stack | Set up the OpenDNP3 configuration. | examples/outstation.py | def configure_stack():
"""Set up the OpenDNP3 configuration."""
stack_config = asiodnp3.OutstationStackConfig(opendnp3.DatabaseSizes.AllTypes(10))
stack_config.outstation.eventBufferConfig = opendnp3.EventBufferConfig().AllTypes(10)
stack_config.outstation.params.allowUnsolicited = True
... | def configure_stack():
"""Set up the OpenDNP3 configuration."""
stack_config = asiodnp3.OutstationStackConfig(opendnp3.DatabaseSizes.AllTypes(10))
stack_config.outstation.eventBufferConfig = opendnp3.EventBufferConfig().AllTypes(10)
stack_config.outstation.params.allowUnsolicited = True
... | [
"Set",
"up",
"the",
"OpenDNP3",
"configuration",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L84-L92 | [
"def",
"configure_stack",
"(",
")",
":",
"stack_config",
"=",
"asiodnp3",
".",
"OutstationStackConfig",
"(",
"opendnp3",
".",
"DatabaseSizes",
".",
"AllTypes",
"(",
"10",
")",
")",
"stack_config",
".",
"outstation",
".",
"eventBufferConfig",
"=",
"opendnp3",
"."... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationApplication.configure_database | Configure the Outstation's database of input point definitions.
Configure two Analog points (group/variation 30.1) at indexes 1 and 2.
Configure two Binary points (group/variation 1.2) at indexes 1 and 2. | examples/outstation.py | def configure_database(db_config):
"""
Configure the Outstation's database of input point definitions.
Configure two Analog points (group/variation 30.1) at indexes 1 and 2.
Configure two Binary points (group/variation 1.2) at indexes 1 and 2.
"""
db_config.a... | def configure_database(db_config):
"""
Configure the Outstation's database of input point definitions.
Configure two Analog points (group/variation 30.1) at indexes 1 and 2.
Configure two Binary points (group/variation 1.2) at indexes 1 and 2.
"""
db_config.a... | [
"Configure",
"the",
"Outstation",
"s",
"database",
"of",
"input",
"point",
"definitions",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L95-L113 | [
"def",
"configure_database",
"(",
"db_config",
")",
":",
"db_config",
".",
"analog",
"[",
"1",
"]",
".",
"clazz",
"=",
"opendnp3",
".",
"PointClass",
".",
"Class2",
"db_config",
".",
"analog",
"[",
"1",
"]",
".",
"svariation",
"=",
"opendnp3",
".",
"Stat... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationApplication.GetApplicationIIN | Return the application-controlled IIN field. | examples/outstation.py | def GetApplicationIIN(self):
"""Return the application-controlled IIN field."""
application_iin = opendnp3.ApplicationIIN()
application_iin.configCorrupt = False
application_iin.deviceTrouble = False
application_iin.localControl = False
application_iin.needTime = False
... | def GetApplicationIIN(self):
"""Return the application-controlled IIN field."""
application_iin = opendnp3.ApplicationIIN()
application_iin.configCorrupt = False
application_iin.deviceTrouble = False
application_iin.localControl = False
application_iin.needTime = False
... | [
"Return",
"the",
"application",
"-",
"controlled",
"IIN",
"field",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L155-L166 | [
"def",
"GetApplicationIIN",
"(",
"self",
")",
":",
"application_iin",
"=",
"opendnp3",
".",
"ApplicationIIN",
"(",
")",
"application_iin",
".",
"configCorrupt",
"=",
"False",
"application_iin",
".",
"deviceTrouble",
"=",
"False",
"application_iin",
".",
"localContro... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationApplication.process_point_value | A PointValue was received from the Master. Process its payload.
:param command_type: (string) Either 'Select' or 'Operate'.
:param command: A ControlRelayOutputBlock or else a wrapped data value (AnalogOutputInt16, etc.).
:param index: (integer) DNP3 index of the payload's data definition.
... | examples/outstation.py | def process_point_value(cls, command_type, command, index, op_type):
"""
A PointValue was received from the Master. Process its payload.
:param command_type: (string) Either 'Select' or 'Operate'.
:param command: A ControlRelayOutputBlock or else a wrapped data value (AnalogOutputIn... | def process_point_value(cls, command_type, command, index, op_type):
"""
A PointValue was received from the Master. Process its payload.
:param command_type: (string) Either 'Select' or 'Operate'.
:param command: A ControlRelayOutputBlock or else a wrapped data value (AnalogOutputIn... | [
"A",
"PointValue",
"was",
"received",
"from",
"the",
"Master",
".",
"Process",
"its",
"payload",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L190-L199 | [
"def",
"process_point_value",
"(",
"cls",
",",
"command_type",
",",
"command",
",",
"index",
",",
"op_type",
")",
":",
"_log",
".",
"debug",
"(",
"'Processing received point value for index {}: {}'",
".",
"format",
"(",
"index",
",",
"command",
")",
")"
] | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationApplication.apply_update | Record an opendnp3 data value (Analog, Binary, etc.) in the outstation's database.
The data value gets sent to the Master as a side-effect.
:param value: An instance of Analog, Binary, or another opendnp3 data value.
:param index: (integer) Index of the data definition in the opendnp3 data... | examples/outstation.py | def apply_update(self, value, index):
"""
Record an opendnp3 data value (Analog, Binary, etc.) in the outstation's database.
The data value gets sent to the Master as a side-effect.
:param value: An instance of Analog, Binary, or another opendnp3 data value.
:param inde... | def apply_update(self, value, index):
"""
Record an opendnp3 data value (Analog, Binary, etc.) in the outstation's database.
The data value gets sent to the Master as a side-effect.
:param value: An instance of Analog, Binary, or another opendnp3 data value.
:param inde... | [
"Record",
"an",
"opendnp3",
"data",
"value",
"(",
"Analog",
"Binary",
"etc",
".",
")",
"in",
"the",
"outstation",
"s",
"database",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L201-L214 | [
"def",
"apply_update",
"(",
"self",
",",
"value",
",",
"index",
")",
":",
"_log",
".",
"debug",
"(",
"'Recording {} measurement, index={}, value={}'",
".",
"format",
"(",
"type",
"(",
"value",
")",
".",
"__name__",
",",
"index",
",",
"value",
".",
"value",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.