repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
greenelab/PathCORE-T | pathcore/network.py | CoNetwork._augment_network | def _augment_network(self, edge_dict):
"""Given a dictionary of edges (edge id -> feature list), add all of
these to the CoNetwork object
"""
for (vertex0, vertex1), feature_list in edge_dict.items():
edge_obj = Edge(vertex0, vertex1, feature_list)
self.edges[(ver... | python | def _augment_network(self, edge_dict):
"""Given a dictionary of edges (edge id -> feature list), add all of
these to the CoNetwork object
"""
for (vertex0, vertex1), feature_list in edge_dict.items():
edge_obj = Edge(vertex0, vertex1, feature_list)
self.edges[(ver... | [
"def",
"_augment_network",
"(",
"self",
",",
"edge_dict",
")",
":",
"for",
"(",
"vertex0",
",",
"vertex1",
")",
",",
"feature_list",
"in",
"edge_dict",
".",
"items",
"(",
")",
":",
"edge_obj",
"=",
"Edge",
"(",
"vertex0",
",",
"vertex1",
",",
"feature_li... | Given a dictionary of edges (edge id -> feature list), add all of
these to the CoNetwork object | [
"Given",
"a",
"dictionary",
"of",
"edges",
"(",
"edge",
"id",
"-",
">",
"feature",
"list",
")",
"add",
"all",
"of",
"these",
"to",
"the",
"CoNetwork",
"object"
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L512-L520 | train | Augment the CoNetwork object with the edges from a dictionary of edges. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork._edges_from_permutation | def _edges_from_permutation(self, feature_pathway_dict):
"""Given a dictionary mapping each feature to the pathways
overrepresented in the feature, build a CoNetwork by
creating edges for every pairwise combination of pathways in a feature.
"""
network_edges = {}
for feat... | python | def _edges_from_permutation(self, feature_pathway_dict):
"""Given a dictionary mapping each feature to the pathways
overrepresented in the feature, build a CoNetwork by
creating edges for every pairwise combination of pathways in a feature.
"""
network_edges = {}
for feat... | [
"def",
"_edges_from_permutation",
"(",
"self",
",",
"feature_pathway_dict",
")",
":",
"network_edges",
"=",
"{",
"}",
"for",
"feature",
",",
"pathway_list",
"in",
"feature_pathway_dict",
".",
"items",
"(",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"("... | Given a dictionary mapping each feature to the pathways
overrepresented in the feature, build a CoNetwork by
creating edges for every pairwise combination of pathways in a feature. | [
"Given",
"a",
"dictionary",
"mapping",
"each",
"feature",
"to",
"the",
"pathways",
"overrepresented",
"in",
"the",
"feature",
"build",
"a",
"CoNetwork",
"by",
"creating",
"edges",
"for",
"every",
"pairwise",
"combination",
"of",
"pathways",
"in",
"a",
"feature",... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L522-L537 | train | Given a dictionary mapping each feature to the pathways
overrepresented in the feature build a CoNetwork by creating edges for every pair of pathways in the feature. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork._collect_pathways_by_feature | def _collect_pathways_by_feature(self, pathway_feature_tuples):
"""Given a tuple list [(pathway, feature)], create a dictionary
mapping each feature to the pathways overrepresented in the feature.
"""
pathways_in_feature = {}
for (pathway, feature) in pathway_feature_tuples:
... | python | def _collect_pathways_by_feature(self, pathway_feature_tuples):
"""Given a tuple list [(pathway, feature)], create a dictionary
mapping each feature to the pathways overrepresented in the feature.
"""
pathways_in_feature = {}
for (pathway, feature) in pathway_feature_tuples:
... | [
"def",
"_collect_pathways_by_feature",
"(",
"self",
",",
"pathway_feature_tuples",
")",
":",
"pathways_in_feature",
"=",
"{",
"}",
"for",
"(",
"pathway",
",",
"feature",
")",
"in",
"pathway_feature_tuples",
":",
"vertex",
"=",
"self",
".",
"add_pathway",
"(",
"p... | Given a tuple list [(pathway, feature)], create a dictionary
mapping each feature to the pathways overrepresented in the feature. | [
"Given",
"a",
"tuple",
"list",
"[",
"(",
"pathway",
"feature",
")",
"]",
"create",
"a",
"dictionary",
"mapping",
"each",
"feature",
"to",
"the",
"pathways",
"overrepresented",
"in",
"the",
"feature",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L539-L549 | train | Given a list of tuples of pathway and feature return a dictionary mapping each feature to the pathways overrepresented in the feature. |
pyQode/pyqode.cobol | pyqode/cobol/api/folding.py | CobolFoldDetector.normalize_text | def normalize_text(self, text):
"""
Normalize text, when fixed format is ON, replace the first 6 chars by a space.
"""
if not self.editor.free_format:
text = ' ' * 6 + text[6:]
return text.upper() | python | def normalize_text(self, text):
"""
Normalize text, when fixed format is ON, replace the first 6 chars by a space.
"""
if not self.editor.free_format:
text = ' ' * 6 + text[6:]
return text.upper() | [
"def",
"normalize_text",
"(",
"self",
",",
"text",
")",
":",
"if",
"not",
"self",
".",
"editor",
".",
"free_format",
":",
"text",
"=",
"' '",
"*",
"6",
"+",
"text",
"[",
"6",
":",
"]",
"return",
"text",
".",
"upper",
"(",
")"
] | Normalize text, when fixed format is ON, replace the first 6 chars by a space. | [
"Normalize",
"text",
"when",
"fixed",
"format",
"is",
"ON",
"replace",
"the",
"first",
"6",
"chars",
"by",
"a",
"space",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/folding.py#L43-L49 | train | Normalize text when fixed format is ON replace the first 6 chars by a space. |
BernardFW/bernard | src/bernard/engine/state.py | BaseState.health_check | async def health_check(cls) -> Iterator[HealthCheckFail]:
"""
Perform checks of the state itself. So far:
- For each method of the class, check for the presence of a
health_check() method. If the method is present then call it. This is
used to allow the context decorator to ... | python | async def health_check(cls) -> Iterator[HealthCheckFail]:
"""
Perform checks of the state itself. So far:
- For each method of the class, check for the presence of a
health_check() method. If the method is present then call it. This is
used to allow the context decorator to ... | [
"async",
"def",
"health_check",
"(",
"cls",
")",
"->",
"Iterator",
"[",
"HealthCheckFail",
"]",
":",
"for",
"k",
",",
"v",
"in",
"cls",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"'health_check'",
")",
"and",
"calla... | Perform checks of the state itself. So far:
- For each method of the class, check for the presence of a
health_check() method. If the method is present then call it. This is
used to allow the context decorator to make some checks on the
structure of the class. | [
"Perform",
"checks",
"of",
"the",
"state",
"itself",
".",
"So",
"far",
":"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/state.py#L59-L72 | train | Iterate over the health checks of the state. |
GuiltyTargets/ppi-network-annotation | src/ppi_network_annotation/model/neighborhood_network.py | NeighborhoodNetwork.get_neighborhood_network | def get_neighborhood_network(self, node_name: str, order: int = 1) -> Graph:
"""Get the neighborhood graph of a node.
:param str node_name: Node whose neighborhood graph is requested.
:return Graph: Neighborhood graph
"""
logger.info("In get_neighborhood_graph()")
neighb... | python | def get_neighborhood_network(self, node_name: str, order: int = 1) -> Graph:
"""Get the neighborhood graph of a node.
:param str node_name: Node whose neighborhood graph is requested.
:return Graph: Neighborhood graph
"""
logger.info("In get_neighborhood_graph()")
neighb... | [
"def",
"get_neighborhood_network",
"(",
"self",
",",
"node_name",
":",
"str",
",",
"order",
":",
"int",
"=",
"1",
")",
"->",
"Graph",
":",
"logger",
".",
"info",
"(",
"\"In get_neighborhood_graph()\"",
")",
"neighbors",
"=",
"list",
"(",
"self",
".",
"get_... | Get the neighborhood graph of a node.
:param str node_name: Node whose neighborhood graph is requested.
:return Graph: Neighborhood graph | [
"Get",
"the",
"neighborhood",
"graph",
"of",
"a",
"node",
"."
] | 4d7b6713485f2d0a0957e6457edc1b1b5a237460 | https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/neighborhood_network.py#L26-L36 | train | Get the neighborhood graph of a node. |
GuiltyTargets/ppi-network-annotation | src/ppi_network_annotation/model/neighborhood_network.py | NeighborhoodNetwork.get_neighbor_names | def get_neighbor_names(self, node_name: str, order: int = 1) -> list:
"""Get the names of all neighbors of a node, and the node itself.
:param node_name: Node whose neighbor names are requested.
:return: A list of names of all neighbors of a node, and the node itself.
"""
logger... | python | def get_neighbor_names(self, node_name: str, order: int = 1) -> list:
"""Get the names of all neighbors of a node, and the node itself.
:param node_name: Node whose neighbor names are requested.
:return: A list of names of all neighbors of a node, and the node itself.
"""
logger... | [
"def",
"get_neighbor_names",
"(",
"self",
",",
"node_name",
":",
"str",
",",
"order",
":",
"int",
"=",
"1",
")",
"->",
"list",
":",
"logger",
".",
"info",
"(",
"\"In get_neighbor_names()\"",
")",
"node",
"=",
"self",
".",
"graph",
".",
"vs",
".",
"find... | Get the names of all neighbors of a node, and the node itself.
:param node_name: Node whose neighbor names are requested.
:return: A list of names of all neighbors of a node, and the node itself. | [
"Get",
"the",
"names",
"of",
"all",
"neighbors",
"of",
"a",
"node",
"and",
"the",
"node",
"itself",
"."
] | 4d7b6713485f2d0a0957e6457edc1b1b5a237460 | https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/neighborhood_network.py#L38-L49 | train | Get the neighbor names of a node. |
GuiltyTargets/ppi-network-annotation | src/ppi_network_annotation/model/neighborhood_network.py | NeighborhoodNetwork.get_neighborhood_overlap | def get_neighborhood_overlap(self, node1, node2, connection_type=None):
"""Get the intersection of two nodes's neighborhoods.
Neighborhood is defined by parameter connection_type.
:param Vertex node1: First node.
:param Vertex node2: Second node.
:param Optional[str] connection_... | python | def get_neighborhood_overlap(self, node1, node2, connection_type=None):
"""Get the intersection of two nodes's neighborhoods.
Neighborhood is defined by parameter connection_type.
:param Vertex node1: First node.
:param Vertex node2: Second node.
:param Optional[str] connection_... | [
"def",
"get_neighborhood_overlap",
"(",
"self",
",",
"node1",
",",
"node2",
",",
"connection_type",
"=",
"None",
")",
":",
"if",
"connection_type",
"is",
"None",
"or",
"connection_type",
"==",
"\"direct\"",
":",
"order",
"=",
"1",
"elif",
"connection_type",
"=... | Get the intersection of two nodes's neighborhoods.
Neighborhood is defined by parameter connection_type.
:param Vertex node1: First node.
:param Vertex node2: Second node.
:param Optional[str] connection_type: One of direct or second-degree. Defaults to direct.
:return: Overlap ... | [
"Get",
"the",
"intersection",
"of",
"two",
"nodes",
"s",
"neighborhoods",
"."
] | 4d7b6713485f2d0a0957e6457edc1b1b5a237460 | https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/neighborhood_network.py#L51-L72 | train | Get the intersection of two nodes s neighborhoods. |
inveniosoftware/invenio-query-parser | invenio_query_parser/contrib/spires/parser.py | SpiresSmartValue.parse | def parse(cls, parser, text, pos): # pylint: disable=W0613
"""Match simple values excluding some Keywords like 'and' and 'or'"""
if not text.strip():
return text, SyntaxError("Invalid value")
class Rule(object):
grammar = attr('value', SpiresSimpleValue), omit(re.compil... | python | def parse(cls, parser, text, pos): # pylint: disable=W0613
"""Match simple values excluding some Keywords like 'and' and 'or'"""
if not text.strip():
return text, SyntaxError("Invalid value")
class Rule(object):
grammar = attr('value', SpiresSimpleValue), omit(re.compil... | [
"def",
"parse",
"(",
"cls",
",",
"parser",
",",
"text",
",",
"pos",
")",
":",
"# pylint: disable=W0613",
"if",
"not",
"text",
".",
"strip",
"(",
")",
":",
"return",
"text",
",",
"SyntaxError",
"(",
"\"Invalid value\"",
")",
"class",
"Rule",
"(",
"object"... | Match simple values excluding some Keywords like 'and' and 'or | [
"Match",
"simple",
"values",
"excluding",
"some",
"Keywords",
"like",
"and",
"and",
"or"
] | 21a2c36318003ff52d2e18e7196bb420db8ecb4b | https://github.com/inveniosoftware/invenio-query-parser/blob/21a2c36318003ff52d2e18e7196bb420db8ecb4b/invenio_query_parser/contrib/spires/parser.py#L64-L82 | train | Match simple values excluding some Keywords like and or |
rsgalloway/grit | grit/cmd/cmd.py | Git.execute | def execute(self, command,
istream=None,
with_keep_cwd=False,
with_extended_output=False,
with_exceptions=True,
as_process=False,
output_stream=None,
**subprocess_kwargs
):
"""Handles executing the command on the shell and consumes and returns
the returned information (stdout)
:... | python | def execute(self, command,
istream=None,
with_keep_cwd=False,
with_extended_output=False,
with_exceptions=True,
as_process=False,
output_stream=None,
**subprocess_kwargs
):
"""Handles executing the command on the shell and consumes and returns
the returned information (stdout)
:... | [
"def",
"execute",
"(",
"self",
",",
"command",
",",
"istream",
"=",
"None",
",",
"with_keep_cwd",
"=",
"False",
",",
"with_extended_output",
"=",
"False",
",",
"with_exceptions",
"=",
"True",
",",
"as_process",
"=",
"False",
",",
"output_stream",
"=",
"None"... | Handles executing the command on the shell and consumes and returns
the returned information (stdout)
:param command:
The command argument list to execute.
It should be a string, or a sequence of program arguments. The
program to execute is the first item in the args sequence or string.
:param istream:... | [
"Handles",
"executing",
"the",
"command",
"on",
"the",
"shell",
"and",
"consumes",
"and",
"returns",
"the",
"returned",
"information",
"(",
"stdout",
")"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cmd.py#L228-L359 | train | Executes a git command on the shell and returns the output of the command. |
rsgalloway/grit | grit/cmd/cmd.py | Git.transform_kwargs | def transform_kwargs(self, **kwargs):
"""Transforms Python style kwargs into git command line options."""
args = list()
for k, v in kwargs.items():
if len(k) == 1:
if v is True:
args.append("-%s" % k)
elif type(v) is not bool:
args.append("-%s%s" % (k, v))
else:
if v is True:
args... | python | def transform_kwargs(self, **kwargs):
"""Transforms Python style kwargs into git command line options."""
args = list()
for k, v in kwargs.items():
if len(k) == 1:
if v is True:
args.append("-%s" % k)
elif type(v) is not bool:
args.append("-%s%s" % (k, v))
else:
if v is True:
args... | [
"def",
"transform_kwargs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"k",
")",
"==",
"1",
":",
"if",
"v",
"is",
"True",
... | Transforms Python style kwargs into git command line options. | [
"Transforms",
"Python",
"style",
"kwargs",
"into",
"git",
"command",
"line",
"options",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cmd.py#L361-L375 | train | Transforms Python style kwargs into git command line options. |
rsgalloway/grit | grit/cmd/cmd.py | Git._call_process | def _call_process(self, method, *args, **kwargs):
"""Run the given git command with the specified arguments and return
the result as a String
:param method:
is the command. Contained "_" characters will be converted to dashes,
such as in 'ls_files' to call 'ls-files'.
:param args:
is the list of argu... | python | def _call_process(self, method, *args, **kwargs):
"""Run the given git command with the specified arguments and return
the result as a String
:param method:
is the command. Contained "_" characters will be converted to dashes,
such as in 'ls_files' to call 'ls-files'.
:param args:
is the list of argu... | [
"def",
"_call_process",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Handle optional arguments prior to calling transform_kwargs",
"# otherwise these'll end up in args, which is bad.",
"_kwargs",
"=",
"dict",
"(",
")",
"for",
"kwar... | Run the given git command with the specified arguments and return
the result as a String
:param method:
is the command. Contained "_" characters will be converted to dashes,
such as in 'ls_files' to call 'ls-files'.
:param args:
is the list of arguments. If None is included, it will be pruned.
This ... | [
"Run",
"the",
"given",
"git",
"command",
"with",
"the",
"specified",
"arguments",
"and",
"return",
"the",
"result",
"as",
"a",
"String"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cmd.py#L392-L432 | train | Execute a git command with the specified arguments and return the result. |
rsgalloway/grit | grit/cmd/cmd.py | Git.get_object_header | def get_object_header(self, ref):
""" Use this method to quickly examine the type and size of the object behind
the given ref.
:note: The method will only suffer from the costs of command invocation
once and reuses the command in subsequent calls.
:return: (hexsha, type_string, size_as_int)"""
cm... | python | def get_object_header(self, ref):
""" Use this method to quickly examine the type and size of the object behind
the given ref.
:note: The method will only suffer from the costs of command invocation
once and reuses the command in subsequent calls.
:return: (hexsha, type_string, size_as_int)"""
cm... | [
"def",
"get_object_header",
"(",
"self",
",",
"ref",
")",
":",
"cmd",
"=",
"self",
".",
"__get_persistent_cmd",
"(",
"\"cat_file_header\"",
",",
"\"cat_file\"",
",",
"batch_check",
"=",
"True",
")",
"return",
"self",
".",
"__get_object_header",
"(",
"cmd",
","... | Use this method to quickly examine the type and size of the object behind
the given ref.
:note: The method will only suffer from the costs of command invocation
once and reuses the command in subsequent calls.
:return: (hexsha, type_string, size_as_int) | [
"Use",
"this",
"method",
"to",
"quickly",
"examine",
"the",
"type",
"and",
"size",
"of",
"the",
"object",
"behind",
"the",
"given",
"ref",
".",
":",
"note",
":",
"The",
"method",
"will",
"only",
"suffer",
"from",
"the",
"costs",
"of",
"command",
"invocat... | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cmd.py#L480-L489 | train | This method will quickly examine the type and size of the object behind
enumerated by the given ref. |
rsgalloway/grit | grit/cmd/cmd.py | Git.stream_object_data | def stream_object_data(self, ref):
"""As get_object_header, but returns the data as a stream
:return: (hexsha, type_string, size_as_int, stream)
:note: This method is not threadsafe, you need one independent Command instance
per thread to be safe !"""
cmd = self.__get_persistent_cmd("cat_file_all", "cat_file... | python | def stream_object_data(self, ref):
"""As get_object_header, but returns the data as a stream
:return: (hexsha, type_string, size_as_int, stream)
:note: This method is not threadsafe, you need one independent Command instance
per thread to be safe !"""
cmd = self.__get_persistent_cmd("cat_file_all", "cat_file... | [
"def",
"stream_object_data",
"(",
"self",
",",
"ref",
")",
":",
"cmd",
"=",
"self",
".",
"__get_persistent_cmd",
"(",
"\"cat_file_all\"",
",",
"\"cat_file\"",
",",
"batch",
"=",
"True",
")",
"hexsha",
",",
"typename",
",",
"size",
"=",
"self",
".",
"__get_... | As get_object_header, but returns the data as a stream
:return: (hexsha, type_string, size_as_int, stream)
:note: This method is not threadsafe, you need one independent Command instance
per thread to be safe ! | [
"As",
"get_object_header",
"but",
"returns",
"the",
"data",
"as",
"a",
"stream",
":",
"return",
":",
"(",
"hexsha",
"type_string",
"size_as_int",
"stream",
")",
":",
"note",
":",
"This",
"method",
"is",
"not",
"threadsafe",
"you",
"need",
"one",
"independent... | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cmd.py#L500-L507 | train | As get_object_header but returns the data as a stream
return |
pyQode/pyqode.cobol | pyqode/cobol/api/pic.py | _clean_code | def _clean_code(code):
"""
Cleans the received code (the parser does not like extra spaces not a VALUE
statement). Returns the cleaned code as a list of lines.
:param code: The COBOL code to clean
:return The list of code lines (cleaned)
"""
lines = []
# cleanup lines, the parser is ve... | python | def _clean_code(code):
"""
Cleans the received code (the parser does not like extra spaces not a VALUE
statement). Returns the cleaned code as a list of lines.
:param code: The COBOL code to clean
:return The list of code lines (cleaned)
"""
lines = []
# cleanup lines, the parser is ve... | [
"def",
"_clean_code",
"(",
"code",
")",
":",
"lines",
"=",
"[",
"]",
"# cleanup lines, the parser is very sensitive to extra spaces,...",
"for",
"l",
"in",
"code",
".",
"splitlines",
"(",
")",
":",
"# remove last .",
"if",
"l",
".",
"endswith",
"(",
"'.'",
")",
... | Cleans the received code (the parser does not like extra spaces not a VALUE
statement). Returns the cleaned code as a list of lines.
:param code: The COBOL code to clean
:return The list of code lines (cleaned) | [
"Cleans",
"the",
"received",
"code",
"(",
"the",
"parser",
"does",
"not",
"like",
"extra",
"spaces",
"not",
"a",
"VALUE",
"statement",
")",
".",
"Returns",
"the",
"cleaned",
"code",
"as",
"a",
"list",
"of",
"lines",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/pic.py#L17-L44 | train | Cleans the received COBOL code. |
pyQode/pyqode.cobol | pyqode/cobol/api/pic.py | get_field_infos | def get_field_infos(code, free_format):
"""
Gets the list of pic fields information from line |start| to line |end|.
:param code: code to parse
:returns: the list of pic fields info found in the specified text.
"""
offset = 0
field_infos = []
lines = _clean_code(code)
previous_off... | python | def get_field_infos(code, free_format):
"""
Gets the list of pic fields information from line |start| to line |end|.
:param code: code to parse
:returns: the list of pic fields info found in the specified text.
"""
offset = 0
field_infos = []
lines = _clean_code(code)
previous_off... | [
"def",
"get_field_infos",
"(",
"code",
",",
"free_format",
")",
":",
"offset",
"=",
"0",
"field_infos",
"=",
"[",
"]",
"lines",
"=",
"_clean_code",
"(",
"code",
")",
"previous_offset",
"=",
"0",
"for",
"row",
"in",
"process_cobol",
"(",
"lines",
",",
"fr... | Gets the list of pic fields information from line |start| to line |end|.
:param code: code to parse
:returns: the list of pic fields info found in the specified text. | [
"Gets",
"the",
"list",
"of",
"pic",
"fields",
"information",
"from",
"line",
"|start|",
"to",
"line",
"|end|",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/pic.py#L47-L103 | train | Returns the list of pic fields info found in the specified text. |
walter426/Python_GoogleMapsApi | GoogleMapsApi/elevation.py | Elevation.GetElevation | def GetElevation(self, LatLngSet, sensor = False):
'''Get Elevation of input locations
LatLngSet: An coordinate array will be converted to proper location format here
Pls refer to the Google Maps Web API for the details of the remained parameters
'''
locations =... | python | def GetElevation(self, LatLngSet, sensor = False):
'''Get Elevation of input locations
LatLngSet: An coordinate array will be converted to proper location format here
Pls refer to the Google Maps Web API for the details of the remained parameters
'''
locations =... | [
"def",
"GetElevation",
"(",
"self",
",",
"LatLngSet",
",",
"sensor",
"=",
"False",
")",
":",
"locations",
"=",
"[",
"]",
"for",
"[",
"lat",
",",
"lng",
"]",
"in",
"LatLngSet",
":",
"locations",
".",
"append",
"(",
"str",
"(",
"lat",
")",
"+",
"\",\... | Get Elevation of input locations
LatLngSet: An coordinate array will be converted to proper location format here
Pls refer to the Google Maps Web API for the details of the remained parameters | [
"Get",
"Elevation",
"of",
"input",
"locations",
"LatLngSet",
":",
"An",
"coordinate",
"array",
"will",
"be",
"converted",
"to",
"proper",
"location",
"format",
"here",
"Pls",
"refer",
"to",
"the",
"Google",
"Maps",
"Web",
"API",
"for",
"the",
"details",
"of"... | 4832b293a0027446941a5f00ecc66256f92ddbce | https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/elevation.py#L33-L57 | train | Get Elevation of input locations
LatLngSet |
walter426/Python_GoogleMapsApi | GoogleMapsApi/GoogleMapsServiceParser.py | ServiceParser.get_signed_url | def get_signed_url(self, params):
'''Returns a Premier account signed url.'''
params['client'] = self.client_id
url_params = {'protocol': self.protocol, 'domain': self.domain,
'service': self.service, 'params': urlencode(params)}
secret = base... | python | def get_signed_url(self, params):
'''Returns a Premier account signed url.'''
params['client'] = self.client_id
url_params = {'protocol': self.protocol, 'domain': self.domain,
'service': self.service, 'params': urlencode(params)}
secret = base... | [
"def",
"get_signed_url",
"(",
"self",
",",
"params",
")",
":",
"params",
"[",
"'client'",
"]",
"=",
"self",
".",
"client_id",
"url_params",
"=",
"{",
"'protocol'",
":",
"self",
".",
"protocol",
",",
"'domain'",
":",
"self",
".",
"domain",
",",
"'service'... | Returns a Premier account signed url. | [
"Returns",
"a",
"Premier",
"account",
"signed",
"url",
"."
] | 4832b293a0027446941a5f00ecc66256f92ddbce | https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/GoogleMapsServiceParser.py#L85-L98 | train | Returns a Premier account signed url. |
walter426/Python_GoogleMapsApi | GoogleMapsApi/GoogleMapsServiceParser.py | ServiceParser.parse_json | def parse_json(self, page):
'''Returns json feed.'''
if not isinstance(page, basestring):
page = util.decode_page(page)
self.doc = json.loads(page)
results = self.doc.get(self.result_name, [])
if not results:
self.check_status(self.doc.ge... | python | def parse_json(self, page):
'''Returns json feed.'''
if not isinstance(page, basestring):
page = util.decode_page(page)
self.doc = json.loads(page)
results = self.doc.get(self.result_name, [])
if not results:
self.check_status(self.doc.ge... | [
"def",
"parse_json",
"(",
"self",
",",
"page",
")",
":",
"if",
"not",
"isinstance",
"(",
"page",
",",
"basestring",
")",
":",
"page",
"=",
"util",
".",
"decode_page",
"(",
"page",
")",
"self",
".",
"doc",
"=",
"json",
".",
"loads",
"(",
"page",
")"... | Returns json feed. | [
"Returns",
"json",
"feed",
"."
] | 4832b293a0027446941a5f00ecc66256f92ddbce | https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/GoogleMapsServiceParser.py#L112-L125 | train | Returns json feed. |
walter426/Python_GoogleMapsApi | GoogleMapsApi/GoogleMapsServiceParser.py | ServiceParser.check_status | def check_status(self, status):
'''Validates error statuses.'''
if status == 'ZERO_RESULTS':
raise GoogleServiceResultError(
'The Google service was successful but returned no results.')
elif status == 'OVER_QUERY_LIMIT':
raise GoogleServi... | python | def check_status(self, status):
'''Validates error statuses.'''
if status == 'ZERO_RESULTS':
raise GoogleServiceResultError(
'The Google service was successful but returned no results.')
elif status == 'OVER_QUERY_LIMIT':
raise GoogleServi... | [
"def",
"check_status",
"(",
"self",
",",
"status",
")",
":",
"if",
"status",
"==",
"'ZERO_RESULTS'",
":",
"raise",
"GoogleServiceResultError",
"(",
"'The Google service was successful but returned no results.'",
")",
"elif",
"status",
"==",
"'OVER_QUERY_LIMIT'",
":",
"r... | Validates error statuses. | [
"Validates",
"error",
"statuses",
"."
] | 4832b293a0027446941a5f00ecc66256f92ddbce | https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/GoogleMapsServiceParser.py#L128-L149 | train | Validates error statuses. |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | _determine_case | def _determine_case(was_upper, words, string):
"""
Determine case type of string.
Arguments:
was_upper {[type]} -- [description]
words {[type]} -- [description]
string {[type]} -- [description]
Returns:
- upper: All words are upper-case.
- lower: All words are l... | python | def _determine_case(was_upper, words, string):
"""
Determine case type of string.
Arguments:
was_upper {[type]} -- [description]
words {[type]} -- [description]
string {[type]} -- [description]
Returns:
- upper: All words are upper-case.
- lower: All words are l... | [
"def",
"_determine_case",
"(",
"was_upper",
",",
"words",
",",
"string",
")",
":",
"case_type",
"=",
"'unknown'",
"if",
"was_upper",
":",
"case_type",
"=",
"'upper'",
"elif",
"string",
".",
"islower",
"(",
")",
":",
"case_type",
"=",
"'lower'",
"elif",
"le... | Determine case type of string.
Arguments:
was_upper {[type]} -- [description]
words {[type]} -- [description]
string {[type]} -- [description]
Returns:
- upper: All words are upper-case.
- lower: All words are lower-case.
- pascal: All words are title-case or up... | [
"Determine",
"case",
"type",
"of",
"string",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L15-L60 | train | Determines the type of string. |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | _advanced_acronym_detection | def _advanced_acronym_detection(s, i, words, acronyms):
"""
Detect acronyms by checking against a list of acronyms.
Check a run of words represented by the range [s, i].
Return last index of new word groups.
"""
# Combine each letter into single string.
acstr = ''.join(words[s:i])
# Li... | python | def _advanced_acronym_detection(s, i, words, acronyms):
"""
Detect acronyms by checking against a list of acronyms.
Check a run of words represented by the range [s, i].
Return last index of new word groups.
"""
# Combine each letter into single string.
acstr = ''.join(words[s:i])
# Li... | [
"def",
"_advanced_acronym_detection",
"(",
"s",
",",
"i",
",",
"words",
",",
"acronyms",
")",
":",
"# Combine each letter into single string.",
"acstr",
"=",
"''",
".",
"join",
"(",
"words",
"[",
"s",
":",
"i",
"]",
")",
"# List of ranges representing found acrony... | Detect acronyms by checking against a list of acronyms.
Check a run of words represented by the range [s, i].
Return last index of new word groups. | [
"Detect",
"acronyms",
"by",
"checking",
"against",
"a",
"list",
"of",
"acronyms",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L63-L123 | train | Detect acronyms by checking against a list of words represented by the range [ s i ). |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | _simple_acronym_detection | def _simple_acronym_detection(s, i, words, *args):
"""Detect acronyms based on runs of upper-case letters."""
# Combine each letter into a single string.
acronym = ''.join(words[s:i])
# Remove original letters in word list.
for _ in xrange(s, i):
del words[s]
# Replace them with new wo... | python | def _simple_acronym_detection(s, i, words, *args):
"""Detect acronyms based on runs of upper-case letters."""
# Combine each letter into a single string.
acronym = ''.join(words[s:i])
# Remove original letters in word list.
for _ in xrange(s, i):
del words[s]
# Replace them with new wo... | [
"def",
"_simple_acronym_detection",
"(",
"s",
",",
"i",
",",
"words",
",",
"*",
"args",
")",
":",
"# Combine each letter into a single string.",
"acronym",
"=",
"''",
".",
"join",
"(",
"words",
"[",
"s",
":",
"i",
"]",
")",
"# Remove original letters in word lis... | Detect acronyms based on runs of upper-case letters. | [
"Detect",
"acronyms",
"based",
"on",
"runs",
"of",
"upper",
"-",
"case",
"letters",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L126-L138 | train | Simple acronym detection. |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | _sanitize_acronyms | def _sanitize_acronyms(unsafe_acronyms):
"""
Check acronyms against regex.
Normalize valid acronyms to upper-case.
If an invalid acronym is encountered raise InvalidAcronymError.
"""
valid_acronym = regex.compile(u'^[\p{Ll}\p{Lu}\p{Nd}]+$')
acronyms = []
for a in unsafe_acronyms:
... | python | def _sanitize_acronyms(unsafe_acronyms):
"""
Check acronyms against regex.
Normalize valid acronyms to upper-case.
If an invalid acronym is encountered raise InvalidAcronymError.
"""
valid_acronym = regex.compile(u'^[\p{Ll}\p{Lu}\p{Nd}]+$')
acronyms = []
for a in unsafe_acronyms:
... | [
"def",
"_sanitize_acronyms",
"(",
"unsafe_acronyms",
")",
":",
"valid_acronym",
"=",
"regex",
".",
"compile",
"(",
"u'^[\\p{Ll}\\p{Lu}\\p{Nd}]+$'",
")",
"acronyms",
"=",
"[",
"]",
"for",
"a",
"in",
"unsafe_acronyms",
":",
"if",
"valid_acronym",
".",
"match",
"("... | Check acronyms against regex.
Normalize valid acronyms to upper-case.
If an invalid acronym is encountered raise InvalidAcronymError. | [
"Check",
"acronyms",
"against",
"regex",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L150-L164 | train | Check acronyms against regex. |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | _normalize_words | def _normalize_words(words, acronyms):
"""Normalize case of each word to PascalCase."""
for i, _ in enumerate(words):
# if detect_acronyms:
if words[i].upper() in acronyms:
# Convert known acronyms to upper-case.
words[i] = words[i].upper()
else:
# Fal... | python | def _normalize_words(words, acronyms):
"""Normalize case of each word to PascalCase."""
for i, _ in enumerate(words):
# if detect_acronyms:
if words[i].upper() in acronyms:
# Convert known acronyms to upper-case.
words[i] = words[i].upper()
else:
# Fal... | [
"def",
"_normalize_words",
"(",
"words",
",",
"acronyms",
")",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"words",
")",
":",
"# if detect_acronyms:",
"if",
"words",
"[",
"i",
"]",
".",
"upper",
"(",
")",
"in",
"acronyms",
":",
"# Convert known ac... | Normalize case of each word to PascalCase. | [
"Normalize",
"case",
"of",
"each",
"word",
"to",
"PascalCase",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L167-L178 | train | Normalize case of each word to PascalCase. |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | _separate_words | def _separate_words(string):
"""
Segment string on separator into list of words.
Arguments:
string -- the string we want to process
Returns:
words -- list of words the string got minced to
separator -- the separator char intersecting words
was_upper -- whether string ha... | python | def _separate_words(string):
"""
Segment string on separator into list of words.
Arguments:
string -- the string we want to process
Returns:
words -- list of words the string got minced to
separator -- the separator char intersecting words
was_upper -- whether string ha... | [
"def",
"_separate_words",
"(",
"string",
")",
":",
"words",
"=",
"[",
"]",
"separator",
"=",
"\"\"",
"# Index of current character. Initially 1 because we don't want to check",
"# if the 0th character is a boundary.",
"i",
"=",
"1",
"# Index of first character in a sequence",
"... | Segment string on separator into list of words.
Arguments:
string -- the string we want to process
Returns:
words -- list of words the string got minced to
separator -- the separator char intersecting words
was_upper -- whether string happened to be upper-case | [
"Segment",
"string",
"on",
"separator",
"into",
"list",
"of",
"words",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L181-L252 | train | This function separates the string into a list of words. |
AlejandroFrias/case-conversion | case_conversion/case_parse.py | parse_case | def parse_case(string, acronyms=None, preserve_case=False):
"""
Parse a stringiable into a list of words.
Also returns the case type, which can be one of the following:
- upper: All words are upper-case.
- lower: All words are lower-case.
- pascal: All words are title-case or upper-... | python | def parse_case(string, acronyms=None, preserve_case=False):
"""
Parse a stringiable into a list of words.
Also returns the case type, which can be one of the following:
- upper: All words are upper-case.
- lower: All words are lower-case.
- pascal: All words are title-case or upper-... | [
"def",
"parse_case",
"(",
"string",
",",
"acronyms",
"=",
"None",
",",
"preserve_case",
"=",
"False",
")",
":",
"words",
",",
"separator",
",",
"was_upper",
"=",
"_separate_words",
"(",
"string",
")",
"if",
"acronyms",
":",
"# Use advanced acronym detection with... | Parse a stringiable into a list of words.
Also returns the case type, which can be one of the following:
- upper: All words are upper-case.
- lower: All words are lower-case.
- pascal: All words are title-case or upper-case. Note that the
stringiable may still have separat... | [
"Parse",
"a",
"stringiable",
"into",
"a",
"list",
"of",
"words",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L255-L319 | train | Parses a stringiable into a list of words. |
jpscaletti/authcode | authcode/auth_views_mixin.py | ViewsMixin.render_template | def render_template(self, name, **kwargs):
"""Search for a setting named ``template_<name>`` and renders it.
If one is not defined it uses the default template of the library
at ``autchode/templates/<name>,html``.
To render the template uses the ``render`` function, a property that
... | python | def render_template(self, name, **kwargs):
"""Search for a setting named ``template_<name>`` and renders it.
If one is not defined it uses the default template of the library
at ``autchode/templates/<name>,html``.
To render the template uses the ``render`` function, a property that
... | [
"def",
"render_template",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"custom_template",
"=",
"getattr",
"(",
"self",
",",
"'template_'",
"+",
"name",
")",
"if",
"custom_template",
":",
"return",
"self",
".",
"render",
"(",
"custom_templat... | Search for a setting named ``template_<name>`` and renders it.
If one is not defined it uses the default template of the library
at ``autchode/templates/<name>,html``.
To render the template uses the ``render`` function, a property that
has been probably overwritten in a ``auth.setup_fo... | [
"Search",
"for",
"a",
"setting",
"named",
"template_<name",
">",
"and",
"renders",
"it",
".",
"If",
"one",
"is",
"not",
"defined",
"it",
"uses",
"the",
"default",
"template",
"of",
"the",
"library",
"at",
"autchode",
"/",
"templates",
"/",
"<name",
">",
... | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/auth_views_mixin.py#L44-L57 | train | Render a template with the given name. |
jpscaletti/authcode | authcode/auth_views_mixin.py | ViewsMixin.send_email | def send_email(self, user, subject, msg):
"""Should be overwritten in the setup"""
print('To:', user)
print('Subject:', subject)
print(msg) | python | def send_email(self, user, subject, msg):
"""Should be overwritten in the setup"""
print('To:', user)
print('Subject:', subject)
print(msg) | [
"def",
"send_email",
"(",
"self",
",",
"user",
",",
"subject",
",",
"msg",
")",
":",
"print",
"(",
"'To:'",
",",
"user",
")",
"print",
"(",
"'Subject:'",
",",
"subject",
")",
"print",
"(",
"msg",
")"
] | Should be overwritten in the setup | [
"Should",
"be",
"overwritten",
"in",
"the",
"setup"
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/auth_views_mixin.py#L67-L71 | train | Send an email to the specified user. |
BernardFW/bernard | src/bernard/i18n/intents.py | IntentsDb.update | def update(self, new_data: IntentDict):
"""
Receive an update from the loaders.
"""
for locale, data in new_data.items():
if locale not in self.dict:
self.dict[locale] = {}
self.dict[locale].update(data) | python | def update(self, new_data: IntentDict):
"""
Receive an update from the loaders.
"""
for locale, data in new_data.items():
if locale not in self.dict:
self.dict[locale] = {}
self.dict[locale].update(data) | [
"def",
"update",
"(",
"self",
",",
"new_data",
":",
"IntentDict",
")",
":",
"for",
"locale",
",",
"data",
"in",
"new_data",
".",
"items",
"(",
")",
":",
"if",
"locale",
"not",
"in",
"self",
".",
"dict",
":",
"self",
".",
"dict",
"[",
"locale",
"]",... | Receive an update from the loaders. | [
"Receive",
"an",
"update",
"from",
"the",
"loaders",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/intents.py#L52-L61 | train | Update the dictionary with the new data. |
BernardFW/bernard | src/bernard/i18n/intents.py | IntentsDb.get | def get(self, key: Text, locale: Optional[Text]) -> List[Tuple[Text, ...]]:
"""
Get a single set of intents.
"""
locale = self.choose_locale(locale)
return self.dict[locale][key] | python | def get(self, key: Text, locale: Optional[Text]) -> List[Tuple[Text, ...]]:
"""
Get a single set of intents.
"""
locale = self.choose_locale(locale)
return self.dict[locale][key] | [
"def",
"get",
"(",
"self",
",",
"key",
":",
"Text",
",",
"locale",
":",
"Optional",
"[",
"Text",
"]",
")",
"->",
"List",
"[",
"Tuple",
"[",
"Text",
",",
"...",
"]",
"]",
":",
"locale",
"=",
"self",
".",
"choose_locale",
"(",
"locale",
")",
"retur... | Get a single set of intents. | [
"Get",
"a",
"single",
"set",
"of",
"intents",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/intents.py#L63-L70 | train | Get a single set of intents. |
BernardFW/bernard | src/bernard/i18n/intents.py | Intent.strings | async def strings(self, request: Optional['Request']=None) \
-> List[Tuple[Text, ...]]:
"""
For the given request, find the list of strings of that intent. If the
intent does not exist, it will raise a KeyError.
"""
if request:
locale = await request.get_... | python | async def strings(self, request: Optional['Request']=None) \
-> List[Tuple[Text, ...]]:
"""
For the given request, find the list of strings of that intent. If the
intent does not exist, it will raise a KeyError.
"""
if request:
locale = await request.get_... | [
"async",
"def",
"strings",
"(",
"self",
",",
"request",
":",
"Optional",
"[",
"'Request'",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"Tuple",
"[",
"Text",
",",
"...",
"]",
"]",
":",
"if",
"request",
":",
"locale",
"=",
"await",
"request",
".",
"get... | For the given request, find the list of strings of that intent. If the
intent does not exist, it will raise a KeyError. | [
"For",
"the",
"given",
"request",
"find",
"the",
"list",
"of",
"strings",
"of",
"that",
"intent",
".",
"If",
"the",
"intent",
"does",
"not",
"exist",
"it",
"will",
"raise",
"a",
"KeyError",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/intents.py#L90-L102 | train | Returns the list of strings for the given intent. |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_unitless_standard_names | def get_unitless_standard_names():
'''
Returns a list of valid standard_names that are allowed to be unitless
'''
global _UNITLESS_DB
if _UNITLESS_DB is None:
with open(resource_filename('cc_plugin_ncei', 'data/unitless.json'), 'r') as f:
_UNITLESS_DB = json.load(f)
return _U... | python | def get_unitless_standard_names():
'''
Returns a list of valid standard_names that are allowed to be unitless
'''
global _UNITLESS_DB
if _UNITLESS_DB is None:
with open(resource_filename('cc_plugin_ncei', 'data/unitless.json'), 'r') as f:
_UNITLESS_DB = json.load(f)
return _U... | [
"def",
"get_unitless_standard_names",
"(",
")",
":",
"global",
"_UNITLESS_DB",
"if",
"_UNITLESS_DB",
"is",
"None",
":",
"with",
"open",
"(",
"resource_filename",
"(",
"'cc_plugin_ncei'",
",",
"'data/unitless.json'",
")",
",",
"'r'",
")",
"as",
"f",
":",
"_UNITLE... | Returns a list of valid standard_names that are allowed to be unitless | [
"Returns",
"a",
"list",
"of",
"valid",
"standard_names",
"that",
"are",
"allowed",
"to",
"be",
"unitless"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L16-L24 | train | Returns a list of valid standard names that are allowed to be unitless
|
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_sea_names | def get_sea_names():
'''
Returns a list of NODC sea names
source of list: http://www.nodc.noaa.gov/General/NODC-Archive/seanames.xml
'''
global _SEA_NAMES
if _SEA_NAMES is None:
resource_text = get_data("cc_plugin_ncei", "data/seanames.xml")
parser = etree.XMLParser(remove_blank... | python | def get_sea_names():
'''
Returns a list of NODC sea names
source of list: http://www.nodc.noaa.gov/General/NODC-Archive/seanames.xml
'''
global _SEA_NAMES
if _SEA_NAMES is None:
resource_text = get_data("cc_plugin_ncei", "data/seanames.xml")
parser = etree.XMLParser(remove_blank... | [
"def",
"get_sea_names",
"(",
")",
":",
"global",
"_SEA_NAMES",
"if",
"_SEA_NAMES",
"is",
"None",
":",
"resource_text",
"=",
"get_data",
"(",
"\"cc_plugin_ncei\"",
",",
"\"data/seanames.xml\"",
")",
"parser",
"=",
"etree",
".",
"XMLParser",
"(",
"remove_blank_text"... | Returns a list of NODC sea names
source of list: http://www.nodc.noaa.gov/General/NODC-Archive/seanames.xml | [
"Returns",
"a",
"list",
"of",
"NODC",
"sea",
"names"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L27-L44 | train | Returns a list of NODC sea names available in the NODC - Archive. |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | is_geophysical | def is_geophysical(ds, variable):
'''
Returns true if the dataset's variable is likely a geophysical variable
'''
ncvar = ds.variables[variable]
# Does it have a standard name and units?
standard_name = getattr(ncvar, 'standard_name', '')
if not standard_name:
return False
if sta... | python | def is_geophysical(ds, variable):
'''
Returns true if the dataset's variable is likely a geophysical variable
'''
ncvar = ds.variables[variable]
# Does it have a standard name and units?
standard_name = getattr(ncvar, 'standard_name', '')
if not standard_name:
return False
if sta... | [
"def",
"is_geophysical",
"(",
"ds",
",",
"variable",
")",
":",
"ncvar",
"=",
"ds",
".",
"variables",
"[",
"variable",
"]",
"# Does it have a standard name and units?",
"standard_name",
"=",
"getattr",
"(",
"ncvar",
",",
"'standard_name'",
",",
"''",
")",
"if",
... | Returns true if the dataset's variable is likely a geophysical variable | [
"Returns",
"true",
"if",
"the",
"dataset",
"s",
"variable",
"is",
"likely",
"a",
"geophysical",
"variable"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L47-L77 | train | Returns true if the dataset s variable is likely a geophysical variable |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_z_variable | def get_z_variable(nc):
'''
Returns the name of the variable that defines the Z axis or height/depth
:param netCDF4.Dataset nc: netCDF dataset
'''
axis_z = nc.get_variables_by_attributes(axis='Z')
if axis_z:
return axis_z[0].name
valid_standard_names = ('depth', 'height', 'altitude'... | python | def get_z_variable(nc):
'''
Returns the name of the variable that defines the Z axis or height/depth
:param netCDF4.Dataset nc: netCDF dataset
'''
axis_z = nc.get_variables_by_attributes(axis='Z')
if axis_z:
return axis_z[0].name
valid_standard_names = ('depth', 'height', 'altitude'... | [
"def",
"get_z_variable",
"(",
"nc",
")",
":",
"axis_z",
"=",
"nc",
".",
"get_variables_by_attributes",
"(",
"axis",
"=",
"'Z'",
")",
"if",
"axis_z",
":",
"return",
"axis_z",
"[",
"0",
"]",
".",
"name",
"valid_standard_names",
"=",
"(",
"'depth'",
",",
"'... | Returns the name of the variable that defines the Z axis or height/depth
:param netCDF4.Dataset nc: netCDF dataset | [
"Returns",
"the",
"name",
"of",
"the",
"variable",
"that",
"defines",
"the",
"Z",
"axis",
"or",
"height",
"/",
"depth"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L95-L108 | train | Returns the name of the variable that defines the Z axis or height or depth or altitude. |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_lat_variable | def get_lat_variable(nc):
'''
Returns the variable for latitude
:param netcdf4.dataset nc: an open netcdf dataset object
'''
if 'latitude' in nc.variables:
return 'latitude'
latitudes = nc.get_variables_by_attributes(standard_name="latitude")
if latitudes:
return latitudes[0... | python | def get_lat_variable(nc):
'''
Returns the variable for latitude
:param netcdf4.dataset nc: an open netcdf dataset object
'''
if 'latitude' in nc.variables:
return 'latitude'
latitudes = nc.get_variables_by_attributes(standard_name="latitude")
if latitudes:
return latitudes[0... | [
"def",
"get_lat_variable",
"(",
"nc",
")",
":",
"if",
"'latitude'",
"in",
"nc",
".",
"variables",
":",
"return",
"'latitude'",
"latitudes",
"=",
"nc",
".",
"get_variables_by_attributes",
"(",
"standard_name",
"=",
"\"latitude\"",
")",
"if",
"latitudes",
":",
"... | Returns the variable for latitude
:param netcdf4.dataset nc: an open netcdf dataset object | [
"Returns",
"the",
"variable",
"for",
"latitude"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L111-L122 | train | Returns the variable for latitude |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_lon_variable | def get_lon_variable(nc):
'''
Returns the variable for longitude
:param netCDF4.Dataset nc: netCDF dataset
'''
if 'longitude' in nc.variables:
return 'longitude'
longitudes = nc.get_variables_by_attributes(standard_name="longitude")
if longitudes:
return longitudes[0].name
... | python | def get_lon_variable(nc):
'''
Returns the variable for longitude
:param netCDF4.Dataset nc: netCDF dataset
'''
if 'longitude' in nc.variables:
return 'longitude'
longitudes = nc.get_variables_by_attributes(standard_name="longitude")
if longitudes:
return longitudes[0].name
... | [
"def",
"get_lon_variable",
"(",
"nc",
")",
":",
"if",
"'longitude'",
"in",
"nc",
".",
"variables",
":",
"return",
"'longitude'",
"longitudes",
"=",
"nc",
".",
"get_variables_by_attributes",
"(",
"standard_name",
"=",
"\"longitude\"",
")",
"if",
"longitudes",
":"... | Returns the variable for longitude
:param netCDF4.Dataset nc: netCDF dataset | [
"Returns",
"the",
"variable",
"for",
"longitude"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L125-L136 | train | Returns the variable for longitude
|
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_time_variable | def get_time_variable(ds):
'''
Returns the likeliest variable to be the time coordiante variable
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
for var in ds.variables:
if getattr(ds.variables[var], 'axis', '') == 'T':
return var
else:
candidates = ds.get_var... | python | def get_time_variable(ds):
'''
Returns the likeliest variable to be the time coordiante variable
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
for var in ds.variables:
if getattr(ds.variables[var], 'axis', '') == 'T':
return var
else:
candidates = ds.get_var... | [
"def",
"get_time_variable",
"(",
"ds",
")",
":",
"for",
"var",
"in",
"ds",
".",
"variables",
":",
"if",
"getattr",
"(",
"ds",
".",
"variables",
"[",
"var",
"]",
",",
"'axis'",
",",
"''",
")",
"==",
"'T'",
":",
"return",
"var",
"else",
":",
"candida... | Returns the likeliest variable to be the time coordiante variable
:param netCDF4.Dataset ds: An open netCDF4 Dataset | [
"Returns",
"the",
"likeliest",
"variable",
"to",
"be",
"the",
"time",
"coordiante",
"variable"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L179-L197 | train | Returns the likeliest variable to be the time coordiante variable |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | get_crs_variable | def get_crs_variable(ds):
'''
Returns the name of the variable identified by a grid_mapping attribute
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
for var in ds.variables:
grid_mapping = getattr(ds.variables[var], 'grid_mapping', '')
if grid_mapping and grid_mapping in ds.... | python | def get_crs_variable(ds):
'''
Returns the name of the variable identified by a grid_mapping attribute
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
for var in ds.variables:
grid_mapping = getattr(ds.variables[var], 'grid_mapping', '')
if grid_mapping and grid_mapping in ds.... | [
"def",
"get_crs_variable",
"(",
"ds",
")",
":",
"for",
"var",
"in",
"ds",
".",
"variables",
":",
"grid_mapping",
"=",
"getattr",
"(",
"ds",
".",
"variables",
"[",
"var",
"]",
",",
"'grid_mapping'",
",",
"''",
")",
"if",
"grid_mapping",
"and",
"grid_mappi... | Returns the name of the variable identified by a grid_mapping attribute
:param netCDF4.Dataset ds: An open netCDF4 Dataset | [
"Returns",
"the",
"name",
"of",
"the",
"variable",
"identified",
"by",
"a",
"grid_mapping",
"attribute"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L200-L210 | train | Returns the name of the variable identified by a grid_mapping attribute |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | is_timeseries | def is_timeseries(nc, variable):
'''
Returns true if the variable is a time series feature type.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x, y, z, t(o)
# X(o)
dims = nc.variables[variable].dimensions
cmatrix = coord... | python | def is_timeseries(nc, variable):
'''
Returns true if the variable is a time series feature type.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x, y, z, t(o)
# X(o)
dims = nc.variables[variable].dimensions
cmatrix = coord... | [
"def",
"is_timeseries",
"(",
"nc",
",",
"variable",
")",
":",
"# x, y, z, t(o)",
"# X(o)",
"dims",
"=",
"nc",
".",
"variables",
"[",
"variable",
"]",
".",
"dimensions",
"cmatrix",
"=",
"coordinate_dimension_matrix",
"(",
"nc",
")",
"for",
"req",
"in",
"(",
... | Returns true if the variable is a time series feature type.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check | [
"Returns",
"true",
"if",
"the",
"variable",
"is",
"a",
"time",
"series",
"feature",
"type",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L268-L297 | train | Returns true if the variable is a time series feature type. |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | is_single_trajectory | def is_single_trajectory(nc, variable):
'''
Returns true if the variable is a single trajectory feature
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(t), y(t), z(t), t(t)
# X(t)
dims = nc.variables[variable].dimensions
c... | python | def is_single_trajectory(nc, variable):
'''
Returns true if the variable is a single trajectory feature
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(t), y(t), z(t), t(t)
# X(t)
dims = nc.variables[variable].dimensions
c... | [
"def",
"is_single_trajectory",
"(",
"nc",
",",
"variable",
")",
":",
"# x(t), y(t), z(t), t(t)",
"# X(t)",
"dims",
"=",
"nc",
".",
"variables",
"[",
"variable",
"]",
".",
"dimensions",
"cmatrix",
"=",
"coordinate_dimension_matrix",
"(",
"nc",
")",
"for",
"req",
... | Returns true if the variable is a single trajectory feature
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check | [
"Returns",
"true",
"if",
"the",
"variable",
"is",
"a",
"single",
"trajectory",
"feature"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L401-L427 | train | Returns true if the variable is a single trajectory feature |
ioos/cc-plugin-ncei | cc_plugin_ncei/util.py | is_2d_regular_grid | def is_2d_regular_grid(nc, variable):
'''
Returns True if the variable is a 2D Regular grid.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(x), y(y), t(t)
# X(t, y, x)
dims = nc.variables[variable].dimensions
cmatrix = ... | python | def is_2d_regular_grid(nc, variable):
'''
Returns True if the variable is a 2D Regular grid.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(x), y(y), t(t)
# X(t, y, x)
dims = nc.variables[variable].dimensions
cmatrix = ... | [
"def",
"is_2d_regular_grid",
"(",
"nc",
",",
"variable",
")",
":",
"# x(x), y(y), t(t)",
"# X(t, y, x)",
"dims",
"=",
"nc",
".",
"variables",
"[",
"variable",
"]",
".",
"dimensions",
"cmatrix",
"=",
"coordinate_dimension_matrix",
"(",
"nc",
")",
"for",
"req",
... | Returns True if the variable is a 2D Regular grid.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check | [
"Returns",
"True",
"if",
"the",
"variable",
"is",
"a",
"2D",
"Regular",
"grid",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L804-L836 | train | Returns True if the variable is a 2D Regular grid. |
rsgalloway/grit | grit/server/handler.py | handle_read | def handle_read(repo, **kwargs):
"""handles reading repo information"""
log.info('read: %s %s' %(repo, kwargs))
if type(repo) in [unicode, str]:
return {'name': 'Repo', 'desc': 'Welcome to Grit', 'comment': ''}
else:
return repo.serialize() | python | def handle_read(repo, **kwargs):
"""handles reading repo information"""
log.info('read: %s %s' %(repo, kwargs))
if type(repo) in [unicode, str]:
return {'name': 'Repo', 'desc': 'Welcome to Grit', 'comment': ''}
else:
return repo.serialize() | [
"def",
"handle_read",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'read: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"if",
"type",
"(",
"repo",
")",
"in",
"[",
"unicode",
",",
"str",
"]",
":",
"return",
"{",
... | handles reading repo information | [
"handles",
"reading",
"repo",
"information"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L24-L30 | train | handles reading repo information |
rsgalloway/grit | grit/server/handler.py | handle_new | def handle_new(path, **kwargs):
""":return: new repo.Local instance"""
log.info('new: %s %s' %(path, kwargs))
repo = Local.new(path=path, **kwargs)
return repo.serialize() | python | def handle_new(path, **kwargs):
""":return: new repo.Local instance"""
log.info('new: %s %s' %(path, kwargs))
repo = Local.new(path=path, **kwargs)
return repo.serialize() | [
"def",
"handle_new",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'new: %s %s'",
"%",
"(",
"path",
",",
"kwargs",
")",
")",
"repo",
"=",
"Local",
".",
"new",
"(",
"path",
"=",
"path",
",",
"*",
"*",
"kwargs",
")",
"... | :return: new repo.Local instance | [
":",
"return",
":",
"new",
"repo",
".",
"Local",
"instance"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L32-L36 | train | Handle a new file. |
rsgalloway/grit | grit/server/handler.py | handle_branch | def handle_branch(repo, **kwargs):
""":return: Local.create()"""
log.info('branch: %s %s' %(repo, kwargs))
if type(repo) in [unicode, str]:
path = os.path.join(repo, kwargs.get('name', 'Unnamed'))
desc = kwargs.get('desc')
branch = Repo.new(path=path, desc=desc, bare=True)
else:
... | python | def handle_branch(repo, **kwargs):
""":return: Local.create()"""
log.info('branch: %s %s' %(repo, kwargs))
if type(repo) in [unicode, str]:
path = os.path.join(repo, kwargs.get('name', 'Unnamed'))
desc = kwargs.get('desc')
branch = Repo.new(path=path, desc=desc, bare=True)
else:
... | [
"def",
"handle_branch",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'branch: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"if",
"type",
"(",
"repo",
")",
"in",
"[",
"unicode",
",",
"str",
"]",
":",
"path",
"="... | :return: Local.create() | [
":",
"return",
":",
"Local",
".",
"create",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L38-L52 | train | Handle branch creation. |
rsgalloway/grit | grit/server/handler.py | handle_items | def handle_items(repo, **kwargs):
""":return: repo.files()"""
log.info('items: %s %s' %(repo, kwargs))
if not hasattr(repo, 'items'):
return []
return [i.serialize() for i in repo.items(**kwargs)] | python | def handle_items(repo, **kwargs):
""":return: repo.files()"""
log.info('items: %s %s' %(repo, kwargs))
if not hasattr(repo, 'items'):
return []
return [i.serialize() for i in repo.items(**kwargs)] | [
"def",
"handle_items",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'items: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"if",
"not",
"hasattr",
"(",
"repo",
",",
"'items'",
")",
":",
"return",
"[",
"]",
"return"... | :return: repo.files() | [
":",
"return",
":",
"repo",
".",
"files",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L63-L68 | train | Handle items. |
rsgalloway/grit | grit/server/handler.py | handle_tags | def handle_tags(repo, **kwargs):
""":return: repo.tags()"""
log.info('tags: %s %s' %(repo, kwargs))
return [str(t) for t in repo.tags(**kwargs)] | python | def handle_tags(repo, **kwargs):
""":return: repo.tags()"""
log.info('tags: %s %s' %(repo, kwargs))
return [str(t) for t in repo.tags(**kwargs)] | [
"def",
"handle_tags",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'tags: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"return",
"[",
"str",
"(",
"t",
")",
"for",
"t",
"in",
"repo",
".",
"tags",
"(",
"*",
"*"... | :return: repo.tags() | [
":",
"return",
":",
"repo",
".",
"tags",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L74-L77 | train | Returns a list of tags from a repository |
rsgalloway/grit | grit/server/handler.py | handle_versions | def handle_versions(repo, **kwargs):
""":return: repo.versions()"""
log.info('versions: %s %s' %(repo, kwargs))
if not hasattr(repo, 'versions'):
return []
return [v.serialize() for v in repo.versions(**kwargs)] | python | def handle_versions(repo, **kwargs):
""":return: repo.versions()"""
log.info('versions: %s %s' %(repo, kwargs))
if not hasattr(repo, 'versions'):
return []
return [v.serialize() for v in repo.versions(**kwargs)] | [
"def",
"handle_versions",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'versions: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"if",
"not",
"hasattr",
"(",
"repo",
",",
"'versions'",
")",
":",
"return",
"[",
"]",
... | :return: repo.versions() | [
":",
"return",
":",
"repo",
".",
"versions",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L79-L84 | train | Handle versions of the repository. |
rsgalloway/grit | grit/server/handler.py | handle_submodules | def handle_submodules(repo, **kwargs):
""":return: repo.submodules()"""
log.info('submodules: %s %s' %(repo, kwargs))
return [serialize(s, type='submodule', url=s.url) for s in repo.submodules(**kwargs)] | python | def handle_submodules(repo, **kwargs):
""":return: repo.submodules()"""
log.info('submodules: %s %s' %(repo, kwargs))
return [serialize(s, type='submodule', url=s.url) for s in repo.submodules(**kwargs)] | [
"def",
"handle_submodules",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'submodules: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"return",
"[",
"serialize",
"(",
"s",
",",
"type",
"=",
"'submodule'",
",",
"url",
... | :return: repo.submodules() | [
":",
"return",
":",
"repo",
".",
"submodules",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L86-L89 | train | Handle submodules. |
rsgalloway/grit | grit/server/handler.py | handle_addSubmodule | def handle_addSubmodule(repo, **kwargs):
""":return: repo.addSubmodule()"""
log.info('addSubmodule: %s %s' %(repo, kwargs))
try:
proxy = repo.addSubmodule(**kwargs)
return [serialize(proxy, type='submodule', url=proxy.url)]
except RepoError, e:
raise | python | def handle_addSubmodule(repo, **kwargs):
""":return: repo.addSubmodule()"""
log.info('addSubmodule: %s %s' %(repo, kwargs))
try:
proxy = repo.addSubmodule(**kwargs)
return [serialize(proxy, type='submodule', url=proxy.url)]
except RepoError, e:
raise | [
"def",
"handle_addSubmodule",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'addSubmodule: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"try",
":",
"proxy",
"=",
"repo",
".",
"addSubmodule",
"(",
"*",
"*",
"kwargs",
... | :return: repo.addSubmodule() | [
":",
"return",
":",
"repo",
".",
"addSubmodule",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L91-L98 | train | Add a submodule to the current node. |
rsgalloway/grit | grit/server/handler.py | handle_addVersion | def handle_addVersion(repo, **kwargs):
""":return: repo.addSubmodule()"""
log.info('addVersion: %s %s' %(repo, kwargs))
try:
v = repo.addVersion(**kwargs)
return v.serialize()
except RepoError, e:
raise | python | def handle_addVersion(repo, **kwargs):
""":return: repo.addSubmodule()"""
log.info('addVersion: %s %s' %(repo, kwargs))
try:
v = repo.addVersion(**kwargs)
return v.serialize()
except RepoError, e:
raise | [
"def",
"handle_addVersion",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'addVersion: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"try",
":",
"v",
"=",
"repo",
".",
"addVersion",
"(",
"*",
"*",
"kwargs",
")",
"r... | :return: repo.addSubmodule() | [
":",
"return",
":",
"repo",
".",
"addSubmodule",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L100-L107 | train | Add a version to the current node. |
rsgalloway/grit | grit/server/handler.py | handle_parent | def handle_parent(repo, **kwargs):
""":return: repo.parent()"""
log.info('parent: %s %s' %(repo, kwargs))
_parent = repo.parent()
if _parent:
return [_parent.serialize()] | python | def handle_parent(repo, **kwargs):
""":return: repo.parent()"""
log.info('parent: %s %s' %(repo, kwargs))
_parent = repo.parent()
if _parent:
return [_parent.serialize()] | [
"def",
"handle_parent",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'parent: %s %s'",
"%",
"(",
"repo",
",",
"kwargs",
")",
")",
"_parent",
"=",
"repo",
".",
"parent",
"(",
")",
"if",
"_parent",
":",
"return",
"[",
"_p... | :return: repo.parent() | [
":",
"return",
":",
"repo",
".",
"parent",
"()"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L109-L114 | train | Handle parent repository. |
rsgalloway/grit | grit/server/handler.py | handle_upload | def handle_upload(repo, **kwargs):
"""
:param kwargs: valud kwargs
filename: file name
filedata: file data
:return: new Item
"""
log.info('upload: %s' %(repo))
name = kwargs.get('filename', 'Untitled')
data = kwargs.get('filedata')
repo.addItem(Item.from_string(repo=rep... | python | def handle_upload(repo, **kwargs):
"""
:param kwargs: valud kwargs
filename: file name
filedata: file data
:return: new Item
"""
log.info('upload: %s' %(repo))
name = kwargs.get('filename', 'Untitled')
data = kwargs.get('filedata')
repo.addItem(Item.from_string(repo=rep... | [
"def",
"handle_upload",
"(",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"'upload: %s'",
"%",
"(",
"repo",
")",
")",
"name",
"=",
"kwargs",
".",
"get",
"(",
"'filename'",
",",
"'Untitled'",
")",
"data",
"=",
"kwargs",
".",
"... | :param kwargs: valud kwargs
filename: file name
filedata: file data
:return: new Item | [
":",
"param",
"kwargs",
":",
"valud",
"kwargs",
"filename",
":",
"file",
"name",
"filedata",
":",
"file",
"data",
":",
"return",
":",
"new",
"Item"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/handler.py#L116-L126 | train | Handle an upload of a file to a node |
garenchan/policy | policy/_utils.py | dict_from_object | def dict_from_object(obj: object):
"""Convert a object into dictionary with all of its readable attributes."""
# If object is a dict instance, no need to convert.
return (obj if isinstance(obj, dict)
else {attr: getattr(obj, attr)
for attr in dir(obj) if not attr.startswith('_... | python | def dict_from_object(obj: object):
"""Convert a object into dictionary with all of its readable attributes."""
# If object is a dict instance, no need to convert.
return (obj if isinstance(obj, dict)
else {attr: getattr(obj, attr)
for attr in dir(obj) if not attr.startswith('_... | [
"def",
"dict_from_object",
"(",
"obj",
":",
"object",
")",
":",
"# If object is a dict instance, no need to convert.",
"return",
"(",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
"else",
"{",
"attr",
":",
"getattr",
"(",
"obj",
",",
"attr",
")",
... | Convert a object into dictionary with all of its readable attributes. | [
"Convert",
"a",
"object",
"into",
"dictionary",
"with",
"all",
"of",
"its",
"readable",
"attributes",
"."
] | 7709ae5f371146f8c90380d0877a5e59d731f644 | https://github.com/garenchan/policy/blob/7709ae5f371146f8c90380d0877a5e59d731f644/policy/_utils.py#L13-L19 | train | Convert a object into dictionary with all of its readable attributes. |
garenchan/policy | policy/_utils.py | xgetattr | def xgetattr(obj: object, name: str, default=_sentinel, getitem=False):
"""Get attribute value from object.
:param obj: object
:param name: attribute or key name
:param default: when attribute or key missing, return default; if obj is a
dict and use getitem, default will not be used.
:param... | python | def xgetattr(obj: object, name: str, default=_sentinel, getitem=False):
"""Get attribute value from object.
:param obj: object
:param name: attribute or key name
:param default: when attribute or key missing, return default; if obj is a
dict and use getitem, default will not be used.
:param... | [
"def",
"xgetattr",
"(",
"obj",
":",
"object",
",",
"name",
":",
"str",
",",
"default",
"=",
"_sentinel",
",",
"getitem",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"if",
"getitem",
":",
"# In tune with `dict.__getitem_... | Get attribute value from object.
:param obj: object
:param name: attribute or key name
:param default: when attribute or key missing, return default; if obj is a
dict and use getitem, default will not be used.
:param getitem: when object is a dict, use getitem or get
:return: attribute or k... | [
"Get",
"attribute",
"value",
"from",
"object",
"."
] | 7709ae5f371146f8c90380d0877a5e59d731f644 | https://github.com/garenchan/policy/blob/7709ae5f371146f8c90380d0877a5e59d731f644/policy/_utils.py#L22-L48 | train | Get attribute value from object. |
BernardFW/bernard | src/bernard/conf/__init__.py | list_config_files | def list_config_files() -> List[Text]:
"""
This function returns the list of configuration files to load.
This is a callable so the configuration can be reloaded with files that
changed in between.
"""
return [
os.path.join(os.path.dirname(__file__), 'default_settings.py'),
os.... | python | def list_config_files() -> List[Text]:
"""
This function returns the list of configuration files to load.
This is a callable so the configuration can be reloaded with files that
changed in between.
"""
return [
os.path.join(os.path.dirname(__file__), 'default_settings.py'),
os.... | [
"def",
"list_config_files",
"(",
")",
"->",
"List",
"[",
"Text",
"]",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'default_settings.py'",
")",
",",
"os",
".",
"getenv",
"(",
... | This function returns the list of configuration files to load.
This is a callable so the configuration can be reloaded with files that
changed in between. | [
"This",
"function",
"returns",
"the",
"list",
"of",
"configuration",
"files",
"to",
"load",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/conf/__init__.py#L15-L26 | train | This function returns the list of configuration files that can be loaded from the current directory. |
frostming/marko | marko/helpers.py | camel_to_snake_case | def camel_to_snake_case(name):
"""Takes a camelCased string and converts to snake_case."""
pattern = r'[A-Z][a-z]+|[A-Z]+(?![a-z])'
return '_'.join(map(str.lower, re.findall(pattern, name))) | python | def camel_to_snake_case(name):
"""Takes a camelCased string and converts to snake_case."""
pattern = r'[A-Z][a-z]+|[A-Z]+(?![a-z])'
return '_'.join(map(str.lower, re.findall(pattern, name))) | [
"def",
"camel_to_snake_case",
"(",
"name",
")",
":",
"pattern",
"=",
"r'[A-Z][a-z]+|[A-Z]+(?![a-z])'",
"return",
"'_'",
".",
"join",
"(",
"map",
"(",
"str",
".",
"lower",
",",
"re",
".",
"findall",
"(",
"pattern",
",",
"name",
")",
")",
")"
] | Takes a camelCased string and converts to snake_case. | [
"Takes",
"a",
"camelCased",
"string",
"and",
"converts",
"to",
"snake_case",
"."
] | 1cd030b665fa37bad1f8b3a25a89ce1a7c491dde | https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/helpers.py#L10-L13 | train | Takes a camelCased string and converts to snake_case. |
frostming/marko | marko/helpers.py | is_paired | def is_paired(text, open='(', close=')'):
"""Check if the text only contains:
1. blackslash escaped parentheses, or
2. parentheses paired.
"""
count = 0
escape = False
for c in text:
if escape:
escape = False
elif c == '\\':
escape = True
elif ... | python | def is_paired(text, open='(', close=')'):
"""Check if the text only contains:
1. blackslash escaped parentheses, or
2. parentheses paired.
"""
count = 0
escape = False
for c in text:
if escape:
escape = False
elif c == '\\':
escape = True
elif ... | [
"def",
"is_paired",
"(",
"text",
",",
"open",
"=",
"'('",
",",
"close",
"=",
"')'",
")",
":",
"count",
"=",
"0",
"escape",
"=",
"False",
"for",
"c",
"in",
"text",
":",
"if",
"escape",
":",
"escape",
"=",
"False",
"elif",
"c",
"==",
"'\\\\'",
":",... | Check if the text only contains:
1. blackslash escaped parentheses, or
2. parentheses paired. | [
"Check",
"if",
"the",
"text",
"only",
"contains",
":",
"1",
".",
"blackslash",
"escaped",
"parentheses",
"or",
"2",
".",
"parentheses",
"paired",
"."
] | 1cd030b665fa37bad1f8b3a25a89ce1a7c491dde | https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/helpers.py#L16-L34 | train | Check if the text only contains paired or paired. |
frostming/marko | marko/helpers.py | Source.match_prefix | def match_prefix(prefix, line):
"""Check if the line starts with given prefix and
return the position of the end of prefix.
If the prefix is not matched, return -1.
"""
m = re.match(prefix, line.expandtabs(4))
if not m:
if re.match(prefix, line.expandtabs(4).r... | python | def match_prefix(prefix, line):
"""Check if the line starts with given prefix and
return the position of the end of prefix.
If the prefix is not matched, return -1.
"""
m = re.match(prefix, line.expandtabs(4))
if not m:
if re.match(prefix, line.expandtabs(4).r... | [
"def",
"match_prefix",
"(",
"prefix",
",",
"line",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"prefix",
",",
"line",
".",
"expandtabs",
"(",
"4",
")",
")",
"if",
"not",
"m",
":",
"if",
"re",
".",
"match",
"(",
"prefix",
",",
"line",
".",
"exp... | Check if the line starts with given prefix and
return the position of the end of prefix.
If the prefix is not matched, return -1. | [
"Check",
"if",
"the",
"line",
"starts",
"with",
"given",
"prefix",
"and",
"return",
"the",
"position",
"of",
"the",
"end",
"of",
"prefix",
".",
"If",
"the",
"prefix",
"is",
"not",
"matched",
"return",
"-",
"1",
"."
] | 1cd030b665fa37bad1f8b3a25a89ce1a7c491dde | https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/helpers.py#L101-L116 | train | Check if the line starts with given prefix and
return the position of the end of the prefix. |
frostming/marko | marko/helpers.py | Source.expect_re | def expect_re(self, regexp):
"""Test against the given regular expression and returns the match object.
:param regexp: the expression to be tested.
:returns: the match object.
"""
prefix_len = self.match_prefix(
self.prefix, self.next_line(require_prefix=False)
... | python | def expect_re(self, regexp):
"""Test against the given regular expression and returns the match object.
:param regexp: the expression to be tested.
:returns: the match object.
"""
prefix_len = self.match_prefix(
self.prefix, self.next_line(require_prefix=False)
... | [
"def",
"expect_re",
"(",
"self",
",",
"regexp",
")",
":",
"prefix_len",
"=",
"self",
".",
"match_prefix",
"(",
"self",
".",
"prefix",
",",
"self",
".",
"next_line",
"(",
"require_prefix",
"=",
"False",
")",
")",
"if",
"prefix_len",
">=",
"0",
":",
"mat... | Test against the given regular expression and returns the match object.
:param regexp: the expression to be tested.
:returns: the match object. | [
"Test",
"against",
"the",
"given",
"regular",
"expression",
"and",
"returns",
"the",
"match",
"object",
"."
] | 1cd030b665fa37bad1f8b3a25a89ce1a7c491dde | https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/helpers.py#L118-L132 | train | Test against the given regular expression and returns the match object. |
frostming/marko | marko/helpers.py | Source.next_line | def next_line(self, require_prefix=True):
"""Return the next line in the source.
:param require_prefix: if False, the whole line will be returned.
otherwise, return the line with prefix stripped or None if the prefix
is not matched.
"""
if require_prefix:
... | python | def next_line(self, require_prefix=True):
"""Return the next line in the source.
:param require_prefix: if False, the whole line will be returned.
otherwise, return the line with prefix stripped or None if the prefix
is not matched.
"""
if require_prefix:
... | [
"def",
"next_line",
"(",
"self",
",",
"require_prefix",
"=",
"True",
")",
":",
"if",
"require_prefix",
":",
"m",
"=",
"self",
".",
"expect_re",
"(",
"r'(?m)[^\\n]*?$\\n?'",
")",
"else",
":",
"m",
"=",
"self",
".",
"_expect_re",
"(",
"r'(?m)[^\\n]*$\\n?'",
... | Return the next line in the source.
:param require_prefix: if False, the whole line will be returned.
otherwise, return the line with prefix stripped or None if the prefix
is not matched. | [
"Return",
"the",
"next",
"line",
"in",
"the",
"source",
"."
] | 1cd030b665fa37bad1f8b3a25a89ce1a7c491dde | https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/helpers.py#L134-L147 | train | Return the next line in the source. |
frostming/marko | marko/helpers.py | Source.consume | def consume(self):
"""Consume the body of source. ``pos`` will move forward."""
if self.match:
self.pos = self.match.end()
if self.match.group()[-1] == '\n':
self._update_prefix()
self.match = None | python | def consume(self):
"""Consume the body of source. ``pos`` will move forward."""
if self.match:
self.pos = self.match.end()
if self.match.group()[-1] == '\n':
self._update_prefix()
self.match = None | [
"def",
"consume",
"(",
"self",
")",
":",
"if",
"self",
".",
"match",
":",
"self",
".",
"pos",
"=",
"self",
".",
"match",
".",
"end",
"(",
")",
"if",
"self",
".",
"match",
".",
"group",
"(",
")",
"[",
"-",
"1",
"]",
"==",
"'\\n'",
":",
"self",... | Consume the body of source. ``pos`` will move forward. | [
"Consume",
"the",
"body",
"of",
"source",
".",
"pos",
"will",
"move",
"forward",
"."
] | 1cd030b665fa37bad1f8b3a25a89ce1a7c491dde | https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/helpers.py#L149-L155 | train | Consume the body of source. |
kata198/python-subprocess2 | subprocess2/BackgroundTask.py | _py_read1 | def _py_read1(fileObj, maxBuffer):
'''
_py_read1 - Pure python version of "read1", which allows non-blocking I/O on a potentially unfinished or non-newline-ending stream.
@param maxBuffer - Max buffer size
@return - All data available on stream, regardless of newlines
'''
i = 0
... | python | def _py_read1(fileObj, maxBuffer):
'''
_py_read1 - Pure python version of "read1", which allows non-blocking I/O on a potentially unfinished or non-newline-ending stream.
@param maxBuffer - Max buffer size
@return - All data available on stream, regardless of newlines
'''
i = 0
... | [
"def",
"_py_read1",
"(",
"fileObj",
",",
"maxBuffer",
")",
":",
"i",
"=",
"0",
"ret",
"=",
"[",
"]",
"while",
"i",
"<",
"maxBuffer",
":",
"c",
"=",
"fileObj",
".",
"read",
"(",
"1",
")",
"if",
"c",
"==",
"''",
":",
"# Stream has been closed",
"brea... | _py_read1 - Pure python version of "read1", which allows non-blocking I/O on a potentially unfinished or non-newline-ending stream.
@param maxBuffer - Max buffer size
@return - All data available on stream, regardless of newlines | [
"_py_read1",
"-",
"Pure",
"python",
"version",
"of",
"read1",
"which",
"allows",
"non",
"-",
"blocking",
"I",
"/",
"O",
"on",
"a",
"potentially",
"unfinished",
"or",
"non",
"-",
"newline",
"-",
"ending",
"stream",
"."
] | 8544b0b651d8e14de9fdd597baa704182e248b01 | https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/BackgroundTask.py#L116-L138 | train | Internal function for reading from a file - like object. |
kata198/python-subprocess2 | subprocess2/BackgroundTask.py | BackgroundTaskInfo.asDict | def asDict(self):
'''
asDict - Returns a copy of the current state as a dictionary. This copy will not be updated automatically.
@return <dict> - Dictionary with all fields in BackgroundTaskInfo.FIELDS
'''
ret = {}
for field in BackgroundTaskInfo.FIELDS:
... | python | def asDict(self):
'''
asDict - Returns a copy of the current state as a dictionary. This copy will not be updated automatically.
@return <dict> - Dictionary with all fields in BackgroundTaskInfo.FIELDS
'''
ret = {}
for field in BackgroundTaskInfo.FIELDS:
... | [
"def",
"asDict",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"field",
"in",
"BackgroundTaskInfo",
".",
"FIELDS",
":",
"ret",
"[",
"field",
"]",
"=",
"getattr",
"(",
"self",
",",
"field",
")",
"return",
"ret"
] | asDict - Returns a copy of the current state as a dictionary. This copy will not be updated automatically.
@return <dict> - Dictionary with all fields in BackgroundTaskInfo.FIELDS | [
"asDict",
"-",
"Returns",
"a",
"copy",
"of",
"the",
"current",
"state",
"as",
"a",
"dictionary",
".",
"This",
"copy",
"will",
"not",
"be",
"updated",
"automatically",
"."
] | 8544b0b651d8e14de9fdd597baa704182e248b01 | https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/BackgroundTask.py#L84-L93 | train | Returns a copy of the current state as a dictionary. |
kata198/python-subprocess2 | subprocess2/BackgroundTask.py | BackgroundTaskInfo.waitToFinish | def waitToFinish(self, timeout=None, pollInterval=.1):
'''
waitToFinish - Wait (Block current thread), optionally with a timeout, until background task completes.
@param timeout <None/float> - None to wait forever, otherwise max number of seconds to wait
@param pollInterval ... | python | def waitToFinish(self, timeout=None, pollInterval=.1):
'''
waitToFinish - Wait (Block current thread), optionally with a timeout, until background task completes.
@param timeout <None/float> - None to wait forever, otherwise max number of seconds to wait
@param pollInterval ... | [
"def",
"waitToFinish",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"pollInterval",
"=",
".1",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"while",
"self",
".",
"isFinished",
"is",
"False",
":",
"time",
".",
"sleep",
"(",
"pollInterval",
")",
"else... | waitToFinish - Wait (Block current thread), optionally with a timeout, until background task completes.
@param timeout <None/float> - None to wait forever, otherwise max number of seconds to wait
@param pollInterval <float> - Seconds between each poll. Keep high if interactivity is not importan... | [
"waitToFinish",
"-",
"Wait",
"(",
"Block",
"current",
"thread",
")",
"optionally",
"with",
"a",
"timeout",
"until",
"background",
"task",
"completes",
"."
] | 8544b0b651d8e14de9fdd597baa704182e248b01 | https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/BackgroundTask.py#L95-L113 | train | Wait until the current process completes. |
garenchan/policy | policy/checks.py | register | def register(name, _callable=None):
"""A decorator used for register custom check.
:param name: name of check
:type: str
:param _callable: check class or a function which return check instance
:return: _callable or a decorator
"""
def wrapper(_callable):
registered_checks[name] = _c... | python | def register(name, _callable=None):
"""A decorator used for register custom check.
:param name: name of check
:type: str
:param _callable: check class or a function which return check instance
:return: _callable or a decorator
"""
def wrapper(_callable):
registered_checks[name] = _c... | [
"def",
"register",
"(",
"name",
",",
"_callable",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"_callable",
")",
":",
"registered_checks",
"[",
"name",
"]",
"=",
"_callable",
"return",
"_callable",
"# If function or class is given, do the registeration",
"if",
"_... | A decorator used for register custom check.
:param name: name of check
:type: str
:param _callable: check class or a function which return check instance
:return: _callable or a decorator | [
"A",
"decorator",
"used",
"for",
"register",
"custom",
"check",
"."
] | 7709ae5f371146f8c90380d0877a5e59d731f644 | https://github.com/garenchan/policy/blob/7709ae5f371146f8c90380d0877a5e59d731f644/policy/checks.py#L177-L193 | train | A decorator used for registering a custom check. |
BernardFW/bernard | src/bernard/platforms/facebook/layers.py | MessagingType.serialize | def serialize(self):
"""
Generates the messaging-type-related part of the message dictionary.
"""
if self.response is not None:
return {'messaging_type': 'RESPONSE'}
if self.update is not None:
return {'messaging_type': 'UPDATE'}
if self.tag is ... | python | def serialize(self):
"""
Generates the messaging-type-related part of the message dictionary.
"""
if self.response is not None:
return {'messaging_type': 'RESPONSE'}
if self.update is not None:
return {'messaging_type': 'UPDATE'}
if self.tag is ... | [
"def",
"serialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"response",
"is",
"not",
"None",
":",
"return",
"{",
"'messaging_type'",
":",
"'RESPONSE'",
"}",
"if",
"self",
".",
"update",
"is",
"not",
"None",
":",
"return",
"{",
"'messaging_type'",
":",
... | Generates the messaging-type-related part of the message dictionary. | [
"Generates",
"the",
"messaging",
"-",
"type",
"-",
"related",
"part",
"of",
"the",
"message",
"dictionary",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/layers.py#L102-L120 | train | Returns the message dictionary for the current message. |
BernardFW/bernard | src/bernard/platforms/facebook/layers.py | QuickRepliesList.patch_register | async def patch_register(self, register: Dict, request: 'Request'):
"""
Store all options in the "choices" sub-register. We store both the
text and the potential intent, in order to match both regular
quick reply clicks but also the user typing stuff on his keyboard that
matches ... | python | async def patch_register(self, register: Dict, request: 'Request'):
"""
Store all options in the "choices" sub-register. We store both the
text and the potential intent, in order to match both regular
quick reply clicks but also the user typing stuff on his keyboard that
matches ... | [
"async",
"def",
"patch_register",
"(",
"self",
",",
"register",
":",
"Dict",
",",
"request",
":",
"'Request'",
")",
":",
"register",
"[",
"'choices'",
"]",
"=",
"{",
"o",
".",
"slug",
":",
"{",
"'intent'",
":",
"o",
".",
"intent",
".",
"key",
"if",
... | Store all options in the "choices" sub-register. We store both the
text and the potential intent, in order to match both regular
quick reply clicks but also the user typing stuff on his keyboard that
matches more or less the content of quick replies. | [
"Store",
"all",
"options",
"in",
"the",
"choices",
"sub",
"-",
"register",
".",
"We",
"store",
"both",
"the",
"text",
"and",
"the",
"potential",
"intent",
"in",
"order",
"to",
"match",
"both",
"regular",
"quick",
"reply",
"clicks",
"but",
"also",
"the",
... | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/layers.py#L198-L214 | train | Patch the register with all options in the choices sub - register. |
BernardFW/bernard | src/bernard/platforms/facebook/layers.py | ButtonTemplate.is_sharable | def is_sharable(self):
"""
Is sharable if marked as and if buttons are sharable (they might
hold sensitive data).
"""
return self.sharable and all(x.is_sharable() for x in self.buttons) | python | def is_sharable(self):
"""
Is sharable if marked as and if buttons are sharable (they might
hold sensitive data).
"""
return self.sharable and all(x.is_sharable() for x in self.buttons) | [
"def",
"is_sharable",
"(",
"self",
")",
":",
"return",
"self",
".",
"sharable",
"and",
"all",
"(",
"x",
".",
"is_sharable",
"(",
")",
"for",
"x",
"in",
"self",
".",
"buttons",
")"
] | Is sharable if marked as and if buttons are sharable (they might
hold sensitive data). | [
"Is",
"sharable",
"if",
"marked",
"as",
"and",
"if",
"buttons",
"are",
"sharable",
"(",
"they",
"might",
"hold",
"sensitive",
"data",
")",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/layers.py#L253-L258 | train | Is sharable if the tag is marked as and all buttons are sharable. |
BernardFW/bernard | src/bernard/platforms/facebook/layers.py | GenericTemplate.is_sharable | def is_sharable(self):
"""
Can only be sharable if marked as such and no child element is blocking
sharing due to security reasons.
"""
return bool(
self.sharable and
all(x.is_sharable() for x in self.elements)
) | python | def is_sharable(self):
"""
Can only be sharable if marked as such and no child element is blocking
sharing due to security reasons.
"""
return bool(
self.sharable and
all(x.is_sharable() for x in self.elements)
) | [
"def",
"is_sharable",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"sharable",
"and",
"all",
"(",
"x",
".",
"is_sharable",
"(",
")",
"for",
"x",
"in",
"self",
".",
"elements",
")",
")"
] | Can only be sharable if marked as such and no child element is blocking
sharing due to security reasons. | [
"Can",
"only",
"be",
"sharable",
"if",
"marked",
"as",
"such",
"and",
"no",
"child",
"element",
"is",
"blocking",
"sharing",
"due",
"to",
"security",
"reasons",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/layers.py#L289-L297 | train | Returns True if this entry is not sharable. |
mbourqui/django-echoices | echoices/enums/enums.py | EChoice.values | def values(cls):
"""
Returns
-------
tuple
of all the values of this Enum
"""
if not hasattr(cls, '__values_'):
cls.__values_ = tuple([c.value for c in list(cls)])
return cls.__values_ | python | def values(cls):
"""
Returns
-------
tuple
of all the values of this Enum
"""
if not hasattr(cls, '__values_'):
cls.__values_ = tuple([c.value for c in list(cls)])
return cls.__values_ | [
"def",
"values",
"(",
"cls",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'__values_'",
")",
":",
"cls",
".",
"__values_",
"=",
"tuple",
"(",
"[",
"c",
".",
"value",
"for",
"c",
"in",
"list",
"(",
"cls",
")",
"]",
")",
"return",
"cls",
"... | Returns
-------
tuple
of all the values of this Enum | [
"Returns",
"-------",
"tuple",
"of",
"all",
"the",
"values",
"of",
"this",
"Enum"
] | c57405005ec368ac602bb38a71091a1e03c723bb | https://github.com/mbourqui/django-echoices/blob/c57405005ec368ac602bb38a71091a1e03c723bb/echoices/enums/enums.py#L121-L132 | train | Returns a tuple of all the values of this Enum
|
mbourqui/django-echoices | echoices/enums/enums.py | EChoice.max_value_length | def max_value_length(cls):
"""
Not to be used when using numeric values.
Returns
-------
int
the maximal length required by this Enum to be stored in the database
"""
if not hasattr(cls, '__max_value_length_'):
cls.__max_value_len... | python | def max_value_length(cls):
"""
Not to be used when using numeric values.
Returns
-------
int
the maximal length required by this Enum to be stored in the database
"""
if not hasattr(cls, '__max_value_length_'):
cls.__max_value_len... | [
"def",
"max_value_length",
"(",
"cls",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'__max_value_length_'",
")",
":",
"cls",
".",
"__max_value_length_",
"=",
"max",
"(",
"[",
"len",
"(",
"c",
".",
"value",
")",
"for",
"c",
"in",
"list",
"(",
"... | Not to be used when using numeric values.
Returns
-------
int
the maximal length required by this Enum to be stored in the database | [
"Not",
"to",
"be",
"used",
"when",
"using",
"numeric",
"values",
".",
"Returns",
"-------",
"int",
"the",
"maximal",
"length",
"required",
"by",
"this",
"Enum",
"to",
"be",
"stored",
"in",
"the",
"database"
] | c57405005ec368ac602bb38a71091a1e03c723bb | https://github.com/mbourqui/django-echoices/blob/c57405005ec368ac602bb38a71091a1e03c723bb/echoices/enums/enums.py#L135-L147 | train | Returns the maximum length of the value of the key - value pairs in the database. |
mbourqui/django-echoices | echoices/enums/enums.py | EChoice.choices | def choices(cls):
"""
Generate the choices as required by Django models.
Returns
-------
tuple
"""
# "natural" order, aka as given when instantiating
if not hasattr(cls, '__choices_'):
cls.__choices_ = tuple([c.choice for c in list(cls)])
... | python | def choices(cls):
"""
Generate the choices as required by Django models.
Returns
-------
tuple
"""
# "natural" order, aka as given when instantiating
if not hasattr(cls, '__choices_'):
cls.__choices_ = tuple([c.choice for c in list(cls)])
... | [
"def",
"choices",
"(",
"cls",
")",
":",
"# \"natural\" order, aka as given when instantiating",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'__choices_'",
")",
":",
"cls",
".",
"__choices_",
"=",
"tuple",
"(",
"[",
"c",
".",
"choice",
"for",
"c",
"in",
"list",... | Generate the choices as required by Django models.
Returns
-------
tuple | [
"Generate",
"the",
"choices",
"as",
"required",
"by",
"Django",
"models",
"."
] | c57405005ec368ac602bb38a71091a1e03c723bb | https://github.com/mbourqui/django-echoices/blob/c57405005ec368ac602bb38a71091a1e03c723bb/echoices/enums/enums.py#L150-L162 | train | Generate the choices as required by Django models.
|
mbourqui/django-echoices | echoices/enums/enums.py | EChoice.from_value | def from_value(cls, value):
"""
Return the EChoice object associated with this value, if any.
Parameters
----------
value
In the type of the `value` field, as set when instantiating this EChoice.
Returns
-------
EChoice
Raises
... | python | def from_value(cls, value):
"""
Return the EChoice object associated with this value, if any.
Parameters
----------
value
In the type of the `value` field, as set when instantiating this EChoice.
Returns
-------
EChoice
Raises
... | [
"def",
"from_value",
"(",
"cls",
",",
"value",
")",
":",
"warnings",
".",
"warn",
"(",
"\"{0}.{1} will be deprecated in a future release. \"",
"\"Please use {0}.{2} instead\"",
".",
"format",
"(",
"cls",
".",
"__name__",
",",
"cls",
".",
"from_value",
".",
"__name__... | Return the EChoice object associated with this value, if any.
Parameters
----------
value
In the type of the `value` field, as set when instantiating this EChoice.
Returns
-------
EChoice
Raises
------
KeyError
if `value`... | [
"Return",
"the",
"EChoice",
"object",
"associated",
"with",
"this",
"value",
"if",
"any",
"."
] | c57405005ec368ac602bb38a71091a1e03c723bb | https://github.com/mbourqui/django-echoices/blob/c57405005ec368ac602bb38a71091a1e03c723bb/echoices/enums/enums.py#L165-L187 | train | Returns the object associated with this value if any. |
mbourqui/django-echoices | echoices/enums/enums.py | EOrderedChoice.choices | def choices(cls, order='natural'):
"""
Generate the choices as required by Django models.
Parameters
----------
order : str
in which the elements should be returned. Possible values are:
* 'sorted', the elements will be sorted by `value`
* 're... | python | def choices(cls, order='natural'):
"""
Generate the choices as required by Django models.
Parameters
----------
order : str
in which the elements should be returned. Possible values are:
* 'sorted', the elements will be sorted by `value`
* 're... | [
"def",
"choices",
"(",
"cls",
",",
"order",
"=",
"'natural'",
")",
":",
"INC",
",",
"DEC",
",",
"NAT",
"=",
"'sorted'",
",",
"'reverse'",
",",
"'natural'",
"options",
"=",
"[",
"INC",
",",
"DEC",
",",
"NAT",
"]",
"assert",
"order",
"in",
"options",
... | Generate the choices as required by Django models.
Parameters
----------
order : str
in which the elements should be returned. Possible values are:
* 'sorted', the elements will be sorted by `value`
* 'reverse', the elements will be sorted by `value` as if ea... | [
"Generate",
"the",
"choices",
"as",
"required",
"by",
"Django",
"models",
"."
] | c57405005ec368ac602bb38a71091a1e03c723bb | https://github.com/mbourqui/django-echoices/blob/c57405005ec368ac602bb38a71091a1e03c723bb/echoices/enums/enums.py#L272-L303 | train | Generate the choices as required by Django models. |
cloudmesh-cmd3/cmd3 | cmd3/plugins/edit.py | edit.do_edit | def do_edit(self, arg, arguments):
"""
::
Usage:
edit FILENAME
Edits the file with the given name
Arguments:
FILENAME the file to edit
"""
def _create_file(filename):
if not os.path.exists(filename)... | python | def do_edit(self, arg, arguments):
"""
::
Usage:
edit FILENAME
Edits the file with the given name
Arguments:
FILENAME the file to edit
"""
def _create_file(filename):
if not os.path.exists(filename)... | [
"def",
"do_edit",
"(",
"self",
",",
"arg",
",",
"arguments",
")",
":",
"def",
"_create_file",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"file",
"(",
"filename",
",",
"'w+'",
")",
".",
"clos... | ::
Usage:
edit FILENAME
Edits the file with the given name
Arguments:
FILENAME the file to edit | [
"::"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/edit.py#L19-L81 | train | Edit the file with the given name. |
BernardFW/bernard | src/bernard/server/views.py | bernard_auth | def bernard_auth(func):
"""
Authenticates the users based on the query-string-provided token
"""
@wraps(func)
async def wrapper(request: Request):
def get_query_token():
token_key = settings.WEBVIEW_TOKEN_KEY
return request.query.get(token_key, '')
def get_h... | python | def bernard_auth(func):
"""
Authenticates the users based on the query-string-provided token
"""
@wraps(func)
async def wrapper(request: Request):
def get_query_token():
token_key = settings.WEBVIEW_TOKEN_KEY
return request.query.get(token_key, '')
def get_h... | [
"def",
"bernard_auth",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"request",
":",
"Request",
")",
":",
"def",
"get_query_token",
"(",
")",
":",
"token_key",
"=",
"settings",
".",
"WEBVIEW_TOKEN_KEY",
"return",
... | Authenticates the users based on the query-string-provided token | [
"Authenticates",
"the",
"users",
"based",
"on",
"the",
"query",
"-",
"string",
"-",
"provided",
"token"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/server/views.py#L37-L74 | train | Decorator that returns a response that is a response to the users based on the query - string - provided token
. |
BernardFW/bernard | src/bernard/server/views.py | postback_me | async def postback_me(msg: BaseMessage, platform: Platform) -> Response:
"""
Provides the front-end with details about the user. This output can be
completed using the `api_postback_me` middleware hook.
"""
async def get_basic_info(_msg: BaseMessage, _platform: Platform):
user = _msg.get_us... | python | async def postback_me(msg: BaseMessage, platform: Platform) -> Response:
"""
Provides the front-end with details about the user. This output can be
completed using the `api_postback_me` middleware hook.
"""
async def get_basic_info(_msg: BaseMessage, _platform: Platform):
user = _msg.get_us... | [
"async",
"def",
"postback_me",
"(",
"msg",
":",
"BaseMessage",
",",
"platform",
":",
"Platform",
")",
"->",
"Response",
":",
"async",
"def",
"get_basic_info",
"(",
"_msg",
":",
"BaseMessage",
",",
"_platform",
":",
"Platform",
")",
":",
"user",
"=",
"_msg"... | Provides the front-end with details about the user. This output can be
completed using the `api_postback_me` middleware hook. | [
"Provides",
"the",
"front",
"-",
"end",
"with",
"details",
"about",
"the",
"user",
".",
"This",
"output",
"can",
"be",
"completed",
"using",
"the",
"api_postback_me",
"middleware",
"hook",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/server/views.py#L78-L95 | train | Provides the front - end with details about the user. |
BernardFW/bernard | src/bernard/server/views.py | postback_send | async def postback_send(msg: BaseMessage, platform: Platform) -> Response:
"""
Injects the POST body into the FSM as a Postback message.
"""
await platform.inject_message(msg)
return json_response({
'status': 'ok',
}) | python | async def postback_send(msg: BaseMessage, platform: Platform) -> Response:
"""
Injects the POST body into the FSM as a Postback message.
"""
await platform.inject_message(msg)
return json_response({
'status': 'ok',
}) | [
"async",
"def",
"postback_send",
"(",
"msg",
":",
"BaseMessage",
",",
"platform",
":",
"Platform",
")",
"->",
"Response",
":",
"await",
"platform",
".",
"inject_message",
"(",
"msg",
")",
"return",
"json_response",
"(",
"{",
"'status'",
":",
"'ok'",
",",
"... | Injects the POST body into the FSM as a Postback message. | [
"Injects",
"the",
"POST",
"body",
"into",
"the",
"FSM",
"as",
"a",
"Postback",
"message",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/server/views.py#L99-L108 | train | Sends a message to the FSM as a Postback message. |
BernardFW/bernard | src/bernard/server/views.py | postback_analytics | async def postback_analytics(msg: BaseMessage, platform: Platform) -> Response:
"""
Makes a call to an analytics function.
"""
try:
pb = msg.get_layers()[0]
assert isinstance(pb, Postback)
user = msg.get_user()
user_lang = await user.get_locale()
user_id = user.... | python | async def postback_analytics(msg: BaseMessage, platform: Platform) -> Response:
"""
Makes a call to an analytics function.
"""
try:
pb = msg.get_layers()[0]
assert isinstance(pb, Postback)
user = msg.get_user()
user_lang = await user.get_locale()
user_id = user.... | [
"async",
"def",
"postback_analytics",
"(",
"msg",
":",
"BaseMessage",
",",
"platform",
":",
"Platform",
")",
"->",
"Response",
":",
"try",
":",
"pb",
"=",
"msg",
".",
"get_layers",
"(",
")",
"[",
"0",
"]",
"assert",
"isinstance",
"(",
"pb",
",",
"Postb... | Makes a call to an analytics function. | [
"Makes",
"a",
"call",
"to",
"an",
"analytics",
"function",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/server/views.py#L112-L148 | train | Makes a call to an analytics function. |
openvax/varlens | varlens/variant_includes.py | ReadEvidence.column_name | def column_name(self, source, allele_group):
"""
Parameters
----------
source : string
name of the ReadSource
allele_group : string
one of: num_ref, num_alt, total_depth
Returns
----------
column name : string
"""
... | python | def column_name(self, source, allele_group):
"""
Parameters
----------
source : string
name of the ReadSource
allele_group : string
one of: num_ref, num_alt, total_depth
Returns
----------
column name : string
"""
... | [
"def",
"column_name",
"(",
"self",
",",
"source",
",",
"allele_group",
")",
":",
"return",
"self",
".",
"column_format",
".",
"format",
"(",
"source",
"=",
"source",
",",
"allele_group",
"=",
"allele_group",
")"
] | Parameters
----------
source : string
name of the ReadSource
allele_group : string
one of: num_ref, num_alt, total_depth
Returns
----------
column name : string | [
"Parameters",
"----------",
"source",
":",
"string",
"name",
"of",
"the",
"ReadSource"
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/variant_includes.py#L351-L367 | train | Returns the column name of the log entry. |
klmitch/turnstile | turnstile/control.py | register | def register(name, func=None):
"""
Function or decorator which registers a given function as a
recognized control command.
"""
def decorator(func):
# Perform the registration
ControlDaemon._register(name, func)
return func
# If func was given, call the decorator, otherw... | python | def register(name, func=None):
"""
Function or decorator which registers a given function as a
recognized control command.
"""
def decorator(func):
# Perform the registration
ControlDaemon._register(name, func)
return func
# If func was given, call the decorator, otherw... | [
"def",
"register",
"(",
"name",
",",
"func",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"# Perform the registration",
"ControlDaemon",
".",
"_register",
"(",
"name",
",",
"func",
")",
"return",
"func",
"# If func was given, call the decora... | Function or decorator which registers a given function as a
recognized control command. | [
"Function",
"or",
"decorator",
"which",
"registers",
"a",
"given",
"function",
"as",
"a",
"recognized",
"control",
"command",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L288-L304 | train | Decorator which registers a given function as a
recognized control command. |
klmitch/turnstile | turnstile/control.py | ping | def ping(daemon, channel, data=None):
"""
Process the 'ping' control message.
:param daemon: The control daemon; used to get at the
configuration and the database.
:param channel: The publish channel to which to send the
response.
:param data: Optional extra d... | python | def ping(daemon, channel, data=None):
"""
Process the 'ping' control message.
:param daemon: The control daemon; used to get at the
configuration and the database.
:param channel: The publish channel to which to send the
response.
:param data: Optional extra d... | [
"def",
"ping",
"(",
"daemon",
",",
"channel",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"channel",
":",
"# No place to reply to",
"return",
"# Get our configured node name",
"node_name",
"=",
"daemon",
".",
"config",
"[",
"'control'",
"]",
".",
"get",
... | Process the 'ping' control message.
:param daemon: The control daemon; used to get at the
configuration and the database.
:param channel: The publish channel to which to send the
response.
:param data: Optional extra data. Will be returned as the
sec... | [
"Process",
"the",
"ping",
"control",
"message",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L308-L340 | train | Process the ping message and send it to the named channel. |
klmitch/turnstile | turnstile/control.py | reload | def reload(daemon, load_type=None, spread=None):
"""
Process the 'reload' control message.
:param daemon: The control daemon; used to get at the
configuration and call the actual reload.
:param load_type: Optional type of reload. If given as
'immediate', reload... | python | def reload(daemon, load_type=None, spread=None):
"""
Process the 'reload' control message.
:param daemon: The control daemon; used to get at the
configuration and call the actual reload.
:param load_type: Optional type of reload. If given as
'immediate', reload... | [
"def",
"reload",
"(",
"daemon",
",",
"load_type",
"=",
"None",
",",
"spread",
"=",
"None",
")",
":",
"# Figure out what type of reload this needs to be",
"if",
"load_type",
"==",
"'immediate'",
":",
"spread",
"=",
"None",
"elif",
"load_type",
"==",
"'spread'",
"... | Process the 'reload' control message.
:param daemon: The control daemon; used to get at the
configuration and call the actual reload.
:param load_type: Optional type of reload. If given as
'immediate', reload is triggered
immediately. If given as... | [
"Process",
"the",
"reload",
"control",
"message",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L344-L396 | train | Process the reload message. |
klmitch/turnstile | turnstile/control.py | LimitData.set_limits | def set_limits(self, limits):
"""
Set the limit data to the given list of limits. Limits are
specified as the raw msgpack string representing the limit.
Computes the checksum of the limits; if the checksum is
identical to the current one, no action is taken.
"""
... | python | def set_limits(self, limits):
"""
Set the limit data to the given list of limits. Limits are
specified as the raw msgpack string representing the limit.
Computes the checksum of the limits; if the checksum is
identical to the current one, no action is taken.
"""
... | [
"def",
"set_limits",
"(",
"self",
",",
"limits",
")",
":",
"# First task, build the checksum of the new limits",
"chksum",
"=",
"hashlib",
".",
"md5",
"(",
")",
"# sufficient for our purposes",
"for",
"lim",
"in",
"limits",
":",
"chksum",
".",
"update",
"(",
"lim"... | Set the limit data to the given list of limits. Limits are
specified as the raw msgpack string representing the limit.
Computes the checksum of the limits; if the checksum is
identical to the current one, no action is taken. | [
"Set",
"the",
"limit",
"data",
"to",
"the",
"given",
"list",
"of",
"limits",
".",
"Limits",
"are",
"specified",
"as",
"the",
"raw",
"msgpack",
"string",
"representing",
"the",
"limit",
".",
"Computes",
"the",
"checksum",
"of",
"the",
"limits",
";",
"if",
... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L60-L80 | train | Sets the limit data to the given list of limits. |
klmitch/turnstile | turnstile/control.py | LimitData.get_limits | def get_limits(self, limit_sum=None):
"""
Gets the current limit data if it is different from the data
indicated by limit_sum. The db argument is used for hydrating
the limit objects. Raises a NoChangeException if the
limit_sum represents no change, otherwise returns a tuple
... | python | def get_limits(self, limit_sum=None):
"""
Gets the current limit data if it is different from the data
indicated by limit_sum. The db argument is used for hydrating
the limit objects. Raises a NoChangeException if the
limit_sum represents no change, otherwise returns a tuple
... | [
"def",
"get_limits",
"(",
"self",
",",
"limit_sum",
"=",
"None",
")",
":",
"with",
"self",
".",
"limit_lock",
":",
"# Any changes?",
"if",
"limit_sum",
"and",
"self",
".",
"limit_sum",
"==",
"limit_sum",
":",
"raise",
"NoChangeException",
"(",
")",
"# Return... | Gets the current limit data if it is different from the data
indicated by limit_sum. The db argument is used for hydrating
the limit objects. Raises a NoChangeException if the
limit_sum represents no change, otherwise returns a tuple
consisting of the current limit_sum and a list of Li... | [
"Gets",
"the",
"current",
"limit",
"data",
"if",
"it",
"is",
"different",
"from",
"the",
"data",
"indicated",
"by",
"limit_sum",
".",
"The",
"db",
"argument",
"is",
"used",
"for",
"hydrating",
"the",
"limit",
"objects",
".",
"Raises",
"a",
"NoChangeException... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L82-L98 | train | Gets the current limit data if it is different from the current limit data. |
klmitch/turnstile | turnstile/control.py | ControlDaemon.start | def start(self):
"""
Starts the ControlDaemon by launching the listening thread and
triggering the initial limits load.
"""
# Spawn the listening thread
self.listen_thread = eventlet.spawn_n(self.listen)
# Now do the initial load
self.reload() | python | def start(self):
"""
Starts the ControlDaemon by launching the listening thread and
triggering the initial limits load.
"""
# Spawn the listening thread
self.listen_thread = eventlet.spawn_n(self.listen)
# Now do the initial load
self.reload() | [
"def",
"start",
"(",
"self",
")",
":",
"# Spawn the listening thread",
"self",
".",
"listen_thread",
"=",
"eventlet",
".",
"spawn_n",
"(",
"self",
".",
"listen",
")",
"# Now do the initial load",
"self",
".",
"reload",
"(",
")"
] | Starts the ControlDaemon by launching the listening thread and
triggering the initial limits load. | [
"Starts",
"the",
"ControlDaemon",
"by",
"launching",
"the",
"listening",
"thread",
"and",
"triggering",
"the",
"initial",
"limits",
"load",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L136-L146 | train | Starts the ControlDaemon by launching the listening thread and then reloading the initial load. |
klmitch/turnstile | turnstile/control.py | ControlDaemon.listen | def listen(self):
"""
Listen for incoming control messages.
If the 'redis.shard_hint' configuration is set, its value will
be passed to the pubsub() method when setting up the
subscription. The control channel to subscribe to is
specified by the 'redis.control_channel' ... | python | def listen(self):
"""
Listen for incoming control messages.
If the 'redis.shard_hint' configuration is set, its value will
be passed to the pubsub() method when setting up the
subscription. The control channel to subscribe to is
specified by the 'redis.control_channel' ... | [
"def",
"listen",
"(",
"self",
")",
":",
"# Use a specific database handle, with override. This allows",
"# the long-lived listen thread to be configured to use a",
"# different database or different database options.",
"db",
"=",
"self",
".",
"config",
".",
"get_database",
"(",
"'... | Listen for incoming control messages.
If the 'redis.shard_hint' configuration is set, its value will
be passed to the pubsub() method when setting up the
subscription. The control channel to subscribe to is
specified by the 'redis.control_channel' configuration
('control' by de... | [
"Listen",
"for",
"incoming",
"control",
"messages",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L148-L212 | train | Listen for incoming control messages. |
klmitch/turnstile | turnstile/control.py | ControlDaemon.reload | def reload(self):
"""
Reloads the limits configuration from the database.
If an error occurs loading the configuration, an error-level
log message will be emitted. Additionally, the error message
will be added to the set specified by the 'redis.errors_key'
configuration... | python | def reload(self):
"""
Reloads the limits configuration from the database.
If an error occurs loading the configuration, an error-level
log message will be emitted. Additionally, the error message
will be added to the set specified by the 'redis.errors_key'
configuration... | [
"def",
"reload",
"(",
"self",
")",
":",
"# Acquire the pending semaphore. If we fail, exit--someone",
"# else is already doing the reload",
"if",
"not",
"self",
".",
"pending",
".",
"acquire",
"(",
"False",
")",
":",
"return",
"# Do the remaining steps in a try/finally block... | Reloads the limits configuration from the database.
If an error occurs loading the configuration, an error-level
log message will be emitted. Additionally, the error message
will be added to the set specified by the 'redis.errors_key'
configuration ('errors' by default) and sent to the... | [
"Reloads",
"the",
"limits",
"configuration",
"from",
"the",
"database",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L225-L271 | train | Reloads the limits configuration from the database and publishes the message to the error set. |
klmitch/turnstile | turnstile/control.py | ControlDaemon.db | def db(self):
"""
Obtain a handle for the database. This allows lazy
initialization of the database handle.
"""
# Initialize the database handle from the middleware's copy of
# it
if not self._db:
self._db = self.middleware.db
return self._d... | python | def db(self):
"""
Obtain a handle for the database. This allows lazy
initialization of the database handle.
"""
# Initialize the database handle from the middleware's copy of
# it
if not self._db:
self._db = self.middleware.db
return self._d... | [
"def",
"db",
"(",
"self",
")",
":",
"# Initialize the database handle from the middleware's copy of",
"# it",
"if",
"not",
"self",
".",
"_db",
":",
"self",
".",
"_db",
"=",
"self",
".",
"middleware",
".",
"db",
"return",
"self",
".",
"_db"
] | Obtain a handle for the database. This allows lazy
initialization of the database handle. | [
"Obtain",
"a",
"handle",
"for",
"the",
"database",
".",
"This",
"allows",
"lazy",
"initialization",
"of",
"the",
"database",
"handle",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L274-L285 | train | Returns a handle for the database. |
polyaxon/hestia | hestia/headers.py | get_header | def get_header(request, header_service):
"""Return request's 'X_POLYAXON_...:' header, as a bytestring.
Hide some test client ickyness where the header can be unicode.
"""
service = request.META.get('HTTP_{}'.format(header_service), b'')
if isinstance(service, str):
# Work around django tes... | python | def get_header(request, header_service):
"""Return request's 'X_POLYAXON_...:' header, as a bytestring.
Hide some test client ickyness where the header can be unicode.
"""
service = request.META.get('HTTP_{}'.format(header_service), b'')
if isinstance(service, str):
# Work around django tes... | [
"def",
"get_header",
"(",
"request",
",",
"header_service",
")",
":",
"service",
"=",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_{}'",
".",
"format",
"(",
"header_service",
")",
",",
"b''",
")",
"if",
"isinstance",
"(",
"service",
",",
"str",
")",
... | Return request's 'X_POLYAXON_...:' header, as a bytestring.
Hide some test client ickyness where the header can be unicode. | [
"Return",
"request",
"s",
"X_POLYAXON_",
"...",
":",
"header",
"as",
"a",
"bytestring",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/headers.py#L9-L18 | train | Return request s X_POLYAXON_... : header as a bytestring. |
garenchan/policy | demos/flask/server.py | enforce_policy | def enforce_policy(rule):
"""Enforce a policy to a API."""
def wrapper(func):
"""Decorator used for wrap API."""
@functools.wraps(func)
def wrapped(*args, **kwargs):
if enforcer.enforce(rule, {}, g.cred):
return func(*args, **kwargs)
return wrapped
... | python | def enforce_policy(rule):
"""Enforce a policy to a API."""
def wrapper(func):
"""Decorator used for wrap API."""
@functools.wraps(func)
def wrapped(*args, **kwargs):
if enforcer.enforce(rule, {}, g.cred):
return func(*args, **kwargs)
return wrapped
... | [
"def",
"enforce_policy",
"(",
"rule",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"\"\"\"Decorator used for wrap API.\"\"\"",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
... | Enforce a policy to a API. | [
"Enforce",
"a",
"policy",
"to",
"a",
"API",
"."
] | 7709ae5f371146f8c90380d0877a5e59d731f644 | https://github.com/garenchan/policy/blob/7709ae5f371146f8c90380d0877a5e59d731f644/demos/flask/server.py#L56-L67 | train | Decorator used for enforcing a policy to a API. |
jpscaletti/authcode | authcode/setups/setup_for_bottle.py | setup_for_bottle | def setup_for_bottle(
auth, app, send_email=None, render=None,
session=None, request=None, urloptions=None):
import bottle
auth.request = request or bottle.request
if session is not None:
auth.session = session
if send_email:
auth.send_email = send_email
auth.render... | python | def setup_for_bottle(
auth, app, send_email=None, render=None,
session=None, request=None, urloptions=None):
import bottle
auth.request = request or bottle.request
if session is not None:
auth.session = session
if send_email:
auth.send_email = send_email
auth.render... | [
"def",
"setup_for_bottle",
"(",
"auth",
",",
"app",
",",
"send_email",
"=",
"None",
",",
"render",
"=",
"None",
",",
"session",
"=",
"None",
",",
"request",
"=",
"None",
",",
"urloptions",
"=",
"None",
")",
":",
"import",
"bottle",
"auth",
".",
"reques... | Set the session **before** calling ``setup_for_bottle`` like this:
@hook('before_request')
def setup_request():
request.session = request.environ['beaker.session'] | [
"Set",
"the",
"session",
"**",
"before",
"**",
"calling",
"setup_for_bottle",
"like",
"this",
":"
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/setups/setup_for_bottle.py#L5-L40 | train | Setup bottle for the given application. |
jstitch/MambuPy | MambuPy/rest/mambuproduct.py | MambuProducts.convertDict2Attrs | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Product object for each one, initializing them
one at a time, and changing the attrs attribute (which just... | python | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Product object for each one, initializing them
one at a time, and changing the attrs attribute (which just... | [
"def",
"convertDict2Attrs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"n",
",",
"r",
"in",
"enumerate",
"(",
"self",
".",
"attrs",
")",
":",
"# ok ok, I'm modifying elements of a list while iterating it. BAD PRACTICE!",
"try",
":",... | The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Product object for each one, initializing them
one at a time, and changing the attrs attribute (which just
holds a list of plain dictionaries) with a Mambu... | [
"The",
"trick",
"for",
"iterable",
"Mambu",
"Objects",
"comes",
"here",
":"
] | 2af98cc12e7ed5ec183b3e97644e880e70b79ee8 | https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuproduct.py#L58-L86 | train | This function converts a dictionary of Mambu objects into a list of MambuProduct objects. |
dropseed/configyaml | configyaml/loader.py | ConfigLoader.load | def load(self):
"""
- should not be empty
- yaml itself should be valid (should we grab more than 1 yaml error at a time?)
- we should have whitelist of fields the can set at each level, and start
getting objects out of those, processing grammar if necessary, validating other s... | python | def load(self):
"""
- should not be empty
- yaml itself should be valid (should we grab more than 1 yaml error at a time?)
- we should have whitelist of fields the can set at each level, and start
getting objects out of those, processing grammar if necessary, validating other s... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"config_text",
",",
"str",
")",
":",
"self",
".",
"config_text",
"=",
"self",
".",
"config_text",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"not",
"self",
".",
"config... | - should not be empty
- yaml itself should be valid (should we grab more than 1 yaml error at a time?)
- we should have whitelist of fields the can set at each level, and start
getting objects out of those, processing grammar if necessary, validating other settings
errors coming all ... | [
"-",
"should",
"not",
"be",
"empty",
"-",
"yaml",
"itself",
"should",
"be",
"valid",
"(",
"should",
"we",
"grab",
"more",
"than",
"1",
"yaml",
"error",
"at",
"a",
"time?",
")",
"-",
"we",
"should",
"have",
"whitelist",
"of",
"fields",
"the",
"can",
"... | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/loader.py#L23-L55 | train | loads the configuration file into memory |
klmitch/turnstile | turnstile/database.py | initialize | def initialize(config):
"""
Initialize a connection to the Redis database.
"""
# Determine the client class to use
if 'redis_client' in config:
client = utils.find_entrypoint('turnstile.redis_client',
config['redis_client'], required=True)
else:
... | python | def initialize(config):
"""
Initialize a connection to the Redis database.
"""
# Determine the client class to use
if 'redis_client' in config:
client = utils.find_entrypoint('turnstile.redis_client',
config['redis_client'], required=True)
else:
... | [
"def",
"initialize",
"(",
"config",
")",
":",
"# Determine the client class to use",
"if",
"'redis_client'",
"in",
"config",
":",
"client",
"=",
"utils",
".",
"find_entrypoint",
"(",
"'turnstile.redis_client'",
",",
"config",
"[",
"'redis_client'",
"]",
",",
"requir... | Initialize a connection to the Redis database. | [
"Initialize",
"a",
"connection",
"to",
"the",
"Redis",
"database",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/database.py#L35-L111 | train | Initialize a new connection to the Redis database. |
klmitch/turnstile | turnstile/database.py | limits_hydrate | def limits_hydrate(db, lims):
"""
Helper function to hydrate a list of limits.
:param db: A database handle.
:param lims: A list of limit strings, as retrieved from the
database.
"""
return [limits.Limit.hydrate(db, lim) for lim in lims] | python | def limits_hydrate(db, lims):
"""
Helper function to hydrate a list of limits.
:param db: A database handle.
:param lims: A list of limit strings, as retrieved from the
database.
"""
return [limits.Limit.hydrate(db, lim) for lim in lims] | [
"def",
"limits_hydrate",
"(",
"db",
",",
"lims",
")",
":",
"return",
"[",
"limits",
".",
"Limit",
".",
"hydrate",
"(",
"db",
",",
"lim",
")",
"for",
"lim",
"in",
"lims",
"]"
] | Helper function to hydrate a list of limits.
:param db: A database handle.
:param lims: A list of limit strings, as retrieved from the
database. | [
"Helper",
"function",
"to",
"hydrate",
"a",
"list",
"of",
"limits",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/database.py#L114-L123 | train | Helper function to hydrate a list of limits. |
klmitch/turnstile | turnstile/database.py | limit_update | def limit_update(db, key, limits):
"""
Safely updates the list of limits in the database.
:param db: The database handle.
:param key: The key the limits are stored under.
:param limits: A list or sequence of limit objects, each
understanding the dehydrate() method.
The limit... | python | def limit_update(db, key, limits):
"""
Safely updates the list of limits in the database.
:param db: The database handle.
:param key: The key the limits are stored under.
:param limits: A list or sequence of limit objects, each
understanding the dehydrate() method.
The limit... | [
"def",
"limit_update",
"(",
"db",
",",
"key",
",",
"limits",
")",
":",
"# Start by dehydrating all the limits",
"desired",
"=",
"[",
"msgpack",
".",
"dumps",
"(",
"l",
".",
"dehydrate",
"(",
")",
")",
"for",
"l",
"in",
"limits",
"]",
"desired_set",
"=",
... | Safely updates the list of limits in the database.
:param db: The database handle.
:param key: The key the limits are stored under.
:param limits: A list or sequence of limit objects, each
understanding the dehydrate() method.
The limits list currently in the database will be atomic... | [
"Safely",
"updates",
"the",
"list",
"of",
"limits",
"in",
"the",
"database",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/database.py#L126-L172 | train | Update the list of limits in the database. |
klmitch/turnstile | turnstile/database.py | command | def command(db, channel, command, *args):
"""
Utility function to issue a command to all Turnstile instances.
:param db: The database handle.
:param channel: The control channel all Turnstile instances are
listening on.
:param command: The command, as plain text. Currently, onl... | python | def command(db, channel, command, *args):
"""
Utility function to issue a command to all Turnstile instances.
:param db: The database handle.
:param channel: The control channel all Turnstile instances are
listening on.
:param command: The command, as plain text. Currently, onl... | [
"def",
"command",
"(",
"db",
",",
"channel",
",",
"command",
",",
"*",
"args",
")",
":",
"# Build the command we're sending",
"cmd",
"=",
"[",
"command",
"]",
"cmd",
".",
"extend",
"(",
"str",
"(",
"a",
")",
"for",
"a",
"in",
"args",
")",
"# Send it ou... | Utility function to issue a command to all Turnstile instances.
:param db: The database handle.
:param channel: The control channel all Turnstile instances are
listening on.
:param command: The command, as plain text. Currently, only
'reload' and 'ping' are recogniz... | [
"Utility",
"function",
"to",
"issue",
"a",
"command",
"to",
"all",
"Turnstile",
"instances",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/database.py#L175-L196 | train | Utility function to issue a command to all Turnstile instances. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.