repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
kxgames/vecrec
vecrec/shapes.py
Vector.get_radians
def get_radians(self): """ Return the angle between this vector and the positive x-axis measured in radians. Result will be between -pi and pi. """ if not self: raise NullVectorError() return math.atan2(self.y, self.x)
python
def get_radians(self): """ Return the angle between this vector and the positive x-axis measured in radians. Result will be between -pi and pi. """ if not self: raise NullVectorError() return math.atan2(self.y, self.x)
[ "def", "get_radians", "(", "self", ")", ":", "if", "not", "self", ":", "raise", "NullVectorError", "(", ")", "return", "math", ".", "atan2", "(", "self", ".", "y", ",", "self", ".", "x", ")" ]
Return the angle between this vector and the positive x-axis measured in radians. Result will be between -pi and pi.
[ "Return", "the", "angle", "between", "this", "vector", "and", "the", "positive", "x", "-", "axis", "measured", "in", "radians", ".", "Result", "will", "be", "between", "-", "pi", "and", "pi", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L440-L444
kxgames/vecrec
vecrec/shapes.py
Vector.get_rotated
def get_rotated(self, angle): """ Return a vector rotated by angle from the given vector. Angle measured in radians counter-clockwise. """ result = self.copy() result.rotate(angle) return result
python
def get_rotated(self, angle): """ Return a vector rotated by angle from the given vector. Angle measured in radians counter-clockwise. """ result = self.copy() result.rotate(angle) return result
[ "def", "get_rotated", "(", "self", ",", "angle", ")", ":", "result", "=", "self", ".", "copy", "(", ")", "result", ".", "rotate", "(", "angle", ")", "return", "result" ]
Return a vector rotated by angle from the given vector. Angle measured in radians counter-clockwise.
[ "Return", "a", "vector", "rotated", "by", "angle", "from", "the", "given", "vector", ".", "Angle", "measured", "in", "radians", "counter", "-", "clockwise", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L468-L472
kxgames/vecrec
vecrec/shapes.py
Vector.get_rounded
def get_rounded(self, digits): """ Return a vector with the elements rounded to the given number of digits. """ result = self.copy() result.round(digits) return result
python
def get_rounded(self, digits): """ Return a vector with the elements rounded to the given number of digits. """ result = self.copy() result.round(digits) return result
[ "def", "get_rounded", "(", "self", ",", "digits", ")", ":", "result", "=", "self", ".", "copy", "(", ")", "result", ".", "round", "(", "digits", ")", "return", "result" ]
Return a vector with the elements rounded to the given number of digits.
[ "Return", "a", "vector", "with", "the", "elements", "rounded", "to", "the", "given", "number", "of", "digits", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L474-L478
kxgames/vecrec
vecrec/shapes.py
Vector.set_radians
def set_radians(self, angle): """ Set the angle that this vector makes with the x-axis. """ self.x, self.y = math.cos(angle), math.sin(angle)
python
def set_radians(self, angle): """ Set the angle that this vector makes with the x-axis. """ self.x, self.y = math.cos(angle), math.sin(angle)
[ "def", "set_radians", "(", "self", ",", "angle", ")", ":", "self", ".", "x", ",", "self", ".", "y", "=", "math", ".", "cos", "(", "angle", ")", ",", "math", ".", "sin", "(", "angle", ")" ]
Set the angle that this vector makes with the x-axis.
[ "Set", "the", "angle", "that", "this", "vector", "makes", "with", "the", "x", "-", "axis", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L496-L498
kxgames/vecrec
vecrec/shapes.py
Rectangle.grow
def grow(self, *padding): """ Grow this rectangle by the given padding on all sides. """ try: lpad, rpad, tpad, bpad = padding except ValueError: lpad = rpad = tpad = bpad = padding[0] self._bottom -= bpad self._left -= lpad self._width += lpad + ...
python
def grow(self, *padding): """ Grow this rectangle by the given padding on all sides. """ try: lpad, rpad, tpad, bpad = padding except ValueError: lpad = rpad = tpad = bpad = padding[0] self._bottom -= bpad self._left -= lpad self._width += lpad + ...
[ "def", "grow", "(", "self", ",", "*", "padding", ")", ":", "try", ":", "lpad", ",", "rpad", ",", "tpad", ",", "bpad", "=", "padding", "except", "ValueError", ":", "lpad", "=", "rpad", "=", "tpad", "=", "bpad", "=", "padding", "[", "0", "]", "self...
Grow this rectangle by the given padding on all sides.
[ "Grow", "this", "rectangle", "by", "the", "given", "padding", "on", "all", "sides", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L676-L687
kxgames/vecrec
vecrec/shapes.py
Rectangle.displace
def displace(self, vector): """ Displace this rectangle by the given vector. """ self._bottom += vector.y self._left += vector.x return self
python
def displace(self, vector): """ Displace this rectangle by the given vector. """ self._bottom += vector.y self._left += vector.x return self
[ "def", "displace", "(", "self", ",", "vector", ")", ":", "self", ".", "_bottom", "+=", "vector", ".", "y", "self", ".", "_left", "+=", "vector", ".", "x", "return", "self" ]
Displace this rectangle by the given vector.
[ "Displace", "this", "rectangle", "by", "the", "given", "vector", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L703-L707
kxgames/vecrec
vecrec/shapes.py
Rectangle.round
def round(self, digits=0): """ Round the dimensions of the given rectangle to the given number of digits. """ self._left = round(self._left, digits) self._bottom = round(self._bottom, digits) self._width = round(self._width, digits) self._height = round(self._height, digits)
python
def round(self, digits=0): """ Round the dimensions of the given rectangle to the given number of digits. """ self._left = round(self._left, digits) self._bottom = round(self._bottom, digits) self._width = round(self._width, digits) self._height = round(self._height, digits)
[ "def", "round", "(", "self", ",", "digits", "=", "0", ")", ":", "self", ".", "_left", "=", "round", "(", "self", ".", "_left", ",", "digits", ")", "self", ".", "_bottom", "=", "round", "(", "self", ".", "_bottom", ",", "digits", ")", "self", ".",...
Round the dimensions of the given rectangle to the given number of digits.
[ "Round", "the", "dimensions", "of", "the", "given", "rectangle", "to", "the", "given", "number", "of", "digits", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L709-L714
kxgames/vecrec
vecrec/shapes.py
Rectangle.set
def set(self, shape): """ Fill this rectangle with the dimensions of the given shape. """ self.bottom, self.left = shape.bottom, shape.left self.width, self.height = shape.width, shape.height return self
python
def set(self, shape): """ Fill this rectangle with the dimensions of the given shape. """ self.bottom, self.left = shape.bottom, shape.left self.width, self.height = shape.width, shape.height return self
[ "def", "set", "(", "self", ",", "shape", ")", ":", "self", ".", "bottom", ",", "self", ".", "left", "=", "shape", ".", "bottom", ",", "shape", ".", "left", "self", ".", "width", ",", "self", ".", "height", "=", "shape", ".", "width", ",", "shape"...
Fill this rectangle with the dimensions of the given shape.
[ "Fill", "this", "rectangle", "with", "the", "dimensions", "of", "the", "given", "shape", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L716-L720
kxgames/vecrec
vecrec/shapes.py
Rectangle.inside
def inside(self, other): """ Return true if this rectangle is inside the given shape. """ return ( self.left >= other.left and self.right <= other.right and self.top <= other.top and self.bottom >= other.bottom)
python
def inside(self, other): """ Return true if this rectangle is inside the given shape. """ return ( self.left >= other.left and self.right <= other.right and self.top <= other.top and self.bottom >= other.bottom)
[ "def", "inside", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "left", ">=", "other", ".", "left", "and", "self", ".", "right", "<=", "other", ".", "right", "and", "self", ".", "top", "<=", "other", ".", "top", "and", "self", "...
Return true if this rectangle is inside the given shape.
[ "Return", "true", "if", "this", "rectangle", "is", "inside", "the", "given", "shape", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L729-L734
kxgames/vecrec
vecrec/shapes.py
Rectangle.touching
def touching(self, other): """ Return true if this rectangle is touching the given shape. """ if self.top < other.bottom: return False if self.bottom > other.top: return False if self.left > other.right: return False if self.right < other.left: return False return True
python
def touching(self, other): """ Return true if this rectangle is touching the given shape. """ if self.top < other.bottom: return False if self.bottom > other.top: return False if self.left > other.right: return False if self.right < other.left: return False return True
[ "def", "touching", "(", "self", ",", "other", ")", ":", "if", "self", ".", "top", "<", "other", ".", "bottom", ":", "return", "False", "if", "self", ".", "bottom", ">", "other", ".", "top", ":", "return", "False", "if", "self", ".", "left", ">", ...
Return true if this rectangle is touching the given shape.
[ "Return", "true", "if", "this", "rectangle", "is", "touching", "the", "given", "shape", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L742-L750
kxgames/vecrec
vecrec/shapes.py
Rectangle.contains
def contains(self, other): """ Return true if the given shape is inside this rectangle. """ return (self.left <= other.left and self.right >= other.right and self.top >= other.top and self.bottom <= other.bottom)
python
def contains(self, other): """ Return true if the given shape is inside this rectangle. """ return (self.left <= other.left and self.right >= other.right and self.top >= other.top and self.bottom <= other.bottom)
[ "def", "contains", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "left", "<=", "other", ".", "left", "and", "self", ".", "right", ">=", "other", ".", "right", "and", "self", ".", "top", ">=", "other", ".", "top", "and", "self", ...
Return true if the given shape is inside this rectangle.
[ "Return", "true", "if", "the", "given", "shape", "is", "inside", "this", "rectangle", "." ]
train
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L753-L758
treycucco/bidon
bidon/experimental/finite_state_machine.py
FiniteStateMachine._handle_node
def _handle_node(self, data): """Given a piece of data, check each node_type that the last_node_type can lead to and act using the first whose checker returns true. """ next_options = self.graph[self.last_node_type] for node_type in next_options: checker, handler, *_ = node_type if check...
python
def _handle_node(self, data): """Given a piece of data, check each node_type that the last_node_type can lead to and act using the first whose checker returns true. """ next_options = self.graph[self.last_node_type] for node_type in next_options: checker, handler, *_ = node_type if check...
[ "def", "_handle_node", "(", "self", ",", "data", ")", ":", "next_options", "=", "self", ".", "graph", "[", "self", ".", "last_node_type", "]", "for", "node_type", "in", "next_options", ":", "checker", ",", "handler", ",", "", "*", "_", "=", "node_type", ...
Given a piece of data, check each node_type that the last_node_type can lead to and act using the first whose checker returns true.
[ "Given", "a", "piece", "of", "data", "check", "each", "node_type", "that", "the", "last_node_type", "can", "lead", "to", "and", "act", "using", "the", "first", "whose", "checker", "returns", "true", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/finite_state_machine.py#L25-L36
treycucco/bidon
bidon/experimental/finite_state_machine.py
FiniteStateMachine.parse
def parse(self, nodes): """Given a stream of node data, try to parse the nodes according to the machine's graph.""" self.last_node_type = self.initial_node_type for node_number, node in enumerate(nodes): try: self.step(node) except Exception as ex: raise Exception("An error occur...
python
def parse(self, nodes): """Given a stream of node data, try to parse the nodes according to the machine's graph.""" self.last_node_type = self.initial_node_type for node_number, node in enumerate(nodes): try: self.step(node) except Exception as ex: raise Exception("An error occur...
[ "def", "parse", "(", "self", ",", "nodes", ")", ":", "self", ".", "last_node_type", "=", "self", ".", "initial_node_type", "for", "node_number", ",", "node", "in", "enumerate", "(", "nodes", ")", ":", "try", ":", "self", ".", "step", "(", "node", ")", ...
Given a stream of node data, try to parse the nodes according to the machine's graph.
[ "Given", "a", "stream", "of", "node", "data", "try", "to", "parse", "the", "nodes", "according", "to", "the", "machine", "s", "graph", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/finite_state_machine.py#L42-L49
limpyd/redis-limpyd-extensions
limpyd_extensions/dynamic/related.py
DynamicRelatedFieldMixin.get_name_for
def get_name_for(self, dynamic_part): """ Return the name for the current dynamic field, accepting a limpyd instance for the dynamic part """ dynamic_part = self.from_python(dynamic_part) return super(DynamicRelatedFieldMixin, self).get_name_for(dynamic_part)
python
def get_name_for(self, dynamic_part): """ Return the name for the current dynamic field, accepting a limpyd instance for the dynamic part """ dynamic_part = self.from_python(dynamic_part) return super(DynamicRelatedFieldMixin, self).get_name_for(dynamic_part)
[ "def", "get_name_for", "(", "self", ",", "dynamic_part", ")", ":", "dynamic_part", "=", "self", ".", "from_python", "(", "dynamic_part", ")", "return", "super", "(", "DynamicRelatedFieldMixin", ",", "self", ")", ".", "get_name_for", "(", "dynamic_part", ")" ]
Return the name for the current dynamic field, accepting a limpyd instance for the dynamic part
[ "Return", "the", "name", "for", "the", "current", "dynamic", "field", "accepting", "a", "limpyd", "instance", "for", "the", "dynamic", "part" ]
train
https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/related.py#L67-L73
etcher-be/elib_config
elib_config/_value/_config_value_toml.py
ConfigValueTOML.add_to_toml_obj
def add_to_toml_obj(self, toml_obj: tomlkit.container.Container, not_set: str): """ Updates the given container in-place with this ConfigValue :param toml_obj: container to update :type toml_obj: tomlkit.container.Containers :param not_set: random UUID used to denote a value tha...
python
def add_to_toml_obj(self, toml_obj: tomlkit.container.Container, not_set: str): """ Updates the given container in-place with this ConfigValue :param toml_obj: container to update :type toml_obj: tomlkit.container.Containers :param not_set: random UUID used to denote a value tha...
[ "def", "add_to_toml_obj", "(", "self", ",", "toml_obj", ":", "tomlkit", ".", "container", ".", "Container", ",", "not_set", ":", "str", ")", ":", "self", ".", "_toml_add_description", "(", "toml_obj", ")", "self", ".", "_toml_add_value_type", "(", "toml_obj", ...
Updates the given container in-place with this ConfigValue :param toml_obj: container to update :type toml_obj: tomlkit.container.Containers :param not_set: random UUID used to denote a value that has no default :type not_set: str
[ "Updates", "the", "given", "container", "in", "-", "place", "with", "this", "ConfigValue" ]
train
https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_value/_config_value_toml.py#L78-L91
ulf1/oxyba
oxyba/jackknife_stats.py
jackknife_stats
def jackknife_stats(theta_subs, theta_full, N=None, d=1): """Compute Jackknife Estimates, SE, Bias, t-scores, p-values Parameters: ----------- theta_subs : ndarray The metrics, estimates, parameters, etc. of the model (see "func") for each subsample. It is a <C x M> matrix, i.e....
python
def jackknife_stats(theta_subs, theta_full, N=None, d=1): """Compute Jackknife Estimates, SE, Bias, t-scores, p-values Parameters: ----------- theta_subs : ndarray The metrics, estimates, parameters, etc. of the model (see "func") for each subsample. It is a <C x M> matrix, i.e....
[ "def", "jackknife_stats", "(", "theta_subs", ",", "theta_full", ",", "N", "=", "None", ",", "d", "=", "1", ")", ":", "# The biased Jackknife Estimate", "import", "numpy", "as", "np", "theta_biased", "=", "np", ".", "mean", "(", "theta_subs", ",", "axis", "...
Compute Jackknife Estimates, SE, Bias, t-scores, p-values Parameters: ----------- theta_subs : ndarray The metrics, estimates, parameters, etc. of the model (see "func") for each subsample. It is a <C x M> matrix, i.e. C=binocoeff(N,d) subsamples, and M parameters that are r...
[ "Compute", "Jackknife", "Estimates", "SE", "Bias", "t", "-", "scores", "p", "-", "values" ]
train
https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/jackknife_stats.py#L1-L105
autonimo/autonimo
autonimo/ctrls/task_ctrl.py
TaskController.import_tasks
def import_tasks(self, path): """ Attempts to load tasks from a given path. :param path: Path to tasks. :return: None. """ for zz in os.walk(path): for module in zz[2]: if module.endswith('.py'): import importlib ...
python
def import_tasks(self, path): """ Attempts to load tasks from a given path. :param path: Path to tasks. :return: None. """ for zz in os.walk(path): for module in zz[2]: if module.endswith('.py'): import importlib ...
[ "def", "import_tasks", "(", "self", ",", "path", ")", ":", "for", "zz", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "module", "in", "zz", "[", "2", "]", ":", "if", "module", ".", "endswith", "(", "'.py'", ")", ":", "import", "importlib...
Attempts to load tasks from a given path. :param path: Path to tasks. :return: None.
[ "Attempts", "to", "load", "tasks", "from", "a", "given", "path", ".", ":", "param", "path", ":", "Path", "to", "tasks", ".", ":", "return", ":", "None", "." ]
train
https://github.com/autonimo/autonimo/blob/72acfe05cc08207442317794f6c3afbbf077be58/autonimo/ctrls/task_ctrl.py#L66-L85
tylerbutler/propane
propane/strings.py
space_out_camel_case
def space_out_camel_case(stringAsCamelCase): """ Adds spaces to a camel case string. Failure to space out string returns the original string. >>> space_out_camel_case('DMLSServicesOtherBSTextLLC') 'DMLS Services Other BS Text LLC' """ pattern = re.compile(r'([A-Z][A-Z][a-z])|([a-z][A-Z])') ...
python
def space_out_camel_case(stringAsCamelCase): """ Adds spaces to a camel case string. Failure to space out string returns the original string. >>> space_out_camel_case('DMLSServicesOtherBSTextLLC') 'DMLS Services Other BS Text LLC' """ pattern = re.compile(r'([A-Z][A-Z][a-z])|([a-z][A-Z])') ...
[ "def", "space_out_camel_case", "(", "stringAsCamelCase", ")", ":", "pattern", "=", "re", ".", "compile", "(", "r'([A-Z][A-Z][a-z])|([a-z][A-Z])'", ")", "if", "stringAsCamelCase", "is", "None", ":", "return", "None", "return", "pattern", ".", "sub", "(", "lambda", ...
Adds spaces to a camel case string. Failure to space out string returns the original string. >>> space_out_camel_case('DMLSServicesOtherBSTextLLC') 'DMLS Services Other BS Text LLC'
[ "Adds", "spaces", "to", "a", "camel", "case", "string", ".", "Failure", "to", "space", "out", "string", "returns", "the", "original", "string", "." ]
train
https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/strings.py#L9-L21
tylerbutler/propane
propane/strings.py
slugify
def slugify(text, length_limit=0, delimiter=u'-'): """Generates an ASCII-only slug of a string.""" result = [] for word in _punctuation_regex.split(text.lower()): word = _available_unicode_handlers[0](word) if word: result.append(word) slug = delimiter.join(result) if len...
python
def slugify(text, length_limit=0, delimiter=u'-'): """Generates an ASCII-only slug of a string.""" result = [] for word in _punctuation_regex.split(text.lower()): word = _available_unicode_handlers[0](word) if word: result.append(word) slug = delimiter.join(result) if len...
[ "def", "slugify", "(", "text", ",", "length_limit", "=", "0", ",", "delimiter", "=", "u'-'", ")", ":", "result", "=", "[", "]", "for", "word", "in", "_punctuation_regex", ".", "split", "(", "text", ".", "lower", "(", ")", ")", ":", "word", "=", "_a...
Generates an ASCII-only slug of a string.
[ "Generates", "an", "ASCII", "-", "only", "slug", "of", "a", "string", "." ]
train
https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/strings.py#L60-L70
russell/pygments-cl-repl
pygments_cl_repl/__init__.py
sexp_reader.read
def read(self, stream): """ Will parse the stream until a complete sexp has been read. Returns True until state is complete. """ stack = self.stack while True: if stack[0]: # will be true once one sexp has been parsed self.rest_string = stream...
python
def read(self, stream): """ Will parse the stream until a complete sexp has been read. Returns True until state is complete. """ stack = self.stack while True: if stack[0]: # will be true once one sexp has been parsed self.rest_string = stream...
[ "def", "read", "(", "self", ",", "stream", ")", ":", "stack", "=", "self", ".", "stack", "while", "True", ":", "if", "stack", "[", "0", "]", ":", "# will be true once one sexp has been parsed", "self", ".", "rest_string", "=", "stream", "return", "False", ...
Will parse the stream until a complete sexp has been read. Returns True until state is complete.
[ "Will", "parse", "the", "stream", "until", "a", "complete", "sexp", "has", "been", "read", ".", "Returns", "True", "until", "state", "is", "complete", "." ]
train
https://github.com/russell/pygments-cl-repl/blob/dff6e3ff0017b934b56f76cd54d48a6e55a52550/pygments_cl_repl/__init__.py#L26-L66
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/filters/aleph_filter.py
name_to_vector
def name_to_vector(name): """ Convert `name` to the ASCII vector. Example: >>> name_to_vector("ing. Franta Putšálek") ['putsalek', 'franta', 'ing'] Args: name (str): Name which will be vectorized. Returns: list: Vector created from name. """ if not isinstan...
python
def name_to_vector(name): """ Convert `name` to the ASCII vector. Example: >>> name_to_vector("ing. Franta Putšálek") ['putsalek', 'franta', 'ing'] Args: name (str): Name which will be vectorized. Returns: list: Vector created from name. """ if not isinstan...
[ "def", "name_to_vector", "(", "name", ")", ":", "if", "not", "isinstance", "(", "name", ",", "unicode", ")", ":", "name", "=", "name", ".", "decode", "(", "\"utf-8\"", ")", "name", "=", "name", ".", "lower", "(", ")", "name", "=", "unicodedata", ".",...
Convert `name` to the ASCII vector. Example: >>> name_to_vector("ing. Franta Putšálek") ['putsalek', 'franta', 'ing'] Args: name (str): Name which will be vectorized. Returns: list: Vector created from name.
[ "Convert", "name", "to", "the", "ASCII", "vector", "." ]
train
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/filters/aleph_filter.py#L20-L41
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/filters/aleph_filter.py
compare_names
def compare_names(first, second): """ Compare two names in complicated, but more error prone way. Algorithm is using vector comparison. Example: >>> compare_names("Franta Putšálek", "ing. Franta Putšálek") 100.0 >>> compare_names("F. Putšálek", "ing. Franta Putšálek") 5...
python
def compare_names(first, second): """ Compare two names in complicated, but more error prone way. Algorithm is using vector comparison. Example: >>> compare_names("Franta Putšálek", "ing. Franta Putšálek") 100.0 >>> compare_names("F. Putšálek", "ing. Franta Putšálek") 5...
[ "def", "compare_names", "(", "first", ",", "second", ")", ":", "first", "=", "name_to_vector", "(", "first", ")", "second", "=", "name_to_vector", "(", "second", ")", "zipped", "=", "zip", "(", "first", ",", "second", ")", "if", "not", "zipped", ":", "...
Compare two names in complicated, but more error prone way. Algorithm is using vector comparison. Example: >>> compare_names("Franta Putšálek", "ing. Franta Putšálek") 100.0 >>> compare_names("F. Putšálek", "ing. Franta Putšálek") 50.0 Args: first (str): Fisst name...
[ "Compare", "two", "names", "in", "complicated", "but", "more", "error", "prone", "way", "." ]
train
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/filters/aleph_filter.py#L44-L76
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/filters/aleph_filter.py
filter_publication
def filter_publication(publication, cmp_authors=True): """ Filter publications based at data from Aleph. Args: publication (obj): :class:`.Publication` instance. Returns: obj/None: None if the publication was found in Aleph or `publication` \ if not. """ query...
python
def filter_publication(publication, cmp_authors=True): """ Filter publications based at data from Aleph. Args: publication (obj): :class:`.Publication` instance. Returns: obj/None: None if the publication was found in Aleph or `publication` \ if not. """ query...
[ "def", "filter_publication", "(", "publication", ",", "cmp_authors", "=", "True", ")", ":", "query", "=", "None", "isbn_query", "=", "False", "# there can be ISBN query or book title query", "if", "publication", ".", "optionals", "and", "publication", ".", "optionals"...
Filter publications based at data from Aleph. Args: publication (obj): :class:`.Publication` instance. Returns: obj/None: None if the publication was found in Aleph or `publication` \ if not.
[ "Filter", "publications", "based", "at", "data", "from", "Aleph", "." ]
train
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/filters/aleph_filter.py#L79-L148
totokaka/pySpaceGDN
setup.py
get_long_description
def get_long_description(): """ Read the long description. """ here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst')) as readme: return readme.read() return None
python
def get_long_description(): """ Read the long description. """ here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst')) as readme: return readme.read() return None
[ "def", "get_long_description", "(", ")", ":", "here", "=", "path", ".", "abspath", "(", "path", ".", "dirname", "(", "__file__", ")", ")", "with", "open", "(", "path", ".", "join", "(", "here", ",", "'README.rst'", ")", ")", "as", "readme", ":", "ret...
Read the long description.
[ "Read", "the", "long", "description", "." ]
train
https://github.com/totokaka/pySpaceGDN/blob/55c8be8d751e24873e0a7f7e99d2b715442ec878/setup.py#L7-L12
klmitch/bark
bark/format.py
ParseState.pop_state
def pop_state(self, idx=None): """ Pops off the most recent state. :param idx: If provided, specifies the index at which the next string begins. """ self.state.pop() if idx is not None: self.str_begin = idx
python
def pop_state(self, idx=None): """ Pops off the most recent state. :param idx: If provided, specifies the index at which the next string begins. """ self.state.pop() if idx is not None: self.str_begin = idx
[ "def", "pop_state", "(", "self", ",", "idx", "=", "None", ")", ":", "self", ".", "state", ".", "pop", "(", ")", "if", "idx", "is", "not", "None", ":", "self", ".", "str_begin", "=", "idx" ]
Pops off the most recent state. :param idx: If provided, specifies the index at which the next string begins.
[ "Pops", "off", "the", "most", "recent", "state", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L52-L63
klmitch/bark
bark/format.py
ParseState.add_text
def add_text(self, end, next=None): """ Adds the text from string beginning to the specified ending index to the format. :param end: The ending index of the string. :param next: The next string begin index. If None, the string index will not be updated. ...
python
def add_text(self, end, next=None): """ Adds the text from string beginning to the specified ending index to the format. :param end: The ending index of the string. :param next: The next string begin index. If None, the string index will not be updated. ...
[ "def", "add_text", "(", "self", ",", "end", ",", "next", "=", "None", ")", ":", "if", "self", ".", "str_begin", "!=", "end", ":", "self", ".", "fmt", ".", "append_text", "(", "self", ".", "format", "[", "self", ".", "str_begin", ":", "end", "]", ...
Adds the text from string beginning to the specified ending index to the format. :param end: The ending index of the string. :param next: The next string begin index. If None, the string index will not be updated.
[ "Adds", "the", "text", "from", "string", "beginning", "to", "the", "specified", "ending", "index", "to", "the", "format", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L82-L96
klmitch/bark
bark/format.py
ParseState.add_escape
def add_escape(self, idx, char): """ Translates and adds the escape sequence. :param idx: Provides the ending index of the escape sequence. :param char: The actual character that was escaped. """ self.fmt.append_text(self.fmt._unescape.get( self.format[self....
python
def add_escape(self, idx, char): """ Translates and adds the escape sequence. :param idx: Provides the ending index of the escape sequence. :param char: The actual character that was escaped. """ self.fmt.append_text(self.fmt._unescape.get( self.format[self....
[ "def", "add_escape", "(", "self", ",", "idx", ",", "char", ")", ":", "self", ".", "fmt", ".", "append_text", "(", "self", ".", "fmt", ".", "_unescape", ".", "get", "(", "self", ".", "format", "[", "self", ".", "str_begin", ":", "idx", "]", ",", "...
Translates and adds the escape sequence. :param idx: Provides the ending index of the escape sequence. :param char: The actual character that was escaped.
[ "Translates", "and", "adds", "the", "escape", "sequence", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L98-L107
klmitch/bark
bark/format.py
ParseState.set_param
def set_param(self, idx): """ Adds the parameter to the conversion modifier. :param idx: Provides the ending index of the parameter string. """ self.modifier.set_param(self.format[self.param_begin:idx])
python
def set_param(self, idx): """ Adds the parameter to the conversion modifier. :param idx: Provides the ending index of the parameter string. """ self.modifier.set_param(self.format[self.param_begin:idx])
[ "def", "set_param", "(", "self", ",", "idx", ")", ":", "self", ".", "modifier", ".", "set_param", "(", "self", ".", "format", "[", "self", ".", "param_begin", ":", "idx", "]", ")" ]
Adds the parameter to the conversion modifier. :param idx: Provides the ending index of the parameter string.
[ "Adds", "the", "parameter", "to", "the", "conversion", "modifier", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L109-L116
klmitch/bark
bark/format.py
ParseState.set_conversion
def set_conversion(self, idx): """ Adds the conversion to the format. :param idx: The ending index of the conversion name. """ # First, determine the name if self.conv_begin: name = self.format[self.conv_begin:idx] else: name = self.forma...
python
def set_conversion(self, idx): """ Adds the conversion to the format. :param idx: The ending index of the conversion name. """ # First, determine the name if self.conv_begin: name = self.format[self.conv_begin:idx] else: name = self.forma...
[ "def", "set_conversion", "(", "self", ",", "idx", ")", ":", "# First, determine the name", "if", "self", ".", "conv_begin", ":", "name", "=", "self", ".", "format", "[", "self", ".", "conv_begin", ":", "idx", "]", "else", ":", "name", "=", "self", ".", ...
Adds the conversion to the format. :param idx: The ending index of the conversion name.
[ "Adds", "the", "conversion", "to", "the", "format", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L118-L144
klmitch/bark
bark/format.py
ParseState.set_code
def set_code(self, idx): """ Sets a code to be filtered on for the conversion. Note that this also sets the 'code_last' attribute and configures to ignore the remaining characters of the code. :param idx: The index at which the code _begins_. :returns: True if the code...
python
def set_code(self, idx): """ Sets a code to be filtered on for the conversion. Note that this also sets the 'code_last' attribute and configures to ignore the remaining characters of the code. :param idx: The index at which the code _begins_. :returns: True if the code...
[ "def", "set_code", "(", "self", ",", "idx", ")", ":", "code", "=", "self", ".", "format", "[", "idx", ":", "idx", "+", "3", "]", "if", "len", "(", "code", ")", "<", "3", "or", "not", "code", ".", "isdigit", "(", ")", ":", "return", "False", "...
Sets a code to be filtered on for the conversion. Note that this also sets the 'code_last' attribute and configures to ignore the remaining characters of the code. :param idx: The index at which the code _begins_. :returns: True if the code is valid, False otherwise.
[ "Sets", "a", "code", "to", "be", "filtered", "on", "for", "the", "conversion", ".", "Note", "that", "this", "also", "sets", "the", "code_last", "attribute", "and", "configures", "to", "ignore", "the", "remaining", "characters", "of", "the", "code", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L153-L172
klmitch/bark
bark/format.py
ParseState.end_state
def end_state(self): """ Wrap things up and add any final string content. """ # Make sure we append any trailing text if self.str_begin != len(self.format): if len(self.state) > 1 or self.state[-1] != 'string': self.fmt.append_text( ...
python
def end_state(self): """ Wrap things up and add any final string content. """ # Make sure we append any trailing text if self.str_begin != len(self.format): if len(self.state) > 1 or self.state[-1] != 'string': self.fmt.append_text( ...
[ "def", "end_state", "(", "self", ")", ":", "# Make sure we append any trailing text", "if", "self", ".", "str_begin", "!=", "len", "(", "self", ".", "format", ")", ":", "if", "len", "(", "self", ".", "state", ")", ">", "1", "or", "self", ".", "state", ...
Wrap things up and add any final string content.
[ "Wrap", "things", "up", "and", "add", "any", "final", "string", "content", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L174-L188
klmitch/bark
bark/format.py
ParseState.conversion
def conversion(self, idx): """ Switches into the 'conversion' state, used to parse a % conversion. :param idx: The format string index at which the conversion begins. """ self.state.append('conversion') self.str_begin = idx self.param...
python
def conversion(self, idx): """ Switches into the 'conversion' state, used to parse a % conversion. :param idx: The format string index at which the conversion begins. """ self.state.append('conversion') self.str_begin = idx self.param...
[ "def", "conversion", "(", "self", ",", "idx", ")", ":", "self", ".", "state", ".", "append", "(", "'conversion'", ")", "self", ".", "str_begin", "=", "idx", "self", ".", "param_begin", "=", "None", "self", ".", "conv_begin", "=", "None", "self", ".", ...
Switches into the 'conversion' state, used to parse a % conversion. :param idx: The format string index at which the conversion begins.
[ "Switches", "into", "the", "conversion", "state", "used", "to", "parse", "a", "%", "conversion", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L190-L206
klmitch/bark
bark/format.py
Format._get_conversion
def _get_conversion(cls, conv_chr, modifier): """ Return a conversion given its character. :param conv_chr: The letter of the conversion, e.g., "a" for AddressConversion, etc. :param modifier: The format modifier applied to this conversi...
python
def _get_conversion(cls, conv_chr, modifier): """ Return a conversion given its character. :param conv_chr: The letter of the conversion, e.g., "a" for AddressConversion, etc. :param modifier: The format modifier applied to this conversi...
[ "def", "_get_conversion", "(", "cls", ",", "conv_chr", ",", "modifier", ")", ":", "# Do we need to look up the conversion?", "if", "conv_chr", "not", "in", "cls", ".", "_conversion_cache", ":", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "'b...
Return a conversion given its character. :param conv_chr: The letter of the conversion, e.g., "a" for AddressConversion, etc. :param modifier: The format modifier applied to this conversion. :returns: An instance of bark.conversions.Conversion.
[ "Return", "a", "conversion", "given", "its", "character", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L254-L287
klmitch/bark
bark/format.py
Format.parse
def parse(cls, format): """ Parse a format string. Factory function for the Format class. :param format: The format string to parse. :returns: An instance of class Format. """ fmt = cls() # Return an empty Format if format is empty if not format: ...
python
def parse(cls, format): """ Parse a format string. Factory function for the Format class. :param format: The format string to parse. :returns: An instance of class Format. """ fmt = cls() # Return an empty Format if format is empty if not format: ...
[ "def", "parse", "(", "cls", ",", "format", ")", ":", "fmt", "=", "cls", "(", ")", "# Return an empty Format if format is empty", "if", "not", "format", ":", "return", "fmt", "# Initialize the state for parsing", "state", "=", "ParseState", "(", "fmt", ",", "form...
Parse a format string. Factory function for the Format class. :param format: The format string to parse. :returns: An instance of class Format.
[ "Parse", "a", "format", "string", ".", "Factory", "function", "for", "the", "Format", "class", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L290-L365
klmitch/bark
bark/format.py
Format.append_text
def append_text(self, text): """ Append static text to the Format. :param text: The text to append. """ if (self.conversions and isinstance(self.conversions[-1], conversions.StringConversion)): self.conversions[-1].append(t...
python
def append_text(self, text): """ Append static text to the Format. :param text: The text to append. """ if (self.conversions and isinstance(self.conversions[-1], conversions.StringConversion)): self.conversions[-1].append(t...
[ "def", "append_text", "(", "self", ",", "text", ")", ":", "if", "(", "self", ".", "conversions", "and", "isinstance", "(", "self", ".", "conversions", "[", "-", "1", "]", ",", "conversions", ".", "StringConversion", ")", ")", ":", "self", ".", "convers...
Append static text to the Format. :param text: The text to append.
[ "Append", "static", "text", "to", "the", "Format", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L381-L393
klmitch/bark
bark/format.py
Format.prepare
def prepare(self, request): """ Performs any preparations necessary for the Format. :param request: The webob Request object describing the request. :returns: A list of dictionary values needed by the convert() method. """ data...
python
def prepare(self, request): """ Performs any preparations necessary for the Format. :param request: The webob Request object describing the request. :returns: A list of dictionary values needed by the convert() method. """ data...
[ "def", "prepare", "(", "self", ",", "request", ")", ":", "data", "=", "[", "]", "for", "conv", "in", "self", ".", "conversions", ":", "data", ".", "append", "(", "conv", ".", "prepare", "(", "request", ")", ")", "return", "data" ]
Performs any preparations necessary for the Format. :param request: The webob Request object describing the request. :returns: A list of dictionary values needed by the convert() method.
[ "Performs", "any", "preparations", "necessary", "for", "the", "Format", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L404-L419
klmitch/bark
bark/format.py
Format.convert
def convert(self, request, response, data): """ Performs the desired formatting. :param request: The webob Request object describing the request. :param response: The webob Response object describing the response. :param data: The...
python
def convert(self, request, response, data): """ Performs the desired formatting. :param request: The webob Request object describing the request. :param response: The webob Response object describing the response. :param data: The...
[ "def", "convert", "(", "self", ",", "request", ",", "response", ",", "data", ")", ":", "result", "=", "[", "]", "for", "conv", ",", "datum", "in", "zip", "(", "self", ".", "conversions", ",", "data", ")", ":", "# Only include conversion if it's allowed", ...
Performs the desired formatting. :param request: The webob Request object describing the request. :param response: The webob Response object describing the response. :param data: The data dictionary list returned by the prepa...
[ "Performs", "the", "desired", "formatting", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L421-L444
insilicolife/micti
MICTI/MARKERS.py
MICTI.FDR_BH
def FDR_BH(self, p): """Benjamini-Hochberg p-value correction for multiple hypothesis testing.""" p = np.asfarray(p) by_descend = p.argsort()[::-1] by_orig = by_descend.argsort() steps = float(len(p)) / np.arange(len(p), 0, -1) q = np.minimum(1, np.minimum.accumulate(step...
python
def FDR_BH(self, p): """Benjamini-Hochberg p-value correction for multiple hypothesis testing.""" p = np.asfarray(p) by_descend = p.argsort()[::-1] by_orig = by_descend.argsort() steps = float(len(p)) / np.arange(len(p), 0, -1) q = np.minimum(1, np.minimum.accumulate(step...
[ "def", "FDR_BH", "(", "self", ",", "p", ")", ":", "p", "=", "np", ".", "asfarray", "(", "p", ")", "by_descend", "=", "p", ".", "argsort", "(", ")", "[", ":", ":", "-", "1", "]", "by_orig", "=", "by_descend", ".", "argsort", "(", ")", "steps", ...
Benjamini-Hochberg p-value correction for multiple hypothesis testing.
[ "Benjamini", "-", "Hochberg", "p", "-", "value", "correction", "for", "multiple", "hypothesis", "testing", "." ]
train
https://github.com/insilicolife/micti/blob/f12f46724295b57c4859e6acf7eab580fc355eb1/MICTI/MARKERS.py#L229-L236
brentpayne/kennyg
kennyg/sax_handler.py
KennyGSAXHandler.is_valid
def is_valid(self, name=None, debug=False): """ Check to see if the current xml path is to be processed. """ valid_tags = self.action_tree invalid = False for item in self.current_tree: try: if item in valid_tags or self.ALL_TAGS in valid_tags:...
python
def is_valid(self, name=None, debug=False): """ Check to see if the current xml path is to be processed. """ valid_tags = self.action_tree invalid = False for item in self.current_tree: try: if item in valid_tags or self.ALL_TAGS in valid_tags:...
[ "def", "is_valid", "(", "self", ",", "name", "=", "None", ",", "debug", "=", "False", ")", ":", "valid_tags", "=", "self", ".", "action_tree", "invalid", "=", "False", "for", "item", "in", "self", ".", "current_tree", ":", "try", ":", "if", "item", "...
Check to see if the current xml path is to be processed.
[ "Check", "to", "see", "if", "the", "current", "xml", "path", "is", "to", "be", "processed", "." ]
train
https://github.com/brentpayne/kennyg/blob/c688dd6d270bb7dcdcce7f08c54eafb1bf3232f2/kennyg/sax_handler.py#L16-L35
emencia/emencia-django-forum
forum/forms/crispies.py
category_helper
def category_helper(form_tag=True): """ Category's form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag helper.layout = Layout( Row( Column( 'title', css...
python
def category_helper(form_tag=True): """ Category's form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag helper.layout = Layout( Row( Column( 'title', css...
[ "def", "category_helper", "(", "form_tag", "=", "True", ")", ":", "helper", "=", "FormHelper", "(", ")", "helper", ".", "form_action", "=", "'.'", "helper", ".", "attrs", "=", "{", "'data_abide'", ":", "''", "}", "helper", ".", "form_tag", "=", "form_tag...
Category's form layout helper
[ "Category", "s", "form", "layout", "helper" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/forms/crispies.py#L9-L53
emencia/emencia-django-forum
forum/forms/crispies.py
thread_helper
def thread_helper(form_tag=True, edit_mode=False, for_moderator=False): """ Thread's form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag fieldsets = [ Row( Column( 'sub...
python
def thread_helper(form_tag=True, edit_mode=False, for_moderator=False): """ Thread's form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag fieldsets = [ Row( Column( 'sub...
[ "def", "thread_helper", "(", "form_tag", "=", "True", ",", "edit_mode", "=", "False", ",", "for_moderator", "=", "False", ")", ":", "helper", "=", "FormHelper", "(", ")", "helper", ".", "form_action", "=", "'.'", "helper", ".", "attrs", "=", "{", "'data_...
Thread's form layout helper
[ "Thread", "s", "form", "layout", "helper" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/forms/crispies.py#L57-L145
emencia/emencia-django-forum
forum/forms/crispies.py
post_helper
def post_helper(form_tag=True, edit_mode=False): """ Post's form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag fieldsets = [ Row( Column( 'text', css_c...
python
def post_helper(form_tag=True, edit_mode=False): """ Post's form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag fieldsets = [ Row( Column( 'text', css_c...
[ "def", "post_helper", "(", "form_tag", "=", "True", ",", "edit_mode", "=", "False", ")", ":", "helper", "=", "FormHelper", "(", ")", "helper", ".", "form_action", "=", "'.'", "helper", ".", "attrs", "=", "{", "'data_abide'", ":", "''", "}", "helper", "...
Post's form layout helper
[ "Post", "s", "form", "layout", "helper" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/forms/crispies.py#L148-L186
emencia/emencia-django-forum
forum/forms/crispies.py
post_delete_helper
def post_delete_helper(form_tag=True): """ Message's delete form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag helper.layout = Layout( ButtonHolderPanel( Row( Column( ...
python
def post_delete_helper(form_tag=True): """ Message's delete form layout helper """ helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag helper.layout = Layout( ButtonHolderPanel( Row( Column( ...
[ "def", "post_delete_helper", "(", "form_tag", "=", "True", ")", ":", "helper", "=", "FormHelper", "(", ")", "helper", ".", "form_action", "=", "'.'", "helper", ".", "attrs", "=", "{", "'data_abide'", ":", "''", "}", "helper", ".", "form_tag", "=", "form_...
Message's delete form layout helper
[ "Message", "s", "delete", "form", "layout", "helper" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/forms/crispies.py#L191-L215
alexhayes/django-toolkit
django_toolkit/decorators.py
permission_required_raise
def permission_required_raise(perm, login_url=None, raise_exception=True): """ A permission_required decorator that raises by default. """ return permission_required(perm, login_url=login_url, raise_exception=raise_exception)
python
def permission_required_raise(perm, login_url=None, raise_exception=True): """ A permission_required decorator that raises by default. """ return permission_required(perm, login_url=login_url, raise_exception=raise_exception)
[ "def", "permission_required_raise", "(", "perm", ",", "login_url", "=", "None", ",", "raise_exception", "=", "True", ")", ":", "return", "permission_required", "(", "perm", ",", "login_url", "=", "login_url", ",", "raise_exception", "=", "raise_exception", ")" ]
A permission_required decorator that raises by default.
[ "A", "permission_required", "decorator", "that", "raises", "by", "default", "." ]
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/decorators.py#L31-L35
azogue/dataweb
dataweb/requestweb/__init__.py
request_data_url
def request_data_url(url, headers=None, num_retries=NUM_RETRIES, timeout=TIMEOUT, params_request=None, json_req=False, **kwargs_req): """ Realiza sucesivos intentos de request a una url dada, intentándolo hasta que recibe un status 200 (OK) y el texto recibido es mayor que MIN_LEN_REQUE...
python
def request_data_url(url, headers=None, num_retries=NUM_RETRIES, timeout=TIMEOUT, params_request=None, json_req=False, **kwargs_req): """ Realiza sucesivos intentos de request a una url dada, intentándolo hasta que recibe un status 200 (OK) y el texto recibido es mayor que MIN_LEN_REQUE...
[ "def", "request_data_url", "(", "url", ",", "headers", "=", "None", ",", "num_retries", "=", "NUM_RETRIES", ",", "timeout", "=", "TIMEOUT", ",", "params_request", "=", "None", ",", "json_req", "=", "False", ",", "*", "*", "kwargs_req", ")", ":", "count", ...
Realiza sucesivos intentos de request a una url dada, intentándolo hasta que recibe un status 200 (OK) y el texto recibido es mayor que MIN_LEN_REQUEST (=10). Resulta útil cuando se están realizando múltiples requests al mismo servidor (por velocidad), y no siempre las respuestas que emite son correctas. ...
[ "Realiza", "sucesivos", "intentos", "de", "request", "a", "una", "url", "dada", "intentándolo", "hasta", "que", "recibe", "un", "status", "200", "(", "OK", ")", "y", "el", "texto", "recibido", "es", "mayor", "que", "MIN_LEN_REQUEST", "(", "=", "10", ")", ...
train
https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/requestweb/__init__.py#L40-L96
azogue/dataweb
dataweb/requestweb/__init__.py
get_data_en_intervalo
def get_data_en_intervalo(d0=None, df=None, date_fmt=DATE_FMT, usar_multithread=USAR_MULTITHREAD, max_threads_requests=MAX_THREADS_REQUESTS, timeout=TIMEOUT, num_retries=NUM_RETRIES, func_procesa_data_dia=None, func_url_data_dia=None, max_act...
python
def get_data_en_intervalo(d0=None, df=None, date_fmt=DATE_FMT, usar_multithread=USAR_MULTITHREAD, max_threads_requests=MAX_THREADS_REQUESTS, timeout=TIMEOUT, num_retries=NUM_RETRIES, func_procesa_data_dia=None, func_url_data_dia=None, max_act...
[ "def", "get_data_en_intervalo", "(", "d0", "=", "None", ",", "df", "=", "None", ",", "date_fmt", "=", "DATE_FMT", ",", "usar_multithread", "=", "USAR_MULTITHREAD", ",", "max_threads_requests", "=", "MAX_THREADS_REQUESTS", ",", "timeout", "=", "TIMEOUT", ",", "nu...
Obtiene los datos en bruto de la red realizando múltiples requests al tiempo Procesa los datos en bruto obtenidos de la red convirtiendo a Pandas DataFrame
[ "Obtiene", "los", "datos", "en", "bruto", "de", "la", "red", "realizando", "múltiples", "requests", "al", "tiempo", "Procesa", "los", "datos", "en", "bruto", "obtenidos", "de", "la", "red", "convirtiendo", "a", "Pandas", "DataFrame" ]
train
https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/requestweb/__init__.py#L99-L227
monkeython/scriba
scriba/schemes/file.py
write
def write(url, content, **args): """Put the object/collection into a file URL.""" with FileResource(url, **args) as resource: resource.write(content)
python
def write(url, content, **args): """Put the object/collection into a file URL.""" with FileResource(url, **args) as resource: resource.write(content)
[ "def", "write", "(", "url", ",", "content", ",", "*", "*", "args", ")", ":", "with", "FileResource", "(", "url", ",", "*", "*", "args", ")", "as", "resource", ":", "resource", ".", "write", "(", "content", ")" ]
Put the object/collection into a file URL.
[ "Put", "the", "object", "/", "collection", "into", "a", "file", "URL", "." ]
train
https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/schemes/file.py#L64-L67
alexhayes/django-toolkit
django_toolkit/celery/decorators.py
ensure_self
def ensure_self(func): """ Decorator that can be used to ensure 'self' is the first argument on a task method. This only needs to be used with task methods that are used as a callback to a chord or in link_error and is really just a hack to get around https://github.com/celery/celery/issues/2137 U...
python
def ensure_self(func): """ Decorator that can be used to ensure 'self' is the first argument on a task method. This only needs to be used with task methods that are used as a callback to a chord or in link_error and is really just a hack to get around https://github.com/celery/celery/issues/2137 U...
[ "def", "ensure_self", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", "=", "kwargs", ".", "pop", "(", "'this'", ")", "if", "len", "(", "args", ")", ...
Decorator that can be used to ensure 'self' is the first argument on a task method. This only needs to be used with task methods that are used as a callback to a chord or in link_error and is really just a hack to get around https://github.com/celery/celery/issues/2137 Usage: .. code-block:: python ...
[ "Decorator", "that", "can", "be", "used", "to", "ensure", "self", "is", "the", "first", "argument", "on", "a", "task", "method", "." ]
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/celery/decorators.py#L3-L53
b3j0f/utils
b3j0f/utils/runtime.py
singleton_per_scope
def singleton_per_scope(_cls, _scope=None, _renew=False, *args, **kwargs): """Instanciate a singleton per scope.""" result = None singletons = SINGLETONS_PER_SCOPES.setdefault(_scope, {}) if _renew or _cls not in singletons: singletons[_cls] = _cls(*args, **kwargs) result = singletons[_c...
python
def singleton_per_scope(_cls, _scope=None, _renew=False, *args, **kwargs): """Instanciate a singleton per scope.""" result = None singletons = SINGLETONS_PER_SCOPES.setdefault(_scope, {}) if _renew or _cls not in singletons: singletons[_cls] = _cls(*args, **kwargs) result = singletons[_c...
[ "def", "singleton_per_scope", "(", "_cls", ",", "_scope", "=", "None", ",", "_renew", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "None", "singletons", "=", "SINGLETONS_PER_SCOPES", ".", "setdefault", "(", "_scope", ...
Instanciate a singleton per scope.
[ "Instanciate", "a", "singleton", "per", "scope", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L70-L82
b3j0f/utils
b3j0f/utils/runtime.py
_safebuiltins
def _safebuiltins(): """Construct a safe builtin environment without I/O functions. :rtype: dict""" result = {} objectnames = [ objectname for objectname in dir(builtins) if objectname not in BUILTIN_IO_PROPS ] for objectname in objectnames: result[objectname] = getat...
python
def _safebuiltins(): """Construct a safe builtin environment without I/O functions. :rtype: dict""" result = {} objectnames = [ objectname for objectname in dir(builtins) if objectname not in BUILTIN_IO_PROPS ] for objectname in objectnames: result[objectname] = getat...
[ "def", "_safebuiltins", "(", ")", ":", "result", "=", "{", "}", "objectnames", "=", "[", "objectname", "for", "objectname", "in", "dir", "(", "builtins", ")", "if", "objectname", "not", "in", "BUILTIN_IO_PROPS", "]", "for", "objectname", "in", "objectnames",...
Construct a safe builtin environment without I/O functions. :rtype: dict
[ "Construct", "a", "safe", "builtin", "environment", "without", "I", "/", "O", "functions", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L85-L100
b3j0f/utils
b3j0f/utils/runtime.py
_safe_processing
def _safe_processing(nsafefn, source, _globals=None, _locals=None): """Do a safe processing of input fn in using SAFE_BUILTINS. :param fn: function to call with input parameters. :param source: source object to process with fn. :param dict _globals: global objects by name. :param dict _locals: loca...
python
def _safe_processing(nsafefn, source, _globals=None, _locals=None): """Do a safe processing of input fn in using SAFE_BUILTINS. :param fn: function to call with input parameters. :param source: source object to process with fn. :param dict _globals: global objects by name. :param dict _locals: loca...
[ "def", "_safe_processing", "(", "nsafefn", ",", "source", ",", "_globals", "=", "None", ",", "_locals", "=", "None", ")", ":", "if", "_globals", "is", "None", ":", "_globals", "=", "SAFE_BUILTINS", "else", ":", "_globals", ".", "update", "(", "SAFE_BUILTIN...
Do a safe processing of input fn in using SAFE_BUILTINS. :param fn: function to call with input parameters. :param source: source object to process with fn. :param dict _globals: global objects by name. :param dict _locals: local objects by name. :return: fn processing result
[ "Do", "a", "safe", "processing", "of", "input", "fn", "in", "using", "SAFE_BUILTINS", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L105-L120
b3j0f/utils
b3j0f/utils/runtime.py
_make_constants
def _make_constants(func, builtin_only=False, stoplist=None, verbose=None): """Generate new function where code is an input function code with all LOAD_GLOBAL statements changed to LOAD_CONST statements. :param function func: code function to transform. :param bool builtin_only: only transform builtin ...
python
def _make_constants(func, builtin_only=False, stoplist=None, verbose=None): """Generate new function where code is an input function code with all LOAD_GLOBAL statements changed to LOAD_CONST statements. :param function func: code function to transform. :param bool builtin_only: only transform builtin ...
[ "def", "_make_constants", "(", "func", ",", "builtin_only", "=", "False", ",", "stoplist", "=", "None", ",", "verbose", "=", "None", ")", ":", "result", "=", "func", "if", "stoplist", "is", "None", ":", "stoplist", "=", "[", "]", "try", ":", "fcode", ...
Generate new function where code is an input function code with all LOAD_GLOBAL statements changed to LOAD_CONST statements. :param function func: code function to transform. :param bool builtin_only: only transform builtin objects. :param list stoplist: attribute names to not transform. :param fun...
[ "Generate", "new", "function", "where", "code", "is", "an", "input", "function", "code", "with", "all", "LOAD_GLOBAL", "statements", "changed", "to", "LOAD_CONST", "statements", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L145-L276
b3j0f/utils
b3j0f/utils/runtime.py
getcodeobj
def getcodeobj(consts, intcode, newcodeobj, oldcodeobj): """Get code object from decompiled code. :param list consts: constants to add in the result. :param list intcode: list of byte code to use. :param newcodeobj: new code object with empty body. :param oldcodeobj: old code object. :return: n...
python
def getcodeobj(consts, intcode, newcodeobj, oldcodeobj): """Get code object from decompiled code. :param list consts: constants to add in the result. :param list intcode: list of byte code to use. :param newcodeobj: new code object with empty body. :param oldcodeobj: old code object. :return: n...
[ "def", "getcodeobj", "(", "consts", ",", "intcode", ",", "newcodeobj", ",", "oldcodeobj", ")", ":", "# get code string", "if", "PY3", ":", "codestr", "=", "bytes", "(", "intcode", ")", "else", ":", "codestr", "=", "reduce", "(", "lambda", "x", ",", "y", ...
Get code object from decompiled code. :param list consts: constants to add in the result. :param list intcode: list of byte code to use. :param newcodeobj: new code object with empty body. :param oldcodeobj: old code object. :return: new code object to produce.
[ "Get", "code", "object", "from", "decompiled", "code", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L279-L309
b3j0f/utils
b3j0f/utils/runtime.py
bind_all
def bind_all(morc, builtin_only=False, stoplist=None, verbose=None): """Recursively apply constant binding to functions in a module or class. Use as the last line of the module (after everything is defined, but before test code). In modules that need modifiable globals, set builtin_only to True. :...
python
def bind_all(morc, builtin_only=False, stoplist=None, verbose=None): """Recursively apply constant binding to functions in a module or class. Use as the last line of the module (after everything is defined, but before test code). In modules that need modifiable globals, set builtin_only to True. :...
[ "def", "bind_all", "(", "morc", ",", "builtin_only", "=", "False", ",", "stoplist", "=", "None", ",", "verbose", "=", "None", ")", ":", "if", "stoplist", "is", "None", ":", "stoplist", "=", "[", "]", "def", "_bind_all", "(", "morc", ",", "builtin_only"...
Recursively apply constant binding to functions in a module or class. Use as the last line of the module (after everything is defined, but before test code). In modules that need modifiable globals, set builtin_only to True. :param morc: module or class to transform. :param bool builtin_only: only...
[ "Recursively", "apply", "constant", "binding", "to", "functions", "in", "a", "module", "or", "class", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L315-L355
b3j0f/utils
b3j0f/utils/runtime.py
make_constants
def make_constants(builtin_only=False, stoplist=None, verbose=None): """Return a decorator for optimizing global references. Replaces global references with their currently defined values. If not defined, the dynamic (runtime) global lookup is left undisturbed. If builtin_only is True, then only builti...
python
def make_constants(builtin_only=False, stoplist=None, verbose=None): """Return a decorator for optimizing global references. Replaces global references with their currently defined values. If not defined, the dynamic (runtime) global lookup is left undisturbed. If builtin_only is True, then only builti...
[ "def", "make_constants", "(", "builtin_only", "=", "False", ",", "stoplist", "=", "None", ",", "verbose", "=", "None", ")", ":", "if", "stoplist", "is", "None", ":", "stoplist", "=", "[", "]", "if", "isinstance", "(", "builtin_only", ",", "type", "(", ...
Return a decorator for optimizing global references. Replaces global references with their currently defined values. If not defined, the dynamic (runtime) global lookup is left undisturbed. If builtin_only is True, then only builtins are optimized. Variable names in the stoplist are also left undisturb...
[ "Return", "a", "decorator", "for", "optimizing", "global", "references", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/runtime.py#L359-L380
naphatkrit/easyci
easyci/locking.py
init
def init(vcs): """Initialize the locking module for a repository """ path = os.path.join(vcs.private_dir(), 'locks') if not os.path.exists(path): os.mkdir(path)
python
def init(vcs): """Initialize the locking module for a repository """ path = os.path.join(vcs.private_dir(), 'locks') if not os.path.exists(path): os.mkdir(path)
[ "def", "init", "(", "vcs", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "vcs", ".", "private_dir", "(", ")", ",", "'locks'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "os", ".", "mkdir", "(", "p...
Initialize the locking module for a repository
[ "Initialize", "the", "locking", "module", "for", "a", "repository" ]
train
https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/locking.py#L24-L29
naphatkrit/easyci
easyci/locking.py
lock
def lock(vcs, lock_object, wait=True): """A context manager that grabs the lock and releases it when done. This blocks until the lock can be acquired. Args: vcs (easyci.vcs.base.Vcs) lock_object (Lock) wait (boolean) - whether to wait for the lock or error out Raises: ...
python
def lock(vcs, lock_object, wait=True): """A context manager that grabs the lock and releases it when done. This blocks until the lock can be acquired. Args: vcs (easyci.vcs.base.Vcs) lock_object (Lock) wait (boolean) - whether to wait for the lock or error out Raises: ...
[ "def", "lock", "(", "vcs", ",", "lock_object", ",", "wait", "=", "True", ")", ":", "if", "wait", ":", "timeout", "=", "-", "1", "else", ":", "timeout", "=", "0", "lock_path", "=", "_get_lock_path", "(", "vcs", ",", "lock_object", ")", "lock", "=", ...
A context manager that grabs the lock and releases it when done. This blocks until the lock can be acquired. Args: vcs (easyci.vcs.base.Vcs) lock_object (Lock) wait (boolean) - whether to wait for the lock or error out Raises: Timeout
[ "A", "context", "manager", "that", "grabs", "the", "lock", "and", "releases", "it", "when", "done", "." ]
train
https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/locking.py#L33-L53
minhhoit/yacms
yacms/utils/urls.py
home_slug
def home_slug(): """ Returns the slug arg defined for the ``home`` urlpattern, which is the definitive source of the ``url`` field defined for an editable homepage object. """ prefix = get_script_prefix() slug = reverse("home") if slug.startswith(prefix): slug = '/' + slug[len(pr...
python
def home_slug(): """ Returns the slug arg defined for the ``home`` urlpattern, which is the definitive source of the ``url`` field defined for an editable homepage object. """ prefix = get_script_prefix() slug = reverse("home") if slug.startswith(prefix): slug = '/' + slug[len(pr...
[ "def", "home_slug", "(", ")", ":", "prefix", "=", "get_script_prefix", "(", ")", "slug", "=", "reverse", "(", "\"home\"", ")", "if", "slug", ".", "startswith", "(", "prefix", ")", ":", "slug", "=", "'/'", "+", "slug", "[", "len", "(", "prefix", ")", ...
Returns the slug arg defined for the ``home`` urlpattern, which is the definitive source of the ``url`` field defined for an editable homepage object.
[ "Returns", "the", "slug", "arg", "defined", "for", "the", "home", "urlpattern", "which", "is", "the", "definitive", "source", "of", "the", "url", "field", "defined", "for", "an", "editable", "homepage", "object", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L32-L45
minhhoit/yacms
yacms/utils/urls.py
slugify_unicode
def slugify_unicode(s): """ Replacement for Django's slugify which allows unicode chars in slugs, for URLs in Chinese, Russian, etc. Adopted from https://github.com/mozilla/unicode-slugify/ """ chars = [] for char in str(smart_text(s)): cat = unicodedata.category(char)[0] if ...
python
def slugify_unicode(s): """ Replacement for Django's slugify which allows unicode chars in slugs, for URLs in Chinese, Russian, etc. Adopted from https://github.com/mozilla/unicode-slugify/ """ chars = [] for char in str(smart_text(s)): cat = unicodedata.category(char)[0] if ...
[ "def", "slugify_unicode", "(", "s", ")", ":", "chars", "=", "[", "]", "for", "char", "in", "str", "(", "smart_text", "(", "s", ")", ")", ":", "cat", "=", "unicodedata", ".", "category", "(", "char", ")", "[", "0", "]", "if", "cat", "in", "\"LN\""...
Replacement for Django's slugify which allows unicode chars in slugs, for URLs in Chinese, Russian, etc. Adopted from https://github.com/mozilla/unicode-slugify/
[ "Replacement", "for", "Django", "s", "slugify", "which", "allows", "unicode", "chars", "in", "slugs", "for", "URLs", "in", "Chinese", "Russian", "etc", ".", "Adopted", "from", "https", ":", "//", "github", ".", "com", "/", "mozilla", "/", "unicode", "-", ...
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L56-L69
minhhoit/yacms
yacms/utils/urls.py
unique_slug
def unique_slug(queryset, slug_field, slug): """ Ensures a slug is unique for the given queryset, appending an integer to its end until the slug is unique. """ i = 0 while True: if i > 0: if i > 1: slug = slug.rsplit("-", 1)[0] slug = "%s-%s" % (sl...
python
def unique_slug(queryset, slug_field, slug): """ Ensures a slug is unique for the given queryset, appending an integer to its end until the slug is unique. """ i = 0 while True: if i > 0: if i > 1: slug = slug.rsplit("-", 1)[0] slug = "%s-%s" % (sl...
[ "def", "unique_slug", "(", "queryset", ",", "slug_field", ",", "slug", ")", ":", "i", "=", "0", "while", "True", ":", "if", "i", ">", "0", ":", "if", "i", ">", "1", ":", "slug", "=", "slug", ".", "rsplit", "(", "\"-\"", ",", "1", ")", "[", "0...
Ensures a slug is unique for the given queryset, appending an integer to its end until the slug is unique.
[ "Ensures", "a", "slug", "is", "unique", "for", "the", "given", "queryset", "appending", "an", "integer", "to", "its", "end", "until", "the", "slug", "is", "unique", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L72-L88
minhhoit/yacms
yacms/utils/urls.py
next_url
def next_url(request): """ Returns URL to redirect to from the ``next`` param in the request. """ next = request.GET.get("next", request.POST.get("next", "")) host = request.get_host() return next if next and is_safe_url(next, host=host) else None
python
def next_url(request): """ Returns URL to redirect to from the ``next`` param in the request. """ next = request.GET.get("next", request.POST.get("next", "")) host = request.get_host() return next if next and is_safe_url(next, host=host) else None
[ "def", "next_url", "(", "request", ")", ":", "next", "=", "request", ".", "GET", ".", "get", "(", "\"next\"", ",", "request", ".", "POST", ".", "get", "(", "\"next\"", ",", "\"\"", ")", ")", "host", "=", "request", ".", "get_host", "(", ")", "retur...
Returns URL to redirect to from the ``next`` param in the request.
[ "Returns", "URL", "to", "redirect", "to", "from", "the", "next", "param", "in", "the", "request", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L91-L97
minhhoit/yacms
yacms/utils/urls.py
login_redirect
def login_redirect(request): """ Returns the redirect response for login/signup. Favors: - next param - LOGIN_REDIRECT_URL setting - homepage """ ignorable_nexts = ("",) if "yacms.accounts" in settings.INSTALLED_APPS: from yacms.accounts import urls ignorable_nexts += (ur...
python
def login_redirect(request): """ Returns the redirect response for login/signup. Favors: - next param - LOGIN_REDIRECT_URL setting - homepage """ ignorable_nexts = ("",) if "yacms.accounts" in settings.INSTALLED_APPS: from yacms.accounts import urls ignorable_nexts += (ur...
[ "def", "login_redirect", "(", "request", ")", ":", "ignorable_nexts", "=", "(", "\"\"", ",", ")", "if", "\"yacms.accounts\"", "in", "settings", ".", "INSTALLED_APPS", ":", "from", "yacms", ".", "accounts", "import", "urls", "ignorable_nexts", "+=", "(", "urls"...
Returns the redirect response for login/signup. Favors: - next param - LOGIN_REDIRECT_URL setting - homepage
[ "Returns", "the", "redirect", "response", "for", "login", "/", "signup", ".", "Favors", ":", "-", "next", "param", "-", "LOGIN_REDIRECT_URL", "setting", "-", "homepage" ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L100-L122
minhhoit/yacms
yacms/utils/urls.py
path_to_slug
def path_to_slug(path): """ Removes everything from the given URL path, including language code and ``PAGES_SLUG`` if any is set, returning a slug that would match a ``Page`` instance's slug. """ from yacms.urls import PAGES_SLUG lang_code = translation.get_language_from_path(path) for p...
python
def path_to_slug(path): """ Removes everything from the given URL path, including language code and ``PAGES_SLUG`` if any is set, returning a slug that would match a ``Page`` instance's slug. """ from yacms.urls import PAGES_SLUG lang_code = translation.get_language_from_path(path) for p...
[ "def", "path_to_slug", "(", "path", ")", ":", "from", "yacms", ".", "urls", "import", "PAGES_SLUG", "lang_code", "=", "translation", ".", "get_language_from_path", "(", "path", ")", "for", "prefix", "in", "(", "lang_code", ",", "settings", ".", "SITE_PREFIX", ...
Removes everything from the given URL path, including language code and ``PAGES_SLUG`` if any is set, returning a slug that would match a ``Page`` instance's slug.
[ "Removes", "everything", "from", "the", "given", "URL", "path", "including", "language", "code", "and", "PAGES_SLUG", "if", "any", "is", "set", "returning", "a", "slug", "that", "would", "match", "a", "Page", "instance", "s", "slug", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L125-L136
vedarthk/exreporter
exreporter/contrib/django_middlewares.py
ExreporterGithubMiddleware.process_exception
def process_exception(self, request, exception): """Report exceptions from requests via Exreporter. """ gc = GithubCredentials( user=settings.EXREPORTER_GITHUB_USER, repo=settings.EXREPORTER_GITHUB_REPO, auth_token=settings.EXREPORTER_GITHUB_AUTH_TOKEN) ...
python
def process_exception(self, request, exception): """Report exceptions from requests via Exreporter. """ gc = GithubCredentials( user=settings.EXREPORTER_GITHUB_USER, repo=settings.EXREPORTER_GITHUB_REPO, auth_token=settings.EXREPORTER_GITHUB_AUTH_TOKEN) ...
[ "def", "process_exception", "(", "self", ",", "request", ",", "exception", ")", ":", "gc", "=", "GithubCredentials", "(", "user", "=", "settings", ".", "EXREPORTER_GITHUB_USER", ",", "repo", "=", "settings", ".", "EXREPORTER_GITHUB_REPO", ",", "auth_token", "=",...
Report exceptions from requests via Exreporter.
[ "Report", "exceptions", "from", "requests", "via", "Exreporter", "." ]
train
https://github.com/vedarthk/exreporter/blob/8adf445477341d43a13d3baa2551e1c0f68229bb/exreporter/contrib/django_middlewares.py#L29-L40
mixmastamyk/out
out/format.py
left_indent
def left_indent(text, indent=12, end='\n'): ''' A bit of the ol' ultraviolence :-/ ''' indent = ' ' * indent lines = [indent + line for line in text.splitlines(True)] lines.append(end) return ''.join(lines)
python
def left_indent(text, indent=12, end='\n'): ''' A bit of the ol' ultraviolence :-/ ''' indent = ' ' * indent lines = [indent + line for line in text.splitlines(True)] lines.append(end) return ''.join(lines)
[ "def", "left_indent", "(", "text", ",", "indent", "=", "12", ",", "end", "=", "'\\n'", ")", ":", "indent", "=", "' '", "*", "indent", "lines", "=", "[", "indent", "+", "line", "for", "line", "in", "text", ".", "splitlines", "(", "True", ")", "]", ...
A bit of the ol' ultraviolence :-/
[ "A", "bit", "of", "the", "ol", "ultraviolence", ":", "-", "/" ]
train
https://github.com/mixmastamyk/out/blob/f5e02a783ed529e21753c7e6233d0c5550241fd9/out/format.py#L212-L217
mixmastamyk/out
out/format.py
ColorFormatter.format
def format(self, record): ''' Log color formatting. ''' levelname = record.levelname # len7 limit if levelname == 'CRITICAL': levelname = record.levelname = 'FATAL' if self.usesTime(): record.asctime = self.formatTime(record, self.datefmt) # render the...
python
def format(self, record): ''' Log color formatting. ''' levelname = record.levelname # len7 limit if levelname == 'CRITICAL': levelname = record.levelname = 'FATAL' if self.usesTime(): record.asctime = self.formatTime(record, self.datefmt) # render the...
[ "def", "format", "(", "self", ",", "record", ")", ":", "levelname", "=", "record", ".", "levelname", "# len7 limit", "if", "levelname", "==", "'CRITICAL'", ":", "levelname", "=", "record", ".", "levelname", "=", "'FATAL'", "if", "self", ".", "usesTime", "(...
Log color formatting.
[ "Log", "color", "formatting", "." ]
train
https://github.com/mixmastamyk/out/blob/f5e02a783ed529e21753c7e6233d0c5550241fd9/out/format.py#L102-L149
mixmastamyk/out
out/format.py
JSONFormatter.format
def format(self, record): ''' Log color formatting. ''' levelname = record.levelname if levelname == 'CRITICAL': levelname = record.levelname = 'FATAL' record.asctime = self.formatTime(record, self.datefmt) # render the message part with arguments try: # All...
python
def format(self, record): ''' Log color formatting. ''' levelname = record.levelname if levelname == 'CRITICAL': levelname = record.levelname = 'FATAL' record.asctime = self.formatTime(record, self.datefmt) # render the message part with arguments try: # All...
[ "def", "format", "(", "self", ",", "record", ")", ":", "levelname", "=", "record", ".", "levelname", "if", "levelname", "==", "'CRITICAL'", ":", "levelname", "=", "record", ".", "levelname", "=", "'FATAL'", "record", ".", "asctime", "=", "self", ".", "fo...
Log color formatting.
[ "Log", "color", "formatting", "." ]
train
https://github.com/mixmastamyk/out/blob/f5e02a783ed529e21753c7e6233d0c5550241fd9/out/format.py#L172-L209
florianpaquet/mease
mease/backends/redis.py
RedisBackendMixin.connect
def connect(self): """ Connects to publisher """ self.client = redis.Redis( host=self.host, port=self.port, password=self.password)
python
def connect(self): """ Connects to publisher """ self.client = redis.Redis( host=self.host, port=self.port, password=self.password)
[ "def", "connect", "(", "self", ")", ":", "self", ".", "client", "=", "redis", ".", "Redis", "(", "host", "=", "self", ".", "host", ",", "port", "=", "self", ".", "port", ",", "password", "=", "self", ".", "password", ")" ]
Connects to publisher
[ "Connects", "to", "publisher" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/redis.py#L31-L36
florianpaquet/mease
mease/backends/redis.py
RedisPublisher.publish
def publish(self, message_type, client_id, client_storage, *args, **kwargs): """ Publishes a message """ p = self.pack(message_type, client_id, client_storage, args, kwargs) self.client.publish(self.channel, p)
python
def publish(self, message_type, client_id, client_storage, *args, **kwargs): """ Publishes a message """ p = self.pack(message_type, client_id, client_storage, args, kwargs) self.client.publish(self.channel, p)
[ "def", "publish", "(", "self", ",", "message_type", ",", "client_id", ",", "client_storage", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "p", "=", "self", ".", "pack", "(", "message_type", ",", "client_id", ",", "client_storage", ",", "args", ...
Publishes a message
[ "Publishes", "a", "message" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/redis.py#L43-L48
florianpaquet/mease
mease/backends/redis.py
RedisSubscriber.connect
def connect(self): """ Connects to Redis """ logger.info("Connecting to Redis on {host}:{port}...".format( host=self.host, port=self.port)) super(RedisSubscriber, self).connect() logger.info("Successfully connected to Redis") # Subscribe to channel ...
python
def connect(self): """ Connects to Redis """ logger.info("Connecting to Redis on {host}:{port}...".format( host=self.host, port=self.port)) super(RedisSubscriber, self).connect() logger.info("Successfully connected to Redis") # Subscribe to channel ...
[ "def", "connect", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Connecting to Redis on {host}:{port}...\"", ".", "format", "(", "host", "=", "self", ".", "host", ",", "port", "=", "self", ".", "port", ")", ")", "super", "(", "RedisSubscriber", ",",...
Connects to Redis
[ "Connects", "to", "Redis" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/redis.py#L61-L81
florianpaquet/mease
mease/backends/redis.py
RedisSubscriber.listen
def listen(self): """ Listen for messages """ for message in self.pubsub.listen(): if message['type'] == 'message': message_type, client_id, client_storage, args, kwargs = self.unpack( message['data']) self.dispatch_message...
python
def listen(self): """ Listen for messages """ for message in self.pubsub.listen(): if message['type'] == 'message': message_type, client_id, client_storage, args, kwargs = self.unpack( message['data']) self.dispatch_message...
[ "def", "listen", "(", "self", ")", ":", "for", "message", "in", "self", ".", "pubsub", ".", "listen", "(", ")", ":", "if", "message", "[", "'type'", "]", "==", "'message'", ":", "message_type", ",", "client_id", ",", "client_storage", ",", "args", ",",...
Listen for messages
[ "Listen", "for", "messages" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/redis.py#L83-L93
florianpaquet/mease
mease/backends/redis.py
RedisSubscriber.exit
def exit(self): """ Closes the connection """ self.pubsub.unsubscribe() self.client.connection_pool.disconnect() logger.info("Connection to Redis closed")
python
def exit(self): """ Closes the connection """ self.pubsub.unsubscribe() self.client.connection_pool.disconnect() logger.info("Connection to Redis closed")
[ "def", "exit", "(", "self", ")", ":", "self", ".", "pubsub", ".", "unsubscribe", "(", ")", "self", ".", "client", ".", "connection_pool", ".", "disconnect", "(", ")", "logger", ".", "info", "(", "\"Connection to Redis closed\"", ")" ]
Closes the connection
[ "Closes", "the", "connection" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/redis.py#L95-L102
florianpaquet/mease
mease/backends/redis.py
RedisBackend.get_kwargs
def get_kwargs(self): """ Returns kwargs for both publisher and subscriber classes """ return { 'host': self.host, 'port': self.port, 'channel': self.channel, 'password': self.password }
python
def get_kwargs(self): """ Returns kwargs for both publisher and subscriber classes """ return { 'host': self.host, 'port': self.port, 'channel': self.channel, 'password': self.password }
[ "def", "get_kwargs", "(", "self", ")", ":", "return", "{", "'host'", ":", "self", ".", "host", ",", "'port'", ":", "self", ".", "port", ",", "'channel'", ":", "self", ".", "channel", ",", "'password'", ":", "self", ".", "password", "}" ]
Returns kwargs for both publisher and subscriber classes
[ "Returns", "kwargs", "for", "both", "publisher", "and", "subscriber", "classes" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/redis.py#L121-L130
eagleamon/pynetio
setup.py
read
def read(fname): " read the passed file " if exists(fname): return open(join(dirname(__file__), fname)).read()
python
def read(fname): " read the passed file " if exists(fname): return open(join(dirname(__file__), fname)).read()
[ "def", "read", "(", "fname", ")", ":", "if", "exists", "(", "fname", ")", ":", "return", "open", "(", "join", "(", "dirname", "(", "__file__", ")", ",", "fname", ")", ")", ".", "read", "(", ")" ]
read the passed file
[ "read", "the", "passed", "file" ]
train
https://github.com/eagleamon/pynetio/blob/3bc212cae18608de0214b964e395877d3ca4aa7b/setup.py#L7-L10
monkeython/scriba
scriba/schemes/scriba_pop.py
read
def read(url, **args): """Get the object from a ftp URL.""" all_ = args.pop('all', False) password = args.pop('password', '') if not password: raise ValueError('password') try: username, __ = url.username.split(';') except ValueError: username = url.username if not us...
python
def read(url, **args): """Get the object from a ftp URL.""" all_ = args.pop('all', False) password = args.pop('password', '') if not password: raise ValueError('password') try: username, __ = url.username.split(';') except ValueError: username = url.username if not us...
[ "def", "read", "(", "url", ",", "*", "*", "args", ")", ":", "all_", "=", "args", ".", "pop", "(", "'all'", ",", "False", ")", "password", "=", "args", ".", "pop", "(", "'password'", ",", "''", ")", "if", "not", "password", ":", "raise", "ValueErr...
Get the object from a ftp URL.
[ "Get", "the", "object", "from", "a", "ftp", "URL", "." ]
train
https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/schemes/scriba_pop.py#L19-L55
opinkerfi/nago
nago/extensions/checkresults.py
get
def get(): """ Get all nagios status information from a local nagios instance """ livestatus = mk_livestatus() hosts = livestatus.get_hosts() services = livestatus.get_services() result = {} result['hosts'] = hosts result['services'] = services return result
python
def get(): """ Get all nagios status information from a local nagios instance """ livestatus = mk_livestatus() hosts = livestatus.get_hosts() services = livestatus.get_services() result = {} result['hosts'] = hosts result['services'] = services return result
[ "def", "get", "(", ")", ":", "livestatus", "=", "mk_livestatus", "(", ")", "hosts", "=", "livestatus", ".", "get_hosts", "(", ")", "services", "=", "livestatus", ".", "get_services", "(", ")", "result", "=", "{", "}", "result", "[", "'hosts'", "]", "="...
Get all nagios status information from a local nagios instance
[ "Get", "all", "nagios", "status", "information", "from", "a", "local", "nagios", "instance" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/checkresults.py#L19-L28
opinkerfi/nago
nago/extensions/checkresults.py
post
def post(hosts=None, services=None, check_existance=True, create_services=True, create_hosts=False): """ Puts a list of hosts into local instance of nagios checkresults Arguments: hosts -- list of dicts, like one obtained from get_checkresults services -- list of dicts, like...
python
def post(hosts=None, services=None, check_existance=True, create_services=True, create_hosts=False): """ Puts a list of hosts into local instance of nagios checkresults Arguments: hosts -- list of dicts, like one obtained from get_checkresults services -- list of dicts, like...
[ "def", "post", "(", "hosts", "=", "None", ",", "services", "=", "None", ",", "check_existance", "=", "True", ",", "create_services", "=", "True", ",", "create_hosts", "=", "False", ")", ":", "nagios_config", "=", "config", "(", ")", "nagios_config", ".", ...
Puts a list of hosts into local instance of nagios checkresults Arguments: hosts -- list of dicts, like one obtained from get_checkresults services -- list of dicts, like one obtained from get_checkresults check_existance -- If True, check (and log) if objects already ...
[ "Puts", "a", "list", "of", "hosts", "into", "local", "instance", "of", "nagios", "checkresults", "Arguments", ":", "hosts", "--", "list", "of", "dicts", "like", "one", "obtained", "from", "get_checkresults", "services", "--", "list", "of", "dicts", "like", "...
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/checkresults.py#L31-L69
opinkerfi/nago
nago/extensions/checkresults.py
send
def send(remote_host=None): """ Send local nagios data to a remote nago instance """ my_data = get() if not remote_host: remote_host = nago.extensions.settings.get('server') remote_node = nago.core.get_node(remote_host) remote_node.send_command('checkresults', 'post', **my_data) return "...
python
def send(remote_host=None): """ Send local nagios data to a remote nago instance """ my_data = get() if not remote_host: remote_host = nago.extensions.settings.get('server') remote_node = nago.core.get_node(remote_host) remote_node.send_command('checkresults', 'post', **my_data) return "...
[ "def", "send", "(", "remote_host", "=", "None", ")", ":", "my_data", "=", "get", "(", ")", "if", "not", "remote_host", ":", "remote_host", "=", "nago", ".", "extensions", ".", "settings", ".", "get", "(", "'server'", ")", "remote_node", "=", "nago", "....
Send local nagios data to a remote nago instance
[ "Send", "local", "nagios", "data", "to", "a", "remote", "nago", "instance" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/checkresults.py#L72-L79
opinkerfi/nago
nago/extensions/checkresults.py
_format_checkresult
def _format_checkresult(**kwargs): """ Returns a string in a nagios "checkresults" compatible format """ o = {} o['check_type'] = '1' o['check_options'] = '0' o['scheduled_check'] = '1' o['reschedule_check'] = '1' o['latency'] = '0.0' o['start_time'] = '%5f' % time.time() o['finish_t...
python
def _format_checkresult(**kwargs): """ Returns a string in a nagios "checkresults" compatible format """ o = {} o['check_type'] = '1' o['check_options'] = '0' o['scheduled_check'] = '1' o['reschedule_check'] = '1' o['latency'] = '0.0' o['start_time'] = '%5f' % time.time() o['finish_t...
[ "def", "_format_checkresult", "(", "*", "*", "kwargs", ")", ":", "o", "=", "{", "}", "o", "[", "'check_type'", "]", "=", "'1'", "o", "[", "'check_options'", "]", "=", "'0'", "o", "[", "'scheduled_check'", "]", "=", "'1'", "o", "[", "'reschedule_check'"...
Returns a string in a nagios "checkresults" compatible format
[ "Returns", "a", "string", "in", "a", "nagios", "checkresults", "compatible", "format" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/checkresults.py#L89-L132
tempodb/tempodb-python
tempodb/protocol/objects.py
JSONSerializable.from_json
def from_json(self, json_text): """Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object ...
python
def from_json(self, json_text): """Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object ...
[ "def", "from_json", "(", "self", ",", "json_text", ")", ":", "#due to the architecture of response parsing, particularly", "#where the API returns lists, the JSON might have already been", "#parsed by the time it gets here", "if", "type", "(", "json_text", ")", "in", "[", "str", ...
Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object to deserialize from :type json_text...
[ "Deserialize", "a", "JSON", "object", "into", "this", "object", ".", "This", "method", "will", "check", "that", "the", "JSON", "object", "has", "the", "required", "keys", "and", "will", "set", "each", "of", "the", "keys", "in", "that", "JSON", "object", ...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L33-L57
tempodb/tempodb-python
tempodb/protocol/objects.py
JSONSerializable.to_json
def to_json(self): """Serialize an object to JSON based on its "properties" class attribute. :rtype: string""" j = {} for p in self.properties: j[p] = getattr(self, p) return json.dumps(j)
python
def to_json(self): """Serialize an object to JSON based on its "properties" class attribute. :rtype: string""" j = {} for p in self.properties: j[p] = getattr(self, p) return json.dumps(j)
[ "def", "to_json", "(", "self", ")", ":", "j", "=", "{", "}", "for", "p", "in", "self", ".", "properties", ":", "j", "[", "p", "]", "=", "getattr", "(", "self", ",", "p", ")", "return", "json", ".", "dumps", "(", "j", ")" ]
Serialize an object to JSON based on its "properties" class attribute. :rtype: string
[ "Serialize", "an", "object", "to", "JSON", "based", "on", "its", "properties", "class", "attribute", "." ]
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L59-L69
tempodb/tempodb-python
tempodb/protocol/objects.py
JSONSerializable.to_dictionary
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
python
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
[ "def", "to_dictionary", "(", "self", ")", ":", "j", "=", "{", "}", "for", "p", "in", "self", ".", "properties", ":", "j", "[", "p", "]", "=", "getattr", "(", "self", ",", "p", ")", "return", "j" ]
Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string.
[ "Serialize", "an", "object", "into", "dictionary", "form", ".", "Useful", "if", "you", "have", "to", "serialize", "an", "array", "of", "objects", "into", "JSON", ".", "Otherwise", "if", "you", "call", "the", ":", "meth", ":", "to_json", "method", "on", "...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L71-L81
tempodb/tempodb-python
tempodb/protocol/objects.py
SingleValue.to_dictionary
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
python
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
[ "def", "to_dictionary", "(", "self", ")", ":", "j", "=", "{", "}", "j", "[", "'series'", "]", "=", "self", ".", "series", ".", "to_dictionary", "(", ")", "j", "[", "'data'", "]", "=", "self", ".", "data", ".", "to_dictionary", "(", ")", "return", ...
Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string.
[ "Serialize", "an", "object", "into", "dictionary", "form", ".", "Useful", "if", "you", "have", "to", "serialize", "an", "array", "of", "objects", "into", "JSON", ".", "Otherwise", "if", "you", "call", "the", ":", "meth", ":", "to_json", "method", "on", "...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L166-L175
tempodb/tempodb-python
tempodb/protocol/objects.py
SeriesSummary.to_dictionary
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
python
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
[ "def", "to_dictionary", "(", "self", ")", ":", "d", "=", "{", "'start'", ":", "self", ".", "start", ".", "isoformat", "(", ")", ",", "'end'", ":", "self", ".", "end", ".", "isoformat", "(", ")", ",", "'tz'", ":", "self", ".", "tz", ",", "'summary...
Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string.
[ "Serialize", "an", "object", "into", "dictionary", "form", ".", "Useful", "if", "you", "have", "to", "serialize", "an", "array", "of", "objects", "into", "JSON", ".", "Otherwise", "if", "you", "call", "the", ":", "meth", ":", "to_json", "method", "on", "...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L229-L241
tempodb/tempodb-python
tempodb/protocol/objects.py
DataPoint.from_data
def from_data(self, time, value, series_id=None, key=None, tz=None): """Create a DataPoint object from data, rather than a JSON object or string. This should be used by user code to construct DataPoints from Python-based data like Datetime objects and floats. The series_id and key argu...
python
def from_data(self, time, value, series_id=None, key=None, tz=None): """Create a DataPoint object from data, rather than a JSON object or string. This should be used by user code to construct DataPoints from Python-based data like Datetime objects and floats. The series_id and key argu...
[ "def", "from_data", "(", "self", ",", "time", ",", "value", ",", "series_id", "=", "None", ",", "key", "=", "None", ",", "tz", "=", "None", ")", ":", "t", "=", "check_time_param", "(", "time", ")", "if", "type", "(", "value", ")", "in", "[", "flo...
Create a DataPoint object from data, rather than a JSON object or string. This should be used by user code to construct DataPoints from Python-based data like Datetime objects and floats. The series_id and key arguments are only necessary if you are doing a multi write, in which case t...
[ "Create", "a", "DataPoint", "object", "from", "data", "rather", "than", "a", "JSON", "object", "or", "string", ".", "This", "should", "be", "used", "by", "user", "code", "to", "construct", "DataPoints", "from", "Python", "-", "based", "data", "like", "Date...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L277-L312
tempodb/tempodb-python
tempodb/protocol/objects.py
DataPoint.to_dictionary
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
python
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
[ "def", "to_dictionary", "(", "self", ")", ":", "j", "=", "{", "}", "for", "p", "in", "self", ".", "properties", ":", "try", ":", "v", "=", "getattr", "(", "self", ",", "p", ")", "except", "AttributeError", ":", "continue", "if", "v", "is", "not", ...
Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string.
[ "Serialize", "an", "object", "into", "dictionary", "form", ".", "Useful", "if", "you", "have", "to", "serialize", "an", "array", "of", "objects", "into", "JSON", ".", "Otherwise", "if", "you", "call", "the", ":", "meth", ":", "to_json", "method", "on", "...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L365-L383
tempodb/tempodb-python
tempodb/protocol/objects.py
DataPointFound.from_json
def from_json(self, json_text): """Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object ...
python
def from_json(self, json_text): """Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object ...
[ "def", "from_json", "(", "self", ",", "json_text", ")", ":", "if", "type", "(", "json_text", ")", "in", "[", "str", ",", "unicode", "]", ":", "j", "=", "json", ".", "loads", "(", "json_text", ")", "else", ":", "j", "=", "json_text", "try", ":", "...
Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object to deserialize from :type json_text...
[ "Deserialize", "a", "JSON", "object", "into", "this", "object", ".", "This", "method", "will", "check", "that", "the", "JSON", "object", "has", "the", "required", "keys", "and", "will", "set", "each", "of", "the", "keys", "in", "that", "JSON", "object", ...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L406-L436
tempodb/tempodb-python
tempodb/protocol/objects.py
DataPointFound.to_dictionary
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
python
def to_dictionary(self): """Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string."""...
[ "def", "to_dictionary", "(", "self", ")", ":", "j", "=", "{", "}", "j", "[", "'interval'", "]", "=", "{", "'start'", ":", "self", ".", "start", ".", "isoformat", "(", ")", ",", "'end'", ":", "self", ".", "end", ".", "isoformat", "(", ")", "}", ...
Serialize an object into dictionary form. Useful if you have to serialize an array of objects into JSON. Otherwise, if you call the :meth:`to_json` method on each object in the list and then try to dump the array, you end up with an array with one string.
[ "Serialize", "an", "object", "into", "dictionary", "form", ".", "Useful", "if", "you", "have", "to", "serialize", "an", "array", "of", "objects", "into", "JSON", ".", "Otherwise", "if", "you", "call", "the", ":", "meth", ":", "to_json", "method", "on", "...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L438-L448
tempodb/tempodb-python
tempodb/protocol/objects.py
MultiPoint.from_json
def from_json(self, json_text): """Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object ...
python
def from_json(self, json_text): """Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object ...
[ "def", "from_json", "(", "self", ",", "json_text", ")", ":", "if", "type", "(", "json_text", ")", "in", "[", "str", ",", "unicode", "]", ":", "j", "=", "json", ".", "loads", "(", "json_text", ")", "else", ":", "j", "=", "json_text", "try", ":", "...
Deserialize a JSON object into this object. This method will check that the JSON object has the required keys and will set each of the keys in that JSON object as an instance attribute of this object. :param json_text: the JSON text or object to deserialize from :type json_text...
[ "Deserialize", "a", "JSON", "object", "into", "this", "object", ".", "This", "method", "will", "check", "that", "the", "JSON", "object", "has", "the", "required", "keys", "and", "will", "set", "each", "of", "the", "keys", "in", "that", "JSON", "object", ...
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L475-L502
tempodb/tempodb-python
tempodb/protocol/objects.py
MultiPoint.to_json
def to_json(self): """Serialize an object to JSON based on its "properties" class attribute. :rtype: string""" j = {} for p in self.properties: try: v = getattr(self, p) except AttributeError: continue if v is ...
python
def to_json(self): """Serialize an object to JSON based on its "properties" class attribute. :rtype: string""" j = {} for p in self.properties: try: v = getattr(self, p) except AttributeError: continue if v is ...
[ "def", "to_json", "(", "self", ")", ":", "j", "=", "{", "}", "for", "p", "in", "self", ".", "properties", ":", "try", ":", "v", "=", "getattr", "(", "self", ",", "p", ")", "except", "AttributeError", ":", "continue", "if", "v", "is", "not", "None...
Serialize an object to JSON based on its "properties" class attribute. :rtype: string
[ "Serialize", "an", "object", "to", "JSON", "based", "on", "its", "properties", "class", "attribute", "." ]
train
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L504-L522
jmgilman/Neolib
neolib/pyamf/util/pure.py
StringIOProxy.read
def read(self, n=-1): """ Reads C{n} bytes from the stream. """ if n < -1: raise IOError('Cannot read backwards') bytes = self._buffer.read(n) return bytes
python
def read(self, n=-1): """ Reads C{n} bytes from the stream. """ if n < -1: raise IOError('Cannot read backwards') bytes = self._buffer.read(n) return bytes
[ "def", "read", "(", "self", ",", "n", "=", "-", "1", ")", ":", "if", "n", "<", "-", "1", ":", "raise", "IOError", "(", "'Cannot read backwards'", ")", "bytes", "=", "self", ".", "_buffer", ".", "read", "(", "n", ")", "return", "bytes" ]
Reads C{n} bytes from the stream.
[ "Reads", "C", "{", "n", "}", "bytes", "from", "the", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L65-L74
jmgilman/Neolib
neolib/pyamf/util/pure.py
StringIOProxy.truncate
def truncate(self, size=0): """ Truncates the stream to the specified length. @param size: The length of the stream, in bytes. @type size: C{int} """ if size == 0: self._buffer = StringIO() self._len_changed = True return cur...
python
def truncate(self, size=0): """ Truncates the stream to the specified length. @param size: The length of the stream, in bytes. @type size: C{int} """ if size == 0: self._buffer = StringIO() self._len_changed = True return cur...
[ "def", "truncate", "(", "self", ",", "size", "=", "0", ")", ":", "if", "size", "==", "0", ":", "self", ".", "_buffer", "=", "StringIO", "(", ")", "self", ".", "_len_changed", "=", "True", "return", "cur_pos", "=", "self", ".", "tell", "(", ")", "...
Truncates the stream to the specified length. @param size: The length of the stream, in bytes. @type size: C{int}
[ "Truncates", "the", "stream", "to", "the", "specified", "length", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L94-L114
jmgilman/Neolib
neolib/pyamf/util/pure.py
StringIOProxy.write
def write(self, s, size=None): """ Writes the content of the specified C{s} into this buffer. @param s: Raw bytes """ self._buffer.write(s) self._len_changed = True
python
def write(self, s, size=None): """ Writes the content of the specified C{s} into this buffer. @param s: Raw bytes """ self._buffer.write(s) self._len_changed = True
[ "def", "write", "(", "self", ",", "s", ",", "size", "=", "None", ")", ":", "self", ".", "_buffer", ".", "write", "(", "s", ")", "self", ".", "_len_changed", "=", "True" ]
Writes the content of the specified C{s} into this buffer. @param s: Raw bytes
[ "Writes", "the", "content", "of", "the", "specified", "C", "{", "s", "}", "into", "this", "buffer", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L116-L123
jmgilman/Neolib
neolib/pyamf/util/pure.py
StringIOProxy._get_len
def _get_len(self): """ Return total number of bytes in buffer. """ if hasattr(self._buffer, 'len'): self._len = self._buffer.len return old_pos = self._buffer.tell() self._buffer.seek(0, 2) self._len = self._buffer.tell() self._...
python
def _get_len(self): """ Return total number of bytes in buffer. """ if hasattr(self._buffer, 'len'): self._len = self._buffer.len return old_pos = self._buffer.tell() self._buffer.seek(0, 2) self._len = self._buffer.tell() self._...
[ "def", "_get_len", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "_buffer", ",", "'len'", ")", ":", "self", ".", "_len", "=", "self", ".", "_buffer", ".", "len", "return", "old_pos", "=", "self", ".", "_buffer", ".", "tell", "(", ")", ...
Return total number of bytes in buffer.
[ "Return", "total", "number", "of", "bytes", "in", "buffer", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L125-L138
jmgilman/Neolib
neolib/pyamf/util/pure.py
StringIOProxy.consume
def consume(self): """ Chops the tail off the stream starting at 0 and ending at C{tell()}. The stream pointer is set to 0 at the end of this function. @since: 0.4 """ try: bytes = self.read() except IOError: bytes = '' self.trunc...
python
def consume(self): """ Chops the tail off the stream starting at 0 and ending at C{tell()}. The stream pointer is set to 0 at the end of this function. @since: 0.4 """ try: bytes = self.read() except IOError: bytes = '' self.trunc...
[ "def", "consume", "(", "self", ")", ":", "try", ":", "bytes", "=", "self", ".", "read", "(", ")", "except", "IOError", ":", "bytes", "=", "''", "self", ".", "truncate", "(", ")", "if", "len", "(", "bytes", ")", ">", "0", ":", "self", ".", "writ...
Chops the tail off the stream starting at 0 and ending at C{tell()}. The stream pointer is set to 0 at the end of this function. @since: 0.4
[ "Chops", "the", "tail", "off", "the", "stream", "starting", "at", "0", "and", "ending", "at", "C", "{", "tell", "()", "}", ".", "The", "stream", "pointer", "is", "set", "to", "0", "at", "the", "end", "of", "this", "function", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L149-L165
jmgilman/Neolib
neolib/pyamf/util/pure.py
DataTypeMixIn._read
def _read(self, length): """ Reads C{length} bytes from the stream. If an attempt to read past the end of the buffer is made, L{IOError} is raised. """ bytes = self.read(length) if len(bytes) != length: self.seek(0 - len(bytes), 1) raise IOError(...
python
def _read(self, length): """ Reads C{length} bytes from the stream. If an attempt to read past the end of the buffer is made, L{IOError} is raised. """ bytes = self.read(length) if len(bytes) != length: self.seek(0 - len(bytes), 1) raise IOError(...
[ "def", "_read", "(", "self", ",", "length", ")", ":", "bytes", "=", "self", ".", "read", "(", "length", ")", "if", "len", "(", "bytes", ")", "!=", "length", ":", "self", ".", "seek", "(", "0", "-", "len", "(", "bytes", ")", ",", "1", ")", "ra...
Reads C{length} bytes from the stream. If an attempt to read past the end of the buffer is made, L{IOError} is raised.
[ "Reads", "C", "{", "length", "}", "bytes", "from", "the", "stream", ".", "If", "an", "attempt", "to", "read", "past", "the", "end", "of", "the", "buffer", "is", "made", "L", "{", "IOError", "}", "is", "raised", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L189-L201
jmgilman/Neolib
neolib/pyamf/util/pure.py
DataTypeMixIn._is_big_endian
def _is_big_endian(self): """ Whether the current endian is big endian. """ if self.endian == DataTypeMixIn.ENDIAN_NATIVE: return SYSTEM_ENDIAN == DataTypeMixIn.ENDIAN_BIG return self.endian in (DataTypeMixIn.ENDIAN_BIG, DataTypeMixIn.ENDIAN_NETWORK)
python
def _is_big_endian(self): """ Whether the current endian is big endian. """ if self.endian == DataTypeMixIn.ENDIAN_NATIVE: return SYSTEM_ENDIAN == DataTypeMixIn.ENDIAN_BIG return self.endian in (DataTypeMixIn.ENDIAN_BIG, DataTypeMixIn.ENDIAN_NETWORK)
[ "def", "_is_big_endian", "(", "self", ")", ":", "if", "self", ".", "endian", "==", "DataTypeMixIn", ".", "ENDIAN_NATIVE", ":", "return", "SYSTEM_ENDIAN", "==", "DataTypeMixIn", ".", "ENDIAN_BIG", "return", "self", ".", "endian", "in", "(", "DataTypeMixIn", "."...
Whether the current endian is big endian.
[ "Whether", "the", "current", "endian", "is", "big", "endian", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L203-L210
jmgilman/Neolib
neolib/pyamf/util/pure.py
DataTypeMixIn.write_uchar
def write_uchar(self, c): """ Writes an C{unsigned char} to the stream. @param c: Unsigned char @type c: C{int} @raise TypeError: Unexpected type for int C{c}. @raise OverflowError: Not in range. """ if type(c) not in python.int_types: raise T...
python
def write_uchar(self, c): """ Writes an C{unsigned char} to the stream. @param c: Unsigned char @type c: C{int} @raise TypeError: Unexpected type for int C{c}. @raise OverflowError: Not in range. """ if type(c) not in python.int_types: raise T...
[ "def", "write_uchar", "(", "self", ",", "c", ")", ":", "if", "type", "(", "c", ")", "not", "in", "python", ".", "int_types", ":", "raise", "TypeError", "(", "'expected an int (got:%r)'", "%", "type", "(", "c", ")", ")", "if", "not", "0", "<=", "c", ...
Writes an C{unsigned char} to the stream. @param c: Unsigned char @type c: C{int} @raise TypeError: Unexpected type for int C{c}. @raise OverflowError: Not in range.
[ "Writes", "an", "C", "{", "unsigned", "char", "}", "to", "the", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L218-L233
jmgilman/Neolib
neolib/pyamf/util/pure.py
DataTypeMixIn.write_ushort
def write_ushort(self, s): """ Writes a 2 byte unsigned integer to the stream. @param s: 2 byte unsigned integer @type s: C{int} @raise TypeError: Unexpected type for int C{s}. @raise OverflowError: Not in range. """ if type(s) not in python.int_types: ...
python
def write_ushort(self, s): """ Writes a 2 byte unsigned integer to the stream. @param s: 2 byte unsigned integer @type s: C{int} @raise TypeError: Unexpected type for int C{s}. @raise OverflowError: Not in range. """ if type(s) not in python.int_types: ...
[ "def", "write_ushort", "(", "self", ",", "s", ")", ":", "if", "type", "(", "s", ")", "not", "in", "python", ".", "int_types", ":", "raise", "TypeError", "(", "'expected an int (got:%r)'", "%", "(", "type", "(", "s", ")", ",", ")", ")", "if", "not", ...
Writes a 2 byte unsigned integer to the stream. @param s: 2 byte unsigned integer @type s: C{int} @raise TypeError: Unexpected type for int C{s}. @raise OverflowError: Not in range.
[ "Writes", "a", "2", "byte", "unsigned", "integer", "to", "the", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L264-L279
jmgilman/Neolib
neolib/pyamf/util/pure.py
DataTypeMixIn.write_ulong
def write_ulong(self, l): """ Writes a 4 byte unsigned integer to the stream. @param l: 4 byte unsigned integer @type l: C{int} @raise TypeError: Unexpected type for int C{l}. @raise OverflowError: Not in range. """ if type(l) not in python.int_types: ...
python
def write_ulong(self, l): """ Writes a 4 byte unsigned integer to the stream. @param l: 4 byte unsigned integer @type l: C{int} @raise TypeError: Unexpected type for int C{l}. @raise OverflowError: Not in range. """ if type(l) not in python.int_types: ...
[ "def", "write_ulong", "(", "self", ",", "l", ")", ":", "if", "type", "(", "l", ")", "not", "in", "python", ".", "int_types", ":", "raise", "TypeError", "(", "'expected an int (got:%r)'", "%", "(", "type", "(", "l", ")", ",", ")", ")", "if", "not", ...
Writes a 4 byte unsigned integer to the stream. @param l: 4 byte unsigned integer @type l: C{int} @raise TypeError: Unexpected type for int C{l}. @raise OverflowError: Not in range.
[ "Writes", "a", "4", "byte", "unsigned", "integer", "to", "the", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L310-L325