repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
AtteqCom/zsl | src/zsl/interface/web/utils/response_headers.py | append_headers | def append_headers(f):
"""
Appends all the web headers:
* ZSL version and information,
* default CORS if not already set up,
* cache.
:param f: The decorated function.
:return: The function which appends the web headers.
"""
@wraps(f)
def _response_decorator(*args, **kwarg... | python | def append_headers(f):
"""
Appends all the web headers:
* ZSL version and information,
* default CORS if not already set up,
* cache.
:param f: The decorated function.
:return: The function which appends the web headers.
"""
@wraps(f)
def _response_decorator(*args, **kwarg... | [
"def",
"append_headers",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"_response_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"response",
"=",
"r",
"i... | Appends all the web headers:
* ZSL version and information,
* default CORS if not already set up,
* cache.
:param f: The decorated function.
:return: The function which appends the web headers. | [
"Appends",
"all",
"the",
"web",
"headers",
":",
"*",
"ZSL",
"version",
"and",
"information",
"*",
"default",
"CORS",
"if",
"not",
"already",
"set",
"up",
"*",
"cache",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/interface/web/utils/response_headers.py#L50-L67 |
AtteqCom/zsl | src/zsl/utils/deploy/integrator.py | integrate_to_file | def integrate_to_file(what, filename, start_line, end_line):
"""WARNING this is working every second run.. so serious bug
Integrate content into a file withing "line marks"
"""
try:
with open(filename) as f:
lines = f.readlines()
except IOError:
lines = []
tmp_file ... | python | def integrate_to_file(what, filename, start_line, end_line):
"""WARNING this is working every second run.. so serious bug
Integrate content into a file withing "line marks"
"""
try:
with open(filename) as f:
lines = f.readlines()
except IOError:
lines = []
tmp_file ... | [
"def",
"integrate_to_file",
"(",
"what",
",",
"filename",
",",
"start_line",
",",
"end_line",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"except",
"IOError",
":",
"lines",
... | WARNING this is working every second run.. so serious bug
Integrate content into a file withing "line marks" | [
"WARNING",
"this",
"is",
"working",
"every",
"second",
"run",
"..",
"so",
"serious",
"bug",
"Integrate",
"content",
"into",
"a",
"file",
"withing",
"line",
"marks"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/deploy/integrator.py#L12-L52 |
AtteqCom/zsl | src/zsl/utils/model_helper.py | update_model | def update_model(raw_model, app_model, forbidden_keys=None, inverse=False):
"""Updates the `raw_model` according to the values in the `app_model`.
:param raw_model: Raw model which gets updated.
:param app_model: App model holding the data.
:param forbidden_keys: Data/attributes which will not be updat... | python | def update_model(raw_model, app_model, forbidden_keys=None, inverse=False):
"""Updates the `raw_model` according to the values in the `app_model`.
:param raw_model: Raw model which gets updated.
:param app_model: App model holding the data.
:param forbidden_keys: Data/attributes which will not be updat... | [
"def",
"update_model",
"(",
"raw_model",
",",
"app_model",
",",
"forbidden_keys",
"=",
"None",
",",
"inverse",
"=",
"False",
")",
":",
"if",
"forbidden_keys",
"is",
"None",
":",
"forbidden_keys",
"=",
"[",
"]",
"if",
"type",
"(",
"app_model",
")",
"!=",
... | Updates the `raw_model` according to the values in the `app_model`.
:param raw_model: Raw model which gets updated.
:param app_model: App model holding the data.
:param forbidden_keys: Data/attributes which will not be updated.
:type forbidden_keys: list
:param inverse: If the value is `True` all `... | [
"Updates",
"the",
"raw_model",
"according",
"to",
"the",
"values",
"in",
"the",
"app_model",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/model_helper.py#L13-L41 |
briney/abutils | abutils/utils/progbar.py | progress_bar | def progress_bar(finished, total, start_time=None, extra_info=None,
autocomplete=True, completion_string='/n'):
'''
Prints an ASCII progress bar.
Each call to ``progress_bar`` will update the progress bar. An example
of tracking the progress of a list of items would look like::
... | python | def progress_bar(finished, total, start_time=None, extra_info=None,
autocomplete=True, completion_string='/n'):
'''
Prints an ASCII progress bar.
Each call to ``progress_bar`` will update the progress bar. An example
of tracking the progress of a list of items would look like::
... | [
"def",
"progress_bar",
"(",
"finished",
",",
"total",
",",
"start_time",
"=",
"None",
",",
"extra_info",
"=",
"None",
",",
"autocomplete",
"=",
"True",
",",
"completion_string",
"=",
"'/n'",
")",
":",
"pct",
"=",
"int",
"(",
"100.",
"*",
"finished",
"/",... | Prints an ASCII progress bar.
Each call to ``progress_bar`` will update the progress bar. An example
of tracking the progress of a list of items would look like::
job_list = [job1, job2, job3, ... jobN]
total_jobs = len(job_list)
#initialize the progress bar
progress_bar(0, to... | [
"Prints",
"an",
"ASCII",
"progress",
"bar",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/progbar.py#L32-L91 |
mvcisback/py-aiger | aiger/common.py | _ite | def _ite(test: str, in1: str, in0: str, output: str = None):
r"test -> in1 /\ ~test -> in0"
assert len({test, in0, in1}) == 3
true_out = bit_flipper([test]) >> or_gate([test, in1], 'true_out')
false_out = or_gate([test, in0], 'false_out')
return (true_out | false_out) >> and_gate(['true_out', 'fals... | python | def _ite(test: str, in1: str, in0: str, output: str = None):
r"test -> in1 /\ ~test -> in0"
assert len({test, in0, in1}) == 3
true_out = bit_flipper([test]) >> or_gate([test, in1], 'true_out')
false_out = or_gate([test, in0], 'false_out')
return (true_out | false_out) >> and_gate(['true_out', 'fals... | [
"def",
"_ite",
"(",
"test",
":",
"str",
",",
"in1",
":",
"str",
",",
"in0",
":",
"str",
",",
"output",
":",
"str",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"{",
"test",
",",
"in0",
",",
"in1",
"}",
")",
"==",
"3",
"true_out",
"=",
"bit_fl... | r"test -> in1 /\ ~test -> in0 | [
"r",
"test",
"-",
">",
"in1",
"/",
"\\",
"~test",
"-",
">",
"in0"
] | train | https://github.com/mvcisback/py-aiger/blob/475ae75bd19a54ac5a71aa4dadb8369a009a1627/aiger/common.py#L126-L133 |
AtteqCom/zsl | src/zsl/db/model/raw_model.py | ModelBase.update | def update(self, app_model, forbidden_keys=None, inverse=False):
"""
Updates the raw model. Consult `zsl.utils.model_helper.update_model`.
"""
if forbidden_keys is None:
forbidden_keys = []
update_model(self, app_model, forbidden_keys, inverse) | python | def update(self, app_model, forbidden_keys=None, inverse=False):
"""
Updates the raw model. Consult `zsl.utils.model_helper.update_model`.
"""
if forbidden_keys is None:
forbidden_keys = []
update_model(self, app_model, forbidden_keys, inverse) | [
"def",
"update",
"(",
"self",
",",
"app_model",
",",
"forbidden_keys",
"=",
"None",
",",
"inverse",
"=",
"False",
")",
":",
"if",
"forbidden_keys",
"is",
"None",
":",
"forbidden_keys",
"=",
"[",
"]",
"update_model",
"(",
"self",
",",
"app_model",
",",
"f... | Updates the raw model. Consult `zsl.utils.model_helper.update_model`. | [
"Updates",
"the",
"raw",
"model",
".",
"Consult",
"zsl",
".",
"utils",
".",
"model_helper",
".",
"update_model",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/db/model/raw_model.py#L15-L22 |
AtteqCom/zsl | src/zsl/utils/xml_to_json.py | xml_to_json | def xml_to_json(element, definition, required=False):
# TODO document tuple - it looks little too complex
"""Convert XML (ElementTree) to dictionary from a definition schema.
Definition schema can be a simple string - XPath or @attribute for
direct extraction or a complex one described by
* dictio... | python | def xml_to_json(element, definition, required=False):
# TODO document tuple - it looks little too complex
"""Convert XML (ElementTree) to dictionary from a definition schema.
Definition schema can be a simple string - XPath or @attribute for
direct extraction or a complex one described by
* dictio... | [
"def",
"xml_to_json",
"(",
"element",
",",
"definition",
",",
"required",
"=",
"False",
")",
":",
"# TODO document tuple - it looks little too complex",
"# handle simple definition",
"if",
"isinstance",
"(",
"definition",
",",
"str",
")",
"and",
"len",
"(",
"definitio... | Convert XML (ElementTree) to dictionary from a definition schema.
Definition schema can be a simple string - XPath or @attribute for
direct extraction or a complex one described by
* dictionary ``{key: 'xpath or @attribute', second: 'complex definition'}`` \
required parameters can be marked with * ... | [
"Convert",
"XML",
"(",
"ElementTree",
")",
"to",
"dictionary",
"from",
"a",
"definition",
"schema",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_to_json.py#L24-L81 |
AtteqCom/zsl | src/zsl/utils/xml_to_json.py | _parse_dict | def _parse_dict(element, definition):
"""Parse xml element by a definition given in dict format.
:param element: ElementTree element
:param definition: definition schema
:type definition: dict
:return: parsed xml
:rtype: dict
"""
sub_dict = {}
for name, subdef in viewitems(definiti... | python | def _parse_dict(element, definition):
"""Parse xml element by a definition given in dict format.
:param element: ElementTree element
:param definition: definition schema
:type definition: dict
:return: parsed xml
:rtype: dict
"""
sub_dict = {}
for name, subdef in viewitems(definiti... | [
"def",
"_parse_dict",
"(",
"element",
",",
"definition",
")",
":",
"sub_dict",
"=",
"{",
"}",
"for",
"name",
",",
"subdef",
"in",
"viewitems",
"(",
"definition",
")",
":",
"(",
"name",
",",
"required",
")",
"=",
"_parse_name",
"(",
"name",
")",
"sub_di... | Parse xml element by a definition given in dict format.
:param element: ElementTree element
:param definition: definition schema
:type definition: dict
:return: parsed xml
:rtype: dict | [
"Parse",
"xml",
"element",
"by",
"a",
"definition",
"given",
"in",
"dict",
"format",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_to_json.py#L84-L100 |
AtteqCom/zsl | src/zsl/utils/xml_to_json.py | _parse_tuple | def _parse_tuple(element, definition, required):
"""Parse xml element by a definition given in tuple format.
:param element: ElementTree element
:param definition: definition schema
:type definition: tuple
:param required: parsed value should be not None
:type required: bool
:return: parsed... | python | def _parse_tuple(element, definition, required):
"""Parse xml element by a definition given in tuple format.
:param element: ElementTree element
:param definition: definition schema
:type definition: tuple
:param required: parsed value should be not None
:type required: bool
:return: parsed... | [
"def",
"_parse_tuple",
"(",
"element",
",",
"definition",
",",
"required",
")",
":",
"# TODO needs to be documented properly.",
"d_len",
"=",
"len",
"(",
"definition",
")",
"if",
"d_len",
"==",
"0",
":",
"return",
"None",
"if",
"d_len",
"==",
"1",
":",
"retu... | Parse xml element by a definition given in tuple format.
:param element: ElementTree element
:param definition: definition schema
:type definition: tuple
:param required: parsed value should be not None
:type required: bool
:return: parsed xml | [
"Parse",
"xml",
"element",
"by",
"a",
"definition",
"given",
"in",
"tuple",
"format",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_to_json.py#L103-L142 |
AtteqCom/zsl | src/zsl/utils/xml_to_json.py | _parse_list | def _parse_list(element, definition):
"""Parse xml element by definition given by list.
Find all elements matched by the string given as the first value
in the list (as XPath or @attribute).
If there is a second argument it will be handled as a definitions
for the elements matched or the text when... | python | def _parse_list(element, definition):
"""Parse xml element by definition given by list.
Find all elements matched by the string given as the first value
in the list (as XPath or @attribute).
If there is a second argument it will be handled as a definitions
for the elements matched or the text when... | [
"def",
"_parse_list",
"(",
"element",
",",
"definition",
")",
":",
"if",
"len",
"(",
"definition",
")",
"==",
"0",
":",
"raise",
"XmlToJsonException",
"(",
"'List definition needs some definition'",
")",
"tag",
"=",
"definition",
"[",
"0",
"]",
"tag_def",
"=",... | Parse xml element by definition given by list.
Find all elements matched by the string given as the first value
in the list (as XPath or @attribute).
If there is a second argument it will be handled as a definitions
for the elements matched or the text when not.
:param element: ElementTree elemen... | [
"Parse",
"xml",
"element",
"by",
"definition",
"given",
"by",
"list",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_to_json.py#L145-L171 |
AtteqCom/zsl | src/zsl/utils/xml_to_json.py | _parse_name | def _parse_name(name):
"""Parse name in complex dict definition.
In complex definition required params can be marked with `*`.
:param name:
:return: name and required flag
:rtype: tuple
"""
required = False
if name[-1] == '*':
name = name[0:-1]
required = True
ret... | python | def _parse_name(name):
"""Parse name in complex dict definition.
In complex definition required params can be marked with `*`.
:param name:
:return: name and required flag
:rtype: tuple
"""
required = False
if name[-1] == '*':
name = name[0:-1]
required = True
ret... | [
"def",
"_parse_name",
"(",
"name",
")",
":",
"required",
"=",
"False",
"if",
"name",
"[",
"-",
"1",
"]",
"==",
"'*'",
":",
"name",
"=",
"name",
"[",
"0",
":",
"-",
"1",
"]",
"required",
"=",
"True",
"return",
"name",
",",
"required"
] | Parse name in complex dict definition.
In complex definition required params can be marked with `*`.
:param name:
:return: name and required flag
:rtype: tuple | [
"Parse",
"name",
"in",
"complex",
"dict",
"definition",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_to_json.py#L174-L189 |
briney/abutils | abutils/utils/ssh_tunnel.py | get_host_port | def get_host_port(spec, default_port):
"parse 'hostname:22' into a host and port, with the port optional"
args = (spec.split(':', 1) + [default_port])[:2]
args[1] = int(args[1])
return args[0], args[1] | python | def get_host_port(spec, default_port):
"parse 'hostname:22' into a host and port, with the port optional"
args = (spec.split(':', 1) + [default_port])[:2]
args[1] = int(args[1])
return args[0], args[1] | [
"def",
"get_host_port",
"(",
"spec",
",",
"default_port",
")",
":",
"args",
"=",
"(",
"spec",
".",
"split",
"(",
"':'",
",",
"1",
")",
"+",
"[",
"default_port",
"]",
")",
"[",
":",
"2",
"]",
"args",
"[",
"1",
"]",
"=",
"int",
"(",
"args",
"[",
... | parse 'hostname:22' into a host and port, with the port optional | [
"parse",
"hostname",
":",
"22",
"into",
"a",
"host",
"and",
"port",
"with",
"the",
"port",
"optional"
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/ssh_tunnel.py#L105-L109 |
briney/abutils | abutils/core/lineage.py | Lineage.name | def name(self):
'''
Returns the lineage name, or None if the name cannot be found.
'''
clonify_ids = [p.heavy['clonify']['id'] for p in self.heavies if 'clonify' in p.heavy]
if len(clonify_ids) > 0:
return clonify_ids[0]
return None | python | def name(self):
'''
Returns the lineage name, or None if the name cannot be found.
'''
clonify_ids = [p.heavy['clonify']['id'] for p in self.heavies if 'clonify' in p.heavy]
if len(clonify_ids) > 0:
return clonify_ids[0]
return None | [
"def",
"name",
"(",
"self",
")",
":",
"clonify_ids",
"=",
"[",
"p",
".",
"heavy",
"[",
"'clonify'",
"]",
"[",
"'id'",
"]",
"for",
"p",
"in",
"self",
".",
"heavies",
"if",
"'clonify'",
"in",
"p",
".",
"heavy",
"]",
"if",
"len",
"(",
"clonify_ids",
... | Returns the lineage name, or None if the name cannot be found. | [
"Returns",
"the",
"lineage",
"name",
"or",
"None",
"if",
"the",
"name",
"cannot",
"be",
"found",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/lineage.py#L170-L177 |
briney/abutils | abutils/core/lineage.py | Lineage.verified_pairs | def verified_pairs(self):
'''
Returns all lineage Pair objects that contain verified pairings.
'''
if not hasattr(self.just_pairs[0], 'verified'):
self.verify_light_chains()
return [p for p in self.just_pairs if p.verified] | python | def verified_pairs(self):
'''
Returns all lineage Pair objects that contain verified pairings.
'''
if not hasattr(self.just_pairs[0], 'verified'):
self.verify_light_chains()
return [p for p in self.just_pairs if p.verified] | [
"def",
"verified_pairs",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"just_pairs",
"[",
"0",
"]",
",",
"'verified'",
")",
":",
"self",
".",
"verify_light_chains",
"(",
")",
"return",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"just... | Returns all lineage Pair objects that contain verified pairings. | [
"Returns",
"all",
"lineage",
"Pair",
"objects",
"that",
"contain",
"verified",
"pairings",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/lineage.py#L188-L194 |
briney/abutils | abutils/core/lineage.py | Lineage.size | def size(self, pairs_only=False):
'''
Calculate the size of the lineage.
Inputs (optional)
-----------------
pairs_only: count only paired sequences
Returns
-------
Lineage size (int)
'''
if pairs_only:
return len(self.just_pa... | python | def size(self, pairs_only=False):
'''
Calculate the size of the lineage.
Inputs (optional)
-----------------
pairs_only: count only paired sequences
Returns
-------
Lineage size (int)
'''
if pairs_only:
return len(self.just_pa... | [
"def",
"size",
"(",
"self",
",",
"pairs_only",
"=",
"False",
")",
":",
"if",
"pairs_only",
":",
"return",
"len",
"(",
"self",
".",
"just_pairs",
")",
"else",
":",
"return",
"len",
"(",
"self",
".",
"heavies",
")"
] | Calculate the size of the lineage.
Inputs (optional)
-----------------
pairs_only: count only paired sequences
Returns
-------
Lineage size (int) | [
"Calculate",
"the",
"size",
"of",
"the",
"lineage",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/lineage.py#L273-L288 |
briney/abutils | abutils/core/lineage.py | Lineage.verify_light_chains | def verify_light_chains(self, threshold=0.9):
'''
Clusters the light chains to identify potentially spurious (non-lineage)
pairings. Following clustering, all pairs in the largest light chain
cluster are assumed to be correctly paired. For each of those pairs,
the <verified> attr... | python | def verify_light_chains(self, threshold=0.9):
'''
Clusters the light chains to identify potentially spurious (non-lineage)
pairings. Following clustering, all pairs in the largest light chain
cluster are assumed to be correctly paired. For each of those pairs,
the <verified> attr... | [
"def",
"verify_light_chains",
"(",
"self",
",",
"threshold",
"=",
"0.9",
")",
":",
"lseqs",
"=",
"[",
"l",
".",
"light",
"for",
"l",
"in",
"self",
".",
"lights",
"]",
"clusters",
"=",
"cluster",
"(",
"lseqs",
",",
"threshold",
"=",
"threshold",
")",
... | Clusters the light chains to identify potentially spurious (non-lineage)
pairings. Following clustering, all pairs in the largest light chain
cluster are assumed to be correctly paired. For each of those pairs,
the <verified> attribute is set to True. For pairs not in the largest
light c... | [
"Clusters",
"the",
"light",
"chains",
"to",
"identify",
"potentially",
"spurious",
"(",
"non",
"-",
"lineage",
")",
"pairings",
".",
"Following",
"clustering",
"all",
"pairs",
"in",
"the",
"largest",
"light",
"chain",
"cluster",
"are",
"assumed",
"to",
"be",
... | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/lineage.py#L291-L308 |
briney/abutils | abutils/core/lineage.py | Lineage.dot_alignment | def dot_alignment(self, seq_field='vdj_nt', name_field='seq_id', uca=None,
chain='heavy', uca_name='UCA', as_fasta=False, just_alignment=False):
'''
Returns a multiple sequence alignment of all lineage sequence with the UCA
where matches to the UCA are shown as dots and mismatches ar... | python | def dot_alignment(self, seq_field='vdj_nt', name_field='seq_id', uca=None,
chain='heavy', uca_name='UCA', as_fasta=False, just_alignment=False):
'''
Returns a multiple sequence alignment of all lineage sequence with the UCA
where matches to the UCA are shown as dots and mismatches ar... | [
"def",
"dot_alignment",
"(",
"self",
",",
"seq_field",
"=",
"'vdj_nt'",
",",
"name_field",
"=",
"'seq_id'",
",",
"uca",
"=",
"None",
",",
"chain",
"=",
"'heavy'",
",",
"uca_name",
"=",
"'UCA'",
",",
"as_fasta",
"=",
"False",
",",
"just_alignment",
"=",
"... | Returns a multiple sequence alignment of all lineage sequence with the UCA
where matches to the UCA are shown as dots and mismatches are shown as the
mismatched residue.
Inputs (optional)
-----------------
seq_field: the sequence field to be used for alignment. Default is 'vdj_n... | [
"Returns",
"a",
"multiple",
"sequence",
"alignment",
"of",
"all",
"lineage",
"sequence",
"with",
"the",
"UCA",
"where",
"matches",
"to",
"the",
"UCA",
"are",
"shown",
"as",
"dots",
"and",
"mismatches",
"are",
"shown",
"as",
"the",
"mismatched",
"residue",
".... | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/lineage.py#L311-L366 |
datacamp/protowhat | protowhat/State.py | State.to_child | def to_child(self, append_message="", **kwargs):
"""Basic implementation of returning a child state"""
bad_pars = set(kwargs) - set(self._child_params)
if bad_pars:
raise KeyError("Invalid init params for State: %s" % ", ".join(bad_pars))
child = copy(self)
for k, v... | python | def to_child(self, append_message="", **kwargs):
"""Basic implementation of returning a child state"""
bad_pars = set(kwargs) - set(self._child_params)
if bad_pars:
raise KeyError("Invalid init params for State: %s" % ", ".join(bad_pars))
child = copy(self)
for k, v... | [
"def",
"to_child",
"(",
"self",
",",
"append_message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"bad_pars",
"=",
"set",
"(",
"kwargs",
")",
"-",
"set",
"(",
"self",
".",
"_child_params",
")",
"if",
"bad_pars",
":",
"raise",
"KeyError",
"(",
"\... | Basic implementation of returning a child state | [
"Basic",
"implementation",
"of",
"returning",
"a",
"child",
"state"
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/State.py#L120-L137 |
AtteqCom/zsl | src/zsl/utils/rss.py | complex_el_from_dict | def complex_el_from_dict(parent, data, key):
"""Create element from a dict definition and add it to ``parent``.
:param parent: parent element
:type parent: Element
:param data: dictionary with elements definitions, it can be a simple \
{element_name: 'element_value'} or complex \
{element_name:... | python | def complex_el_from_dict(parent, data, key):
"""Create element from a dict definition and add it to ``parent``.
:param parent: parent element
:type parent: Element
:param data: dictionary with elements definitions, it can be a simple \
{element_name: 'element_value'} or complex \
{element_name:... | [
"def",
"complex_el_from_dict",
"(",
"parent",
",",
"data",
",",
"key",
")",
":",
"el",
"=",
"ET",
".",
"SubElement",
"(",
"parent",
",",
"key",
")",
"value",
"=",
"data",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"if... | Create element from a dict definition and add it to ``parent``.
:param parent: parent element
:type parent: Element
:param data: dictionary with elements definitions, it can be a simple \
{element_name: 'element_value'} or complex \
{element_name: {_attr: {name: value, name1: value1}, _text: 'text'... | [
"Create",
"element",
"from",
"a",
"dict",
"definition",
"and",
"add",
"it",
"to",
"parent",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/rss.py#L16-L41 |
AtteqCom/zsl | src/zsl/utils/rss.py | element_from_dict | def element_from_dict(parent, data, element):
"""Create ``element`` to ``parent`` and sets its value to data[element], which
will be removed from the ``data``.
:param parent: parent element
:type parent: Element
:param data: dictionary where data[element] is desired value
:type data: dict(str, ... | python | def element_from_dict(parent, data, element):
"""Create ``element`` to ``parent`` and sets its value to data[element], which
will be removed from the ``data``.
:param parent: parent element
:type parent: Element
:param data: dictionary where data[element] is desired value
:type data: dict(str, ... | [
"def",
"element_from_dict",
"(",
"parent",
",",
"data",
",",
"element",
")",
":",
"el",
"=",
"ET",
".",
"SubElement",
"(",
"parent",
",",
"element",
")",
"el",
".",
"text",
"=",
"data",
".",
"pop",
"(",
"element",
")",
"return",
"el"
] | Create ``element`` to ``parent`` and sets its value to data[element], which
will be removed from the ``data``.
:param parent: parent element
:type parent: Element
:param data: dictionary where data[element] is desired value
:type data: dict(str, str)
:param element: name of the new element
... | [
"Create",
"element",
"to",
"parent",
"and",
"sets",
"its",
"value",
"to",
"data",
"[",
"element",
"]",
"which",
"will",
"be",
"removed",
"from",
"the",
"data",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/rss.py#L44-L59 |
AtteqCom/zsl | src/zsl/utils/rss.py | rss_create | def rss_create(channel, articles):
"""Create RSS xml feed.
:param channel: channel info [title, link, description, language]
:type channel: dict(str, str)
:param articles: list of articles, an article is a dictionary with some \
required fields [title, description, link] and any optional, which wil... | python | def rss_create(channel, articles):
"""Create RSS xml feed.
:param channel: channel info [title, link, description, language]
:type channel: dict(str, str)
:param articles: list of articles, an article is a dictionary with some \
required fields [title, description, link] and any optional, which wil... | [
"def",
"rss_create",
"(",
"channel",
",",
"articles",
")",
":",
"channel",
"=",
"channel",
".",
"copy",
"(",
")",
"# TODO use deepcopy",
"# list will not clone the dictionaries in the list and `elemen_from_dict`",
"# pops items from them",
"articles",
"=",
"list",
"(",
"a... | Create RSS xml feed.
:param channel: channel info [title, link, description, language]
:type channel: dict(str, str)
:param articles: list of articles, an article is a dictionary with some \
required fields [title, description, link] and any optional, which will \
result to `<dict_key>dict_value</d... | [
"Create",
"RSS",
"xml",
"feed",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/rss.py#L62-L101 |
AtteqCom/zsl | src/zsl/utils/security_helper.py | compute_token | def compute_token(random_token, config):
"""Compute a hash of the given token with a preconfigured secret.
:param random_token: random token
:type random_token: str
:return: hashed token
:rtype: str
"""
secure_token = config[TOKEN_SERVICE_SECURITY_CONFIG]
sha1hash = hashlib.sha1()
s... | python | def compute_token(random_token, config):
"""Compute a hash of the given token with a preconfigured secret.
:param random_token: random token
:type random_token: str
:return: hashed token
:rtype: str
"""
secure_token = config[TOKEN_SERVICE_SECURITY_CONFIG]
sha1hash = hashlib.sha1()
s... | [
"def",
"compute_token",
"(",
"random_token",
",",
"config",
")",
":",
"secure_token",
"=",
"config",
"[",
"TOKEN_SERVICE_SECURITY_CONFIG",
"]",
"sha1hash",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"sha1hash",
".",
"update",
"(",
"random_token",
"+",
"secure_token"... | Compute a hash of the given token with a preconfigured secret.
:param random_token: random token
:type random_token: str
:return: hashed token
:rtype: str | [
"Compute",
"a",
"hash",
"of",
"the",
"given",
"token",
"with",
"a",
"preconfigured",
"secret",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/security_helper.py#L44-L55 |
AtteqCom/zsl | src/zsl/utils/security_helper.py | verify_security_data | def verify_security_data(security):
"""Verify an untrusted security token.
:param security: security token
:type security: dict
:return: True if valid
:rtype: bool
"""
random_token = security[TOKEN_RANDOM]
hashed_token = security[TOKEN_HASHED]
return str(hashed_token) == str(compute... | python | def verify_security_data(security):
"""Verify an untrusted security token.
:param security: security token
:type security: dict
:return: True if valid
:rtype: bool
"""
random_token = security[TOKEN_RANDOM]
hashed_token = security[TOKEN_HASHED]
return str(hashed_token) == str(compute... | [
"def",
"verify_security_data",
"(",
"security",
")",
":",
"random_token",
"=",
"security",
"[",
"TOKEN_RANDOM",
"]",
"hashed_token",
"=",
"security",
"[",
"TOKEN_HASHED",
"]",
"return",
"str",
"(",
"hashed_token",
")",
"==",
"str",
"(",
"compute_token",
"(",
"... | Verify an untrusted security token.
:param security: security token
:type security: dict
:return: True if valid
:rtype: bool | [
"Verify",
"an",
"untrusted",
"security",
"token",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/security_helper.py#L58-L68 |
briney/abutils | abutils/utils/pipeline.py | initialize | def initialize(log_file, project_dir=None, debug=False):
'''
Initializes an AbTools pipeline.
Initialization includes printing the AbTools splash, setting up logging,
creating the project directory, and logging both the project directory
and the log location.
Args:
log_file (str): Pat... | python | def initialize(log_file, project_dir=None, debug=False):
'''
Initializes an AbTools pipeline.
Initialization includes printing the AbTools splash, setting up logging,
creating the project directory, and logging both the project directory
and the log location.
Args:
log_file (str): Pat... | [
"def",
"initialize",
"(",
"log_file",
",",
"project_dir",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"print_splash",
"(",
")",
"log",
".",
"setup_logging",
"(",
"log_file",
",",
"print_log_location",
"=",
"False",
",",
"debug",
"=",
"debug",
")",
... | Initializes an AbTools pipeline.
Initialization includes printing the AbTools splash, setting up logging,
creating the project directory, and logging both the project directory
and the log location.
Args:
log_file (str): Path to the log file. Required.
project_dir (str): Path to the ... | [
"Initializes",
"an",
"AbTools",
"pipeline",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/pipeline.py#L40-L71 |
briney/abutils | abutils/utils/pipeline.py | list_files | def list_files(d, extension=None):
'''
Lists files in a given directory.
Args:
d (str): Path to a directory.
extension (str): If supplied, only files that contain the
specificied extension will be returned. Default is ``False``,
which returns all files in ``d``.
... | python | def list_files(d, extension=None):
'''
Lists files in a given directory.
Args:
d (str): Path to a directory.
extension (str): If supplied, only files that contain the
specificied extension will be returned. Default is ``False``,
which returns all files in ``d``.
... | [
"def",
"list_files",
"(",
"d",
",",
"extension",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"d",
")",
":",
"expanded_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"d",
")",
"files",
"=",
"sorted",
"(",
"glob",
".",... | Lists files in a given directory.
Args:
d (str): Path to a directory.
extension (str): If supplied, only files that contain the
specificied extension will be returned. Default is ``False``,
which returns all files in ``d``.
Returns:
list: A sorted list of fil... | [
"Lists",
"files",
"in",
"a",
"given",
"directory",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/pipeline.py#L86-L113 |
AtteqCom/zsl | src/zsl/interface/cli.py | _get_version | def _get_version(ctx, _, value):
"""Click callback for option to show current ZSL version."""
if not value or ctx.resilient_parsing:
return
message = 'Zsl %(version)s\nPython %(python_version)s'
click.echo(message % {
'version': version,
'python_version': sys.version,
}, col... | python | def _get_version(ctx, _, value):
"""Click callback for option to show current ZSL version."""
if not value or ctx.resilient_parsing:
return
message = 'Zsl %(version)s\nPython %(python_version)s'
click.echo(message % {
'version': version,
'python_version': sys.version,
}, col... | [
"def",
"_get_version",
"(",
"ctx",
",",
"_",
",",
"value",
")",
":",
"if",
"not",
"value",
"or",
"ctx",
".",
"resilient_parsing",
":",
"return",
"message",
"=",
"'Zsl %(version)s\\nPython %(python_version)s'",
"click",
".",
"echo",
"(",
"message",
"%",
"{",
... | Click callback for option to show current ZSL version. | [
"Click",
"callback",
"for",
"option",
"to",
"show",
"current",
"ZSL",
"version",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/interface/cli.py#L22-L32 |
AtteqCom/zsl | src/zsl/utils/resource_helper.py | create_model_resource | def create_model_resource(resource_map, name, app=Injected):
"""Create a model resource from a dict ``resource_map``
{'resource name': ('model package', 'model class')}
:param resource_map: dict with resource descriptions
:type resource_map: dict(str, tuple(str))
:param name: name of the concrete r... | python | def create_model_resource(resource_map, name, app=Injected):
"""Create a model resource from a dict ``resource_map``
{'resource name': ('model package', 'model class')}
:param resource_map: dict with resource descriptions
:type resource_map: dict(str, tuple(str))
:param name: name of the concrete r... | [
"def",
"create_model_resource",
"(",
"resource_map",
",",
"name",
",",
"app",
"=",
"Injected",
")",
":",
"try",
":",
"resource_description",
"=",
"resource_map",
"[",
"name",
"]",
"if",
"len",
"(",
"resource_description",
")",
"==",
"2",
":",
"module_name",
... | Create a model resource from a dict ``resource_map``
{'resource name': ('model package', 'model class')}
:param resource_map: dict with resource descriptions
:type resource_map: dict(str, tuple(str))
:param name: name of the concrete resource
:param app: current application, injected
:type app:... | [
"Create",
"a",
"model",
"resource",
"from",
"a",
"dict",
"resource_map",
"{",
"resource",
"name",
":",
"(",
"model",
"package",
"model",
"class",
")",
"}"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/resource_helper.py#L130-L156 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | dict_pick | def dict_pick(dictionary, allowed_keys):
"""
Return a dictionary only with keys found in `allowed_keys`
"""
return {key: value for key, value in viewitems(dictionary) if key in allowed_keys} | python | def dict_pick(dictionary, allowed_keys):
"""
Return a dictionary only with keys found in `allowed_keys`
"""
return {key: value for key, value in viewitems(dictionary) if key in allowed_keys} | [
"def",
"dict_pick",
"(",
"dictionary",
",",
"allowed_keys",
")",
":",
"return",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"viewitems",
"(",
"dictionary",
")",
"if",
"key",
"in",
"allowed_keys",
"}"
] | Return a dictionary only with keys found in `allowed_keys` | [
"Return",
"a",
"dictionary",
"only",
"with",
"keys",
"found",
"in",
"allowed_keys"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L39-L43 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | page_to_offset | def page_to_offset(params):
"""
Transforms `page`/`per_page` from `params` to `limit`/`offset` suitable for SQL.
:param dict params: The dictionary containing `page` and `per_page` values will be added
the values `limit` and `offset`.
"""
if 'page' not in params:
re... | python | def page_to_offset(params):
"""
Transforms `page`/`per_page` from `params` to `limit`/`offset` suitable for SQL.
:param dict params: The dictionary containing `page` and `per_page` values will be added
the values `limit` and `offset`.
"""
if 'page' not in params:
re... | [
"def",
"page_to_offset",
"(",
"params",
")",
":",
"if",
"'page'",
"not",
"in",
"params",
":",
"return",
"page",
"=",
"params",
"[",
"'page'",
"]",
"del",
"params",
"[",
"'page'",
"]",
"# 'per_page' je len alias za 'limit'",
"if",
"'per_page'",
"in",
"params",
... | Transforms `page`/`per_page` from `params` to `limit`/`offset` suitable for SQL.
:param dict params: The dictionary containing `page` and `per_page` values will be added
the values `limit` and `offset`. | [
"Transforms",
"page",
"/",
"per_page",
"from",
"params",
"to",
"limit",
"/",
"offset",
"suitable",
"for",
"SQL",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L46-L68 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource.create | def create(self, params, args, data):
# type: (str, dict, dict) -> AppModel
"""
POST /resource/model_cls/
data
Create new resource
"""
ctx = self._create_context(params, args, data)
model = self._create_one(ctx)
self._save_one(model, ctx)
... | python | def create(self, params, args, data):
# type: (str, dict, dict) -> AppModel
"""
POST /resource/model_cls/
data
Create new resource
"""
ctx = self._create_context(params, args, data)
model = self._create_one(ctx)
self._save_one(model, ctx)
... | [
"def",
"create",
"(",
"self",
",",
"params",
",",
"args",
",",
"data",
")",
":",
"# type: (str, dict, dict) -> AppModel",
"ctx",
"=",
"self",
".",
"_create_context",
"(",
"params",
",",
"args",
",",
"data",
")",
"model",
"=",
"self",
".",
"_create_one",
"(... | POST /resource/model_cls/
data
Create new resource | [
"POST",
"/",
"resource",
"/",
"model_cls",
"/",
"data"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L202-L213 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource.read | def read(self, params=None, args=None, data=None):
# type: (str, dict, dict) -> Union[List[AppModel], AppModel]
"""
GET /resource/model_cls/[params:id]?[args:{limit,offset,page,per_page,filter_by,order_by,related,fields}]
Get resource/s
:param params
:type params list
... | python | def read(self, params=None, args=None, data=None):
# type: (str, dict, dict) -> Union[List[AppModel], AppModel]
"""
GET /resource/model_cls/[params:id]?[args:{limit,offset,page,per_page,filter_by,order_by,related,fields}]
Get resource/s
:param params
:type params list
... | [
"def",
"read",
"(",
"self",
",",
"params",
"=",
"None",
",",
"args",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"# type: (str, dict, dict) -> Union[List[AppModel], AppModel]",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"[",
"]",
"if",
"args",
... | GET /resource/model_cls/[params:id]?[args:{limit,offset,page,per_page,filter_by,order_by,related,fields}]
Get resource/s
:param params
:type params list
:param args
:type args dict
:param data
:type data: dict | [
"GET",
"/",
"resource",
"/",
"model_cls",
"/",
"[",
"params",
":",
"id",
"]",
"?",
"[",
"args",
":",
"{",
"limit",
"offset",
"page",
"per_page",
"filter_by",
"order_by",
"related",
"fields",
"}",
"]"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L215-L250 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource.update | def update(self, params, args, data):
# type: (str, dict, dict) -> Union[List[AppModel], AppModel]
"""
PUT /resource/model_cls/[params:id]
data
Update resource/s
"""
ctx = self._create_context(params, args, data)
row_id = ctx.get_row_id()
if row_... | python | def update(self, params, args, data):
# type: (str, dict, dict) -> Union[List[AppModel], AppModel]
"""
PUT /resource/model_cls/[params:id]
data
Update resource/s
"""
ctx = self._create_context(params, args, data)
row_id = ctx.get_row_id()
if row_... | [
"def",
"update",
"(",
"self",
",",
"params",
",",
"args",
",",
"data",
")",
":",
"# type: (str, dict, dict) -> Union[List[AppModel], AppModel]",
"ctx",
"=",
"self",
".",
"_create_context",
"(",
"params",
",",
"args",
",",
"data",
")",
"row_id",
"=",
"ctx",
"."... | PUT /resource/model_cls/[params:id]
data
Update resource/s | [
"PUT",
"/",
"resource",
"/",
"model_cls",
"/",
"[",
"params",
":",
"id",
"]",
"data"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L253-L268 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource.delete | def delete(self, params, args, data):
# type: (str, dict, dict) -> None
"""
DELETE /resource/model_cls/[params]?[args]
delete resource/s
"""
ctx = self._create_context(params, args, data)
row_id = ctx.get_row_id()
if row_id is not None:
retur... | python | def delete(self, params, args, data):
# type: (str, dict, dict) -> None
"""
DELETE /resource/model_cls/[params]?[args]
delete resource/s
"""
ctx = self._create_context(params, args, data)
row_id = ctx.get_row_id()
if row_id is not None:
retur... | [
"def",
"delete",
"(",
"self",
",",
"params",
",",
"args",
",",
"data",
")",
":",
"# type: (str, dict, dict) -> None",
"ctx",
"=",
"self",
".",
"_create_context",
"(",
"params",
",",
"args",
",",
"data",
")",
"row_id",
"=",
"ctx",
".",
"get_row_id",
"(",
... | DELETE /resource/model_cls/[params]?[args]
delete resource/s | [
"DELETE",
"/",
"resource",
"/",
"model_cls",
"/",
"[",
"params",
"]",
"?",
"[",
"args",
"]"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L271-L284 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource._create_one | def _create_one(self, ctx):
"""
Creates an instance to be saved when a model is created.
"""
assert isinstance(ctx, ResourceQueryContext)
fields = dict_pick(ctx.data, self._model_columns)
model = self.model_cls(**fields)
return model | python | def _create_one(self, ctx):
"""
Creates an instance to be saved when a model is created.
"""
assert isinstance(ctx, ResourceQueryContext)
fields = dict_pick(ctx.data, self._model_columns)
model = self.model_cls(**fields)
return model | [
"def",
"_create_one",
"(",
"self",
",",
"ctx",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"ResourceQueryContext",
")",
"fields",
"=",
"dict_pick",
"(",
"ctx",
".",
"data",
",",
"self",
".",
"_model_columns",
")",
"model",
"=",
"self",
".",
"model... | Creates an instance to be saved when a model is created. | [
"Creates",
"an",
"instance",
"to",
"be",
"saved",
"when",
"a",
"model",
"is",
"created",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L287-L295 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource._save_one | def _save_one(self, model, ctx):
"""
Saves the created instance.
"""
assert isinstance(ctx, ResourceQueryContext)
self._orm.add(model)
self._orm.flush() | python | def _save_one(self, model, ctx):
"""
Saves the created instance.
"""
assert isinstance(ctx, ResourceQueryContext)
self._orm.add(model)
self._orm.flush() | [
"def",
"_save_one",
"(",
"self",
",",
"model",
",",
"ctx",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"ResourceQueryContext",
")",
"self",
".",
"_orm",
".",
"add",
"(",
"model",
")",
"self",
".",
"_orm",
".",
"flush",
"(",
")"
] | Saves the created instance. | [
"Saves",
"the",
"created",
"instance",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L297-L304 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource._update_one | def _update_one(self, ctx):
"""
Update row
"""
assert isinstance(ctx, ResourceQueryContext)
fields = ctx.data
row_id = ctx.get_row_id()
return self._update_one_simple(row_id, fields, ctx) | python | def _update_one(self, ctx):
"""
Update row
"""
assert isinstance(ctx, ResourceQueryContext)
fields = ctx.data
row_id = ctx.get_row_id()
return self._update_one_simple(row_id, fields, ctx) | [
"def",
"_update_one",
"(",
"self",
",",
"ctx",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"ResourceQueryContext",
")",
"fields",
"=",
"ctx",
".",
"data",
"row_id",
"=",
"ctx",
".",
"get_row_id",
"(",
")",
"return",
"self",
".",
"_update_one_simple"... | Update row | [
"Update",
"row"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L402-L409 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource._update_collection | def _update_collection(self, ctx):
"""
Bulk update
"""
assert isinstance(ctx, ResourceQueryContext)
models = []
for row in ctx.data:
models.append(self._update_one_simple(row.pop('id'), row, ctx))
return models | python | def _update_collection(self, ctx):
"""
Bulk update
"""
assert isinstance(ctx, ResourceQueryContext)
models = []
for row in ctx.data:
models.append(self._update_one_simple(row.pop('id'), row, ctx))
return models | [
"def",
"_update_collection",
"(",
"self",
",",
"ctx",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"ResourceQueryContext",
")",
"models",
"=",
"[",
"]",
"for",
"row",
"in",
"ctx",
".",
"data",
":",
"models",
".",
"append",
"(",
"self",
".",
"_upd... | Bulk update | [
"Bulk",
"update"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L411-L421 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource._create_delete_one_query | def _create_delete_one_query(self, row_id, ctx):
"""
Delete row by id query creation.
:param int row_id: Identifier of the deleted row.
:param ResourceQueryContext ctx: The context of this delete query.
"""
assert isinstance(ctx, ResourceQueryContext)
return sel... | python | def _create_delete_one_query(self, row_id, ctx):
"""
Delete row by id query creation.
:param int row_id: Identifier of the deleted row.
:param ResourceQueryContext ctx: The context of this delete query.
"""
assert isinstance(ctx, ResourceQueryContext)
return sel... | [
"def",
"_create_delete_one_query",
"(",
"self",
",",
"row_id",
",",
"ctx",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"ResourceQueryContext",
")",
"return",
"self",
".",
"_orm",
".",
"query",
"(",
"self",
".",
"model_cls",
")",
".",
"filter",
"(",
... | Delete row by id query creation.
:param int row_id: Identifier of the deleted row.
:param ResourceQueryContext ctx: The context of this delete query. | [
"Delete",
"row",
"by",
"id",
"query",
"creation",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L434-L443 |
AtteqCom/zsl | src/zsl/resource/model_resource.py | ModelResource._delete_collection | def _delete_collection(self, ctx):
"""
Delete a collection from DB, optionally filtered by ``filter_by``
"""
assert isinstance(ctx, ResourceQueryContext)
filter_by = ctx.get_filter_by()
q = self._orm.query(self.model_cls)
if filter_by is not None:
q ... | python | def _delete_collection(self, ctx):
"""
Delete a collection from DB, optionally filtered by ``filter_by``
"""
assert isinstance(ctx, ResourceQueryContext)
filter_by = ctx.get_filter_by()
q = self._orm.query(self.model_cls)
if filter_by is not None:
q ... | [
"def",
"_delete_collection",
"(",
"self",
",",
"ctx",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"ResourceQueryContext",
")",
"filter_by",
"=",
"ctx",
".",
"get_filter_by",
"(",
")",
"q",
"=",
"self",
".",
"_orm",
".",
"query",
"(",
"self",
".",
... | Delete a collection from DB, optionally filtered by ``filter_by`` | [
"Delete",
"a",
"collection",
"from",
"DB",
"optionally",
"filtered",
"by",
"filter_by"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/model_resource.py#L445-L457 |
AtteqCom/zsl | src/zsl/utils/email_helper.py | send_email | def send_email(sender, receivers, subject, text=None, html=None, charset='utf-8', config=Injected):
"""Sends an email.
:param sender: Sender as string or None for default got from config.
:param receivers: String or array of recipients.
:param subject: Subject.
:param text: Plain text message.
... | python | def send_email(sender, receivers, subject, text=None, html=None, charset='utf-8', config=Injected):
"""Sends an email.
:param sender: Sender as string or None for default got from config.
:param receivers: String or array of recipients.
:param subject: Subject.
:param text: Plain text message.
... | [
"def",
"send_email",
"(",
"sender",
",",
"receivers",
",",
"subject",
",",
"text",
"=",
"None",
",",
"html",
"=",
"None",
",",
"charset",
"=",
"'utf-8'",
",",
"config",
"=",
"Injected",
")",
":",
"smtp_config",
"=",
"config",
"[",
"'SMTP'",
"]",
"# Rec... | Sends an email.
:param sender: Sender as string or None for default got from config.
:param receivers: String or array of recipients.
:param subject: Subject.
:param text: Plain text message.
:param html: Html message.
:param charset: Charset.
:param config: Current configuration | [
"Sends",
"an",
"email",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/email_helper.py#L16-L63 |
AtteqCom/zsl | src/zsl/router/task.py | TaskNamespace.add_packages | def add_packages(self, packages):
"""
Adds an automatic resolution of urls into tasks.
:param packages: The url will determine package/module and the class.
:return: self
"""
# type: (List[str])->TaskNamespace
assert isinstance(packages, list), "Packages must be l... | python | def add_packages(self, packages):
"""
Adds an automatic resolution of urls into tasks.
:param packages: The url will determine package/module and the class.
:return: self
"""
# type: (List[str])->TaskNamespace
assert isinstance(packages, list), "Packages must be l... | [
"def",
"add_packages",
"(",
"self",
",",
"packages",
")",
":",
"# type: (List[str])->TaskNamespace",
"assert",
"isinstance",
"(",
"packages",
",",
"list",
")",
",",
"\"Packages must be list of strings.\"",
"self",
".",
"_task_packages",
"+=",
"packages",
"return",
"se... | Adds an automatic resolution of urls into tasks.
:param packages: The url will determine package/module and the class.
:return: self | [
"Adds",
"an",
"automatic",
"resolution",
"of",
"urls",
"into",
"tasks",
".",
":",
"param",
"packages",
":",
"The",
"url",
"will",
"determine",
"package",
"/",
"module",
"and",
"the",
"class",
".",
":",
"return",
":",
"self"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/router/task.py#L29-L38 |
AtteqCom/zsl | src/zsl/router/task.py | TaskRouter.route | def route(self, path):
# type: (str)->Tuple[Any, Callable]
"""
Returns the task handling the given request path.
"""
logging.getLogger(__name__).debug("Routing path '%s'.", path)
cls = None
for strategy in self._strategies:
if strategy.can_route(path)... | python | def route(self, path):
# type: (str)->Tuple[Any, Callable]
"""
Returns the task handling the given request path.
"""
logging.getLogger(__name__).debug("Routing path '%s'.", path)
cls = None
for strategy in self._strategies:
if strategy.can_route(path)... | [
"def",
"route",
"(",
"self",
",",
"path",
")",
":",
"# type: (str)->Tuple[Any, Callable]",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"\"Routing path '%s'.\"",
",",
"path",
")",
"cls",
"=",
"None",
"for",
"strategy",
"in",
"self",
... | Returns the task handling the given request path. | [
"Returns",
"the",
"task",
"handling",
"the",
"given",
"request",
"path",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/router/task.py#L220-L236 |
AtteqCom/zsl | src/zsl/router/task.py | TaskRouter._create_result | def _create_result(self, cls):
# type:(Callable)->Tuple[Any, Callable]
"""
Create the task using the injector initialization.
:param cls:
:return:
"""
task = instantiate(cls)
logging.getLogger(__name__).debug("Task object {0} created [{1}].".format(cls.__n... | python | def _create_result(self, cls):
# type:(Callable)->Tuple[Any, Callable]
"""
Create the task using the injector initialization.
:param cls:
:return:
"""
task = instantiate(cls)
logging.getLogger(__name__).debug("Task object {0} created [{1}].".format(cls.__n... | [
"def",
"_create_result",
"(",
"self",
",",
"cls",
")",
":",
"# type:(Callable)->Tuple[Any, Callable]",
"task",
"=",
"instantiate",
"(",
"cls",
")",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"\"Task object {0} created [{1}].\"",
".",
"fo... | Create the task using the injector initialization.
:param cls:
:return: | [
"Create",
"the",
"task",
"using",
"the",
"injector",
"initialization",
".",
":",
"param",
"cls",
":",
":",
"return",
":"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/router/task.py#L238-L247 |
briney/abutils | abutils/utils/convert.py | abi_to_fasta | def abi_to_fasta(input, output):
'''
Converts ABI or AB1 files to FASTA format.
Args:
input (str): Path to a file or directory containing abi/ab1 files or
zip archives of abi/ab1 files
output (str): Path to a directory for the output FASTA files
'''
direcs = [input, ]... | python | def abi_to_fasta(input, output):
'''
Converts ABI or AB1 files to FASTA format.
Args:
input (str): Path to a file or directory containing abi/ab1 files or
zip archives of abi/ab1 files
output (str): Path to a directory for the output FASTA files
'''
direcs = [input, ]... | [
"def",
"abi_to_fasta",
"(",
"input",
",",
"output",
")",
":",
"direcs",
"=",
"[",
"input",
",",
"]",
"# unzip any zip archives",
"zip_files",
"=",
"list_files",
"(",
"input",
",",
"[",
"'zip'",
"]",
")",
"if",
"zip_files",
":",
"direcs",
".",
"extend",
"... | Converts ABI or AB1 files to FASTA format.
Args:
input (str): Path to a file or directory containing abi/ab1 files or
zip archives of abi/ab1 files
output (str): Path to a directory for the output FASTA files | [
"Converts",
"ABI",
"or",
"AB1",
"files",
"to",
"FASTA",
"format",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/convert.py#L37-L61 |
AtteqCom/zsl | src/zsl/utils/reflection_helper.py | extend | def extend(instance, new_class):
"""Adds new_class to the ancestors of instance.
:param instance: Instance that will have a new ancestor.
:param new_class: Ancestor.
"""
instance.__class__ = type(
'%s_extended_with_%s' % (instance.__class__.__name__, new_class.__name__),
(new_class,... | python | def extend(instance, new_class):
"""Adds new_class to the ancestors of instance.
:param instance: Instance that will have a new ancestor.
:param new_class: Ancestor.
"""
instance.__class__ = type(
'%s_extended_with_%s' % (instance.__class__.__name__, new_class.__name__),
(new_class,... | [
"def",
"extend",
"(",
"instance",
",",
"new_class",
")",
":",
"instance",
".",
"__class__",
"=",
"type",
"(",
"'%s_extended_with_%s'",
"%",
"(",
"instance",
".",
"__class__",
".",
"__name__",
",",
"new_class",
".",
"__name__",
")",
",",
"(",
"new_class",
"... | Adds new_class to the ancestors of instance.
:param instance: Instance that will have a new ancestor.
:param new_class: Ancestor. | [
"Adds",
"new_class",
"to",
"the",
"ancestors",
"of",
"instance",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/reflection_helper.py#L15-L25 |
AtteqCom/zsl | src/zsl/utils/deploy/js_model_generator.py | generate_js_models | def generate_js_models(module, models, collection_prefix, model_prefix,
model_fn, collection_fn, marker, integrate, js_file):
# type: (str, str, str, str, str, str, str, bool, str) -> Union[str, None]
"""Generate models for Backbone Javascript applications.
:param module: module from... | python | def generate_js_models(module, models, collection_prefix, model_prefix,
model_fn, collection_fn, marker, integrate, js_file):
# type: (str, str, str, str, str, str, str, bool, str) -> Union[str, None]
"""Generate models for Backbone Javascript applications.
:param module: module from... | [
"def",
"generate_js_models",
"(",
"module",
",",
"models",
",",
"collection_prefix",
",",
"model_prefix",
",",
"model_fn",
",",
"collection_fn",
",",
"marker",
",",
"integrate",
",",
"js_file",
")",
":",
"# type: (str, str, str, str, str, str, str, bool, str) -> Union[str... | Generate models for Backbone Javascript applications.
:param module: module from which models are imported
:param models: model name, can be a tuple WineCountry/WineCountries as singular/plural
:param model_prefix: namespace prefix for models (app.models.)
:param collection_prefix: namespace prefix for... | [
"Generate",
"models",
"for",
"Backbone",
"Javascript",
"applications",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/deploy/js_model_generator.py#L166-L207 |
AtteqCom/zsl | src/zsl/utils/deploy/js_model_generator.py | ModelGenerator._map_table_name | def _map_table_name(self, model_names):
"""
Pre foregin_keys potrbejeme pre z nazvu tabulky zistit class,
tak si to namapujme
"""
for model in model_names:
if isinstance(model, tuple):
model = model[0]
try:
model_cls = get... | python | def _map_table_name(self, model_names):
"""
Pre foregin_keys potrbejeme pre z nazvu tabulky zistit class,
tak si to namapujme
"""
for model in model_names:
if isinstance(model, tuple):
model = model[0]
try:
model_cls = get... | [
"def",
"_map_table_name",
"(",
"self",
",",
"model_names",
")",
":",
"for",
"model",
"in",
"model_names",
":",
"if",
"isinstance",
"(",
"model",
",",
"tuple",
")",
":",
"model",
"=",
"model",
"[",
"0",
"]",
"try",
":",
"model_cls",
"=",
"getattr",
"(",... | Pre foregin_keys potrbejeme pre z nazvu tabulky zistit class,
tak si to namapujme | [
"Pre",
"foregin_keys",
"potrbejeme",
"pre",
"z",
"nazvu",
"tabulky",
"zistit",
"class",
"tak",
"si",
"to",
"namapujme"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/deploy/js_model_generator.py#L56-L70 |
AtteqCom/zsl | src/zsl/utils/nginx_push_helper.py | NginxPusher.push_msg | def push_msg(self, channel_id, msg):
"""Push ``msg`` for given ``channel_id``. If ``msg`` is not string, it
will be urlencoded
"""
if type(msg) is not str:
msg = urlencode(msg)
return self.push(channel_id, msg) | python | def push_msg(self, channel_id, msg):
"""Push ``msg`` for given ``channel_id``. If ``msg`` is not string, it
will be urlencoded
"""
if type(msg) is not str:
msg = urlencode(msg)
return self.push(channel_id, msg) | [
"def",
"push_msg",
"(",
"self",
",",
"channel_id",
",",
"msg",
")",
":",
"if",
"type",
"(",
"msg",
")",
"is",
"not",
"str",
":",
"msg",
"=",
"urlencode",
"(",
"msg",
")",
"return",
"self",
".",
"push",
"(",
"channel_id",
",",
"msg",
")"
] | Push ``msg`` for given ``channel_id``. If ``msg`` is not string, it
will be urlencoded | [
"Push",
"msg",
"for",
"given",
"channel_id",
".",
"If",
"msg",
"is",
"not",
"string",
"it",
"will",
"be",
"urlencoded"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/nginx_push_helper.py#L26-L34 |
AtteqCom/zsl | src/zsl/utils/nginx_push_helper.py | NginxPusher.push_object | def push_object(self, channel_id, obj):
"""Push ``obj`` for ``channel_id``. ``obj`` will be encoded as JSON in
the request.
"""
return self.push(channel_id, json.dumps(obj).replace('"', '\\"')) | python | def push_object(self, channel_id, obj):
"""Push ``obj`` for ``channel_id``. ``obj`` will be encoded as JSON in
the request.
"""
return self.push(channel_id, json.dumps(obj).replace('"', '\\"')) | [
"def",
"push_object",
"(",
"self",
",",
"channel_id",
",",
"obj",
")",
":",
"return",
"self",
".",
"push",
"(",
"channel_id",
",",
"json",
".",
"dumps",
"(",
"obj",
")",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")",
")"
] | Push ``obj`` for ``channel_id``. ``obj`` will be encoded as JSON in
the request. | [
"Push",
"obj",
"for",
"channel_id",
".",
"obj",
"will",
"be",
"encoded",
"as",
"JSON",
"in",
"the",
"request",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/nginx_push_helper.py#L36-L41 |
AtteqCom/zsl | src/zsl/utils/nginx_push_helper.py | NginxPusher.push | def push(self, channel_id, data):
"""Push message with POST ``data`` for ``channel_id``
"""
channel_path = self.channel_path(channel_id)
response = requests.post(channel_path, data)
return response.json() | python | def push(self, channel_id, data):
"""Push message with POST ``data`` for ``channel_id``
"""
channel_path = self.channel_path(channel_id)
response = requests.post(channel_path, data)
return response.json() | [
"def",
"push",
"(",
"self",
",",
"channel_id",
",",
"data",
")",
":",
"channel_path",
"=",
"self",
".",
"channel_path",
"(",
"channel_id",
")",
"response",
"=",
"requests",
".",
"post",
"(",
"channel_path",
",",
"data",
")",
"return",
"response",
".",
"j... | Push message with POST ``data`` for ``channel_id`` | [
"Push",
"message",
"with",
"POST",
"data",
"for",
"channel_id"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/nginx_push_helper.py#L43-L50 |
AtteqCom/zsl | src/zsl/utils/nginx_push_helper.py | NginxPusher.delete_channel | def delete_channel(self, channel_id):
"""Deletes channel
"""
req = requests.delete(self.channel_path(channel_id))
return req | python | def delete_channel(self, channel_id):
"""Deletes channel
"""
req = requests.delete(self.channel_path(channel_id))
return req | [
"def",
"delete_channel",
"(",
"self",
",",
"channel_id",
")",
":",
"req",
"=",
"requests",
".",
"delete",
"(",
"self",
".",
"channel_path",
"(",
"channel_id",
")",
")",
"return",
"req"
] | Deletes channel | [
"Deletes",
"channel"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/nginx_push_helper.py#L52-L56 |
AtteqCom/zsl | src/zsl/utils/url_helper.py | slugify | def slugify(value, allow_unicode=False):
"""Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
:param value: string
:param allow_unicode: allow utf8 characters
:type allow_unicode: bool
:return: slugified string
:rtype: str
:Example:... | python | def slugify(value, allow_unicode=False):
"""Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
:param value: string
:param allow_unicode: allow utf8 characters
:type allow_unicode: bool
:return: slugified string
:rtype: str
:Example:... | [
"def",
"slugify",
"(",
"value",
",",
"allow_unicode",
"=",
"False",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"if",
"allow_unicode",
":",
"value",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKC'",
",",
"value",
")",
"value",
"=",
"re",
".",
... | Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
:param value: string
:param allow_unicode: allow utf8 characters
:type allow_unicode: bool
:return: slugified string
:rtype: str
:Example:
>>> slugify('pekná líščička')
'... | [
"Normalizes",
"string",
"converts",
"to",
"lowercase",
"removes",
"non",
"-",
"alpha",
"characters",
"and",
"converts",
"spaces",
"to",
"hyphens",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/url_helper.py#L16-L39 |
AtteqCom/zsl | src/zsl/utils/url_helper.py | urlencode | def urlencode(query):
"""Encode string to be used in urls (percent encoding).
:param query: string to be encoded
:type query: str
:return: urlencoded string
:rtype: str
:Example:
>>> urlencode('pekná líščička')
'pekn%C3%A1%20l%C3%AD%C5%A1%C4%8Di%C4%8Dka'
"""
if hasattr(... | python | def urlencode(query):
"""Encode string to be used in urls (percent encoding).
:param query: string to be encoded
:type query: str
:return: urlencoded string
:rtype: str
:Example:
>>> urlencode('pekná líščička')
'pekn%C3%A1%20l%C3%AD%C5%A1%C4%8Di%C4%8Dka'
"""
if hasattr(... | [
"def",
"urlencode",
"(",
"query",
")",
":",
"if",
"hasattr",
"(",
"urllib",
",",
"'parse'",
")",
":",
"return",
"urllib",
".",
"parse",
".",
"urlencode",
"(",
"query",
")",
"else",
":",
"return",
"urllib",
".",
"urlencode",
"(",
"query",
")"
] | Encode string to be used in urls (percent encoding).
:param query: string to be encoded
:type query: str
:return: urlencoded string
:rtype: str
:Example:
>>> urlencode('pekná líščička')
'pekn%C3%A1%20l%C3%AD%C5%A1%C4%8Di%C4%8Dka' | [
"Encode",
"string",
"to",
"be",
"used",
"in",
"urls",
"(",
"percent",
"encoding",
")",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/url_helper.py#L42-L57 |
AtteqCom/zsl | src/zsl/application/modules/web/web_context_module.py | WebInitializer.initialize | def initialize():
"""
Import in this form is necessary so that we avoid the unwanted behavior and immediate initialization of the
application objects. This makes the initialization procedure run in the time when it is necessary and has every
required resources.
"""
from z... | python | def initialize():
"""
Import in this form is necessary so that we avoid the unwanted behavior and immediate initialization of the
application objects. This makes the initialization procedure run in the time when it is necessary and has every
required resources.
"""
from z... | [
"def",
"initialize",
"(",
")",
":",
"from",
"zsl",
".",
"interface",
".",
"web",
".",
"performers",
".",
"default",
"import",
"create_not_found_mapping",
"from",
"zsl",
".",
"interface",
".",
"web",
".",
"performers",
".",
"resource",
"import",
"create_resourc... | Import in this form is necessary so that we avoid the unwanted behavior and immediate initialization of the
application objects. This makes the initialization procedure run in the time when it is necessary and has every
required resources. | [
"Import",
"in",
"this",
"form",
"is",
"necessary",
"so",
"that",
"we",
"avoid",
"the",
"unwanted",
"behavior",
"and",
"immediate",
"initialization",
"of",
"the",
"application",
"objects",
".",
"This",
"makes",
"the",
"initialization",
"procedure",
"run",
"in",
... | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/modules/web/web_context_module.py#L23-L33 |
AtteqCom/zsl | src/zsl/application/modules/web/web_context_module.py | WebHandler.run_web | def run_web(self, flask, host='127.0.0.1', port=5000, **options):
# type: (Zsl, str, int, **Any)->None
"""Alias for Flask.run"""
return flask.run(
host=flask.config.get('FLASK_HOST', host),
port=flask.config.get('FLASK_PORT', port),
debug=flask.config.get('DEB... | python | def run_web(self, flask, host='127.0.0.1', port=5000, **options):
# type: (Zsl, str, int, **Any)->None
"""Alias for Flask.run"""
return flask.run(
host=flask.config.get('FLASK_HOST', host),
port=flask.config.get('FLASK_PORT', port),
debug=flask.config.get('DEB... | [
"def",
"run_web",
"(",
"self",
",",
"flask",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"5000",
",",
"*",
"*",
"options",
")",
":",
"# type: (Zsl, str, int, **Any)->None",
"return",
"flask",
".",
"run",
"(",
"host",
"=",
"flask",
".",
"config",
"... | Alias for Flask.run | [
"Alias",
"for",
"Flask",
".",
"run"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/modules/web/web_context_module.py#L66-L74 |
AtteqCom/zsl | src/zsl/utils/command_dispatcher.py | CommandDispatcher.execute_command | def execute_command(self, command, args=None):
"""
Execute a command
:param command: name of the command
:type command: str
:param args: optional named arguments for command
:type args: dict
:return: the result of command
:raises KeyError: if command is n... | python | def execute_command(self, command, args=None):
"""
Execute a command
:param command: name of the command
:type command: str
:param args: optional named arguments for command
:type args: dict
:return: the result of command
:raises KeyError: if command is n... | [
"def",
"execute_command",
"(",
"self",
",",
"command",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"{",
"}",
"command_fn",
"=",
"self",
".",
"commands",
"[",
"command",
"]",
"return",
"command_fn",
"(",
"*",
"*",... | Execute a command
:param command: name of the command
:type command: str
:param args: optional named arguments for command
:type args: dict
:return: the result of command
:raises KeyError: if command is not found | [
"Execute",
"a",
"command"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/command_dispatcher.py#L43-L60 |
AtteqCom/zsl | src/zsl/utils/command_dispatcher.py | CommandDispatcher.bound | def bound(self, instance):
"""
Return a new dispatcher, which will switch all command functions
with bounded methods of given instance matched by name. It will
match only regular methods.
:param instance: object instance
:type instance: object
:return: new Dispat... | python | def bound(self, instance):
"""
Return a new dispatcher, which will switch all command functions
with bounded methods of given instance matched by name. It will
match only regular methods.
:param instance: object instance
:type instance: object
:return: new Dispat... | [
"def",
"bound",
"(",
"self",
",",
"instance",
")",
":",
"bounded_dispatcher",
"=",
"CommandDispatcher",
"(",
")",
"bounded_dispatcher",
".",
"commands",
"=",
"self",
".",
"commands",
".",
"copy",
"(",
")",
"for",
"name",
"in",
"self",
".",
"commands",
":",... | Return a new dispatcher, which will switch all command functions
with bounded methods of given instance matched by name. It will
match only regular methods.
:param instance: object instance
:type instance: object
:return: new Dispatcher
:rtype: CommandDispatcher | [
"Return",
"a",
"new",
"dispatcher",
"which",
"will",
"switch",
"all",
"command",
"functions",
"with",
"bounded",
"methods",
"of",
"given",
"instance",
"matched",
"by",
"name",
".",
"It",
"will",
"match",
"only",
"regular",
"methods",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/command_dispatcher.py#L62-L83 |
briney/abutils | abutils/utils/s3.py | compress_and_upload | def compress_and_upload(data, compressed_file, s3_path, multipart_chunk_size_mb=500,
method='gz', delete=False, access_key=None, secret_key=None):
'''
Compresses data and uploads to S3.
S3 upload uses ``s3cmd``, so you must either:
1) Manually configure ``s3cmd`` prior to use (typically using ... | python | def compress_and_upload(data, compressed_file, s3_path, multipart_chunk_size_mb=500,
method='gz', delete=False, access_key=None, secret_key=None):
'''
Compresses data and uploads to S3.
S3 upload uses ``s3cmd``, so you must either:
1) Manually configure ``s3cmd`` prior to use (typically using ... | [
"def",
"compress_and_upload",
"(",
"data",
",",
"compressed_file",
",",
"s3_path",
",",
"multipart_chunk_size_mb",
"=",
"500",
",",
"method",
"=",
"'gz'",
",",
"delete",
"=",
"False",
",",
"access_key",
"=",
"None",
",",
"secret_key",
"=",
"None",
")",
":",
... | Compresses data and uploads to S3.
S3 upload uses ``s3cmd``, so you must either:
1) Manually configure ``s3cmd`` prior to use (typically using ``s3cmd --configure``).
2) Configure ``s3cmd`` using ``s3.configure()``.
3) Pass your access key and secret key to ``compress_and_upload``, which... | [
"Compresses",
"data",
"and",
"uploads",
"to",
"S3",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/s3.py#L37-L93 |
briney/abutils | abutils/utils/s3.py | put | def put(f, s3_path, multipart_chunk_size_mb=500, logger=None):
'''
Uploads a single file to S3, using s3cmd.
Args:
f (str): Path to a single file.
s3_path (str): The S3 path, with the filename omitted. The S3 filename
will be the basename of the ``f``. For example::
... | python | def put(f, s3_path, multipart_chunk_size_mb=500, logger=None):
'''
Uploads a single file to S3, using s3cmd.
Args:
f (str): Path to a single file.
s3_path (str): The S3 path, with the filename omitted. The S3 filename
will be the basename of the ``f``. For example::
... | [
"def",
"put",
"(",
"f",
",",
"s3_path",
",",
"multipart_chunk_size_mb",
"=",
"500",
",",
"logger",
"=",
"None",
")",
":",
"if",
"not",
"logger",
":",
"logger",
"=",
"log",
".",
"get_logger",
"(",
"'s3'",
")",
"fname",
"=",
"os",
".",
"path",
".",
"... | Uploads a single file to S3, using s3cmd.
Args:
f (str): Path to a single file.
s3_path (str): The S3 path, with the filename omitted. The S3 filename
will be the basename of the ``f``. For example::
put(f='/path/to/myfile.tar.gz', s3_path='s3://my_bucket/path/to/')
... | [
"Uploads",
"a",
"single",
"file",
"to",
"S3",
"using",
"s3cmd",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/s3.py#L96-L123 |
briney/abutils | abutils/utils/s3.py | compress | def compress(d, output, fmt='gz', logger=None):
'''
Creates a compressed/uncompressed tar file.
Args:
d: Can be one of three things:
1. the path to a single file, as a string
2. the path to a single directory, as a string
3. an iterable of file or directory p... | python | def compress(d, output, fmt='gz', logger=None):
'''
Creates a compressed/uncompressed tar file.
Args:
d: Can be one of three things:
1. the path to a single file, as a string
2. the path to a single directory, as a string
3. an iterable of file or directory p... | [
"def",
"compress",
"(",
"d",
",",
"output",
",",
"fmt",
"=",
"'gz'",
",",
"logger",
"=",
"None",
")",
":",
"if",
"not",
"logger",
":",
"logger",
"=",
"log",
".",
"get_logger",
"(",
"'s3'",
")",
"if",
"type",
"(",
"d",
")",
"not",
"in",
"[",
"li... | Creates a compressed/uncompressed tar file.
Args:
d: Can be one of three things:
1. the path to a single file, as a string
2. the path to a single directory, as a string
3. an iterable of file or directory paths
output (str): Output file path.
fmt: ... | [
"Creates",
"a",
"compressed",
"/",
"uncompressed",
"tar",
"file",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/s3.py#L139-L174 |
briney/abutils | abutils/utils/s3.py | configure | def configure(access_key=None, secret_key=None, logger=None):
'''
Configures s3cmd prior to first use.
If no arguments are provided, you will be prompted to enter
the access key and secret key interactively.
Args:
access_key (str): AWS access key
secret_key (str): AWS secret key
... | python | def configure(access_key=None, secret_key=None, logger=None):
'''
Configures s3cmd prior to first use.
If no arguments are provided, you will be prompted to enter
the access key and secret key interactively.
Args:
access_key (str): AWS access key
secret_key (str): AWS secret key
... | [
"def",
"configure",
"(",
"access_key",
"=",
"None",
",",
"secret_key",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"if",
"not",
"logger",
":",
"logger",
"=",
"log",
".",
"get_logger",
"(",
"'s3'",
")",
"if",
"not",
"all",
"(",
"[",
"access_key... | Configures s3cmd prior to first use.
If no arguments are provided, you will be prompted to enter
the access key and secret key interactively.
Args:
access_key (str): AWS access key
secret_key (str): AWS secret key | [
"Configures",
"s3cmd",
"prior",
"to",
"first",
"use",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/s3.py#L201-L223 |
AtteqCom/zsl | src/zsl/utils/params_helper.py | required_params | def required_params(data, *r_params):
"""Check if given parameters are in the given dict, if not raise an
exception.
:param data: data to check
:type data: dict
:param r_params: required parameters
:raises RequestException: if params not in data
"""
if not reduce(lambda still_valid, pa... | python | def required_params(data, *r_params):
"""Check if given parameters are in the given dict, if not raise an
exception.
:param data: data to check
:type data: dict
:param r_params: required parameters
:raises RequestException: if params not in data
"""
if not reduce(lambda still_valid, pa... | [
"def",
"required_params",
"(",
"data",
",",
"*",
"r_params",
")",
":",
"if",
"not",
"reduce",
"(",
"lambda",
"still_valid",
",",
"param",
":",
"still_valid",
"and",
"param",
"in",
"data",
",",
"r_params",
",",
"True",
")",
":",
"raise",
"RequestException",... | Check if given parameters are in the given dict, if not raise an
exception.
:param data: data to check
:type data: dict
:param r_params: required parameters
:raises RequestException: if params not in data | [
"Check",
"if",
"given",
"parameters",
"are",
"in",
"the",
"given",
"dict",
"if",
"not",
"raise",
"an",
"exception",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/params_helper.py#L22-L34 |
AtteqCom/zsl | src/zsl/utils/params_helper.py | safe_args | def safe_args(fn, args):
"""Check if ``args`` as a dictionary has the required parameters of ``fn``
function and filter any waste parameters so ``fn`` can be safely called
with them.
:param fn: function object
:type fn: Callable
:param args: dictionary of parameters
:type args: dict
:re... | python | def safe_args(fn, args):
"""Check if ``args`` as a dictionary has the required parameters of ``fn``
function and filter any waste parameters so ``fn`` can be safely called
with them.
:param fn: function object
:type fn: Callable
:param args: dictionary of parameters
:type args: dict
:re... | [
"def",
"safe_args",
"(",
"fn",
",",
"args",
")",
":",
"fn_args",
"=",
"inspect",
".",
"getargspec",
"(",
"fn",
")",
"if",
"fn_args",
".",
"defaults",
":",
"required_params",
"(",
"args",
",",
"fn_args",
".",
"args",
"[",
":",
"-",
"len",
"(",
"fn_arg... | Check if ``args`` as a dictionary has the required parameters of ``fn``
function and filter any waste parameters so ``fn`` can be safely called
with them.
:param fn: function object
:type fn: Callable
:param args: dictionary of parameters
:type args: dict
:return: dictionary to be used as n... | [
"Check",
"if",
"args",
"as",
"a",
"dictionary",
"has",
"the",
"required",
"parameters",
"of",
"fn",
"function",
"and",
"filter",
"any",
"waste",
"parameters",
"so",
"fn",
"can",
"be",
"safely",
"called",
"with",
"them",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/params_helper.py#L41-L63 |
briney/abutils | abutils/utils/mongodb.py | get_db | def get_db(db, ip='localhost', port=27017, user=None, password=None):
'''
Returns a pymongo Database object.
.. note:
Both ``user`` and ``password`` are required when connecting to a MongoDB
database that has authentication enabled.
Arguments:
db (str): Name of the MongoDB da... | python | def get_db(db, ip='localhost', port=27017, user=None, password=None):
'''
Returns a pymongo Database object.
.. note:
Both ``user`` and ``password`` are required when connecting to a MongoDB
database that has authentication enabled.
Arguments:
db (str): Name of the MongoDB da... | [
"def",
"get_db",
"(",
"db",
",",
"ip",
"=",
"'localhost'",
",",
"port",
"=",
"27017",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
".",
"lower",
"(",
")",
"==",
"'darwin'",
":",
"con... | Returns a pymongo Database object.
.. note:
Both ``user`` and ``password`` are required when connecting to a MongoDB
database that has authentication enabled.
Arguments:
db (str): Name of the MongoDB database. Required.
ip (str): IP address of the MongoDB server. Default is ... | [
"Returns",
"a",
"pymongo",
"Database",
"object",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/mongodb.py#L79-L115 |
briney/abutils | abutils/utils/mongodb.py | get_collections | def get_collections(db, collection=None, prefix=None, suffix=None):
'''
Returns a sorted list of collection names found in ``db``.
Arguments:
db (Database): A pymongo Database object. Can be obtained
with ``get_db``.
collection (str): Name of a collection. If the collection is... | python | def get_collections(db, collection=None, prefix=None, suffix=None):
'''
Returns a sorted list of collection names found in ``db``.
Arguments:
db (Database): A pymongo Database object. Can be obtained
with ``get_db``.
collection (str): Name of a collection. If the collection is... | [
"def",
"get_collections",
"(",
"db",
",",
"collection",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"suffix",
"=",
"None",
")",
":",
"if",
"collection",
"is",
"not",
"None",
":",
"return",
"[",
"collection",
",",
"]",
"collections",
"=",
"db",
".",
... | Returns a sorted list of collection names found in ``db``.
Arguments:
db (Database): A pymongo Database object. Can be obtained
with ``get_db``.
collection (str): Name of a collection. If the collection is
present in the MongoDB database, a single-element list will
... | [
"Returns",
"a",
"sorted",
"list",
"of",
"collection",
"names",
"found",
"in",
"db",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/mongodb.py#L118-L151 |
briney/abutils | abutils/utils/mongodb.py | rename_collection | def rename_collection(db, collection, new_name):
'''
Renames a MongoDB collection.
Arguments:
db (Database): A pymongo Database object. Can be obtained
with ``get_db``.
collection (str): Name of the collection to be renamed.
new_name (str, func): ``new_name`` can be o... | python | def rename_collection(db, collection, new_name):
'''
Renames a MongoDB collection.
Arguments:
db (Database): A pymongo Database object. Can be obtained
with ``get_db``.
collection (str): Name of the collection to be renamed.
new_name (str, func): ``new_name`` can be o... | [
"def",
"rename_collection",
"(",
"db",
",",
"collection",
",",
"new_name",
")",
":",
"if",
"hasattr",
"(",
"new_name",
",",
"'__call__'",
")",
":",
"_new",
"=",
"new_name",
"(",
"collection",
")",
"if",
"_new",
"==",
"''",
":",
"return",
"else",
":",
"... | Renames a MongoDB collection.
Arguments:
db (Database): A pymongo Database object. Can be obtained
with ``get_db``.
collection (str): Name of the collection to be renamed.
new_name (str, func): ``new_name`` can be one of two things::
1. The new collection name, a... | [
"Renames",
"a",
"MongoDB",
"collection",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/mongodb.py#L154-L180 |
briney/abutils | abutils/utils/mongodb.py | update | def update(field, value, db, collection, match=None):
'''
Updates MongoDB documents.
Sets ``field`` equal to ``value`` for all documents that
meet ``match`` criteria.
Arguments:
field (str): Field to update.
value (str): Update value.
db (Database): A pymongo Database ob... | python | def update(field, value, db, collection, match=None):
'''
Updates MongoDB documents.
Sets ``field`` equal to ``value`` for all documents that
meet ``match`` criteria.
Arguments:
field (str): Field to update.
value (str): Update value.
db (Database): A pymongo Database ob... | [
"def",
"update",
"(",
"field",
",",
"value",
",",
"db",
",",
"collection",
",",
"match",
"=",
"None",
")",
":",
"c",
"=",
"db",
"[",
"collection",
"]",
"match",
"=",
"match",
"if",
"match",
"is",
"not",
"None",
"else",
"{",
"}",
"# check MongoDB vers... | Updates MongoDB documents.
Sets ``field`` equal to ``value`` for all documents that
meet ``match`` criteria.
Arguments:
field (str): Field to update.
value (str): Update value.
db (Database): A pymongo Database object.
collection (str): Collection name.
match (... | [
"Updates",
"MongoDB",
"documents",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/mongodb.py#L183-L210 |
briney/abutils | abutils/utils/mongodb.py | mongoimport | def mongoimport(json, database,
ip='localhost', port=27017,
user=None, password=None,
delim='_', delim1=None, delim2=None,
delim_occurance=1, delim1_occurance=1, delim2_occurance=1):
'''
Performs mongoimport on one or more json files.
Args:
... | python | def mongoimport(json, database,
ip='localhost', port=27017,
user=None, password=None,
delim='_', delim1=None, delim2=None,
delim_occurance=1, delim1_occurance=1, delim2_occurance=1):
'''
Performs mongoimport on one or more json files.
Args:
... | [
"def",
"mongoimport",
"(",
"json",
",",
"database",
",",
"ip",
"=",
"'localhost'",
",",
"port",
"=",
"27017",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"delim",
"=",
"'_'",
",",
"delim1",
"=",
"None",
",",
"delim2",
"=",
"None",
... | Performs mongoimport on one or more json files.
Args:
json: Can be one of several things:
- path to a single JSON file
- an iterable (list or tuple) of one or more JSON file paths
- path to a directory containing one or more JSON files
database (str): Name of ... | [
"Performs",
"mongoimport",
"on",
"one",
"or",
"more",
"json",
"files",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/mongodb.py#L239-L312 |
briney/abutils | abutils/utils/mongodb.py | index | def index(db, collection, fields, directions=None, desc=False, background=False):
'''
Builds a simple (single field) or complex (multiple fields) index
on a single collection in a MongoDB database.
Args:
db (Database): A pymongo Database object.
collection (str): Collection name.
... | python | def index(db, collection, fields, directions=None, desc=False, background=False):
'''
Builds a simple (single field) or complex (multiple fields) index
on a single collection in a MongoDB database.
Args:
db (Database): A pymongo Database object.
collection (str): Collection name.
... | [
"def",
"index",
"(",
"db",
",",
"collection",
",",
"fields",
",",
"directions",
"=",
"None",
",",
"desc",
"=",
"False",
",",
"background",
"=",
"False",
")",
":",
"import",
"pymongo",
"if",
"type",
"(",
"fields",
")",
"in",
"STR_TYPES",
":",
"fields",
... | Builds a simple (single field) or complex (multiple fields) index
on a single collection in a MongoDB database.
Args:
db (Database): A pymongo Database object.
collection (str): Collection name.
fields: Can be one of two things:
- the name of a single field, as a string
... | [
"Builds",
"a",
"simple",
"(",
"single",
"field",
")",
"or",
"complex",
"(",
"multiple",
"fields",
")",
"index",
"on",
"a",
"single",
"collection",
"in",
"a",
"MongoDB",
"database",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/mongodb.py#L315-L353 |
AtteqCom/zsl | src/zsl/application/service_application.py | get_settings_from_profile | def get_settings_from_profile(profile, profile_dir=None):
# type: (str, Any)->str
""""Returns the configuration file path for the given profile.
:param profile: Profile name to be used.
:param profile_dir: The directory where the profile configuration file should reside. It
may... | python | def get_settings_from_profile(profile, profile_dir=None):
# type: (str, Any)->str
""""Returns the configuration file path for the given profile.
:param profile: Profile name to be used.
:param profile_dir: The directory where the profile configuration file should reside. It
may... | [
"def",
"get_settings_from_profile",
"(",
"profile",
",",
"profile_dir",
"=",
"None",
")",
":",
"# type: (str, Any)->str",
"if",
"profile_dir",
"is",
"None",
":",
"import",
"settings",
"profile_dir",
"=",
"settings",
"if",
"hasattr",
"(",
"profile_dir",
",",
"'__fi... | Returns the configuration file path for the given profile.
:param profile: Profile name to be used.
:param profile_dir: The directory where the profile configuration file should reside. It
may be also a module, and then the directory of the module is used.
:return: Configuration fi... | [
"Returns",
"the",
"configuration",
"file",
"path",
"for",
"the",
"given",
"profile",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/service_application.py#L39-L55 |
AtteqCom/zsl | src/zsl/application/service_application.py | ServiceApplication._configure | def _configure(self, config_object=None):
# type: (Any) -> None
"""Read the configuration from config files.
Loads the default settings and the profile settings if available.
Check :func:`.set_profile`.
:param config_object:
This parameter is the configuration decscr... | python | def _configure(self, config_object=None):
# type: (Any) -> None
"""Read the configuration from config files.
Loads the default settings and the profile settings if available.
Check :func:`.set_profile`.
:param config_object:
This parameter is the configuration decscr... | [
"def",
"_configure",
"(",
"self",
",",
"config_object",
"=",
"None",
")",
":",
"# type: (Any) -> None",
"if",
"config_object",
":",
"self",
".",
"config",
".",
"from_mapping",
"(",
"config_object",
")",
"else",
":",
"self",
".",
"config",
".",
"from_object",
... | Read the configuration from config files.
Loads the default settings and the profile settings if available.
Check :func:`.set_profile`.
:param config_object:
This parameter is the configuration decscription may be a dict or
string describing the module from which the con... | [
"Read",
"the",
"configuration",
"from",
"config",
"files",
".",
"Loads",
"the",
"default",
"settings",
"and",
"the",
"profile",
"settings",
"if",
"available",
".",
"Check",
":",
"func",
":",
".",
"set_profile",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/service_application.py#L100-L119 |
AtteqCom/zsl | src/zsl/application/service_application.py | ServiceApplication._get_app_module | def _get_app_module(self):
# type: () -> Callable
"""Returns a module which binds the current app and configuration.
:return: configuration callback
:rtype: Callable
"""
def configure(binder):
# type: (Binder) -> Callable
binder.bind(ServiceAppli... | python | def _get_app_module(self):
# type: () -> Callable
"""Returns a module which binds the current app and configuration.
:return: configuration callback
:rtype: Callable
"""
def configure(binder):
# type: (Binder) -> Callable
binder.bind(ServiceAppli... | [
"def",
"_get_app_module",
"(",
"self",
")",
":",
"# type: () -> Callable",
"def",
"configure",
"(",
"binder",
")",
":",
"# type: (Binder) -> Callable",
"binder",
".",
"bind",
"(",
"ServiceApplication",
",",
"to",
"=",
"self",
",",
"scope",
"=",
"singleton",
")",... | Returns a module which binds the current app and configuration.
:return: configuration callback
:rtype: Callable | [
"Returns",
"a",
"module",
"which",
"binds",
"the",
"current",
"app",
"and",
"configuration",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/service_application.py#L130-L143 |
AtteqCom/zsl | src/zsl/application/service_application.py | ServiceApplication._configure_injector | def _configure_injector(self, modules):
"""Create the injector and install the modules.
There is a necessary order of calls. First we have to bind `Config` and
`Zsl`, then we need to register the app into the global stack and then
we can install all other modules, which can use `Zsl` an... | python | def _configure_injector(self, modules):
"""Create the injector and install the modules.
There is a necessary order of calls. First we have to bind `Config` and
`Zsl`, then we need to register the app into the global stack and then
we can install all other modules, which can use `Zsl` an... | [
"def",
"_configure_injector",
"(",
"self",
",",
"modules",
")",
":",
"self",
".",
"_register",
"(",
")",
"self",
".",
"_create_injector",
"(",
")",
"self",
".",
"_bind_core",
"(",
")",
"self",
".",
"_bind_modules",
"(",
"modules",
")",
"self",
".",
"logg... | Create the injector and install the modules.
There is a necessary order of calls. First we have to bind `Config` and
`Zsl`, then we need to register the app into the global stack and then
we can install all other modules, which can use `Zsl` and `Config`
injection.
:param modul... | [
"Create",
"the",
"injector",
"and",
"install",
"the",
"modules",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/service_application.py#L145-L161 |
AtteqCom/zsl | src/zsl/application/modules/cache_module.py | RedisCacheInjectionModule.configure | def configure(self, binder):
# type: (Binder) -> None
"""Initializer of the cache - creates the Redis cache module as the
default cache infrastructure. The module is bound to `RedisCacheModule`
and `CacheModule` keys. The initializer also creates `RedisIdHelper`
and bounds it to ... | python | def configure(self, binder):
# type: (Binder) -> None
"""Initializer of the cache - creates the Redis cache module as the
default cache infrastructure. The module is bound to `RedisCacheModule`
and `CacheModule` keys. The initializer also creates `RedisIdHelper`
and bounds it to ... | [
"def",
"configure",
"(",
"self",
",",
"binder",
")",
":",
"# type: (Binder) -> None",
"redis_cache_module",
"=",
"RedisCacheModule",
"(",
")",
"binder",
".",
"bind",
"(",
"RedisCacheModule",
",",
"to",
"=",
"redis_cache_module",
",",
"scope",
"=",
"singleton",
"... | Initializer of the cache - creates the Redis cache module as the
default cache infrastructure. The module is bound to `RedisCacheModule`
and `CacheModule` keys. The initializer also creates `RedisIdHelper`
and bounds it to `RedisIdHelper` and `IdHelper` keys.
:param Binder binder: The b... | [
"Initializer",
"of",
"the",
"cache",
"-",
"creates",
"the",
"Redis",
"cache",
"module",
"as",
"the",
"default",
"cache",
"infrastructure",
".",
"The",
"module",
"is",
"bound",
"to",
"RedisCacheModule",
"and",
"CacheModule",
"keys",
".",
"The",
"initializer",
"... | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/modules/cache_module.py#L22-L56 |
AtteqCom/zsl | src/zsl/application/error_handler.py | error_handler | def error_handler(f):
"""
Default error handler.
- On server side error shows a message
'An error occurred!' and returns 500 status code.
- Also serves well in the case when the resource/task/method
is not found - returns 404 status code.
"""
@wraps(f)
def error_handling_fun... | python | def error_handler(f):
"""
Default error handler.
- On server side error shows a message
'An error occurred!' and returns 500 status code.
- Also serves well in the case when the resource/task/method
is not found - returns 404 status code.
"""
@wraps(f)
def error_handling_fun... | [
"def",
"error_handler",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"error_handling_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"@",
"inject",
"(",
"error_config",
"=",
"ErrorConfiguration",
")",
"def",
"get_error_configurat... | Default error handler.
- On server side error shows a message
'An error occurred!' and returns 500 status code.
- Also serves well in the case when the resource/task/method
is not found - returns 404 status code. | [
"Default",
"error",
"handler",
".",
"-",
"On",
"server",
"side",
"error",
"shows",
"a",
"message",
"An",
"error",
"occurred!",
"and",
"returns",
"500",
"status",
"code",
".",
"-",
"Also",
"serves",
"well",
"in",
"the",
"case",
"when",
"the",
"resource",
... | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/error_handler.py#L114-L150 |
briney/abutils | abutils/utils/decorators.py | lazy_property | def lazy_property(func):
'''
Wraps a property to provide lazy evaluation. Eliminates boilerplate.
Also provides for setting and deleting the property.
Use as you would use the @property decorator::
# OLD:
class MyClass():
def __init__():
self._compute = None... | python | def lazy_property(func):
'''
Wraps a property to provide lazy evaluation. Eliminates boilerplate.
Also provides for setting and deleting the property.
Use as you would use the @property decorator::
# OLD:
class MyClass():
def __init__():
self._compute = None... | [
"def",
"lazy_property",
"(",
"func",
")",
":",
"attr_name",
"=",
"'_lazy_'",
"+",
"func",
".",
"__name__",
"@",
"property",
"def",
"_lazy_property",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"attr_name",
")",
":",
"setattr",
"(",
... | Wraps a property to provide lazy evaluation. Eliminates boilerplate.
Also provides for setting and deleting the property.
Use as you would use the @property decorator::
# OLD:
class MyClass():
def __init__():
self._compute = None
@property
d... | [
"Wraps",
"a",
"property",
"to",
"provide",
"lazy",
"evaluation",
".",
"Eliminates",
"boilerplate",
".",
"Also",
"provides",
"for",
"setting",
"and",
"deleting",
"the",
"property",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/decorators.py#L29-L106 |
briney/abutils | abutils/utils/decorators.py | coroutine | def coroutine(func):
'''
Initializes a coroutine -- essentially it just takes a
generator function and calls generator.next() to get
things going.
'''
def start(*args, **kwargs):
cr = func(*args, **kwargs)
cr.next()
return cr
return start | python | def coroutine(func):
'''
Initializes a coroutine -- essentially it just takes a
generator function and calls generator.next() to get
things going.
'''
def start(*args, **kwargs):
cr = func(*args, **kwargs)
cr.next()
return cr
return start | [
"def",
"coroutine",
"(",
"func",
")",
":",
"def",
"start",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cr",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"cr",
".",
"next",
"(",
")",
"return",
"cr",
"return",
"start"
] | Initializes a coroutine -- essentially it just takes a
generator function and calls generator.next() to get
things going. | [
"Initializes",
"a",
"coroutine",
"--",
"essentially",
"it",
"just",
"takes",
"a",
"generator",
"function",
"and",
"calls",
"generator",
".",
"next",
"()",
"to",
"get",
"things",
"going",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/decorators.py#L109-L119 |
briney/abutils | abutils/core/sequence.py | Sequence.fasta | def fasta(self):
'''
str: Returns the sequence, as a FASTA-formatted string
Note: The FASTA string is built using ``Sequence.id`` and ``Sequence.sequence``.
'''
if not self._fasta:
self._fasta = '>{}\n{}'.format(self.id, self.sequence)
return self._fasta | python | def fasta(self):
'''
str: Returns the sequence, as a FASTA-formatted string
Note: The FASTA string is built using ``Sequence.id`` and ``Sequence.sequence``.
'''
if not self._fasta:
self._fasta = '>{}\n{}'.format(self.id, self.sequence)
return self._fasta | [
"def",
"fasta",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_fasta",
":",
"self",
".",
"_fasta",
"=",
"'>{}\\n{}'",
".",
"format",
"(",
"self",
".",
"id",
",",
"self",
".",
"sequence",
")",
"return",
"self",
".",
"_fasta"
] | str: Returns the sequence, as a FASTA-formatted string
Note: The FASTA string is built using ``Sequence.id`` and ``Sequence.sequence``. | [
"str",
":",
"Returns",
"the",
"sequence",
"as",
"a",
"FASTA",
"-",
"formatted",
"string"
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/sequence.py#L183-L191 |
briney/abutils | abutils/core/sequence.py | Sequence.fastq | def fastq(self):
'''
str: Returns the sequence, as a FASTQ-formatted string
If ``Sequence.qual`` is ``None``, then ``None`` will be returned instead of a
FASTQ string
'''
if self.qual is None:
self._fastq = None
else:
if self._fastq is Non... | python | def fastq(self):
'''
str: Returns the sequence, as a FASTQ-formatted string
If ``Sequence.qual`` is ``None``, then ``None`` will be returned instead of a
FASTQ string
'''
if self.qual is None:
self._fastq = None
else:
if self._fastq is Non... | [
"def",
"fastq",
"(",
"self",
")",
":",
"if",
"self",
".",
"qual",
"is",
"None",
":",
"self",
".",
"_fastq",
"=",
"None",
"else",
":",
"if",
"self",
".",
"_fastq",
"is",
"None",
":",
"self",
".",
"_fastq",
"=",
"'@{}\\n{}\\n+\\n{}'",
".",
"format",
... | str: Returns the sequence, as a FASTQ-formatted string
If ``Sequence.qual`` is ``None``, then ``None`` will be returned instead of a
FASTQ string | [
"str",
":",
"Returns",
"the",
"sequence",
"as",
"a",
"FASTQ",
"-",
"formatted",
"string"
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/sequence.py#L194-L206 |
briney/abutils | abutils/core/sequence.py | Sequence.reverse_complement | def reverse_complement(self):
'''
str: Returns the reverse complement of ``Sequence.sequence``.
'''
if self._reverse_complement is None:
self._reverse_complement = self._get_reverse_complement()
return self._reverse_complement | python | def reverse_complement(self):
'''
str: Returns the reverse complement of ``Sequence.sequence``.
'''
if self._reverse_complement is None:
self._reverse_complement = self._get_reverse_complement()
return self._reverse_complement | [
"def",
"reverse_complement",
"(",
"self",
")",
":",
"if",
"self",
".",
"_reverse_complement",
"is",
"None",
":",
"self",
".",
"_reverse_complement",
"=",
"self",
".",
"_get_reverse_complement",
"(",
")",
"return",
"self",
".",
"_reverse_complement"
] | str: Returns the reverse complement of ``Sequence.sequence``. | [
"str",
":",
"Returns",
"the",
"reverse",
"complement",
"of",
"Sequence",
".",
"sequence",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/sequence.py#L209-L215 |
briney/abutils | abutils/core/sequence.py | Sequence.region | def region(self, start=0, end=None):
'''
Returns a region of ``Sequence.sequence``, in FASTA format.
If called without kwargs, the entire sequence will be returned.
Args:
start (int): Start position of the region to be returned. Default
is 0.
e... | python | def region(self, start=0, end=None):
'''
Returns a region of ``Sequence.sequence``, in FASTA format.
If called without kwargs, the entire sequence will be returned.
Args:
start (int): Start position of the region to be returned. Default
is 0.
e... | [
"def",
"region",
"(",
"self",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"len",
"(",
"self",
".",
"sequence",
")",
"return",
"'>{}\\n{}'",
".",
"format",
"(",
"self",
".",
"id",
",",
"... | Returns a region of ``Sequence.sequence``, in FASTA format.
If called without kwargs, the entire sequence will be returned.
Args:
start (int): Start position of the region to be returned. Default
is 0.
end (int): End position of the region to be returned. Nega... | [
"Returns",
"a",
"region",
"of",
"Sequence",
".",
"sequence",
"in",
"FASTA",
"format",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/sequence.py#L252-L272 |
AtteqCom/zsl | src/zsl/utils/string_helper.py | underscore_to_camelcase | def underscore_to_camelcase(value, first_upper=True):
"""Transform string from underscore_string to camelCase.
:param value: string with underscores
:param first_upper: the result will have its first character in upper case
:type value: str
:return: string in CamelCase or camelCase according to the... | python | def underscore_to_camelcase(value, first_upper=True):
"""Transform string from underscore_string to camelCase.
:param value: string with underscores
:param first_upper: the result will have its first character in upper case
:type value: str
:return: string in CamelCase or camelCase according to the... | [
"def",
"underscore_to_camelcase",
"(",
"value",
",",
"first_upper",
"=",
"True",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"camelized",
"=",
"\"\"",
".",
"join",
"(",
"x",
".",
"title",
"(",
")",
"if",
"x",
"else",
"'_'",
"for",
"x",
"in",
... | Transform string from underscore_string to camelCase.
:param value: string with underscores
:param first_upper: the result will have its first character in upper case
:type value: str
:return: string in CamelCase or camelCase according to the first_upper
:rtype: str
:Example:
>>> under... | [
"Transform",
"string",
"from",
"underscore_string",
"to",
"camelCase",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/string_helper.py#L20-L39 |
AtteqCom/zsl | src/zsl/utils/string_helper.py | et_node_to_string | def et_node_to_string(et_node, default=''):
"""Simple method to get stripped text from node or ``default`` string if None is given.
:param et_node: Element or None
:param default: string returned if None is given, default ``''``
:type et_node: xml.etree.ElementTree.Element, None
:type default: str
... | python | def et_node_to_string(et_node, default=''):
"""Simple method to get stripped text from node or ``default`` string if None is given.
:param et_node: Element or None
:param default: string returned if None is given, default ``''``
:type et_node: xml.etree.ElementTree.Element, None
:type default: str
... | [
"def",
"et_node_to_string",
"(",
"et_node",
",",
"default",
"=",
"''",
")",
":",
"return",
"str",
"(",
"et_node",
".",
"text",
")",
".",
"strip",
"(",
")",
"if",
"et_node",
"is",
"not",
"None",
"and",
"et_node",
".",
"text",
"else",
"default"
] | Simple method to get stripped text from node or ``default`` string if None is given.
:param et_node: Element or None
:param default: string returned if None is given, default ``''``
:type et_node: xml.etree.ElementTree.Element, None
:type default: str
:return: text from node or default
:rtype: ... | [
"Simple",
"method",
"to",
"get",
"stripped",
"text",
"from",
"node",
"or",
"default",
"string",
"if",
"None",
"is",
"given",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/string_helper.py#L58-L69 |
AtteqCom/zsl | src/zsl/utils/string_helper.py | generate_random_string | def generate_random_string(size=6, chars=string.ascii_uppercase + string.digits):
"""Generate random string.
:param size: Length of the returned string. Default is 6.
:param chars: List of the usable characters. Default is string.ascii_uppercase + string.digits.
:type size: int
:type chars: str
... | python | def generate_random_string(size=6, chars=string.ascii_uppercase + string.digits):
"""Generate random string.
:param size: Length of the returned string. Default is 6.
:param chars: List of the usable characters. Default is string.ascii_uppercase + string.digits.
:type size: int
:type chars: str
... | [
"def",
"generate_random_string",
"(",
"size",
"=",
"6",
",",
"chars",
"=",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"digits",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"chars",
")",
"for",
"_",
"in",
"range"... | Generate random string.
:param size: Length of the returned string. Default is 6.
:param chars: List of the usable characters. Default is string.ascii_uppercase + string.digits.
:type size: int
:type chars: str
:return: The random string.
:rtype: str | [
"Generate",
"random",
"string",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/string_helper.py#L72-L82 |
AtteqCom/zsl | src/zsl/utils/string_helper.py | addslashes | def addslashes(s, escaped_chars=None):
"""Add slashes for given characters. Default is for ``\`` and ``'``.
:param s: string
:param escaped_chars: list of characters to prefix with a slash ``\``
:return: string with slashed characters
:rtype: str
:Example:
>>> addslashes("'")
"... | python | def addslashes(s, escaped_chars=None):
"""Add slashes for given characters. Default is for ``\`` and ``'``.
:param s: string
:param escaped_chars: list of characters to prefix with a slash ``\``
:return: string with slashed characters
:rtype: str
:Example:
>>> addslashes("'")
"... | [
"def",
"addslashes",
"(",
"s",
",",
"escaped_chars",
"=",
"None",
")",
":",
"if",
"escaped_chars",
"is",
"None",
":",
"escaped_chars",
"=",
"[",
"\"\\\\\"",
",",
"\"'\"",
",",
"]",
"# l = [\"\\\\\", '\"', \"'\", \"\\0\", ]",
"for",
"i",
"in",
"escaped_chars",
... | Add slashes for given characters. Default is for ``\`` and ``'``.
:param s: string
:param escaped_chars: list of characters to prefix with a slash ``\``
:return: string with slashed characters
:rtype: str
:Example:
>>> addslashes("'")
"\\'" | [
"Add",
"slashes",
"for",
"given",
"characters",
".",
"Default",
"is",
"for",
"\\",
"and",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/string_helper.py#L85-L104 |
AtteqCom/zsl | src/zsl/utils/string_helper.py | join_list | def join_list(values, delimiter=', ', transform=None):
"""
Concatenates the upper-cased values using the given delimiter if
the given values variable is a list. Otherwise it is just returned.
:param values: List of strings or string .
:param delimiter: The delimiter used to join the values.
:ret... | python | def join_list(values, delimiter=', ', transform=None):
"""
Concatenates the upper-cased values using the given delimiter if
the given values variable is a list. Otherwise it is just returned.
:param values: List of strings or string .
:param delimiter: The delimiter used to join the values.
:ret... | [
"def",
"join_list",
"(",
"values",
",",
"delimiter",
"=",
"', '",
",",
"transform",
"=",
"None",
")",
":",
"# type: (Union[List[str], str], str)->str",
"if",
"transform",
"is",
"None",
":",
"transform",
"=",
"_identity",
"if",
"values",
"is",
"not",
"None",
"a... | Concatenates the upper-cased values using the given delimiter if
the given values variable is a list. Otherwise it is just returned.
:param values: List of strings or string .
:param delimiter: The delimiter used to join the values.
:return: The concatenation or identity. | [
"Concatenates",
"the",
"upper",
"-",
"cased",
"values",
"using",
"the",
"given",
"delimiter",
"if",
"the",
"given",
"values",
"variable",
"is",
"a",
"list",
".",
"Otherwise",
"it",
"is",
"just",
"returned",
".",
":",
"param",
"values",
":",
"List",
"of",
... | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/string_helper.py#L167-L181 |
briney/abutils | abutils/utils/alignment.py | mafft | def mafft(sequences=None, alignment_file=None, fasta=None, fmt='fasta', threads=-1, as_file=False,
reorder=True, print_stdout=False, print_stderr=False, mafft_bin=None):
'''
Performs multiple sequence alignment with MAFFT.
Args:
sequences (list): Sequences to be aligned. ``sequences`` ca... | python | def mafft(sequences=None, alignment_file=None, fasta=None, fmt='fasta', threads=-1, as_file=False,
reorder=True, print_stdout=False, print_stderr=False, mafft_bin=None):
'''
Performs multiple sequence alignment with MAFFT.
Args:
sequences (list): Sequences to be aligned. ``sequences`` ca... | [
"def",
"mafft",
"(",
"sequences",
"=",
"None",
",",
"alignment_file",
"=",
"None",
",",
"fasta",
"=",
"None",
",",
"fmt",
"=",
"'fasta'",
",",
"threads",
"=",
"-",
"1",
",",
"as_file",
"=",
"False",
",",
"reorder",
"=",
"True",
",",
"print_stdout",
"... | Performs multiple sequence alignment with MAFFT.
Args:
sequences (list): Sequences to be aligned. ``sequences`` can be one of four things:
1. a FASTA-formatted string
2. a list of BioPython ``SeqRecord`` objects
3. a list of AbTools ``Sequence`` objects
... | [
"Performs",
"multiple",
"sequence",
"alignment",
"with",
"MAFFT",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/alignment.py#L66-L154 |
briney/abutils | abutils/utils/alignment.py | muscle | def muscle(sequences=None, alignment_file=None, fasta=None,
fmt='fasta', as_file=False, maxiters=None, diags=False,
gap_open=None, gap_extend=None, muscle_bin=None):
'''
Performs multiple sequence alignment with MUSCLE.
Args:
sequences (list): Sequences to be aligned. ``sequences`` can be ... | python | def muscle(sequences=None, alignment_file=None, fasta=None,
fmt='fasta', as_file=False, maxiters=None, diags=False,
gap_open=None, gap_extend=None, muscle_bin=None):
'''
Performs multiple sequence alignment with MUSCLE.
Args:
sequences (list): Sequences to be aligned. ``sequences`` can be ... | [
"def",
"muscle",
"(",
"sequences",
"=",
"None",
",",
"alignment_file",
"=",
"None",
",",
"fasta",
"=",
"None",
",",
"fmt",
"=",
"'fasta'",
",",
"as_file",
"=",
"False",
",",
"maxiters",
"=",
"None",
",",
"diags",
"=",
"False",
",",
"gap_open",
"=",
"... | Performs multiple sequence alignment with MUSCLE.
Args:
sequences (list): Sequences to be aligned. ``sequences`` can be one of four things:
1. a FASTA-formatted string
2. a list of BioPython ``SeqRecord`` objects
3. a list of AbTools ``Sequence`` objects
... | [
"Performs",
"multiple",
"sequence",
"alignment",
"with",
"MUSCLE",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/alignment.py#L157-L243 |
briney/abutils | abutils/utils/alignment.py | local_alignment | def local_alignment(query, target=None, targets=None, match=3, mismatch=-2,
gap_open=-5, gap_extend=-2, matrix=None, aa=False, gap_open_penalty=None, gap_extend_penalty=None):
'''
Striped Smith-Waterman local pairwise alignment.
Args:
query: Query sequence. ``query`` can be one of four thi... | python | def local_alignment(query, target=None, targets=None, match=3, mismatch=-2,
gap_open=-5, gap_extend=-2, matrix=None, aa=False, gap_open_penalty=None, gap_extend_penalty=None):
'''
Striped Smith-Waterman local pairwise alignment.
Args:
query: Query sequence. ``query`` can be one of four thi... | [
"def",
"local_alignment",
"(",
"query",
",",
"target",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"match",
"=",
"3",
",",
"mismatch",
"=",
"-",
"2",
",",
"gap_open",
"=",
"-",
"5",
",",
"gap_extend",
"=",
"-",
"2",
",",
"matrix",
"=",
"None",
... | Striped Smith-Waterman local pairwise alignment.
Args:
query: Query sequence. ``query`` can be one of four things:
1. a nucleotide or amino acid sequence, as a string
2. a Biopython ``SeqRecord`` object
3. an AbTools ``Sequence`` object
4. a list/tuple o... | [
"Striped",
"Smith",
"-",
"Waterman",
"local",
"pairwise",
"alignment",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/alignment.py#L279-L361 |
briney/abutils | abutils/utils/alignment.py | global_alignment | def global_alignment(query, target=None, targets=None, match=3, mismatch=-2, gap_open=-5, gap_extend=-2,
score_match=None, score_mismatch=None, score_gap_open=None,
score_gap_extend=None, matrix=None, aa=False):
'''
Needleman-Wunch global pairwise alignment.
With ``global_alignment``, you c... | python | def global_alignment(query, target=None, targets=None, match=3, mismatch=-2, gap_open=-5, gap_extend=-2,
score_match=None, score_mismatch=None, score_gap_open=None,
score_gap_extend=None, matrix=None, aa=False):
'''
Needleman-Wunch global pairwise alignment.
With ``global_alignment``, you c... | [
"def",
"global_alignment",
"(",
"query",
",",
"target",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"match",
"=",
"3",
",",
"mismatch",
"=",
"-",
"2",
",",
"gap_open",
"=",
"-",
"5",
",",
"gap_extend",
"=",
"-",
"2",
",",
"score_match",
"=",
"No... | Needleman-Wunch global pairwise alignment.
With ``global_alignment``, you can score an alignment using different
paramaters than were used to compute the alignment. This allows you to
compute pure identity scores (match=1, mismatch=0) on pairs of sequences
for which those alignment parameters would be ... | [
"Needleman",
"-",
"Wunch",
"global",
"pairwise",
"alignment",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/alignment.py#L390-L518 |
briney/abutils | abutils/utils/alignment.py | dot_alignment | def dot_alignment(sequences, seq_field=None, name_field=None, root=None, root_name=None,
cluster_threshold=0.75, as_fasta=False, just_alignment=False):
'''
Creates a dot alignment (dots indicate identity, mismatches are represented by the mismatched
residue) for a list of sequences.
Args:
... | python | def dot_alignment(sequences, seq_field=None, name_field=None, root=None, root_name=None,
cluster_threshold=0.75, as_fasta=False, just_alignment=False):
'''
Creates a dot alignment (dots indicate identity, mismatches are represented by the mismatched
residue) for a list of sequences.
Args:
... | [
"def",
"dot_alignment",
"(",
"sequences",
",",
"seq_field",
"=",
"None",
",",
"name_field",
"=",
"None",
",",
"root",
"=",
"None",
",",
"root_name",
"=",
"None",
",",
"cluster_threshold",
"=",
"0.75",
",",
"as_fasta",
"=",
"False",
",",
"just_alignment",
"... | Creates a dot alignment (dots indicate identity, mismatches are represented by the mismatched
residue) for a list of sequences.
Args:
sequence (list(Sequence)): A list of Sequence objects to be aligned.
seq_field (str): Name of the sequence field key. Default is ``vdj_nt``.
name_fiel... | [
"Creates",
"a",
"dot",
"alignment",
"(",
"dots",
"indicate",
"identity",
"mismatches",
"are",
"represented",
"by",
"the",
"mismatched",
"residue",
")",
"for",
"a",
"list",
"of",
"sequences",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/alignment.py#L945-L1076 |
AtteqCom/zsl | src/zsl/utils/import_helper.py | fetch_class | def fetch_class(full_class_name):
"""Fetches the given class.
:param string full_class_name: Name of the class to be fetched.
"""
(module_name, class_name) = full_class_name.rsplit('.', 1)
module = importlib.import_module(module_name)
return getattr(module, class_name) | python | def fetch_class(full_class_name):
"""Fetches the given class.
:param string full_class_name: Name of the class to be fetched.
"""
(module_name, class_name) = full_class_name.rsplit('.', 1)
module = importlib.import_module(module_name)
return getattr(module, class_name) | [
"def",
"fetch_class",
"(",
"full_class_name",
")",
":",
"(",
"module_name",
",",
"class_name",
")",
"=",
"full_class_name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"return",
"getatt... | Fetches the given class.
:param string full_class_name: Name of the class to be fetched. | [
"Fetches",
"the",
"given",
"class",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/import_helper.py#L12-L19 |
datacamp/protowhat | protowhat/checks/check_simple.py | has_chosen | def has_chosen(state, correct, msgs):
"""Verify exercises of the type MultipleChoiceExercise
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
correct: index of correct option, where 1 is the first option.
msgs : list of feedback... | python | def has_chosen(state, correct, msgs):
"""Verify exercises of the type MultipleChoiceExercise
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
correct: index of correct option, where 1 is the first option.
msgs : list of feedback... | [
"def",
"has_chosen",
"(",
"state",
",",
"correct",
",",
"msgs",
")",
":",
"ctxt",
"=",
"{",
"}",
"exec",
"(",
"state",
".",
"student_code",
",",
"globals",
"(",
")",
",",
"ctxt",
")",
"sel_indx",
"=",
"ctxt",
"[",
"\"selected_option\"",
"]",
"if",
"s... | Verify exercises of the type MultipleChoiceExercise
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
correct: index of correct option, where 1 is the first option.
msgs : list of feedback messages corresponding to each option.
... | [
"Verify",
"exercises",
"of",
"the",
"type",
"MultipleChoiceExercise"
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_simple.py#L4-L27 |
datacamp/protowhat | protowhat/checks/check_logic.py | multi | def multi(state, *tests):
"""Run multiple subtests. Return original state (for chaining).
This function could be thought as an AND statement, since all tests it runs must pass
Args:
state: State instance describing student and solution code, can be omitted if used with Ex()
tests: one or ... | python | def multi(state, *tests):
"""Run multiple subtests. Return original state (for chaining).
This function could be thought as an AND statement, since all tests it runs must pass
Args:
state: State instance describing student and solution code, can be omitted if used with Ex()
tests: one or ... | [
"def",
"multi",
"(",
"state",
",",
"*",
"tests",
")",
":",
"for",
"test",
"in",
"iter_tests",
"(",
"tests",
")",
":",
"# assume test is function needing a state argument",
"# partial state so reporter can test",
"state",
".",
"do_test",
"(",
"partial",
"(",
"test",
... | Run multiple subtests. Return original state (for chaining).
This function could be thought as an AND statement, since all tests it runs must pass
Args:
state: State instance describing student and solution code, can be omitted if used with Ex()
tests: one or more sub-SCTs to run.
:Examp... | [
"Run",
"multiple",
"subtests",
".",
"Return",
"original",
"state",
"(",
"for",
"chaining",
")",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_logic.py#L8-L36 |
datacamp/protowhat | protowhat/checks/check_logic.py | check_not | def check_not(state, *tests, msg):
"""Run multiple subtests that should fail. If all subtests fail, returns original state (for chaining)
- This function is currently only tested in working with ``has_code()`` in the subtests.
- This function can be thought as a ``NOT(x OR y OR ...)`` statement, since all ... | python | def check_not(state, *tests, msg):
"""Run multiple subtests that should fail. If all subtests fail, returns original state (for chaining)
- This function is currently only tested in working with ``has_code()`` in the subtests.
- This function can be thought as a ``NOT(x OR y OR ...)`` statement, since all ... | [
"def",
"check_not",
"(",
"state",
",",
"*",
"tests",
",",
"msg",
")",
":",
"for",
"test",
"in",
"iter_tests",
"(",
"tests",
")",
":",
"try",
":",
"test",
"(",
"state",
")",
"except",
"TestFail",
":",
"# it fails, as expected, off to next one",
"continue",
... | Run multiple subtests that should fail. If all subtests fail, returns original state (for chaining)
- This function is currently only tested in working with ``has_code()`` in the subtests.
- This function can be thought as a ``NOT(x OR y OR ...)`` statement, since all tests it runs must fail
- This functio... | [
"Run",
"multiple",
"subtests",
"that",
"should",
"fail",
".",
"If",
"all",
"subtests",
"fail",
"returns",
"original",
"state",
"(",
"for",
"chaining",
")"
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_logic.py#L40-L74 |
datacamp/protowhat | protowhat/checks/check_logic.py | check_or | def check_or(state, *tests):
"""Test whether at least one SCT passes.
If all of the tests fail, the feedback of the first test will be presented to the student.
Args:
state: State instance describing student and solution code, can be omitted if used with Ex()
tests: one or more sub-SCTs to... | python | def check_or(state, *tests):
"""Test whether at least one SCT passes.
If all of the tests fail, the feedback of the first test will be presented to the student.
Args:
state: State instance describing student and solution code, can be omitted if used with Ex()
tests: one or more sub-SCTs to... | [
"def",
"check_or",
"(",
"state",
",",
"*",
"tests",
")",
":",
"success",
"=",
"False",
"first_feedback",
"=",
"None",
"for",
"test",
"in",
"iter_tests",
"(",
"tests",
")",
":",
"try",
":",
"multi",
"(",
"state",
",",
"test",
")",
"success",
"=",
"Tru... | Test whether at least one SCT passes.
If all of the tests fail, the feedback of the first test will be presented to the student.
Args:
state: State instance describing student and solution code, can be omitted if used with Ex()
tests: one or more sub-SCTs to run
:Example:
The SCT ... | [
"Test",
"whether",
"at",
"least",
"one",
"SCT",
"passes",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_logic.py#L77-L114 |
datacamp/protowhat | protowhat/checks/check_logic.py | check_correct | def check_correct(state, check, diagnose):
"""Allows feedback from a diagnostic SCT, only if a check SCT fails.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
check: An sct chain that must succeed.
diagnose: An sct chain to run if the... | python | def check_correct(state, check, diagnose):
"""Allows feedback from a diagnostic SCT, only if a check SCT fails.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
check: An sct chain that must succeed.
diagnose: An sct chain to run if the... | [
"def",
"check_correct",
"(",
"state",
",",
"check",
",",
"diagnose",
")",
":",
"feedback",
"=",
"None",
"try",
":",
"multi",
"(",
"state",
",",
"check",
")",
"except",
"TestFail",
"as",
"e",
":",
"feedback",
"=",
"e",
".",
"feedback",
"# todo: let if fro... | Allows feedback from a diagnostic SCT, only if a check SCT fails.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
check: An sct chain that must succeed.
diagnose: An sct chain to run if the check fails.
:Example:
The SCT below... | [
"Allows",
"feedback",
"from",
"a",
"diagnostic",
"SCT",
"only",
"if",
"a",
"check",
"SCT",
"fails",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_logic.py#L117-L151 |
datacamp/protowhat | protowhat/checks/check_logic.py | fail | def fail(state, msg="fail"):
"""Always fails the SCT, with an optional msg.
This function takes a single argument, ``msg``, that is the feedback given to the student.
Note that this would be a terrible idea for grading submissions, but may be useful while writing SCTs.
For example, failing a test will ... | python | def fail(state, msg="fail"):
"""Always fails the SCT, with an optional msg.
This function takes a single argument, ``msg``, that is the feedback given to the student.
Note that this would be a terrible idea for grading submissions, but may be useful while writing SCTs.
For example, failing a test will ... | [
"def",
"fail",
"(",
"state",
",",
"msg",
"=",
"\"fail\"",
")",
":",
"_msg",
"=",
"state",
".",
"build_message",
"(",
"msg",
")",
"state",
".",
"report",
"(",
"Feedback",
"(",
"_msg",
",",
"state",
")",
")",
"return",
"state"
] | Always fails the SCT, with an optional msg.
This function takes a single argument, ``msg``, that is the feedback given to the student.
Note that this would be a terrible idea for grading submissions, but may be useful while writing SCTs.
For example, failing a test will highlight the code as if the previou... | [
"Always",
"fails",
"the",
"SCT",
"with",
"an",
"optional",
"msg",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_logic.py#L175-L185 |
AtteqCom/zsl | src/zsl/utils/xml_helper.py | required_attributes | def required_attributes(element, *attributes):
"""Check element for required attributes. Raise ``NotValidXmlException`` on error.
:param element: ElementTree element
:param attributes: list of attributes names to check
:raises NotValidXmlException: if some argument is missing
"""
if not reduce(... | python | def required_attributes(element, *attributes):
"""Check element for required attributes. Raise ``NotValidXmlException`` on error.
:param element: ElementTree element
:param attributes: list of attributes names to check
:raises NotValidXmlException: if some argument is missing
"""
if not reduce(... | [
"def",
"required_attributes",
"(",
"element",
",",
"*",
"attributes",
")",
":",
"if",
"not",
"reduce",
"(",
"lambda",
"still_valid",
",",
"param",
":",
"still_valid",
"and",
"param",
"in",
"element",
".",
"attrib",
",",
"attributes",
",",
"True",
")",
":",... | Check element for required attributes. Raise ``NotValidXmlException`` on error.
:param element: ElementTree element
:param attributes: list of attributes names to check
:raises NotValidXmlException: if some argument is missing | [
"Check",
"element",
"for",
"required",
"attributes",
".",
"Raise",
"NotValidXmlException",
"on",
"error",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L22-L30 |
AtteqCom/zsl | src/zsl/utils/xml_helper.py | required_elements | def required_elements(element, *children):
"""Check element (``xml.etree.ElementTree.Element``) for required children, defined as XPath. Raise
``NotValidXmlException`` on error.
:param element: ElementTree element
:param children: list of XPaths to check
:raises NotValidXmlException: if some child ... | python | def required_elements(element, *children):
"""Check element (``xml.etree.ElementTree.Element``) for required children, defined as XPath. Raise
``NotValidXmlException`` on error.
:param element: ElementTree element
:param children: list of XPaths to check
:raises NotValidXmlException: if some child ... | [
"def",
"required_elements",
"(",
"element",
",",
"*",
"children",
")",
":",
"for",
"child",
"in",
"children",
":",
"if",
"element",
".",
"find",
"(",
"child",
")",
"is",
"None",
":",
"raise",
"NotValidXmlException",
"(",
"msg_err_missing_children",
"(",
"ele... | Check element (``xml.etree.ElementTree.Element``) for required children, defined as XPath. Raise
``NotValidXmlException`` on error.
:param element: ElementTree element
:param children: list of XPaths to check
:raises NotValidXmlException: if some child is missing | [
"Check",
"element",
"(",
"xml",
".",
"etree",
".",
"ElementTree",
".",
"Element",
")",
"for",
"required",
"children",
"defined",
"as",
"XPath",
".",
"Raise",
"NotValidXmlException",
"on",
"error",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L33-L43 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.