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/utils/xml_helper.py | required_items | def required_items(element, children, attributes):
"""Check an xml element to include given attributes and children.
:param element: ElementTree element
:param children: list of XPaths to check
:param attributes: list of attributes names to check
:raises NotValidXmlException: if some argument is mi... | python | def required_items(element, children, attributes):
"""Check an xml element to include given attributes and children.
:param element: ElementTree element
:param children: list of XPaths to check
:param attributes: list of attributes names to check
:raises NotValidXmlException: if some argument is mi... | [
"def",
"required_items",
"(",
"element",
",",
"children",
",",
"attributes",
")",
":",
"required_elements",
"(",
"element",
",",
"*",
"children",
")",
"required_attributes",
"(",
"element",
",",
"*",
"attributes",
")"
] | Check an xml element to include given attributes and children.
:param element: ElementTree element
:param children: list of XPaths to check
:param attributes: list of attributes names to check
:raises NotValidXmlException: if some argument is missing
:raises NotValidXmlException: if some child is m... | [
"Check",
"an",
"xml",
"element",
"to",
"include",
"given",
"attributes",
"and",
"children",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L46-L56 |
AtteqCom/zsl | src/zsl/utils/xml_helper.py | attrib_to_dict | def attrib_to_dict(element, *args, **kwargs):
"""For an ElementTree ``element`` extract specified attributes. If an attribute does not exists, its value will be
``None``.
attrib_to_dict(element, 'attr_a', 'attr_b') -> {'attr_a': 'value', 'attr_a': 'value'}
Mapping between xml attributes and dictionary... | python | def attrib_to_dict(element, *args, **kwargs):
"""For an ElementTree ``element`` extract specified attributes. If an attribute does not exists, its value will be
``None``.
attrib_to_dict(element, 'attr_a', 'attr_b') -> {'attr_a': 'value', 'attr_a': 'value'}
Mapping between xml attributes and dictionary... | [
"def",
"attrib_to_dict",
"(",
"element",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"return",
"{",
"key",
":",
"element",
".",
"get",
"(",
"key",
")",
"for",
"key",
"in",
"args",
"}",
"if"... | For an ElementTree ``element`` extract specified attributes. If an attribute does not exists, its value will be
``None``.
attrib_to_dict(element, 'attr_a', 'attr_b') -> {'attr_a': 'value', 'attr_a': 'value'}
Mapping between xml attributes and dictionary keys is done with kwargs.
attrib_to_dict(element... | [
"For",
"an",
"ElementTree",
"element",
"extract",
"specified",
"attributes",
".",
"If",
"an",
"attribute",
"does",
"not",
"exists",
"its",
"value",
"will",
"be",
"None",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L81-L96 |
AtteqCom/zsl | src/zsl/utils/xml_helper.py | get_xml_root | def get_xml_root(xml_path):
"""Load and parse an xml by given xml_path and return its root.
:param xml_path: URL to a xml file
:type xml_path: str
:return: xml root
"""
r = requests.get(xml_path)
root = ET.fromstring(r.content)
return root | python | def get_xml_root(xml_path):
"""Load and parse an xml by given xml_path and return its root.
:param xml_path: URL to a xml file
:type xml_path: str
:return: xml root
"""
r = requests.get(xml_path)
root = ET.fromstring(r.content)
return root | [
"def",
"get_xml_root",
"(",
"xml_path",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"xml_path",
")",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"r",
".",
"content",
")",
"return",
"root"
] | Load and parse an xml by given xml_path and return its root.
:param xml_path: URL to a xml file
:type xml_path: str
:return: xml root | [
"Load",
"and",
"parse",
"an",
"xml",
"by",
"given",
"xml_path",
"and",
"return",
"its",
"root",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L99-L108 |
AtteqCom/zsl | src/zsl/utils/xml_helper.py | element_to_int | def element_to_int(element, attribute=None):
"""Convert ``element`` object to int. If attribute is not given, convert ``element.text``.
:param element: ElementTree element
:param attribute: attribute name
:type attribute: str
:returns: integer
:rtype: int
"""
if attribute is not None:
... | python | def element_to_int(element, attribute=None):
"""Convert ``element`` object to int. If attribute is not given, convert ``element.text``.
:param element: ElementTree element
:param attribute: attribute name
:type attribute: str
:returns: integer
:rtype: int
"""
if attribute is not None:
... | [
"def",
"element_to_int",
"(",
"element",
",",
"attribute",
"=",
"None",
")",
":",
"if",
"attribute",
"is",
"not",
"None",
":",
"return",
"int",
"(",
"element",
".",
"get",
"(",
"attribute",
")",
")",
"else",
":",
"return",
"int",
"(",
"element",
".",
... | Convert ``element`` object to int. If attribute is not given, convert ``element.text``.
:param element: ElementTree element
:param attribute: attribute name
:type attribute: str
:returns: integer
:rtype: int | [
"Convert",
"element",
"object",
"to",
"int",
".",
"If",
"attribute",
"is",
"not",
"given",
"convert",
"element",
".",
"text",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L111-L123 |
AtteqCom/zsl | src/zsl/utils/xml_helper.py | create_el | def create_el(name, text=None, attrib=None):
"""Create element with given attributes and set element.text property to given
text value (if text is not None)
:param name: element name
:type name: str
:param text: text node value
:type text: str
:param attrib: attributes
:type attrib: dic... | python | def create_el(name, text=None, attrib=None):
"""Create element with given attributes and set element.text property to given
text value (if text is not None)
:param name: element name
:type name: str
:param text: text node value
:type text: str
:param attrib: attributes
:type attrib: dic... | [
"def",
"create_el",
"(",
"name",
",",
"text",
"=",
"None",
",",
"attrib",
"=",
"None",
")",
":",
"if",
"attrib",
"is",
"None",
":",
"attrib",
"=",
"{",
"}",
"el",
"=",
"ET",
".",
"Element",
"(",
"name",
",",
"attrib",
")",
"if",
"text",
"is",
"... | Create element with given attributes and set element.text property to given
text value (if text is not None)
:param name: element name
:type name: str
:param text: text node value
:type text: str
:param attrib: attributes
:type attrib: dict
:returns: xml element
:rtype: Element | [
"Create",
"element",
"with",
"given",
"attributes",
"and",
"set",
"element",
".",
"text",
"property",
"to",
"given",
"text",
"value",
"(",
"if",
"text",
"is",
"not",
"None",
")"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_helper.py#L126-L145 |
AtteqCom/zsl | src/zsl/application/containers/container.py | IoCContainer.modules | def modules(cls):
"""Collect all the public class attributes.
All class attributes should be a DI modules, this method collects them
and returns as a list.
:return: list of DI modules
:rtype: list[Union[Module, Callable]]
"""
members = inspect.getmembers(cls, la... | python | def modules(cls):
"""Collect all the public class attributes.
All class attributes should be a DI modules, this method collects them
and returns as a list.
:return: list of DI modules
:rtype: list[Union[Module, Callable]]
"""
members = inspect.getmembers(cls, la... | [
"def",
"modules",
"(",
"cls",
")",
":",
"members",
"=",
"inspect",
".",
"getmembers",
"(",
"cls",
",",
"lambda",
"a",
":",
"not",
"(",
"inspect",
".",
"isroutine",
"(",
"a",
")",
"and",
"a",
".",
"__name__",
"==",
"'modules'",
")",
")",
"modules",
... | Collect all the public class attributes.
All class attributes should be a DI modules, this method collects them
and returns as a list.
:return: list of DI modules
:rtype: list[Union[Module, Callable]] | [
"Collect",
"all",
"the",
"public",
"class",
"attributes",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/application/containers/container.py#L24-L35 |
briney/abutils | abutils/core/pair.py | get_pairs | def get_pairs(db, collection, experiment=None, subject=None, group=None, name='seq_id',
delim=None, delim_occurance=1, pairs_only=False, h_selection_func=None, l_selection_func=None):
'''
Gets sequences and assigns them to the appropriate mAb pair, based on the sequence name.
Inputs:
::db:: is a p... | python | def get_pairs(db, collection, experiment=None, subject=None, group=None, name='seq_id',
delim=None, delim_occurance=1, pairs_only=False, h_selection_func=None, l_selection_func=None):
'''
Gets sequences and assigns them to the appropriate mAb pair, based on the sequence name.
Inputs:
::db:: is a p... | [
"def",
"get_pairs",
"(",
"db",
",",
"collection",
",",
"experiment",
"=",
"None",
",",
"subject",
"=",
"None",
",",
"group",
"=",
"None",
",",
"name",
"=",
"'seq_id'",
",",
"delim",
"=",
"None",
",",
"delim_occurance",
"=",
"1",
",",
"pairs_only",
"=",... | Gets sequences and assigns them to the appropriate mAb pair, based on the sequence name.
Inputs:
::db:: is a pymongo database connection object
::collection:: is the collection name, as a string
If ::subject:: is provided, only sequences with a 'subject' field matching ::subject:: will
be incl... | [
"Gets",
"sequences",
"and",
"assigns",
"them",
"to",
"the",
"appropriate",
"mAb",
"pair",
"based",
"on",
"the",
"sequence",
"name",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L328-L374 |
briney/abutils | abutils/core/pair.py | assign_pairs | def assign_pairs(seqs, name='seq_id', delim=None, delim_occurance=1, pairs_only=False,
h_selection_func=None, l_selection_func=None):
'''
Assigns sequences to the appropriate mAb pair, based on the sequence name.
Inputs:
::seqs:: is a list of dicts, of the format returned by querying ... | python | def assign_pairs(seqs, name='seq_id', delim=None, delim_occurance=1, pairs_only=False,
h_selection_func=None, l_selection_func=None):
'''
Assigns sequences to the appropriate mAb pair, based on the sequence name.
Inputs:
::seqs:: is a list of dicts, of the format returned by querying ... | [
"def",
"assign_pairs",
"(",
"seqs",
",",
"name",
"=",
"'seq_id'",
",",
"delim",
"=",
"None",
",",
"delim_occurance",
"=",
"1",
",",
"pairs_only",
"=",
"False",
",",
"h_selection_func",
"=",
"None",
",",
"l_selection_func",
"=",
"None",
")",
":",
"pdict",
... | Assigns sequences to the appropriate mAb pair, based on the sequence name.
Inputs:
::seqs:: is a list of dicts, of the format returned by querying a MongoDB containing
Abstar output.
::name:: is the dict key of the field to be used to group the sequences into pairs.
Default is 'seq_id'
... | [
"Assigns",
"sequences",
"to",
"the",
"appropriate",
"mAb",
"pair",
"based",
"on",
"the",
"sequence",
"name",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L377-L413 |
briney/abutils | abutils/core/pair.py | deduplicate | def deduplicate(pairs, aa=False, ignore_primer_regions=False):
'''
Removes duplicate sequences from a list of Pair objects.
If a Pair has heavy and light chains, both chains must identically match heavy and light chains
from another Pair to be considered a duplicate. If a Pair has only a single chain,
... | python | def deduplicate(pairs, aa=False, ignore_primer_regions=False):
'''
Removes duplicate sequences from a list of Pair objects.
If a Pair has heavy and light chains, both chains must identically match heavy and light chains
from another Pair to be considered a duplicate. If a Pair has only a single chain,
... | [
"def",
"deduplicate",
"(",
"pairs",
",",
"aa",
"=",
"False",
",",
"ignore_primer_regions",
"=",
"False",
")",
":",
"nr_pairs",
"=",
"[",
"]",
"just_pairs",
"=",
"[",
"p",
"for",
"p",
"in",
"pairs",
"if",
"p",
".",
"is_pair",
"]",
"single_chains",
"=",
... | Removes duplicate sequences from a list of Pair objects.
If a Pair has heavy and light chains, both chains must identically match heavy and light chains
from another Pair to be considered a duplicate. If a Pair has only a single chain,
identical matches to that chain will cause the single chain Pair to be ... | [
"Removes",
"duplicate",
"sequences",
"from",
"a",
"list",
"of",
"Pair",
"objects",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L416-L463 |
briney/abutils | abutils/core/pair.py | Pair._refine_v | def _refine_v(seq, species):
'''
Completes the 5' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species.
'''
vgerm = germlines.get_germline(seq['v_gene']['full'], species)
aln = global_alignment(seq['vdj_nt'], vgerm)
... | python | def _refine_v(seq, species):
'''
Completes the 5' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species.
'''
vgerm = germlines.get_germline(seq['v_gene']['full'], species)
aln = global_alignment(seq['vdj_nt'], vgerm)
... | [
"def",
"_refine_v",
"(",
"seq",
",",
"species",
")",
":",
"vgerm",
"=",
"germlines",
".",
"get_germline",
"(",
"seq",
"[",
"'v_gene'",
"]",
"[",
"'full'",
"]",
",",
"species",
")",
"aln",
"=",
"global_alignment",
"(",
"seq",
"[",
"'vdj_nt'",
"]",
",",
... | Completes the 5' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species. | [
"Completes",
"the",
"5",
"end",
"of",
"a",
"a",
"truncated",
"sequence",
"with",
"germline",
"nucleotides",
".",
"Input",
"is",
"a",
"MongoDB",
"dict",
"(",
"seq",
")",
"and",
"the",
"species",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L262-L275 |
briney/abutils | abutils/core/pair.py | Pair._refine_j | def _refine_j(seq, species):
'''
Completes the 3' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species.
'''
jgerm = germlines.get_germline(seq['j_gene']['full'], species)
aln = global_alignment(seq['vdj_nt'], jgerm)
... | python | def _refine_j(seq, species):
'''
Completes the 3' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species.
'''
jgerm = germlines.get_germline(seq['j_gene']['full'], species)
aln = global_alignment(seq['vdj_nt'], jgerm)
... | [
"def",
"_refine_j",
"(",
"seq",
",",
"species",
")",
":",
"jgerm",
"=",
"germlines",
".",
"get_germline",
"(",
"seq",
"[",
"'j_gene'",
"]",
"[",
"'full'",
"]",
",",
"species",
")",
"aln",
"=",
"global_alignment",
"(",
"seq",
"[",
"'vdj_nt'",
"]",
",",
... | Completes the 3' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species. | [
"Completes",
"the",
"3",
"end",
"of",
"a",
"a",
"truncated",
"sequence",
"with",
"germline",
"nucleotides",
".",
"Input",
"is",
"a",
"MongoDB",
"dict",
"(",
"seq",
")",
"and",
"the",
"species",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L278-L291 |
briney/abutils | abutils/core/pair.py | Pair._retranslate | def _retranslate(seq):
'''
Retranslates a nucleotide sequence following refinement.
Input is a Pair sequence (basically a dict of MongoDB output).
'''
if len(seq['vdj_nt']) % 3 != 0:
trunc = len(seq['vdj_nt']) % 3
seq['vdj_nt'] = seq['vdj_nt'][:-trunc]
... | python | def _retranslate(seq):
'''
Retranslates a nucleotide sequence following refinement.
Input is a Pair sequence (basically a dict of MongoDB output).
'''
if len(seq['vdj_nt']) % 3 != 0:
trunc = len(seq['vdj_nt']) % 3
seq['vdj_nt'] = seq['vdj_nt'][:-trunc]
... | [
"def",
"_retranslate",
"(",
"seq",
")",
":",
"if",
"len",
"(",
"seq",
"[",
"'vdj_nt'",
"]",
")",
"%",
"3",
"!=",
"0",
":",
"trunc",
"=",
"len",
"(",
"seq",
"[",
"'vdj_nt'",
"]",
")",
"%",
"3",
"seq",
"[",
"'vdj_nt'",
"]",
"=",
"seq",
"[",
"'v... | Retranslates a nucleotide sequence following refinement.
Input is a Pair sequence (basically a dict of MongoDB output). | [
"Retranslates",
"a",
"nucleotide",
"sequence",
"following",
"refinement",
".",
"Input",
"is",
"a",
"Pair",
"sequence",
"(",
"basically",
"a",
"dict",
"of",
"MongoDB",
"output",
")",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L294-L302 |
briney/abutils | abutils/core/pair.py | Pair.fasta | def fasta(self, key='vdj_nt', append_chain=True):
'''
Returns the sequence pair as a fasta string. If the Pair object contains
both heavy and light chain sequences, both will be returned as a single string.
By default, the fasta string contains the 'vdj_nt' sequence for each chain. To c... | python | def fasta(self, key='vdj_nt', append_chain=True):
'''
Returns the sequence pair as a fasta string. If the Pair object contains
both heavy and light chain sequences, both will be returned as a single string.
By default, the fasta string contains the 'vdj_nt' sequence for each chain. To c... | [
"def",
"fasta",
"(",
"self",
",",
"key",
"=",
"'vdj_nt'",
",",
"append_chain",
"=",
"True",
")",
":",
"fastas",
"=",
"[",
"]",
"for",
"s",
",",
"chain",
"in",
"[",
"(",
"self",
".",
"heavy",
",",
"'heavy'",
")",
",",
"(",
"self",
".",
"light",
... | Returns the sequence pair as a fasta string. If the Pair object contains
both heavy and light chain sequences, both will be returned as a single string.
By default, the fasta string contains the 'vdj_nt' sequence for each chain. To change,
use the <key> option to select an alternate sequence.
... | [
"Returns",
"the",
"sequence",
"pair",
"as",
"a",
"fasta",
"string",
".",
"If",
"the",
"Pair",
"object",
"contains",
"both",
"heavy",
"and",
"light",
"chain",
"sequences",
"both",
"will",
"be",
"returned",
"as",
"a",
"single",
"string",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L305-L325 |
briney/abutils | abutils/utils/color.py | cmap_from_color | def cmap_from_color(color, dark=False):
'''
Generates a matplotlib colormap from a single color.
Colormap will be built, by default, from white to ``color``.
Args:
color: Can be one of several things:
1. Hex code
2. HTML color name
3. RGB tuple
da... | python | def cmap_from_color(color, dark=False):
'''
Generates a matplotlib colormap from a single color.
Colormap will be built, by default, from white to ``color``.
Args:
color: Can be one of several things:
1. Hex code
2. HTML color name
3. RGB tuple
da... | [
"def",
"cmap_from_color",
"(",
"color",
",",
"dark",
"=",
"False",
")",
":",
"if",
"dark",
":",
"return",
"sns",
".",
"dark_palette",
"(",
"color",
",",
"as_cmap",
"=",
"True",
")",
"else",
":",
"return",
"sns",
".",
"light_palette",
"(",
"color",
",",... | Generates a matplotlib colormap from a single color.
Colormap will be built, by default, from white to ``color``.
Args:
color: Can be one of several things:
1. Hex code
2. HTML color name
3. RGB tuple
dark (bool): If ``True``, colormap will be built from ... | [
"Generates",
"a",
"matplotlib",
"colormap",
"from",
"a",
"single",
"color",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/color.py#L44-L70 |
briney/abutils | abutils/utils/color.py | truncate_colormap | def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=256):
"""
Truncates a colormap, such that the new colormap consists of
``cmap[minval:maxval]``.
If maxval is larger than minval, the truncated colormap will be reversed.
Args:
cmap (colormap): Colormap to be truncated
minval (float)... | python | def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=256):
"""
Truncates a colormap, such that the new colormap consists of
``cmap[minval:maxval]``.
If maxval is larger than minval, the truncated colormap will be reversed.
Args:
cmap (colormap): Colormap to be truncated
minval (float)... | [
"def",
"truncate_colormap",
"(",
"cmap",
",",
"minval",
"=",
"0.0",
",",
"maxval",
"=",
"1.0",
",",
"n",
"=",
"256",
")",
":",
"cmap",
"=",
"get_cmap",
"(",
"cmap",
")",
"name",
"=",
"\"%s-trunc-%.2g-%.2g\"",
"%",
"(",
"cmap",
".",
"name",
",",
"minv... | Truncates a colormap, such that the new colormap consists of
``cmap[minval:maxval]``.
If maxval is larger than minval, the truncated colormap will be reversed.
Args:
cmap (colormap): Colormap to be truncated
minval (float): Lower bound. Should be a float betwee 0 and 1.
maxval (float): U... | [
"Truncates",
"a",
"colormap",
"such",
"that",
"the",
"new",
"colormap",
"consists",
"of",
"cmap",
"[",
"minval",
":",
"maxval",
"]",
"."
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/color.py#L91-L117 |
briney/abutils | abutils/utils/color.py | stack_colormap | def stack_colormap(lower, upper, n=256):
"""
Stacks two colormaps (``lower`` and ``upper``) such that
low half -> ``lower`` colors, high half -> ``upper`` colors
Args:
lower (colormap): colormap for the lower half of the stacked colormap.
upper (colormap): colormap for the upper half of the... | python | def stack_colormap(lower, upper, n=256):
"""
Stacks two colormaps (``lower`` and ``upper``) such that
low half -> ``lower`` colors, high half -> ``upper`` colors
Args:
lower (colormap): colormap for the lower half of the stacked colormap.
upper (colormap): colormap for the upper half of the... | [
"def",
"stack_colormap",
"(",
"lower",
",",
"upper",
",",
"n",
"=",
"256",
")",
":",
"A",
"=",
"get_cmap",
"(",
"lower",
")",
"B",
"=",
"get_cmap",
"(",
"upper",
")",
"name",
"=",
"\"%s-%s\"",
"%",
"(",
"A",
".",
"name",
",",
"B",
".",
"name",
... | Stacks two colormaps (``lower`` and ``upper``) such that
low half -> ``lower`` colors, high half -> ``upper`` colors
Args:
lower (colormap): colormap for the lower half of the stacked colormap.
upper (colormap): colormap for the upper half of the stacked colormap.
n (int): Number of colormap ... | [
"Stacks",
"two",
"colormaps",
"(",
"lower",
"and",
"upper",
")",
"such",
"that",
"low",
"half",
"-",
">",
"lower",
"colors",
"high",
"half",
"-",
">",
"upper",
"colors"
] | train | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/color.py#L120-L137 |
AtteqCom/zsl | src/zsl/utils/warnings.py | deprecated | def deprecated(func):
"""This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used."""
@functools.wraps(func)
def decorated(*args, **kwargs):
warnings.warn_explicit(
"Call to deprecated function {}.... | python | def deprecated(func):
"""This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used."""
@functools.wraps(func)
def decorated(*args, **kwargs):
warnings.warn_explicit(
"Call to deprecated function {}.... | [
"def",
"deprecated",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn_explicit",
"(",
"\"Call to deprecated function {}.\"",
".",
"forma... | This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used. | [
"This",
"is",
"a",
"decorator",
"which",
"can",
"be",
"used",
"to",
"mark",
"functions",
"as",
"deprecated",
".",
"It",
"will",
"result",
"in",
"a",
"warning",
"being",
"emitted",
"when",
"the",
"function",
"is",
"used",
"."
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/warnings.py#L7-L22 |
AtteqCom/zsl | src/zsl/db/helpers/nested.py | nested_model | def nested_model(model, nested_fields):
"""
Return :class:`zsl.db.model.app_model import AppModel` with the nested
models attached. ``nested_fields`` can be a simple list as model
fields, or it can be a tree definition in dict with leafs as keys with
``None`` value
"""
# type... | python | def nested_model(model, nested_fields):
"""
Return :class:`zsl.db.model.app_model import AppModel` with the nested
models attached. ``nested_fields`` can be a simple list as model
fields, or it can be a tree definition in dict with leafs as keys with
``None`` value
"""
# type... | [
"def",
"nested_model",
"(",
"model",
",",
"nested_fields",
")",
":",
"# type: (ModelBase, Any)->Optional[AppModel]",
"if",
"model",
"is",
"None",
":",
"return",
"None",
"app_model",
"=",
"model",
".",
"get_app_model",
"(",
")",
"is_dict",
"=",
"isinstance",
"(",
... | Return :class:`zsl.db.model.app_model import AppModel` with the nested
models attached. ``nested_fields`` can be a simple list as model
fields, or it can be a tree definition in dict with leafs as keys with
``None`` value | [
"Return",
":",
"class",
":",
"zsl",
".",
"db",
".",
"model",
".",
"app_model",
"import",
"AppModel",
"with",
"the",
"nested",
"models",
"attached",
".",
"nested_fields",
"can",
"be",
"a",
"simple",
"list",
"as",
"model",
"fields",
"or",
"it",
"can",
"be"... | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/db/helpers/nested.py#L25-L51 |
datacamp/protowhat | protowhat/checks/check_funcs.py | check_node | def check_node(
state,
name,
index=0,
missing_msg="Check the {ast_path}. Could not find the {index}{node_name}.",
priority=None,
):
"""Select a node from abstract syntax tree (AST), using its name and index position.
Args:
state: State instance describing student and solution code. ... | python | def check_node(
state,
name,
index=0,
missing_msg="Check the {ast_path}. Could not find the {index}{node_name}.",
priority=None,
):
"""Select a node from abstract syntax tree (AST), using its name and index position.
Args:
state: State instance describing student and solution code. ... | [
"def",
"check_node",
"(",
"state",
",",
"name",
",",
"index",
"=",
"0",
",",
"missing_msg",
"=",
"\"Check the {ast_path}. Could not find the {index}{node_name}.\"",
",",
"priority",
"=",
"None",
",",
")",
":",
"df",
"=",
"partial",
"(",
"state",
".",
"ast_dispat... | Select a node from abstract syntax tree (AST), using its name and index position.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
name : the name of the abstract syntax tree node to find.
index: the position of that node (see below for det... | [
"Select",
"a",
"node",
"from",
"abstract",
"syntax",
"tree",
"(",
"AST",
")",
"using",
"its",
"name",
"and",
"index",
"position",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_funcs.py#L37-L101 |
datacamp/protowhat | protowhat/checks/check_funcs.py | check_edge | def check_edge(
state,
name,
index=0,
missing_msg="Check the {ast_path}. Could not find the {index}{field_name}.",
):
"""Select an attribute from an abstract syntax tree (AST) node, using the attribute name.
Args:
state: State instance describing student and solution code. Can be omitte... | python | def check_edge(
state,
name,
index=0,
missing_msg="Check the {ast_path}. Could not find the {index}{field_name}.",
):
"""Select an attribute from an abstract syntax tree (AST) node, using the attribute name.
Args:
state: State instance describing student and solution code. Can be omitte... | [
"def",
"check_edge",
"(",
"state",
",",
"name",
",",
"index",
"=",
"0",
",",
"missing_msg",
"=",
"\"Check the {ast_path}. Could not find the {index}{field_name}.\"",
",",
")",
":",
"try",
":",
"sol_attr",
"=",
"getattr",
"(",
"state",
".",
"solution_ast",
",",
"... | Select an attribute from an abstract syntax tree (AST) node, using the attribute name.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
name: the name of the attribute to select from current AST node.
index: entry to get from a list field. ... | [
"Select",
"an",
"attribute",
"from",
"an",
"abstract",
"syntax",
"tree",
"(",
"AST",
")",
"node",
"using",
"the",
"attribute",
"name",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_funcs.py#L105-L166 |
datacamp/protowhat | protowhat/checks/check_funcs.py | has_code | def has_code(
state,
text,
incorrect_msg="Check the {ast_path}. The checker expected to find {text}.",
fixed=False,
):
"""Test whether the student code contains text.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
text : text ... | python | def has_code(
state,
text,
incorrect_msg="Check the {ast_path}. The checker expected to find {text}.",
fixed=False,
):
"""Test whether the student code contains text.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
text : text ... | [
"def",
"has_code",
"(",
"state",
",",
"text",
",",
"incorrect_msg",
"=",
"\"Check the {ast_path}. The checker expected to find {text}.\"",
",",
"fixed",
"=",
"False",
",",
")",
":",
"stu_ast",
"=",
"state",
".",
"student_ast",
"stu_code",
"=",
"state",
".",
"stude... | Test whether the student code contains text.
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
text : text that student code must contain. Can be a regex pattern or a simple string.
incorrect_msg: feedback message if text is not in student c... | [
"Test",
"whether",
"the",
"student",
"code",
"contains",
"text",
"."
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_funcs.py#L172-L243 |
datacamp/protowhat | protowhat/checks/check_funcs.py | has_equal_ast | def has_equal_ast(
state,
incorrect_msg="Check the {ast_path}. {extra}",
sql=None,
start=["expression", "subquery", "sql_script"][0],
exact=None,
):
"""Test whether the student and solution code have identical AST representations
Args:
state: State instance describing student and so... | python | def has_equal_ast(
state,
incorrect_msg="Check the {ast_path}. {extra}",
sql=None,
start=["expression", "subquery", "sql_script"][0],
exact=None,
):
"""Test whether the student and solution code have identical AST representations
Args:
state: State instance describing student and so... | [
"def",
"has_equal_ast",
"(",
"state",
",",
"incorrect_msg",
"=",
"\"Check the {ast_path}. {extra}\"",
",",
"sql",
"=",
"None",
",",
"start",
"=",
"[",
"\"expression\"",
",",
"\"subquery\"",
",",
"\"sql_script\"",
"]",
"[",
"0",
"]",
",",
"exact",
"=",
"None",
... | Test whether the student and solution code have identical AST representations
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
incorrect_msg: feedback message if student and solution ASTs don't match
sql : optional code to use instead of t... | [
"Test",
"whether",
"the",
"student",
"and",
"solution",
"code",
"have",
"identical",
"AST",
"representations"
] | train | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_funcs.py#L247-L319 |
AtteqCom/zsl | src/zsl/utils/cache_helper.py | cache_model | def cache_model(key_params, timeout='default'):
"""
Caching decorator for app models in task.perform
"""
def decorator_fn(fn):
return CacheModelDecorator().decorate(key_params, timeout, fn)
return decorator_fn | python | def cache_model(key_params, timeout='default'):
"""
Caching decorator for app models in task.perform
"""
def decorator_fn(fn):
return CacheModelDecorator().decorate(key_params, timeout, fn)
return decorator_fn | [
"def",
"cache_model",
"(",
"key_params",
",",
"timeout",
"=",
"'default'",
")",
":",
"def",
"decorator_fn",
"(",
"fn",
")",
":",
"return",
"CacheModelDecorator",
"(",
")",
".",
"decorate",
"(",
"key_params",
",",
"timeout",
",",
"fn",
")",
"return",
"decor... | Caching decorator for app models in task.perform | [
"Caching",
"decorator",
"for",
"app",
"models",
"in",
"task",
".",
"perform"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/cache_helper.py#L126-L133 |
AtteqCom/zsl | src/zsl/utils/cache_helper.py | cache_page | def cache_page(key_params, timeout='default'):
"""
Cache a page (slice) of a list of AppModels
"""
def decorator_fn(fn):
d = CachePageDecorator()
return d.decorate(key_params, timeout, fn)
return decorator_fn | python | def cache_page(key_params, timeout='default'):
"""
Cache a page (slice) of a list of AppModels
"""
def decorator_fn(fn):
d = CachePageDecorator()
return d.decorate(key_params, timeout, fn)
return decorator_fn | [
"def",
"cache_page",
"(",
"key_params",
",",
"timeout",
"=",
"'default'",
")",
":",
"def",
"decorator_fn",
"(",
"fn",
")",
":",
"d",
"=",
"CachePageDecorator",
"(",
")",
"return",
"d",
".",
"decorate",
"(",
"key_params",
",",
"timeout",
",",
"fn",
")",
... | Cache a page (slice) of a list of AppModels | [
"Cache",
"a",
"page",
"(",
"slice",
")",
"of",
"a",
"list",
"of",
"AppModels"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/cache_helper.py#L158-L166 |
AtteqCom/zsl | src/zsl/utils/cache_helper.py | create_key_for_data | def create_key_for_data(prefix, data, key_params):
"""
From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator)
"""
d = data.get_data()
values = []
for k in key_params:
if k in d and type(d[k]) is list:
values.append("{0}:{1}".f... | python | def create_key_for_data(prefix, data, key_params):
"""
From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator)
"""
d = data.get_data()
values = []
for k in key_params:
if k in d and type(d[k]) is list:
values.append("{0}:{1}".f... | [
"def",
"create_key_for_data",
"(",
"prefix",
",",
"data",
",",
"key_params",
")",
":",
"d",
"=",
"data",
".",
"get_data",
"(",
")",
"values",
"=",
"[",
"]",
"for",
"k",
"in",
"key_params",
":",
"if",
"k",
"in",
"d",
"and",
"type",
"(",
"d",
"[",
... | From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator) | [
"From",
"data",
"params",
"in",
"task",
"create",
"corresponding",
"key",
"with",
"help",
"of",
"key_params",
"(",
"defined",
"in",
"decorator",
")"
] | train | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/cache_helper.py#L181-L194 |
opencivicdata/pupa | pupa/importers/base.py | omnihash | def omnihash(obj):
""" recursively hash unhashable objects """
if isinstance(obj, set):
return hash(frozenset(omnihash(e) for e in obj))
elif isinstance(obj, (tuple, list)):
return hash(tuple(omnihash(e) for e in obj))
elif isinstance(obj, dict):
return hash(frozenset((k, omnihas... | python | def omnihash(obj):
""" recursively hash unhashable objects """
if isinstance(obj, set):
return hash(frozenset(omnihash(e) for e in obj))
elif isinstance(obj, (tuple, list)):
return hash(tuple(omnihash(e) for e in obj))
elif isinstance(obj, dict):
return hash(frozenset((k, omnihas... | [
"def",
"omnihash",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"set",
")",
":",
"return",
"hash",
"(",
"frozenset",
"(",
"omnihash",
"(",
"e",
")",
"for",
"e",
"in",
"obj",
")",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"(",
"tup... | recursively hash unhashable objects | [
"recursively",
"hash",
"unhashable",
"objects"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L18-L27 |
opencivicdata/pupa | pupa/importers/base.py | items_differ | def items_differ(jsonitems, dbitems, subfield_dict):
""" check whether or not jsonitems and dbitems differ """
# short circuit common cases
if len(jsonitems) == len(dbitems) == 0:
# both are empty
return False
elif len(jsonitems) != len(dbitems):
# if lengths differ, they're def... | python | def items_differ(jsonitems, dbitems, subfield_dict):
""" check whether or not jsonitems and dbitems differ """
# short circuit common cases
if len(jsonitems) == len(dbitems) == 0:
# both are empty
return False
elif len(jsonitems) != len(dbitems):
# if lengths differ, they're def... | [
"def",
"items_differ",
"(",
"jsonitems",
",",
"dbitems",
",",
"subfield_dict",
")",
":",
"# short circuit common cases",
"if",
"len",
"(",
"jsonitems",
")",
"==",
"len",
"(",
"dbitems",
")",
"==",
"0",
":",
"# both are empty",
"return",
"False",
"elif",
"len",... | check whether or not jsonitems and dbitems differ | [
"check",
"whether",
"or",
"not",
"jsonitems",
"and",
"dbitems",
"differ"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L30-L81 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter.resolve_json_id | def resolve_json_id(self, json_id, allow_no_match=False):
"""
Given an id found in scraped JSON, return a DB id for the object.
params:
json_id: id from json
allow_no_match: just return None if id can't be resolved
returns:
... | python | def resolve_json_id(self, json_id, allow_no_match=False):
"""
Given an id found in scraped JSON, return a DB id for the object.
params:
json_id: id from json
allow_no_match: just return None if id can't be resolved
returns:
... | [
"def",
"resolve_json_id",
"(",
"self",
",",
"json_id",
",",
"allow_no_match",
"=",
"False",
")",
":",
"if",
"not",
"json_id",
":",
"return",
"None",
"if",
"json_id",
".",
"startswith",
"(",
"'~'",
")",
":",
"# keep caches of all the pseudo-ids to avoid doing 1000s... | Given an id found in scraped JSON, return a DB id for the object.
params:
json_id: id from json
allow_no_match: just return None if id can't be resolved
returns:
database id
raises:
ValueError if id couldn't be... | [
"Given",
"an",
"id",
"found",
"in",
"scraped",
"JSON",
"return",
"a",
"DB",
"id",
"for",
"the",
"object",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L130-L185 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter.import_directory | def import_directory(self, datadir):
""" import a JSON directory into the database """
def json_stream():
# load all json, mapped by json_id
for fname in glob.glob(os.path.join(datadir, self._type + '_*.json')):
with open(fname) as f:
yield js... | python | def import_directory(self, datadir):
""" import a JSON directory into the database """
def json_stream():
# load all json, mapped by json_id
for fname in glob.glob(os.path.join(datadir, self._type + '_*.json')):
with open(fname) as f:
yield js... | [
"def",
"import_directory",
"(",
"self",
",",
"datadir",
")",
":",
"def",
"json_stream",
"(",
")",
":",
"# load all json, mapped by json_id",
"for",
"fname",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"datadir",
",",
"self",
".",
... | import a JSON directory into the database | [
"import",
"a",
"JSON",
"directory",
"into",
"the",
"database"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L187-L196 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter._prepare_imports | def _prepare_imports(self, dicts):
""" filters the import stream to remove duplicates
also serves as a good place to override if anything special has to be done to the
order of the import stream (see OrganizationImporter)
"""
# hash(json): id
seen_hashes = {}
f... | python | def _prepare_imports(self, dicts):
""" filters the import stream to remove duplicates
also serves as a good place to override if anything special has to be done to the
order of the import stream (see OrganizationImporter)
"""
# hash(json): id
seen_hashes = {}
f... | [
"def",
"_prepare_imports",
"(",
"self",
",",
"dicts",
")",
":",
"# hash(json): id",
"seen_hashes",
"=",
"{",
"}",
"for",
"data",
"in",
"dicts",
":",
"json_id",
"=",
"data",
".",
"pop",
"(",
"'_id'",
")",
"# map duplicates (using omnihash to tell if json dicts are ... | filters the import stream to remove duplicates
also serves as a good place to override if anything special has to be done to the
order of the import stream (see OrganizationImporter) | [
"filters",
"the",
"import",
"stream",
"to",
"remove",
"duplicates"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L198-L217 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter.import_data | def import_data(self, data_items):
""" import a bunch of dicts together """
# keep counts of all actions
record = {
'insert': 0, 'update': 0, 'noop': 0,
'start': utcnow(),
'records': {
'insert': [],
'update': [],
... | python | def import_data(self, data_items):
""" import a bunch of dicts together """
# keep counts of all actions
record = {
'insert': 0, 'update': 0, 'noop': 0,
'start': utcnow(),
'records': {
'insert': [],
'update': [],
... | [
"def",
"import_data",
"(",
"self",
",",
"data_items",
")",
":",
"# keep counts of all actions",
"record",
"=",
"{",
"'insert'",
":",
"0",
",",
"'update'",
":",
"0",
",",
"'noop'",
":",
"0",
",",
"'start'",
":",
"utcnow",
"(",
")",
",",
"'records'",
":",
... | import a bunch of dicts together | [
"import",
"a",
"bunch",
"of",
"dicts",
"together"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L219-L243 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter.import_item | def import_item(self, data):
""" function used by import_data """
what = 'noop'
# remove the JSON _id (may still be there if called directly)
data.pop('_id', None)
# add fields/etc.
data = self.apply_transformers(data)
data = self.prepare_for_db(data)
t... | python | def import_item(self, data):
""" function used by import_data """
what = 'noop'
# remove the JSON _id (may still be there if called directly)
data.pop('_id', None)
# add fields/etc.
data = self.apply_transformers(data)
data = self.prepare_for_db(data)
t... | [
"def",
"import_item",
"(",
"self",
",",
"data",
")",
":",
"what",
"=",
"'noop'",
"# remove the JSON _id (may still be there if called directly)",
"data",
".",
"pop",
"(",
"'_id'",
",",
"None",
")",
"# add fields/etc.",
"data",
"=",
"self",
".",
"apply_transformers",... | function used by import_data | [
"function",
"used",
"by",
"import_data"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L245-L301 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter._update_related | def _update_related(self, obj, related, subfield_dict):
"""
update DB objects related to a base object
obj: a base object to create related
related: dict mapping field names to lists of related objects
subfield_list: where to get the next layer of s... | python | def _update_related(self, obj, related, subfield_dict):
"""
update DB objects related to a base object
obj: a base object to create related
related: dict mapping field names to lists of related objects
subfield_list: where to get the next layer of s... | [
"def",
"_update_related",
"(",
"self",
",",
"obj",
",",
"related",
",",
"subfield_dict",
")",
":",
"# keep track of whether or not anything was updated",
"updated",
"=",
"False",
"# for each related field - check if there are differences",
"for",
"field",
",",
"items",
"in"... | update DB objects related to a base object
obj: a base object to create related
related: dict mapping field names to lists of related objects
subfield_list: where to get the next layer of subfields | [
"update",
"DB",
"objects",
"related",
"to",
"a",
"base",
"object",
"obj",
":",
"a",
"base",
"object",
"to",
"create",
"related",
"related",
":",
"dict",
"mapping",
"field",
"names",
"to",
"lists",
"of",
"related",
"objects",
"subfield_list",
":",
"where",
... | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L303-L369 |
opencivicdata/pupa | pupa/importers/base.py | BaseImporter._create_related | def _create_related(self, obj, related, subfield_dict):
"""
create DB objects related to a base object
obj: a base object to create related
related: dict mapping field names to lists of related objects
subfield_list: where to get the next layer of s... | python | def _create_related(self, obj, related, subfield_dict):
"""
create DB objects related to a base object
obj: a base object to create related
related: dict mapping field names to lists of related objects
subfield_list: where to get the next layer of s... | [
"def",
"_create_related",
"(",
"self",
",",
"obj",
",",
"related",
",",
"subfield_dict",
")",
":",
"for",
"field",
",",
"items",
"in",
"related",
".",
"items",
"(",
")",
":",
"subobjects",
"=",
"[",
"]",
"all_subrelated",
"=",
"[",
"]",
"Subtype",
",",... | create DB objects related to a base object
obj: a base object to create related
related: dict mapping field names to lists of related objects
subfield_list: where to get the next layer of subfields | [
"create",
"DB",
"objects",
"related",
"to",
"a",
"base",
"object",
"obj",
":",
"a",
"base",
"object",
"to",
"create",
"related",
"related",
":",
"dict",
"mapping",
"field",
"names",
"to",
"lists",
"of",
"related",
"objects",
"subfield_list",
":",
"where",
... | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/base.py#L371-L407 |
opencivicdata/pupa | pupa/utils/topsort.py | Network.add_edge | def add_edge(self, fro, to):
"""
When doing topological sorting, the semantics of the edge mean that
the depedency runs from the parent to the child - which is to say that
the parent is required to be sorted *before* the child.
[ FROM ] ------> [ TO ]
Committee... | python | def add_edge(self, fro, to):
"""
When doing topological sorting, the semantics of the edge mean that
the depedency runs from the parent to the child - which is to say that
the parent is required to be sorted *before* the child.
[ FROM ] ------> [ TO ]
Committee... | [
"def",
"add_edge",
"(",
"self",
",",
"fro",
",",
"to",
")",
":",
"self",
".",
"add_node",
"(",
"fro",
")",
"self",
".",
"add_node",
"(",
"to",
")",
"self",
".",
"edges",
"[",
"fro",
"]",
".",
"add",
"(",
"to",
")"
] | When doing topological sorting, the semantics of the edge mean that
the depedency runs from the parent to the child - which is to say that
the parent is required to be sorted *before* the child.
[ FROM ] ------> [ TO ]
Committee on Finance -> Subcommittee of the Finance Commit... | [
"When",
"doing",
"topological",
"sorting",
"the",
"semantics",
"of",
"the",
"edge",
"mean",
"that",
"the",
"depedency",
"runs",
"from",
"the",
"parent",
"to",
"the",
"child",
"-",
"which",
"is",
"to",
"say",
"that",
"the",
"parent",
"is",
"required",
"to",... | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/utils/topsort.py#L31-L43 |
opencivicdata/pupa | pupa/utils/topsort.py | Network.leaf_nodes | def leaf_nodes(self):
"""
Return an interable of nodes with no edges pointing at them. This is
helpful to find all nodes without dependencies.
"""
# Now contains all nodes that contain dependencies.
deps = {item for sublist in self.edges.values() for item in sublist}
... | python | def leaf_nodes(self):
"""
Return an interable of nodes with no edges pointing at them. This is
helpful to find all nodes without dependencies.
"""
# Now contains all nodes that contain dependencies.
deps = {item for sublist in self.edges.values() for item in sublist}
... | [
"def",
"leaf_nodes",
"(",
"self",
")",
":",
"# Now contains all nodes that contain dependencies.",
"deps",
"=",
"{",
"item",
"for",
"sublist",
"in",
"self",
".",
"edges",
".",
"values",
"(",
")",
"for",
"item",
"in",
"sublist",
"}",
"# contains all nodes *without*... | Return an interable of nodes with no edges pointing at them. This is
helpful to find all nodes without dependencies. | [
"Return",
"an",
"interable",
"of",
"nodes",
"with",
"no",
"edges",
"pointing",
"at",
"them",
".",
"This",
"is",
"helpful",
"to",
"find",
"all",
"nodes",
"without",
"dependencies",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/utils/topsort.py#L45-L53 |
opencivicdata/pupa | pupa/utils/topsort.py | Network.prune_node | def prune_node(self, node, remove_backrefs=False):
"""
remove node `node` from the network (including any edges that may
have been pointing at `node`).
"""
if not remove_backrefs:
for fro, connections in self.edges.items():
if node in self.edges[fro]:
... | python | def prune_node(self, node, remove_backrefs=False):
"""
remove node `node` from the network (including any edges that may
have been pointing at `node`).
"""
if not remove_backrefs:
for fro, connections in self.edges.items():
if node in self.edges[fro]:
... | [
"def",
"prune_node",
"(",
"self",
",",
"node",
",",
"remove_backrefs",
"=",
"False",
")",
":",
"if",
"not",
"remove_backrefs",
":",
"for",
"fro",
",",
"connections",
"in",
"self",
".",
"edges",
".",
"items",
"(",
")",
":",
"if",
"node",
"in",
"self",
... | remove node `node` from the network (including any edges that may
have been pointing at `node`). | [
"remove",
"node",
"node",
"from",
"the",
"network",
"(",
"including",
"any",
"edges",
"that",
"may",
"have",
"been",
"pointing",
"at",
"node",
")",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/utils/topsort.py#L55-L78 |
opencivicdata/pupa | pupa/utils/topsort.py | Network.sort | def sort(self):
"""
Return an iterable of nodes, toplogically sorted to correctly import
dependencies before leaf nodes.
"""
while self.nodes:
iterated = False
for node in self.leaf_nodes():
iterated = True
self.prune_node(n... | python | def sort(self):
"""
Return an iterable of nodes, toplogically sorted to correctly import
dependencies before leaf nodes.
"""
while self.nodes:
iterated = False
for node in self.leaf_nodes():
iterated = True
self.prune_node(n... | [
"def",
"sort",
"(",
"self",
")",
":",
"while",
"self",
".",
"nodes",
":",
"iterated",
"=",
"False",
"for",
"node",
"in",
"self",
".",
"leaf_nodes",
"(",
")",
":",
"iterated",
"=",
"True",
"self",
".",
"prune_node",
"(",
"node",
")",
"yield",
"node",
... | Return an iterable of nodes, toplogically sorted to correctly import
dependencies before leaf nodes. | [
"Return",
"an",
"iterable",
"of",
"nodes",
"toplogically",
"sorted",
"to",
"correctly",
"import",
"dependencies",
"before",
"leaf",
"nodes",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/utils/topsort.py#L80-L92 |
opencivicdata/pupa | pupa/utils/topsort.py | Network.dot | def dot(self):
"""
Return a buffer that represents something dot(1) can render.
"""
buff = "digraph graphname {"
for fro in self.edges:
for to in self.edges[fro]:
buff += "%s -> %s;" % (fro, to)
buff += "}"
return buff | python | def dot(self):
"""
Return a buffer that represents something dot(1) can render.
"""
buff = "digraph graphname {"
for fro in self.edges:
for to in self.edges[fro]:
buff += "%s -> %s;" % (fro, to)
buff += "}"
return buff | [
"def",
"dot",
"(",
"self",
")",
":",
"buff",
"=",
"\"digraph graphname {\"",
"for",
"fro",
"in",
"self",
".",
"edges",
":",
"for",
"to",
"in",
"self",
".",
"edges",
"[",
"fro",
"]",
":",
"buff",
"+=",
"\"%s -> %s;\"",
"%",
"(",
"fro",
",",
"to",
")... | Return a buffer that represents something dot(1) can render. | [
"Return",
"a",
"buffer",
"that",
"represents",
"something",
"dot",
"(",
"1",
")",
"can",
"render",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/utils/topsort.py#L94-L103 |
opencivicdata/pupa | pupa/utils/topsort.py | Network.cycles | def cycles(self):
"""
Fairly expensive cycle detection algorithm. This method
will return the shortest unique cycles that were detected.
Debug usage may look something like:
print("The following cycles were found:")
for cycle in network.cycles():
print(" ... | python | def cycles(self):
"""
Fairly expensive cycle detection algorithm. This method
will return the shortest unique cycles that were detected.
Debug usage may look something like:
print("The following cycles were found:")
for cycle in network.cycles():
print(" ... | [
"def",
"cycles",
"(",
"self",
")",
":",
"def",
"walk_node",
"(",
"node",
",",
"seen",
")",
":",
"\"\"\"\n Walk each top-level node we know about, and recurse\n along the graph.\n \"\"\"",
"if",
"node",
"in",
"seen",
":",
"yield",
"(",
"nod... | Fairly expensive cycle detection algorithm. This method
will return the shortest unique cycles that were detected.
Debug usage may look something like:
print("The following cycles were found:")
for cycle in network.cycles():
print(" ", " -> ".join(cycle)) | [
"Fairly",
"expensive",
"cycle",
"detection",
"algorithm",
".",
"This",
"method",
"will",
"return",
"the",
"shortest",
"unique",
"cycles",
"that",
"were",
"detected",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/utils/topsort.py#L105-L145 |
opencivicdata/pupa | pupa/scrape/popolo.py | pseudo_organization | def pseudo_organization(organization, classification, default=None):
""" helper for setting an appropriate ID for organizations """
if organization and classification:
raise ScrapeValueError('cannot specify both classification and organization')
elif classification:
return _make_pseudo_id(cl... | python | def pseudo_organization(organization, classification, default=None):
""" helper for setting an appropriate ID for organizations """
if organization and classification:
raise ScrapeValueError('cannot specify both classification and organization')
elif classification:
return _make_pseudo_id(cl... | [
"def",
"pseudo_organization",
"(",
"organization",
",",
"classification",
",",
"default",
"=",
"None",
")",
":",
"if",
"organization",
"and",
"classification",
":",
"raise",
"ScrapeValueError",
"(",
"'cannot specify both classification and organization'",
")",
"elif",
"... | helper for setting an appropriate ID for organizations | [
"helper",
"for",
"setting",
"an",
"appropriate",
"ID",
"for",
"organizations"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/scrape/popolo.py#L214-L230 |
opencivicdata/pupa | pupa/scrape/popolo.py | Person.add_membership | def add_membership(self, name_or_org, role='member', **kwargs):
"""
add a membership in an organization and return the membership
object in case there are more details to add
"""
if isinstance(name_or_org, Organization):
membership = Membership(person_id=self.... | python | def add_membership(self, name_or_org, role='member', **kwargs):
"""
add a membership in an organization and return the membership
object in case there are more details to add
"""
if isinstance(name_or_org, Organization):
membership = Membership(person_id=self.... | [
"def",
"add_membership",
"(",
"self",
",",
"name_or_org",
",",
"role",
"=",
"'member'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"name_or_org",
",",
"Organization",
")",
":",
"membership",
"=",
"Membership",
"(",
"person_id",
"=",
"self"... | add a membership in an organization and return the membership
object in case there are more details to add | [
"add",
"a",
"membership",
"in",
"an",
"organization",
"and",
"return",
"the",
"membership",
"object",
"in",
"case",
"there",
"are",
"more",
"details",
"to",
"add"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/scrape/popolo.py#L104-L120 |
opencivicdata/pupa | pupa/scrape/base.py | Scraper.save_object | def save_object(self, obj):
"""
Save object to disk as JSON.
Generally shouldn't be called directly.
"""
obj.pre_save(self.jurisdiction.jurisdiction_id)
filename = '{0}_{1}.json'.format(obj._type, obj._id).replace('/', '-')
self.info('save %s %s as %s',... | python | def save_object(self, obj):
"""
Save object to disk as JSON.
Generally shouldn't be called directly.
"""
obj.pre_save(self.jurisdiction.jurisdiction_id)
filename = '{0}_{1}.json'.format(obj._type, obj._id).replace('/', '-')
self.info('save %s %s as %s',... | [
"def",
"save_object",
"(",
"self",
",",
"obj",
")",
":",
"obj",
".",
"pre_save",
"(",
"self",
".",
"jurisdiction",
".",
"jurisdiction_id",
")",
"filename",
"=",
"'{0}_{1}.json'",
".",
"format",
"(",
"obj",
".",
"_type",
",",
"obj",
".",
"_id",
")",
"."... | Save object to disk as JSON.
Generally shouldn't be called directly. | [
"Save",
"object",
"to",
"disk",
"as",
"JSON",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/scrape/base.py#L76-L106 |
opencivicdata/pupa | pupa/scrape/base.py | BaseModel.validate | def validate(self, schema=None):
"""
Validate that we have a valid object.
On error, this will raise a `ScrapeValueError`
This also expects that the schemas assume that omitting required
in the schema asserts the field is optional, not required. This is
due to upstream ... | python | def validate(self, schema=None):
"""
Validate that we have a valid object.
On error, this will raise a `ScrapeValueError`
This also expects that the schemas assume that omitting required
in the schema asserts the field is optional, not required. This is
due to upstream ... | [
"def",
"validate",
"(",
"self",
",",
"schema",
"=",
"None",
")",
":",
"if",
"schema",
"is",
"None",
":",
"schema",
"=",
"self",
".",
"_schema",
"type_checker",
"=",
"Draft3Validator",
".",
"TYPE_CHECKER",
".",
"redefine",
"(",
"\"datetime\"",
",",
"lambda"... | Validate that we have a valid object.
On error, this will raise a `ScrapeValueError`
This also expects that the schemas assume that omitting required
in the schema asserts the field is optional, not required. This is
due to upstream schemas being in JSON Schema v3, and not validictory'... | [
"Validate",
"that",
"we",
"have",
"a",
"valid",
"object",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/scrape/base.py#L171-L196 |
opencivicdata/pupa | pupa/scrape/base.py | SourceMixin.add_source | def add_source(self, url, *, note=''):
""" Add a source URL from which data was collected """
new = {'url': url, 'note': note}
self.sources.append(new) | python | def add_source(self, url, *, note=''):
""" Add a source URL from which data was collected """
new = {'url': url, 'note': note}
self.sources.append(new) | [
"def",
"add_source",
"(",
"self",
",",
"url",
",",
"*",
",",
"note",
"=",
"''",
")",
":",
"new",
"=",
"{",
"'url'",
":",
"url",
",",
"'note'",
":",
"note",
"}",
"self",
".",
"sources",
".",
"append",
"(",
"new",
")"
] | Add a source URL from which data was collected | [
"Add",
"a",
"source",
"URL",
"from",
"which",
"data",
"was",
"collected"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/scrape/base.py#L222-L225 |
molpopgen/fwdpy11 | fwdpy11/_evolve_genomes.py | evolve_genomes | def evolve_genomes(rng, pop, params, recorder=None):
"""
Evolve a population without tree sequence recordings. In other words,
complete genomes must be simulated and tracked.
:param rng: random number generator
:type rng: :class:`fwdpy11.GSLrng`
:param pop: A population
:type pop: :class:`... | python | def evolve_genomes(rng, pop, params, recorder=None):
"""
Evolve a population without tree sequence recordings. In other words,
complete genomes must be simulated and tracked.
:param rng: random number generator
:type rng: :class:`fwdpy11.GSLrng`
:param pop: A population
:type pop: :class:`... | [
"def",
"evolve_genomes",
"(",
"rng",
",",
"pop",
",",
"params",
",",
"recorder",
"=",
"None",
")",
":",
"import",
"warnings",
"# Test parameters while suppressing warnings",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",... | Evolve a population without tree sequence recordings. In other words,
complete genomes must be simulated and tracked.
:param rng: random number generator
:type rng: :class:`fwdpy11.GSLrng`
:param pop: A population
:type pop: :class:`fwdpy11.DiploidPopulation`
:param params: simulation paramete... | [
"Evolve",
"a",
"population",
"without",
"tree",
"sequence",
"recordings",
".",
"In",
"other",
"words",
"complete",
"genomes",
"must",
"be",
"simulated",
"and",
"tracked",
"."
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/_evolve_genomes.py#L21-L61 |
molpopgen/fwdpy11 | fwdpy11/_tables_to_tskit.py | _initializeIndividualTable | def _initializeIndividualTable(pop, tc):
"""
Returns node ID -> individual map
"""
# First, alive individuals:
individal_nodes = {}
for i in range(pop.N):
individal_nodes[2*i] = i
individal_nodes[2*i+1] = i
metadata_strings = _generate_individual_metadata(pop.diploid_metadata... | python | def _initializeIndividualTable(pop, tc):
"""
Returns node ID -> individual map
"""
# First, alive individuals:
individal_nodes = {}
for i in range(pop.N):
individal_nodes[2*i] = i
individal_nodes[2*i+1] = i
metadata_strings = _generate_individual_metadata(pop.diploid_metadata... | [
"def",
"_initializeIndividualTable",
"(",
"pop",
",",
"tc",
")",
":",
"# First, alive individuals:",
"individal_nodes",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"pop",
".",
"N",
")",
":",
"individal_nodes",
"[",
"2",
"*",
"i",
"]",
"=",
"i",
"indiv... | Returns node ID -> individual map | [
"Returns",
"node",
"ID",
"-",
">",
"individual",
"map"
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/_tables_to_tskit.py#L65-L90 |
molpopgen/fwdpy11 | fwdpy11/_tables_to_tskit.py | dump_tables_to_tskit | def dump_tables_to_tskit(pop):
"""
Converts fwdpy11.TableCollection to an
tskit.TreeSequence
"""
node_view = np.array(pop.tables.nodes, copy=True)
node_view['time'] -= node_view['time'].max()
node_view['time'][np.where(node_view['time'] != 0.0)[0]] *= -1.0
edge_view = np.array(pop.tables... | python | def dump_tables_to_tskit(pop):
"""
Converts fwdpy11.TableCollection to an
tskit.TreeSequence
"""
node_view = np.array(pop.tables.nodes, copy=True)
node_view['time'] -= node_view['time'].max()
node_view['time'][np.where(node_view['time'] != 0.0)[0]] *= -1.0
edge_view = np.array(pop.tables... | [
"def",
"dump_tables_to_tskit",
"(",
"pop",
")",
":",
"node_view",
"=",
"np",
".",
"array",
"(",
"pop",
".",
"tables",
".",
"nodes",
",",
"copy",
"=",
"True",
")",
"node_view",
"[",
"'time'",
"]",
"-=",
"node_view",
"[",
"'time'",
"]",
".",
"max",
"("... | Converts fwdpy11.TableCollection to an
tskit.TreeSequence | [
"Converts",
"fwdpy11",
".",
"TableCollection",
"to",
"an",
"tskit",
".",
"TreeSequence"
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/_tables_to_tskit.py#L93-L145 |
molpopgen/fwdpy11 | fwdpy11/ezparams.py | mslike | def mslike(pop, **kwargs):
"""
Function to establish default parameters
for a single-locus simulation for standard pop-gen
modeling scenarios.
:params pop: An instance of :class:`fwdpy11.DiploidPopulation`
:params kwargs: Keyword arguments.
"""
import fwdpy11
if isinstance(pop, fwdp... | python | def mslike(pop, **kwargs):
"""
Function to establish default parameters
for a single-locus simulation for standard pop-gen
modeling scenarios.
:params pop: An instance of :class:`fwdpy11.DiploidPopulation`
:params kwargs: Keyword arguments.
"""
import fwdpy11
if isinstance(pop, fwdp... | [
"def",
"mslike",
"(",
"pop",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"fwdpy11",
"if",
"isinstance",
"(",
"pop",
",",
"fwdpy11",
".",
"DiploidPopulation",
")",
"is",
"False",
":",
"raise",
"ValueError",
"(",
"\"incorrect pop type: \"",
"+",
"str",
"(",... | Function to establish default parameters
for a single-locus simulation for standard pop-gen
modeling scenarios.
:params pop: An instance of :class:`fwdpy11.DiploidPopulation`
:params kwargs: Keyword arguments. | [
"Function",
"to",
"establish",
"default",
"parameters",
"for",
"a",
"single",
"-",
"locus",
"simulation",
"for",
"standard",
"pop",
"-",
"gen",
"modeling",
"scenarios",
"."
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/ezparams.py#L21-L62 |
opencivicdata/pupa | pupa/importers/people.py | PersonImporter.limit_spec | def limit_spec(self, spec):
"""
Whenever we do a Pseudo ID lookup from the database, we need to limit
based on the memberships -> organization -> jurisdiction, so we scope
the resolution.
"""
if list(spec.keys()) == ['name']:
# if we're just resolving on name,... | python | def limit_spec(self, spec):
"""
Whenever we do a Pseudo ID lookup from the database, we need to limit
based on the memberships -> organization -> jurisdiction, so we scope
the resolution.
"""
if list(spec.keys()) == ['name']:
# if we're just resolving on name,... | [
"def",
"limit_spec",
"(",
"self",
",",
"spec",
")",
":",
"if",
"list",
"(",
"spec",
".",
"keys",
"(",
")",
")",
"==",
"[",
"'name'",
"]",
":",
"# if we're just resolving on name, include other names",
"return",
"(",
"(",
"Q",
"(",
"name",
"=",
"spec",
"[... | Whenever we do a Pseudo ID lookup from the database, we need to limit
based on the memberships -> organization -> jurisdiction, so we scope
the resolution. | [
"Whenever",
"we",
"do",
"a",
"Pseudo",
"ID",
"lookup",
"from",
"the",
"database",
"we",
"need",
"to",
"limit",
"based",
"on",
"the",
"memberships",
"-",
">",
"organization",
"-",
">",
"jurisdiction",
"so",
"we",
"scope",
"the",
"resolution",
"."
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/people.py#L37-L48 |
molpopgen/fwdpy11 | fwdpy11/_model_params.py | ModelParams.validate | def validate(self):
"""
Error check model params.
:raises TypeError: Throws TypeError if validation fails.
"""
if self.nregions is None:
raise TypeError("neutral regions cannot be None")
if self.sregions is None:
raise TypeError("selected regions... | python | def validate(self):
"""
Error check model params.
:raises TypeError: Throws TypeError if validation fails.
"""
if self.nregions is None:
raise TypeError("neutral regions cannot be None")
if self.sregions is None:
raise TypeError("selected regions... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"nregions",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"neutral regions cannot be None\"",
")",
"if",
"self",
".",
"sregions",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"selected regions c... | Error check model params.
:raises TypeError: Throws TypeError if validation fails. | [
"Error",
"check",
"model",
"params",
"."
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/_model_params.py#L171-L191 |
opencivicdata/pupa | pupa/importers/organizations.py | OrganizationImporter._prepare_imports | def _prepare_imports(self, dicts):
""" an override for prepare imports that sorts the imports by parent_id dependencies """
# all pseudo parent ids we've seen
pseudo_ids = set()
# pseudo matches
pseudo_matches = {}
# get prepared imports from parent
prepared = di... | python | def _prepare_imports(self, dicts):
""" an override for prepare imports that sorts the imports by parent_id dependencies """
# all pseudo parent ids we've seen
pseudo_ids = set()
# pseudo matches
pseudo_matches = {}
# get prepared imports from parent
prepared = di... | [
"def",
"_prepare_imports",
"(",
"self",
",",
"dicts",
")",
":",
"# all pseudo parent ids we've seen",
"pseudo_ids",
"=",
"set",
"(",
")",
"# pseudo matches",
"pseudo_matches",
"=",
"{",
"}",
"# get prepared imports from parent",
"prepared",
"=",
"dict",
"(",
"super",
... | an override for prepare imports that sorts the imports by parent_id dependencies | [
"an",
"override",
"for",
"prepare",
"imports",
"that",
"sorts",
"the",
"imports",
"by",
"parent_id",
"dependencies"
] | train | https://github.com/opencivicdata/pupa/blob/18e0ddc4344804987ee0f2227bf600375538dbd5/pupa/importers/organizations.py#L61-L122 |
molpopgen/fwdpy11 | fwdpy11/_evolvets.py | evolvets | def evolvets(rng, pop, params, simplification_interval, recorder=None,
suppress_table_indexing=False, record_gvalue_matrix=False,
stopping_criterion=None,
track_mutation_counts=False,
remove_extinct_variants=True):
"""
Evolve a population with tree sequence recording
... | python | def evolvets(rng, pop, params, simplification_interval, recorder=None,
suppress_table_indexing=False, record_gvalue_matrix=False,
stopping_criterion=None,
track_mutation_counts=False,
remove_extinct_variants=True):
"""
Evolve a population with tree sequence recording
... | [
"def",
"evolvets",
"(",
"rng",
",",
"pop",
",",
"params",
",",
"simplification_interval",
",",
"recorder",
"=",
"None",
",",
"suppress_table_indexing",
"=",
"False",
",",
"record_gvalue_matrix",
"=",
"False",
",",
"stopping_criterion",
"=",
"None",
",",
"track_m... | Evolve a population with tree sequence recording
:param rng: random number generator
:type rng: :class:`fwdpy11.GSLrng`
:param pop: A population
:type pop: :class:`fwdpy11.DiploidPopulation`
:param params: simulation parameters
:type params: :class:`fwdpy11.ModelParams`
:param simplificatio... | [
"Evolve",
"a",
"population",
"with",
"tree",
"sequence",
"recording"
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/_evolvets.py#L21-L94 |
molpopgen/fwdpy11 | fwdpy11/demography.py | exponential_size_change | def exponential_size_change(Nstart, Nstop, time):
"""
Generate a list of population sizes
according to exponential size_change model
:param Nstart: population size at onset of size change
:param Nstop: Population size to reach at end of size change
:param time: Time (in generations) to get from... | python | def exponential_size_change(Nstart, Nstop, time):
"""
Generate a list of population sizes
according to exponential size_change model
:param Nstart: population size at onset of size change
:param Nstop: Population size to reach at end of size change
:param time: Time (in generations) to get from... | [
"def",
"exponential_size_change",
"(",
"Nstart",
",",
"Nstop",
",",
"time",
")",
":",
"if",
"time",
"<",
"1",
":",
"raise",
"RuntimeError",
"(",
"\"time must be >= 1\"",
")",
"if",
"Nstart",
"<",
"1",
"or",
"Nstop",
"<",
"1",
":",
"raise",
"RuntimeError",
... | Generate a list of population sizes
according to exponential size_change model
:param Nstart: population size at onset of size change
:param Nstop: Population size to reach at end of size change
:param time: Time (in generations) to get from Nstart to Nstop
:return: A list of integers representing... | [
"Generate",
"a",
"list",
"of",
"population",
"sizes",
"according",
"to",
"exponential",
"size_change",
"model"
] | train | https://github.com/molpopgen/fwdpy11/blob/7a5905f0f0a09e24ae5b0f39d22017499e81ea9e/fwdpy11/demography.py#L4-L25 |
markdrago/pgsanity | pgsanity/sqlprep.py | split_sql | def split_sql(sql):
"""generate hunks of SQL that are between the bookends
return: tuple of beginning bookend, closing bookend, and contents
note: beginning & end of string are returned as None"""
bookends = ("\n", ";", "--", "/*", "*/")
last_bookend_found = None
start = 0
while sta... | python | def split_sql(sql):
"""generate hunks of SQL that are between the bookends
return: tuple of beginning bookend, closing bookend, and contents
note: beginning & end of string are returned as None"""
bookends = ("\n", ";", "--", "/*", "*/")
last_bookend_found = None
start = 0
while sta... | [
"def",
"split_sql",
"(",
"sql",
")",
":",
"bookends",
"=",
"(",
"\"\\n\"",
",",
"\";\"",
",",
"\"--\"",
",",
"\"/*\"",
",",
"\"*/\"",
")",
"last_bookend_found",
"=",
"None",
"start",
"=",
"0",
"while",
"start",
"<=",
"len",
"(",
"sql",
")",
":",
"res... | generate hunks of SQL that are between the bookends
return: tuple of beginning bookend, closing bookend, and contents
note: beginning & end of string are returned as None | [
"generate",
"hunks",
"of",
"SQL",
"that",
"are",
"between",
"the",
"bookends",
"return",
":",
"tuple",
"of",
"beginning",
"bookend",
"closing",
"bookend",
"and",
"contents",
"note",
":",
"beginning",
"&",
"end",
"of",
"string",
"are",
"returned",
"as",
"None... | train | https://github.com/markdrago/pgsanity/blob/3bd391be1c5f0e2ce041652bdaf1d6b54424c6d8/pgsanity/sqlprep.py#L53-L70 |
markdrago/pgsanity | pgsanity/pgsanity.py | check_file | def check_file(filename=None, show_filename=False, add_semicolon=False):
"""
Check whether an input file is valid PostgreSQL. If no filename is
passed, STDIN is checked.
Returns a status code: 0 if the input is valid, 1 if invalid.
"""
# either work with sys.stdin or open the file
if filena... | python | def check_file(filename=None, show_filename=False, add_semicolon=False):
"""
Check whether an input file is valid PostgreSQL. If no filename is
passed, STDIN is checked.
Returns a status code: 0 if the input is valid, 1 if invalid.
"""
# either work with sys.stdin or open the file
if filena... | [
"def",
"check_file",
"(",
"filename",
"=",
"None",
",",
"show_filename",
"=",
"False",
",",
"add_semicolon",
"=",
"False",
")",
":",
"# either work with sys.stdin or open the file",
"if",
"filename",
"is",
"not",
"None",
":",
"with",
"open",
"(",
"filename",
","... | Check whether an input file is valid PostgreSQL. If no filename is
passed, STDIN is checked.
Returns a status code: 0 if the input is valid, 1 if invalid. | [
"Check",
"whether",
"an",
"input",
"file",
"is",
"valid",
"PostgreSQL",
".",
"If",
"no",
"filename",
"is",
"passed",
"STDIN",
"is",
"checked",
"."
] | train | https://github.com/markdrago/pgsanity/blob/3bd391be1c5f0e2ce041652bdaf1d6b54424c6d8/pgsanity/pgsanity.py#L17-L44 |
markdrago/pgsanity | pgsanity/pgsanity.py | check_string | def check_string(sql_string, add_semicolon=False):
"""
Check whether a string is valid PostgreSQL. Returns a boolean
indicating validity and a message from ecpg, which will be an
empty string if the input was valid, or a description of the
problem otherwise.
"""
prepped_sql = sqlprep.prepare... | python | def check_string(sql_string, add_semicolon=False):
"""
Check whether a string is valid PostgreSQL. Returns a boolean
indicating validity and a message from ecpg, which will be an
empty string if the input was valid, or a description of the
problem otherwise.
"""
prepped_sql = sqlprep.prepare... | [
"def",
"check_string",
"(",
"sql_string",
",",
"add_semicolon",
"=",
"False",
")",
":",
"prepped_sql",
"=",
"sqlprep",
".",
"prepare_sql",
"(",
"sql_string",
",",
"add_semicolon",
"=",
"add_semicolon",
")",
"success",
",",
"msg",
"=",
"ecpg",
".",
"check_synta... | Check whether a string is valid PostgreSQL. Returns a boolean
indicating validity and a message from ecpg, which will be an
empty string if the input was valid, or a description of the
problem otherwise. | [
"Check",
"whether",
"a",
"string",
"is",
"valid",
"PostgreSQL",
".",
"Returns",
"a",
"boolean",
"indicating",
"validity",
"and",
"a",
"message",
"from",
"ecpg",
"which",
"will",
"be",
"an",
"empty",
"string",
"if",
"the",
"input",
"was",
"valid",
"or",
"a"... | train | https://github.com/markdrago/pgsanity/blob/3bd391be1c5f0e2ce041652bdaf1d6b54424c6d8/pgsanity/pgsanity.py#L46-L55 |
markdrago/pgsanity | pgsanity/ecpg.py | check_syntax | def check_syntax(string):
""" Check syntax of a string of PostgreSQL-dialect SQL """
args = ["ecpg", "-o", "-", "-"]
with open(os.devnull, "w") as devnull:
try:
proc = subprocess.Popen(args, shell=False,
stdout=devnull,
... | python | def check_syntax(string):
""" Check syntax of a string of PostgreSQL-dialect SQL """
args = ["ecpg", "-o", "-", "-"]
with open(os.devnull, "w") as devnull:
try:
proc = subprocess.Popen(args, shell=False,
stdout=devnull,
... | [
"def",
"check_syntax",
"(",
"string",
")",
":",
"args",
"=",
"[",
"\"ecpg\"",
",",
"\"-o\"",
",",
"\"-\"",
",",
"\"-\"",
"]",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"as",
"devnull",
":",
"try",
":",
"proc",
"=",
"subprocess",
... | Check syntax of a string of PostgreSQL-dialect SQL | [
"Check",
"syntax",
"of",
"a",
"string",
"of",
"PostgreSQL",
"-",
"dialect",
"SQL"
] | train | https://github.com/markdrago/pgsanity/blob/3bd391be1c5f0e2ce041652bdaf1d6b54424c6d8/pgsanity/ecpg.py#L6-L24 |
QualiSystems/vCenterShell | static_vm_package/VCenterAutoloadStaticVMDriver/app_discovery/vm_autoload_driver.py | DeployAppOrchestrationDriver.get_inventory | def get_inventory(self, context):
"""
Will locate vm in vcenter and fill its uuid
:type context: cloudshell.shell.core.context.ResourceCommandContext
"""
vcenter_vm_name = context.resource.attributes['vCenter VM']
vcenter_vm_name = vcenter_vm_name.replace('\\', '/')
... | python | def get_inventory(self, context):
"""
Will locate vm in vcenter and fill its uuid
:type context: cloudshell.shell.core.context.ResourceCommandContext
"""
vcenter_vm_name = context.resource.attributes['vCenter VM']
vcenter_vm_name = vcenter_vm_name.replace('\\', '/')
... | [
"def",
"get_inventory",
"(",
"self",
",",
"context",
")",
":",
"vcenter_vm_name",
"=",
"context",
".",
"resource",
".",
"attributes",
"[",
"'vCenter VM'",
"]",
"vcenter_vm_name",
"=",
"vcenter_vm_name",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"vcenter_... | Will locate vm in vcenter and fill its uuid
:type context: cloudshell.shell.core.context.ResourceCommandContext | [
"Will",
"locate",
"vm",
"in",
"vcenter",
"and",
"fill",
"its",
"uuid",
":",
"type",
"context",
":",
"cloudshell",
".",
"shell",
".",
"core",
".",
"context",
".",
"ResourceCommandContext"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/static_vm_package/VCenterAutoloadStaticVMDriver/app_discovery/vm_autoload_driver.py#L25-L64 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/retrieve_snapshots.py | RetrieveSnapshotsCommand.get_snapshots | def get_snapshots(self, si, logger, vm_uuid):
"""
Restores a virtual machine to a snapshot
:param vim.ServiceInstance si: py_vmomi service instance
:param logger: Logger
:param vm_uuid: uuid of the virtual machine
"""
vm = self.pyvmomi_service.find_by_uuid(si, vm_... | python | def get_snapshots(self, si, logger, vm_uuid):
"""
Restores a virtual machine to a snapshot
:param vim.ServiceInstance si: py_vmomi service instance
:param logger: Logger
:param vm_uuid: uuid of the virtual machine
"""
vm = self.pyvmomi_service.find_by_uuid(si, vm_... | [
"def",
"get_snapshots",
"(",
"self",
",",
"si",
",",
"logger",
",",
"vm_uuid",
")",
":",
"vm",
"=",
"self",
".",
"pyvmomi_service",
".",
"find_by_uuid",
"(",
"si",
",",
"vm_uuid",
")",
"logger",
".",
"info",
"(",
"\"Get snapshots\"",
")",
"snapshots",
"=... | Restores a virtual machine to a snapshot
:param vim.ServiceInstance si: py_vmomi service instance
:param logger: Logger
:param vm_uuid: uuid of the virtual machine | [
"Restores",
"a",
"virtual",
"machine",
"to",
"a",
"snapshot",
":",
"param",
"vim",
".",
"ServiceInstance",
"si",
":",
"py_vmomi",
"service",
"instance",
":",
"param",
"logger",
":",
"Logger",
":",
"param",
"vm_uuid",
":",
"uuid",
"of",
"the",
"virtual",
"m... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/retrieve_snapshots.py#L15-L26 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.connect | def connect(self, address, user, password, port=443):
"""
Connect to vCenter via SSL and return SI object
:param address: vCenter address (host / ip address)
:param user: user name for authentication
:param password:password for authentication
:param port: ... | python | def connect(self, address, user, password, port=443):
"""
Connect to vCenter via SSL and return SI object
:param address: vCenter address (host / ip address)
:param user: user name for authentication
:param password:password for authentication
:param port: ... | [
"def",
"connect",
"(",
"self",
",",
"address",
",",
"user",
",",
"password",
",",
"port",
"=",
"443",
")",
":",
"'# Disabling urllib3 ssl warnings'",
"requests",
".",
"packages",
".",
"urllib3",
".",
"disable_warnings",
"(",
")",
"'# Disabling SSL certificate veri... | Connect to vCenter via SSL and return SI object
:param address: vCenter address (host / ip address)
:param user: user name for authentication
:param password:password for authentication
:param port: port for the SSL connection. Default = 443 | [
"Connect",
"to",
"vCenter",
"via",
"SSL",
"and",
"return",
"SI",
"object",
":",
"param",
"address",
":",
"vCenter",
"address",
"(",
"host",
"/",
"ip",
"address",
")",
":",
"param",
"user",
":",
"user",
"name",
"for",
"authentication",
":",
"param",
"pass... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L50-L87 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_datacenter_by_name | def find_datacenter_by_name(self, si, path, name):
"""
Finds datacenter in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datacent... | python | def find_datacenter_by_name(self, si, path, name):
"""
Finds datacenter in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datacent... | [
"def",
"find_datacenter_by_name",
"(",
"self",
",",
"si",
",",
"path",
",",
"name",
")",
":",
"return",
"self",
".",
"find_obj_by_path",
"(",
"si",
",",
"path",
",",
"name",
",",
"self",
".",
"Datacenter",
")"
] | Finds datacenter in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datacenter name to return | [
"Finds",
"datacenter",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L93-L101 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_by_uuid | def find_by_uuid(self, si, uuid, is_vm=True, path=None, data_center=None):
"""
Finds vm/host by his uuid in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param uuid: the object uuid
:param path: the path to find the object ('dc' or 'dc/f... | python | def find_by_uuid(self, si, uuid, is_vm=True, path=None, data_center=None):
"""
Finds vm/host by his uuid in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param uuid: the object uuid
:param path: the path to find the object ('dc' or 'dc/f... | [
"def",
"find_by_uuid",
"(",
"self",
",",
"si",
",",
"uuid",
",",
"is_vm",
"=",
"True",
",",
"path",
"=",
"None",
",",
"data_center",
"=",
"None",
")",
":",
"if",
"uuid",
"is",
"None",
":",
"return",
"None",
"if",
"path",
"is",
"not",
"None",
":",
... | Finds vm/host by his uuid in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param uuid: the object uuid
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param is_vm: if true, search for virtual mach... | [
"Finds",
"vm",
"/",
"host",
"by",
"his",
"uuid",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L103-L120 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_item_in_path_by_type | def find_item_in_path_by_type(self, si, path, obj_type):
"""
This function finds the first item of that type in path
:param ServiceInstance si: pyvmomi ServiceInstance
:param str path: the path to search in
:param type obj_type: the vim type of the object
:return: pyvmomi... | python | def find_item_in_path_by_type(self, si, path, obj_type):
"""
This function finds the first item of that type in path
:param ServiceInstance si: pyvmomi ServiceInstance
:param str path: the path to search in
:param type obj_type: the vim type of the object
:return: pyvmomi... | [
"def",
"find_item_in_path_by_type",
"(",
"self",
",",
"si",
",",
"path",
",",
"obj_type",
")",
":",
"if",
"obj_type",
"is",
"None",
":",
"return",
"None",
"search_index",
"=",
"si",
".",
"content",
".",
"searchIndex",
"sub_folder",
"=",
"si",
".",
"content... | This function finds the first item of that type in path
:param ServiceInstance si: pyvmomi ServiceInstance
:param str path: the path to search in
:param type obj_type: the vim type of the object
:return: pyvmomi type instance object or None | [
"This",
"function",
"finds",
"the",
"first",
"item",
"of",
"that",
"type",
"in",
"path",
":",
"param",
"ServiceInstance",
"si",
":",
"pyvmomi",
"ServiceInstance",
":",
"param",
"str",
"path",
":",
"the",
"path",
"to",
"search",
"in",
":",
"param",
"type",
... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L122-L148 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_host_by_name | def find_host_by_name(self, si, path, name):
"""
Finds datastore in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name ... | python | def find_host_by_name(self, si, path, name):
"""
Finds datastore in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name ... | [
"def",
"find_host_by_name",
"(",
"self",
",",
"si",
",",
"path",
",",
"name",
")",
":",
"return",
"self",
".",
"find_obj_by_path",
"(",
"si",
",",
"path",
",",
"name",
",",
"self",
".",
"Host",
")"
] | Finds datastore in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name to return | [
"Finds",
"datastore",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L150-L158 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_datastore_by_name | def find_datastore_by_name(self, si, path, name):
"""
Finds datastore in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore ... | python | def find_datastore_by_name(self, si, path, name):
"""
Finds datastore in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore ... | [
"def",
"find_datastore_by_name",
"(",
"self",
",",
"si",
",",
"path",
",",
"name",
")",
":",
"return",
"self",
".",
"find_obj_by_path",
"(",
"si",
",",
"path",
",",
"name",
",",
"self",
".",
"Datastore",
")"
] | Finds datastore in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name to return | [
"Finds",
"datastore",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L160-L168 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_portgroup | def find_portgroup(self, si, dv_switch_path, name):
"""
Returns the portgroup on the dvSwitch
:param name: str
:param dv_switch_path: str
:param si: service instance
"""
dv_switch = self.get_folder(si, dv_switch_path)
if dv_switch and dv_switch.portgroup:
... | python | def find_portgroup(self, si, dv_switch_path, name):
"""
Returns the portgroup on the dvSwitch
:param name: str
:param dv_switch_path: str
:param si: service instance
"""
dv_switch = self.get_folder(si, dv_switch_path)
if dv_switch and dv_switch.portgroup:
... | [
"def",
"find_portgroup",
"(",
"self",
",",
"si",
",",
"dv_switch_path",
",",
"name",
")",
":",
"dv_switch",
"=",
"self",
".",
"get_folder",
"(",
"si",
",",
"dv_switch_path",
")",
"if",
"dv_switch",
"and",
"dv_switch",
".",
"portgroup",
":",
"for",
"port",
... | Returns the portgroup on the dvSwitch
:param name: str
:param dv_switch_path: str
:param si: service instance | [
"Returns",
"the",
"portgroup",
"on",
"the",
"dvSwitch",
":",
"param",
"name",
":",
"str",
":",
"param",
"dv_switch_path",
":",
"str",
":",
"param",
"si",
":",
"service",
"instance"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L170-L182 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_network_by_name | def find_network_by_name(self, si, path, name):
"""
Finds network in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name... | python | def find_network_by_name(self, si, path, name):
"""
Finds network in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name... | [
"def",
"find_network_by_name",
"(",
"self",
",",
"si",
",",
"path",
",",
"name",
")",
":",
"return",
"self",
".",
"find_obj_by_path",
"(",
"si",
",",
"path",
",",
"name",
",",
"self",
".",
"Network",
")"
] | Finds network in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the datastore name to return | [
"Finds",
"network",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L184-L192 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_vm_by_name | def find_vm_by_name(self, si, path, name):
"""
Finds vm in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the vm name to return
... | python | def find_vm_by_name(self, si, path, name):
"""
Finds vm in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the vm name to return
... | [
"def",
"find_vm_by_name",
"(",
"self",
",",
"si",
",",
"path",
",",
"name",
")",
":",
"return",
"self",
".",
"find_obj_by_path",
"(",
"si",
",",
"path",
",",
"name",
",",
"self",
".",
"VM",
")"
] | Finds vm in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the vm name to return | [
"Finds",
"vm",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L194-L202 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_obj_by_path | def find_obj_by_path(self, si, path, name, type_name):
"""
Finds object in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the object n... | python | def find_obj_by_path(self, si, path, name, type_name):
"""
Finds object in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the object n... | [
"def",
"find_obj_by_path",
"(",
"self",
",",
"si",
",",
"path",
",",
"name",
",",
"type_name",
")",
":",
"folder",
"=",
"self",
".",
"get_folder",
"(",
"si",
",",
"path",
")",
"if",
"folder",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'vmomi manag... | Finds object in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
:param name: the object name to return
:param type_name: the name of the type, can be (vm,... | [
"Finds",
"object",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L204-L228 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.find_dvs_by_path | def find_dvs_by_path(self,si ,path):
"""
Finds vm in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
"""
dvs = self.get_folder(si, path)
i... | python | def find_dvs_by_path(self,si ,path):
"""
Finds vm in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
"""
dvs = self.get_folder(si, path)
i... | [
"def",
"find_dvs_by_path",
"(",
"self",
",",
"si",
",",
"path",
")",
":",
"dvs",
"=",
"self",
".",
"get_folder",
"(",
"si",
",",
"path",
")",
"if",
"not",
"dvs",
":",
"raise",
"ValueError",
"(",
"'Could not find Default DvSwitch in path {0}'",
".",
"format",... | Finds vm in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...') | [
"Finds",
"vm",
"in",
"the",
"vCenter",
"or",
"returns",
"None",
":",
"param",
"si",
":",
"pyvmomi",
"ServiceInstance",
":",
"param",
"path",
":",
"the",
"path",
"to",
"find",
"the",
"object",
"(",
"dc",
"or",
"dc",
"/",
"folder",
"or",
"dc",
"/",
"fo... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L230-L243 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.get_folder | def get_folder(self, si, path, root=None):
"""
Finds folder in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
"""
search_index = si.content.sear... | python | def get_folder(self, si, path, root=None):
"""
Finds folder in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
"""
search_index = si.content.sear... | [
"def",
"get_folder",
"(",
"self",
",",
"si",
",",
"path",
",",
"root",
"=",
"None",
")",
":",
"search_index",
"=",
"si",
".",
"content",
".",
"searchIndex",
"sub_folder",
"=",
"root",
"if",
"root",
"else",
"si",
".",
"content",
".",
"rootFolder",
"if",... | Finds folder in the vCenter or returns "None"
:param si: pyvmomi 'ServiceInstance'
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...') | [
"Finds",
"folder",
"in",
"the",
"vCenter",
"or",
"returns",
"None"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L245-L304 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.get_network_by_full_name | def get_network_by_full_name(self, si, default_network_full_name):
"""
Find network by a Full Name
:param default_network_full_name: <str> Full Network Name - likes 'Root/Folder/Network'
:return:
"""
path, name = get_path_and_name(default_network_full_name)
return... | python | def get_network_by_full_name(self, si, default_network_full_name):
"""
Find network by a Full Name
:param default_network_full_name: <str> Full Network Name - likes 'Root/Folder/Network'
:return:
"""
path, name = get_path_and_name(default_network_full_name)
return... | [
"def",
"get_network_by_full_name",
"(",
"self",
",",
"si",
",",
"default_network_full_name",
")",
":",
"path",
",",
"name",
"=",
"get_path_and_name",
"(",
"default_network_full_name",
")",
"return",
"self",
".",
"find_network_by_name",
"(",
"si",
",",
"path",
",",... | Find network by a Full Name
:param default_network_full_name: <str> Full Network Name - likes 'Root/Folder/Network'
:return: | [
"Find",
"network",
"by",
"a",
"Full",
"Name",
":",
"param",
"default_network_full_name",
":",
"<str",
">",
"Full",
"Network",
"Name",
"-",
"likes",
"Root",
"/",
"Folder",
"/",
"Network",
":",
"return",
":"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L306-L313 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.get_obj | def get_obj(self, content, vimtype, name):
"""
Return an object by name for a specific type, if name is None the
first found object is returned
:param content: pyvmomi content object
:param vimtype: the type of object too search
:param name: the object name t... | python | def get_obj(self, content, vimtype, name):
"""
Return an object by name for a specific type, if name is None the
first found object is returned
:param content: pyvmomi content object
:param vimtype: the type of object too search
:param name: the object name t... | [
"def",
"get_obj",
"(",
"self",
",",
"content",
",",
"vimtype",
",",
"name",
")",
":",
"obj",
"=",
"None",
"container",
"=",
"self",
".",
"_get_all_objects_by_type",
"(",
"content",
",",
"vimtype",
")",
"# If no name was given will return the first object from list o... | Return an object by name for a specific type, if name is None the
first found object is returned
:param content: pyvmomi content object
:param vimtype: the type of object too search
:param name: the object name to return | [
"Return",
"an",
"object",
"by",
"name",
"for",
"a",
"specific",
"type",
"if",
"name",
"is",
"None",
"the",
"first",
"found",
"object",
"is",
"returned"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L315-L338 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.clone_vm | def clone_vm(self, clone_params, logger, cancellation_context):
"""
Clone a VM from a template/VM and return the vm oject or throws argument is not valid
:param cancellation_context:
:param clone_params: CloneVmParameters =
:param logger:
"""
result = self.CloneV... | python | def clone_vm(self, clone_params, logger, cancellation_context):
"""
Clone a VM from a template/VM and return the vm oject or throws argument is not valid
:param cancellation_context:
:param clone_params: CloneVmParameters =
:param logger:
"""
result = self.CloneV... | [
"def",
"clone_vm",
"(",
"self",
",",
"clone_params",
",",
"logger",
",",
"cancellation_context",
")",
":",
"result",
"=",
"self",
".",
"CloneVmResult",
"(",
")",
"if",
"not",
"isinstance",
"(",
"clone_params",
".",
"si",
",",
"self",
".",
"vim",
".",
"Se... | Clone a VM from a template/VM and return the vm oject or throws argument is not valid
:param cancellation_context:
:param clone_params: CloneVmParameters =
:param logger: | [
"Clone",
"a",
"VM",
"from",
"a",
"template",
"/",
"VM",
"and",
"return",
"the",
"vm",
"oject",
"or",
"throws",
"argument",
"is",
"not",
"valid"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L413-L491 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.destroy_vm | def destroy_vm(self, vm, logger):
"""
destroy the given vm
:param vm: virutal machine pyvmomi object
:param logger:
"""
self.power_off_before_destroy(logger, vm)
logger.info(("Destroying VM {0}".format(vm.name)))
task = vm.Destroy_Task()
retu... | python | def destroy_vm(self, vm, logger):
"""
destroy the given vm
:param vm: virutal machine pyvmomi object
:param logger:
"""
self.power_off_before_destroy(logger, vm)
logger.info(("Destroying VM {0}".format(vm.name)))
task = vm.Destroy_Task()
retu... | [
"def",
"destroy_vm",
"(",
"self",
",",
"vm",
",",
"logger",
")",
":",
"self",
".",
"power_off_before_destroy",
"(",
"logger",
",",
"vm",
")",
"logger",
".",
"info",
"(",
"(",
"\"Destroying VM {0}\"",
".",
"format",
"(",
"vm",
".",
"name",
")",
")",
")"... | destroy the given vm
:param vm: virutal machine pyvmomi object
:param logger: | [
"destroy",
"the",
"given",
"vm",
":",
"param",
"vm",
":",
"virutal",
"machine",
"pyvmomi",
"object",
":",
"param",
"logger",
":"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L561-L573 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.destroy_vm_by_name | def destroy_vm_by_name(self, si, vm_name, vm_path, logger):
"""
destroy the given vm
:param si: pyvmomi 'ServiceInstance'
:param vm_name: str name of the vm to destroyed
:param vm_path: str path to the vm that will be destroyed
:param logger:
"""
i... | python | def destroy_vm_by_name(self, si, vm_name, vm_path, logger):
"""
destroy the given vm
:param si: pyvmomi 'ServiceInstance'
:param vm_name: str name of the vm to destroyed
:param vm_path: str path to the vm that will be destroyed
:param logger:
"""
i... | [
"def",
"destroy_vm_by_name",
"(",
"self",
",",
"si",
",",
"vm_name",
",",
"vm_path",
",",
"logger",
")",
":",
"if",
"vm_name",
"is",
"not",
"None",
":",
"vm",
"=",
"self",
".",
"find_vm_by_name",
"(",
"si",
",",
"vm_path",
",",
"vm_name",
")",
"if",
... | destroy the given vm
:param si: pyvmomi 'ServiceInstance'
:param vm_name: str name of the vm to destroyed
:param vm_path: str path to the vm that will be destroyed
:param logger: | [
"destroy",
"the",
"given",
"vm",
":",
"param",
"si",
":",
"pyvmomi",
"ServiceInstance",
":",
"param",
"vm_name",
":",
"str",
"name",
"of",
"the",
"vm",
"to",
"destroyed",
":",
"param",
"vm_path",
":",
"str",
"path",
"to",
"the",
"vm",
"that",
"will",
"... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L582-L594 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.destroy_vm_by_uuid | def destroy_vm_by_uuid(self, si, vm_uuid, vm_path, logger):
"""
destroy the given vm
:param si: pyvmomi 'ServiceInstance'
:param vm_uuid: str uuid of the vm to destroyed
:param vm_path: str path to the vm that will be destroyed
:param logger:
"""
if v... | python | def destroy_vm_by_uuid(self, si, vm_uuid, vm_path, logger):
"""
destroy the given vm
:param si: pyvmomi 'ServiceInstance'
:param vm_uuid: str uuid of the vm to destroyed
:param vm_path: str path to the vm that will be destroyed
:param logger:
"""
if v... | [
"def",
"destroy_vm_by_uuid",
"(",
"self",
",",
"si",
",",
"vm_uuid",
",",
"vm_path",
",",
"logger",
")",
":",
"if",
"vm_uuid",
"is",
"not",
"None",
":",
"vm",
"=",
"self",
".",
"find_by_uuid",
"(",
"si",
",",
"vm_uuid",
",",
"vm_path",
")",
"if",
"vm... | destroy the given vm
:param si: pyvmomi 'ServiceInstance'
:param vm_uuid: str uuid of the vm to destroyed
:param vm_path: str path to the vm that will be destroyed
:param logger: | [
"destroy",
"the",
"given",
"vm",
":",
"param",
"si",
":",
"pyvmomi",
"ServiceInstance",
":",
"param",
"vm_uuid",
":",
"str",
"uuid",
"of",
"the",
"vm",
"to",
"destroyed",
":",
"param",
"vm_path",
":",
"str",
"path",
"to",
"the",
"vm",
"that",
"will",
"... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L596-L610 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.vm_reconfig_task | def vm_reconfig_task(vm, device_change):
"""
Create Task for VM re-configure
:param vm: <vim.vm obj> VM which will be re-configure
:param device_change:
:return: Task
"""
config_spec = vim.vm.ConfigSpec(deviceChange=device_change)
task = vm.ReconfigVM_Task... | python | def vm_reconfig_task(vm, device_change):
"""
Create Task for VM re-configure
:param vm: <vim.vm obj> VM which will be re-configure
:param device_change:
:return: Task
"""
config_spec = vim.vm.ConfigSpec(deviceChange=device_change)
task = vm.ReconfigVM_Task... | [
"def",
"vm_reconfig_task",
"(",
"vm",
",",
"device_change",
")",
":",
"config_spec",
"=",
"vim",
".",
"vm",
".",
"ConfigSpec",
"(",
"deviceChange",
"=",
"device_change",
")",
"task",
"=",
"vm",
".",
"ReconfigVM_Task",
"(",
"config_spec",
")",
"return",
"task... | Create Task for VM re-configure
:param vm: <vim.vm obj> VM which will be re-configure
:param device_change:
:return: Task | [
"Create",
"Task",
"for",
"VM",
"re",
"-",
"configure",
":",
"param",
"vm",
":",
"<vim",
".",
"vm",
"obj",
">",
"VM",
"which",
"will",
"be",
"re",
"-",
"configure",
":",
"param",
"device_change",
":",
":",
"return",
":",
"Task"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L650-L659 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.vm_get_network_by_name | def vm_get_network_by_name(vm, network_name):
"""
Try to find Network scanning all attached to VM networks
:param vm: <vim.vm>
:param network_name: <str> name of network
:return: <vim.vm.Network or None>
"""
# return None
for network in vm.network:
... | python | def vm_get_network_by_name(vm, network_name):
"""
Try to find Network scanning all attached to VM networks
:param vm: <vim.vm>
:param network_name: <str> name of network
:return: <vim.vm.Network or None>
"""
# return None
for network in vm.network:
... | [
"def",
"vm_get_network_by_name",
"(",
"vm",
",",
"network_name",
")",
":",
"# return None",
"for",
"network",
"in",
"vm",
".",
"network",
":",
"if",
"hasattr",
"(",
"network",
",",
"\"name\"",
")",
"and",
"network_name",
"==",
"network",
".",
"name",
":",
... | Try to find Network scanning all attached to VM networks
:param vm: <vim.vm>
:param network_name: <str> name of network
:return: <vim.vm.Network or None> | [
"Try",
"to",
"find",
"Network",
"scanning",
"all",
"attached",
"to",
"VM",
"networks",
":",
"param",
"vm",
":",
"<vim",
".",
"vm",
">",
":",
"param",
"network_name",
":",
"<str",
">",
"name",
"of",
"network",
":",
"return",
":",
"<vim",
".",
"vm",
".... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L662-L673 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | pyVmomiService.get_vm_full_path | def get_vm_full_path(self, si, vm):
"""
:param vm: vim.VirtualMachine
:return:
"""
folder_name = None
folder = vm.parent
if folder:
folder_name = folder.name
folder_parent = folder.parent
while folder_parent and folder_parent.... | python | def get_vm_full_path(self, si, vm):
"""
:param vm: vim.VirtualMachine
:return:
"""
folder_name = None
folder = vm.parent
if folder:
folder_name = folder.name
folder_parent = folder.parent
while folder_parent and folder_parent.... | [
"def",
"get_vm_full_path",
"(",
"self",
",",
"si",
",",
"vm",
")",
":",
"folder_name",
"=",
"None",
"folder",
"=",
"vm",
".",
"parent",
"if",
"folder",
":",
"folder_name",
"=",
"folder",
".",
"name",
"folder_parent",
"=",
"folder",
".",
"parent",
"while"... | :param vm: vim.VirtualMachine
:return: | [
":",
"param",
"vm",
":",
"vim",
".",
"VirtualMachine",
":",
"return",
":"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L729-L751 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/load_vm.py | VMLoader.load_vm_uuid_by_name | def load_vm_uuid_by_name(self, si, vcenter_data_model, vm_name):
"""
Returns the vm uuid
:param si: Service instance to the vcenter
:param vcenter_data_model: vcenter data model
:param vm_name: the vm name
:return: str uuid
"""
path = VMLocation.combine([v... | python | def load_vm_uuid_by_name(self, si, vcenter_data_model, vm_name):
"""
Returns the vm uuid
:param si: Service instance to the vcenter
:param vcenter_data_model: vcenter data model
:param vm_name: the vm name
:return: str uuid
"""
path = VMLocation.combine([v... | [
"def",
"load_vm_uuid_by_name",
"(",
"self",
",",
"si",
",",
"vcenter_data_model",
",",
"vm_name",
")",
":",
"path",
"=",
"VMLocation",
".",
"combine",
"(",
"[",
"vcenter_data_model",
".",
"default_datacenter",
",",
"vm_name",
"]",
")",
"paths",
"=",
"path",
... | Returns the vm uuid
:param si: Service instance to the vcenter
:param vcenter_data_model: vcenter data model
:param vm_name: the vm name
:return: str uuid | [
"Returns",
"the",
"vm",
"uuid",
":",
"param",
"si",
":",
"Service",
"instance",
"to",
"the",
"vcenter",
":",
"param",
"vcenter_data_model",
":",
"vcenter",
"data",
"model",
":",
"param",
"vm_name",
":",
"the",
"vm",
"name",
":",
"return",
":",
"str",
"uu... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/load_vm.py#L12-L31 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/power_manager_vm.py | VirtualMachinePowerManagementCommand.power_off | def power_off(self, si, logger, session, vcenter_data_model, vm_uuid, resource_fullname):
"""
Power off of a vm
:param vcenter_data_model: vcenter model
:param si: Service Instance
:param logger:
:param session:
:param vcenter_data_model: vcenter_data_model
... | python | def power_off(self, si, logger, session, vcenter_data_model, vm_uuid, resource_fullname):
"""
Power off of a vm
:param vcenter_data_model: vcenter model
:param si: Service Instance
:param logger:
:param session:
:param vcenter_data_model: vcenter_data_model
... | [
"def",
"power_off",
"(",
"self",
",",
"si",
",",
"logger",
",",
"session",
",",
"vcenter_data_model",
",",
"vm_uuid",
",",
"resource_fullname",
")",
":",
"logger",
".",
"info",
"(",
"'retrieving vm by uuid: {0}'",
".",
"format",
"(",
"vm_uuid",
")",
")",
"vm... | Power off of a vm
:param vcenter_data_model: vcenter model
:param si: Service Instance
:param logger:
:param session:
:param vcenter_data_model: vcenter_data_model
:param vm_uuid: the uuid of the vm
:param resource_fullname: the full name of the deployed app resou... | [
"Power",
"off",
"of",
"a",
"vm",
":",
"param",
"vcenter_data_model",
":",
"vcenter",
"model",
":",
"param",
"si",
":",
"Service",
"Instance",
":",
"param",
"logger",
":",
":",
"param",
"session",
":",
":",
"param",
"vcenter_data_model",
":",
"vcenter_data_mo... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/power_manager_vm.py#L15-L54 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/power_manager_vm.py | VirtualMachinePowerManagementCommand.power_on | def power_on(self, si, logger, session, vm_uuid, resource_fullname):
"""
power on the specified vm
:param si:
:param logger:
:param session:
:param vm_uuid: the uuid of the vm
:param resource_fullname: the full name of the deployed app resource
:return:
... | python | def power_on(self, si, logger, session, vm_uuid, resource_fullname):
"""
power on the specified vm
:param si:
:param logger:
:param session:
:param vm_uuid: the uuid of the vm
:param resource_fullname: the full name of the deployed app resource
:return:
... | [
"def",
"power_on",
"(",
"self",
",",
"si",
",",
"logger",
",",
"session",
",",
"vm_uuid",
",",
"resource_fullname",
")",
":",
"logger",
".",
"info",
"(",
"'retrieving vm by uuid: {0}'",
".",
"format",
"(",
"vm_uuid",
")",
")",
"vm",
"=",
"self",
".",
"pv... | power on the specified vm
:param si:
:param logger:
:param session:
:param vm_uuid: the uuid of the vm
:param resource_fullname: the full name of the deployed app resource
:return: | [
"power",
"on",
"the",
"specified",
"vm",
":",
"param",
"si",
":",
":",
"param",
"logger",
":",
":",
"param",
"session",
":",
":",
"param",
"vm_uuid",
":",
"the",
"uuid",
"of",
"the",
"vm",
":",
"param",
"resource_fullname",
":",
"the",
"full",
"name",
... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/power_manager_vm.py#L56-L79 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/utilites/context_based_logger_factory.py | ContextBasedLoggerFactory.create_logger_for_context | def create_logger_for_context(self, logger_name, context):
"""
Create QS Logger for command context AutoLoadCommandContext or ResourceCommandContext
:param logger_name:
:type logger_name: str
:param context:
:return:
"""
if self._is_instance_of(context, '... | python | def create_logger_for_context(self, logger_name, context):
"""
Create QS Logger for command context AutoLoadCommandContext or ResourceCommandContext
:param logger_name:
:type logger_name: str
:param context:
:return:
"""
if self._is_instance_of(context, '... | [
"def",
"create_logger_for_context",
"(",
"self",
",",
"logger_name",
",",
"context",
")",
":",
"if",
"self",
".",
"_is_instance_of",
"(",
"context",
",",
"'AutoLoadCommandContext'",
")",
":",
"reservation_id",
"=",
"'Autoload'",
"handler_name",
"=",
"context",
"."... | Create QS Logger for command context AutoLoadCommandContext or ResourceCommandContext
:param logger_name:
:type logger_name: str
:param context:
:return: | [
"Create",
"QS",
"Logger",
"for",
"command",
"context",
"AutoLoadCommandContext",
"or",
"ResourceCommandContext",
":",
"param",
"logger_name",
":",
":",
"type",
"logger_name",
":",
"str",
":",
"param",
"context",
":",
":",
"return",
":"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/utilites/context_based_logger_factory.py#L7-L35 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/connect_dvswitch.py | VirtualSwitchConnectCommand.connect_to_networks | def connect_to_networks(self, si, logger, vm_uuid, vm_network_mappings, default_network_name,
reserved_networks, dv_switch_name, promiscuous_mode):
"""
Connect VM to Network
:param si: VmWare Service Instance - defined connection to vCenter
:param logger:
... | python | def connect_to_networks(self, si, logger, vm_uuid, vm_network_mappings, default_network_name,
reserved_networks, dv_switch_name, promiscuous_mode):
"""
Connect VM to Network
:param si: VmWare Service Instance - defined connection to vCenter
:param logger:
... | [
"def",
"connect_to_networks",
"(",
"self",
",",
"si",
",",
"logger",
",",
"vm_uuid",
",",
"vm_network_mappings",
",",
"default_network_name",
",",
"reserved_networks",
",",
"dv_switch_name",
",",
"promiscuous_mode",
")",
":",
"vm",
"=",
"self",
".",
"pv_service",
... | Connect VM to Network
:param si: VmWare Service Instance - defined connection to vCenter
:param logger:
:param vm_uuid: <str> UUID for VM
:param vm_network_mappings: <collection of 'VmNetworkMapping'>
:param default_network_name: <str> Full Network name - likes 'DataCenterName/Ne... | [
"Connect",
"VM",
"to",
"Network",
":",
"param",
"si",
":",
"VmWare",
"Service",
"Instance",
"-",
"defined",
"connection",
"to",
"vCenter",
":",
"param",
"logger",
":",
":",
"param",
"vm_uuid",
":",
"<str",
">",
"UUID",
"for",
"VM",
":",
"param",
"vm_netw... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/connect_dvswitch.py#L25-L68 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/vm/vnic_to_network_mapper.py | VnicToNetworkMapper.map_request_to_vnics | def map_request_to_vnics(self, requests, vnics, existing_network, default_network, reserved_networks):
"""
gets the requests for connecting netwoks and maps it the suitable vnic of specific is not specified
:param reserved_networks: array of reserved networks
:param requests:
:pa... | python | def map_request_to_vnics(self, requests, vnics, existing_network, default_network, reserved_networks):
"""
gets the requests for connecting netwoks and maps it the suitable vnic of specific is not specified
:param reserved_networks: array of reserved networks
:param requests:
:pa... | [
"def",
"map_request_to_vnics",
"(",
"self",
",",
"requests",
",",
"vnics",
",",
"existing_network",
",",
"default_network",
",",
"reserved_networks",
")",
":",
"mapping",
"=",
"dict",
"(",
")",
"reserved_networks",
"=",
"reserved_networks",
"if",
"reserved_networks"... | gets the requests for connecting netwoks and maps it the suitable vnic of specific is not specified
:param reserved_networks: array of reserved networks
:param requests:
:param vnics:
:param existing_network:
:param default_network:
:return: | [
"gets",
"the",
"requests",
"for",
"connecting",
"netwoks",
"and",
"maps",
"it",
"the",
"suitable",
"vnic",
"of",
"specific",
"is",
"not",
"specified",
":",
"param",
"reserved_networks",
":",
"array",
"of",
"reserved",
"networks",
":",
"param",
"requests",
":",... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/vm/vnic_to_network_mapper.py#L5-L34 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/ovf_service.py | OvfImageDeployerService.deploy_image | def deploy_image(self, vcenter_data_model, image_params, logger):
"""
Receives ovf image parameters and deploy it on the designated vcenter
:param VMwarevCenterResourceModel vcenter_data_model:
:type image_params: vCenterShell.vm.ovf_image_params.OvfImageParams
:param logger:
... | python | def deploy_image(self, vcenter_data_model, image_params, logger):
"""
Receives ovf image parameters and deploy it on the designated vcenter
:param VMwarevCenterResourceModel vcenter_data_model:
:type image_params: vCenterShell.vm.ovf_image_params.OvfImageParams
:param logger:
... | [
"def",
"deploy_image",
"(",
"self",
",",
"vcenter_data_model",
",",
"image_params",
",",
"logger",
")",
":",
"ovf_tool_exe_path",
"=",
"vcenter_data_model",
".",
"ovf_tool_path",
"self",
".",
"_validate_url_exists",
"(",
"ovf_tool_exe_path",
",",
"'OVF Tool'",
",",
... | Receives ovf image parameters and deploy it on the designated vcenter
:param VMwarevCenterResourceModel vcenter_data_model:
:type image_params: vCenterShell.vm.ovf_image_params.OvfImageParams
:param logger: | [
"Receives",
"ovf",
"image",
"parameters",
"and",
"deploy",
"it",
"on",
"the",
"designated",
"vcenter",
":",
"param",
"VMwarevCenterResourceModel",
"vcenter_data_model",
":",
":",
"type",
"image_params",
":",
"vCenterShell",
".",
"vm",
".",
"ovf_image_params",
".",
... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/ovf_service.py#L24-L58 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/ovf_service.py | OvfImageDeployerService._get_args | def _get_args(self, ovf_tool_exe_path, image_params, logger):
"""
:type image_params: vCenterShell.vm.ovf_image_params.OvfImageParams
"""
# create vm name
vm_name_param = VM_NAME_PARAM.format(image_params.vm_name)
# datastore name
datastore_param = DATA_STORE_PAR... | python | def _get_args(self, ovf_tool_exe_path, image_params, logger):
"""
:type image_params: vCenterShell.vm.ovf_image_params.OvfImageParams
"""
# create vm name
vm_name_param = VM_NAME_PARAM.format(image_params.vm_name)
# datastore name
datastore_param = DATA_STORE_PAR... | [
"def",
"_get_args",
"(",
"self",
",",
"ovf_tool_exe_path",
",",
"image_params",
",",
"logger",
")",
":",
"# create vm name",
"vm_name_param",
"=",
"VM_NAME_PARAM",
".",
"format",
"(",
"image_params",
".",
"vm_name",
")",
"# datastore name",
"datastore_param",
"=",
... | :type image_params: vCenterShell.vm.ovf_image_params.OvfImageParams | [
":",
"type",
"image_params",
":",
"vCenterShell",
".",
"vm",
".",
"ovf_image_params",
".",
"OvfImageParams"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/ovf_service.py#L60-L104 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py | CommandWrapper.execute_command_with_connection | def execute_command_with_connection(self, context, command, *args):
"""
Note: session & vcenter_data_model & reservation id objects will be injected dynamically to the command
:param command:
:param context: instance of ResourceCommandContext or AutoLoadCommandContext
:type conte... | python | def execute_command_with_connection(self, context, command, *args):
"""
Note: session & vcenter_data_model & reservation id objects will be injected dynamically to the command
:param command:
:param context: instance of ResourceCommandContext or AutoLoadCommandContext
:type conte... | [
"def",
"execute_command_with_connection",
"(",
"self",
",",
"context",
",",
"command",
",",
"*",
"args",
")",
":",
"logger",
"=",
"self",
".",
"context_based_logger_factory",
".",
"create_logger_for_context",
"(",
"logger_name",
"=",
"'vCenterShell'",
",",
"context"... | Note: session & vcenter_data_model & reservation id objects will be injected dynamically to the command
:param command:
:param context: instance of ResourceCommandContext or AutoLoadCommandContext
:type context: cloudshell.shell.core.context.ResourceCommandContext
:param args: | [
"Note",
":",
"session",
"&",
"vcenter_data_model",
"&",
"reservation",
"id",
"objects",
"will",
"be",
"injected",
"dynamically",
"to",
"the",
"command",
":",
"param",
"command",
":",
":",
"param",
"context",
":",
"instance",
"of",
"ResourceCommandContext",
"or",... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py#L54-L135 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py | CommandWrapper.has_connection_details_changed | def has_connection_details_changed(self, req_connection_details):
"""
:param cloudshell.cp.vcenter.models.VCenterConnectionDetails.VCenterConnectionDetails req_connection_details:
:return:
"""
if self.connection_details is None and req_connection_details is None:
retu... | python | def has_connection_details_changed(self, req_connection_details):
"""
:param cloudshell.cp.vcenter.models.VCenterConnectionDetails.VCenterConnectionDetails req_connection_details:
:return:
"""
if self.connection_details is None and req_connection_details is None:
retu... | [
"def",
"has_connection_details_changed",
"(",
"self",
",",
"req_connection_details",
")",
":",
"if",
"self",
".",
"connection_details",
"is",
"None",
"and",
"req_connection_details",
"is",
"None",
":",
"return",
"False",
"if",
"self",
".",
"connection_details",
"is"... | :param cloudshell.cp.vcenter.models.VCenterConnectionDetails.VCenterConnectionDetails req_connection_details:
:return: | [
":",
"param",
"cloudshell",
".",
"cp",
".",
"vcenter",
".",
"models",
".",
"VCenterConnectionDetails",
".",
"VCenterConnectionDetails",
"req_connection_details",
":",
":",
"return",
":"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py#L171-L183 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/restore_snapshot.py | SnapshotRestoreCommand.restore_snapshot | def restore_snapshot(self, si, logger, session, vm_uuid, resource_fullname, snapshot_name):
"""
Restores a virtual machine to a snapshot
:param vim.ServiceInstance si: py_vmomi service instance
:param logger: Logger
:param session: CloudShellAPISession
:type session: clou... | python | def restore_snapshot(self, si, logger, session, vm_uuid, resource_fullname, snapshot_name):
"""
Restores a virtual machine to a snapshot
:param vim.ServiceInstance si: py_vmomi service instance
:param logger: Logger
:param session: CloudShellAPISession
:type session: clou... | [
"def",
"restore_snapshot",
"(",
"self",
",",
"si",
",",
"logger",
",",
"session",
",",
"vm_uuid",
",",
"resource_fullname",
",",
"snapshot_name",
")",
":",
"vm",
"=",
"self",
".",
"pyvmomi_service",
".",
"find_by_uuid",
"(",
"si",
",",
"vm_uuid",
")",
"log... | Restores a virtual machine to a snapshot
:param vim.ServiceInstance si: py_vmomi service instance
:param logger: Logger
:param session: CloudShellAPISession
:type session: cloudshell_api.CloudShellAPISession
:param vm_uuid: uuid of the virtual machine
:param resource_full... | [
"Restores",
"a",
"virtual",
"machine",
"to",
"a",
"snapshot",
":",
"param",
"vim",
".",
"ServiceInstance",
"si",
":",
"py_vmomi",
"service",
"instance",
":",
"param",
"logger",
":",
"Logger",
":",
"param",
"session",
":",
"CloudShellAPISession",
":",
"type",
... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/restore_snapshot.py#L21-L41 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/restore_snapshot.py | SnapshotRestoreCommand._get_snapshot | def _get_snapshot(vm, snapshot_name):
"""
Returns snapshot object by its name
:param vm:
:param snapshot_name:
:type snapshot_name: str
:return: Snapshot by its name
:rtype vim.vm.Snapshot
"""
snapshots = SnapshotRetriever.get_vm_snapshots(vm)
... | python | def _get_snapshot(vm, snapshot_name):
"""
Returns snapshot object by its name
:param vm:
:param snapshot_name:
:type snapshot_name: str
:return: Snapshot by its name
:rtype vim.vm.Snapshot
"""
snapshots = SnapshotRetriever.get_vm_snapshots(vm)
... | [
"def",
"_get_snapshot",
"(",
"vm",
",",
"snapshot_name",
")",
":",
"snapshots",
"=",
"SnapshotRetriever",
".",
"get_vm_snapshots",
"(",
"vm",
")",
"if",
"snapshot_name",
"not",
"in",
"snapshots",
":",
"raise",
"SnapshotNotFoundException",
"(",
"'Snapshot {0} was not... | Returns snapshot object by its name
:param vm:
:param snapshot_name:
:type snapshot_name: str
:return: Snapshot by its name
:rtype vim.vm.Snapshot | [
"Returns",
"snapshot",
"object",
"by",
"its",
"name",
":",
"param",
"vm",
":",
":",
"param",
"snapshot_name",
":",
":",
"type",
"snapshot_name",
":",
"str",
":",
"return",
":",
"Snapshot",
"by",
"its",
"name",
":",
"rtype",
"vim",
".",
"vm",
".",
"Snap... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/restore_snapshot.py#L44-L58 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/save_sandbox.py | SaveAppCommand.save_app | def save_app(self, si, logger, vcenter_data_model, reservation_id, save_app_actions, cancellation_context):
"""
Cretaes an artifact of an app, that can later be restored
:param vcenter_data_model: VMwarevCenterResourceModel
:param vim.ServiceInstance si: py_vmomi service instance
... | python | def save_app(self, si, logger, vcenter_data_model, reservation_id, save_app_actions, cancellation_context):
"""
Cretaes an artifact of an app, that can later be restored
:param vcenter_data_model: VMwarevCenterResourceModel
:param vim.ServiceInstance si: py_vmomi service instance
... | [
"def",
"save_app",
"(",
"self",
",",
"si",
",",
"logger",
",",
"vcenter_data_model",
",",
"reservation_id",
",",
"save_app_actions",
",",
"cancellation_context",
")",
":",
"results",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"'Save Sandbox command starting on '",... | Cretaes an artifact of an app, that can later be restored
:param vcenter_data_model: VMwarevCenterResourceModel
:param vim.ServiceInstance si: py_vmomi service instance
:type si: vim.ServiceInstance
:param logger: Logger
:type logger: cloudshell.core.logger.qs_logger.get_qs_logg... | [
"Cretaes",
"an",
"artifact",
"of",
"an",
"app",
"that",
"can",
"later",
"be",
"restored"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/save_sandbox.py#L38-L91 |
openfisca/country-template | openfisca_country_template/variables/benefits.py | housing_allowance.formula_1980 | def formula_1980(household, period, parameters):
'''
To compute this allowance, the 'rent' value must be provided for the same month, but 'housing_occupancy_status' is not necessary.
'''
return household('rent', period) * parameters(period).benefits.housing_allowance | python | def formula_1980(household, period, parameters):
'''
To compute this allowance, the 'rent' value must be provided for the same month, but 'housing_occupancy_status' is not necessary.
'''
return household('rent', period) * parameters(period).benefits.housing_allowance | [
"def",
"formula_1980",
"(",
"household",
",",
"period",
",",
"parameters",
")",
":",
"return",
"household",
"(",
"'rent'",
",",
"period",
")",
"*",
"parameters",
"(",
"period",
")",
".",
"benefits",
".",
"housing_allowance"
] | To compute this allowance, the 'rent' value must be provided for the same month, but 'housing_occupancy_status' is not necessary. | [
"To",
"compute",
"this",
"allowance",
"the",
"rent",
"value",
"must",
"be",
"provided",
"for",
"the",
"same",
"month",
"but",
"housing_occupancy_status",
"is",
"not",
"necessary",
"."
] | train | https://github.com/openfisca/country-template/blob/b469ec97fecaf273d3a59deffa2ad13b727bde32/openfisca_country_template/variables/benefits.py#L47-L51 |
openfisca/country-template | openfisca_country_template/variables/benefits.py | pension.formula | def formula(person, period, parameters):
'''
A person's pension depends on their birth date.
In French: retraite selon l'âge.
In Arabic: تقاعد.
'''
age_condition = person('age', period) >= parameters(period).general.age_of_retirement
return age_condition | python | def formula(person, period, parameters):
'''
A person's pension depends on their birth date.
In French: retraite selon l'âge.
In Arabic: تقاعد.
'''
age_condition = person('age', period) >= parameters(period).general.age_of_retirement
return age_condition | [
"def",
"formula",
"(",
"person",
",",
"period",
",",
"parameters",
")",
":",
"age_condition",
"=",
"person",
"(",
"'age'",
",",
"period",
")",
">=",
"parameters",
"(",
"period",
")",
".",
"general",
".",
"age_of_retirement",
"return",
"age_condition"
] | A person's pension depends on their birth date.
In French: retraite selon l'âge.
In Arabic: تقاعد. | [
"A",
"person",
"s",
"pension",
"depends",
"on",
"their",
"birth",
"date",
".",
"In",
"French",
":",
"retraite",
"selon",
"l",
"âge",
".",
"In",
"Arabic",
":",
"تقاعد",
"."
] | train | https://github.com/openfisca/country-template/blob/b469ec97fecaf273d3a59deffa2ad13b727bde32/openfisca_country_template/variables/benefits.py#L62-L69 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/utilites/command_result.py | set_command_result | def set_command_result(result, unpicklable=False):
"""
Serializes output as JSON and writes it to console output wrapped with special prefix and suffix
:param result: Result to return
:param unpicklable: If True adds JSON can be deserialized as real object.
When False will be des... | python | def set_command_result(result, unpicklable=False):
"""
Serializes output as JSON and writes it to console output wrapped with special prefix and suffix
:param result: Result to return
:param unpicklable: If True adds JSON can be deserialized as real object.
When False will be des... | [
"def",
"set_command_result",
"(",
"result",
",",
"unpicklable",
"=",
"False",
")",
":",
"# we do not need to serialize an empty response from the vCenter",
"if",
"result",
"is",
"None",
":",
"return",
"if",
"isinstance",
"(",
"result",
",",
"basestring",
")",
":",
"... | Serializes output as JSON and writes it to console output wrapped with special prefix and suffix
:param result: Result to return
:param unpicklable: If True adds JSON can be deserialized as real object.
When False will be deserialized as dictionary | [
"Serializes",
"output",
"as",
"JSON",
"and",
"writes",
"it",
"to",
"console",
"output",
"wrapped",
"with",
"special",
"prefix",
"and",
"suffix",
":",
"param",
"result",
":",
"Result",
"to",
"return",
":",
"param",
"unpicklable",
":",
"If",
"True",
"adds",
... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/utilites/command_result.py#L18-L34 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py | VCenterAutoModelDiscovery.validate_and_discover | def validate_and_discover(self, context):
"""
:type context: models.QualiDriverModels.AutoLoadCommandContext
"""
logger = self._get_logger(context)
logger.info('Autodiscovery started')
si = None
resource = None
with CloudShellSessionContext(context) as cl... | python | def validate_and_discover(self, context):
"""
:type context: models.QualiDriverModels.AutoLoadCommandContext
"""
logger = self._get_logger(context)
logger.info('Autodiscovery started')
si = None
resource = None
with CloudShellSessionContext(context) as cl... | [
"def",
"validate_and_discover",
"(",
"self",
",",
"context",
")",
":",
"logger",
"=",
"self",
".",
"_get_logger",
"(",
"context",
")",
"logger",
".",
"info",
"(",
"'Autodiscovery started'",
")",
"si",
"=",
"None",
"resource",
"=",
"None",
"with",
"CloudShell... | :type context: models.QualiDriverModels.AutoLoadCommandContext | [
":",
"type",
"context",
":",
"models",
".",
"QualiDriverModels",
".",
"AutoLoadCommandContext"
] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py#L53-L94 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py | VCenterAutoModelDiscovery._make_attributes_slash_backslash_agnostic | def _make_attributes_slash_backslash_agnostic(attributes_with_slash_or_backslash):
"""
:param attributes_with_slash_or_backslash: resource attributes from
cloudshell.cp.vcenter.models.QualiDriverModels.ResourceContextDetails
:type attributes_with_slash_or_backslash: dict[str,str]
... | python | def _make_attributes_slash_backslash_agnostic(attributes_with_slash_or_backslash):
"""
:param attributes_with_slash_or_backslash: resource attributes from
cloudshell.cp.vcenter.models.QualiDriverModels.ResourceContextDetails
:type attributes_with_slash_or_backslash: dict[str,str]
... | [
"def",
"_make_attributes_slash_backslash_agnostic",
"(",
"attributes_with_slash_or_backslash",
")",
":",
"attributes_with_slash",
"=",
"dict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"attributes_with_slash_or_backslash",
".",
"items",
"(",
")",
":",
"if",
"key",
"... | :param attributes_with_slash_or_backslash: resource attributes from
cloudshell.cp.vcenter.models.QualiDriverModels.ResourceContextDetails
:type attributes_with_slash_or_backslash: dict[str,str]
:return: attributes_with_slash
:rtype attributes_with_slash: dict[str,str] | [
":",
"param",
"attributes_with_slash_or_backslash",
":",
"resource",
"attributes",
"from",
"cloudshell",
".",
"cp",
".",
"vcenter",
".",
"models",
".",
"QualiDriverModels",
".",
"ResourceContextDetails",
":",
"type",
"attributes_with_slash_or_backslash",
":",
"dict",
"[... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py#L327-L341 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/command_orchestrator.py | CommandOrchestrator.save_sandbox | def save_sandbox(self, context, save_actions, cancellation_context):
"""
Save sandbox command, persists an artifact of existing VMs, from which new vms can be restored
:param ResourceCommandContext context:
:param list[SaveApp] save_actions:
:param CancellationContext cancellatio... | python | def save_sandbox(self, context, save_actions, cancellation_context):
"""
Save sandbox command, persists an artifact of existing VMs, from which new vms can be restored
:param ResourceCommandContext context:
:param list[SaveApp] save_actions:
:param CancellationContext cancellatio... | [
"def",
"save_sandbox",
"(",
"self",
",",
"context",
",",
"save_actions",
",",
"cancellation_context",
")",
":",
"connection",
"=",
"self",
".",
"command_wrapper",
".",
"execute_command_with_connection",
"(",
"context",
",",
"self",
".",
"save_app_command",
".",
"s... | Save sandbox command, persists an artifact of existing VMs, from which new vms can be restored
:param ResourceCommandContext context:
:param list[SaveApp] save_actions:
:param CancellationContext cancellation_context:
:return: list[SaveAppResult] save_app_results | [
"Save",
"sandbox",
"command",
"persists",
"an",
"artifact",
"of",
"existing",
"VMs",
"from",
"which",
"new",
"vms",
"can",
"be",
"restored",
":",
"param",
"ResourceCommandContext",
"context",
":",
":",
"param",
"list",
"[",
"SaveApp",
"]",
"save_actions",
":",... | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/command_orchestrator.py#L191-L202 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.