partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | sat2in4 | Two-in-four (2-in-4) satisfiability.
Args:
pos (iterable):
Variable labels, as an iterable, for non-negated variables of the constraint.
Exactly four variables are specified by `pos` and `neg` together.
neg (tuple):
Variable labels, as an iterable, for negated va... | dwavebinarycsp/factories/constraint/sat.py | def sat2in4(pos, neg=tuple(), vartype=dimod.BINARY, name='2-in-4'):
"""Two-in-four (2-in-4) satisfiability.
Args:
pos (iterable):
Variable labels, as an iterable, for non-negated variables of the constraint.
Exactly four variables are specified by `pos` and `neg` together.
... | def sat2in4(pos, neg=tuple(), vartype=dimod.BINARY, name='2-in-4'):
"""Two-in-four (2-in-4) satisfiability.
Args:
pos (iterable):
Variable labels, as an iterable, for non-negated variables of the constraint.
Exactly four variables are specified by `pos` and `neg` together.
... | [
"Two",
"-",
"in",
"-",
"four",
"(",
"2",
"-",
"in",
"-",
"4",
")",
"satisfiability",
"."
] | dwavesystems/dwavebinarycsp | python | https://github.com/dwavesystems/dwavebinarycsp/blob/d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2/dwavebinarycsp/factories/constraint/sat.py#L27-L102 | [
"def",
"sat2in4",
"(",
"pos",
",",
"neg",
"=",
"tuple",
"(",
")",
",",
"vartype",
"=",
"dimod",
".",
"BINARY",
",",
"name",
"=",
"'2-in-4'",
")",
":",
"pos",
"=",
"tuple",
"(",
"pos",
")",
"neg",
"=",
"tuple",
"(",
"neg",
")",
"variables",
"=",
... | d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2 |
valid | random_2in4sat | Random two-in-four (2-in-4) constraint satisfaction problem.
Args:
num_variables (integer): Number of variables (at least four).
num_clauses (integer): Number of constraints that together constitute the
constraint satisfaction problem.
vartype (Vartype, optional, default='BINARY... | dwavebinarycsp/factories/csp/sat.py | def random_2in4sat(num_variables, num_clauses, vartype=dimod.BINARY, satisfiable=True):
"""Random two-in-four (2-in-4) constraint satisfaction problem.
Args:
num_variables (integer): Number of variables (at least four).
num_clauses (integer): Number of constraints that together constitute the
... | def random_2in4sat(num_variables, num_clauses, vartype=dimod.BINARY, satisfiable=True):
"""Random two-in-four (2-in-4) constraint satisfaction problem.
Args:
num_variables (integer): Number of variables (at least four).
num_clauses (integer): Number of constraints that together constitute the
... | [
"Random",
"two",
"-",
"in",
"-",
"four",
"(",
"2",
"-",
"in",
"-",
"4",
")",
"constraint",
"satisfaction",
"problem",
"."
] | dwavesystems/dwavebinarycsp | python | https://github.com/dwavesystems/dwavebinarycsp/blob/d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2/dwavebinarycsp/factories/csp/sat.py#L34-L128 | [
"def",
"random_2in4sat",
"(",
"num_variables",
",",
"num_clauses",
",",
"vartype",
"=",
"dimod",
".",
"BINARY",
",",
"satisfiable",
"=",
"True",
")",
":",
"if",
"num_variables",
"<",
"4",
":",
"raise",
"ValueError",
"(",
"\"a 2in4 problem needs at least 4 variable... | d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2 |
valid | random_xorsat | Random XOR constraint satisfaction problem.
Args:
num_variables (integer): Number of variables (at least three).
num_clauses (integer): Number of constraints that together constitute the
constraint satisfaction problem.
vartype (Vartype, optional, default='BINARY'): Variable typ... | dwavebinarycsp/factories/csp/sat.py | def random_xorsat(num_variables, num_clauses, vartype=dimod.BINARY, satisfiable=True):
"""Random XOR constraint satisfaction problem.
Args:
num_variables (integer): Number of variables (at least three).
num_clauses (integer): Number of constraints that together constitute the
constr... | def random_xorsat(num_variables, num_clauses, vartype=dimod.BINARY, satisfiable=True):
"""Random XOR constraint satisfaction problem.
Args:
num_variables (integer): Number of variables (at least three).
num_clauses (integer): Number of constraints that together constitute the
constr... | [
"Random",
"XOR",
"constraint",
"satisfaction",
"problem",
"."
] | dwavesystems/dwavebinarycsp | python | https://github.com/dwavesystems/dwavebinarycsp/blob/d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2/dwavebinarycsp/factories/csp/sat.py#L131-L231 | [
"def",
"random_xorsat",
"(",
"num_variables",
",",
"num_clauses",
",",
"vartype",
"=",
"dimod",
".",
"BINARY",
",",
"satisfiable",
"=",
"True",
")",
":",
"if",
"num_variables",
"<",
"3",
":",
"raise",
"ValueError",
"(",
"\"a xor problem needs at least 3 variables\... | d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2 |
valid | kwarg_decorator | Turns a function that accepts a single arg and some kwargs in to a
decorator that can optionally be called with kwargs:
.. code-block:: python
@kwarg_decorator
def my_decorator(func, bar=True, baz=None):
...
@my_decorator
def my_func():
pass
@m... | wagtailmodelchooser/utils.py | def kwarg_decorator(func):
"""
Turns a function that accepts a single arg and some kwargs in to a
decorator that can optionally be called with kwargs:
.. code-block:: python
@kwarg_decorator
def my_decorator(func, bar=True, baz=None):
...
@my_decorator
def ... | def kwarg_decorator(func):
"""
Turns a function that accepts a single arg and some kwargs in to a
decorator that can optionally be called with kwargs:
.. code-block:: python
@kwarg_decorator
def my_decorator(func, bar=True, baz=None):
...
@my_decorator
def ... | [
"Turns",
"a",
"function",
"that",
"accepts",
"a",
"single",
"arg",
"and",
"some",
"kwargs",
"in",
"to",
"a",
"decorator",
"that",
"can",
"optionally",
"be",
"called",
"with",
"kwargs",
":"
] | neon-jungle/wagtailmodelchooser | python | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/utils.py#L5-L29 | [
"def",
"kwarg_decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorator",
"(",
"arg",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"arg",
"is",
"None",
":",
"return",
"lambda",
"arg",
":",
"decorator",
"(",
"arg"... | 8dd1e33dd61418a726ff3acf67a956626c8b7ba1 |
valid | signature_matches | Work out if a function is callable with some args or not. | wagtailmodelchooser/utils.py | def signature_matches(func, args=(), kwargs={}):
"""
Work out if a function is callable with some args or not.
"""
try:
sig = inspect.signature(func)
sig.bind(*args, **kwargs)
except TypeError:
return False
else:
return True | def signature_matches(func, args=(), kwargs={}):
"""
Work out if a function is callable with some args or not.
"""
try:
sig = inspect.signature(func)
sig.bind(*args, **kwargs)
except TypeError:
return False
else:
return True | [
"Work",
"out",
"if",
"a",
"function",
"is",
"callable",
"with",
"some",
"args",
"or",
"not",
"."
] | neon-jungle/wagtailmodelchooser | python | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/utils.py#L32-L42 | [
"def",
"signature_matches",
"(",
"func",
",",
"args",
"=",
"(",
")",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"try",
":",
"sig",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"sig",
".",
"bind",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
"... | 8dd1e33dd61418a726ff3acf67a956626c8b7ba1 |
valid | last_arg_decorator | Allows a function to be used as either a decorator with args, or called as
a normal function.
@last_arg_decorator
def register_a_thing(foo, func, bar=True):
..
# Called as a decorator
@register_a_thing("abc", bar=False)
def my_func():
...
# Called as a normal function call... | wagtailmodelchooser/utils.py | def last_arg_decorator(func):
"""
Allows a function to be used as either a decorator with args, or called as
a normal function.
@last_arg_decorator
def register_a_thing(foo, func, bar=True):
..
# Called as a decorator
@register_a_thing("abc", bar=False)
def my_func():
.... | def last_arg_decorator(func):
"""
Allows a function to be used as either a decorator with args, or called as
a normal function.
@last_arg_decorator
def register_a_thing(foo, func, bar=True):
..
# Called as a decorator
@register_a_thing("abc", bar=False)
def my_func():
.... | [
"Allows",
"a",
"function",
"to",
"be",
"used",
"as",
"either",
"a",
"decorator",
"with",
"args",
"or",
"called",
"as",
"a",
"normal",
"function",
"."
] | neon-jungle/wagtailmodelchooser | python | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/utils.py#L45-L71 | [
"def",
"last_arg_decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"signature_matches",
"(",
"func",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"func... | 8dd1e33dd61418a726ff3acf67a956626c8b7ba1 |
valid | Registry.register_chooser | Adds a model chooser definition to the registry. | wagtailmodelchooser/__init__.py | def register_chooser(self, chooser, **kwargs):
"""Adds a model chooser definition to the registry."""
if not issubclass(chooser, Chooser):
return self.register_simple_chooser(chooser, **kwargs)
self.choosers[chooser.model] = chooser(**kwargs)
return chooser | def register_chooser(self, chooser, **kwargs):
"""Adds a model chooser definition to the registry."""
if not issubclass(chooser, Chooser):
return self.register_simple_chooser(chooser, **kwargs)
self.choosers[chooser.model] = chooser(**kwargs)
return chooser | [
"Adds",
"a",
"model",
"chooser",
"definition",
"to",
"the",
"registry",
"."
] | neon-jungle/wagtailmodelchooser | python | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/__init__.py#L16-L22 | [
"def",
"register_chooser",
"(",
"self",
",",
"chooser",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"issubclass",
"(",
"chooser",
",",
"Chooser",
")",
":",
"return",
"self",
".",
"register_simple_chooser",
"(",
"chooser",
",",
"*",
"*",
"kwargs",
")"... | 8dd1e33dd61418a726ff3acf67a956626c8b7ba1 |
valid | Registry.register_simple_chooser | Generates a model chooser definition from a model, and adds it to the
registry. | wagtailmodelchooser/__init__.py | def register_simple_chooser(self, model, **kwargs):
"""
Generates a model chooser definition from a model, and adds it to the
registry.
"""
name = '{}Chooser'.format(model._meta.object_name)
attrs = {'model': model}
attrs.update(kwargs)
chooser = type(nam... | def register_simple_chooser(self, model, **kwargs):
"""
Generates a model chooser definition from a model, and adds it to the
registry.
"""
name = '{}Chooser'.format(model._meta.object_name)
attrs = {'model': model}
attrs.update(kwargs)
chooser = type(nam... | [
"Generates",
"a",
"model",
"chooser",
"definition",
"from",
"a",
"model",
"and",
"adds",
"it",
"to",
"the",
"registry",
"."
] | neon-jungle/wagtailmodelchooser | python | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/__init__.py#L24-L36 | [
"def",
"register_simple_chooser",
"(",
"self",
",",
"model",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"'{}Chooser'",
".",
"format",
"(",
"model",
".",
"_meta",
".",
"object_name",
")",
"attrs",
"=",
"{",
"'model'",
":",
"model",
"}",
"attrs",
".... | 8dd1e33dd61418a726ff3acf67a956626c8b7ba1 |
valid | instance_from_str | Given an instance string in the form "app.Model:pk", returns a tuple of
``(model, instance)``. If the pk part is empty, ``instance`` will be
``None``. Raises ``ValueError`` on invalid model strings or missing
instances. | wagtailmodelchooser/views.py | def instance_from_str(instance_str):
"""
Given an instance string in the form "app.Model:pk", returns a tuple of
``(model, instance)``. If the pk part is empty, ``instance`` will be
``None``. Raises ``ValueError`` on invalid model strings or missing
instances.
"""
match = instance_str_re.mat... | def instance_from_str(instance_str):
"""
Given an instance string in the form "app.Model:pk", returns a tuple of
``(model, instance)``. If the pk part is empty, ``instance`` will be
``None``. Raises ``ValueError`` on invalid model strings or missing
instances.
"""
match = instance_str_re.mat... | [
"Given",
"an",
"instance",
"string",
"in",
"the",
"form",
"app",
".",
"Model",
":",
"pk",
"returns",
"a",
"tuple",
"of",
"(",
"model",
"instance",
")",
".",
"If",
"the",
"pk",
"part",
"is",
"empty",
"instance",
"will",
"be",
"None",
".",
"Raises",
"V... | neon-jungle/wagtailmodelchooser | python | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/views.py#L15-L39 | [
"def",
"instance_from_str",
"(",
"instance_str",
")",
":",
"match",
"=",
"instance_str_re",
".",
"match",
"(",
"instance_str",
")",
"if",
"not",
"match",
":",
"raise",
"ValueError",
"(",
"\"Invalid instance string\"",
")",
"model_string",
"=",
"match",
".",
"gro... | 8dd1e33dd61418a726ff3acf67a956626c8b7ba1 |
valid | AudioField.formatter | Get audio-related fields
Try to find fields for the audio url for specified preferred quality
level, or next-lowest available quality url otherwise. | pandora/models/playlist.py | def formatter(self, api_client, data, newval):
"""Get audio-related fields
Try to find fields for the audio url for specified preferred quality
level, or next-lowest available quality url otherwise.
"""
url_map = data.get("audioUrlMap")
audio_url = data.get("audioUrl")
... | def formatter(self, api_client, data, newval):
"""Get audio-related fields
Try to find fields for the audio url for specified preferred quality
level, or next-lowest available quality url otherwise.
"""
url_map = data.get("audioUrlMap")
audio_url = data.get("audioUrl")
... | [
"Get",
"audio",
"-",
"related",
"fields"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/models/playlist.py#L39-L83 | [
"def",
"formatter",
"(",
"self",
",",
"api_client",
",",
"data",
",",
"newval",
")",
":",
"url_map",
"=",
"data",
".",
"get",
"(",
"\"audioUrlMap\"",
")",
"audio_url",
"=",
"data",
".",
"get",
"(",
"\"audioUrl\"",
")",
"# Only an audio URL, not a quality map. ... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | AdditionalUrlField.formatter | Parse additional url fields and map them to inputs
Attempt to create a dictionary with keys being user input, and
response being the returned URL | pandora/models/playlist.py | def formatter(self, api_client, data, newval):
"""Parse additional url fields and map them to inputs
Attempt to create a dictionary with keys being user input, and
response being the returned URL
"""
if newval is None:
return None
user_param = data['_paramAd... | def formatter(self, api_client, data, newval):
"""Parse additional url fields and map them to inputs
Attempt to create a dictionary with keys being user input, and
response being the returned URL
"""
if newval is None:
return None
user_param = data['_paramAd... | [
"Parse",
"additional",
"url",
"fields",
"and",
"map",
"them",
"to",
"inputs"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/models/playlist.py#L88-L104 | [
"def",
"formatter",
"(",
"self",
",",
"api_client",
",",
"data",
",",
"newval",
")",
":",
"if",
"newval",
"is",
"None",
":",
"return",
"None",
"user_param",
"=",
"data",
"[",
"'_paramAdditionalUrls'",
"]",
"urls",
"=",
"{",
"}",
"if",
"isinstance",
"(",
... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PandoraModel.from_json_list | Convert a list of JSON values to a list of models | pandora/models/_base.py | def from_json_list(cls, api_client, data):
"""Convert a list of JSON values to a list of models
"""
return [cls.from_json(api_client, item) for item in data] | def from_json_list(cls, api_client, data):
"""Convert a list of JSON values to a list of models
"""
return [cls.from_json(api_client, item) for item in data] | [
"Convert",
"a",
"list",
"of",
"JSON",
"values",
"to",
"a",
"list",
"of",
"models"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/models/_base.py#L101-L104 | [
"def",
"from_json_list",
"(",
"cls",
",",
"api_client",
",",
"data",
")",
":",
"return",
"[",
"cls",
".",
"from_json",
"(",
"api_client",
",",
"item",
")",
"for",
"item",
"in",
"data",
"]"
] | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PandoraModel.populate_fields | Populate all fields of a model with data
Given a model with a PandoraModel superclass will enumerate all
declared fields on that model and populate the values of their Field
and SyntheticField classes. All declared fields will have a value after
this function runs even if they are missi... | pandora/models/_base.py | def populate_fields(api_client, instance, data):
"""Populate all fields of a model with data
Given a model with a PandoraModel superclass will enumerate all
declared fields on that model and populate the values of their Field
and SyntheticField classes. All declared fields will have a v... | def populate_fields(api_client, instance, data):
"""Populate all fields of a model with data
Given a model with a PandoraModel superclass will enumerate all
declared fields on that model and populate the values of their Field
and SyntheticField classes. All declared fields will have a v... | [
"Populate",
"all",
"fields",
"of",
"a",
"model",
"with",
"data"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/models/_base.py#L120-L147 | [
"def",
"populate_fields",
"(",
"api_client",
",",
"instance",
",",
"data",
")",
":",
"for",
"key",
",",
"value",
"in",
"instance",
".",
"__class__",
".",
"_fields",
".",
"items",
"(",
")",
":",
"default",
"=",
"getattr",
"(",
"value",
",",
"\"default\"",... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PandoraModel.from_json | Convert one JSON value to a model object | pandora/models/_base.py | def from_json(cls, api_client, data):
"""Convert one JSON value to a model object
"""
self = cls(api_client)
PandoraModel.populate_fields(api_client, self, data)
return self | def from_json(cls, api_client, data):
"""Convert one JSON value to a model object
"""
self = cls(api_client)
PandoraModel.populate_fields(api_client, self, data)
return self | [
"Convert",
"one",
"JSON",
"value",
"to",
"a",
"model",
"object"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/models/_base.py#L150-L155 | [
"def",
"from_json",
"(",
"cls",
",",
"api_client",
",",
"data",
")",
":",
"self",
"=",
"cls",
"(",
"api_client",
")",
"PandoraModel",
".",
"populate_fields",
"(",
"api_client",
",",
"self",
",",
"data",
")",
"return",
"self"
] | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PandoraModel._base_repr | Common repr logic for subclasses to hook | pandora/models/_base.py | def _base_repr(self, and_also=None):
"""Common repr logic for subclasses to hook
"""
items = [
"=".join((key, repr(getattr(self, key))))
for key in sorted(self._fields.keys())]
if items:
output = ", ".join(items)
else:
output = Non... | def _base_repr(self, and_also=None):
"""Common repr logic for subclasses to hook
"""
items = [
"=".join((key, repr(getattr(self, key))))
for key in sorted(self._fields.keys())]
if items:
output = ", ".join(items)
else:
output = Non... | [
"Common",
"repr",
"logic",
"for",
"subclasses",
"to",
"hook"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/models/_base.py#L157-L173 | [
"def",
"_base_repr",
"(",
"self",
",",
"and_also",
"=",
"None",
")",
":",
"items",
"=",
"[",
"\"=\"",
".",
"join",
"(",
"(",
"key",
",",
"repr",
"(",
"getattr",
"(",
"self",
",",
"key",
")",
")",
")",
")",
"for",
"key",
"in",
"sorted",
"(",
"se... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | BasePlayer._send_cmd | Write command to remote process | pydora/audio_backend.py | def _send_cmd(self, cmd):
"""Write command to remote process
"""
self._process.stdin.write("{}\n".format(cmd).encode("utf-8"))
self._process.stdin.flush() | def _send_cmd(self, cmd):
"""Write command to remote process
"""
self._process.stdin.write("{}\n".format(cmd).encode("utf-8"))
self._process.stdin.flush() | [
"Write",
"command",
"to",
"remote",
"process"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/audio_backend.py#L110-L114 | [
"def",
"_send_cmd",
"(",
"self",
",",
"cmd",
")",
":",
"self",
".",
"_process",
".",
"stdin",
".",
"write",
"(",
"\"{}\\n\"",
".",
"format",
"(",
"cmd",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
"self",
".",
"_process",
".",
"stdin",
".",
"fl... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | BasePlayer._ensure_started | Ensure player backing process is started | pydora/audio_backend.py | def _ensure_started(self):
"""Ensure player backing process is started
"""
if self._process and self._process.poll() is None:
return
if not getattr(self, "_cmd"):
raise RuntimeError("Player command is not configured")
log.debug("Starting playback command... | def _ensure_started(self):
"""Ensure player backing process is started
"""
if self._process and self._process.poll() is None:
return
if not getattr(self, "_cmd"):
raise RuntimeError("Player command is not configured")
log.debug("Starting playback command... | [
"Ensure",
"player",
"backing",
"process",
"is",
"started"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/audio_backend.py#L137-L148 | [
"def",
"_ensure_started",
"(",
"self",
")",
":",
"if",
"self",
".",
"_process",
"and",
"self",
".",
"_process",
".",
"poll",
"(",
")",
"is",
"None",
":",
"return",
"if",
"not",
"getattr",
"(",
"self",
",",
"\"_cmd\"",
")",
":",
"raise",
"RuntimeError",... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | BasePlayer.play | Play a new song from a Pandora model
Returns once the stream starts but does not shut down the remote audio
output backend process. Calls the input callback when the user has
input. | pydora/audio_backend.py | def play(self, song):
"""Play a new song from a Pandora model
Returns once the stream starts but does not shut down the remote audio
output backend process. Calls the input callback when the user has
input.
"""
self._callbacks.play(song)
self._load_track(song)
... | def play(self, song):
"""Play a new song from a Pandora model
Returns once the stream starts but does not shut down the remote audio
output backend process. Calls the input callback when the user has
input.
"""
self._callbacks.play(song)
self._load_track(song)
... | [
"Play",
"a",
"new",
"song",
"from",
"a",
"Pandora",
"model"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/audio_backend.py#L157-L185 | [
"def",
"play",
"(",
"self",
",",
"song",
")",
":",
"self",
".",
"_callbacks",
".",
"play",
"(",
"song",
")",
"self",
".",
"_load_track",
"(",
"song",
")",
"time",
".",
"sleep",
"(",
"2",
")",
"# Give the backend time to load the track",
"while",
"True",
... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | BasePlayer.play_station | Play the station until something ends it
This function will run forever until termintated by calling
end_station. | pydora/audio_backend.py | def play_station(self, station):
"""Play the station until something ends it
This function will run forever until termintated by calling
end_station.
"""
for song in iterate_forever(station.get_playlist):
try:
self.play(song)
except StopIt... | def play_station(self, station):
"""Play the station until something ends it
This function will run forever until termintated by calling
end_station.
"""
for song in iterate_forever(station.get_playlist):
try:
self.play(song)
except StopIt... | [
"Play",
"the",
"station",
"until",
"something",
"ends",
"it"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/audio_backend.py#L192-L203 | [
"def",
"play_station",
"(",
"self",
",",
"station",
")",
":",
"for",
"song",
"in",
"iterate_forever",
"(",
"station",
".",
"get_playlist",
")",
":",
"try",
":",
"self",
".",
"play",
"(",
"song",
")",
"except",
"StopIteration",
":",
"self",
".",
"stop",
... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | VLCPlayer._post_start | Set stdout to non-blocking
VLC does not always return a newline when reading status so in order to
be lazy and still use the read API without caring about how much output
there is we switch stdout to nonblocking mode and just read a large
chunk of datin order to be lazy and still use th... | pydora/audio_backend.py | def _post_start(self):
"""Set stdout to non-blocking
VLC does not always return a newline when reading status so in order to
be lazy and still use the read API without caring about how much output
there is we switch stdout to nonblocking mode and just read a large
chunk of datin... | def _post_start(self):
"""Set stdout to non-blocking
VLC does not always return a newline when reading status so in order to
be lazy and still use the read API without caring about how much output
there is we switch stdout to nonblocking mode and just read a large
chunk of datin... | [
"Set",
"stdout",
"to",
"non",
"-",
"blocking"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/audio_backend.py#L270-L281 | [
"def",
"_post_start",
"(",
"self",
")",
":",
"flags",
"=",
"fcntl",
".",
"fcntl",
"(",
"self",
".",
"_process",
".",
"stdout",
",",
"fcntl",
".",
"F_GETFL",
")",
"fcntl",
".",
"fcntl",
"(",
"self",
".",
"_process",
".",
"stdout",
",",
"fcntl",
".",
... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PlayerApp.station_selection_menu | Format a station menu and make the user select a station | pydora/player.py | def station_selection_menu(self, error=None):
"""Format a station menu and make the user select a station
"""
self.screen.clear()
if error:
self.screen.print_error("{}\n".format(error))
for i, station in enumerate(self.stations):
i = "{:>3}".format(i)
... | def station_selection_menu(self, error=None):
"""Format a station menu and make the user select a station
"""
self.screen.clear()
if error:
self.screen.print_error("{}\n".format(error))
for i, station in enumerate(self.stations):
i = "{:>3}".format(i)
... | [
"Format",
"a",
"station",
"menu",
"and",
"make",
"the",
"user",
"select",
"a",
"station"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/player.py#L115-L127 | [
"def",
"station_selection_menu",
"(",
"self",
",",
"error",
"=",
"None",
")",
":",
"self",
".",
"screen",
".",
"clear",
"(",
")",
"if",
"error",
":",
"self",
".",
"screen",
".",
"print_error",
"(",
"\"{}\\n\"",
".",
"format",
"(",
"error",
")",
")",
... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PlayerApp.play | Play callback | pydora/player.py | def play(self, song):
"""Play callback
"""
if song.is_ad:
print("{} ".format(Colors.cyan("Advertisement")))
else:
print("{} by {}".format(Colors.cyan(song.song_name),
Colors.yellow(song.artist_name))) | def play(self, song):
"""Play callback
"""
if song.is_ad:
print("{} ".format(Colors.cyan("Advertisement")))
else:
print("{} by {}".format(Colors.cyan(song.song_name),
Colors.yellow(song.artist_name))) | [
"Play",
"callback"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/player.py#L129-L136 | [
"def",
"play",
"(",
"self",
",",
"song",
")",
":",
"if",
"song",
".",
"is_ad",
":",
"print",
"(",
"\"{} \"",
".",
"format",
"(",
"Colors",
".",
"cyan",
"(",
"\"Advertisement\"",
")",
")",
")",
"else",
":",
"print",
"(",
"\"{} by {}\"",
".",
"format",... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | PlayerApp.input | Input callback, handles key presses | pydora/player.py | def input(self, input, song):
"""Input callback, handles key presses
"""
try:
cmd = getattr(self, self.CMD_MAP[input][1])
except (IndexError, KeyError):
return self.screen.print_error(
"Invalid command {!r}!".format(input))
cmd(song) | def input(self, input, song):
"""Input callback, handles key presses
"""
try:
cmd = getattr(self, self.CMD_MAP[input][1])
except (IndexError, KeyError):
return self.screen.print_error(
"Invalid command {!r}!".format(input))
cmd(song) | [
"Input",
"callback",
"handles",
"key",
"presses"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/player.py#L223-L232 | [
"def",
"input",
"(",
"self",
",",
"input",
",",
"song",
")",
":",
"try",
":",
"cmd",
"=",
"getattr",
"(",
"self",
",",
"self",
".",
"CMD_MAP",
"[",
"input",
"]",
"[",
"1",
"]",
")",
"except",
"(",
"IndexError",
",",
"KeyError",
")",
":",
"return"... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | retries | Function decorator implementing retrying logic.
exceptions: A tuple of exception classes; default (Exception,)
The decorator will call the function up to max_tries times if it raises
an exception.
By default it catches instances of the Exception class and subclasses.
This will recover after all b... | pandora/transport.py | def retries(max_tries, exceptions=(Exception,)):
"""Function decorator implementing retrying logic.
exceptions: A tuple of exception classes; default (Exception,)
The decorator will call the function up to max_tries times if it raises
an exception.
By default it catches instances of the Exception... | def retries(max_tries, exceptions=(Exception,)):
"""Function decorator implementing retrying logic.
exceptions: A tuple of exception classes; default (Exception,)
The decorator will call the function up to max_tries times if it raises
an exception.
By default it catches instances of the Exception... | [
"Function",
"decorator",
"implementing",
"retrying",
"logic",
"."
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/transport.py#L29-L65 | [
"def",
"retries",
"(",
"max_tries",
",",
"exceptions",
"=",
"(",
"Exception",
",",
")",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"def",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"retries_left",
"=",
"max_tries",
"wh... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | delay_exponential | Calculate time to sleep based on exponential function.
The format is::
base * growth_factor ^ (attempts - 1)
If ``base`` is set to 'rand' then a random number between
0 and 1 will be used as the base.
Base must be greater than 0, otherwise a ValueError will be
raised. | pandora/transport.py | def delay_exponential(base, growth_factor, attempts):
"""Calculate time to sleep based on exponential function.
The format is::
base * growth_factor ^ (attempts - 1)
If ``base`` is set to 'rand' then a random number between
0 and 1 will be used as the base.
Base must be greater than 0, oth... | def delay_exponential(base, growth_factor, attempts):
"""Calculate time to sleep based on exponential function.
The format is::
base * growth_factor ^ (attempts - 1)
If ``base`` is set to 'rand' then a random number between
0 and 1 will be used as the base.
Base must be greater than 0, oth... | [
"Calculate",
"time",
"to",
"sleep",
"based",
"on",
"exponential",
"function",
".",
"The",
"format",
"is",
"::"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pandora/transport.py#L68-L85 | [
"def",
"delay_exponential",
"(",
"base",
",",
"growth_factor",
",",
"attempts",
")",
":",
"if",
"base",
"==",
"'rand'",
":",
"base",
"=",
"random",
".",
"random",
"(",
")",
"elif",
"base",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"The 'base' param mus... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | iterate_forever | Iterate over a finite iterator forever
When the iterator is exhausted will call the function again to generate a
new iterator and keep iterating. | pydora/utils.py | def iterate_forever(func, *args, **kwargs):
"""Iterate over a finite iterator forever
When the iterator is exhausted will call the function again to generate a
new iterator and keep iterating.
"""
output = func(*args, **kwargs)
while True:
try:
playlist_item = next(output)
... | def iterate_forever(func, *args, **kwargs):
"""Iterate over a finite iterator forever
When the iterator is exhausted will call the function again to generate a
new iterator and keep iterating.
"""
output = func(*args, **kwargs)
while True:
try:
playlist_item = next(output)
... | [
"Iterate",
"over",
"a",
"finite",
"iterator",
"forever"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/utils.py#L178-L192 | [
"def",
"iterate_forever",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"while",
"True",
":",
"try",
":",
"playlist_item",
"=",
"next",
"(",
"output",
")",
... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | Screen.get_integer | Gather user input and convert it to an integer
Will keep trying till the user enters an interger or until they ^C the
program. | pydora/utils.py | def get_integer(prompt):
"""Gather user input and convert it to an integer
Will keep trying till the user enters an interger or until they ^C the
program.
"""
while True:
try:
return int(input(prompt).strip())
except ValueError:
... | def get_integer(prompt):
"""Gather user input and convert it to an integer
Will keep trying till the user enters an interger or until they ^C the
program.
"""
while True:
try:
return int(input(prompt).strip())
except ValueError:
... | [
"Gather",
"user",
"input",
"and",
"convert",
"it",
"to",
"an",
"integer"
] | mcrute/pydora | python | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/utils.py#L165-L175 | [
"def",
"get_integer",
"(",
"prompt",
")",
":",
"while",
"True",
":",
"try",
":",
"return",
"int",
"(",
"input",
"(",
"prompt",
")",
".",
"strip",
"(",
")",
")",
"except",
"ValueError",
":",
"print",
"(",
"Colors",
".",
"red",
"(",
"\"Invalid Input!\"",... | d9e353e7f19da741dcf372246b4d5640cb788488 |
valid | CollectorComposite.collect | collect results
Returns:
a list of results | alphatwirl/loop/CollectorComposite.py | def collect(self, dataset_readers_list):
"""collect results
Returns:
a list of results
"""
ret = [ ]
for i, collector in enumerate(self.components):
report = ProgressReport(name='collecting results', done=(i + 1), total=len(self.components))
... | def collect(self, dataset_readers_list):
"""collect results
Returns:
a list of results
"""
ret = [ ]
for i, collector in enumerate(self.components):
report = ProgressReport(name='collecting results', done=(i + 1), total=len(self.components))
... | [
"collect",
"results"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/loop/CollectorComposite.py#L47-L62 | [
"def",
"collect",
"(",
"self",
",",
"dataset_readers_list",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"i",
",",
"collector",
"in",
"enumerate",
"(",
"self",
".",
"components",
")",
":",
"report",
"=",
"ProgressReport",
"(",
"name",
"=",
"'collecting results'"... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | TaskPackageDropbox.open | open the drop box
You need to call this method before starting putting packages.
Returns
-------
None | alphatwirl/concurrently/TaskPackageDropbox.py | def open(self):
"""open the drop box
You need to call this method before starting putting packages.
Returns
-------
None
"""
self.workingArea.open()
self.runid_pkgidx_map = { }
self.runid_to_return = deque() | def open(self):
"""open the drop box
You need to call this method before starting putting packages.
Returns
-------
None
"""
self.workingArea.open()
self.runid_pkgidx_map = { }
self.runid_to_return = deque() | [
"open",
"the",
"drop",
"box"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/TaskPackageDropbox.py#L40-L53 | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"workingArea",
".",
"open",
"(",
")",
"self",
".",
"runid_pkgidx_map",
"=",
"{",
"}",
"self",
".",
"runid_to_return",
"=",
"deque",
"(",
")"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | TaskPackageDropbox.put | put a task
This method places a task in the working area and have the
dispatcher execute it.
If you need to put multiple tasks, it can be much faster to
use `put_multiple()` than to use this method multiple times
depending of the dispatcher.
Parameters
--------... | alphatwirl/concurrently/TaskPackageDropbox.py | def put(self, package):
"""put a task
This method places a task in the working area and have the
dispatcher execute it.
If you need to put multiple tasks, it can be much faster to
use `put_multiple()` than to use this method multiple times
depending of the dispatcher.
... | def put(self, package):
"""put a task
This method places a task in the working area and have the
dispatcher execute it.
If you need to put multiple tasks, it can be much faster to
use `put_multiple()` than to use this method multiple times
depending of the dispatcher.
... | [
"put",
"a",
"task"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/TaskPackageDropbox.py#L75-L104 | [
"def",
"put",
"(",
"self",
",",
"package",
")",
":",
"pkgidx",
"=",
"self",
".",
"workingArea",
".",
"put_package",
"(",
"package",
")",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"info",
"(",
"'submitting {}'",
".",... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | TaskPackageDropbox.put_multiple | put tasks
This method places multiple tasks in the working area and have
the dispatcher execute them.
Parameters
----------
packages : list(callable)
A list of tasks
Returns
-------
list(int)
Package indices assigned by the worki... | alphatwirl/concurrently/TaskPackageDropbox.py | def put_multiple(self, packages):
"""put tasks
This method places multiple tasks in the working area and have
the dispatcher execute them.
Parameters
----------
packages : list(callable)
A list of tasks
Returns
-------
list(int)
... | def put_multiple(self, packages):
"""put tasks
This method places multiple tasks in the working area and have
the dispatcher execute them.
Parameters
----------
packages : list(callable)
A list of tasks
Returns
-------
list(int)
... | [
"put",
"tasks"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/TaskPackageDropbox.py#L106-L133 | [
"def",
"put_multiple",
"(",
"self",
",",
"packages",
")",
":",
"pkgidxs",
"=",
"[",
"self",
".",
"workingArea",
".",
"put_package",
"(",
"p",
")",
"for",
"p",
"in",
"packages",
"]",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"log... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | TaskPackageDropbox.receive | return pairs of package indices and results of all tasks
This method waits until all tasks finish.
Returns
-------
list
A list of pairs of package indices and results | alphatwirl/concurrently/TaskPackageDropbox.py | def receive(self):
"""return pairs of package indices and results of all tasks
This method waits until all tasks finish.
Returns
-------
list
A list of pairs of package indices and results
"""
ret = [ ] # a list of (pkgid, result)
while Tru... | def receive(self):
"""return pairs of package indices and results of all tasks
This method waits until all tasks finish.
Returns
-------
list
A list of pairs of package indices and results
"""
ret = [ ] # a list of (pkgid, result)
while Tru... | [
"return",
"pairs",
"of",
"package",
"indices",
"and",
"results",
"of",
"all",
"tasks"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/TaskPackageDropbox.py#L135-L160 | [
"def",
"receive",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"# a list of (pkgid, result)",
"while",
"True",
":",
"if",
"self",
".",
"runid_pkgidx_map",
":",
"self",
".",
"runid_to_return",
".",
"extend",
"(",
"self",
".",
"dispatcher",
".",
"poll",
"(",... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | TaskPackageDropbox.poll | return pairs of package indices and results of finished tasks
This method does not wait for tasks to finish.
Returns
-------
list
A list of pairs of package indices and results | alphatwirl/concurrently/TaskPackageDropbox.py | def poll(self):
"""return pairs of package indices and results of finished tasks
This method does not wait for tasks to finish.
Returns
-------
list
A list of pairs of package indices and results
"""
self.runid_to_return.extend(self.dispatcher.poll... | def poll(self):
"""return pairs of package indices and results of finished tasks
This method does not wait for tasks to finish.
Returns
-------
list
A list of pairs of package indices and results
"""
self.runid_to_return.extend(self.dispatcher.poll... | [
"return",
"pairs",
"of",
"package",
"indices",
"and",
"results",
"of",
"finished",
"tasks"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/TaskPackageDropbox.py#L162-L176 | [
"def",
"poll",
"(",
"self",
")",
":",
"self",
".",
"runid_to_return",
".",
"extend",
"(",
"self",
".",
"dispatcher",
".",
"poll",
"(",
")",
")",
"ret",
"=",
"self",
".",
"_collect_all_finished_pkgidx_result_pairs",
"(",
")",
"return",
"ret"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | TaskPackageDropbox.receive_one | return a pair of a package index and result of a task
This method waits until a tasks finishes. It returns `None` if
no task is running.
Returns
-------
tuple or None
A pair of a package index and result. `None` if no tasks
is running. | alphatwirl/concurrently/TaskPackageDropbox.py | def receive_one(self):
"""return a pair of a package index and result of a task
This method waits until a tasks finishes. It returns `None` if
no task is running.
Returns
-------
tuple or None
A pair of a package index and result. `None` if no tasks
... | def receive_one(self):
"""return a pair of a package index and result of a task
This method waits until a tasks finishes. It returns `None` if
no task is running.
Returns
-------
tuple or None
A pair of a package index and result. `None` if no tasks
... | [
"return",
"a",
"pair",
"of",
"a",
"package",
"index",
"and",
"result",
"of",
"a",
"task"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/TaskPackageDropbox.py#L178-L208 | [
"def",
"receive_one",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"runid_pkgidx_map",
":",
"return",
"None",
"while",
"True",
":",
"if",
"not",
"self",
".",
"runid_to_return",
":",
"self",
".",
"runid_to_return",
".",
"extend",
"(",
"self",
".",
"di... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | MPEventLoopRunner.run_multiple | run the event loops in the background.
Args:
eventLoops (list): a list of event loops to run | alphatwirl/loop/MPEventLoopRunner.py | def run_multiple(self, eventLoops):
"""run the event loops in the background.
Args:
eventLoops (list): a list of event loops to run
"""
self.nruns += len(eventLoops)
return self.communicationChannel.put_multiple(eventLoops) | def run_multiple(self, eventLoops):
"""run the event loops in the background.
Args:
eventLoops (list): a list of event loops to run
"""
self.nruns += len(eventLoops)
return self.communicationChannel.put_multiple(eventLoops) | [
"run",
"the",
"event",
"loops",
"in",
"the",
"background",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/loop/MPEventLoopRunner.py#L84-L93 | [
"def",
"run_multiple",
"(",
"self",
",",
"eventLoops",
")",
":",
"self",
".",
"nruns",
"+=",
"len",
"(",
"eventLoops",
")",
"return",
"self",
".",
"communicationChannel",
".",
"put_multiple",
"(",
"eventLoops",
")"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | MPEventLoopRunner.poll | Return pairs of run ids and results of finish event loops. | alphatwirl/loop/MPEventLoopRunner.py | def poll(self):
"""Return pairs of run ids and results of finish event loops.
"""
ret = self.communicationChannel.receive_finished()
self.nruns -= len(ret)
return ret | def poll(self):
"""Return pairs of run ids and results of finish event loops.
"""
ret = self.communicationChannel.receive_finished()
self.nruns -= len(ret)
return ret | [
"Return",
"pairs",
"of",
"run",
"ids",
"and",
"results",
"of",
"finish",
"event",
"loops",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/loop/MPEventLoopRunner.py#L95-L100 | [
"def",
"poll",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"communicationChannel",
".",
"receive_finished",
"(",
")",
"self",
".",
"nruns",
"-=",
"len",
"(",
"ret",
")",
"return",
"ret"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | MPEventLoopRunner.receive_one | Return a pair of a run id and a result.
This method waits until an event loop finishes.
This method returns None if no loop is running. | alphatwirl/loop/MPEventLoopRunner.py | def receive_one(self):
"""Return a pair of a run id and a result.
This method waits until an event loop finishes.
This method returns None if no loop is running.
"""
if self.nruns == 0:
return None
ret = self.communicationChannel.receive_one()
if ret ... | def receive_one(self):
"""Return a pair of a run id and a result.
This method waits until an event loop finishes.
This method returns None if no loop is running.
"""
if self.nruns == 0:
return None
ret = self.communicationChannel.receive_one()
if ret ... | [
"Return",
"a",
"pair",
"of",
"a",
"run",
"id",
"and",
"a",
"result",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/loop/MPEventLoopRunner.py#L102-L113 | [
"def",
"receive_one",
"(",
"self",
")",
":",
"if",
"self",
".",
"nruns",
"==",
"0",
":",
"return",
"None",
"ret",
"=",
"self",
".",
"communicationChannel",
".",
"receive_one",
"(",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"self",
".",
"nruns",
"-=... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | MPEventLoopRunner.receive | Return pairs of run ids and results.
This method waits until all event loops finish | alphatwirl/loop/MPEventLoopRunner.py | def receive(self):
"""Return pairs of run ids and results.
This method waits until all event loops finish
"""
ret = self.communicationChannel.receive_all()
self.nruns -= len(ret)
if self.nruns > 0:
import logging
logger = logging.getLogger(__name_... | def receive(self):
"""Return pairs of run ids and results.
This method waits until all event loops finish
"""
ret = self.communicationChannel.receive_all()
self.nruns -= len(ret)
if self.nruns > 0:
import logging
logger = logging.getLogger(__name_... | [
"Return",
"pairs",
"of",
"run",
"ids",
"and",
"results",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/loop/MPEventLoopRunner.py#L115-L134 | [
"def",
"receive",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"communicationChannel",
".",
"receive_all",
"(",
")",
"self",
".",
"nruns",
"-=",
"len",
"(",
"ret",
")",
"if",
"self",
".",
"nruns",
">",
"0",
":",
"import",
"logging",
"logger",
"=",... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | MPEventLoopRunner.end | wait until all event loops end and returns the results. | alphatwirl/loop/MPEventLoopRunner.py | def end(self):
"""wait until all event loops end and returns the results.
"""
results = self.communicationChannel.receive()
if self.nruns != len(results):
import logging
logger = logging.getLogger(__name__)
# logger.setLevel(logging.DEBUG)
... | def end(self):
"""wait until all event loops end and returns the results.
"""
results = self.communicationChannel.receive()
if self.nruns != len(results):
import logging
logger = logging.getLogger(__name__)
# logger.setLevel(logging.DEBUG)
... | [
"wait",
"until",
"all",
"event",
"loops",
"end",
"and",
"returns",
"the",
"results",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/loop/MPEventLoopRunner.py#L136-L153 | [
"def",
"end",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"communicationChannel",
".",
"receive",
"(",
")",
"if",
"self",
".",
"nruns",
"!=",
"len",
"(",
"results",
")",
":",
"import",
"logging",
"logger",
"=",
"logging",
".",
"getLogger",
"(",... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | key_vals_dict_to_tuple_list | Convert ``key_vals_dict`` to `tuple_list``.
Args:
key_vals_dict (dict): The first parameter.
fill: a value to fill missing data
Returns:
A list of tuples | alphatwirl/summary/convert.py | def key_vals_dict_to_tuple_list(key_vals_dict, fill=float('nan')):
"""Convert ``key_vals_dict`` to `tuple_list``.
Args:
key_vals_dict (dict): The first parameter.
fill: a value to fill missing data
Returns:
A list of tuples
"""
tuple_list = [ ]
if not key_vals_dict: ... | def key_vals_dict_to_tuple_list(key_vals_dict, fill=float('nan')):
"""Convert ``key_vals_dict`` to `tuple_list``.
Args:
key_vals_dict (dict): The first parameter.
fill: a value to fill missing data
Returns:
A list of tuples
"""
tuple_list = [ ]
if not key_vals_dict: ... | [
"Convert",
"key_vals_dict",
"to",
"tuple_list",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/summary/convert.py#L5-L31 | [
"def",
"key_vals_dict_to_tuple_list",
"(",
"key_vals_dict",
",",
"fill",
"=",
"float",
"(",
"'nan'",
")",
")",
":",
"tuple_list",
"=",
"[",
"]",
"if",
"not",
"key_vals_dict",
":",
"return",
"tuple_list",
"vlen",
"=",
"max",
"(",
"[",
"len",
"(",
"vs",
")... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | WorkingArea.open | Open the working area
Returns
-------
None | alphatwirl/concurrently/WorkingArea.py | def open(self):
"""Open the working area
Returns
-------
None
"""
self.path = self._prepare_dir(self.topdir)
self._copy_executable(area_path=self.path)
self._save_logging_levels(area_path=self.path)
self._put_python_modules(modules=self.python_mo... | def open(self):
"""Open the working area
Returns
-------
None
"""
self.path = self._prepare_dir(self.topdir)
self._copy_executable(area_path=self.path)
self._save_logging_levels(area_path=self.path)
self._put_python_modules(modules=self.python_mo... | [
"Open",
"the",
"working",
"area"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L62-L73 | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"path",
"=",
"self",
".",
"_prepare_dir",
"(",
"self",
".",
"topdir",
")",
"self",
".",
"_copy_executable",
"(",
"area_path",
"=",
"self",
".",
"path",
")",
"self",
".",
"_save_logging_levels",
"(",
"a... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | WorkingArea.put_package | Put a package
Parameters
----------
package :
a task package
Returns
-------
int
A package index | alphatwirl/concurrently/WorkingArea.py | def put_package(self, package):
"""Put a package
Parameters
----------
package :
a task package
Returns
-------
int
A package index
"""
self.last_package_index += 1
package_index = self.last_package_index
... | def put_package(self, package):
"""Put a package
Parameters
----------
package :
a task package
Returns
-------
int
A package index
"""
self.last_package_index += 1
package_index = self.last_package_index
... | [
"Put",
"a",
"package"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L142-L175 | [
"def",
"put_package",
"(",
"self",
",",
"package",
")",
":",
"self",
".",
"last_package_index",
"+=",
"1",
"package_index",
"=",
"self",
".",
"last_package_index",
"package_fullpath",
"=",
"self",
".",
"package_fullpath",
"(",
"package_index",
")",
"# e.g., '{path... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | WorkingArea.collect_result | Collect the result of a task
Parameters
----------
package_index :
a package index
Returns
-------
obj
The result of the task | alphatwirl/concurrently/WorkingArea.py | def collect_result(self, package_index):
"""Collect the result of a task
Parameters
----------
package_index :
a package index
Returns
-------
obj
The result of the task
"""
result_fullpath = self.result_fullpath(package... | def collect_result(self, package_index):
"""Collect the result of a task
Parameters
----------
package_index :
a package index
Returns
-------
obj
The result of the task
"""
result_fullpath = self.result_fullpath(package... | [
"Collect",
"the",
"result",
"of",
"a",
"task"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L177-L203 | [
"def",
"collect_result",
"(",
"self",
",",
"package_index",
")",
":",
"result_fullpath",
"=",
"self",
".",
"result_fullpath",
"(",
"package_index",
")",
"# e.g., '{path}/tpd_20161129_122841_HnpcmF/results/task_00009/result.p.gz'",
"try",
":",
"with",
"gzip",
".",
"open",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | WorkingArea.package_fullpath | Returns the full path of the package
This method returns the full path to the package. This method
simply constructs the path based on the convention and doesn't
check if the package actually exists.
Parameters
----------
package_index :
a package index
... | alphatwirl/concurrently/WorkingArea.py | def package_fullpath(self, package_index):
"""Returns the full path of the package
This method returns the full path to the package. This method
simply constructs the path based on the convention and doesn't
check if the package actually exists.
Parameters
----------
... | def package_fullpath(self, package_index):
"""Returns the full path of the package
This method returns the full path to the package. This method
simply constructs the path based on the convention and doesn't
check if the package actually exists.
Parameters
----------
... | [
"Returns",
"the",
"full",
"path",
"of",
"the",
"package"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L234-L256 | [
"def",
"package_fullpath",
"(",
"self",
",",
"package_index",
")",
":",
"ret",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"self",
".",
"package_relpath",
"(",
"package_index",
")",
")",
"# e.g., '{path}/tpd_20161129_122841_HnpcmF/task_00... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | WorkingArea.result_relpath | Returns the relative path of the result
This method returns the path to the result relative to the
top dir of the working area. This method simply constructs the
path based on the convention and doesn't check if the result
actually exists.
Parameters
----------
... | alphatwirl/concurrently/WorkingArea.py | def result_relpath(self, package_index):
"""Returns the relative path of the result
This method returns the path to the result relative to the
top dir of the working area. This method simply constructs the
path based on the convention and doesn't check if the result
actually exi... | def result_relpath(self, package_index):
"""Returns the relative path of the result
This method returns the path to the result relative to the
top dir of the working area. This method simply constructs the
path based on the convention and doesn't check if the result
actually exi... | [
"Returns",
"the",
"relative",
"path",
"of",
"the",
"result"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L258-L284 | [
"def",
"result_relpath",
"(",
"self",
",",
"package_index",
")",
":",
"dirname",
"=",
"'task_{:05d}'",
".",
"format",
"(",
"package_index",
")",
"# e.g., 'task_00009'",
"ret",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'results'",
",",
"dirname",
",",
"'resu... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | WorkingArea.result_fullpath | Returns the full path of the result
This method returns the full path to the result. This method
simply constructs the path based on the convention and doesn't
check if the result actually exists.
Parameters
----------
package_index :
a package index
... | alphatwirl/concurrently/WorkingArea.py | def result_fullpath(self, package_index):
"""Returns the full path of the result
This method returns the full path to the result. This method
simply constructs the path based on the convention and doesn't
check if the result actually exists.
Parameters
----------
... | def result_fullpath(self, package_index):
"""Returns the full path of the result
This method returns the full path to the result. This method
simply constructs the path based on the convention and doesn't
check if the result actually exists.
Parameters
----------
... | [
"Returns",
"the",
"full",
"path",
"of",
"the",
"result"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L286-L308 | [
"def",
"result_fullpath",
"(",
"self",
",",
"package_index",
")",
":",
"ret",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"self",
".",
"result_relpath",
"(",
"package_index",
")",
")",
"# e.g., '{path}/tpd_20161129_122841_HnpcmF/results/t... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | HTCondorJobSubmitter.run_multiple | Submit multiple jobs
Parameters
----------
workingArea :
A workingArea
package_indices : list(int)
A list of package indices
Returns
-------
list(str)
The list of the run IDs of the jobs | alphatwirl/concurrently/condor/submitter.py | def run_multiple(self, workingArea, package_indices):
"""Submit multiple jobs
Parameters
----------
workingArea :
A workingArea
package_indices : list(int)
A list of package indices
Returns
-------
list(str)
The list o... | def run_multiple(self, workingArea, package_indices):
"""Submit multiple jobs
Parameters
----------
workingArea :
A workingArea
package_indices : list(int)
A list of package indices
Returns
-------
list(str)
The list o... | [
"Submit",
"multiple",
"jobs"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/condor/submitter.py#L102-L133 | [
"def",
"run_multiple",
"(",
"self",
",",
"workingArea",
",",
"package_indices",
")",
":",
"if",
"not",
"package_indices",
":",
"return",
"[",
"]",
"job_desc",
"=",
"self",
".",
"_compose_job_desc",
"(",
"workingArea",
",",
"package_indices",
")",
"clusterprocids... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | HTCondorJobSubmitter.poll | Return the run IDs of the finished jobs
Returns
-------
list(str)
The list of the run IDs of the finished jobs | alphatwirl/concurrently/condor/submitter.py | def poll(self):
"""Return the run IDs of the finished jobs
Returns
-------
list(str)
The list of the run IDs of the finished jobs
"""
clusterids = clusterprocids2clusterids(self.clusterprocids_outstanding)
clusterprocid_status_list = query_status_fo... | def poll(self):
"""Return the run IDs of the finished jobs
Returns
-------
list(str)
The list of the run IDs of the finished jobs
"""
clusterids = clusterprocids2clusterids(self.clusterprocids_outstanding)
clusterprocid_status_list = query_status_fo... | [
"Return",
"the",
"run",
"IDs",
"of",
"the",
"finished",
"jobs"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/condor/submitter.py#L154-L187 | [
"def",
"poll",
"(",
"self",
")",
":",
"clusterids",
"=",
"clusterprocids2clusterids",
"(",
"self",
".",
"clusterprocids_outstanding",
")",
"clusterprocid_status_list",
"=",
"query_status_for",
"(",
"clusterids",
")",
"# e.g., [['1730126.0', 2], ['1730127.0', 2], ['1730129.1',... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | HTCondorJobSubmitter.wait | Wait until all jobs finish and return the run IDs of the finished jobs
Returns
-------
list(str)
The list of the run IDs of the finished jobs | alphatwirl/concurrently/condor/submitter.py | def wait(self):
"""Wait until all jobs finish and return the run IDs of the finished jobs
Returns
-------
list(str)
The list of the run IDs of the finished jobs
"""
sleep = 5
while True:
if self.clusterprocids_outstanding:
... | def wait(self):
"""Wait until all jobs finish and return the run IDs of the finished jobs
Returns
-------
list(str)
The list of the run IDs of the finished jobs
"""
sleep = 5
while True:
if self.clusterprocids_outstanding:
... | [
"Wait",
"until",
"all",
"jobs",
"finish",
"and",
"return",
"the",
"run",
"IDs",
"of",
"the",
"finished",
"jobs"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/condor/submitter.py#L189-L206 | [
"def",
"wait",
"(",
"self",
")",
":",
"sleep",
"=",
"5",
"while",
"True",
":",
"if",
"self",
".",
"clusterprocids_outstanding",
":",
"self",
".",
"poll",
"(",
")",
"if",
"not",
"self",
".",
"clusterprocids_outstanding",
":",
"break",
"time",
".",
"sleep"... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | HTCondorJobSubmitter.failed_runids | Provide the run IDs of failed jobs
Returns
-------
None | alphatwirl/concurrently/condor/submitter.py | def failed_runids(self, runids):
"""Provide the run IDs of failed jobs
Returns
-------
None
"""
# remove failed clusterprocids from self.clusterprocids_finished
# so that len(self.clusterprocids_finished)) becomes the number
# of the successfully finis... | def failed_runids(self, runids):
"""Provide the run IDs of failed jobs
Returns
-------
None
"""
# remove failed clusterprocids from self.clusterprocids_finished
# so that len(self.clusterprocids_finished)) becomes the number
# of the successfully finis... | [
"Provide",
"the",
"run",
"IDs",
"of",
"failed",
"jobs"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/condor/submitter.py#L208-L225 | [
"def",
"failed_runids",
"(",
"self",
",",
"runids",
")",
":",
"# remove failed clusterprocids from self.clusterprocids_finished",
"# so that len(self.clusterprocids_finished)) becomes the number",
"# of the successfully finished jobs",
"for",
"i",
"in",
"runids",
":",
"try",
":",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | atpbar | Progress bar | alphatwirl/progressbar/main.py | def atpbar(iterable, name=None):
"""Progress bar
"""
try:
len_ = len(iterable)
except TypeError:
logger = logging.getLogger(__name__)
logging.warning('length is unknown: {!r}'.format(iterable))
logging.warning('atpbar is turned off')
return iterable
if name ... | def atpbar(iterable, name=None):
"""Progress bar
"""
try:
len_ = len(iterable)
except TypeError:
logger = logging.getLogger(__name__)
logging.warning('length is unknown: {!r}'.format(iterable))
logging.warning('atpbar is turned off')
return iterable
if name ... | [
"Progress",
"bar"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/progressbar/main.py#L12-L27 | [
"def",
"atpbar",
"(",
"iterable",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"len_",
"=",
"len",
"(",
"iterable",
")",
"except",
"TypeError",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logging",
".",
"warning",
"(",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | BranchAddressManager.getArrays | return the array.array objects for the branch and its counter branch
This method returns a pair of the array.array objects. The first one is
for the given tree and branch name. The second one is for its counter
branch. The second one will be None when the branch does not have a
counter.... | alphatwirl/roottree/BranchAddressManager.py | def getArrays(self, tree, branchName):
"""return the array.array objects for the branch and its counter branch
This method returns a pair of the array.array objects. The first one is
for the given tree and branch name. The second one is for its counter
branch. The second one will be Non... | def getArrays(self, tree, branchName):
"""return the array.array objects for the branch and its counter branch
This method returns a pair of the array.array objects. The first one is
for the given tree and branch name. The second one is for its counter
branch. The second one will be Non... | [
"return",
"the",
"array",
".",
"array",
"objects",
"for",
"the",
"branch",
"and",
"its",
"counter",
"branch"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/roottree/BranchAddressManager.py#L23-L36 | [
"def",
"getArrays",
"(",
"self",
",",
"tree",
",",
"branchName",
")",
":",
"itsArray",
"=",
"self",
".",
"_getArray",
"(",
"tree",
",",
"branchName",
")",
"if",
"itsArray",
"is",
"None",
":",
"return",
"None",
",",
"None",
"itsCountArray",
"=",
"self",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.begin | begin | alphatwirl/concurrently/CommunicationChannel.py | def begin(self):
"""begin
"""
if self.isopen: return
self.dropbox.open()
self.isopen = True | def begin(self):
"""begin
"""
if self.isopen: return
self.dropbox.open()
self.isopen = True | [
"begin"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L114-L120 | [
"def",
"begin",
"(",
"self",
")",
":",
"if",
"self",
".",
"isopen",
":",
"return",
"self",
".",
"dropbox",
".",
"open",
"(",
")",
"self",
".",
"isopen",
"=",
"True"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.put | put a task and its arguments
If you need to put multiple tasks, it can be faster to put
multiple tasks with `put_multiple()` than to use this method
multiple times.
Parameters
----------
task : a function
A function to be executed
args : list
... | alphatwirl/concurrently/CommunicationChannel.py | def put(self, task, *args, **kwargs):
"""put a task and its arguments
If you need to put multiple tasks, it can be faster to put
multiple tasks with `put_multiple()` than to use this method
multiple times.
Parameters
----------
task : a function
A fu... | def put(self, task, *args, **kwargs):
"""put a task and its arguments
If you need to put multiple tasks, it can be faster to put
multiple tasks with `put_multiple()` than to use this method
multiple times.
Parameters
----------
task : a function
A fu... | [
"put",
"a",
"task",
"and",
"its",
"arguments"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L122-L150 | [
"def",
"put",
"(",
"self",
",",
"task",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"isopen",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"warning",
"(",
"'the drop box is n... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.put_multiple | put a list of tasks and their arguments
This method can be used to put multiple tasks at once. Calling
this method once with multiple tasks can be much faster than
calling `put()` multiple times.
Parameters
----------
task_args_kwargs_list : list
A list of ... | alphatwirl/concurrently/CommunicationChannel.py | def put_multiple(self, task_args_kwargs_list):
"""put a list of tasks and their arguments
This method can be used to put multiple tasks at once. Calling
this method once with multiple tasks can be much faster than
calling `put()` multiple times.
Parameters
----------
... | def put_multiple(self, task_args_kwargs_list):
"""put a list of tasks and their arguments
This method can be used to put multiple tasks at once. Calling
this method once with multiple tasks can be much faster than
calling `put()` multiple times.
Parameters
----------
... | [
"put",
"a",
"list",
"of",
"tasks",
"and",
"their",
"arguments"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L152-L187 | [
"def",
"put_multiple",
"(",
"self",
",",
"task_args_kwargs_list",
")",
":",
"if",
"not",
"self",
".",
"isopen",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"warning",
"(",
"'the drop box is not open'",
")",
"return",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.receive_finished | return a list of pairs of IDs and results of finished tasks.
This method doesn't wait for tasks to finish. It returns IDs
and results which have already finished.
Returns
-------
list
A list of pairs of IDs and results | alphatwirl/concurrently/CommunicationChannel.py | def receive_finished(self):
"""return a list of pairs of IDs and results of finished tasks.
This method doesn't wait for tasks to finish. It returns IDs
and results which have already finished.
Returns
-------
list
A list of pairs of IDs and results
... | def receive_finished(self):
"""return a list of pairs of IDs and results of finished tasks.
This method doesn't wait for tasks to finish. It returns IDs
and results which have already finished.
Returns
-------
list
A list of pairs of IDs and results
... | [
"return",
"a",
"list",
"of",
"pairs",
"of",
"IDs",
"and",
"results",
"of",
"finished",
"tasks",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L189-L205 | [
"def",
"receive_finished",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"isopen",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"warning",
"(",
"'the drop box is not open'",
")",
"return",
"return",
"self",
".",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.receive_one | return a pair of an ID and a result of a task.
This method waits for a task to finish.
Returns
-------
An ID and a result of a task. `None` if no task is running. | alphatwirl/concurrently/CommunicationChannel.py | def receive_one(self):
"""return a pair of an ID and a result of a task.
This method waits for a task to finish.
Returns
-------
An ID and a result of a task. `None` if no task is running.
"""
if not self.isopen:
logger = logging.getLogger(__name__)... | def receive_one(self):
"""return a pair of an ID and a result of a task.
This method waits for a task to finish.
Returns
-------
An ID and a result of a task. `None` if no task is running.
"""
if not self.isopen:
logger = logging.getLogger(__name__)... | [
"return",
"a",
"pair",
"of",
"an",
"ID",
"and",
"a",
"result",
"of",
"a",
"task",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L207-L221 | [
"def",
"receive_one",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"isopen",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"warning",
"(",
"'the drop box is not open'",
")",
"return",
"return",
"self",
".",
"drop... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.receive_all | return a list of pairs of IDs and results of all tasks.
This method waits for all tasks to finish.
Returns
-------
list
A list of pairs of IDs and results | alphatwirl/concurrently/CommunicationChannel.py | def receive_all(self):
"""return a list of pairs of IDs and results of all tasks.
This method waits for all tasks to finish.
Returns
-------
list
A list of pairs of IDs and results
"""
if not self.isopen:
logger = logging.getLogger(__nam... | def receive_all(self):
"""return a list of pairs of IDs and results of all tasks.
This method waits for all tasks to finish.
Returns
-------
list
A list of pairs of IDs and results
"""
if not self.isopen:
logger = logging.getLogger(__nam... | [
"return",
"a",
"list",
"of",
"pairs",
"of",
"IDs",
"and",
"results",
"of",
"all",
"tasks",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L223-L238 | [
"def",
"receive_all",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"isopen",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"warning",
"(",
"'the drop box is not open'",
")",
"return",
"return",
"self",
".",
"drop... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.receive | return a list results of all tasks.
This method waits for all tasks to finish.
Returns
-------
list
A list of results of the tasks. The results are sorted in
the order in which the tasks are put. | alphatwirl/concurrently/CommunicationChannel.py | def receive(self):
"""return a list results of all tasks.
This method waits for all tasks to finish.
Returns
-------
list
A list of results of the tasks. The results are sorted in
the order in which the tasks are put.
"""
pkgidx_result_p... | def receive(self):
"""return a list results of all tasks.
This method waits for all tasks to finish.
Returns
-------
list
A list of results of the tasks. The results are sorted in
the order in which the tasks are put.
"""
pkgidx_result_p... | [
"return",
"a",
"list",
"results",
"of",
"all",
"tasks",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L240-L256 | [
"def",
"receive",
"(",
"self",
")",
":",
"pkgidx_result_pairs",
"=",
"self",
".",
"receive_all",
"(",
")",
"if",
"pkgidx_result_pairs",
"is",
"None",
":",
"return",
"results",
"=",
"[",
"r",
"for",
"_",
",",
"r",
"in",
"pkgidx_result_pairs",
"]",
"return",... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CommunicationChannel.end | end | alphatwirl/concurrently/CommunicationChannel.py | def end(self):
"""end
"""
if not self.isopen: return
self.dropbox.close()
self.isopen = False | def end(self):
"""end
"""
if not self.isopen: return
self.dropbox.close()
self.isopen = False | [
"end"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L264-L270 | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"isopen",
":",
"return",
"self",
".",
"dropbox",
".",
"close",
"(",
")",
"self",
".",
"isopen",
"=",
"False"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | expand_path_cfg | expand a path config
Args:
path_cfg (str, tuple, dict): a config for path
alias_dict (dict): a dict for aliases
overriding_kargs (dict): to be used for recursive call | alphatwirl/selection/factories/expand.py | def expand_path_cfg(path_cfg, alias_dict={ }, overriding_kargs={ }):
"""expand a path config
Args:
path_cfg (str, tuple, dict): a config for path
alias_dict (dict): a dict for aliases
overriding_kargs (dict): to be used for recursive call
"""
if isinstance(path_cfg, str):
... | def expand_path_cfg(path_cfg, alias_dict={ }, overriding_kargs={ }):
"""expand a path config
Args:
path_cfg (str, tuple, dict): a config for path
alias_dict (dict): a dict for aliases
overriding_kargs (dict): to be used for recursive call
"""
if isinstance(path_cfg, str):
... | [
"expand",
"a",
"path",
"config"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/selection/factories/expand.py#L4-L20 | [
"def",
"expand_path_cfg",
"(",
"path_cfg",
",",
"alias_dict",
"=",
"{",
"}",
",",
"overriding_kargs",
"=",
"{",
"}",
")",
":",
"if",
"isinstance",
"(",
"path_cfg",
",",
"str",
")",
":",
"return",
"_expand_str",
"(",
"path_cfg",
",",
"alias_dict",
",",
"o... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | _expand_str | expand a path config given as a string | alphatwirl/selection/factories/expand.py | def _expand_str(path_cfg, alias_dict, overriding_kargs):
"""expand a path config given as a string
"""
if path_cfg in alias_dict:
# e.g., path_cfg = 'var_cut'
return _expand_str_alias(path_cfg, alias_dict, overriding_kargs)
# e.g., path_cfg = 'ev : {low} <= ev.var[0] < {high}'
ret... | def _expand_str(path_cfg, alias_dict, overriding_kargs):
"""expand a path config given as a string
"""
if path_cfg in alias_dict:
# e.g., path_cfg = 'var_cut'
return _expand_str_alias(path_cfg, alias_dict, overriding_kargs)
# e.g., path_cfg = 'ev : {low} <= ev.var[0] < {high}'
ret... | [
"expand",
"a",
"path",
"config",
"given",
"as",
"a",
"string"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/selection/factories/expand.py#L23-L33 | [
"def",
"_expand_str",
"(",
"path_cfg",
",",
"alias_dict",
",",
"overriding_kargs",
")",
":",
"if",
"path_cfg",
"in",
"alias_dict",
":",
"# e.g., path_cfg = 'var_cut'",
"return",
"_expand_str_alias",
"(",
"path_cfg",
",",
"alias_dict",
",",
"overriding_kargs",
")",
"... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | _expand_str_alias | expand a path config given as a string
Args:
path_cfg (str): an alias
alias_dict (dict):
overriding_kargs (dict): | alphatwirl/selection/factories/expand.py | def _expand_str_alias(path_cfg, alias_dict, overriding_kargs):
"""expand a path config given as a string
Args:
path_cfg (str): an alias
alias_dict (dict):
overriding_kargs (dict):
"""
# e.g.,
# path_cfg = 'var_cut'
new_path_cfg = alias_dict[path_cfg]
# e.g., ('ev :... | def _expand_str_alias(path_cfg, alias_dict, overriding_kargs):
"""expand a path config given as a string
Args:
path_cfg (str): an alias
alias_dict (dict):
overriding_kargs (dict):
"""
# e.g.,
# path_cfg = 'var_cut'
new_path_cfg = alias_dict[path_cfg]
# e.g., ('ev :... | [
"expand",
"a",
"path",
"config",
"given",
"as",
"a",
"string"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/selection/factories/expand.py#L67-L88 | [
"def",
"_expand_str_alias",
"(",
"path_cfg",
",",
"alias_dict",
",",
"overriding_kargs",
")",
":",
"# e.g.,",
"# path_cfg = 'var_cut'",
"new_path_cfg",
"=",
"alias_dict",
"[",
"path_cfg",
"]",
"# e.g., ('ev : {low} <= ev.var[0] < {high}', {'low': 10, 'high': 200})",
"new_overri... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | _expand_tuple | expand a path config given as a tuple | alphatwirl/selection/factories/expand.py | def _expand_tuple(path_cfg, alias_dict, overriding_kargs):
"""expand a path config given as a tuple
"""
# e.g.,
# path_cfg = ('ev : {low} <= ev.var[0] < {high}', {'low': 10, 'high': 200})
# overriding_kargs = {'alias': 'var_cut', 'name': 'var_cut25', 'low': 25}
new_path_cfg = path_cfg[0]
... | def _expand_tuple(path_cfg, alias_dict, overriding_kargs):
"""expand a path config given as a tuple
"""
# e.g.,
# path_cfg = ('ev : {low} <= ev.var[0] < {high}', {'low': 10, 'high': 200})
# overriding_kargs = {'alias': 'var_cut', 'name': 'var_cut25', 'low': 25}
new_path_cfg = path_cfg[0]
... | [
"expand",
"a",
"path",
"config",
"given",
"as",
"a",
"tuple"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/selection/factories/expand.py#L91-L113 | [
"def",
"_expand_tuple",
"(",
"path_cfg",
",",
"alias_dict",
",",
"overriding_kargs",
")",
":",
"# e.g.,",
"# path_cfg = ('ev : {low} <= ev.var[0] < {high}', {'low': 10, 'high': 200})",
"# overriding_kargs = {'alias': 'var_cut', 'name': 'var_cut25', 'low': 25}",
"new_path_cfg",
"=",
"pa... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | SubprocessRunner.poll | check if the jobs are running and return a list of pids for
finished jobs | alphatwirl/concurrently/SubprocessRunner.py | def poll(self):
"""check if the jobs are running and return a list of pids for
finished jobs
"""
finished_procs = [p for p in self.running_procs if p.poll() is not None]
self.running_procs = collections.deque([p for p in self.running_procs if p not in finished_procs])
f... | def poll(self):
"""check if the jobs are running and return a list of pids for
finished jobs
"""
finished_procs = [p for p in self.running_procs if p.poll() is not None]
self.running_procs = collections.deque([p for p in self.running_procs if p not in finished_procs])
f... | [
"check",
"if",
"the",
"jobs",
"are",
"running",
"and",
"return",
"a",
"list",
"of",
"pids",
"for",
"finished",
"jobs"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/SubprocessRunner.py#L59-L79 | [
"def",
"poll",
"(",
"self",
")",
":",
"finished_procs",
"=",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"running_procs",
"if",
"p",
".",
"poll",
"(",
")",
"is",
"not",
"None",
"]",
"self",
".",
"running_procs",
"=",
"collections",
".",
"deque",
"(",
... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | SubprocessRunner.wait | wait until all jobs finish and return a list of pids | alphatwirl/concurrently/SubprocessRunner.py | def wait(self):
"""wait until all jobs finish and return a list of pids
"""
finished_pids = [ ]
while self.running_procs:
finished_pids.extend(self.poll())
return finished_pids | def wait(self):
"""wait until all jobs finish and return a list of pids
"""
finished_pids = [ ]
while self.running_procs:
finished_pids.extend(self.poll())
return finished_pids | [
"wait",
"until",
"all",
"jobs",
"finish",
"and",
"return",
"a",
"list",
"of",
"pids"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/SubprocessRunner.py#L81-L87 | [
"def",
"wait",
"(",
"self",
")",
":",
"finished_pids",
"=",
"[",
"]",
"while",
"self",
".",
"running_procs",
":",
"finished_pids",
".",
"extend",
"(",
"self",
".",
"poll",
"(",
")",
")",
"return",
"finished_pids"
] | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | BranchAddressManagerForVector.getVector | return the ROOT.vector object for the branch. | alphatwirl/roottree/BranchAddressManagerForVector.py | def getVector(self, tree, branchName):
"""return the ROOT.vector object for the branch.
"""
if (tree, branchName) in self.__class__.addressDict:
return self.__class__.addressDict[(tree, branchName)]
itsVector = self._getVector(tree, branchName)
self.__class__.addre... | def getVector(self, tree, branchName):
"""return the ROOT.vector object for the branch.
"""
if (tree, branchName) in self.__class__.addressDict:
return self.__class__.addressDict[(tree, branchName)]
itsVector = self._getVector(tree, branchName)
self.__class__.addre... | [
"return",
"the",
"ROOT",
".",
"vector",
"object",
"for",
"the",
"branch",
"."
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/roottree/BranchAddressManagerForVector.py#L18-L29 | [
"def",
"getVector",
"(",
"self",
",",
"tree",
",",
"branchName",
")",
":",
"if",
"(",
"tree",
",",
"branchName",
")",
"in",
"self",
".",
"__class__",
".",
"addressDict",
":",
"return",
"self",
".",
"__class__",
".",
"addressDict",
"[",
"(",
"tree",
","... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | build_parallel | initializes `Parallel`
Parameters
----------
parallel_mode : str
"multiprocessing" (default), "htcondor" or "subprocess"
quiet : bool, optional
if True, progress bars will not be shown in the "multiprocessing" mode.
process : int, optional
The number of processes when ``para... | alphatwirl/parallel/build.py | def build_parallel(parallel_mode, quiet=True, processes=4,
user_modules=None, dispatcher_options=None):
"""initializes `Parallel`
Parameters
----------
parallel_mode : str
"multiprocessing" (default), "htcondor" or "subprocess"
quiet : bool, optional
if True, prog... | def build_parallel(parallel_mode, quiet=True, processes=4,
user_modules=None, dispatcher_options=None):
"""initializes `Parallel`
Parameters
----------
parallel_mode : str
"multiprocessing" (default), "htcondor" or "subprocess"
quiet : bool, optional
if True, prog... | [
"initializes",
"Parallel"
] | alphatwirl/alphatwirl | python | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/parallel/build.py#L14-L66 | [
"def",
"build_parallel",
"(",
"parallel_mode",
",",
"quiet",
"=",
"True",
",",
"processes",
"=",
"4",
",",
"user_modules",
"=",
"None",
",",
"dispatcher_options",
"=",
"None",
")",
":",
"if",
"user_modules",
"is",
"None",
":",
"user_modules",
"=",
"[",
"]"... | 5138eeba6cd8a334ba52d6c2c022b33c61e3ba38 |
valid | CMakeGen.configure | Ensure all config-time files have been generated. Return a
dictionary of generated items. | yotta/lib/cmakegen.py | def configure(self, component, all_dependencies):
''' Ensure all config-time files have been generated. Return a
dictionary of generated items.
'''
r = {}
builddir = self.buildroot
# only dependencies which are actually valid can contribute to the
# config d... | def configure(self, component, all_dependencies):
''' Ensure all config-time files have been generated. Return a
dictionary of generated items.
'''
r = {}
builddir = self.buildroot
# only dependencies which are actually valid can contribute to the
# config d... | [
"Ensure",
"all",
"config",
"-",
"time",
"files",
"have",
"been",
"generated",
".",
"Return",
"a",
"dictionary",
"of",
"generated",
"items",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L66-L96 | [
"def",
"configure",
"(",
"self",
",",
"component",
",",
"all_dependencies",
")",
":",
"r",
"=",
"{",
"}",
"builddir",
"=",
"self",
".",
"buildroot",
"# only dependencies which are actually valid can contribute to the",
"# config data (which includes the versions of all depend... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | CMakeGen.generateRecursive | generate top-level CMakeLists for this component and its
dependencies: the CMakeLists are all generated in self.buildroot,
which MUST be out-of-source
!!! NOTE: experimenting with a slightly different way of doing
things here, this function is a generator that yields any... | yotta/lib/cmakegen.py | def generateRecursive(self, component, all_components, builddir=None, modbuilddir=None, processed_components=None, application=None):
''' generate top-level CMakeLists for this component and its
dependencies: the CMakeLists are all generated in self.buildroot,
which MUST be out-of-source... | def generateRecursive(self, component, all_components, builddir=None, modbuilddir=None, processed_components=None, application=None):
''' generate top-level CMakeLists for this component and its
dependencies: the CMakeLists are all generated in self.buildroot,
which MUST be out-of-source... | [
"generate",
"top",
"-",
"level",
"CMakeLists",
"for",
"this",
"component",
"and",
"its",
"dependencies",
":",
"the",
"CMakeLists",
"are",
"all",
"generated",
"in",
"self",
".",
"buildroot",
"which",
"MUST",
"be",
"out",
"-",
"of",
"-",
"source"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L98-L166 | [
"def",
"generateRecursive",
"(",
"self",
",",
"component",
",",
"all_components",
",",
"builddir",
"=",
"None",
",",
"modbuilddir",
"=",
"None",
",",
"processed_components",
"=",
"None",
",",
"application",
"=",
"None",
")",
":",
"assert",
"(",
"self",
".",
... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | CMakeGen._validateListedSubdirsExist | Return true if all the subdirectories which this component lists in
its module.json file exist (although their validity is otherwise
not checked).
If they don't, warning messages are printed. | yotta/lib/cmakegen.py | def _validateListedSubdirsExist(self, component):
''' Return true if all the subdirectories which this component lists in
its module.json file exist (although their validity is otherwise
not checked).
If they don't, warning messages are printed.
'''
lib_subdi... | def _validateListedSubdirsExist(self, component):
''' Return true if all the subdirectories which this component lists in
its module.json file exist (although their validity is otherwise
not checked).
If they don't, warning messages are printed.
'''
lib_subdi... | [
"Return",
"true",
"if",
"all",
"the",
"subdirectories",
"which",
"this",
"component",
"lists",
"in",
"its",
"module",
".",
"json",
"file",
"exist",
"(",
"although",
"their",
"validity",
"is",
"otherwise",
"not",
"checked",
")",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L175-L200 | [
"def",
"_validateListedSubdirsExist",
"(",
"self",
",",
"component",
")",
":",
"lib_subdirs",
"=",
"component",
".",
"getLibs",
"(",
"explicit_only",
"=",
"True",
")",
"bin_subdirs",
"=",
"component",
".",
"getBinaries",
"(",
")",
"ok",
"=",
"True",
"for",
"... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | CMakeGen._listSubDirectories | return: {
manual: [list of subdirectories with manual CMakeLists],
auto: [list of pairs: (subdirectories name to autogenerate, a list of source files in that dir)],
bin: {dictionary of subdirectory name to binary name},
lib: {dictionary of subdirec... | yotta/lib/cmakegen.py | def _listSubDirectories(self, component, toplevel):
''' return: {
manual: [list of subdirectories with manual CMakeLists],
auto: [list of pairs: (subdirectories name to autogenerate, a list of source files in that dir)],
bin: {dictionary of subdirectory name ... | def _listSubDirectories(self, component, toplevel):
''' return: {
manual: [list of subdirectories with manual CMakeLists],
auto: [list of pairs: (subdirectories name to autogenerate, a list of source files in that dir)],
bin: {dictionary of subdirectory name ... | [
"return",
":",
"{",
"manual",
":",
"[",
"list",
"of",
"subdirectories",
"with",
"manual",
"CMakeLists",
"]",
"auto",
":",
"[",
"list",
"of",
"pairs",
":",
"(",
"subdirectories",
"name",
"to",
"autogenerate",
"a",
"list",
"of",
"source",
"files",
"in",
"t... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L202-L305 | [
"def",
"_listSubDirectories",
"(",
"self",
",",
"component",
",",
"toplevel",
")",
":",
"manual_subdirs",
"=",
"[",
"]",
"auto_subdirs",
"=",
"[",
"]",
"header_subdirs",
"=",
"[",
"]",
"lib_subdirs",
"=",
"component",
".",
"getLibs",
"(",
")",
"bin_subdirs",... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | CMakeGen._getConfigData | returns (path_to_config_header, cmake_set_definitions) | yotta/lib/cmakegen.py | def _getConfigData(self, all_dependencies, component, builddir, build_info_header_path):
''' returns (path_to_config_header, cmake_set_definitions) '''
# ordered_json, , read/write ordered json, internal
from yotta.lib import ordered_json
add_defs_header = ''
set_definitions = ''... | def _getConfigData(self, all_dependencies, component, builddir, build_info_header_path):
''' returns (path_to_config_header, cmake_set_definitions) '''
# ordered_json, , read/write ordered json, internal
from yotta.lib import ordered_json
add_defs_header = ''
set_definitions = ''... | [
"returns",
"(",
"path_to_config_header",
"cmake_set_definitions",
")"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L329-L399 | [
"def",
"_getConfigData",
"(",
"self",
",",
"all_dependencies",
",",
"component",
",",
"builddir",
",",
"build_info_header_path",
")",
":",
"# ordered_json, , read/write ordered json, internal",
"from",
"yotta",
".",
"lib",
"import",
"ordered_json",
"add_defs_header",
"=",... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | CMakeGen.getBuildInfo | Write the build info header file, and return (path_to_written_header, set_cmake_definitions) | yotta/lib/cmakegen.py | def getBuildInfo(self, sourcedir, builddir):
''' Write the build info header file, and return (path_to_written_header, set_cmake_definitions) '''
cmake_defs = ''
preproc_defs = '// yotta build info, #include YOTTA_BUILD_INFO_HEADER to access\n'
# standard library modules
import d... | def getBuildInfo(self, sourcedir, builddir):
''' Write the build info header file, and return (path_to_written_header, set_cmake_definitions) '''
cmake_defs = ''
preproc_defs = '// yotta build info, #include YOTTA_BUILD_INFO_HEADER to access\n'
# standard library modules
import d... | [
"Write",
"the",
"build",
"info",
"header",
"file",
"and",
"return",
"(",
"path_to_written_header",
"set_cmake_definitions",
")"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L401-L461 | [
"def",
"getBuildInfo",
"(",
"self",
",",
"sourcedir",
",",
"builddir",
")",
":",
"cmake_defs",
"=",
"''",
"preproc_defs",
"=",
"'// yotta build info, #include YOTTA_BUILD_INFO_HEADER to access\\n'",
"# standard library modules",
"import",
"datetime",
"# vcs, , represent version... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | CMakeGen.generate | active_dependencies is the dictionary of components that need to be
built for this component, but will not already have been built for
another component. | yotta/lib/cmakegen.py | def generate(
self, builddir, modbuilddir, component, active_dependencies, immediate_dependencies, all_dependencies, application, toplevel
):
''' active_dependencies is the dictionary of components that need to be
built for this component, but will not already have been built for... | def generate(
self, builddir, modbuilddir, component, active_dependencies, immediate_dependencies, all_dependencies, application, toplevel
):
''' active_dependencies is the dictionary of components that need to be
built for this component, but will not already have been built for... | [
"active_dependencies",
"is",
"the",
"dictionary",
"of",
"components",
"that",
"need",
"to",
"be",
"built",
"for",
"this",
"component",
"but",
"will",
"not",
"already",
"have",
"been",
"built",
"for",
"another",
"component",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/cmakegen.py#L463-L637 | [
"def",
"generate",
"(",
"self",
",",
"builddir",
",",
"modbuilddir",
",",
"component",
",",
"active_dependencies",
",",
"immediate_dependencies",
",",
"all_dependencies",
",",
"application",
",",
"toplevel",
")",
":",
"include_root_dirs",
"=",
"''",
"if",
"applica... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _handleAuth | Decorator to re-try API calls after asking the user for authentication. | yotta/lib/github_access.py | def _handleAuth(fn):
''' Decorator to re-try API calls after asking the user for authentication. '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
# if yotta is being run noninteractively, then we never retry, but we
# do call auth.authorizeUser, so that a login URL can be displayed:
... | def _handleAuth(fn):
''' Decorator to re-try API calls after asking the user for authentication. '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
# if yotta is being run noninteractively, then we never retry, but we
# do call auth.authorizeUser, so that a login URL can be displayed:
... | [
"Decorator",
"to",
"re",
"-",
"try",
"API",
"calls",
"after",
"asking",
"the",
"user",
"for",
"authentication",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L51-L110 | [
"def",
"_handleAuth",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# if yotta is being run noninteractively, then we never retry, but we",
"# do call auth.authorizeUser, ... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _getTags | return a dictionary of {tag: tarball_url} | yotta/lib/github_access.py | def _getTags(repo):
''' return a dictionary of {tag: tarball_url}'''
logger.debug('get tags for %s', repo)
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
tags = repo.get_tags()
logger.debug('tags for %s: %s', repo, [t.name for t in tags])
return {t.name: _ens... | def _getTags(repo):
''' return a dictionary of {tag: tarball_url}'''
logger.debug('get tags for %s', repo)
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
tags = repo.get_tags()
logger.debug('tags for %s: %s', repo, [t.name for t in tags])
return {t.name: _ens... | [
"return",
"a",
"dictionary",
"of",
"{",
"tag",
":",
"tarball_url",
"}"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L113-L120 | [
"def",
"_getTags",
"(",
"repo",
")",
":",
"logger",
".",
"debug",
"(",
"'get tags for %s'",
",",
"repo",
")",
"g",
"=",
"Github",
"(",
"settings",
".",
"getProperty",
"(",
"'github'",
",",
"'authtoken'",
")",
")",
"repo",
"=",
"g",
".",
"get_repo",
"("... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _getTipArchiveURL | return a string containing a tarball url | yotta/lib/github_access.py | def _getTipArchiveURL(repo):
''' return a string containing a tarball url '''
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
return repo.get_archive_link('tarball') | def _getTipArchiveURL(repo):
''' return a string containing a tarball url '''
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
return repo.get_archive_link('tarball') | [
"return",
"a",
"string",
"containing",
"a",
"tarball",
"url"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L138-L142 | [
"def",
"_getTipArchiveURL",
"(",
"repo",
")",
":",
"g",
"=",
"Github",
"(",
"settings",
".",
"getProperty",
"(",
"'github'",
",",
"'authtoken'",
")",
")",
"repo",
"=",
"g",
".",
"get_repo",
"(",
"repo",
")",
"return",
"repo",
".",
"get_archive_link",
"("... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _getCommitArchiveURL | return a string containing a tarball url | yotta/lib/github_access.py | def _getCommitArchiveURL(repo, commit):
''' return a string containing a tarball url '''
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
return repo.get_archive_link('tarball', commit) | def _getCommitArchiveURL(repo, commit):
''' return a string containing a tarball url '''
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
return repo.get_archive_link('tarball', commit) | [
"return",
"a",
"string",
"containing",
"a",
"tarball",
"url"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L145-L149 | [
"def",
"_getCommitArchiveURL",
"(",
"repo",
",",
"commit",
")",
":",
"g",
"=",
"Github",
"(",
"settings",
".",
"getProperty",
"(",
"'github'",
",",
"'authtoken'",
")",
")",
"repo",
"=",
"g",
".",
"get_repo",
"(",
"repo",
")",
"return",
"repo",
".",
"ge... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _getTarball | unpack the specified tarball url into the specified directory | yotta/lib/github_access.py | def _getTarball(url, into_directory, cache_key, origin_info=None):
'''unpack the specified tarball url into the specified directory'''
try:
access_common.unpackFromCache(cache_key, into_directory)
except KeyError as e:
tok = settings.getProperty('github', 'authtoken')
headers = {}
... | def _getTarball(url, into_directory, cache_key, origin_info=None):
'''unpack the specified tarball url into the specified directory'''
try:
access_common.unpackFromCache(cache_key, into_directory)
except KeyError as e:
tok = settings.getProperty('github', 'authtoken')
headers = {}
... | [
"unpack",
"the",
"specified",
"tarball",
"url",
"into",
"the",
"specified",
"directory"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L152-L179 | [
"def",
"_getTarball",
"(",
"url",
",",
"into_directory",
",",
"cache_key",
",",
"origin_info",
"=",
"None",
")",
":",
"try",
":",
"access_common",
".",
"unpackFromCache",
"(",
"cache_key",
",",
"into_directory",
")",
"except",
"KeyError",
"as",
"e",
":",
"to... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | GithubComponent.createFromSource | returns a github component for any github url (including
git+ssh:// git+http:// etc. or None if this is not a Github URL.
For all of these we use the github api to grab a tarball, because
that's faster.
Normally version will be empty, unless the original url was of the
... | yotta/lib/github_access.py | def createFromSource(cls, vs, name=None):
''' returns a github component for any github url (including
git+ssh:// git+http:// etc. or None if this is not a Github URL.
For all of these we use the github api to grab a tarball, because
that's faster.
Normally versi... | def createFromSource(cls, vs, name=None):
''' returns a github component for any github url (including
git+ssh:// git+http:// etc. or None if this is not a Github URL.
For all of these we use the github api to grab a tarball, because
that's faster.
Normally versi... | [
"returns",
"a",
"github",
"component",
"for",
"any",
"github",
"url",
"(",
"including",
"git",
"+",
"ssh",
":",
"//",
"git",
"+",
"http",
":",
"//",
"etc",
".",
"or",
"None",
"if",
"this",
"is",
"not",
"a",
"Github",
"URL",
".",
"For",
"all",
"of",... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L223-L236 | [
"def",
"createFromSource",
"(",
"cls",
",",
"vs",
",",
"name",
"=",
"None",
")",
":",
"return",
"GithubComponent",
"(",
"vs",
".",
"location",
",",
"vs",
".",
"spec",
",",
"vs",
".",
"semantic_spec",
",",
"name",
")"
] | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | GithubComponent.availableVersions | return a list of Version objects, each with a tarball URL set | yotta/lib/github_access.py | def availableVersions(self):
''' return a list of Version objects, each with a tarball URL set '''
r = []
for t in self._getTags():
logger.debug("available version tag: %s", t)
# ignore empty tags:
if not len(t[0].strip()):
continue
... | def availableVersions(self):
''' return a list of Version objects, each with a tarball URL set '''
r = []
for t in self._getTags():
logger.debug("available version tag: %s", t)
# ignore empty tags:
if not len(t[0].strip()):
continue
... | [
"return",
"a",
"list",
"of",
"Version",
"objects",
"each",
"with",
"a",
"tarball",
"URL",
"set"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L254-L267 | [
"def",
"availableVersions",
"(",
"self",
")",
":",
"r",
"=",
"[",
"]",
"for",
"t",
"in",
"self",
".",
"_getTags",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"available version tag: %s\"",
",",
"t",
")",
"# ignore empty tags:",
"if",
"not",
"len",
"(",... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | GithubComponent.availableTags | return a list of GithubComponentVersion objects for all tags | yotta/lib/github_access.py | def availableTags(self):
''' return a list of GithubComponentVersion objects for all tags
'''
return [
GithubComponentVersion(
'', t[0], t[1], self.name, cache_key=_createCacheKey('tag', t[0], t[1], self.name)
) for t in self._getTags()
] | def availableTags(self):
''' return a list of GithubComponentVersion objects for all tags
'''
return [
GithubComponentVersion(
'', t[0], t[1], self.name, cache_key=_createCacheKey('tag', t[0], t[1], self.name)
) for t in self._getTags()
] | [
"return",
"a",
"list",
"of",
"GithubComponentVersion",
"objects",
"for",
"all",
"tags"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L269-L276 | [
"def",
"availableTags",
"(",
"self",
")",
":",
"return",
"[",
"GithubComponentVersion",
"(",
"''",
",",
"t",
"[",
"0",
"]",
",",
"t",
"[",
"1",
"]",
",",
"self",
".",
"name",
",",
"cache_key",
"=",
"_createCacheKey",
"(",
"'tag'",
",",
"t",
"[",
"0... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | GithubComponent.availableBranches | return a list of GithubComponentVersion objects for the tip of each branch | yotta/lib/github_access.py | def availableBranches(self):
''' return a list of GithubComponentVersion objects for the tip of each branch
'''
return [
GithubComponentVersion(
'', b[0], b[1], self.name, cache_key=None
) for b in _getBranchHeads(self.repo).items()
] | def availableBranches(self):
''' return a list of GithubComponentVersion objects for the tip of each branch
'''
return [
GithubComponentVersion(
'', b[0], b[1], self.name, cache_key=None
) for b in _getBranchHeads(self.repo).items()
] | [
"return",
"a",
"list",
"of",
"GithubComponentVersion",
"objects",
"for",
"the",
"tip",
"of",
"each",
"branch"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L278-L285 | [
"def",
"availableBranches",
"(",
"self",
")",
":",
"return",
"[",
"GithubComponentVersion",
"(",
"''",
",",
"b",
"[",
"0",
"]",
",",
"b",
"[",
"1",
"]",
",",
"self",
".",
"name",
",",
"cache_key",
"=",
"None",
")",
"for",
"b",
"in",
"_getBranchHeads"... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | GithubComponent.commitVersion | return a GithubComponentVersion object for a specific commit if valid | yotta/lib/github_access.py | def commitVersion(self):
''' return a GithubComponentVersion object for a specific commit if valid
'''
import re
commit_match = re.match('^[a-f0-9]{7,40}$', self.tagOrBranchSpec(), re.I)
if commit_match:
return GithubComponentVersion(
'', '', _getComm... | def commitVersion(self):
''' return a GithubComponentVersion object for a specific commit if valid
'''
import re
commit_match = re.match('^[a-f0-9]{7,40}$', self.tagOrBranchSpec(), re.I)
if commit_match:
return GithubComponentVersion(
'', '', _getComm... | [
"return",
"a",
"GithubComponentVersion",
"object",
"for",
"a",
"specific",
"commit",
"if",
"valid"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L292-L303 | [
"def",
"commitVersion",
"(",
"self",
")",
":",
"import",
"re",
"commit_match",
"=",
"re",
".",
"match",
"(",
"'^[a-f0-9]{7,40}$'",
",",
"self",
".",
"tagOrBranchSpec",
"(",
")",
",",
"re",
".",
"I",
")",
"if",
"commit_match",
":",
"return",
"GithubComponen... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | HGComponent.createFromSource | returns a hg component for any hg:// url, or None if this is not
a hg component.
Normally version will be empty, unless the original url was of the
form 'hg+ssh://...#version', which can be used to grab a particular
tagged version. | yotta/lib/hg_access.py | def createFromSource(cls, vs, name=None):
''' returns a hg component for any hg:// url, or None if this is not
a hg component.
Normally version will be empty, unless the original url was of the
form 'hg+ssh://...#version', which can be used to grab a particular
t... | def createFromSource(cls, vs, name=None):
''' returns a hg component for any hg:// url, or None if this is not
a hg component.
Normally version will be empty, unless the original url was of the
form 'hg+ssh://...#version', which can be used to grab a particular
t... | [
"returns",
"a",
"hg",
"component",
"for",
"any",
"hg",
":",
"//",
"url",
"or",
"None",
"if",
"this",
"is",
"not",
"a",
"hg",
"component",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/hg_access.py#L75-L88 | [
"def",
"createFromSource",
"(",
"cls",
",",
"vs",
",",
"name",
"=",
"None",
")",
":",
"# strip hg of the url scheme:",
"if",
"vs",
".",
"location",
".",
"startswith",
"(",
"'hg+'",
")",
":",
"location",
"=",
"vs",
".",
"location",
"[",
"3",
":",
"]",
"... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | dropRootPrivs | decorator to drop su/sudo privilages before running a function on
unix/linux.
The *real* uid is modified, so privileges are permanently dropped for
the process. (i.e. make sure you don't need to do
If there is a SUDO_UID environment variable, then we drop to that,
otherwise we d... | yotta/lib/fsutils_posix.py | def dropRootPrivs(fn):
''' decorator to drop su/sudo privilages before running a function on
unix/linux.
The *real* uid is modified, so privileges are permanently dropped for
the process. (i.e. make sure you don't need to do
If there is a SUDO_UID environment variable, then we drop ... | def dropRootPrivs(fn):
''' decorator to drop su/sudo privilages before running a function on
unix/linux.
The *real* uid is modified, so privileges are permanently dropped for
the process. (i.e. make sure you don't need to do
If there is a SUDO_UID environment variable, then we drop ... | [
"decorator",
"to",
"drop",
"su",
"/",
"sudo",
"privilages",
"before",
"running",
"a",
"function",
"on",
"unix",
"/",
"linux",
".",
"The",
"*",
"real",
"*",
"uid",
"is",
"modified",
"so",
"privileges",
"are",
"permanently",
"dropped",
"for",
"the",
"process... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/fsutils_posix.py#L46-L75 | [
"def",
"dropRootPrivs",
"(",
"fn",
")",
":",
"def",
"wrapped_fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"q",
"=",
"multiprocessing",
".",
"Queue",
"(",
")",
"p",
"=",
"multiprocessing",
".",
"Process",
"(",
"target",
"=",
"_dropPrivsRetu... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | installAndBuild | Perform the build command, but provide detailed error information.
Returns {status:0, build_status:0, generate_status:0, install_status:0} on success.
If status: is nonzero there was some sort of error. Other properties
are optional, and may not be set if that step was not attempted. | yotta/build.py | def installAndBuild(args, following_args):
''' Perform the build command, but provide detailed error information.
Returns {status:0, build_status:0, generate_status:0, install_status:0} on success.
If status: is nonzero there was some sort of error. Other properties
are optional, and may not... | def installAndBuild(args, following_args):
''' Perform the build command, but provide detailed error information.
Returns {status:0, build_status:0, generate_status:0, install_status:0} on success.
If status: is nonzero there was some sort of error. Other properties
are optional, and may not... | [
"Perform",
"the",
"build",
"command",
"but",
"provide",
"detailed",
"error",
"information",
".",
"Returns",
"{",
"status",
":",
"0",
"build_status",
":",
"0",
"generate_status",
":",
"0",
"install_status",
":",
"0",
"}",
"on",
"success",
".",
"If",
"status",... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/build.py#L54-L170 | [
"def",
"installAndBuild",
"(",
"args",
",",
"following_args",
")",
":",
"build_status",
"=",
"generate_status",
"=",
"install_status",
"=",
"0",
"if",
"not",
"hasattr",
"(",
"args",
",",
"'build_targets'",
")",
":",
"vars",
"(",
"args",
")",
"[",
"'build_tar... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _returnRequestError | Decorator that captures requests.exceptions.RequestException errors
and returns them as an error message. If no error occurs the reture
value of the wrapped function is returned (normally None). | yotta/lib/registry_access.py | def _returnRequestError(fn):
''' Decorator that captures requests.exceptions.RequestException errors
and returns them as an error message. If no error occurs the reture
value of the wrapped function is returned (normally None). '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
t... | def _returnRequestError(fn):
''' Decorator that captures requests.exceptions.RequestException errors
and returns them as an error message. If no error occurs the reture
value of the wrapped function is returned (normally None). '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
t... | [
"Decorator",
"that",
"captures",
"requests",
".",
"exceptions",
".",
"RequestException",
"errors",
"and",
"returns",
"them",
"as",
"an",
"error",
"message",
".",
"If",
"no",
"error",
"occurs",
"the",
"reture",
"value",
"of",
"the",
"wrapped",
"function",
"is",... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L127-L137 | [
"def",
"_returnRequestError",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _handleAuth | Decorator to re-try API calls after asking the user for authentication. | yotta/lib/registry_access.py | def _handleAuth(fn):
''' Decorator to re-try API calls after asking the user for authentication. '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
# auth, , authenticate users, internal
from yotta.lib import auth
# if yotta is being run noninteractively, then we never retry, but... | def _handleAuth(fn):
''' Decorator to re-try API calls after asking the user for authentication. '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
# auth, , authenticate users, internal
from yotta.lib import auth
# if yotta is being run noninteractively, then we never retry, but... | [
"Decorator",
"to",
"re",
"-",
"try",
"API",
"calls",
"after",
"asking",
"the",
"user",
"for",
"authentication",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L139-L159 | [
"def",
"_handleAuth",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# auth, , authenticate users, internal",
"from",
"yotta",
".",
"lib",
"import",
"auth",
"# ... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _friendlyAuthError | Decorator to print a friendly you-are-not-authorised message. Use
**outside** the _handleAuth decorator to only print the message after
the user has been given a chance to login. | yotta/lib/registry_access.py | def _friendlyAuthError(fn):
''' Decorator to print a friendly you-are-not-authorised message. Use
**outside** the _handleAuth decorator to only print the message after
the user has been given a chance to login. '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
try:
r... | def _friendlyAuthError(fn):
''' Decorator to print a friendly you-are-not-authorised message. Use
**outside** the _handleAuth decorator to only print the message after
the user has been given a chance to login. '''
@functools.wraps(fn)
def wrapped(*args, **kwargs):
try:
r... | [
"Decorator",
"to",
"print",
"a",
"friendly",
"you",
"-",
"are",
"-",
"not",
"-",
"authorised",
"message",
".",
"Use",
"**",
"outside",
"**",
"the",
"_handleAuth",
"decorator",
"to",
"only",
"print",
"the",
"message",
"after",
"the",
"user",
"has",
"been",
... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L161-L178 | [
"def",
"_friendlyAuthError",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | _raiseUnavailableFor401 | Returns a decorator to swallow a requests exception for modules that
are not accessible without logging in, and turn it into an Unavailable
exception. | yotta/lib/registry_access.py | def _raiseUnavailableFor401(message):
''' Returns a decorator to swallow a requests exception for modules that
are not accessible without logging in, and turn it into an Unavailable
exception.
'''
def __raiseUnavailableFor401(fn):
def wrapped(*args, **kwargs):
try:
... | def _raiseUnavailableFor401(message):
''' Returns a decorator to swallow a requests exception for modules that
are not accessible without logging in, and turn it into an Unavailable
exception.
'''
def __raiseUnavailableFor401(fn):
def wrapped(*args, **kwargs):
try:
... | [
"Returns",
"a",
"decorator",
"to",
"swallow",
"a",
"requests",
"exception",
"for",
"modules",
"that",
"are",
"not",
"accessible",
"without",
"logging",
"in",
"and",
"turn",
"it",
"into",
"an",
"Unavailable",
"exception",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L180-L195 | [
"def",
"_raiseUnavailableFor401",
"(",
"message",
")",
":",
"def",
"__raiseUnavailableFor401",
"(",
"fn",
")",
":",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"k... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | publish | Publish a tarblob to the registry, if the request fails, an exception
is raised, which either triggers re-authentication, or is turned into a
return value by the decorators. (If successful, the decorated function
returns None) | yotta/lib/registry_access.py | def publish(namespace, name, version, description_file, tar_file, readme_file,
readme_file_ext, registry=None):
''' Publish a tarblob to the registry, if the request fails, an exception
is raised, which either triggers re-authentication, or is turned into a
return value by the decorators... | def publish(namespace, name, version, description_file, tar_file, readme_file,
readme_file_ext, registry=None):
''' Publish a tarblob to the registry, if the request fails, an exception
is raised, which either triggers re-authentication, or is turned into a
return value by the decorators... | [
"Publish",
"a",
"tarblob",
"to",
"the",
"registry",
"if",
"the",
"request",
"fails",
"an",
"exception",
"is",
"raised",
"which",
"either",
"triggers",
"re",
"-",
"authentication",
"or",
"is",
"turned",
"into",
"a",
"return",
"value",
"by",
"the",
"decorators... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L497-L530 | [
"def",
"publish",
"(",
"namespace",
",",
"name",
",",
"version",
",",
"description_file",
",",
"tar_file",
",",
"readme_file",
",",
"readme_file_ext",
",",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"url",
"=",
... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | unpublish | Try to unpublish a recently published version. Return any errors that
occur. | yotta/lib/registry_access.py | def unpublish(namespace, name, version, registry=None):
''' Try to unpublish a recently published version. Return any errors that
occur.
'''
registry = registry or Registry_Base_URL
url = '%s/%s/%s/versions/%s' % (
registry,
namespace,
name,
version
)
he... | def unpublish(namespace, name, version, registry=None):
''' Try to unpublish a recently published version. Return any errors that
occur.
'''
registry = registry or Registry_Base_URL
url = '%s/%s/%s/versions/%s' % (
registry,
namespace,
name,
version
)
he... | [
"Try",
"to",
"unpublish",
"a",
"recently",
"published",
"version",
".",
"Return",
"any",
"errors",
"that",
"occur",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L536-L553 | [
"def",
"unpublish",
"(",
"namespace",
",",
"name",
",",
"version",
",",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"url",
"=",
"'%s/%s/%s/versions/%s'",
"%",
"(",
"registry",
",",
"namespace",
",",
"name",
",",... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | listOwners | List the owners of a module or target (owners are the people with
permission to publish versions and add/remove the owners). | yotta/lib/registry_access.py | def listOwners(namespace, name, registry=None):
''' List the owners of a module or target (owners are the people with
permission to publish versions and add/remove the owners).
'''
registry = registry or Registry_Base_URL
url = '%s/%s/%s/owners' % (
registry,
namespace,
... | def listOwners(namespace, name, registry=None):
''' List the owners of a module or target (owners are the people with
permission to publish versions and add/remove the owners).
'''
registry = registry or Registry_Base_URL
url = '%s/%s/%s/owners' % (
registry,
namespace,
... | [
"List",
"the",
"owners",
"of",
"a",
"module",
"or",
"target",
"(",
"owners",
"are",
"the",
"people",
"with",
"permission",
"to",
"publish",
"versions",
"and",
"add",
"/",
"remove",
"the",
"owners",
")",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L559-L583 | [
"def",
"listOwners",
"(",
"namespace",
",",
"name",
",",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"url",
"=",
"'%s/%s/%s/owners'",
"%",
"(",
"registry",
",",
"namespace",
",",
"name",
")",
"request_headers",
... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | removeOwner | Remove an owner for a module or target (owners are the people with
permission to publish versions and add/remove the owners). | yotta/lib/registry_access.py | def removeOwner(namespace, name, owner, registry=None):
''' Remove an owner for a module or target (owners are the people with
permission to publish versions and add/remove the owners).
'''
registry = registry or Registry_Base_URL
url = '%s/%s/%s/owners/%s' % (
registry,
namespa... | def removeOwner(namespace, name, owner, registry=None):
''' Remove an owner for a module or target (owners are the people with
permission to publish versions and add/remove the owners).
'''
registry = registry or Registry_Base_URL
url = '%s/%s/%s/owners/%s' % (
registry,
namespa... | [
"Remove",
"an",
"owner",
"for",
"a",
"module",
"or",
"target",
"(",
"owners",
"are",
"the",
"people",
"with",
"permission",
"to",
"publish",
"versions",
"and",
"add",
"/",
"remove",
"the",
"owners",
")",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L621-L646 | [
"def",
"removeOwner",
"(",
"namespace",
",",
"name",
",",
"owner",
",",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"url",
"=",
"'%s/%s/%s/owners/%s'",
"%",
"(",
"registry",
",",
"namespace",
",",
"name",
",",
... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | search | generator of objects returned by the search endpoint (both modules and
targets).
Query is a full-text search (description, name, keywords), keywords
search only the module/target description keywords lists.
If both parameters are specified the search is the intersection of the
... | yotta/lib/registry_access.py | def search(query='', keywords=[], registry=None):
''' generator of objects returned by the search endpoint (both modules and
targets).
Query is a full-text search (description, name, keywords), keywords
search only the module/target description keywords lists.
If both parameters ar... | def search(query='', keywords=[], registry=None):
''' generator of objects returned by the search endpoint (both modules and
targets).
Query is a full-text search (description, name, keywords), keywords
search only the module/target description keywords lists.
If both parameters ar... | [
"generator",
"of",
"objects",
"returned",
"by",
"the",
"search",
"endpoint",
"(",
"both",
"modules",
"and",
"targets",
")",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L668-L702 | [
"def",
"search",
"(",
"query",
"=",
"''",
",",
"keywords",
"=",
"[",
"]",
",",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"url",
"=",
"'%s/search'",
"%",
"registry",
"headers",
"=",
"_headersForRegistry",
"("... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | setAPIKey | Set the api key for accessing a registry. This is only necessary for
development/test registries. | yotta/lib/registry_access.py | def setAPIKey(registry, api_key):
''' Set the api key for accessing a registry. This is only necessary for
development/test registries.
'''
if (registry is None) or (registry == Registry_Base_URL):
return
sources = _getSources()
source = None
for s in sources:
if _sourceM... | def setAPIKey(registry, api_key):
''' Set the api key for accessing a registry. This is only necessary for
development/test registries.
'''
if (registry is None) or (registry == Registry_Base_URL):
return
sources = _getSources()
source = None
for s in sources:
if _sourceM... | [
"Set",
"the",
"api",
"key",
"for",
"accessing",
"a",
"registry",
".",
"This",
"is",
"only",
"necessary",
"for",
"development",
"/",
"test",
"registries",
"."
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L714-L732 | [
"def",
"setAPIKey",
"(",
"registry",
",",
"api_key",
")",
":",
"if",
"(",
"registry",
"is",
"None",
")",
"or",
"(",
"registry",
"==",
"Registry_Base_URL",
")",
":",
"return",
"sources",
"=",
"_getSources",
"(",
")",
"source",
"=",
"None",
"for",
"s",
"... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | getPublicKey | Return the user's public key (generating and saving a new key pair if necessary) | yotta/lib/registry_access.py | def getPublicKey(registry=None):
''' Return the user's public key (generating and saving a new key pair if necessary) '''
registry = registry or Registry_Base_URL
pubkey_pem = None
if _isPublicRegistry(registry):
pubkey_pem = settings.getProperty('keys', 'public')
else:
for s in _get... | def getPublicKey(registry=None):
''' Return the user's public key (generating and saving a new key pair if necessary) '''
registry = registry or Registry_Base_URL
pubkey_pem = None
if _isPublicRegistry(registry):
pubkey_pem = settings.getProperty('keys', 'public')
else:
for s in _get... | [
"Return",
"the",
"user",
"s",
"public",
"key",
"(",
"generating",
"and",
"saving",
"a",
"new",
"key",
"pair",
"if",
"necessary",
")"
] | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L735-L760 | [
"def",
"getPublicKey",
"(",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"pubkey_pem",
"=",
"None",
"if",
"_isPublicRegistry",
"(",
"registry",
")",
":",
"pubkey_pem",
"=",
"settings",
".",
"getProperty",
"(",
"'ke... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
valid | getAuthData | Poll the registry to get the result of a completed authentication
(which, depending on the authentication the user chose or was directed
to, will include a github or other access token) | yotta/lib/registry_access.py | def getAuthData(registry=None):
''' Poll the registry to get the result of a completed authentication
(which, depending on the authentication the user chose or was directed
to, will include a github or other access token)
'''
registry = registry or Registry_Base_URL
url = '%s/tokens' % (... | def getAuthData(registry=None):
''' Poll the registry to get the result of a completed authentication
(which, depending on the authentication the user chose or was directed
to, will include a github or other access token)
'''
registry = registry or Registry_Base_URL
url = '%s/tokens' % (... | [
"Poll",
"the",
"registry",
"to",
"get",
"the",
"result",
"of",
"a",
"completed",
"authentication",
"(",
"which",
"depending",
"on",
"the",
"authentication",
"the",
"user",
"chose",
"or",
"was",
"directed",
"to",
"will",
"include",
"a",
"github",
"or",
"other... | ARMmbed/yotta | python | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/registry_access.py#L763-L805 | [
"def",
"getAuthData",
"(",
"registry",
"=",
"None",
")",
":",
"registry",
"=",
"registry",
"or",
"Registry_Base_URL",
"url",
"=",
"'%s/tokens'",
"%",
"(",
"registry",
")",
"request_headers",
"=",
"_headersForRegistry",
"(",
"registry",
")",
"logger",
".",
"deb... | 56bc1e56c602fa20307b23fe27518e9cd6c11af1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.