id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38,000 | mdickinson/refcycle | refcycle/object_graph.py | ObjectGraph._raw | def _raw(cls, vertices, edges, out_edges, in_edges, head, tail):
"""
Private constructor for direct construction
of an ObjectGraph from its attributes.
vertices is the collection of vertices
out_edges and in_edges map vertices to lists of edges
head and tail map edges to... | python | def _raw(cls, vertices, edges, out_edges, in_edges, head, tail):
"""
Private constructor for direct construction
of an ObjectGraph from its attributes.
vertices is the collection of vertices
out_edges and in_edges map vertices to lists of edges
head and tail map edges to... | [
"def",
"_raw",
"(",
"cls",
",",
"vertices",
",",
"edges",
",",
"out_edges",
",",
"in_edges",
",",
"head",
",",
"tail",
")",
":",
"self",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"_out_edges",
"=",
"out_edges",
"self",
".",
"_in_ed... | Private constructor for direct construction
of an ObjectGraph from its attributes.
vertices is the collection of vertices
out_edges and in_edges map vertices to lists of edges
head and tail map edges to objects. | [
"Private",
"constructor",
"for",
"direct",
"construction",
"of",
"an",
"ObjectGraph",
"from",
"its",
"attributes",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/object_graph.py#L182-L199 |
38,001 | mdickinson/refcycle | refcycle/object_graph.py | ObjectGraph.annotated | def annotated(self):
"""
Annotate this graph, returning an AnnotatedGraph object
with the same structure.
"""
# Build up dictionary of edge annotations.
edge_annotations = {}
for edge in self.edges:
if edge not in edge_annotations:
# W... | python | def annotated(self):
"""
Annotate this graph, returning an AnnotatedGraph object
with the same structure.
"""
# Build up dictionary of edge annotations.
edge_annotations = {}
for edge in self.edges:
if edge not in edge_annotations:
# W... | [
"def",
"annotated",
"(",
"self",
")",
":",
"# Build up dictionary of edge annotations.",
"edge_annotations",
"=",
"{",
"}",
"for",
"edge",
"in",
"self",
".",
"edges",
":",
"if",
"edge",
"not",
"in",
"edge_annotations",
":",
"# We annotate all edges from a given object... | Annotate this graph, returning an AnnotatedGraph object
with the same structure. | [
"Annotate",
"this",
"graph",
"returning",
"an",
"AnnotatedGraph",
"object",
"with",
"the",
"same",
"structure",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/object_graph.py#L253-L295 |
38,002 | mdickinson/refcycle | refcycle/object_graph.py | ObjectGraph.owned_objects | def owned_objects(self):
"""
List of gc-tracked objects owned by this ObjectGraph instance.
"""
return (
[
self,
self.__dict__,
self._head,
self._tail,
self._out_edges,
self._out_... | python | def owned_objects(self):
"""
List of gc-tracked objects owned by this ObjectGraph instance.
"""
return (
[
self,
self.__dict__,
self._head,
self._tail,
self._out_edges,
self._out_... | [
"def",
"owned_objects",
"(",
"self",
")",
":",
"return",
"(",
"[",
"self",
",",
"self",
".",
"__dict__",
",",
"self",
".",
"_head",
",",
"self",
".",
"_tail",
",",
"self",
".",
"_out_edges",
",",
"self",
".",
"_out_edges",
".",
"_keys",
",",
"self",
... | List of gc-tracked objects owned by this ObjectGraph instance. | [
"List",
"of",
"gc",
"-",
"tracked",
"objects",
"owned",
"by",
"this",
"ObjectGraph",
"instance",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/object_graph.py#L352-L375 |
38,003 | mdickinson/refcycle | refcycle/object_graph.py | ObjectGraph.find_by_typename | def find_by_typename(self, typename):
"""
List of all objects whose type has the given name.
"""
return self.find_by(lambda obj: type(obj).__name__ == typename) | python | def find_by_typename(self, typename):
"""
List of all objects whose type has the given name.
"""
return self.find_by(lambda obj: type(obj).__name__ == typename) | [
"def",
"find_by_typename",
"(",
"self",
",",
"typename",
")",
":",
"return",
"self",
".",
"find_by",
"(",
"lambda",
"obj",
":",
"type",
"(",
"obj",
")",
".",
"__name__",
"==",
"typename",
")"
] | List of all objects whose type has the given name. | [
"List",
"of",
"all",
"objects",
"whose",
"type",
"has",
"the",
"given",
"name",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/object_graph.py#L377-L381 |
38,004 | toumorokoshi/sprinter | sprinter/core/inputs.py | Inputs.get_unset_inputs | def get_unset_inputs(self):
""" Return a set of unset inputs """
return set([k for k, v in self._inputs.items() if v.is_empty(False)]) | python | def get_unset_inputs(self):
""" Return a set of unset inputs """
return set([k for k, v in self._inputs.items() if v.is_empty(False)]) | [
"def",
"get_unset_inputs",
"(",
"self",
")",
":",
"return",
"set",
"(",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_inputs",
".",
"items",
"(",
")",
"if",
"v",
".",
"is_empty",
"(",
"False",
")",
"]",
")"
] | Return a set of unset inputs | [
"Return",
"a",
"set",
"of",
"unset",
"inputs"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/inputs.py#L135-L137 |
38,005 | toumorokoshi/sprinter | sprinter/core/inputs.py | Inputs.prompt_unset_inputs | def prompt_unset_inputs(self, force=False):
""" Prompt for unset input values """
for k, v in self._inputs.items():
if force or v.is_empty(False):
self.get_input(k, force=force) | python | def prompt_unset_inputs(self, force=False):
""" Prompt for unset input values """
for k, v in self._inputs.items():
if force or v.is_empty(False):
self.get_input(k, force=force) | [
"def",
"prompt_unset_inputs",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_inputs",
".",
"items",
"(",
")",
":",
"if",
"force",
"or",
"v",
".",
"is_empty",
"(",
"False",
")",
":",
"self",
".",
"get... | Prompt for unset input values | [
"Prompt",
"for",
"unset",
"input",
"values"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/inputs.py#L139-L143 |
38,006 | toumorokoshi/sprinter | sprinter/core/inputs.py | Inputs.values | def values(self, with_defaults=True):
""" Return the values dictionary, defaulting to default values """
return dict(((k, str(v)) for k, v in self._inputs.items() if not v.is_empty(with_defaults))) | python | def values(self, with_defaults=True):
""" Return the values dictionary, defaulting to default values """
return dict(((k, str(v)) for k, v in self._inputs.items() if not v.is_empty(with_defaults))) | [
"def",
"values",
"(",
"self",
",",
"with_defaults",
"=",
"True",
")",
":",
"return",
"dict",
"(",
"(",
"(",
"k",
",",
"str",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_inputs",
".",
"items",
"(",
")",
"if",
"not",
"v",
"."... | Return the values dictionary, defaulting to default values | [
"Return",
"the",
"values",
"dictionary",
"defaulting",
"to",
"default",
"values"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/inputs.py#L149-L151 |
38,007 | toumorokoshi/sprinter | sprinter/core/inputs.py | Inputs.write_values | def write_values(self):
""" Return the dictionary with which to write values """
return dict(((k, v.value) for k, v in self._inputs.items() if not v.is_secret and not v.is_empty(False))) | python | def write_values(self):
""" Return the dictionary with which to write values """
return dict(((k, v.value) for k, v in self._inputs.items() if not v.is_secret and not v.is_empty(False))) | [
"def",
"write_values",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"(",
"k",
",",
"v",
".",
"value",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_inputs",
".",
"items",
"(",
")",
"if",
"not",
"v",
".",
"is_secret",
"and",
"not",
"v",
... | Return the dictionary with which to write values | [
"Return",
"the",
"dictionary",
"with",
"which",
"to",
"write",
"values"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/inputs.py#L153-L155 |
38,008 | toumorokoshi/sprinter | sprinter/core/inputs.py | Inputs._parse_param_line | def _parse_param_line(self, line):
""" Parse a single param line. """
value = line.strip('\n \t')
if len(value) > 0:
i = Input()
if value.find('#') != -1:
value, extra_attributes = value.split('#')
try:
extra_attributes ... | python | def _parse_param_line(self, line):
""" Parse a single param line. """
value = line.strip('\n \t')
if len(value) > 0:
i = Input()
if value.find('#') != -1:
value, extra_attributes = value.split('#')
try:
extra_attributes ... | [
"def",
"_parse_param_line",
"(",
"self",
",",
"line",
")",
":",
"value",
"=",
"line",
".",
"strip",
"(",
"'\\n \\t'",
")",
"if",
"len",
"(",
"value",
")",
">",
"0",
":",
"i",
"=",
"Input",
"(",
")",
"if",
"value",
".",
"find",
"(",
"'#'",
")",
... | Parse a single param line. | [
"Parse",
"a",
"single",
"param",
"line",
"."
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/inputs.py#L171-L201 |
38,009 | sephii/zipch | zipch/zipcodes.py | ZipcodesDatabase.download | def download(self, overwrite=True):
"""
Download the zipcodes CSV file. If ``overwrite`` is set to False, the
file won't be downloaded if it already exists.
"""
if overwrite or not os.path.exists(self.file_path):
_, f = tempfile.mkstemp()
try:
... | python | def download(self, overwrite=True):
"""
Download the zipcodes CSV file. If ``overwrite`` is set to False, the
file won't be downloaded if it already exists.
"""
if overwrite or not os.path.exists(self.file_path):
_, f = tempfile.mkstemp()
try:
... | [
"def",
"download",
"(",
"self",
",",
"overwrite",
"=",
"True",
")",
":",
"if",
"overwrite",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"file_path",
")",
":",
"_",
",",
"f",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"try",
"... | Download the zipcodes CSV file. If ``overwrite`` is set to False, the
file won't be downloaded if it already exists. | [
"Download",
"the",
"zipcodes",
"CSV",
"file",
".",
"If",
"overwrite",
"is",
"set",
"to",
"False",
"the",
"file",
"won",
"t",
"be",
"downloaded",
"if",
"it",
"already",
"exists",
"."
] | a64720e8cb55d00edeab30c426791cf87bcca82a | https://github.com/sephii/zipch/blob/a64720e8cb55d00edeab30c426791cf87bcca82a/zipch/zipcodes.py#L65-L76 |
38,010 | sephii/zipch | zipch/zipcodes.py | ZipcodesDatabase.get_zipcodes_for_canton | def get_zipcodes_for_canton(self, canton):
"""
Return the list of zipcodes for the given canton code.
"""
zipcodes = [
zipcode for zipcode, location in self.get_locations().items()
if location.canton == canton
]
return zipcodes | python | def get_zipcodes_for_canton(self, canton):
"""
Return the list of zipcodes for the given canton code.
"""
zipcodes = [
zipcode for zipcode, location in self.get_locations().items()
if location.canton == canton
]
return zipcodes | [
"def",
"get_zipcodes_for_canton",
"(",
"self",
",",
"canton",
")",
":",
"zipcodes",
"=",
"[",
"zipcode",
"for",
"zipcode",
",",
"location",
"in",
"self",
".",
"get_locations",
"(",
")",
".",
"items",
"(",
")",
"if",
"location",
".",
"canton",
"==",
"cant... | Return the list of zipcodes for the given canton code. | [
"Return",
"the",
"list",
"of",
"zipcodes",
"for",
"the",
"given",
"canton",
"code",
"."
] | a64720e8cb55d00edeab30c426791cf87bcca82a | https://github.com/sephii/zipch/blob/a64720e8cb55d00edeab30c426791cf87bcca82a/zipch/zipcodes.py#L115-L124 |
38,011 | sephii/zipch | zipch/zipcodes.py | ZipcodesDatabase.get_cantons | def get_cantons(self):
"""
Return the list of unique cantons, sorted by name.
"""
return sorted(list(set([
location.canton for location in self.get_locations().values()
]))) | python | def get_cantons(self):
"""
Return the list of unique cantons, sorted by name.
"""
return sorted(list(set([
location.canton for location in self.get_locations().values()
]))) | [
"def",
"get_cantons",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"list",
"(",
"set",
"(",
"[",
"location",
".",
"canton",
"for",
"location",
"in",
"self",
".",
"get_locations",
"(",
")",
".",
"values",
"(",
")",
"]",
")",
")",
")"
] | Return the list of unique cantons, sorted by name. | [
"Return",
"the",
"list",
"of",
"unique",
"cantons",
"sorted",
"by",
"name",
"."
] | a64720e8cb55d00edeab30c426791cf87bcca82a | https://github.com/sephii/zipch/blob/a64720e8cb55d00edeab30c426791cf87bcca82a/zipch/zipcodes.py#L126-L132 |
38,012 | sephii/zipch | zipch/zipcodes.py | ZipcodesDatabase.get_municipalities | def get_municipalities(self):
"""
Return the list of unique municipalities, sorted by name.
"""
return sorted(list(set([
location.municipality for location in self.get_locations().values()
]))) | python | def get_municipalities(self):
"""
Return the list of unique municipalities, sorted by name.
"""
return sorted(list(set([
location.municipality for location in self.get_locations().values()
]))) | [
"def",
"get_municipalities",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"list",
"(",
"set",
"(",
"[",
"location",
".",
"municipality",
"for",
"location",
"in",
"self",
".",
"get_locations",
"(",
")",
".",
"values",
"(",
")",
"]",
")",
")",
")"
] | Return the list of unique municipalities, sorted by name. | [
"Return",
"the",
"list",
"of",
"unique",
"municipalities",
"sorted",
"by",
"name",
"."
] | a64720e8cb55d00edeab30c426791cf87bcca82a | https://github.com/sephii/zipch/blob/a64720e8cb55d00edeab30c426791cf87bcca82a/zipch/zipcodes.py#L134-L140 |
38,013 | toumorokoshi/sprinter | sprinter/core/featuredict.py | FeatureDict._get_formula_class | def _get_formula_class(self, formula):
"""
get a formula class object if it exists, else
create one, add it to the dict, and pass return it.
"""
# recursive import otherwise
from sprinter.formula.base import FormulaBase
if formula in LEGACY_MAPPINGS:
f... | python | def _get_formula_class(self, formula):
"""
get a formula class object if it exists, else
create one, add it to the dict, and pass return it.
"""
# recursive import otherwise
from sprinter.formula.base import FormulaBase
if formula in LEGACY_MAPPINGS:
f... | [
"def",
"_get_formula_class",
"(",
"self",
",",
"formula",
")",
":",
"# recursive import otherwise",
"from",
"sprinter",
".",
"formula",
".",
"base",
"import",
"FormulaBase",
"if",
"formula",
"in",
"LEGACY_MAPPINGS",
":",
"formula",
"=",
"LEGACY_MAPPINGS",
"[",
"fo... | get a formula class object if it exists, else
create one, add it to the dict, and pass return it. | [
"get",
"a",
"formula",
"class",
"object",
"if",
"it",
"exists",
"else",
"create",
"one",
"add",
"it",
"to",
"the",
"dict",
"and",
"pass",
"return",
"it",
"."
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/featuredict.py#L82-L108 |
38,014 | memphis-iis/GLUDB | gludb/backup.py | is_backup_class | def is_backup_class(cls):
"""Return true if given class supports back up. Currently this means a
gludb.data.Storable-derived class that has a mapping as defined in
gludb.config"""
return True if (
isclass(cls) and
issubclass(cls, Storable) and
get_mapping(cls, no_mapping_ok=True)... | python | def is_backup_class(cls):
"""Return true if given class supports back up. Currently this means a
gludb.data.Storable-derived class that has a mapping as defined in
gludb.config"""
return True if (
isclass(cls) and
issubclass(cls, Storable) and
get_mapping(cls, no_mapping_ok=True)... | [
"def",
"is_backup_class",
"(",
"cls",
")",
":",
"return",
"True",
"if",
"(",
"isclass",
"(",
"cls",
")",
"and",
"issubclass",
"(",
"cls",
",",
"Storable",
")",
"and",
"get_mapping",
"(",
"cls",
",",
"no_mapping_ok",
"=",
"True",
")",
")",
"else",
"Fals... | Return true if given class supports back up. Currently this means a
gludb.data.Storable-derived class that has a mapping as defined in
gludb.config | [
"Return",
"true",
"if",
"given",
"class",
"supports",
"back",
"up",
".",
"Currently",
"this",
"means",
"a",
"gludb",
".",
"data",
".",
"Storable",
"-",
"derived",
"class",
"that",
"has",
"a",
"mapping",
"as",
"defined",
"in",
"gludb",
".",
"config"
] | 25692528ff6fe8184a3570f61f31f1a90088a388 | https://github.com/memphis-iis/GLUDB/blob/25692528ff6fe8184a3570f61f31f1a90088a388/gludb/backup.py#L29-L37 |
38,015 | bryanwweber/thermohw | thermohw/convert_thermo_hw.py | process | def process(
hw_num: int,
problems_to_do: Optional[Iterable[int]] = None,
prefix: Optional[Path] = None,
by_hand: Optional[Iterable[int]] = None,
) -> None:
"""Process the homework problems in ``prefix`` folder.
Arguments
---------
hw_num
The number of this homework
problems... | python | def process(
hw_num: int,
problems_to_do: Optional[Iterable[int]] = None,
prefix: Optional[Path] = None,
by_hand: Optional[Iterable[int]] = None,
) -> None:
"""Process the homework problems in ``prefix`` folder.
Arguments
---------
hw_num
The number of this homework
problems... | [
"def",
"process",
"(",
"hw_num",
":",
"int",
",",
"problems_to_do",
":",
"Optional",
"[",
"Iterable",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"prefix",
":",
"Optional",
"[",
"Path",
"]",
"=",
"None",
",",
"by_hand",
":",
"Optional",
"[",
"Iterable",
... | Process the homework problems in ``prefix`` folder.
Arguments
---------
hw_num
The number of this homework
problems_to_do, optional
A list of the problems to be processed
prefix, optional
A `~pathlib.Path` to this homework assignment folder
by_hand, optional
A li... | [
"Process",
"the",
"homework",
"problems",
"in",
"prefix",
"folder",
"."
] | b6be276c14f8adf6ae23f5498065de74f868ccaa | https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/convert_thermo_hw.py#L80-L178 |
38,016 | bryanwweber/thermohw | thermohw/convert_thermo_hw.py | main | def main(argv: Optional[Sequence[str]] = None) -> None:
"""Parse arguments and process the homework assignment."""
parser = ArgumentParser(description="Convert Jupyter Notebook assignments to PDFs")
parser.add_argument(
"--hw",
type=int,
required=True,
help="Homework number t... | python | def main(argv: Optional[Sequence[str]] = None) -> None:
"""Parse arguments and process the homework assignment."""
parser = ArgumentParser(description="Convert Jupyter Notebook assignments to PDFs")
parser.add_argument(
"--hw",
type=int,
required=True,
help="Homework number t... | [
"def",
"main",
"(",
"argv",
":",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"None",
":",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"\"Convert Jupyter Notebook assignments to PDFs\"",
")",
"parser",
".",
"add_argu... | Parse arguments and process the homework assignment. | [
"Parse",
"arguments",
"and",
"process",
"the",
"homework",
"assignment",
"."
] | b6be276c14f8adf6ae23f5498065de74f868ccaa | https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/convert_thermo_hw.py#L181-L208 |
38,017 | pschmitt/shortmomi | shortmomi/views.py | get_vm_by_name | def get_vm_by_name(content, name, regex=False):
'''
Get a VM by its name
'''
return get_object_by_name(content, vim.VirtualMachine, name, regex) | python | def get_vm_by_name(content, name, regex=False):
'''
Get a VM by its name
'''
return get_object_by_name(content, vim.VirtualMachine, name, regex) | [
"def",
"get_vm_by_name",
"(",
"content",
",",
"name",
",",
"regex",
"=",
"False",
")",
":",
"return",
"get_object_by_name",
"(",
"content",
",",
"vim",
".",
"VirtualMachine",
",",
"name",
",",
"regex",
")"
] | Get a VM by its name | [
"Get",
"a",
"VM",
"by",
"its",
"name"
] | 81ad5a874e454ef0da93b7fd95474e7b9b9918d8 | https://github.com/pschmitt/shortmomi/blob/81ad5a874e454ef0da93b7fd95474e7b9b9918d8/shortmomi/views.py#L29-L33 |
38,018 | pschmitt/shortmomi | shortmomi/views.py | get_datacenter | def get_datacenter(content, obj):
'''
Get the datacenter to whom an object belongs
'''
datacenters = content.rootFolder.childEntity
for d in datacenters:
dch = get_all(content, d, type(obj))
if dch is not None and obj in dch:
return d | python | def get_datacenter(content, obj):
'''
Get the datacenter to whom an object belongs
'''
datacenters = content.rootFolder.childEntity
for d in datacenters:
dch = get_all(content, d, type(obj))
if dch is not None and obj in dch:
return d | [
"def",
"get_datacenter",
"(",
"content",
",",
"obj",
")",
":",
"datacenters",
"=",
"content",
".",
"rootFolder",
".",
"childEntity",
"for",
"d",
"in",
"datacenters",
":",
"dch",
"=",
"get_all",
"(",
"content",
",",
"d",
",",
"type",
"(",
"obj",
")",
")... | Get the datacenter to whom an object belongs | [
"Get",
"the",
"datacenter",
"to",
"whom",
"an",
"object",
"belongs"
] | 81ad5a874e454ef0da93b7fd95474e7b9b9918d8 | https://github.com/pschmitt/shortmomi/blob/81ad5a874e454ef0da93b7fd95474e7b9b9918d8/shortmomi/views.py#L95-L103 |
38,019 | pschmitt/shortmomi | shortmomi/views.py | get_all_vswitches | def get_all_vswitches(content):
'''
Get all the virtual switches
'''
vswitches = []
hosts = get_all_hosts(content)
for h in hosts:
for s in h.config.network.vswitch:
vswitches.append(s)
return vswitches | python | def get_all_vswitches(content):
'''
Get all the virtual switches
'''
vswitches = []
hosts = get_all_hosts(content)
for h in hosts:
for s in h.config.network.vswitch:
vswitches.append(s)
return vswitches | [
"def",
"get_all_vswitches",
"(",
"content",
")",
":",
"vswitches",
"=",
"[",
"]",
"hosts",
"=",
"get_all_hosts",
"(",
"content",
")",
"for",
"h",
"in",
"hosts",
":",
"for",
"s",
"in",
"h",
".",
"config",
".",
"network",
".",
"vswitch",
":",
"vswitches"... | Get all the virtual switches | [
"Get",
"all",
"the",
"virtual",
"switches"
] | 81ad5a874e454ef0da93b7fd95474e7b9b9918d8 | https://github.com/pschmitt/shortmomi/blob/81ad5a874e454ef0da93b7fd95474e7b9b9918d8/shortmomi/views.py#L122-L131 |
38,020 | pschmitt/shortmomi | shortmomi/views.py | print_vm_info | def print_vm_info(vm):
'''
Print information for a particular virtual machine
'''
summary = vm.summary
print('Name : ', summary.config.name)
print('Path : ', summary.config.vmPathName)
print('Guest : ', summary.config.guestFullName)
annotation = summary.config.annotation
if annotat... | python | def print_vm_info(vm):
'''
Print information for a particular virtual machine
'''
summary = vm.summary
print('Name : ', summary.config.name)
print('Path : ', summary.config.vmPathName)
print('Guest : ', summary.config.guestFullName)
annotation = summary.config.annotation
if annotat... | [
"def",
"print_vm_info",
"(",
"vm",
")",
":",
"summary",
"=",
"vm",
".",
"summary",
"print",
"(",
"'Name : '",
",",
"summary",
".",
"config",
".",
"name",
")",
"print",
"(",
"'Path : '",
",",
"summary",
".",
"config",
".",
"vmPathName",
")",
"print",
... | Print information for a particular virtual machine | [
"Print",
"information",
"for",
"a",
"particular",
"virtual",
"machine"
] | 81ad5a874e454ef0da93b7fd95474e7b9b9918d8 | https://github.com/pschmitt/shortmomi/blob/81ad5a874e454ef0da93b7fd95474e7b9b9918d8/shortmomi/views.py#L134-L152 |
38,021 | Workiva/contour | contour/contour.py | module_import | def module_import(module_path):
"""Imports the module indicated in name
Args:
module_path: string representing a module path such as
'app.config' or 'app.extras.my_module'
Returns:
the module matching name of the last component, ie: for
'app.extras.my_module' it returns a
... | python | def module_import(module_path):
"""Imports the module indicated in name
Args:
module_path: string representing a module path such as
'app.config' or 'app.extras.my_module'
Returns:
the module matching name of the last component, ie: for
'app.extras.my_module' it returns a
... | [
"def",
"module_import",
"(",
"module_path",
")",
":",
"try",
":",
"# Import whole module path.",
"module",
"=",
"__import__",
"(",
"module_path",
")",
"# Split into components: ['contour',",
"# 'extras','appengine','ndb_persistence'].",
"components",
"=",
"module_path",
".",
... | Imports the module indicated in name
Args:
module_path: string representing a module path such as
'app.config' or 'app.extras.my_module'
Returns:
the module matching name of the last component, ie: for
'app.extras.my_module' it returns a
reference to my_module
Raises... | [
"Imports",
"the",
"module",
"indicated",
"in",
"name"
] | 599e05c7ab6020b1ccc27e3f64f625abaec33ff2 | https://github.com/Workiva/contour/blob/599e05c7ab6020b1ccc27e3f64f625abaec33ff2/contour/contour.py#L93-L125 |
38,022 | Workiva/contour | contour/contour.py | find_contour_yaml | def find_contour_yaml(config_file=__file__, names=None):
"""
Traverse directory trees to find a contour.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
... | python | def find_contour_yaml(config_file=__file__, names=None):
"""
Traverse directory trees to find a contour.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
... | [
"def",
"find_contour_yaml",
"(",
"config_file",
"=",
"__file__",
",",
"names",
"=",
"None",
")",
":",
"checked",
"=",
"set",
"(",
")",
"contour_yaml",
"=",
"_find_countour_yaml",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"config_file",
")",
",",
"checke... | Traverse directory trees to find a contour.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
the path of contour.yaml or None if not found | [
"Traverse",
"directory",
"trees",
"to",
"find",
"a",
"contour",
".",
"yaml",
"file"
] | 599e05c7ab6020b1ccc27e3f64f625abaec33ff2 | https://github.com/Workiva/contour/blob/599e05c7ab6020b1ccc27e3f64f625abaec33ff2/contour/contour.py#L128-L148 |
38,023 | Workiva/contour | contour/contour.py | _find_countour_yaml | def _find_countour_yaml(start, checked, names=None):
"""Traverse the directory tree identified by start
until a directory already in checked is encountered or the path
of countour.yaml is found.
Checked is present both to make the loop termination easy
to reason about and so the same directories do... | python | def _find_countour_yaml(start, checked, names=None):
"""Traverse the directory tree identified by start
until a directory already in checked is encountered or the path
of countour.yaml is found.
Checked is present both to make the loop termination easy
to reason about and so the same directories do... | [
"def",
"_find_countour_yaml",
"(",
"start",
",",
"checked",
",",
"names",
"=",
"None",
")",
":",
"extensions",
"=",
"[",
"]",
"if",
"names",
":",
"for",
"name",
"in",
"names",
":",
"if",
"not",
"os",
".",
"path",
".",
"splitext",
"(",
"name",
")",
... | Traverse the directory tree identified by start
until a directory already in checked is encountered or the path
of countour.yaml is found.
Checked is present both to make the loop termination easy
to reason about and so the same directories do not get
rechecked
Args:
start: the path to... | [
"Traverse",
"the",
"directory",
"tree",
"identified",
"by",
"start",
"until",
"a",
"directory",
"already",
"in",
"checked",
"is",
"encountered",
"or",
"the",
"path",
"of",
"countour",
".",
"yaml",
"is",
"found",
"."
] | 599e05c7ab6020b1ccc27e3f64f625abaec33ff2 | https://github.com/Workiva/contour/blob/599e05c7ab6020b1ccc27e3f64f625abaec33ff2/contour/contour.py#L151-L189 |
38,024 | smarie/python-parsyfiles | parsyfiles/plugins_optional/support_for_attrs.py | _guess_type_from_validator | def _guess_type_from_validator(validator):
"""
Utility method to return the declared type of an attribute or None. It handles _OptionalValidator and _AndValidator
in order to unpack the validators.
:param validator:
:return: the type of attribute declared in an inner 'instance_of' validator (if any... | python | def _guess_type_from_validator(validator):
"""
Utility method to return the declared type of an attribute or None. It handles _OptionalValidator and _AndValidator
in order to unpack the validators.
:param validator:
:return: the type of attribute declared in an inner 'instance_of' validator (if any... | [
"def",
"_guess_type_from_validator",
"(",
"validator",
")",
":",
"if",
"isinstance",
"(",
"validator",
",",
"_OptionalValidator",
")",
":",
"# Optional : look inside",
"return",
"_guess_type_from_validator",
"(",
"validator",
".",
"validator",
")",
"elif",
"isinstance",... | Utility method to return the declared type of an attribute or None. It handles _OptionalValidator and _AndValidator
in order to unpack the validators.
:param validator:
:return: the type of attribute declared in an inner 'instance_of' validator (if any is found, the first one is used)
or None if no inn... | [
"Utility",
"method",
"to",
"return",
"the",
"declared",
"type",
"of",
"an",
"attribute",
"or",
"None",
".",
"It",
"handles",
"_OptionalValidator",
"and",
"_AndValidator",
"in",
"order",
"to",
"unpack",
"the",
"validators",
"."
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/plugins_optional/support_for_attrs.py#L6-L33 |
38,025 | smarie/python-parsyfiles | parsyfiles/plugins_optional/support_for_attrs.py | is_optional | def is_optional(attr):
"""
Helper method to find if an attribute is mandatory
:param attr:
:return:
"""
return isinstance(attr.validator, _OptionalValidator) or (attr.default is not None and attr.default is not NOTHING) | python | def is_optional(attr):
"""
Helper method to find if an attribute is mandatory
:param attr:
:return:
"""
return isinstance(attr.validator, _OptionalValidator) or (attr.default is not None and attr.default is not NOTHING) | [
"def",
"is_optional",
"(",
"attr",
")",
":",
"return",
"isinstance",
"(",
"attr",
".",
"validator",
",",
"_OptionalValidator",
")",
"or",
"(",
"attr",
".",
"default",
"is",
"not",
"None",
"and",
"attr",
".",
"default",
"is",
"not",
"NOTHING",
")"
] | Helper method to find if an attribute is mandatory
:param attr:
:return: | [
"Helper",
"method",
"to",
"find",
"if",
"an",
"attribute",
"is",
"mandatory"
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/plugins_optional/support_for_attrs.py#L48-L55 |
38,026 | bryanwweber/thermohw | thermohw/preprocessors.py | RawRemover.preprocess | def preprocess(
self, nb: "NotebookNode", resources: dict
) -> Tuple["NotebookNode", dict]:
"""Remove any raw cells from the Notebook.
By default, exclude raw cells from the output. Change this by including
global_content_filter->include_raw = True in the resources dictionary.
... | python | def preprocess(
self, nb: "NotebookNode", resources: dict
) -> Tuple["NotebookNode", dict]:
"""Remove any raw cells from the Notebook.
By default, exclude raw cells from the output. Change this by including
global_content_filter->include_raw = True in the resources dictionary.
... | [
"def",
"preprocess",
"(",
"self",
",",
"nb",
":",
"\"NotebookNode\"",
",",
"resources",
":",
"dict",
")",
"->",
"Tuple",
"[",
"\"NotebookNode\"",
",",
"dict",
"]",
":",
"if",
"not",
"resources",
".",
"get",
"(",
"\"global_content_filter\"",
",",
"{",
"}",
... | Remove any raw cells from the Notebook.
By default, exclude raw cells from the output. Change this by including
global_content_filter->include_raw = True in the resources dictionary.
This preprocessor is necessary because the NotebookExporter doesn't
include the exclude_raw config. | [
"Remove",
"any",
"raw",
"cells",
"from",
"the",
"Notebook",
"."
] | b6be276c14f8adf6ae23f5498065de74f868ccaa | https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/preprocessors.py#L109-L126 |
38,027 | bryanwweber/thermohw | thermohw/preprocessors.py | SolutionRemover.preprocess | def preprocess(
self, nb: "NotebookNode", resources: dict
) -> Tuple["NotebookNode", dict]:
"""Preprocess the entire notebook."""
if "remove_solution" not in resources:
raise KeyError("The resources dictionary must have a remove_solution key.")
if resources["remove_soluti... | python | def preprocess(
self, nb: "NotebookNode", resources: dict
) -> Tuple["NotebookNode", dict]:
"""Preprocess the entire notebook."""
if "remove_solution" not in resources:
raise KeyError("The resources dictionary must have a remove_solution key.")
if resources["remove_soluti... | [
"def",
"preprocess",
"(",
"self",
",",
"nb",
":",
"\"NotebookNode\"",
",",
"resources",
":",
"dict",
")",
"->",
"Tuple",
"[",
"\"NotebookNode\"",
",",
"dict",
"]",
":",
"if",
"\"remove_solution\"",
"not",
"in",
"resources",
":",
"raise",
"KeyError",
"(",
"... | Preprocess the entire notebook. | [
"Preprocess",
"the",
"entire",
"notebook",
"."
] | b6be276c14f8adf6ae23f5498065de74f868ccaa | https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/preprocessors.py#L143-L172 |
38,028 | gtaylor/EVE-Market-Data-Structures | emds/formats/unified/orders.py | parse_from_dict | def parse_from_dict(json_dict):
"""
Given a Unified Uploader message, parse the contents and return a
MarketOrderList.
:param dict json_dict: A Unified Uploader message as a JSON dict.
:rtype: MarketOrderList
:returns: An instance of MarketOrderList, containing the orders
within.
""... | python | def parse_from_dict(json_dict):
"""
Given a Unified Uploader message, parse the contents and return a
MarketOrderList.
:param dict json_dict: A Unified Uploader message as a JSON dict.
:rtype: MarketOrderList
:returns: An instance of MarketOrderList, containing the orders
within.
""... | [
"def",
"parse_from_dict",
"(",
"json_dict",
")",
":",
"order_columns",
"=",
"json_dict",
"[",
"'columns'",
"]",
"order_list",
"=",
"MarketOrderList",
"(",
"upload_keys",
"=",
"json_dict",
"[",
"'uploadKeys'",
"]",
",",
"order_generator",
"=",
"json_dict",
"[",
"... | Given a Unified Uploader message, parse the contents and return a
MarketOrderList.
:param dict json_dict: A Unified Uploader message as a JSON dict.
:rtype: MarketOrderList
:returns: An instance of MarketOrderList, containing the orders
within. | [
"Given",
"a",
"Unified",
"Uploader",
"message",
"parse",
"the",
"contents",
"and",
"return",
"a",
"MarketOrderList",
"."
] | 77d69b24f2aada3aeff8fba3d75891bfba8fdcf3 | https://github.com/gtaylor/EVE-Market-Data-Structures/blob/77d69b24f2aada3aeff8fba3d75891bfba8fdcf3/emds/formats/unified/orders.py#L37-L73 |
38,029 | gtaylor/EVE-Market-Data-Structures | emds/formats/unified/orders.py | encode_to_json | def encode_to_json(order_list):
"""
Encodes this list of MarketOrder instances to a JSON string.
:param MarketOrderList order_list: The order list to serialize.
:rtype: str
"""
rowsets = []
for items_in_region_list in order_list._orders.values():
region_id = items_in_region_list.reg... | python | def encode_to_json(order_list):
"""
Encodes this list of MarketOrder instances to a JSON string.
:param MarketOrderList order_list: The order list to serialize.
:rtype: str
"""
rowsets = []
for items_in_region_list in order_list._orders.values():
region_id = items_in_region_list.reg... | [
"def",
"encode_to_json",
"(",
"order_list",
")",
":",
"rowsets",
"=",
"[",
"]",
"for",
"items_in_region_list",
"in",
"order_list",
".",
"_orders",
".",
"values",
"(",
")",
":",
"region_id",
"=",
"items_in_region_list",
".",
"region_id",
"type_id",
"=",
"items_... | Encodes this list of MarketOrder instances to a JSON string.
:param MarketOrderList order_list: The order list to serialize.
:rtype: str | [
"Encodes",
"this",
"list",
"of",
"MarketOrder",
"instances",
"to",
"a",
"JSON",
"string",
"."
] | 77d69b24f2aada3aeff8fba3d75891bfba8fdcf3 | https://github.com/gtaylor/EVE-Market-Data-Structures/blob/77d69b24f2aada3aeff8fba3d75891bfba8fdcf3/emds/formats/unified/orders.py#L75-L127 |
38,030 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttFixedHeader.decode | def decode(f):
"""Extract a `MqttFixedHeader` from ``f``.
Parameters
----------
f: file
Object with read method.
Raises
-------
DecodeError
When bytes decoded have values incompatible with a
`MqttFixedHeader` object.
U... | python | def decode(f):
"""Extract a `MqttFixedHeader` from ``f``.
Parameters
----------
f: file
Object with read method.
Raises
-------
DecodeError
When bytes decoded have values incompatible with a
`MqttFixedHeader` object.
U... | [
"def",
"decode",
"(",
"f",
")",
":",
"decoder",
"=",
"mqtt_io",
".",
"FileDecoder",
"(",
"f",
")",
"(",
"byte_0",
",",
")",
"=",
"decoder",
".",
"unpack",
"(",
"mqtt_io",
".",
"FIELD_U8",
")",
"packet_type_u4",
"=",
"(",
"byte_0",
">>",
"4",
")",
"... | Extract a `MqttFixedHeader` from ``f``.
Parameters
----------
f: file
Object with read method.
Raises
-------
DecodeError
When bytes decoded have values incompatible with a
`MqttFixedHeader` object.
UnderflowDecodeError
... | [
"Extract",
"a",
"MqttFixedHeader",
"from",
"f",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L197-L237 |
38,031 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttSubscribe.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttSubscribe` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `subscribe`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Ra... | python | def decode_body(cls, header, f):
"""Generates a `MqttSubscribe` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `subscribe`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Ra... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"subscribe",
"decoder",
"=",
"mqtt_io",
".",
"FileDecoder",
"(",
"mqtt_io",
".",
"LimitReader",
"(",
"f",
",",
... | Generates a `MqttSubscribe` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `subscribe`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttSubscribe",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"subscribe",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L892-L932 |
38,032 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttSuback.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttSuback` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `suback`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
... | python | def decode_body(cls, header, f):
"""Generates a `MqttSuback` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `suback`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"suback",
"decoder",
"=",
"mqtt_io",
".",
"FileDecoder",
"(",
"mqtt_io",
".",
"LimitReader",
"(",
"f",
",",
"he... | Generates a `MqttSuback` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `suback`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttSuback",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"suback",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1044-L1082 |
38,033 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttPublish.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttPublish` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `publish`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises... | python | def decode_body(cls, header, f):
"""Generates a `MqttPublish` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `publish`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"publish",
"dupe",
"=",
"bool",
"(",
"header",
".",
"flags",
"&",
"0x08",
")",
"retain",
"=",
"bool",
"(",
... | Generates a `MqttPublish` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `publish`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttPublish",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"publish",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1269-L1316 |
38,034 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttPubrel.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttPubrel` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pubrel`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
... | python | def decode_body(cls, header, f):
"""Generates a `MqttPubrel` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pubrel`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"pubrel",
"decoder",
"=",
"mqtt_io",
".",
"FileDecoder",
"(",
"mqtt_io",
".",
"LimitReader",
"(",
"f",
",",
"he... | Generates a `MqttPubrel` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pubrel`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttPubrel",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"pubrel",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1513-L1544 |
38,035 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttUnsubscribe.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttUnsubscribe` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `unsubscribe`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
... | python | def decode_body(cls, header, f):
"""Generates a `MqttUnsubscribe` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `unsubscribe`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"unsubscribe",
"decoder",
"=",
"mqtt_io",
".",
"FileDecoder",
"(",
"mqtt_io",
".",
"LimitReader",
"(",
"f",
",",
... | Generates a `MqttUnsubscribe` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `unsubscribe`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttUnsubscribe",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"unsubscribe",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1690-L1725 |
38,036 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttUnsuback.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttUnsuback` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `unsuback`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Rais... | python | def decode_body(cls, header, f):
"""Generates a `MqttUnsuback` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `unsuback`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Rais... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"unsuback",
"decoder",
"=",
"mqtt_io",
".",
"FileDecoder",
"(",
"mqtt_io",
".",
"LimitReader",
"(",
"f",
",",
"... | Generates a `MqttUnsuback` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `unsuback`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttUnsuback",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"unsuback",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1767-L1798 |
38,037 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttPingreq.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttPingreq` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pingreq`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises... | python | def decode_body(cls, header, f):
"""Generates a `MqttPingreq` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pingreq`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"pingreq",
"if",
"header",
".",
"remaining_len",
"!=",
"0",
":",
"raise",
"DecodeError",
"(",
"'Extra bytes at end ... | Generates a `MqttPingreq` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pingreq`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttPingreq",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"pingreq",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1828-L1856 |
38,038 | kcallin/mqtt-codec | mqtt_codec/packet.py | MqttPingresp.decode_body | def decode_body(cls, header, f):
"""Generates a `MqttPingresp` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pingresp`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Rais... | python | def decode_body(cls, header, f):
"""Generates a `MqttPingresp` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pingresp`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Rais... | [
"def",
"decode_body",
"(",
"cls",
",",
"header",
",",
"f",
")",
":",
"assert",
"header",
".",
"packet_type",
"==",
"MqttControlPacketType",
".",
"pingresp",
"if",
"header",
".",
"remaining_len",
"!=",
"0",
":",
"raise",
"DecodeError",
"(",
"'Extra bytes at end... | Generates a `MqttPingresp` packet given a
`MqttFixedHeader`. This method asserts that header.packet_type
is `pingresp`.
Parameters
----------
header: MqttFixedHeader
f: file
Object with a read method.
Raises
------
DecodeError
... | [
"Generates",
"a",
"MqttPingresp",
"packet",
"given",
"a",
"MqttFixedHeader",
".",
"This",
"method",
"asserts",
"that",
"header",
".",
"packet_type",
"is",
"pingresp",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L1884-L1912 |
38,039 | legoktm/fab | phabricator/__init__.py | Phabricator.connect | def connect(self):
"""
Sets up your Phabricator session, it's not necessary to call
this directly
"""
if self.token:
self.phab_session = {'token': self.token}
return
req = self.req_session.post('%s/api/conduit.connect' % self.host, data={
... | python | def connect(self):
"""
Sets up your Phabricator session, it's not necessary to call
this directly
"""
if self.token:
self.phab_session = {'token': self.token}
return
req = self.req_session.post('%s/api/conduit.connect' % self.host, data={
... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"token",
":",
"self",
".",
"phab_session",
"=",
"{",
"'token'",
":",
"self",
".",
"token",
"}",
"return",
"req",
"=",
"self",
".",
"req_session",
".",
"post",
"(",
"'%s/api/conduit.connect'",
... | Sets up your Phabricator session, it's not necessary to call
this directly | [
"Sets",
"up",
"your",
"Phabricator",
"session",
"it",
"s",
"not",
"necessary",
"to",
"call",
"this",
"directly"
] | 29a8aba9671ae661864cbdb24e2ac9b842f41633 | https://github.com/legoktm/fab/blob/29a8aba9671ae661864cbdb24e2ac9b842f41633/phabricator/__init__.py#L56-L76 |
38,040 | inveniosoftware/kwalitee | kwalitee/cli/githooks.py | install | def install(force=False):
"""Install git hooks."""
ret, git_dir, _ = run("git rev-parse --show-toplevel")
if ret != 0:
click.echo(
"ERROR: Please run from within a GIT repository.",
file=sys.stderr)
raise click.Abort
git_dir = git_dir[0]
hooks_dir = os.path.j... | python | def install(force=False):
"""Install git hooks."""
ret, git_dir, _ = run("git rev-parse --show-toplevel")
if ret != 0:
click.echo(
"ERROR: Please run from within a GIT repository.",
file=sys.stderr)
raise click.Abort
git_dir = git_dir[0]
hooks_dir = os.path.j... | [
"def",
"install",
"(",
"force",
"=",
"False",
")",
":",
"ret",
",",
"git_dir",
",",
"_",
"=",
"run",
"(",
"\"git rev-parse --show-toplevel\"",
")",
"if",
"ret",
"!=",
"0",
":",
"click",
".",
"echo",
"(",
"\"ERROR: Please run from within a GIT repository.\"",
"... | Install git hooks. | [
"Install",
"git",
"hooks",
"."
] | 9124f8f55b15547fef08c6c43cabced314e70674 | https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/cli/githooks.py#L51-L76 |
38,041 | inveniosoftware/kwalitee | kwalitee/cli/githooks.py | uninstall | def uninstall():
"""Uninstall git hooks."""
ret, git_dir, _ = run("git rev-parse --show-toplevel")
if ret != 0:
click.echo(
"ERROR: Please run from within a GIT repository.",
file=sys.stderr)
raise click.Abort
git_dir = git_dir[0]
hooks_dir = os.path.join(git... | python | def uninstall():
"""Uninstall git hooks."""
ret, git_dir, _ = run("git rev-parse --show-toplevel")
if ret != 0:
click.echo(
"ERROR: Please run from within a GIT repository.",
file=sys.stderr)
raise click.Abort
git_dir = git_dir[0]
hooks_dir = os.path.join(git... | [
"def",
"uninstall",
"(",
")",
":",
"ret",
",",
"git_dir",
",",
"_",
"=",
"run",
"(",
"\"git rev-parse --show-toplevel\"",
")",
"if",
"ret",
"!=",
"0",
":",
"click",
".",
"echo",
"(",
"\"ERROR: Please run from within a GIT repository.\"",
",",
"file",
"=",
"sys... | Uninstall git hooks. | [
"Uninstall",
"git",
"hooks",
"."
] | 9124f8f55b15547fef08c6c43cabced314e70674 | https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/cli/githooks.py#L80-L96 |
38,042 | evansde77/dockerstache | src/dockerstache/__init__.py | setup_logger | def setup_logger():
"""
setup basic logger
"""
logger = logging.getLogger('dockerstache')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(stream=sys.stdout)
handler.setLevel(logging.INFO)
logger.addHandler(handler)
return logger | python | def setup_logger():
"""
setup basic logger
"""
logger = logging.getLogger('dockerstache')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(stream=sys.stdout)
handler.setLevel(logging.INFO)
logger.addHandler(handler)
return logger | [
"def",
"setup_logger",
"(",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'dockerstache'",
")",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"INFO",
")",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
"stream",
"=",
"sys",
".",
"s... | setup basic logger | [
"setup",
"basic",
"logger"
] | 929c102e9fffde322dbf17f8e69533a00976aacb | https://github.com/evansde77/dockerstache/blob/929c102e9fffde322dbf17f8e69533a00976aacb/src/dockerstache/__init__.py#L31-L40 |
38,043 | nimbusproject/dashi | dashi/bootstrap/containers.py | named_any | def named_any(name):
"""
Retrieve a Python object by its fully qualified name from the global Python
module namespace. The first part of the name, that describes a module,
will be discovered and imported. Each subsequent part of the name is
treated as the name of an attribute of the object specifi... | python | def named_any(name):
"""
Retrieve a Python object by its fully qualified name from the global Python
module namespace. The first part of the name, that describes a module,
will be discovered and imported. Each subsequent part of the name is
treated as the name of an attribute of the object specifi... | [
"def",
"named_any",
"(",
"name",
")",
":",
"assert",
"name",
",",
"'Empty module name'",
"names",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"topLevelPackage",
"=",
"None",
"moduleNames",
"=",
"names",
"[",
":",
"]",
"while",
"not",
"topLevelPackage",
":"... | Retrieve a Python object by its fully qualified name from the global Python
module namespace. The first part of the name, that describes a module,
will be discovered and imported. Each subsequent part of the name is
treated as the name of an attribute of the object specified by all of the
name which c... | [
"Retrieve",
"a",
"Python",
"object",
"by",
"its",
"fully",
"qualified",
"name",
"from",
"the",
"global",
"Python",
"module",
"namespace",
".",
"The",
"first",
"part",
"of",
"the",
"name",
"that",
"describes",
"a",
"module",
"will",
"be",
"discovered",
"and",... | 368b3963ec8abd60aebe0f81915429b45cbf4b5a | https://github.com/nimbusproject/dashi/blob/368b3963ec8abd60aebe0f81915429b45cbf4b5a/dashi/bootstrap/containers.py#L126-L158 |
38,044 | nimbusproject/dashi | dashi/bootstrap/containers.py | for_name | def for_name(modpath, classname):
'''
Returns a class of "classname" from module "modname".
'''
module = __import__(modpath, fromlist=[classname])
classobj = getattr(module, classname)
return classobj() | python | def for_name(modpath, classname):
'''
Returns a class of "classname" from module "modname".
'''
module = __import__(modpath, fromlist=[classname])
classobj = getattr(module, classname)
return classobj() | [
"def",
"for_name",
"(",
"modpath",
",",
"classname",
")",
":",
"module",
"=",
"__import__",
"(",
"modpath",
",",
"fromlist",
"=",
"[",
"classname",
"]",
")",
"classobj",
"=",
"getattr",
"(",
"module",
",",
"classname",
")",
"return",
"classobj",
"(",
")"... | Returns a class of "classname" from module "modname". | [
"Returns",
"a",
"class",
"of",
"classname",
"from",
"module",
"modname",
"."
] | 368b3963ec8abd60aebe0f81915429b45cbf4b5a | https://github.com/nimbusproject/dashi/blob/368b3963ec8abd60aebe0f81915429b45cbf4b5a/dashi/bootstrap/containers.py#L160-L166 |
38,045 | nimbusproject/dashi | dashi/bootstrap/containers.py | DotNotationGetItem._convert | def _convert(self, val):
""" Convert the type if necessary and return if a conversion happened. """
if isinstance(val, dict) and not isinstance(val, DotDict):
return DotDict(val), True
elif isinstance(val, list) and not isinstance(val, DotList):
return DotList(val), True
... | python | def _convert(self, val):
""" Convert the type if necessary and return if a conversion happened. """
if isinstance(val, dict) and not isinstance(val, DotDict):
return DotDict(val), True
elif isinstance(val, list) and not isinstance(val, DotList):
return DotList(val), True
... | [
"def",
"_convert",
"(",
"self",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
"and",
"not",
"isinstance",
"(",
"val",
",",
"DotDict",
")",
":",
"return",
"DotDict",
"(",
"val",
")",
",",
"True",
"elif",
"isinstance",
"(",
... | Convert the type if necessary and return if a conversion happened. | [
"Convert",
"the",
"type",
"if",
"necessary",
"and",
"return",
"if",
"a",
"conversion",
"happened",
"."
] | 368b3963ec8abd60aebe0f81915429b45cbf4b5a | https://github.com/nimbusproject/dashi/blob/368b3963ec8abd60aebe0f81915429b45cbf4b5a/dashi/bootstrap/containers.py#L11-L18 |
38,046 | mdickinson/refcycle | refcycle/annotated_graph.py | AnnotatedGraph.to_json | def to_json(self):
"""
Convert to a JSON string.
"""
obj = {
"vertices": [
{
"id": vertex.id,
"annotation": vertex.annotation,
}
for vertex in self.vertices
],
"ed... | python | def to_json(self):
"""
Convert to a JSON string.
"""
obj = {
"vertices": [
{
"id": vertex.id,
"annotation": vertex.annotation,
}
for vertex in self.vertices
],
"ed... | [
"def",
"to_json",
"(",
"self",
")",
":",
"obj",
"=",
"{",
"\"vertices\"",
":",
"[",
"{",
"\"id\"",
":",
"vertex",
".",
"id",
",",
"\"annotation\"",
":",
"vertex",
".",
"annotation",
",",
"}",
"for",
"vertex",
"in",
"self",
".",
"vertices",
"]",
",",
... | Convert to a JSON string. | [
"Convert",
"to",
"a",
"JSON",
"string",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/annotated_graph.py#L199-L223 |
38,047 | mdickinson/refcycle | refcycle/annotated_graph.py | AnnotatedGraph.from_json | def from_json(cls, json_graph):
"""
Reconstruct the graph from a graph exported to JSON.
"""
obj = json.loads(json_graph)
vertices = [
AnnotatedVertex(
id=vertex["id"],
annotation=vertex["annotation"],
)
for ve... | python | def from_json(cls, json_graph):
"""
Reconstruct the graph from a graph exported to JSON.
"""
obj = json.loads(json_graph)
vertices = [
AnnotatedVertex(
id=vertex["id"],
annotation=vertex["annotation"],
)
for ve... | [
"def",
"from_json",
"(",
"cls",
",",
"json_graph",
")",
":",
"obj",
"=",
"json",
".",
"loads",
"(",
"json_graph",
")",
"vertices",
"=",
"[",
"AnnotatedVertex",
"(",
"id",
"=",
"vertex",
"[",
"\"id\"",
"]",
",",
"annotation",
"=",
"vertex",
"[",
"\"anno... | Reconstruct the graph from a graph exported to JSON. | [
"Reconstruct",
"the",
"graph",
"from",
"a",
"graph",
"exported",
"to",
"JSON",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/annotated_graph.py#L226-L251 |
38,048 | mdickinson/refcycle | refcycle/annotated_graph.py | AnnotatedGraph.export_json | def export_json(self, filename):
"""
Export graph in JSON form to the given file.
"""
json_graph = self.to_json()
with open(filename, 'wb') as f:
f.write(json_graph.encode('utf-8')) | python | def export_json(self, filename):
"""
Export graph in JSON form to the given file.
"""
json_graph = self.to_json()
with open(filename, 'wb') as f:
f.write(json_graph.encode('utf-8')) | [
"def",
"export_json",
"(",
"self",
",",
"filename",
")",
":",
"json_graph",
"=",
"self",
".",
"to_json",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"json_graph",
".",
"encode",
"(",
"'utf-8'",... | Export graph in JSON form to the given file. | [
"Export",
"graph",
"in",
"JSON",
"form",
"to",
"the",
"given",
"file",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/annotated_graph.py#L253-L260 |
38,049 | mdickinson/refcycle | refcycle/annotated_graph.py | AnnotatedGraph.import_json | def import_json(cls, filename):
"""
Import graph from the given file. The file is expected
to contain UTF-8 encoded JSON data.
"""
with open(filename, 'rb') as f:
json_graph = f.read().decode('utf-8')
return cls.from_json(json_graph) | python | def import_json(cls, filename):
"""
Import graph from the given file. The file is expected
to contain UTF-8 encoded JSON data.
"""
with open(filename, 'rb') as f:
json_graph = f.read().decode('utf-8')
return cls.from_json(json_graph) | [
"def",
"import_json",
"(",
"cls",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"json_graph",
"=",
"f",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"cls",
".",
"from_json",
"(... | Import graph from the given file. The file is expected
to contain UTF-8 encoded JSON data. | [
"Import",
"graph",
"from",
"the",
"given",
"file",
".",
"The",
"file",
"is",
"expected",
"to",
"contain",
"UTF",
"-",
"8",
"encoded",
"JSON",
"data",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/annotated_graph.py#L263-L271 |
38,050 | mdickinson/refcycle | refcycle/annotated_graph.py | AnnotatedGraph.to_dot | def to_dot(self):
"""
Produce a graph in DOT format.
"""
edge_labels = {
edge.id: edge.annotation
for edge in self._edges
}
edges = [self._format_edge(edge_labels, edge) for edge in self._edges]
vertices = [
DOT_VERTEX_TEMPLA... | python | def to_dot(self):
"""
Produce a graph in DOT format.
"""
edge_labels = {
edge.id: edge.annotation
for edge in self._edges
}
edges = [self._format_edge(edge_labels, edge) for edge in self._edges]
vertices = [
DOT_VERTEX_TEMPLA... | [
"def",
"to_dot",
"(",
"self",
")",
":",
"edge_labels",
"=",
"{",
"edge",
".",
"id",
":",
"edge",
".",
"annotation",
"for",
"edge",
"in",
"self",
".",
"_edges",
"}",
"edges",
"=",
"[",
"self",
".",
"_format_edge",
"(",
"edge_labels",
",",
"edge",
")",... | Produce a graph in DOT format. | [
"Produce",
"a",
"graph",
"in",
"DOT",
"format",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/annotated_graph.py#L293-L316 |
38,051 | toumorokoshi/sprinter | sprinter/external/brew.py | install_brew | def install_brew(target_path):
""" Install brew to the target path """
if not os.path.exists(target_path):
try:
os.makedirs(target_path)
except OSError:
logger.warn("Unable to create directory %s for brew." % target_path)
logger.warn("Skipping...")
... | python | def install_brew(target_path):
""" Install brew to the target path """
if not os.path.exists(target_path):
try:
os.makedirs(target_path)
except OSError:
logger.warn("Unable to create directory %s for brew." % target_path)
logger.warn("Skipping...")
... | [
"def",
"install_brew",
"(",
"target_path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"target_path",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"target_path",
")",
"except",
"OSError",
":",
"logger",
".",
"warn",
"(",
"\"Unabl... | Install brew to the target path | [
"Install",
"brew",
"to",
"the",
"target",
"path"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/external/brew.py#L14-L23 |
38,052 | frascoweb/frasco | frasco/services.py | pass_service | def pass_service(*names):
"""Injects a service instance into the kwargs
"""
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
for name in names:
kwargs[name] = service_proxy(name)
return f(*args, **kwargs)
return wrapper
r... | python | def pass_service(*names):
"""Injects a service instance into the kwargs
"""
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
for name in names:
kwargs[name] = service_proxy(name)
return f(*args, **kwargs)
return wrapper
r... | [
"def",
"pass_service",
"(",
"*",
"names",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"name",
"in",
"names",
":",
... | Injects a service instance into the kwargs | [
"Injects",
"a",
"service",
"instance",
"into",
"the",
"kwargs"
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/services.py#L54-L64 |
38,053 | memphis-iis/GLUDB | gludb/backends/dynamodb.py | get_conn | def get_conn():
"""Return a connection to DynamoDB."""
if os.environ.get('DEBUG', False) or os.environ.get('travis', False):
# In DEBUG mode - use the local DynamoDB
# This also works for travis since we'll be running dynalite
conn = DynamoDBConnection(
host='localhost',
... | python | def get_conn():
"""Return a connection to DynamoDB."""
if os.environ.get('DEBUG', False) or os.environ.get('travis', False):
# In DEBUG mode - use the local DynamoDB
# This also works for travis since we'll be running dynalite
conn = DynamoDBConnection(
host='localhost',
... | [
"def",
"get_conn",
"(",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'DEBUG'",
",",
"False",
")",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'travis'",
",",
"False",
")",
":",
"# In DEBUG mode - use the local DynamoDB",
"# This also works for t... | Return a connection to DynamoDB. | [
"Return",
"a",
"connection",
"to",
"DynamoDB",
"."
] | 25692528ff6fe8184a3570f61f31f1a90088a388 | https://github.com/memphis-iis/GLUDB/blob/25692528ff6fe8184a3570f61f31f1a90088a388/gludb/backends/dynamodb.py#L19-L35 |
38,054 | memphis-iis/GLUDB | gludb/backends/dynamodb.py | Backend.table_schema_call | def table_schema_call(self, target, cls):
"""Perform a table schema call.
We call the callable target with the args and keywords needed for the
table defined by cls. This is how we centralize the Table.create and
Table ctor calls.
"""
index_defs = []
for name in ... | python | def table_schema_call(self, target, cls):
"""Perform a table schema call.
We call the callable target with the args and keywords needed for the
table defined by cls. This is how we centralize the Table.create and
Table ctor calls.
"""
index_defs = []
for name in ... | [
"def",
"table_schema_call",
"(",
"self",
",",
"target",
",",
"cls",
")",
":",
"index_defs",
"=",
"[",
"]",
"for",
"name",
"in",
"cls",
".",
"index_names",
"(",
")",
"or",
"[",
"]",
":",
"index_defs",
".",
"append",
"(",
"GlobalIncludeIndex",
"(",
"gsi_... | Perform a table schema call.
We call the callable target with the args and keywords needed for the
table defined by cls. This is how we centralize the Table.create and
Table ctor calls. | [
"Perform",
"a",
"table",
"schema",
"call",
"."
] | 25692528ff6fe8184a3570f61f31f1a90088a388 | https://github.com/memphis-iis/GLUDB/blob/25692528ff6fe8184a3570f61f31f1a90088a388/gludb/backends/dynamodb.py#L94-L114 |
38,055 | maikelboogerd/eventcore | eventcore/consumer.py | Consumer.thread | def thread(self):
"""
Start a thread for this consumer.
"""
log.info('@{}.thread starting'.format(self.__class__.__name__))
thread = threading.Thread(target=thread_wrapper(self.consume), args=())
thread.daemon = True
thread.start() | python | def thread(self):
"""
Start a thread for this consumer.
"""
log.info('@{}.thread starting'.format(self.__class__.__name__))
thread = threading.Thread(target=thread_wrapper(self.consume), args=())
thread.daemon = True
thread.start() | [
"def",
"thread",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'@{}.thread starting'",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
")",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"thread_wrapper",
"(",
"self... | Start a thread for this consumer. | [
"Start",
"a",
"thread",
"for",
"this",
"consumer",
"."
] | 3675f15344d70111874e0f5e5d3305c925dd38d4 | https://github.com/maikelboogerd/eventcore/blob/3675f15344d70111874e0f5e5d3305c925dd38d4/eventcore/consumer.py#L58-L65 |
38,056 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | _BaseParser._parse_multifile | def _parse_multifile(self, desired_type: Type[T], obj: PersistedObject,
parsing_plan_for_children: Dict[str, ParsingPlan], logger: Logger,
options: Dict[str, Dict[str, Any]]) -> T:
"""
First parse all children from the parsing plan, then calls _build_obj... | python | def _parse_multifile(self, desired_type: Type[T], obj: PersistedObject,
parsing_plan_for_children: Dict[str, ParsingPlan], logger: Logger,
options: Dict[str, Dict[str, Any]]) -> T:
"""
First parse all children from the parsing plan, then calls _build_obj... | [
"def",
"_parse_multifile",
"(",
"self",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"obj",
":",
"PersistedObject",
",",
"parsing_plan_for_children",
":",
"Dict",
"[",
"str",
",",
"ParsingPlan",
"]",
",",
"logger",
":",
"Logger",
",",
"options",
"... | First parse all children from the parsing plan, then calls _build_object_from_parsed_children
:param desired_type:
:param obj:
:param parsing_plan_for_children:
:param logger:
:param options:
:return: | [
"First",
"parse",
"all",
"children",
"from",
"the",
"parsing",
"plan",
"then",
"calls",
"_build_object_from_parsed_children"
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L71-L84 |
38,057 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | _BaseParsingPlan.execute | def execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T:
"""
Overrides the parent method to add log messages.
:param logger: the logger to use during parsing (optional: None is supported)
:param options:
:return:
"""
in_root_call = False
... | python | def execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T:
"""
Overrides the parent method to add log messages.
:param logger: the logger to use during parsing (optional: None is supported)
:param options:
:return:
"""
in_root_call = False
... | [
"def",
"execute",
"(",
"self",
",",
"logger",
":",
"Logger",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"T",
":",
"in_root_call",
"=",
"False",
"if",
"logger",
"is",
"not",
"None",
":",
"# l... | Overrides the parent method to add log messages.
:param logger: the logger to use during parsing (optional: None is supported)
:param options:
:return: | [
"Overrides",
"the",
"parent",
"method",
"to",
"add",
"log",
"messages",
"."
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L115-L159 |
38,058 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | _BaseParsingPlan._execute | def _execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T:
"""
Implementation of the parent class method.
Checks that self.parser is a _BaseParser, and calls the appropriate parsing method.
:param logger:
:param options:
:return:
"""
if ... | python | def _execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T:
"""
Implementation of the parent class method.
Checks that self.parser is a _BaseParser, and calls the appropriate parsing method.
:param logger:
:param options:
:return:
"""
if ... | [
"def",
"_execute",
"(",
"self",
",",
"logger",
":",
"Logger",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"T",
":",
"if",
"isinstance",
"(",
"self",
".",
"parser",
",",
"_BaseParser",
")",
":... | Implementation of the parent class method.
Checks that self.parser is a _BaseParser, and calls the appropriate parsing method.
:param logger:
:param options:
:return: | [
"Implementation",
"of",
"the",
"parent",
"class",
"method",
".",
"Checks",
"that",
"self",
".",
"parser",
"is",
"a",
"_BaseParser",
"and",
"calls",
"the",
"appropriate",
"parsing",
"method",
"."
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L161-L181 |
38,059 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | AnyParser.create_parsing_plan | def create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
_main_call: bool = True):
"""
Implements the abstract parent method by using the recursive parsing plan impl. Subclasses wishing to produce
their own parsing plans... | python | def create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
_main_call: bool = True):
"""
Implements the abstract parent method by using the recursive parsing plan impl. Subclasses wishing to produce
their own parsing plans... | [
"def",
"create_parsing_plan",
"(",
"self",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"filesystem_object",
":",
"PersistedObject",
",",
"logger",
":",
"Logger",
",",
"_main_call",
":",
"bool",
"=",
"True",
")",
":",
"in_root_call",
"=",
"False",
... | Implements the abstract parent method by using the recursive parsing plan impl. Subclasses wishing to produce
their own parsing plans should rather override _create_parsing_plan in order to benefit from this same log msg.
:param desired_type:
:param filesystem_object:
:param logger:
... | [
"Implements",
"the",
"abstract",
"parent",
"method",
"by",
"using",
"the",
"recursive",
"parsing",
"plan",
"impl",
".",
"Subclasses",
"wishing",
"to",
"produce",
"their",
"own",
"parsing",
"plans",
"should",
"rather",
"override",
"_create_parsing_plan",
"in",
"ord... | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L266-L304 |
38,060 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | AnyParser._create_parsing_plan | def _create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
log_only_last: bool = False):
"""
Adds a log message and creates a recursive parsing plan.
:param desired_type:
:param filesystem_object:
:param... | python | def _create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
log_only_last: bool = False):
"""
Adds a log message and creates a recursive parsing plan.
:param desired_type:
:param filesystem_object:
:param... | [
"def",
"_create_parsing_plan",
"(",
"self",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"filesystem_object",
":",
"PersistedObject",
",",
"logger",
":",
"Logger",
",",
"log_only_last",
":",
"bool",
"=",
"False",
")",
":",
"logger",
".",
"debug",
... | Adds a log message and creates a recursive parsing plan.
:param desired_type:
:param filesystem_object:
:param logger:
:param log_only_last: a flag to only log the last part of the file path (default False)
:return: | [
"Adds",
"a",
"log",
"message",
"and",
"creates",
"a",
"recursive",
"parsing",
"plan",
"."
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L306-L319 |
38,061 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | AnyParser._get_parsing_plan_for_multifile_children | def _get_parsing_plan_for_multifile_children(self, obj_on_fs: PersistedObject, desired_type: Type[T],
logger: Logger) -> Dict[str, ParsingPlan[T]]:
"""
This method is called by the _RecursiveParsingPlan when created.
Implementing classes should re... | python | def _get_parsing_plan_for_multifile_children(self, obj_on_fs: PersistedObject, desired_type: Type[T],
logger: Logger) -> Dict[str, ParsingPlan[T]]:
"""
This method is called by the _RecursiveParsingPlan when created.
Implementing classes should re... | [
"def",
"_get_parsing_plan_for_multifile_children",
"(",
"self",
",",
"obj_on_fs",
":",
"PersistedObject",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"logger",
":",
"Logger",
")",
"->",
"Dict",
"[",
"str",
",",
"ParsingPlan",
"[",
"T",
"]",
"]",
... | This method is called by the _RecursiveParsingPlan when created.
Implementing classes should return a dictionary containing a ParsingPlan for each child they plan to parse
using this framework. Note that for the files that will be parsed using a parsing library it is not necessary to
return a Pa... | [
"This",
"method",
"is",
"called",
"by",
"the",
"_RecursiveParsingPlan",
"when",
"created",
".",
"Implementing",
"classes",
"should",
"return",
"a",
"dictionary",
"containing",
"a",
"ParsingPlan",
"for",
"each",
"child",
"they",
"plan",
"to",
"parse",
"using",
"t... | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L322-L339 |
38,062 | smarie/python-parsyfiles | parsyfiles/parsing_core.py | SingleFileParserFunction._parse_singlefile | def _parse_singlefile(self, desired_type: Type[T], file_path: str, encoding: str, logger: Logger,
options: Dict[str, Dict[str, Any]]) -> T:
"""
Relies on the inner parsing function to parse the file.
If _streaming_mode is True, the file will be opened and closed by this... | python | def _parse_singlefile(self, desired_type: Type[T], file_path: str, encoding: str, logger: Logger,
options: Dict[str, Dict[str, Any]]) -> T:
"""
Relies on the inner parsing function to parse the file.
If _streaming_mode is True, the file will be opened and closed by this... | [
"def",
"_parse_singlefile",
"(",
"self",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"file_path",
":",
"str",
",",
"encoding",
":",
"str",
",",
"logger",
":",
"Logger",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
... | Relies on the inner parsing function to parse the file.
If _streaming_mode is True, the file will be opened and closed by this method. Otherwise the parsing function
will be responsible to open and close.
:param desired_type:
:param file_path:
:param encoding:
:param opt... | [
"Relies",
"on",
"the",
"inner",
"parsing",
"function",
"to",
"parse",
"the",
"file",
".",
"If",
"_streaming_mode",
"is",
"True",
"the",
"file",
"will",
"be",
"opened",
"and",
"closed",
"by",
"this",
"method",
".",
"Otherwise",
"the",
"parsing",
"function",
... | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core.py#L573-L615 |
38,063 | smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | print_error_to_io_stream | def print_error_to_io_stream(err: Exception, io: TextIOBase, print_big_traceback : bool = True):
"""
Utility method to print an exception's content to a stream
:param err:
:param io:
:param print_big_traceback:
:return:
"""
if print_big_traceback:
traceback.print_tb(err.__traceb... | python | def print_error_to_io_stream(err: Exception, io: TextIOBase, print_big_traceback : bool = True):
"""
Utility method to print an exception's content to a stream
:param err:
:param io:
:param print_big_traceback:
:return:
"""
if print_big_traceback:
traceback.print_tb(err.__traceb... | [
"def",
"print_error_to_io_stream",
"(",
"err",
":",
"Exception",
",",
"io",
":",
"TextIOBase",
",",
"print_big_traceback",
":",
"bool",
"=",
"True",
")",
":",
"if",
"print_big_traceback",
":",
"traceback",
".",
"print_tb",
"(",
"err",
".",
"__traceback__",
","... | Utility method to print an exception's content to a stream
:param err:
:param io:
:param print_big_traceback:
:return: | [
"Utility",
"method",
"to",
"print",
"an",
"exception",
"s",
"content",
"to",
"a",
"stream"
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L82-L95 |
38,064 | smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | should_hide_traceback | def should_hide_traceback(e):
""" Returns True if we can hide the error traceback in the warnings messages """
if type(e) in {WrongTypeCreatedError, CascadeError, TypeInformationRequiredError}:
return True
elif type(e).__name__ in {'InvalidAttributeNameForConstructorError', 'MissingMandatoryAttribut... | python | def should_hide_traceback(e):
""" Returns True if we can hide the error traceback in the warnings messages """
if type(e) in {WrongTypeCreatedError, CascadeError, TypeInformationRequiredError}:
return True
elif type(e).__name__ in {'InvalidAttributeNameForConstructorError', 'MissingMandatoryAttribut... | [
"def",
"should_hide_traceback",
"(",
"e",
")",
":",
"if",
"type",
"(",
"e",
")",
"in",
"{",
"WrongTypeCreatedError",
",",
"CascadeError",
",",
"TypeInformationRequiredError",
"}",
":",
"return",
"True",
"elif",
"type",
"(",
"e",
")",
".",
"__name__",
"in",
... | Returns True if we can hide the error traceback in the warnings messages | [
"Returns",
"True",
"if",
"we",
"can",
"hide",
"the",
"error",
"traceback",
"in",
"the",
"warnings",
"messages"
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L165-L172 |
38,065 | smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | CascadingParser._create_parsing_plan | def _create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
log_only_last: bool = False) -> ParsingPlan[T]:
"""
Creates a parsing plan to parse the given filesystem object into the given desired_type.
This overrides the m... | python | def _create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
log_only_last: bool = False) -> ParsingPlan[T]:
"""
Creates a parsing plan to parse the given filesystem object into the given desired_type.
This overrides the m... | [
"def",
"_create_parsing_plan",
"(",
"self",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"filesystem_object",
":",
"PersistedObject",
",",
"logger",
":",
"Logger",
",",
"log_only_last",
":",
"bool",
"=",
"False",
")",
"->",
"ParsingPlan",
"[",
"T",
... | Creates a parsing plan to parse the given filesystem object into the given desired_type.
This overrides the method in AnyParser, in order to provide a 'cascading' parsing plan
:param desired_type:
:param filesystem_object:
:param logger:
:param log_only_last: a flag to only log ... | [
"Creates",
"a",
"parsing",
"plan",
"to",
"parse",
"the",
"given",
"filesystem",
"object",
"into",
"the",
"given",
"desired_type",
".",
"This",
"overrides",
"the",
"method",
"in",
"AnyParser",
"in",
"order",
"to",
"provide",
"a",
"cascading",
"parsing",
"plan"
... | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L479-L495 |
38,066 | smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | ParsingChain.are_worth_chaining | def are_worth_chaining(base_parser: Parser, to_type: Type[S], converter: Converter[S,T]) -> bool:
"""
Utility method to check if it makes sense to chain this parser configured with the given to_type, with this
converter. It is an extension of ConverterChain.are_worth_chaining
:param ba... | python | def are_worth_chaining(base_parser: Parser, to_type: Type[S], converter: Converter[S,T]) -> bool:
"""
Utility method to check if it makes sense to chain this parser configured with the given to_type, with this
converter. It is an extension of ConverterChain.are_worth_chaining
:param ba... | [
"def",
"are_worth_chaining",
"(",
"base_parser",
":",
"Parser",
",",
"to_type",
":",
"Type",
"[",
"S",
"]",
",",
"converter",
":",
"Converter",
"[",
"S",
",",
"T",
"]",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"converter",
",",
"ConversionChain",... | Utility method to check if it makes sense to chain this parser configured with the given to_type, with this
converter. It is an extension of ConverterChain.are_worth_chaining
:param base_parser:
:param to_type:
:param converter:
:return: | [
"Utility",
"method",
"to",
"check",
"if",
"it",
"makes",
"sense",
"to",
"chain",
"this",
"parser",
"configured",
"with",
"the",
"given",
"to_type",
"with",
"this",
"converter",
".",
"It",
"is",
"an",
"extension",
"of",
"ConverterChain",
".",
"are_worth_chainin... | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L623-L640 |
38,067 | majuss/lupupy | lupupy/devices/alarm.py | LupusecAlarm.set_mode | def set_mode(self, mode):
"""Set Lupusec alarm mode."""
_LOGGER.debug('State change called from alarm device')
if not mode:
_LOGGER.info('No mode supplied')
elif mode not in CONST.ALL_MODES:
_LOGGER.warning('Invalid mode')
response_object = self._lupusec.s... | python | def set_mode(self, mode):
"""Set Lupusec alarm mode."""
_LOGGER.debug('State change called from alarm device')
if not mode:
_LOGGER.info('No mode supplied')
elif mode not in CONST.ALL_MODES:
_LOGGER.warning('Invalid mode')
response_object = self._lupusec.s... | [
"def",
"set_mode",
"(",
"self",
",",
"mode",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'State change called from alarm device'",
")",
"if",
"not",
"mode",
":",
"_LOGGER",
".",
"info",
"(",
"'No mode supplied'",
")",
"elif",
"mode",
"not",
"in",
"CONST",
".",
... | Set Lupusec alarm mode. | [
"Set",
"Lupusec",
"alarm",
"mode",
"."
] | 71af6c397837ffc393c7b8122be175602638d3c6 | https://github.com/majuss/lupupy/blob/71af6c397837ffc393c7b8122be175602638d3c6/lupupy/devices/alarm.py#L24-L37 |
38,068 | nikcub/floyd | floyd/util/unicode.py | to_utf8 | def to_utf8(value):
"""Returns a string encoded using UTF-8.
This function comes from `Tornado`_.
:param value:
A unicode or string to be encoded.
:returns:
The encoded string.
"""
if isinstance(value, unicode):
return value.encode('utf-8')
assert isinstance(value, str)
return value | python | def to_utf8(value):
"""Returns a string encoded using UTF-8.
This function comes from `Tornado`_.
:param value:
A unicode or string to be encoded.
:returns:
The encoded string.
"""
if isinstance(value, unicode):
return value.encode('utf-8')
assert isinstance(value, str)
return value | [
"def",
"to_utf8",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"return",
"value",
".",
"encode",
"(",
"'utf-8'",
")",
"assert",
"isinstance",
"(",
"value",
",",
"str",
")",
"return",
"value"
] | Returns a string encoded using UTF-8.
This function comes from `Tornado`_.
:param value:
A unicode or string to be encoded.
:returns:
The encoded string. | [
"Returns",
"a",
"string",
"encoded",
"using",
"UTF",
"-",
"8",
"."
] | 5772d0047efb11c9ce5f7d234a9da4576ce24edc | https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/unicode.py#L42-L56 |
38,069 | nikcub/floyd | floyd/util/unicode.py | to_unicode | def to_unicode(value):
"""Returns a unicode string from a string, using UTF-8 to decode if needed.
This function comes from `Tornado`_.
:param value:
A unicode or string to be decoded.
:returns:
The decoded string.
"""
if isinstance(value, str):
return value.decode('utf-8')
assert isinstanc... | python | def to_unicode(value):
"""Returns a unicode string from a string, using UTF-8 to decode if needed.
This function comes from `Tornado`_.
:param value:
A unicode or string to be decoded.
:returns:
The decoded string.
"""
if isinstance(value, str):
return value.decode('utf-8')
assert isinstanc... | [
"def",
"to_unicode",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"value",
".",
"decode",
"(",
"'utf-8'",
")",
"assert",
"isinstance",
"(",
"value",
",",
"unicode",
")",
"return",
"value"
] | Returns a unicode string from a string, using UTF-8 to decode if needed.
This function comes from `Tornado`_.
:param value:
A unicode or string to be decoded.
:returns:
The decoded string. | [
"Returns",
"a",
"unicode",
"string",
"from",
"a",
"string",
"using",
"UTF",
"-",
"8",
"to",
"decode",
"if",
"needed",
"."
] | 5772d0047efb11c9ce5f7d234a9da4576ce24edc | https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/unicode.py#L59-L73 |
38,070 | VikParuchuri/percept | percept/management/base.py | get_commands | def get_commands():
"""
Get all valid commands
return - all valid commands in dictionary form
"""
commands = {}
#Try to load the settings file (settings can be specified on the command line) and get the INSTALLED_APPS
try:
from percept.conf.base import settings
apps = settin... | python | def get_commands():
"""
Get all valid commands
return - all valid commands in dictionary form
"""
commands = {}
#Try to load the settings file (settings can be specified on the command line) and get the INSTALLED_APPS
try:
from percept.conf.base import settings
apps = settin... | [
"def",
"get_commands",
"(",
")",
":",
"commands",
"=",
"{",
"}",
"#Try to load the settings file (settings can be specified on the command line) and get the INSTALLED_APPS",
"try",
":",
"from",
"percept",
".",
"conf",
".",
"base",
"import",
"settings",
"apps",
"=",
"setti... | Get all valid commands
return - all valid commands in dictionary form | [
"Get",
"all",
"valid",
"commands",
"return",
"-",
"all",
"valid",
"commands",
"in",
"dictionary",
"form"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/management/base.py#L62-L85 |
38,071 | VikParuchuri/percept | percept/management/base.py | Management.execute | def execute(self):
"""
Run the command with the command line arguments
"""
#Initialize the option parser
parser = LaxOptionParser(
usage="%prog subcommand [options] [args]",
option_list=BaseCommand.option_list #This will define what is allowed input to the... | python | def execute(self):
"""
Run the command with the command line arguments
"""
#Initialize the option parser
parser = LaxOptionParser(
usage="%prog subcommand [options] [args]",
option_list=BaseCommand.option_list #This will define what is allowed input to the... | [
"def",
"execute",
"(",
"self",
")",
":",
"#Initialize the option parser",
"parser",
"=",
"LaxOptionParser",
"(",
"usage",
"=",
"\"%prog subcommand [options] [args]\"",
",",
"option_list",
"=",
"BaseCommand",
".",
"option_list",
"#This will define what is allowed input to the ... | Run the command with the command line arguments | [
"Run",
"the",
"command",
"with",
"the",
"command",
"line",
"arguments"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/management/base.py#L133-L162 |
38,072 | VikParuchuri/percept | percept/management/base.py | Management.help_text | def help_text(self):
"""
Formats and prints the help text from the command list
"""
help_text = '\n'.join(sorted(get_commands().keys()))
help_text = "\nCommands:\n" + help_text
return help_text | python | def help_text(self):
"""
Formats and prints the help text from the command list
"""
help_text = '\n'.join(sorted(get_commands().keys()))
help_text = "\nCommands:\n" + help_text
return help_text | [
"def",
"help_text",
"(",
"self",
")",
":",
"help_text",
"=",
"'\\n'",
".",
"join",
"(",
"sorted",
"(",
"get_commands",
"(",
")",
".",
"keys",
"(",
")",
")",
")",
"help_text",
"=",
"\"\\nCommands:\\n\"",
"+",
"help_text",
"return",
"help_text"
] | Formats and prints the help text from the command list | [
"Formats",
"and",
"prints",
"the",
"help",
"text",
"from",
"the",
"command",
"list"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/management/base.py#L165-L171 |
38,073 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.register | def register(self):
""" Registers a new device with the name entity_id. This device has permissions for services like subscribe,
publish and access historical data.
"""
register_url = self.base_url + "api/0.1.0/register"
register_headers = {
"apikey": str(self.owner_... | python | def register(self):
""" Registers a new device with the name entity_id. This device has permissions for services like subscribe,
publish and access historical data.
"""
register_url = self.base_url + "api/0.1.0/register"
register_headers = {
"apikey": str(self.owner_... | [
"def",
"register",
"(",
"self",
")",
":",
"register_url",
"=",
"self",
".",
"base_url",
"+",
"\"api/0.1.0/register\"",
"register_headers",
"=",
"{",
"\"apikey\"",
":",
"str",
"(",
"self",
".",
"owner_api_key",
")",
",",
"\"resourceID\"",
":",
"str",
"(",
"se... | Registers a new device with the name entity_id. This device has permissions for services like subscribe,
publish and access historical data. | [
"Registers",
"a",
"new",
"device",
"with",
"the",
"name",
"entity_id",
".",
"This",
"device",
"has",
"permissions",
"for",
"services",
"like",
"subscribe",
"publish",
"and",
"access",
"historical",
"data",
"."
] | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L44-L64 |
38,074 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.no_ssl_verification | def no_ssl_verification(self):
""" Requests module fails due to lets encrypt ssl encryption. Will be fixed in the future release."""
try:
from functools import partialmethod
except ImportError:
# Python 2 fallback: https://gist.github.com/carymrobbins/8940382
... | python | def no_ssl_verification(self):
""" Requests module fails due to lets encrypt ssl encryption. Will be fixed in the future release."""
try:
from functools import partialmethod
except ImportError:
# Python 2 fallback: https://gist.github.com/carymrobbins/8940382
... | [
"def",
"no_ssl_verification",
"(",
"self",
")",
":",
"try",
":",
"from",
"functools",
"import",
"partialmethod",
"except",
"ImportError",
":",
"# Python 2 fallback: https://gist.github.com/carymrobbins/8940382",
"from",
"functools",
"import",
"partial",
"class",
"partialmet... | Requests module fails due to lets encrypt ssl encryption. Will be fixed in the future release. | [
"Requests",
"module",
"fails",
"due",
"to",
"lets",
"encrypt",
"ssl",
"encryption",
".",
"Will",
"be",
"fixed",
"in",
"the",
"future",
"release",
"."
] | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L67-L87 |
38,075 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.publish | def publish(self, data):
""" This function allows an entity to publish data to the middleware.
Args:
data (string): contents to be published by this entity.
"""
if self.entity_api_key == "":
return {'status': 'failure', 'response': 'No API key found in request... | python | def publish(self, data):
""" This function allows an entity to publish data to the middleware.
Args:
data (string): contents to be published by this entity.
"""
if self.entity_api_key == "":
return {'status': 'failure', 'response': 'No API key found in request... | [
"def",
"publish",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"publish_url",
"=",
"self",
".",
"base_ur... | This function allows an entity to publish data to the middleware.
Args:
data (string): contents to be published by this entity. | [
"This",
"function",
"allows",
"an",
"entity",
"to",
"publish",
"data",
"to",
"the",
"middleware",
"."
] | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L89-L117 |
38,076 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.db | def db(self, entity, query_filters="size=10"):
""" This function allows an entity to access the historic data.
Args:
entity (string): Name of the device to listen to
query_filters (string): Elastic search response format string
example,... | python | def db(self, entity, query_filters="size=10"):
""" This function allows an entity to access the historic data.
Args:
entity (string): Name of the device to listen to
query_filters (string): Elastic search response format string
example,... | [
"def",
"db",
"(",
"self",
",",
"entity",
",",
"query_filters",
"=",
"\"size=10\"",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"h... | This function allows an entity to access the historic data.
Args:
entity (string): Name of the device to listen to
query_filters (string): Elastic search response format string
example, "pretty=true&size=10" | [
"This",
"function",
"allows",
"an",
"entity",
"to",
"access",
"the",
"historic",
"data",
"."
] | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L119-L152 |
38,077 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.bind | def bind(self, devices_to_bind):
""" This function allows an entity to list the devices to subscribe for data. This function must be called
at least once, before doing a subscribe. Subscribe function will listen to devices that are bound here.
Args:
devices_to_bind (list): an array... | python | def bind(self, devices_to_bind):
""" This function allows an entity to list the devices to subscribe for data. This function must be called
at least once, before doing a subscribe. Subscribe function will listen to devices that are bound here.
Args:
devices_to_bind (list): an array... | [
"def",
"bind",
"(",
"self",
",",
"devices_to_bind",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"url",
"=",
"self",
".",
"base_ur... | This function allows an entity to list the devices to subscribe for data. This function must be called
at least once, before doing a subscribe. Subscribe function will listen to devices that are bound here.
Args:
devices_to_bind (list): an array of devices to listen to.
... | [
"This",
"function",
"allows",
"an",
"entity",
"to",
"list",
"the",
"devices",
"to",
"subscribe",
"for",
"data",
".",
"This",
"function",
"must",
"be",
"called",
"at",
"least",
"once",
"before",
"doing",
"a",
"subscribe",
".",
"Subscribe",
"function",
"will",... | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L154-L186 |
38,078 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.unbind | def unbind(self, devices_to_unbind):
""" This function allows an entity to unbound devices that are already bound.
Args:
devices_to_unbind (list): an array of devices that are to be unbound ( stop listening)
Example unbind(["test10","testDemo105"])
... | python | def unbind(self, devices_to_unbind):
""" This function allows an entity to unbound devices that are already bound.
Args:
devices_to_unbind (list): an array of devices that are to be unbound ( stop listening)
Example unbind(["test10","testDemo105"])
... | [
"def",
"unbind",
"(",
"self",
",",
"devices_to_unbind",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"url",
"=",
"self",
".",
"bas... | This function allows an entity to unbound devices that are already bound.
Args:
devices_to_unbind (list): an array of devices that are to be unbound ( stop listening)
Example unbind(["test10","testDemo105"]) | [
"This",
"function",
"allows",
"an",
"entity",
"to",
"unbound",
"devices",
"that",
"are",
"already",
"bound",
"."
] | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L188-L219 |
38,079 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.subscribe | def subscribe(self, devices_to_bind=[]):
""" This function allows an entity to subscribe for data from the devices specified in the bind operation. It
creates a thread with an event loop to manager the tasks created in start_subscribe_worker.
Args:
devices_to_bind (list): an array o... | python | def subscribe(self, devices_to_bind=[]):
""" This function allows an entity to subscribe for data from the devices specified in the bind operation. It
creates a thread with an event loop to manager the tasks created in start_subscribe_worker.
Args:
devices_to_bind (list): an array o... | [
"def",
"subscribe",
"(",
"self",
",",
"devices_to_bind",
"=",
"[",
"]",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"self",
".",
... | This function allows an entity to subscribe for data from the devices specified in the bind operation. It
creates a thread with an event loop to manager the tasks created in start_subscribe_worker.
Args:
devices_to_bind (list): an array of devices to listen to | [
"This",
"function",
"allows",
"an",
"entity",
"to",
"subscribe",
"for",
"data",
"from",
"the",
"devices",
"specified",
"in",
"the",
"bind",
"operation",
".",
"It",
"creates",
"a",
"thread",
"with",
"an",
"event",
"loop",
"to",
"manager",
"the",
"tasks",
"c... | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L221-L234 |
38,080 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.start_subscribe_worker | def start_subscribe_worker(self, loop):
""" Switch to new event loop as a thread and run until complete. """
url = self.base_url + "api/0.1.0/subscribe"
task = loop.create_task(self.asynchronously_get_data(url + "?name={0}".format(self.entity_id)))
asyncio.set_event_loop(loop)
lo... | python | def start_subscribe_worker(self, loop):
""" Switch to new event loop as a thread and run until complete. """
url = self.base_url + "api/0.1.0/subscribe"
task = loop.create_task(self.asynchronously_get_data(url + "?name={0}".format(self.entity_id)))
asyncio.set_event_loop(loop)
lo... | [
"def",
"start_subscribe_worker",
"(",
"self",
",",
"loop",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"\"api/0.1.0/subscribe\"",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"asynchronously_get_data",
"(",
"url",
"+",
"\"?name={0}\"",
".... | Switch to new event loop as a thread and run until complete. | [
"Switch",
"to",
"new",
"event",
"loop",
"as",
"a",
"thread",
"and",
"run",
"until",
"complete",
"."
] | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L237-L243 |
38,081 | rbccps-iisc/ideam-python-sdk | ideam/entity.py | Entity.stop_subscribe | def stop_subscribe(self):
""" This function is used to stop the event loop created when subscribe is called. But this function doesn't
stop the thread and should be avoided until its completely developed.
"""
asyncio.gather(*asyncio.Task.all_tasks()).cancel()
self.event_loop.sto... | python | def stop_subscribe(self):
""" This function is used to stop the event loop created when subscribe is called. But this function doesn't
stop the thread and should be avoided until its completely developed.
"""
asyncio.gather(*asyncio.Task.all_tasks()).cancel()
self.event_loop.sto... | [
"def",
"stop_subscribe",
"(",
"self",
")",
":",
"asyncio",
".",
"gather",
"(",
"*",
"asyncio",
".",
"Task",
".",
"all_tasks",
"(",
")",
")",
".",
"cancel",
"(",
")",
"self",
".",
"event_loop",
".",
"stop",
"(",
")",
"self",
".",
"event_loop",
".",
... | This function is used to stop the event loop created when subscribe is called. But this function doesn't
stop the thread and should be avoided until its completely developed. | [
"This",
"function",
"is",
"used",
"to",
"stop",
"the",
"event",
"loop",
"created",
"when",
"subscribe",
"is",
"called",
".",
"But",
"this",
"function",
"doesn",
"t",
"stop",
"the",
"thread",
"and",
"should",
"be",
"avoided",
"until",
"its",
"completely",
"... | fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98 | https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L272-L279 |
38,082 | nikcub/floyd | floyd/util/timesince.py | timeuntil | def timeuntil(d, now=None):
"""
Like timesince, but returns a string measuring the time until
the given time.
"""
if not now:
if getattr(d, 'tzinfo', None):
now = datetime.datetime.now(LocalTimezone(d))
else:
now = datetime.datetime.now()
return timesince(... | python | def timeuntil(d, now=None):
"""
Like timesince, but returns a string measuring the time until
the given time.
"""
if not now:
if getattr(d, 'tzinfo', None):
now = datetime.datetime.now(LocalTimezone(d))
else:
now = datetime.datetime.now()
return timesince(... | [
"def",
"timeuntil",
"(",
"d",
",",
"now",
"=",
"None",
")",
":",
"if",
"not",
"now",
":",
"if",
"getattr",
"(",
"d",
",",
"'tzinfo'",
",",
"None",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
"LocalTimezone",
"(",
"d",
")",... | Like timesince, but returns a string measuring the time until
the given time. | [
"Like",
"timesince",
"but",
"returns",
"a",
"string",
"measuring",
"the",
"time",
"until",
"the",
"given",
"time",
"."
] | 5772d0047efb11c9ce5f7d234a9da4576ce24edc | https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/timesince.py#L59-L69 |
38,083 | toumorokoshi/sprinter | sprinter/external/pippuppet.py | Pip.delete_all_eggs | def delete_all_eggs(self):
""" delete all the eggs in the directory specified """
path_to_delete = os.path.join(self.egg_directory, "lib", "python")
if os.path.exists(path_to_delete):
shutil.rmtree(path_to_delete) | python | def delete_all_eggs(self):
""" delete all the eggs in the directory specified """
path_to_delete = os.path.join(self.egg_directory, "lib", "python")
if os.path.exists(path_to_delete):
shutil.rmtree(path_to_delete) | [
"def",
"delete_all_eggs",
"(",
"self",
")",
":",
"path_to_delete",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"egg_directory",
",",
"\"lib\"",
",",
"\"python\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path_to_delete",
")",
":",
... | delete all the eggs in the directory specified | [
"delete",
"all",
"the",
"eggs",
"in",
"the",
"directory",
"specified"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/external/pippuppet.py#L50-L54 |
38,084 | toumorokoshi/sprinter | sprinter/external/pippuppet.py | Pip.install_egg | def install_egg(self, egg_name):
""" Install an egg into the egg directory """
if not os.path.exists(self.egg_directory):
os.makedirs(self.egg_directory)
self.requirement_set.add_requirement(
InstallRequirement.from_line(egg_name, None))
try:
self.requ... | python | def install_egg(self, egg_name):
""" Install an egg into the egg directory """
if not os.path.exists(self.egg_directory):
os.makedirs(self.egg_directory)
self.requirement_set.add_requirement(
InstallRequirement.from_line(egg_name, None))
try:
self.requ... | [
"def",
"install_egg",
"(",
"self",
",",
"egg_name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"egg_directory",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"egg_directory",
")",
"self",
".",
"requirement_set",
"."... | Install an egg into the egg directory | [
"Install",
"an",
"egg",
"into",
"the",
"egg",
"directory"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/external/pippuppet.py#L56-L67 |
38,085 | NiklasRosenstein-Python/nr-deprecated | nr/stream.py | stream.chunks | def chunks(cls, iterable, n, fill=None):
"""
Collects elements in fixed-length chunks.
"""
return cls(itertools.zip_longest(*[iter(iterable)] * n, fillvalue=fill)) | python | def chunks(cls, iterable, n, fill=None):
"""
Collects elements in fixed-length chunks.
"""
return cls(itertools.zip_longest(*[iter(iterable)] * n, fillvalue=fill)) | [
"def",
"chunks",
"(",
"cls",
",",
"iterable",
",",
"n",
",",
"fill",
"=",
"None",
")",
":",
"return",
"cls",
"(",
"itertools",
".",
"zip_longest",
"(",
"*",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"n",
",",
"fillvalue",
"=",
"fill",
")",
")"... | Collects elements in fixed-length chunks. | [
"Collects",
"elements",
"in",
"fixed",
"-",
"length",
"chunks",
"."
] | f9f8b89ea1b084841a8ab65784eaf68852686b2a | https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/stream.py#L88-L93 |
38,086 | NiklasRosenstein-Python/nr-deprecated | nr/stream.py | stream.partition | def partition(cls, iterable, pred):
"""
Use a predicate to partition items into false and true entries.
"""
t1, t2 = itertools.tee(iterable)
return cls(itertools.filterfalse(pred, t1), filter(pred, t2)) | python | def partition(cls, iterable, pred):
"""
Use a predicate to partition items into false and true entries.
"""
t1, t2 = itertools.tee(iterable)
return cls(itertools.filterfalse(pred, t1), filter(pred, t2)) | [
"def",
"partition",
"(",
"cls",
",",
"iterable",
",",
"pred",
")",
":",
"t1",
",",
"t2",
"=",
"itertools",
".",
"tee",
"(",
"iterable",
")",
"return",
"cls",
"(",
"itertools",
".",
"filterfalse",
"(",
"pred",
",",
"t1",
")",
",",
"filter",
"(",
"pr... | Use a predicate to partition items into false and true entries. | [
"Use",
"a",
"predicate",
"to",
"partition",
"items",
"into",
"false",
"and",
"true",
"entries",
"."
] | f9f8b89ea1b084841a8ab65784eaf68852686b2a | https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/stream.py#L144-L150 |
38,087 | NiklasRosenstein-Python/nr-deprecated | nr/stream.py | stream.count | def count(cls, iterable):
"""
Returns the number of items in an iterable.
"""
iterable = iter(iterable)
count = 0
while True:
try:
next(iterable)
except StopIteration:
break
count += 1
return count | python | def count(cls, iterable):
"""
Returns the number of items in an iterable.
"""
iterable = iter(iterable)
count = 0
while True:
try:
next(iterable)
except StopIteration:
break
count += 1
return count | [
"def",
"count",
"(",
"cls",
",",
"iterable",
")",
":",
"iterable",
"=",
"iter",
"(",
"iterable",
")",
"count",
"=",
"0",
"while",
"True",
":",
"try",
":",
"next",
"(",
"iterable",
")",
"except",
"StopIteration",
":",
"break",
"count",
"+=",
"1",
"ret... | Returns the number of items in an iterable. | [
"Returns",
"the",
"number",
"of",
"items",
"in",
"an",
"iterable",
"."
] | f9f8b89ea1b084841a8ab65784eaf68852686b2a | https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/stream.py#L172-L185 |
38,088 | scraperwiki/dumptruck | dumptruck/dumptruck.py | DumpTruck.column_names | def column_names(self, table):
"""An iterable of column names, for a particular table or
view."""
table_info = self.execute(
u'PRAGMA table_info(%s)' % quote(table))
return (column['name'] for column in table_info) | python | def column_names(self, table):
"""An iterable of column names, for a particular table or
view."""
table_info = self.execute(
u'PRAGMA table_info(%s)' % quote(table))
return (column['name'] for column in table_info) | [
"def",
"column_names",
"(",
"self",
",",
"table",
")",
":",
"table_info",
"=",
"self",
".",
"execute",
"(",
"u'PRAGMA table_info(%s)'",
"%",
"quote",
"(",
"table",
")",
")",
"return",
"(",
"column",
"[",
"'name'",
"]",
"for",
"column",
"in",
"table_info",
... | An iterable of column names, for a particular table or
view. | [
"An",
"iterable",
"of",
"column",
"names",
"for",
"a",
"particular",
"table",
"or",
"view",
"."
] | ac5855e34d4dffc7e53a13ff925ccabda19604fc | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L110-L116 |
38,089 | scraperwiki/dumptruck | dumptruck/dumptruck.py | DumpTruck.execute | def execute(self, sql, *args, **kwargs):
'''
Run raw SQL on the database, and receive relaxing output.
This is sort of the foundational method that most of the
others build on.
'''
try:
self.cursor.execute(sql, *args)
except self.sqlite3.InterfaceError, msg:
raise self.sqlite3.In... | python | def execute(self, sql, *args, **kwargs):
'''
Run raw SQL on the database, and receive relaxing output.
This is sort of the foundational method that most of the
others build on.
'''
try:
self.cursor.execute(sql, *args)
except self.sqlite3.InterfaceError, msg:
raise self.sqlite3.In... | [
"def",
"execute",
"(",
"self",
",",
"sql",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"sql",
",",
"*",
"args",
")",
"except",
"self",
".",
"sqlite3",
".",
"InterfaceError",
",",
"m... | Run raw SQL on the database, and receive relaxing output.
This is sort of the foundational method that most of the
others build on. | [
"Run",
"raw",
"SQL",
"on",
"the",
"database",
"and",
"receive",
"relaxing",
"output",
".",
"This",
"is",
"sort",
"of",
"the",
"foundational",
"method",
"that",
"most",
"of",
"the",
"others",
"build",
"on",
"."
] | ac5855e34d4dffc7e53a13ff925ccabda19604fc | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L129-L148 |
38,090 | scraperwiki/dumptruck | dumptruck/dumptruck.py | DumpTruck.create_table | def create_table(self, data, table_name, error_if_exists = False, **kwargs):
'Create a table based on the data, but don\'t insert anything.'
converted_data = convert(data)
if len(converted_data) == 0 or converted_data[0] == []:
raise ValueError(u'You passed no sample values, or all the values you pas... | python | def create_table(self, data, table_name, error_if_exists = False, **kwargs):
'Create a table based on the data, but don\'t insert anything.'
converted_data = convert(data)
if len(converted_data) == 0 or converted_data[0] == []:
raise ValueError(u'You passed no sample values, or all the values you pas... | [
"def",
"create_table",
"(",
"self",
",",
"data",
",",
"table_name",
",",
"error_if_exists",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"converted_data",
"=",
"convert",
"(",
"data",
")",
"if",
"len",
"(",
"converted_data",
")",
"==",
"0",
"or",
"... | Create a table based on the data, but don\'t insert anything. | [
"Create",
"a",
"table",
"based",
"on",
"the",
"data",
"but",
"don",
"\\",
"t",
"insert",
"anything",
"."
] | ac5855e34d4dffc7e53a13ff925ccabda19604fc | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L199-L232 |
38,091 | scraperwiki/dumptruck | dumptruck/dumptruck.py | DumpTruck.get_var | def get_var(self, key):
'Retrieve one saved variable from the database.'
vt = quote(self.__vars_table)
data = self.execute(u'SELECT * FROM %s WHERE `key` = ?' % vt, [key], commit = False)
if data == []:
raise NameError(u'The DumpTruck variables table doesn\'t have a value for %s.' % key)
else:... | python | def get_var(self, key):
'Retrieve one saved variable from the database.'
vt = quote(self.__vars_table)
data = self.execute(u'SELECT * FROM %s WHERE `key` = ?' % vt, [key], commit = False)
if data == []:
raise NameError(u'The DumpTruck variables table doesn\'t have a value for %s.' % key)
else:... | [
"def",
"get_var",
"(",
"self",
",",
"key",
")",
":",
"vt",
"=",
"quote",
"(",
"self",
".",
"__vars_table",
")",
"data",
"=",
"self",
".",
"execute",
"(",
"u'SELECT * FROM %s WHERE `key` = ?'",
"%",
"vt",
",",
"[",
"key",
"]",
",",
"commit",
"=",
"False... | Retrieve one saved variable from the database. | [
"Retrieve",
"one",
"saved",
"variable",
"from",
"the",
"database",
"."
] | ac5855e34d4dffc7e53a13ff925ccabda19604fc | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L307-L327 |
38,092 | scraperwiki/dumptruck | dumptruck/dumptruck.py | DumpTruck.save_var | def save_var(self, key, value, **kwargs):
'Save one variable to the database.'
# Check whether Highwall's variables table exists
self.__check_or_create_vars_table()
column_type = get_column_type(value)
tmp = quote(self.__vars_table_tmp)
self.execute(u'DROP TABLE IF EXISTS %s' % tmp, commit = ... | python | def save_var(self, key, value, **kwargs):
'Save one variable to the database.'
# Check whether Highwall's variables table exists
self.__check_or_create_vars_table()
column_type = get_column_type(value)
tmp = quote(self.__vars_table_tmp)
self.execute(u'DROP TABLE IF EXISTS %s' % tmp, commit = ... | [
"def",
"save_var",
"(",
"self",
",",
"key",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check whether Highwall's variables table exists",
"self",
".",
"__check_or_create_vars_table",
"(",
")",
"column_type",
"=",
"get_column_type",
"(",
"value",
")",
"tmp"... | Save one variable to the database. | [
"Save",
"one",
"variable",
"to",
"the",
"database",
"."
] | ac5855e34d4dffc7e53a13ff925ccabda19604fc | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L329-L357 |
38,093 | scraperwiki/dumptruck | dumptruck/dumptruck.py | DumpTruck.drop | def drop(self, table_name = 'dumptruck', if_exists = False, **kwargs):
'Drop a table.'
return self.execute(u'DROP TABLE %s %s;' % ('IF EXISTS' if if_exists else '', quote(table_name)), **kwargs) | python | def drop(self, table_name = 'dumptruck', if_exists = False, **kwargs):
'Drop a table.'
return self.execute(u'DROP TABLE %s %s;' % ('IF EXISTS' if if_exists else '', quote(table_name)), **kwargs) | [
"def",
"drop",
"(",
"self",
",",
"table_name",
"=",
"'dumptruck'",
",",
"if_exists",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"execute",
"(",
"u'DROP TABLE %s %s;'",
"%",
"(",
"'IF EXISTS'",
"if",
"if_exists",
"else",
"''",
... | Drop a table. | [
"Drop",
"a",
"table",
"."
] | ac5855e34d4dffc7e53a13ff925ccabda19604fc | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L372-L374 |
38,094 | toumorokoshi/sprinter | sprinter/formula/perforce.py | PerforceFormula.__install_perforce | def __install_perforce(self, config):
""" install perforce binary """
if not system.is_64_bit():
self.logger.warn("Perforce formula is only designed for 64 bit systems! Not install executables...")
return False
version = config.get('version', 'r13.2')
key = 'osx' ... | python | def __install_perforce(self, config):
""" install perforce binary """
if not system.is_64_bit():
self.logger.warn("Perforce formula is only designed for 64 bit systems! Not install executables...")
return False
version = config.get('version', 'r13.2')
key = 'osx' ... | [
"def",
"__install_perforce",
"(",
"self",
",",
"config",
")",
":",
"if",
"not",
"system",
".",
"is_64_bit",
"(",
")",
":",
"self",
".",
"logger",
".",
"warn",
"(",
"\"Perforce formula is only designed for 64 bit systems! Not install executables...\"",
")",
"return",
... | install perforce binary | [
"install",
"perforce",
"binary"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/perforce.py#L144-L164 |
38,095 | toumorokoshi/sprinter | sprinter/formula/perforce.py | PerforceFormula._install_p4v_osx | def _install_p4v_osx(self, url, overwrite=False):
""" Install perforce applications and binaries for mac """
package_exists = False
root_dir = os.path.expanduser(os.path.join("~", "Applications"))
package_exists = len([x for x in P4V_APPLICATIONS if os.path.exists(os.path.join(root_dir, ... | python | def _install_p4v_osx(self, url, overwrite=False):
""" Install perforce applications and binaries for mac """
package_exists = False
root_dir = os.path.expanduser(os.path.join("~", "Applications"))
package_exists = len([x for x in P4V_APPLICATIONS if os.path.exists(os.path.join(root_dir, ... | [
"def",
"_install_p4v_osx",
"(",
"self",
",",
"url",
",",
"overwrite",
"=",
"False",
")",
":",
"package_exists",
"=",
"False",
"root_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"join",
"(",
"\"~\"",
",",
"\"Applications\"... | Install perforce applications and binaries for mac | [
"Install",
"perforce",
"applications",
"and",
"binaries",
"for",
"mac"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/perforce.py#L166-L175 |
38,096 | toumorokoshi/sprinter | sprinter/formula/perforce.py | PerforceFormula._install_p4v_linux | def _install_p4v_linux(self, url):
""" Install perforce applications and binaries for linux """
lib.extract_targz(url,
self.directory.install_directory(self.feature_name),
remove_common_prefix=True)
bin_path = os.path.join(self.directory.instal... | python | def _install_p4v_linux(self, url):
""" Install perforce applications and binaries for linux """
lib.extract_targz(url,
self.directory.install_directory(self.feature_name),
remove_common_prefix=True)
bin_path = os.path.join(self.directory.instal... | [
"def",
"_install_p4v_linux",
"(",
"self",
",",
"url",
")",
":",
"lib",
".",
"extract_targz",
"(",
"url",
",",
"self",
".",
"directory",
".",
"install_directory",
"(",
"self",
".",
"feature_name",
")",
",",
"remove_common_prefix",
"=",
"True",
")",
"bin_path"... | Install perforce applications and binaries for linux | [
"Install",
"perforce",
"applications",
"and",
"binaries",
"for",
"linux"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/perforce.py#L177-L186 |
38,097 | toumorokoshi/sprinter | sprinter/formula/perforce.py | PerforceFormula.__write_p4settings | def __write_p4settings(self, config):
""" write perforce settings """
self.logger.info("Writing p4settings...")
root_dir = os.path.expanduser(config.get('root_path'))
p4settings_path = os.path.join(root_dir, ".p4settings")
if os.path.exists(p4settings_path):
if self.t... | python | def __write_p4settings(self, config):
""" write perforce settings """
self.logger.info("Writing p4settings...")
root_dir = os.path.expanduser(config.get('root_path'))
p4settings_path = os.path.join(root_dir, ".p4settings")
if os.path.exists(p4settings_path):
if self.t... | [
"def",
"__write_p4settings",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Writing p4settings...\"",
")",
"root_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"config",
".",
"get",
"(",
"'root_path'",
")",
")",
... | write perforce settings | [
"write",
"perforce",
"settings"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/perforce.py#L188-L202 |
38,098 | toumorokoshi/sprinter | sprinter/formula/perforce.py | PerforceFormula.__configure_client | def __configure_client(self, config):
""" write the perforce client """
self.logger.info("Configuring p4 client...")
client_dict = config.to_dict()
client_dict['root_path'] = os.path.expanduser(config.get('root_path'))
os.chdir(client_dict['root_path'])
client_dict['hostn... | python | def __configure_client(self, config):
""" write the perforce client """
self.logger.info("Configuring p4 client...")
client_dict = config.to_dict()
client_dict['root_path'] = os.path.expanduser(config.get('root_path'))
os.chdir(client_dict['root_path'])
client_dict['hostn... | [
"def",
"__configure_client",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Configuring p4 client...\"",
")",
"client_dict",
"=",
"config",
".",
"to_dict",
"(",
")",
"client_dict",
"[",
"'root_path'",
"]",
"=",
"os",
".",
... | write the perforce client | [
"write",
"the",
"perforce",
"client"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/perforce.py#L209-L221 |
38,099 | toumorokoshi/sprinter | sprinter/formula/eggscript.py | EggscriptFormula.__install_eggs | def __install_eggs(self, config):
""" Install eggs for a particular configuration """
egg_carton = (self.directory.install_directory(self.feature_name),
'requirements.txt')
eggs = self.__gather_eggs(config)
self.logger.debug("Installing eggs %s..." % eggs)
... | python | def __install_eggs(self, config):
""" Install eggs for a particular configuration """
egg_carton = (self.directory.install_directory(self.feature_name),
'requirements.txt')
eggs = self.__gather_eggs(config)
self.logger.debug("Installing eggs %s..." % eggs)
... | [
"def",
"__install_eggs",
"(",
"self",
",",
"config",
")",
":",
"egg_carton",
"=",
"(",
"self",
".",
"directory",
".",
"install_directory",
"(",
"self",
".",
"feature_name",
")",
",",
"'requirements.txt'",
")",
"eggs",
"=",
"self",
".",
"__gather_eggs",
"(",
... | Install eggs for a particular configuration | [
"Install",
"eggs",
"for",
"a",
"particular",
"configuration"
] | 846697a7a087e69c61d075232e754d6975a64152 | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/eggscript.py#L116-L125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.