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
krukas/Trionyx
trionyx/layout.py
ComponentFieldsMixin.get_fields
def get_fields(self): """Get all fields""" if not hasattr(self, '__fields'): self.__fields = [ self.parse_field(field, index) for index, field in enumerate(getattr(self, 'fields', [])) ] return self.__fields
python
def get_fields(self): """Get all fields""" if not hasattr(self, '__fields'): self.__fields = [ self.parse_field(field, index) for index, field in enumerate(getattr(self, 'fields', [])) ] return self.__fields
[ "def", "get_fields", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'__fields'", ")", ":", "self", ".", "__fields", "=", "[", "self", ".", "parse_field", "(", "field", ",", "index", ")", "for", "index", ",", "field", "in", "enumera...
Get all fields
[ "Get", "all", "fields" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L194-L201
krukas/Trionyx
trionyx/layout.py
ComponentFieldsMixin.parse_field
def parse_field(self, field_data, index=0): """Parse field and add missing options""" field = { '__index__': index, } if isinstance(field_data, str): field.update(self.parse_string_field(field_data)) elif isinstance(field_data, dict): field.up...
python
def parse_field(self, field_data, index=0): """Parse field and add missing options""" field = { '__index__': index, } if isinstance(field_data, str): field.update(self.parse_string_field(field_data)) elif isinstance(field_data, dict): field.up...
[ "def", "parse_field", "(", "self", ",", "field_data", ",", "index", "=", "0", ")", ":", "field", "=", "{", "'__index__'", ":", "index", ",", "}", "if", "isinstance", "(", "field_data", ",", "str", ")", ":", "field", ".", "update", "(", "self", ".", ...
Parse field and add missing options
[ "Parse", "field", "and", "add", "missing", "options" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L203-L235
krukas/Trionyx
trionyx/layout.py
ComponentFieldsMixin.parse_string_field
def parse_string_field(self, field_data): """ Parse a string field to dict with options String value is used as field name. Options can be given after = symbol. Where key value is separated by : and different options by ;, when no : is used then the value becomes True. **Exampl...
python
def parse_string_field(self, field_data): """ Parse a string field to dict with options String value is used as field name. Options can be given after = symbol. Where key value is separated by : and different options by ;, when no : is used then the value becomes True. **Exampl...
[ "def", "parse_string_field", "(", "self", ",", "field_data", ")", ":", "field_name", ",", "", "*", "data", "=", "field_data", ".", "split", "(", "'='", ",", "1", ")", "field", "=", "{", "'field'", ":", "field_name", ",", "}", "for", "option_string", "i...
Parse a string field to dict with options String value is used as field name. Options can be given after = symbol. Where key value is separated by : and different options by ;, when no : is used then the value becomes True. **Example 1:** `field_name` .. code-block:: python ...
[ "Parse", "a", "string", "field", "to", "dict", "with", "options" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L237-L288
krukas/Trionyx
trionyx/layout.py
ComponentFieldsMixin.render_field
def render_field(self, field, data): """Render field for given data""" from trionyx.renderer import renderer if 'value' in field: value = field['value'] elif isinstance(data, object) and hasattr(data, field['field']): value = getattr(data, field['field']) ...
python
def render_field(self, field, data): """Render field for given data""" from trionyx.renderer import renderer if 'value' in field: value = field['value'] elif isinstance(data, object) and hasattr(data, field['field']): value = getattr(data, field['field']) ...
[ "def", "render_field", "(", "self", ",", "field", ",", "data", ")", ":", "from", "trionyx", ".", "renderer", "import", "renderer", "if", "'value'", "in", "field", ":", "value", "=", "field", "[", "'value'", "]", "elif", "isinstance", "(", "data", ",", ...
Render field for given data
[ "Render", "field", "for", "given", "data" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L290-L313
krukas/Trionyx
trionyx/layout.py
ComponentFieldsMixin.get_rendered_object
def get_rendered_object(self, obj=None): """Render object""" obj = obj if obj else self.object return [ { **field, 'value': self.render_field(field, obj) } for field in self.get_fields() ]
python
def get_rendered_object(self, obj=None): """Render object""" obj = obj if obj else self.object return [ { **field, 'value': self.render_field(field, obj) } for field in self.get_fields() ]
[ "def", "get_rendered_object", "(", "self", ",", "obj", "=", "None", ")", ":", "obj", "=", "obj", "if", "obj", "else", "self", ".", "object", "return", "[", "{", "*", "*", "field", ",", "'value'", ":", "self", ".", "render_field", "(", "field", ",", ...
Render object
[ "Render", "object" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L315-L324
krukas/Trionyx
trionyx/layout.py
ComponentFieldsMixin.get_rendered_objects
def get_rendered_objects(self): """Render objects""" objects = self.objects if isinstance(objects, str): objects = getattr(self.object, objects).all() return [ self.get_rendered_object(obj) for obj in objects ]
python
def get_rendered_objects(self): """Render objects""" objects = self.objects if isinstance(objects, str): objects = getattr(self.object, objects).all() return [ self.get_rendered_object(obj) for obj in objects ]
[ "def", "get_rendered_objects", "(", "self", ")", ":", "objects", "=", "self", ".", "objects", "if", "isinstance", "(", "objects", ",", "str", ")", ":", "objects", "=", "getattr", "(", "self", ".", "object", ",", "objects", ")", ".", "all", "(", ")", ...
Render objects
[ "Render", "objects" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L326-L336
krukas/Trionyx
trionyx/layout.py
HtmlTagWrapper.get_attr_text
def get_attr_text(self): """Get html attr text to render in template""" return ' '.join([ '{}="{}"'.format(key, value) for key, value in self.attr.items() ])
python
def get_attr_text(self): """Get html attr text to render in template""" return ' '.join([ '{}="{}"'.format(key, value) for key, value in self.attr.items() ])
[ "def", "get_attr_text", "(", "self", ")", ":", "return", "' '", ".", "join", "(", "[", "'{}=\"{}\"'", ".", "format", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "self", ".", "attr", ".", "items", "(", ")", "]", ")" ]
Get html attr text to render in template
[ "Get", "html", "attr", "text", "to", "render", "in", "template" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L358-L363
shi-cong/PYSTUDY
PYSTUDY/timelib.py
func_runtime
def func_runtime(callback): """ 测试函数执行的时间 :param callback: 函数 :return: 时间 """ now = time.time() print('%s - start: %f' % (callback, now)) callback() now = time.time() - now print('%s - spent: %f Second' % (callback, now))
python
def func_runtime(callback): """ 测试函数执行的时间 :param callback: 函数 :return: 时间 """ now = time.time() print('%s - start: %f' % (callback, now)) callback() now = time.time() - now print('%s - spent: %f Second' % (callback, now))
[ "def", "func_runtime", "(", "callback", ")", ":", "now", "=", "time", ".", "time", "(", ")", "print", "(", "'%s - start: %f'", "%", "(", "callback", ",", "now", ")", ")", "callback", "(", ")", "now", "=", "time", ".", "time", "(", ")", "-", "now", ...
测试函数执行的时间 :param callback: 函数 :return: 时间
[ "测试函数执行的时间", ":", "param", "callback", ":", "函数", ":", "return", ":", "时间" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/timelib.py#L7-L17
pbacterio/dj-paas-env
dj_paas_env/database.py
data_dir
def data_dir(default='data'): """ Return persistent data directory or ``default`` if not found Warning: Do not use this directory to store sqlite databases in producction """ if 'OPENSHIFT_DATA_DIR' in os.environ: return os.environ['OPENSHIFT_DATA_DIR'] if 'GONDOR_DATA_DIR' in os.environ...
python
def data_dir(default='data'): """ Return persistent data directory or ``default`` if not found Warning: Do not use this directory to store sqlite databases in producction """ if 'OPENSHIFT_DATA_DIR' in os.environ: return os.environ['OPENSHIFT_DATA_DIR'] if 'GONDOR_DATA_DIR' in os.environ...
[ "def", "data_dir", "(", "default", "=", "'data'", ")", ":", "if", "'OPENSHIFT_DATA_DIR'", "in", "os", ".", "environ", ":", "return", "os", ".", "environ", "[", "'OPENSHIFT_DATA_DIR'", "]", "if", "'GONDOR_DATA_DIR'", "in", "os", ".", "environ", ":", "return",...
Return persistent data directory or ``default`` if not found Warning: Do not use this directory to store sqlite databases in producction
[ "Return", "persistent", "data", "directory", "or", "default", "if", "not", "found", "Warning", ":", "Do", "not", "use", "this", "directory", "to", "store", "sqlite", "databases", "in", "producction" ]
train
https://github.com/pbacterio/dj-paas-env/blob/1f86bf0a0253cac9eae2442b1e3a8643426077b4/dj_paas_env/database.py#L70-L81
maceoutliner/django-fiction-outlines
fiction_outlines/forms.py
OutlineMoveNodeForm.mk_dropdown_tree
def mk_dropdown_tree(cls, model, root_node, for_node=None): ''' Override of ``treebeard`` method to enforce the same root. ''' options = [] # The difference is that we only generate the subtree for the current root. logger.debug("Using root node pk of %s" % root_node.pk) ...
python
def mk_dropdown_tree(cls, model, root_node, for_node=None): ''' Override of ``treebeard`` method to enforce the same root. ''' options = [] # The difference is that we only generate the subtree for the current root. logger.debug("Using root node pk of %s" % root_node.pk) ...
[ "def", "mk_dropdown_tree", "(", "cls", ",", "model", ",", "root_node", ",", "for_node", "=", "None", ")", ":", "options", "=", "[", "]", "# The difference is that we only generate the subtree for the current root.", "logger", ".", "debug", "(", "\"Using root node pk of ...
Override of ``treebeard`` method to enforce the same root.
[ "Override", "of", "treebeard", "method", "to", "enforce", "the", "same", "root", "." ]
train
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/forms.py#L88-L96
olsoneric/pedemath
pedemath/vec2.py
angle_v2_rad
def angle_v2_rad(vec_a, vec_b): """Returns angle between vec_a and vec_b in range [0, PI]. This does not distinguish if a is left of or right of b. """ # cos(x) = A * B / |A| * |B| return math.acos(vec_a.dot(vec_b) / (vec_a.length() * vec_b.length()))
python
def angle_v2_rad(vec_a, vec_b): """Returns angle between vec_a and vec_b in range [0, PI]. This does not distinguish if a is left of or right of b. """ # cos(x) = A * B / |A| * |B| return math.acos(vec_a.dot(vec_b) / (vec_a.length() * vec_b.length()))
[ "def", "angle_v2_rad", "(", "vec_a", ",", "vec_b", ")", ":", "# cos(x) = A * B / |A| * |B|", "return", "math", ".", "acos", "(", "vec_a", ".", "dot", "(", "vec_b", ")", "/", "(", "vec_a", ".", "length", "(", ")", "*", "vec_b", ".", "length", "(", ")", ...
Returns angle between vec_a and vec_b in range [0, PI]. This does not distinguish if a is left of or right of b.
[ "Returns", "angle", "between", "vec_a", "and", "vec_b", "in", "range", "[", "0", "PI", "]", ".", "This", "does", "not", "distinguish", "if", "a", "is", "left", "of", "or", "right", "of", "b", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L23-L28
olsoneric/pedemath
pedemath/vec2.py
angle_v2_rad_dir
def angle_v2_rad_dir(vec_a, vec_b): """Returns angle between vec_a and vec_b in range [-PI, PI]. This indicates if vec_a is left of or right of vec_b. vec_a is the base vector that the returned angle will be based off of. e.g. if vec_b is to the right (clockwise) of vec_a, the angle will be negati...
python
def angle_v2_rad_dir(vec_a, vec_b): """Returns angle between vec_a and vec_b in range [-PI, PI]. This indicates if vec_a is left of or right of vec_b. vec_a is the base vector that the returned angle will be based off of. e.g. if vec_b is to the right (clockwise) of vec_a, the angle will be negati...
[ "def", "angle_v2_rad_dir", "(", "vec_a", ",", "vec_b", ")", ":", "# cos(x) = A * B / |A| * |B|", "rads", "=", "math", ".", "acos", "(", "vec_a", ".", "dot", "(", "vec_b", ")", "/", "(", "vec_a", ".", "length", "(", ")", "*", "vec_b", ".", "length", "("...
Returns angle between vec_a and vec_b in range [-PI, PI]. This indicates if vec_a is left of or right of vec_b. vec_a is the base vector that the returned angle will be based off of. e.g. if vec_b is to the right (clockwise) of vec_a, the angle will be negative. (note line about angle dir below) ...
[ "Returns", "angle", "between", "vec_a", "and", "vec_b", "in", "range", "[", "-", "PI", "PI", "]", ".", "This", "indicates", "if", "vec_a", "is", "left", "of", "or", "right", "of", "vec_b", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L31-L47
olsoneric/pedemath
pedemath/vec2.py
rot_rads_v2
def rot_rads_v2(vec_a, rads): """ Rotate vector by angle in radians.""" x = vec_a.x * math.cos(rads) - vec_a.y * math.sin(rads) y = vec_a.x * math.sin(rads) + vec_a.y * math.cos(rads) return Vec2(x, y)
python
def rot_rads_v2(vec_a, rads): """ Rotate vector by angle in radians.""" x = vec_a.x * math.cos(rads) - vec_a.y * math.sin(rads) y = vec_a.x * math.sin(rads) + vec_a.y * math.cos(rads) return Vec2(x, y)
[ "def", "rot_rads_v2", "(", "vec_a", ",", "rads", ")", ":", "x", "=", "vec_a", ".", "x", "*", "math", ".", "cos", "(", "rads", ")", "-", "vec_a", ".", "y", "*", "math", ".", "sin", "(", "rads", ")", "y", "=", "vec_a", ".", "x", "*", "math", ...
Rotate vector by angle in radians.
[ "Rotate", "vector", "by", "angle", "in", "radians", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L50-L55
olsoneric/pedemath
pedemath/vec2.py
scale_v2
def scale_v2(vec, amount): """Return a new Vec2 with x and y from vec and multiplied by amount.""" return Vec2(vec.x * amount, vec.y * amount)
python
def scale_v2(vec, amount): """Return a new Vec2 with x and y from vec and multiplied by amount.""" return Vec2(vec.x * amount, vec.y * amount)
[ "def", "scale_v2", "(", "vec", ",", "amount", ")", ":", "return", "Vec2", "(", "vec", ".", "x", "*", "amount", ",", "vec", ".", "y", "*", "amount", ")" ]
Return a new Vec2 with x and y from vec and multiplied by amount.
[ "Return", "a", "new", "Vec2", "with", "x", "and", "y", "from", "vec", "and", "multiplied", "by", "amount", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L58-L61
olsoneric/pedemath
pedemath/vec2.py
dot_v2
def dot_v2(vec1, vec2): """Return the dot product of two vectors""" return vec1.x * vec2.x + vec1.y * vec2.y
python
def dot_v2(vec1, vec2): """Return the dot product of two vectors""" return vec1.x * vec2.x + vec1.y * vec2.y
[ "def", "dot_v2", "(", "vec1", ",", "vec2", ")", ":", "return", "vec1", ".", "x", "*", "vec2", ".", "x", "+", "vec1", ".", "y", "*", "vec2", ".", "y" ]
Return the dot product of two vectors
[ "Return", "the", "dot", "product", "of", "two", "vectors" ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L74-L77
olsoneric/pedemath
pedemath/vec2.py
cross_v2
def cross_v2(vec1, vec2): """Return the crossproduct of the two vectors as a Vec2. Cross product doesn't really make sense in 2D, but return the Z component of the 3d result. """ return vec1.y * vec2.x - vec1.x * vec2.y
python
def cross_v2(vec1, vec2): """Return the crossproduct of the two vectors as a Vec2. Cross product doesn't really make sense in 2D, but return the Z component of the 3d result. """ return vec1.y * vec2.x - vec1.x * vec2.y
[ "def", "cross_v2", "(", "vec1", ",", "vec2", ")", ":", "return", "vec1", ".", "y", "*", "vec2", ".", "x", "-", "vec1", ".", "x", "*", "vec2", ".", "y" ]
Return the crossproduct of the two vectors as a Vec2. Cross product doesn't really make sense in 2D, but return the Z component of the 3d result.
[ "Return", "the", "crossproduct", "of", "the", "two", "vectors", "as", "a", "Vec2", ".", "Cross", "product", "doesn", "t", "really", "make", "sense", "in", "2D", "but", "return", "the", "Z", "component", "of", "the", "3d", "result", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L80-L86
olsoneric/pedemath
pedemath/vec2.py
sub_v2
def sub_v2(v, w): """Subtract: v - w. Assume the first arg v is a Vec2. The second arg w can be a vec2 or a number. """ if type(w) is float or type(w) is int: return Vec2(v.x - w, v.y - w) else: return Vec2(v.x - w.x, v.y - w.y)
python
def sub_v2(v, w): """Subtract: v - w. Assume the first arg v is a Vec2. The second arg w can be a vec2 or a number. """ if type(w) is float or type(w) is int: return Vec2(v.x - w, v.y - w) else: return Vec2(v.x - w.x, v.y - w.y)
[ "def", "sub_v2", "(", "v", ",", "w", ")", ":", "if", "type", "(", "w", ")", "is", "float", "or", "type", "(", "w", ")", "is", "int", ":", "return", "Vec2", "(", "v", ".", "x", "-", "w", ",", "v", ".", "y", "-", "w", ")", "else", ":", "r...
Subtract: v - w. Assume the first arg v is a Vec2. The second arg w can be a vec2 or a number.
[ "Subtract", ":", "v", "-", "w", ".", "Assume", "the", "first", "arg", "v", "is", "a", "Vec2", ".", "The", "second", "arg", "w", "can", "be", "a", "vec2", "or", "a", "number", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L99-L107
olsoneric/pedemath
pedemath/vec2.py
Vec2.truncate
def truncate(self, max_length): """Truncate this vector so it's length does not exceed max.""" if self.length() > max_length: # If it's longer than the max_length, scale to the max_length. self.scale(max_length / self.length())
python
def truncate(self, max_length): """Truncate this vector so it's length does not exceed max.""" if self.length() > max_length: # If it's longer than the max_length, scale to the max_length. self.scale(max_length / self.length())
[ "def", "truncate", "(", "self", ",", "max_length", ")", ":", "if", "self", ".", "length", "(", ")", ">", "max_length", ":", "# If it's longer than the max_length, scale to the max_length.", "self", ".", "scale", "(", "max_length", "/", "self", ".", "length", "("...
Truncate this vector so it's length does not exceed max.
[ "Truncate", "this", "vector", "so", "it", "s", "length", "does", "not", "exceed", "max", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L208-L214
olsoneric/pedemath
pedemath/vec2.py
Vec2.get_scaled_v2
def get_scaled_v2(self, amount): """Return a new Vec2 with x and y multiplied by amount.""" return Vec2(self.x * amount, self.y * amount)
python
def get_scaled_v2(self, amount): """Return a new Vec2 with x and y multiplied by amount.""" return Vec2(self.x * amount, self.y * amount)
[ "def", "get_scaled_v2", "(", "self", ",", "amount", ")", ":", "return", "Vec2", "(", "self", ".", "x", "*", "amount", ",", "self", ".", "y", "*", "amount", ")" ]
Return a new Vec2 with x and y multiplied by amount.
[ "Return", "a", "new", "Vec2", "with", "x", "and", "y", "multiplied", "by", "amount", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L236-L239
olsoneric/pedemath
pedemath/vec2.py
Vec2.get_norm
def get_norm(self): """Return square length: x*x + y*y.""" return self.x * self.x + self.y * self.y
python
def get_norm(self): """Return square length: x*x + y*y.""" return self.x * self.x + self.y * self.y
[ "def", "get_norm", "(", "self", ")", ":", "return", "self", ".", "x", "*", "self", ".", "x", "+", "self", ".", "y", "*", "self", ".", "y" ]
Return square length: x*x + y*y.
[ "Return", "square", "length", ":", "x", "*", "x", "+", "y", "*", "y", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L246-L249
olsoneric/pedemath
pedemath/vec2.py
Vec2.dot
def dot(self, vec): """Return the dot product of self and another Vec2.""" return self.x * vec.x + self.y * vec.y
python
def dot(self, vec): """Return the dot product of self and another Vec2.""" return self.x * vec.x + self.y * vec.y
[ "def", "dot", "(", "self", ",", "vec", ")", ":", "return", "self", ".", "x", "*", "vec", ".", "x", "+", "self", ".", "y", "*", "vec", ".", "y" ]
Return the dot product of self and another Vec2.
[ "Return", "the", "dot", "product", "of", "self", "and", "another", "Vec2", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L273-L276
olsoneric/pedemath
pedemath/vec2.py
Vec2.cross
def cross(self, vec): """Return the 2d cross product of self with another vector. Cross product doesn't make sense in 2D, but return the Z component of the 3d result. """ return self.x * vec.y - vec.x * self.y
python
def cross(self, vec): """Return the 2d cross product of self with another vector. Cross product doesn't make sense in 2D, but return the Z component of the 3d result. """ return self.x * vec.y - vec.x * self.y
[ "def", "cross", "(", "self", ",", "vec", ")", ":", "return", "self", ".", "x", "*", "vec", ".", "y", "-", "vec", ".", "x", "*", "self", ".", "y" ]
Return the 2d cross product of self with another vector. Cross product doesn't make sense in 2D, but return the Z component of the 3d result.
[ "Return", "the", "2d", "cross", "product", "of", "self", "with", "another", "vector", ".", "Cross", "product", "doesn", "t", "make", "sense", "in", "2D", "but", "return", "the", "Z", "component", "of", "the", "3d", "result", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L278-L284
olsoneric/pedemath
pedemath/vec2.py
Vec2.rot_rads
def rot_rads(self, rads): """ Rotate vector by angle in radians.""" new_x = self.x * math.cos(rads) - self.y * math.sin(rads) self.y = self.x * math.sin(rads) + self.y * math.cos(rads) self.x = new_x
python
def rot_rads(self, rads): """ Rotate vector by angle in radians.""" new_x = self.x * math.cos(rads) - self.y * math.sin(rads) self.y = self.x * math.sin(rads) + self.y * math.cos(rads) self.x = new_x
[ "def", "rot_rads", "(", "self", ",", "rads", ")", ":", "new_x", "=", "self", ".", "x", "*", "math", ".", "cos", "(", "rads", ")", "-", "self", ".", "y", "*", "math", ".", "sin", "(", "rads", ")", "self", ".", "y", "=", "self", ".", "x", "*"...
Rotate vector by angle in radians.
[ "Rotate", "vector", "by", "angle", "in", "radians", "." ]
train
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L431-L436
klmitch/appathy
appathy/controller.py
action
def action(*methods, **kwargs): """ Decorator which marks a method as an action. The first positional argument identifies a Routes-compatible path for the action method, which must begin with a '/'. If specified, the remaining positional arguments identify permitted HTTP methods. The followin...
python
def action(*methods, **kwargs): """ Decorator which marks a method as an action. The first positional argument identifies a Routes-compatible path for the action method, which must begin with a '/'. If specified, the remaining positional arguments identify permitted HTTP methods. The followin...
[ "def", "action", "(", "*", "methods", ",", "*", "*", "kwargs", ")", ":", "# Convert methods to a list, so it can be mutated if needed", "methods", "=", "list", "(", "methods", ")", "# Build up the function attributes", "attrs", "=", "dict", "(", "_wsgi_action", "=", ...
Decorator which marks a method as an action. The first positional argument identifies a Routes-compatible path for the action method, which must begin with a '/'. If specified, the remaining positional arguments identify permitted HTTP methods. The following keyword arguments are also recognized: ...
[ "Decorator", "which", "marks", "a", "method", "as", "an", "action", ".", "The", "first", "positional", "argument", "identifies", "a", "Routes", "-", "compatible", "path", "for", "the", "action", "method", "which", "must", "begin", "with", "a", "/", ".", "I...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/controller.py#L318-L395
klmitch/appathy
appathy/controller.py
_extends_preproc
def _extends_preproc(prefunc): """ Decorator which marks a method as a preprocessing extension. The method must have the same name as the method it is extending. Extension methods marked with this decorator are called before calling the action method. They may perform any desired preprocessing...
python
def _extends_preproc(prefunc): """ Decorator which marks a method as a preprocessing extension. The method must have the same name as the method it is extending. Extension methods marked with this decorator are called before calling the action method. They may perform any desired preprocessing...
[ "def", "_extends_preproc", "(", "prefunc", ")", ":", "# Set up the set of functions", "functions", "=", "dict", "(", "preproc", "=", "prefunc", ")", "# Set up the wrapper which implements the behavior", "@", "functools", ".", "wraps", "(", "prefunc", ")", "def", "wrap...
Decorator which marks a method as a preprocessing extension. The method must have the same name as the method it is extending. Extension methods marked with this decorator are called before calling the action method. They may perform any desired preprocessing of the request. Note that if an actual va...
[ "Decorator", "which", "marks", "a", "method", "as", "a", "preprocessing", "extension", ".", "The", "method", "must", "have", "the", "same", "name", "as", "the", "method", "it", "is", "extending", ".", "Extension", "methods", "marked", "with", "this", "decora...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/controller.py#L434-L506
klmitch/appathy
appathy/controller.py
Controller._get_action
def _get_action(self, action): """ Retrieve a descriptor for the named action. Caches descriptors for efficiency. """ # If we don't have an action named that, bail out if action not in self.wsgi_actions: return None # Generate an ActionDescriptor if...
python
def _get_action(self, action): """ Retrieve a descriptor for the named action. Caches descriptors for efficiency. """ # If we don't have an action named that, bail out if action not in self.wsgi_actions: return None # Generate an ActionDescriptor if...
[ "def", "_get_action", "(", "self", ",", "action", ")", ":", "# If we don't have an action named that, bail out", "if", "action", "not", "in", "self", ".", "wsgi_actions", ":", "return", "None", "# Generate an ActionDescriptor if necessary", "if", "action", "not", "in", ...
Retrieve a descriptor for the named action. Caches descriptors for efficiency.
[ "Retrieve", "a", "descriptor", "for", "the", "named", "action", ".", "Caches", "descriptors", "for", "efficiency", "." ]
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/controller.py#L221-L239
klmitch/appathy
appathy/controller.py
Controller._route
def _route(self, action, method): """ Given an action method, generates a route for it. """ # First thing, determine the path for the method path = method._wsgi_path methods = None if path is None: map_rule = self.wsgi_method_map.get(method.__name__) ...
python
def _route(self, action, method): """ Given an action method, generates a route for it. """ # First thing, determine the path for the method path = method._wsgi_path methods = None if path is None: map_rule = self.wsgi_method_map.get(method.__name__) ...
[ "def", "_route", "(", "self", ",", "action", ",", "method", ")", ":", "# First thing, determine the path for the method", "path", "=", "method", ".", "_wsgi_path", "methods", "=", "None", "if", "path", "is", "None", ":", "map_rule", "=", "self", ".", "wsgi_met...
Given an action method, generates a route for it.
[ "Given", "an", "action", "method", "generates", "a", "route", "for", "it", "." ]
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/controller.py#L241-L279
klmitch/appathy
appathy/controller.py
Controller.wsgi_extend
def wsgi_extend(self, controller): """ Extends a controller by registering another controller as an extension of it. All actions defined on the extension controller have routes generated for them (only if none already exist) and are made actions of this controller; all e...
python
def wsgi_extend(self, controller): """ Extends a controller by registering another controller as an extension of it. All actions defined on the extension controller have routes generated for them (only if none already exist) and are made actions of this controller; all e...
[ "def", "wsgi_extend", "(", "self", ",", "controller", ")", ":", "# Add/override actions", "for", "key", ",", "action", "in", "controller", ".", "wsgi_actions", ".", "items", "(", ")", ":", "# If it's a new action, we'll need to route", "if", "self", ".", "wsgi_map...
Extends a controller by registering another controller as an extension of it. All actions defined on the extension controller have routes generated for them (only if none already exist) and are made actions of this controller; all extensions defined on the extension controller are added...
[ "Extends", "a", "controller", "by", "registering", "another", "controller", "as", "an", "extension", "of", "it", ".", "All", "actions", "defined", "on", "the", "extension", "controller", "have", "routes", "generated", "for", "them", "(", "only", "if", "none", ...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/controller.py#L281-L315
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSDefaultHandler.on_message
def on_message(self, data): """ Parsing data, and try to call responding message """ # Trying to parse response data = json.loads(data) if not data["name"] is None: logging.debug("%s: receiving message %s" % (data["name"], data["data"])) fct = getattr(self, "on_" ...
python
def on_message(self, data): """ Parsing data, and try to call responding message """ # Trying to parse response data = json.loads(data) if not data["name"] is None: logging.debug("%s: receiving message %s" % (data["name"], data["data"])) fct = getattr(self, "on_" ...
[ "def", "on_message", "(", "self", ",", "data", ")", ":", "# Trying to parse response", "data", "=", "json", ".", "loads", "(", "data", ")", "if", "not", "data", "[", "\"name\"", "]", "is", "None", ":", "logging", ".", "debug", "(", "\"%s: receiving message...
Parsing data, and try to call responding message
[ "Parsing", "data", "and", "try", "to", "call", "responding", "message" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L26-L41
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSDefaultHandler.publish
def publish(self, name, data, userList): """ Publish data """ # Publish data to all room users self.broadcast(userList, { "name": name, "data": SockJSDefaultHandler._parser.encode(data) })
python
def publish(self, name, data, userList): """ Publish data """ # Publish data to all room users self.broadcast(userList, { "name": name, "data": SockJSDefaultHandler._parser.encode(data) })
[ "def", "publish", "(", "self", ",", "name", ",", "data", ",", "userList", ")", ":", "# Publish data to all room users", "self", ".", "broadcast", "(", "userList", ",", "{", "\"name\"", ":", "name", ",", "\"data\"", ":", "SockJSDefaultHandler", ".", "_parser", ...
Publish data
[ "Publish", "data" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L43-L49
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.join
def join(self, _id): """ Join a room """ if not SockJSRoomHandler._room.has_key(self._gcls() + _id): SockJSRoomHandler._room[self._gcls() + _id] = set() SockJSRoomHandler._room[self._gcls() + _id].add(self)
python
def join(self, _id): """ Join a room """ if not SockJSRoomHandler._room.has_key(self._gcls() + _id): SockJSRoomHandler._room[self._gcls() + _id] = set() SockJSRoomHandler._room[self._gcls() + _id].add(self)
[ "def", "join", "(", "self", ",", "_id", ")", ":", "if", "not", "SockJSRoomHandler", ".", "_room", ".", "has_key", "(", "self", ".", "_gcls", "(", ")", "+", "_id", ")", ":", "SockJSRoomHandler", ".", "_room", "[", "self", ".", "_gcls", "(", ")", "+"...
Join a room
[ "Join", "a", "room" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L61-L65
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.leave
def leave(self, _id): """ Leave a room """ if SockJSRoomHandler._room.has_key(self._gcls() + _id): SockJSRoomHandler._room[self._gcls() + _id].remove(self) if len(SockJSRoomHandler._room[self._gcls() + _id]) == 0: del SockJSRoomHandler._room[self._gcls() + _id]
python
def leave(self, _id): """ Leave a room """ if SockJSRoomHandler._room.has_key(self._gcls() + _id): SockJSRoomHandler._room[self._gcls() + _id].remove(self) if len(SockJSRoomHandler._room[self._gcls() + _id]) == 0: del SockJSRoomHandler._room[self._gcls() + _id]
[ "def", "leave", "(", "self", ",", "_id", ")", ":", "if", "SockJSRoomHandler", ".", "_room", ".", "has_key", "(", "self", ".", "_gcls", "(", ")", "+", "_id", ")", ":", "SockJSRoomHandler", ".", "_room", "[", "self", ".", "_gcls", "(", ")", "+", "_id...
Leave a room
[ "Leave", "a", "room" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L67-L72
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.getRoom
def getRoom(self, _id): """ Retrieve a room from it's id """ if SockJSRoomHandler._room.has_key(self._gcls() + _id): return SockJSRoomHandler._room[self._gcls() + _id] return None
python
def getRoom(self, _id): """ Retrieve a room from it's id """ if SockJSRoomHandler._room.has_key(self._gcls() + _id): return SockJSRoomHandler._room[self._gcls() + _id] return None
[ "def", "getRoom", "(", "self", ",", "_id", ")", ":", "if", "SockJSRoomHandler", ".", "_room", ".", "has_key", "(", "self", ".", "_gcls", "(", ")", "+", "_id", ")", ":", "return", "SockJSRoomHandler", ".", "_room", "[", "self", ".", "_gcls", "(", ")",...
Retrieve a room from it's id
[ "Retrieve", "a", "room", "from", "it", "s", "id" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L74-L78
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.publishToRoom
def publishToRoom(self, roomId, name, data, userList=None): """ Publish to given room data submitted """ if userList is None: userList = self.getRoom(roomId) # Publish data to all room users logging.debug("%s: broadcasting (name: %s, data: %s, number of users: %s)" % (self._...
python
def publishToRoom(self, roomId, name, data, userList=None): """ Publish to given room data submitted """ if userList is None: userList = self.getRoom(roomId) # Publish data to all room users logging.debug("%s: broadcasting (name: %s, data: %s, number of users: %s)" % (self._...
[ "def", "publishToRoom", "(", "self", ",", "roomId", ",", "name", ",", "data", ",", "userList", "=", "None", ")", ":", "if", "userList", "is", "None", ":", "userList", "=", "self", ".", "getRoom", "(", "roomId", ")", "# Publish data to all room users", "log...
Publish to given room data submitted
[ "Publish", "to", "given", "room", "data", "submitted" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L80-L90
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.publishToOther
def publishToOther(self, roomId, name, data): """ Publish to only other people than myself """ tmpList = self.getRoom(roomId) # Select everybody except me userList = [x for x in tmpList if x is not self] self.publishToRoom(roomId, name, data, userList)
python
def publishToOther(self, roomId, name, data): """ Publish to only other people than myself """ tmpList = self.getRoom(roomId) # Select everybody except me userList = [x for x in tmpList if x is not self] self.publishToRoom(roomId, name, data, userList)
[ "def", "publishToOther", "(", "self", ",", "roomId", ",", "name", ",", "data", ")", ":", "tmpList", "=", "self", ".", "getRoom", "(", "roomId", ")", "# Select everybody except me", "userList", "=", "[", "x", "for", "x", "in", "tmpList", "if", "x", "is", ...
Publish to only other people than myself
[ "Publish", "to", "only", "other", "people", "than", "myself" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L92-L97
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.publishToMyself
def publishToMyself(self, roomId, name, data): """ Publish to only myself """ self.publishToRoom(roomId, name, data, [self])
python
def publishToMyself(self, roomId, name, data): """ Publish to only myself """ self.publishToRoom(roomId, name, data, [self])
[ "def", "publishToMyself", "(", "self", ",", "roomId", ",", "name", ",", "data", ")", ":", "self", ".", "publishToRoom", "(", "roomId", ",", "name", ",", "data", ",", "[", "self", "]", ")" ]
Publish to only myself
[ "Publish", "to", "only", "myself" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L99-L101
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
SockJSRoomHandler.isInRoom
def isInRoom(self, _id): """ Check a given user is in given room """ if SockJSRoomHandler._room.has_key(self._gcls() + _id): if self in SockJSRoomHandler._room[self._gcls() + _id]: return True return False
python
def isInRoom(self, _id): """ Check a given user is in given room """ if SockJSRoomHandler._room.has_key(self._gcls() + _id): if self in SockJSRoomHandler._room[self._gcls() + _id]: return True return False
[ "def", "isInRoom", "(", "self", ",", "_id", ")", ":", "if", "SockJSRoomHandler", ".", "_room", ".", "has_key", "(", "self", ".", "_gcls", "(", ")", "+", "_id", ")", ":", "if", "self", "in", "SockJSRoomHandler", ".", "_room", "[", "self", ".", "_gcls"...
Check a given user is in given room
[ "Check", "a", "given", "user", "is", "in", "given", "room" ]
train
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L103-L108
dcrosta/sendlib
sendlib.py
parse
def parse(schema): """ Parse `schema`, either a string or a file-like object, and return a :class:`MessageRegistry` with the loaded messages. """ if not isinstance(schema, basestring): # assume it is file-like schema = schema.read() message = re.compile(r'^\(([^,]+),\s*(\d+)\):\...
python
def parse(schema): """ Parse `schema`, either a string or a file-like object, and return a :class:`MessageRegistry` with the loaded messages. """ if not isinstance(schema, basestring): # assume it is file-like schema = schema.read() message = re.compile(r'^\(([^,]+),\s*(\d+)\):\...
[ "def", "parse", "(", "schema", ")", ":", "if", "not", "isinstance", "(", "schema", ",", "basestring", ")", ":", "# assume it is file-like", "schema", "=", "schema", ".", "read", "(", ")", "message", "=", "re", ".", "compile", "(", "r'^\\(([^,]+),\\s*(\\d+)\\...
Parse `schema`, either a string or a file-like object, and return a :class:`MessageRegistry` with the loaded messages.
[ "Parse", "schema", "either", "a", "string", "or", "a", "file", "-", "like", "object", "and", "return", "a", ":", "class", ":", "MessageRegistry", "with", "the", "loaded", "messages", "." ]
train
https://github.com/dcrosta/sendlib/blob/51ea5412a70cf83a62d51d5c515c0eeac725aea0/sendlib.py#L628-L680
dcrosta/sendlib
sendlib.py
Writer.write
def write(self, fieldname, value=Nothing): """ Write the `value` to the stream, after verifying that `fieldname` is the correct next field in the message format. `value` defaults to :class:`Nothing`, which is distinct from :class:`None`, as :class:`None` is a valid value ...
python
def write(self, fieldname, value=Nothing): """ Write the `value` to the stream, after verifying that `fieldname` is the correct next field in the message format. `value` defaults to :class:`Nothing`, which is distinct from :class:`None`, as :class:`None` is a valid value ...
[ "def", "write", "(", "self", ",", "fieldname", ",", "value", "=", "Nothing", ")", ":", "type", "=", "self", ".", "_check", "(", "fieldname", ",", "value", ")", "if", "self", ".", "_pos", "==", "-", "1", ":", "# write header", "self", ".", "stream", ...
Write the `value` to the stream, after verifying that `fieldname` is the correct next field in the message format. `value` defaults to :class:`Nothing`, which is distinct from :class:`None`, as :class:`None` is a valid value which may be written (when a field is ``or nil``). Whe...
[ "Write", "the", "value", "to", "the", "stream", "after", "verifying", "that", "fieldname", "is", "the", "correct", "next", "field", "in", "the", "message", "format", ".", "value", "defaults", "to", ":", "class", ":", "Nothing", "which", "is", "distinct", "...
train
https://github.com/dcrosta/sendlib/blob/51ea5412a70cf83a62d51d5c515c0eeac725aea0/sendlib.py#L271-L302
dcrosta/sendlib
sendlib.py
Data.readline
def readline(self, size=None): """ Read a line from the stream, including the trailing new line character. If `size` is set, don't read more than `size` bytes, even if the result does not represent a complete line. The last line read may not include a trailing new line ...
python
def readline(self, size=None): """ Read a line from the stream, including the trailing new line character. If `size` is set, don't read more than `size` bytes, even if the result does not represent a complete line. The last line read may not include a trailing new line ...
[ "def", "readline", "(", "self", ",", "size", "=", "None", ")", ":", "if", "self", ".", "_pos", ">=", "self", ".", "length", ":", "return", "''", "if", "size", ":", "amount", "=", "min", "(", "size", ",", "(", "self", ".", "length", "-", "self", ...
Read a line from the stream, including the trailing new line character. If `size` is set, don't read more than `size` bytes, even if the result does not represent a complete line. The last line read may not include a trailing new line character if one was not present in the unde...
[ "Read", "a", "line", "from", "the", "stream", "including", "the", "trailing", "new", "line", "character", ".", "If", "size", "is", "set", "don", "t", "read", "more", "than", "size", "bytes", "even", "if", "the", "result", "does", "not", "represent", "a",...
train
https://github.com/dcrosta/sendlib/blob/51ea5412a70cf83a62d51d5c515c0eeac725aea0/sendlib.py#L338-L356
dcrosta/sendlib
sendlib.py
Data.skip
def skip(self): """ Advance the internal pointer to the end of the data area in the stream. This allows the next call to :meth:`Reader.read` to succeed, as though all the data had been read by the application. """ self.stream.seek(self.bytes_remaining(), os.SEEK_C...
python
def skip(self): """ Advance the internal pointer to the end of the data area in the stream. This allows the next call to :meth:`Reader.read` to succeed, as though all the data had been read by the application. """ self.stream.seek(self.bytes_remaining(), os.SEEK_C...
[ "def", "skip", "(", "self", ")", ":", "self", ".", "stream", ".", "seek", "(", "self", ".", "bytes_remaining", "(", ")", ",", "os", ".", "SEEK_CUR", ")", "self", ".", "_pos", "=", "self", ".", "length" ]
Advance the internal pointer to the end of the data area in the stream. This allows the next call to :meth:`Reader.read` to succeed, as though all the data had been read by the application.
[ "Advance", "the", "internal", "pointer", "to", "the", "end", "of", "the", "data", "area", "in", "the", "stream", ".", "This", "allows", "the", "next", "call", "to", ":", "meth", ":", "Reader", ".", "read", "to", "succeed", "as", "though", "all", "the",...
train
https://github.com/dcrosta/sendlib/blob/51ea5412a70cf83a62d51d5c515c0eeac725aea0/sendlib.py#L358-L366
dcrosta/sendlib
sendlib.py
Reader.read
def read(self, fieldname): """ Read the next field from the stream. `fieldname` is used to verify that your application logic matches the message field order, and if `fieldname` does not match the next field in the message definition, :class:`SendlibError` is raised. ...
python
def read(self, fieldname): """ Read the next field from the stream. `fieldname` is used to verify that your application logic matches the message field order, and if `fieldname` does not match the next field in the message definition, :class:`SendlibError` is raised. ...
[ "def", "read", "(", "self", ",", "fieldname", ")", ":", "if", "self", ".", "_pos", "==", "-", "1", ":", "self", ".", "_pos", "=", "0", "if", "PREFIX", "[", "'message'", "]", "!=", "self", ".", "stream", ".", "read", "(", "1", ")", ":", "raise",...
Read the next field from the stream. `fieldname` is used to verify that your application logic matches the message field order, and if `fieldname` does not match the next field in the message definition, :class:`SendlibError` is raised. Returns a Python object of the correct typ...
[ "Read", "the", "next", "field", "from", "the", "stream", ".", "fieldname", "is", "used", "to", "verify", "that", "your", "application", "logic", "matches", "the", "message", "field", "order", "and", "if", "fieldname", "does", "not", "match", "the", "next", ...
train
https://github.com/dcrosta/sendlib/blob/51ea5412a70cf83a62d51d5c515c0eeac725aea0/sendlib.py#L438-L478
JNRowe/jnrbase
jnrbase/git.py
find_tag
def find_tag(__matcher: str = 'v[0-9]*', *, strict: bool = True, git_dir: str = '.') -> str: """Find closest tag for a git repository. Note: This defaults to `Semantic Version`_ tag matching. Args: __matcher: Glob-style tag pattern to match strict: Allow commit-ish, if...
python
def find_tag(__matcher: str = 'v[0-9]*', *, strict: bool = True, git_dir: str = '.') -> str: """Find closest tag for a git repository. Note: This defaults to `Semantic Version`_ tag matching. Args: __matcher: Glob-style tag pattern to match strict: Allow commit-ish, if...
[ "def", "find_tag", "(", "__matcher", ":", "str", "=", "'v[0-9]*'", ",", "*", ",", "strict", ":", "bool", "=", "True", ",", "git_dir", ":", "str", "=", "'.'", ")", "->", "str", ":", "command", "=", "'git describe --abbrev=12 --dirty'", ".", "split", "(", ...
Find closest tag for a git repository. Note: This defaults to `Semantic Version`_ tag matching. Args: __matcher: Glob-style tag pattern to match strict: Allow commit-ish, if no tag found git_dir: Repository to search Returns: Matching tag name .. _Semantic Vers...
[ "Find", "closest", "tag", "for", "a", "git", "repository", "." ]
train
https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/git.py#L26-L52
minus7/asif
asif/bot.py
Channel.on_message
def on_message(self, *args, accept_query=False, matcher=None, **kwargs): """ Convenience wrapper of `Client.on_message` pre-bound with `channel=self.name`. """ if accept_query: def new_matcher(msg: Message): ret = True if matcher: ...
python
def on_message(self, *args, accept_query=False, matcher=None, **kwargs): """ Convenience wrapper of `Client.on_message` pre-bound with `channel=self.name`. """ if accept_query: def new_matcher(msg: Message): ret = True if matcher: ...
[ "def", "on_message", "(", "self", ",", "*", "args", ",", "accept_query", "=", "False", ",", "matcher", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "accept_query", ":", "def", "new_matcher", "(", "msg", ":", "Message", ")", ":", "ret", "=", ...
Convenience wrapper of `Client.on_message` pre-bound with `channel=self.name`.
[ "Convenience", "wrapper", "of", "Client", ".", "on_message", "pre", "-", "bound", "with", "channel", "=", "self", ".", "name", "." ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L56-L74
minus7/asif
asif/bot.py
Client.await_message
def await_message(self, *args, **kwargs) -> 'asyncio.Future[Message]': """ Block until a message matches. See `on_message` """ fut = asyncio.Future() @self.on_message(*args, **kwargs) async def handler(message): fut.set_result(message) # remove handler...
python
def await_message(self, *args, **kwargs) -> 'asyncio.Future[Message]': """ Block until a message matches. See `on_message` """ fut = asyncio.Future() @self.on_message(*args, **kwargs) async def handler(message): fut.set_result(message) # remove handler...
[ "def", "await_message", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "'asyncio.Future[Message]'", ":", "fut", "=", "asyncio", ".", "Future", "(", ")", "@", "self", ".", "on_message", "(", "*", "args", ",", "*", "*", "kwargs", ")...
Block until a message matches. See `on_message`
[ "Block", "until", "a", "message", "matches", ".", "See", "on_message" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L287-L297
minus7/asif
asif/bot.py
Client.on_join
def on_join(self, channel: str=None) -> Callable[[Callable], Callable]: """ Register a handler that's called after a channel is joined. The handler is called with the `Channel` as argument, must be a coroutine and is run non-blocking. :param channel: channel to look out for or `N...
python
def on_join(self, channel: str=None) -> Callable[[Callable], Callable]: """ Register a handler that's called after a channel is joined. The handler is called with the `Channel` as argument, must be a coroutine and is run non-blocking. :param channel: channel to look out for or `N...
[ "def", "on_join", "(", "self", ",", "channel", ":", "str", "=", "None", ")", "->", "Callable", "[", "[", "Callable", "]", ",", "Callable", "]", ":", "def", "decorator", "(", "fn", ":", "Callable", "[", "[", "self", ".", "IrcMessage", "]", ",", "Non...
Register a handler that's called after a channel is joined. The handler is called with the `Channel` as argument, must be a coroutine and is run non-blocking. :param channel: channel to look out for or `None` for all channels
[ "Register", "a", "handler", "that", "s", "called", "after", "a", "channel", "is", "joined", ".", "The", "handler", "is", "called", "with", "the", "Channel", "as", "argument", "must", "be", "a", "coroutine", "and", "is", "run", "non", "-", "blocking", "."...
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L303-L316
minus7/asif
asif/bot.py
Client.on_command
def on_command(self, *args: Sequence[str], rest: str=None) -> Callable[[Callable], Callable]: """ Register a handler that's called when (the beginning of) a `IrcMessage` matches. The handler is called with the `IrcMessage` as argument, must be a coroutine and is run blocking, i.e. you ca...
python
def on_command(self, *args: Sequence[str], rest: str=None) -> Callable[[Callable], Callable]: """ Register a handler that's called when (the beginning of) a `IrcMessage` matches. The handler is called with the `IrcMessage` as argument, must be a coroutine and is run blocking, i.e. you ca...
[ "def", "on_command", "(", "self", ",", "*", "args", ":", "Sequence", "[", "str", "]", ",", "rest", ":", "str", "=", "None", ")", "->", "Callable", "[", "[", "Callable", "]", ",", "Callable", "]", ":", "def", "decorator", "(", "fn", ":", "Callable",...
Register a handler that's called when (the beginning of) a `IrcMessage` matches. The handler is called with the `IrcMessage` as argument, must be a coroutine and is run blocking, i.e. you cannot use `await_command` in it! :param args: commands args that must match (the actual command is the firs...
[ "Register", "a", "handler", "that", "s", "called", "when", "(", "the", "beginning", "of", ")", "a", "IrcMessage", "matches", ".", "The", "handler", "is", "called", "with", "the", "IrcMessage", "as", "argument", "must", "be", "a", "coroutine", "and", "is", ...
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L326-L340
minus7/asif
asif/bot.py
Client.await_command
def await_command(self, *args, **kwargs) -> 'asyncio.Future[IrcMessage]': """ Block until a command matches. See `on_command` """ fut = asyncio.Future() @self.on_command(*args, **kwargs) async def handler(msg): fut.set_result(msg) # remove handler when...
python
def await_command(self, *args, **kwargs) -> 'asyncio.Future[IrcMessage]': """ Block until a command matches. See `on_command` """ fut = asyncio.Future() @self.on_command(*args, **kwargs) async def handler(msg): fut.set_result(msg) # remove handler when...
[ "def", "await_command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "'asyncio.Future[IrcMessage]'", ":", "fut", "=", "asyncio", ".", "Future", "(", ")", "@", "self", ".", "on_command", "(", "*", "args", ",", "*", "*", "kwargs", ...
Block until a command matches. See `on_command`
[ "Block", "until", "a", "command", "matches", ".", "See", "on_command" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L348-L358
minus7/asif
asif/bot.py
Client.message
async def message(self, recipient: str, text: str, notice: bool=False) -> None: """ Lower level messaging function used by User and Channel """ await self._send(cc.PRIVMSG if not notice else cc.NOTICE, recipient, rest=text)
python
async def message(self, recipient: str, text: str, notice: bool=False) -> None: """ Lower level messaging function used by User and Channel """ await self._send(cc.PRIVMSG if not notice else cc.NOTICE, recipient, rest=text)
[ "async", "def", "message", "(", "self", ",", "recipient", ":", "str", ",", "text", ":", "str", ",", "notice", ":", "bool", "=", "False", ")", "->", "None", ":", "await", "self", ".", "_send", "(", "cc", ".", "PRIVMSG", "if", "not", "notice", "else"...
Lower level messaging function used by User and Channel
[ "Lower", "level", "messaging", "function", "used", "by", "User", "and", "Channel" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L389-L393
minus7/asif
asif/bot.py
Client._bg
def _bg(self, coro: coroutine) -> asyncio.Task: """Run coro in background, log errors""" async def runner(): try: await coro except: self._log.exception("async: Coroutine raised exception") return asyncio.ensure_future(runner())
python
def _bg(self, coro: coroutine) -> asyncio.Task: """Run coro in background, log errors""" async def runner(): try: await coro except: self._log.exception("async: Coroutine raised exception") return asyncio.ensure_future(runner())
[ "def", "_bg", "(", "self", ",", "coro", ":", "coroutine", ")", "->", "asyncio", ".", "Task", ":", "async", "def", "runner", "(", ")", ":", "try", ":", "await", "coro", "except", ":", "self", ".", "_log", ".", "exception", "(", "\"async: Coroutine raise...
Run coro in background, log errors
[ "Run", "coro", "in", "background", "log", "errors" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L450-L457
minus7/asif
asif/bot.py
Client.get_user
def get_user(self, nick: str) -> User: """ :param nick: nick or prefix """ hostmask = None if "!" in nick: nick, _, hostmask = nick.partition("!") user = self._users.get(nick) if not user: self._users[nick] = user = User(nick, self, hostmas...
python
def get_user(self, nick: str) -> User: """ :param nick: nick or prefix """ hostmask = None if "!" in nick: nick, _, hostmask = nick.partition("!") user = self._users.get(nick) if not user: self._users[nick] = user = User(nick, self, hostmas...
[ "def", "get_user", "(", "self", ",", "nick", ":", "str", ")", "->", "User", ":", "hostmask", "=", "None", "if", "\"!\"", "in", "nick", ":", "nick", ",", "_", ",", "hostmask", "=", "nick", ".", "partition", "(", "\"!\"", ")", "user", "=", "self", ...
:param nick: nick or prefix
[ ":", "param", "nick", ":", "nick", "or", "prefix" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L518-L530
minus7/asif
asif/bot.py
Client._on_nick
async def _on_nick(self, msg: IrcMessage) -> None: """ Nick change """ user = self.get_user(msg.prefix) old_nick = user.name del self._users[old_nick] user.name = msg.rest if old_nick == self.nick: # (Forced?) Nick change for ourself ...
python
async def _on_nick(self, msg: IrcMessage) -> None: """ Nick change """ user = self.get_user(msg.prefix) old_nick = user.name del self._users[old_nick] user.name = msg.rest if old_nick == self.nick: # (Forced?) Nick change for ourself ...
[ "async", "def", "_on_nick", "(", "self", ",", "msg", ":", "IrcMessage", ")", "->", "None", ":", "user", "=", "self", ".", "get_user", "(", "msg", ".", "prefix", ")", "old_nick", "=", "user", ".", "name", "del", "self", ".", "_users", "[", "old_nick",...
Nick change
[ "Nick", "change" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L620-L632
minus7/asif
asif/bot.py
Module._populate
def _populate(self, client): """ Populate module with the client when available """ self.client = client for fn in self._buffered_calls: self._log.debug("Executing buffered call {}".format(fn)) fn()
python
def _populate(self, client): """ Populate module with the client when available """ self.client = client for fn in self._buffered_calls: self._log.debug("Executing buffered call {}".format(fn)) fn()
[ "def", "_populate", "(", "self", ",", "client", ")", ":", "self", ".", "client", "=", "client", "for", "fn", "in", "self", ".", "_buffered_calls", ":", "self", ".", "_log", ".", "debug", "(", "\"Executing buffered call {}\"", ".", "format", "(", "fn", ")...
Populate module with the client when available
[ "Populate", "module", "with", "the", "client", "when", "available" ]
train
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L680-L687
wtsi-hgi/python-baton-wrapper
baton/_baton/baton_metadata_mappers.py
_BatonIrodsMetadataMapper._modify
def _modify(self, paths: Union[str, List[str]], metadata_for_paths: Union[IrodsMetadata, List[IrodsMetadata]], operation: str): """ Modifies the metadata of the entity or entities in iRODS with the given path. :param path: the paths of the entity or entities to modify :pa...
python
def _modify(self, paths: Union[str, List[str]], metadata_for_paths: Union[IrodsMetadata, List[IrodsMetadata]], operation: str): """ Modifies the metadata of the entity or entities in iRODS with the given path. :param path: the paths of the entity or entities to modify :pa...
[ "def", "_modify", "(", "self", ",", "paths", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "metadata_for_paths", ":", "Union", "[", "IrodsMetadata", ",", "List", "[", "IrodsMetadata", "]", "]", ",", "operation", ":", "str", ")", "...
Modifies the metadata of the entity or entities in iRODS with the given path. :param path: the paths of the entity or entities to modify :param metadata_for_paths: the metadata to change. If only one metadata object is given, that metadata is set for all, else the metadata is matched against the...
[ "Modifies", "the", "metadata", "of", "the", "entity", "or", "entities", "in", "iRODS", "with", "the", "given", "path", ".", ":", "param", "path", ":", "the", "paths", "of", "the", "entity", "or", "entities", "to", "modify", ":", "param", "metadata_for_path...
train
https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/baton_metadata_mappers.py#L91-L115
wtsi-hgi/python-baton-wrapper
baton/_baton/baton_metadata_mappers.py
_BatonIrodsMetadataMapper._path_to_baton_json
def _path_to_baton_json(self, path: str) -> Dict: """ Converts a path to the type of iRODS entity the mapper deals with, to its JSON representation. :param path: the path to convert :return: the JSON representation of the path """ entity = self._create_entity_with_path(pa...
python
def _path_to_baton_json(self, path: str) -> Dict: """ Converts a path to the type of iRODS entity the mapper deals with, to its JSON representation. :param path: the path to convert :return: the JSON representation of the path """ entity = self._create_entity_with_path(pa...
[ "def", "_path_to_baton_json", "(", "self", ",", "path", ":", "str", ")", "->", "Dict", ":", "entity", "=", "self", ".", "_create_entity_with_path", "(", "path", ")", "return", "self", ".", "_entity_to_baton_json", "(", "entity", ")" ]
Converts a path to the type of iRODS entity the mapper deals with, to its JSON representation. :param path: the path to convert :return: the JSON representation of the path
[ "Converts", "a", "path", "to", "the", "type", "of", "iRODS", "entity", "the", "mapper", "deals", "with", "to", "its", "JSON", "representation", ".", ":", "param", "path", ":", "the", "path", "to", "convert", ":", "return", ":", "the", "JSON", "representa...
train
https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/baton_metadata_mappers.py#L117-L124
b3j0f/schema
b3j0f/schema/utils.py
datatype2schemacls
def datatype2schemacls( _datatype, _registry=None, _factory=None, _force=True, _besteffort=True, **kwargs ): """Get a schema class which has been associated to input data type by the registry or the factory in this order. :param type datatype: data type from where get associated schema. ...
python
def datatype2schemacls( _datatype, _registry=None, _factory=None, _force=True, _besteffort=True, **kwargs ): """Get a schema class which has been associated to input data type by the registry or the factory in this order. :param type datatype: data type from where get associated schema. ...
[ "def", "datatype2schemacls", "(", "_datatype", ",", "_registry", "=", "None", ",", "_factory", "=", "None", ",", "_force", "=", "True", ",", "_besteffort", "=", "True", ",", "*", "*", "kwargs", ")", ":", "result", "=", "None", "gdbt", "=", "getbydatatype...
Get a schema class which has been associated to input data type by the registry or the factory in this order. :param type datatype: data type from where get associated schema. :param SchemaRegisgry _registry: registry from where call the getbydatatype . Default is the global registry. :param Sc...
[ "Get", "a", "schema", "class", "which", "has", "been", "associated", "to", "input", "data", "type", "by", "the", "registry", "or", "the", "factory", "in", "this", "order", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/utils.py#L51-L87
b3j0f/schema
b3j0f/schema/utils.py
data2schema
def data2schema( _data=None, _force=False, _besteffort=True, _registry=None, _factory=None, _buildkwargs=None, **kwargs ): """Get the schema able to instanciate input data. The default value of schema will be data. Can be used such as a decorator: ..code-block:: python @data2...
python
def data2schema( _data=None, _force=False, _besteffort=True, _registry=None, _factory=None, _buildkwargs=None, **kwargs ): """Get the schema able to instanciate input data. The default value of schema will be data. Can be used such as a decorator: ..code-block:: python @data2...
[ "def", "data2schema", "(", "_data", "=", "None", ",", "_force", "=", "False", ",", "_besteffort", "=", "True", ",", "_registry", "=", "None", ",", "_factory", "=", "None", ",", "_buildkwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "_d...
Get the schema able to instanciate input data. The default value of schema will be data. Can be used such as a decorator: ..code-block:: python @data2schema def example(): pass # return a function schema @data2schema(_registry=myregistry) def example(): pass # return a...
[ "Get", "the", "schema", "able", "to", "instanciate", "input", "data", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/utils.py#L90-L160
b3j0f/schema
b3j0f/schema/utils.py
data2schemacls
def data2schemacls(_data, **kwargs): """Convert a data to a schema cls. :param data: object or dictionary from where get a schema cls. :return: schema class. :rtype: type """ content = {} for key in list(kwargs): # fill kwargs kwargs[key] = data2schema(kwargs[key]) if isinsta...
python
def data2schemacls(_data, **kwargs): """Convert a data to a schema cls. :param data: object or dictionary from where get a schema cls. :return: schema class. :rtype: type """ content = {} for key in list(kwargs): # fill kwargs kwargs[key] = data2schema(kwargs[key]) if isinsta...
[ "def", "data2schemacls", "(", "_data", ",", "*", "*", "kwargs", ")", ":", "content", "=", "{", "}", "for", "key", "in", "list", "(", "kwargs", ")", ":", "# fill kwargs", "kwargs", "[", "key", "]", "=", "data2schema", "(", "kwargs", "[", "key", "]", ...
Convert a data to a schema cls. :param data: object or dictionary from where get a schema cls. :return: schema class. :rtype: type
[ "Convert", "a", "data", "to", "a", "schema", "cls", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/utils.py#L163-L198
b3j0f/schema
b3j0f/schema/utils.py
validate
def validate(schema, data, owner=None): """Validate input data with input schema. :param Schema schema: schema able to validate input data. :param data: data to validate. :param Schema owner: input schema parent schema. :raises: Exception if the data is not validated. """ schema._validate(d...
python
def validate(schema, data, owner=None): """Validate input data with input schema. :param Schema schema: schema able to validate input data. :param data: data to validate. :param Schema owner: input schema parent schema. :raises: Exception if the data is not validated. """ schema._validate(d...
[ "def", "validate", "(", "schema", ",", "data", ",", "owner", "=", "None", ")", ":", "schema", ".", "_validate", "(", "data", "=", "data", ",", "owner", "=", "owner", ")" ]
Validate input data with input schema. :param Schema schema: schema able to validate input data. :param data: data to validate. :param Schema owner: input schema parent schema. :raises: Exception if the data is not validated.
[ "Validate", "input", "data", "with", "input", "schema", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/utils.py#L235-L243
b3j0f/schema
b3j0f/schema/utils.py
dump
def dump(schema): """Get a serialized value of input schema. :param Schema schema: schema to serialize. :rtype: dict """ result = {} for name, _ in iteritems(schema.getschemas()): if hasattr(schema, name): val = getattr(schema, name) if isinstance(val, Dynamic...
python
def dump(schema): """Get a serialized value of input schema. :param Schema schema: schema to serialize. :rtype: dict """ result = {} for name, _ in iteritems(schema.getschemas()): if hasattr(schema, name): val = getattr(schema, name) if isinstance(val, Dynamic...
[ "def", "dump", "(", "schema", ")", ":", "result", "=", "{", "}", "for", "name", ",", "_", "in", "iteritems", "(", "schema", ".", "getschemas", "(", ")", ")", ":", "if", "hasattr", "(", "schema", ",", "name", ")", ":", "val", "=", "getattr", "(", ...
Get a serialized value of input schema. :param Schema schema: schema to serialize. :rtype: dict
[ "Get", "a", "serialized", "value", "of", "input", "schema", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/utils.py#L246-L267
b3j0f/schema
b3j0f/schema/utils.py
updatecontent
def updatecontent(schemacls=None, updateparents=True, exclude=None): """Transform all schema class attributes to schemas. It can be used such as a decorator in order to ensure to update attributes with the decorated schema but take care to the limitation to use old style method call for overidden metho...
python
def updatecontent(schemacls=None, updateparents=True, exclude=None): """Transform all schema class attributes to schemas. It can be used such as a decorator in order to ensure to update attributes with the decorated schema but take care to the limitation to use old style method call for overidden metho...
[ "def", "updatecontent", "(", "schemacls", "=", "None", ",", "updateparents", "=", "True", ",", "exclude", "=", "None", ")", ":", "if", "schemacls", "is", "None", ":", "return", "lambda", "schemacls", ":", "updatecontent", "(", "schemacls", "=", "schemacls", ...
Transform all schema class attributes to schemas. It can be used such as a decorator in order to ensure to update attributes with the decorated schema but take care to the limitation to use old style method call for overidden methods. .. example: @updatecontent # update content at the end of ...
[ "Transform", "all", "schema", "class", "attributes", "to", "schemas", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/utils.py#L309-L390
ryanleland/Akispy
akispy/__init__.py
Connection.verify_key
def verify_key(self, url): """For verifying your API key. Provide the URL of your site or blog you will be checking spam from. """ response = self._request('verify-key', { 'blog': url, 'key': self._key }) if response.stat...
python
def verify_key(self, url): """For verifying your API key. Provide the URL of your site or blog you will be checking spam from. """ response = self._request('verify-key', { 'blog': url, 'key': self._key }) if response.stat...
[ "def", "verify_key", "(", "self", ",", "url", ")", ":", "response", "=", "self", ".", "_request", "(", "'verify-key'", ",", "{", "'blog'", ":", "url", ",", "'key'", ":", "self", ".", "_key", "}", ")", "if", "response", ".", "status", "is", "200", "...
For verifying your API key. Provide the URL of your site or blog you will be checking spam from.
[ "For", "verifying", "your", "API", "key", ".", "Provide", "the", "URL", "of", "your", "site", "or", "blog", "you", "will", "be", "checking", "spam", "from", "." ]
train
https://github.com/ryanleland/Akispy/blob/dbbb85a1d1b027051e11179289cc9067cb90baf6/akispy/__init__.py#L29-L44
ryanleland/Akispy
akispy/__init__.py
Connection.comment_check
def comment_check(self, params): """For checking comments.""" # Check required params for comment-check for required in ['blog', 'user_ip', 'user_agent']: if required not in params: raise MissingParams(required) response = self._request('comment-che...
python
def comment_check(self, params): """For checking comments.""" # Check required params for comment-check for required in ['blog', 'user_ip', 'user_agent']: if required not in params: raise MissingParams(required) response = self._request('comment-che...
[ "def", "comment_check", "(", "self", ",", "params", ")", ":", "# Check required params for comment-check", "for", "required", "in", "[", "'blog'", ",", "'user_ip'", ",", "'user_agent'", "]", ":", "if", "required", "not", "in", "params", ":", "raise", "MissingPar...
For checking comments.
[ "For", "checking", "comments", "." ]
train
https://github.com/ryanleland/Akispy/blob/dbbb85a1d1b027051e11179289cc9067cb90baf6/akispy/__init__.py#L46-L60
ryanleland/Akispy
akispy/__init__.py
Connection.submit_ham
def submit_ham(self, params): """For submitting a ham comment to Akismet.""" # Check required params for submit-ham for required in ['blog', 'user_ip', 'user_agent']: if required not in params: raise MissingParams(required) response = self._request(...
python
def submit_ham(self, params): """For submitting a ham comment to Akismet.""" # Check required params for submit-ham for required in ['blog', 'user_ip', 'user_agent']: if required not in params: raise MissingParams(required) response = self._request(...
[ "def", "submit_ham", "(", "self", ",", "params", ")", ":", "# Check required params for submit-ham", "for", "required", "in", "[", "'blog'", ",", "'user_ip'", ",", "'user_agent'", "]", ":", "if", "required", "not", "in", "params", ":", "raise", "MissingParams", ...
For submitting a ham comment to Akismet.
[ "For", "submitting", "a", "ham", "comment", "to", "Akismet", "." ]
train
https://github.com/ryanleland/Akispy/blob/dbbb85a1d1b027051e11179289cc9067cb90baf6/akispy/__init__.py#L77-L90
ryanleland/Akispy
akispy/__init__.py
Connection._request
def _request(self, function, params, method='POST', headers={}): """Builds a request object.""" if method is 'POST': params = urllib.parse.urlencode(params) headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } path = ...
python
def _request(self, function, params, method='POST', headers={}): """Builds a request object.""" if method is 'POST': params = urllib.parse.urlencode(params) headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } path = ...
[ "def", "_request", "(", "self", ",", "function", ",", "params", ",", "method", "=", "'POST'", ",", "headers", "=", "{", "}", ")", ":", "if", "method", "is", "'POST'", ":", "params", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ")", ...
Builds a request object.
[ "Builds", "a", "request", "object", "." ]
train
https://github.com/ryanleland/Akispy/blob/dbbb85a1d1b027051e11179289cc9067cb90baf6/akispy/__init__.py#L92-L102
Apitax/Apitax
apitax/api/controllers/migrations/apitax_controller.py
create_user
def create_user(user, name, create=None): # noqa: E501 """Create a new script Create a new script # noqa: E501 :param user: Get user with this name :type user: str :param name: Get status of a driver with this name :type name: str :param create: The data needed to create this user :ty...
python
def create_user(user, name, create=None): # noqa: E501 """Create a new script Create a new script # noqa: E501 :param user: Get user with this name :type user: str :param name: Get status of a driver with this name :type name: str :param create: The data needed to create this user :ty...
[ "def", "create_user", "(", "user", ",", "name", ",", "create", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "create", "=", "Create", ".", "from_dict", "(", "connexion", ".", "request", ".", "get_json", "(...
Create a new script Create a new script # noqa: E501 :param user: Get user with this name :type user: str :param name: Get status of a driver with this name :type name: str :param create: The data needed to create this user :type create: dict | bytes :rtype: Response
[ "Create", "a", "new", "script" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/migrations/apitax_controller.py#L53-L82
Apitax/Apitax
apitax/api/controllers/migrations/apitax_controller.py
refresh_token
def refresh_token(): # noqa: E501 """Refreshes login token using refresh token Refreshes login token using refresh token # noqa: E501 :rtype: UserAuth """ current_user = get_jwt_identity() if not current_user: return ErrorResponse(status=401, message="Not logged in") access_token...
python
def refresh_token(): # noqa: E501 """Refreshes login token using refresh token Refreshes login token using refresh token # noqa: E501 :rtype: UserAuth """ current_user = get_jwt_identity() if not current_user: return ErrorResponse(status=401, message="Not logged in") access_token...
[ "def", "refresh_token", "(", ")", ":", "# noqa: E501", "current_user", "=", "get_jwt_identity", "(", ")", "if", "not", "current_user", ":", "return", "ErrorResponse", "(", "status", "=", "401", ",", "message", "=", "\"Not logged in\"", ")", "access_token", "=", ...
Refreshes login token using refresh token Refreshes login token using refresh token # noqa: E501 :rtype: UserAuth
[ "Refreshes", "login", "token", "using", "refresh", "token" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/migrations/apitax_controller.py#L182-L194
Apitax/Apitax
apitax/api/controllers/migrations/apitax_controller.py
save_user
def save_user(user, name, save=None): # noqa: E501 """Save a script Save a script # noqa: E501 :param user: Get user with this name :type user: str :param name: Get status of a driver with this name :type name: str :param save: The data needed to save this user :type save: dict | byte...
python
def save_user(user, name, save=None): # noqa: E501 """Save a script Save a script # noqa: E501 :param user: Get user with this name :type user: str :param name: Get status of a driver with this name :type name: str :param save: The data needed to save this user :type save: dict | byte...
[ "def", "save_user", "(", "user", ",", "name", ",", "save", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "save", "=", "Save", ".", "from_dict", "(", "connexion", ".", "request", ".", "get_json", "(", ")"...
Save a script Save a script # noqa: E501 :param user: Get user with this name :type user: str :param name: Get status of a driver with this name :type name: str :param save: The data needed to save this user :type save: dict | bytes :rtype: Response
[ "Save", "a", "script" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/migrations/apitax_controller.py#L198-L227
b3j0f/schema
b3j0f/schema/lang/factory.py
build
def build(_resource, _cache=True, **kwargs): """Build a schema from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use cache system. :rtype: Schema. """ return _SCHEMAFACTORY.build(_resource=_resource, _cache=True, **kwargs)
python
def build(_resource, _cache=True, **kwargs): """Build a schema from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use cache system. :rtype: Schema. """ return _SCHEMAFACTORY.build(_resource=_resource, _cache=True, **kwargs)
[ "def", "build", "(", "_resource", ",", "_cache", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "_SCHEMAFACTORY", ".", "build", "(", "_resource", "=", "_resource", ",", "_cache", "=", "True", ",", "*", "*", "kwargs", ")" ]
Build a schema from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use cache system. :rtype: Schema.
[ "Build", "a", "schema", "from", "input", "_resource", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L185-L192
b3j0f/schema
b3j0f/schema/lang/factory.py
getschemacls
def getschemacls(resource, besteffort=False): """Get schema class related to input resource. :param resource: resource from which get schema class. :param bool besteffort: if True (default) try a best effort in parsing the inheritance tree of resource if resource is a class. :rtype: type ...
python
def getschemacls(resource, besteffort=False): """Get schema class related to input resource. :param resource: resource from which get schema class. :param bool besteffort: if True (default) try a best effort in parsing the inheritance tree of resource if resource is a class. :rtype: type ...
[ "def", "getschemacls", "(", "resource", ",", "besteffort", "=", "False", ")", ":", "return", "_SCHEMAFACTORY", ".", "getschemacls", "(", "resource", "=", "resource", ",", "besteffort", "=", "besteffort", ")" ]
Get schema class related to input resource. :param resource: resource from which get schema class. :param bool besteffort: if True (default) try a best effort in parsing the inheritance tree of resource if resource is a class. :rtype: type
[ "Get", "schema", "class", "related", "to", "input", "resource", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L203-L213
b3j0f/schema
b3j0f/schema/lang/factory.py
getresource
def getresource(self, schemacls, name): """Get a resource from a builder name. :param type schemacls: waited schema class. :param str name: builder name to use. :return: resource returned by the right builder.getresource(schema). """ return _SCHEMAFACTORY.getresource(schemacls=schemacls, name=n...
python
def getresource(self, schemacls, name): """Get a resource from a builder name. :param type schemacls: waited schema class. :param str name: builder name to use. :return: resource returned by the right builder.getresource(schema). """ return _SCHEMAFACTORY.getresource(schemacls=schemacls, name=n...
[ "def", "getresource", "(", "self", ",", "schemacls", ",", "name", ")", ":", "return", "_SCHEMAFACTORY", ".", "getresource", "(", "schemacls", "=", "schemacls", ",", "name", "=", "name", ")" ]
Get a resource from a builder name. :param type schemacls: waited schema class. :param str name: builder name to use. :return: resource returned by the right builder.getresource(schema).
[ "Get", "a", "resource", "from", "a", "builder", "name", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L216-L223
b3j0f/schema
b3j0f/schema/lang/factory.py
SchemaFactory.registerbuilder
def registerbuilder(self, builder, name=None): """Register a schema builder with a key name. Can be used such as a decorator where the builder can be the name for a short use. :param SchemaBuilder builder: schema builder. :param str name: builder name. Default is builder name o...
python
def registerbuilder(self, builder, name=None): """Register a schema builder with a key name. Can be used such as a decorator where the builder can be the name for a short use. :param SchemaBuilder builder: schema builder. :param str name: builder name. Default is builder name o...
[ "def", "registerbuilder", "(", "self", ",", "builder", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "uuid", "(", ")", "self", ".", "_builders", "[", "name", "]", "=", "builder", "return", "builder" ]
Register a schema builder with a key name. Can be used such as a decorator where the builder can be the name for a short use. :param SchemaBuilder builder: schema builder. :param str name: builder name. Default is builder name or generated.
[ "Register", "a", "schema", "builder", "with", "a", "key", "name", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L54-L68
b3j0f/schema
b3j0f/schema/lang/factory.py
SchemaFactory.build
def build(self, _resource, _cache=True, updatecontent=True, **kwargs): """Build a schema class from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use _cache system. :param bool updatecontent: if True (default) update result. :rtyp...
python
def build(self, _resource, _cache=True, updatecontent=True, **kwargs): """Build a schema class from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use _cache system. :param bool updatecontent: if True (default) update result. :rtyp...
[ "def", "build", "(", "self", ",", "_resource", ",", "_cache", "=", "True", ",", "updatecontent", "=", "True", ",", "*", "*", "kwargs", ")", ":", "result", "=", "None", "if", "_cache", "and", "_resource", "in", "self", ".", "_schemasbyresource", ":", "r...
Build a schema class from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use _cache system. :param bool updatecontent: if True (default) update result. :rtype: Schema.
[ "Build", "a", "schema", "class", "from", "input", "_resource", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L93-L127
b3j0f/schema
b3j0f/schema/lang/factory.py
SchemaFactory.getschemacls
def getschemacls(self, resource, besteffort=True): """Get schema class related to input resource. :param resource: resource from which get schema class. :param bool besteffort: if True (default) try a best effort in parsing the inheritance tree of resource if resource is a class. ...
python
def getschemacls(self, resource, besteffort=True): """Get schema class related to input resource. :param resource: resource from which get schema class. :param bool besteffort: if True (default) try a best effort in parsing the inheritance tree of resource if resource is a class. ...
[ "def", "getschemacls", "(", "self", ",", "resource", ",", "besteffort", "=", "True", ")", ":", "result", "=", "None", "if", "hasattr", "(", "resource", ",", "'mro'", ")", "and", "besteffort", "and", "isclass", "(", "resource", ")", ":", "resources", "=",...
Get schema class related to input resource. :param resource: resource from which get schema class. :param bool besteffort: if True (default) try a best effort in parsing the inheritance tree of resource if resource is a class. :rtype: type
[ "Get", "schema", "class", "related", "to", "input", "resource", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L129-L151
b3j0f/schema
b3j0f/schema/lang/factory.py
SchemaFactory.getresource
def getresource(self, schemacls, name): """Get a resource from a builder name. :param type schemacls: waited schema class. :param str name: builder name to use. :return: resource returned by the right builder.getresource(schema). """ return self.builders[name].getresourc...
python
def getresource(self, schemacls, name): """Get a resource from a builder name. :param type schemacls: waited schema class. :param str name: builder name to use. :return: resource returned by the right builder.getresource(schema). """ return self.builders[name].getresourc...
[ "def", "getresource", "(", "self", ",", "schemacls", ",", "name", ")", ":", "return", "self", ".", "builders", "[", "name", "]", ".", "getresource", "(", "schemacls", "=", "schemacls", ")" ]
Get a resource from a builder name. :param type schemacls: waited schema class. :param str name: builder name to use. :return: resource returned by the right builder.getresource(schema).
[ "Get", "a", "resource", "from", "a", "builder", "name", "." ]
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L153-L160
nandilugio/pepython
pepython/task_def.py
s
def s(command, verbose=False, fail_fast=True, interactive=False): """ Run a shell command. """ completed_process = None output = None if interactive: completed_process = subprocess.run( command, shell=True, stdin=sys.stdin, stdout=sys.stdo...
python
def s(command, verbose=False, fail_fast=True, interactive=False): """ Run a shell command. """ completed_process = None output = None if interactive: completed_process = subprocess.run( command, shell=True, stdin=sys.stdin, stdout=sys.stdo...
[ "def", "s", "(", "command", ",", "verbose", "=", "False", ",", "fail_fast", "=", "True", ",", "interactive", "=", "False", ")", ":", "completed_process", "=", "None", "output", "=", "None", "if", "interactive", ":", "completed_process", "=", "subprocess", ...
Run a shell command.
[ "Run", "a", "shell", "command", "." ]
train
https://github.com/nandilugio/pepython/blob/c991b571b66fac7918499e292212f598b5c7b758/pepython/task_def.py#L28-L87
formwork-io/lazarus
lazarus/__init__.py
stop
def stop(): '''Stops lazarus, regardless of which mode it was started in. For example: >>> import lazarus >>> lazarus.default() >>> lazarus.stop() ''' global _active if not _active: msg = 'lazarus is not active' raise RuntimeWarning(msg) _observer.stop()...
python
def stop(): '''Stops lazarus, regardless of which mode it was started in. For example: >>> import lazarus >>> lazarus.default() >>> lazarus.stop() ''' global _active if not _active: msg = 'lazarus is not active' raise RuntimeWarning(msg) _observer.stop()...
[ "def", "stop", "(", ")", ":", "global", "_active", "if", "not", "_active", ":", "msg", "=", "'lazarus is not active'", "raise", "RuntimeWarning", "(", "msg", ")", "_observer", ".", "stop", "(", ")", "_observer", ".", "join", "(", ")", "_deactivate", "(", ...
Stops lazarus, regardless of which mode it was started in. For example: >>> import lazarus >>> lazarus.default() >>> lazarus.stop()
[ "Stops", "lazarus", "regardless", "of", "which", "mode", "it", "was", "started", "in", "." ]
train
https://github.com/formwork-io/lazarus/blob/b2b6120fe06d69c23b4f41d55b6d71860a9fdeaa/lazarus/__init__.py#L32-L47
formwork-io/lazarus
lazarus/__init__.py
_restart
def _restart(): '''Schedule the restart; returning True if cancelled, False otherwise.''' if _restart_cb: # https://github.com/formwork-io/lazarus/issues/2 if _restart_cb() is not None: # restart cancelled return True def down_watchdog(): _observer.stop() ...
python
def _restart(): '''Schedule the restart; returning True if cancelled, False otherwise.''' if _restart_cb: # https://github.com/formwork-io/lazarus/issues/2 if _restart_cb() is not None: # restart cancelled return True def down_watchdog(): _observer.stop() ...
[ "def", "_restart", "(", ")", ":", "if", "_restart_cb", ":", "# https://github.com/formwork-io/lazarus/issues/2", "if", "_restart_cb", "(", ")", "is", "not", "None", ":", "# restart cancelled", "return", "True", "def", "down_watchdog", "(", ")", ":", "_observer", "...
Schedule the restart; returning True if cancelled, False otherwise.
[ "Schedule", "the", "restart", ";", "returning", "True", "if", "cancelled", "False", "otherwise", "." ]
train
https://github.com/formwork-io/lazarus/blob/b2b6120fe06d69c23b4f41d55b6d71860a9fdeaa/lazarus/__init__.py#L66-L90
formwork-io/lazarus
lazarus/__init__.py
is_restart_event
def is_restart_event(event): '''Default logic for whether a filesystem event is a *restart event*. For example: >>> import collections >>> Event = collections.namedtuple('Event', 'src_path dest_path') >>> vim_ev = Event('foo.py', None) >>> is_restart_event(vim_ev) True ...
python
def is_restart_event(event): '''Default logic for whether a filesystem event is a *restart event*. For example: >>> import collections >>> Event = collections.namedtuple('Event', 'src_path dest_path') >>> vim_ev = Event('foo.py', None) >>> is_restart_event(vim_ev) True ...
[ "def", "is_restart_event", "(", "event", ")", ":", "if", "event", ".", "src_path", ".", "endswith", "(", "'.py'", ")", ":", "return", "True", "elif", "hasattr", "(", "event", ",", "'dest_path'", ")", "and", "event", ".", "dest_path", ".", "endswith", "("...
Default logic for whether a filesystem event is a *restart event*. For example: >>> import collections >>> Event = collections.namedtuple('Event', 'src_path dest_path') >>> vim_ev = Event('foo.py', None) >>> is_restart_event(vim_ev) True >>> sublime_ev = Event('.sub...
[ "Default", "logic", "for", "whether", "a", "filesystem", "event", "is", "a", "*", "restart", "event", "*", "." ]
train
https://github.com/formwork-io/lazarus/blob/b2b6120fe06d69c23b4f41d55b6d71860a9fdeaa/lazarus/__init__.py#L93-L116
formwork-io/lazarus
lazarus/__init__.py
default
def default(restart_cb=None, restart_func=None, close_fds=True): '''Sets up lazarus in default mode. See the :py:func:`custom` function for a more powerful mode of use. The default mode of lazarus is to watch all modules rooted at ``PYTHONPATH`` for changes and restart when they take place. Keywo...
python
def default(restart_cb=None, restart_func=None, close_fds=True): '''Sets up lazarus in default mode. See the :py:func:`custom` function for a more powerful mode of use. The default mode of lazarus is to watch all modules rooted at ``PYTHONPATH`` for changes and restart when they take place. Keywo...
[ "def", "default", "(", "restart_cb", "=", "None", ",", "restart_func", "=", "None", ",", "close_fds", "=", "True", ")", ":", "if", "_active", ":", "msg", "=", "'lazarus is already active'", "raise", "RuntimeWarning", "(", "msg", ")", "_python_path", "=", "os...
Sets up lazarus in default mode. See the :py:func:`custom` function for a more powerful mode of use. The default mode of lazarus is to watch all modules rooted at ``PYTHONPATH`` for changes and restart when they take place. Keyword arguments: restart_cb -- Callback invoked prior to restartin...
[ "Sets", "up", "lazarus", "in", "default", "mode", "." ]
train
https://github.com/formwork-io/lazarus/blob/b2b6120fe06d69c23b4f41d55b6d71860a9fdeaa/lazarus/__init__.py#L119-L210
formwork-io/lazarus
lazarus/__init__.py
custom
def custom(srcpaths, event_cb=None, poll_interval=1, recurse=True, restart_cb=None, restart_func=None, close_fds=True): '''Sets up lazarus in custom mode. See the :py:func:`default` function for a simpler mode of use. The custom mode of lazarus is to watch all modules rooted at any of the s...
python
def custom(srcpaths, event_cb=None, poll_interval=1, recurse=True, restart_cb=None, restart_func=None, close_fds=True): '''Sets up lazarus in custom mode. See the :py:func:`default` function for a simpler mode of use. The custom mode of lazarus is to watch all modules rooted at any of the s...
[ "def", "custom", "(", "srcpaths", ",", "event_cb", "=", "None", ",", "poll_interval", "=", "1", ",", "recurse", "=", "True", ",", "restart_cb", "=", "None", ",", "restart_func", "=", "None", ",", "close_fds", "=", "True", ")", ":", "if", "_active", ":"...
Sets up lazarus in custom mode. See the :py:func:`default` function for a simpler mode of use. The custom mode of lazarus is to watch all modules rooted at any of the source paths provided for changes and restart when they take place. Keyword arguments: event_cb -- Callback invoked when a fi...
[ "Sets", "up", "lazarus", "in", "custom", "mode", "." ]
train
https://github.com/formwork-io/lazarus/blob/b2b6120fe06d69c23b4f41d55b6d71860a9fdeaa/lazarus/__init__.py#L213-L337
0compute/xtraceback
xtraceback/xtraceback.py
XTraceback.tty_stream
def tty_stream(self): """ Whether or not our stream is a tty """ return hasattr(self.options.stream, "isatty") \ and self.options.stream.isatty()
python
def tty_stream(self): """ Whether or not our stream is a tty """ return hasattr(self.options.stream, "isatty") \ and self.options.stream.isatty()
[ "def", "tty_stream", "(", "self", ")", ":", "return", "hasattr", "(", "self", ".", "options", ".", "stream", ",", "\"isatty\"", ")", "and", "self", ".", "options", ".", "stream", ".", "isatty", "(", ")" ]
Whether or not our stream is a tty
[ "Whether", "or", "not", "our", "stream", "is", "a", "tty" ]
train
https://github.com/0compute/xtraceback/blob/5f4ae11cf21e6eea830d79aed66d3cd91bd013cd/xtraceback/xtraceback.py#L107-L112
0compute/xtraceback
xtraceback/xtraceback.py
XTraceback.color
def color(self): """ Whether or not color should be output """ return self.tty_stream if self.options.color is None \ else self.options.color
python
def color(self): """ Whether or not color should be output """ return self.tty_stream if self.options.color is None \ else self.options.color
[ "def", "color", "(", "self", ")", ":", "return", "self", ".", "tty_stream", "if", "self", ".", "options", ".", "color", "is", "None", "else", "self", ".", "options", ".", "color" ]
Whether or not color should be output
[ "Whether", "or", "not", "color", "should", "be", "output" ]
train
https://github.com/0compute/xtraceback/blob/5f4ae11cf21e6eea830d79aed66d3cd91bd013cd/xtraceback/xtraceback.py#L115-L120
bitlabstudio/django-unshorten
unshorten/decorators.py
api_auth
def api_auth(func): """ If the user is not logged in, this decorator looks for basic HTTP auth data in the request header. """ @wraps(func) def _decorator(request, *args, **kwargs): authentication = APIAuthentication(request) if authentication.authenticate(): return ...
python
def api_auth(func): """ If the user is not logged in, this decorator looks for basic HTTP auth data in the request header. """ @wraps(func) def _decorator(request, *args, **kwargs): authentication = APIAuthentication(request) if authentication.authenticate(): return ...
[ "def", "api_auth", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "_decorator", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "authentication", "=", "APIAuthentication", "(", "request", ")", "if", "authentication", ...
If the user is not logged in, this decorator looks for basic HTTP auth data in the request header.
[ "If", "the", "user", "is", "not", "logged", "in", "this", "decorator", "looks", "for", "basic", "HTTP", "auth", "data", "in", "the", "request", "header", "." ]
train
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/decorators.py#L9-L21
luismasuelli/python-cantrips
cantrips/decorators.py
customizable
def customizable(subdecorator, **defaults): """ Allows to create customizable decorators. Such decorators (like Django's django.contrib.auth.login_required) can be used in two different ways: # positionally @decorator def myfunc(...): ... and # namely @deco...
python
def customizable(subdecorator, **defaults): """ Allows to create customizable decorators. Such decorators (like Django's django.contrib.auth.login_required) can be used in two different ways: # positionally @decorator def myfunc(...): ... and # namely @deco...
[ "def", "customizable", "(", "subdecorator", ",", "*", "*", "defaults", ")", ":", "@", "wraps", "(", "subdecorator", ",", "assigned", "=", "(", "'__name__'", ",", "'__module__'", ")", ")", "def", "_decorator", "(", "*", "func", ",", "*", "*", "options", ...
Allows to create customizable decorators. Such decorators (like Django's django.contrib.auth.login_required) can be used in two different ways: # positionally @decorator def myfunc(...): ... and # namely @decorator(**opts) def myfunc(...): ... ...
[ "Allows", "to", "create", "customizable", "decorators", ".", "Such", "decorators", "(", "like", "Django", "s", "django", ".", "contrib", ".", "auth", ".", "login_required", ")", "can", "be", "used", "in", "two", "different", "ways", ":" ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/decorators.py#L5-L69
biocore/mustached-octo-ironman
moi/job.py
system_call
def system_call(cmd, **kwargs): """Call cmd and return (stdout, stderr, return_value). Parameters ---------- cmd: str Can be either a string containing the command to be run, or a sequence of strings that are the tokens of the command. kwargs : dict, optional Ignored. Availa...
python
def system_call(cmd, **kwargs): """Call cmd and return (stdout, stderr, return_value). Parameters ---------- cmd: str Can be either a string containing the command to be run, or a sequence of strings that are the tokens of the command. kwargs : dict, optional Ignored. Availa...
[ "def", "system_call", "(", "cmd", ",", "*", "*", "kwargs", ")", ":", "proc", "=", "Popen", "(", "cmd", ",", "universal_newlines", "=", "True", ",", "shell", "=", "True", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "PIPE", ")", "# communicate pulls ...
Call cmd and return (stdout, stderr, return_value). Parameters ---------- cmd: str Can be either a string containing the command to be run, or a sequence of strings that are the tokens of the command. kwargs : dict, optional Ignored. Available so that this function is compatible...
[ "Call", "cmd", "and", "return", "(", "stdout", "stderr", "return_value", ")", "." ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L21-L54
biocore/mustached-octo-ironman
moi/job.py
_status_change
def _status_change(id, new_status): """Update the status of a job The status associated with the id is updated, an update command is issued to the job's pubsub, and and the old status is returned. Parameters ---------- id : str The job ID new_status : str The status change ...
python
def _status_change(id, new_status): """Update the status of a job The status associated with the id is updated, an update command is issued to the job's pubsub, and and the old status is returned. Parameters ---------- id : str The job ID new_status : str The status change ...
[ "def", "_status_change", "(", "id", ",", "new_status", ")", ":", "job_info", "=", "json", ".", "loads", "(", "r_client", ".", "get", "(", "id", ")", ")", "old_status", "=", "job_info", "[", "'status'", "]", "job_info", "[", "'status'", "]", "=", "new_s...
Update the status of a job The status associated with the id is updated, an update command is issued to the job's pubsub, and and the old status is returned. Parameters ---------- id : str The job ID new_status : str The status change Returns ------- str Th...
[ "Update", "the", "status", "of", "a", "job" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L57-L80
biocore/mustached-octo-ironman
moi/job.py
_deposit_payload
def _deposit_payload(to_deposit): """Store job info, and publish an update Parameters ---------- to_deposit : dict The job info """ pubsub = to_deposit['pubsub'] id = to_deposit['id'] with r_client.pipeline() as pipe: pipe.set(id, json.dumps(to_deposit), ex=REDIS_KEY_T...
python
def _deposit_payload(to_deposit): """Store job info, and publish an update Parameters ---------- to_deposit : dict The job info """ pubsub = to_deposit['pubsub'] id = to_deposit['id'] with r_client.pipeline() as pipe: pipe.set(id, json.dumps(to_deposit), ex=REDIS_KEY_T...
[ "def", "_deposit_payload", "(", "to_deposit", ")", ":", "pubsub", "=", "to_deposit", "[", "'pubsub'", "]", "id", "=", "to_deposit", "[", "'id'", "]", "with", "r_client", ".", "pipeline", "(", ")", "as", "pipe", ":", "pipe", ".", "set", "(", "id", ",", ...
Store job info, and publish an update Parameters ---------- to_deposit : dict The job info
[ "Store", "job", "info", "and", "publish", "an", "update" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L83-L98
biocore/mustached-octo-ironman
moi/job.py
_redis_wrap
def _redis_wrap(job_info, func, *args, **kwargs): """Wrap something to compute The function that will have available, via kwargs['moi_update_status'], a method to modify the job status. This method can be used within the executing function by: old_status = kwargs['moi_update_status']('my new s...
python
def _redis_wrap(job_info, func, *args, **kwargs): """Wrap something to compute The function that will have available, via kwargs['moi_update_status'], a method to modify the job status. This method can be used within the executing function by: old_status = kwargs['moi_update_status']('my new s...
[ "def", "_redis_wrap", "(", "job_info", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "status_changer", "=", "partial", "(", "_status_change", ",", "job_info", "[", "'id'", "]", ")", "kwargs", "[", "'moi_update_status'", "]", "=", "sta...
Wrap something to compute The function that will have available, via kwargs['moi_update_status'], a method to modify the job status. This method can be used within the executing function by: old_status = kwargs['moi_update_status']('my new status') Parameters ---------- job_info : dic...
[ "Wrap", "something", "to", "compute" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L101-L154
biocore/mustached-octo-ironman
moi/job.py
submit
def submit(ctx_name, parent_id, name, url, func, *args, **kwargs): """Submit through a context Parameters ---------- ctx_name : str The name of the context to submit through parent_id : str The ID of the group that the job is a part of. name : str The name of the job ...
python
def submit(ctx_name, parent_id, name, url, func, *args, **kwargs): """Submit through a context Parameters ---------- ctx_name : str The name of the context to submit through parent_id : str The ID of the group that the job is a part of. name : str The name of the job ...
[ "def", "submit", "(", "ctx_name", ",", "parent_id", ",", "name", ",", "url", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "ctx_name", ",", "Context", ")", ":", "ctx", "=", "ctx_name", "else", ":", "ctx"...
Submit through a context Parameters ---------- ctx_name : str The name of the context to submit through parent_id : str The ID of the group that the job is a part of. name : str The name of the job url : str The handler that can take the results (e.g., /beta_dive...
[ "Submit", "through", "a", "context" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L157-L188
biocore/mustached-octo-ironman
moi/job.py
_submit
def _submit(ctx, parent_id, name, url, func, *args, **kwargs): """Submit a function to a cluster Parameters ---------- parent_id : str The ID of the group that the job is a part of. name : str The name of the job url : str The handler that can take the results (e.g., /be...
python
def _submit(ctx, parent_id, name, url, func, *args, **kwargs): """Submit a function to a cluster Parameters ---------- parent_id : str The ID of the group that the job is a part of. name : str The name of the job url : str The handler that can take the results (e.g., /be...
[ "def", "_submit", "(", "ctx", ",", "parent_id", ",", "name", ",", "url", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "parent_info", "=", "r_client", ".", "get", "(", "parent_id", ")", "if", "parent_info", "is", "None", ":", "p...
Submit a function to a cluster Parameters ---------- parent_id : str The ID of the group that the job is a part of. name : str The name of the job url : str The handler that can take the results (e.g., /beta_diversity/) func : function The function to execute. An...
[ "Submit", "a", "function", "to", "a", "cluster" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L191-L235
andreycizov/python-xrpc
xrpc/trace.py
trc
def trc(postfix: Optional[str] = None, *, depth=1) -> logging.Logger: """ Automatically generate a logger from the calling function :param postfix: append another logger name on top this :param depth: depth of the call stack at which to capture the caller name :return: instance of a logger with a c...
python
def trc(postfix: Optional[str] = None, *, depth=1) -> logging.Logger: """ Automatically generate a logger from the calling function :param postfix: append another logger name on top this :param depth: depth of the call stack at which to capture the caller name :return: instance of a logger with a c...
[ "def", "trc", "(", "postfix", ":", "Optional", "[", "str", "]", "=", "None", ",", "*", ",", "depth", "=", "1", ")", "->", "logging", ".", "Logger", ":", "x", "=", "inspect", ".", "stack", "(", ")", "[", "depth", "]", "code", "=", "x", "[", "0...
Automatically generate a logger from the calling function :param postfix: append another logger name on top this :param depth: depth of the call stack at which to capture the caller name :return: instance of a logger with a correct path to a current caller
[ "Automatically", "generate", "a", "logger", "from", "the", "calling", "function" ]
train
https://github.com/andreycizov/python-xrpc/blob/4f916383cda7de3272962f3ba07a64f7ec451098/xrpc/trace.py#L32-L55
mdeous/fatbotslim
fatbotslim/irc/tcp.py
TCP._recv_loop
def _recv_loop(self): """ Waits for data forever and feeds the input queue. """ while True: try: data = self._socket.recv(4096) self._ibuffer += data while '\r\n' in self._ibuffer: line, self._ibuffer = self....
python
def _recv_loop(self): """ Waits for data forever and feeds the input queue. """ while True: try: data = self._socket.recv(4096) self._ibuffer += data while '\r\n' in self._ibuffer: line, self._ibuffer = self....
[ "def", "_recv_loop", "(", "self", ")", ":", "while", "True", ":", "try", ":", "data", "=", "self", ".", "_socket", ".", "recv", "(", "4096", ")", "self", ".", "_ibuffer", "+=", "data", "while", "'\\r\\n'", "in", "self", ".", "_ibuffer", ":", "line", ...
Waits for data forever and feeds the input queue.
[ "Waits", "for", "data", "forever", "and", "feeds", "the", "input", "queue", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/tcp.py#L73-L85
mdeous/fatbotslim
fatbotslim/irc/tcp.py
TCP._send_loop
def _send_loop(self): """ Waits for data in the output queue to send. """ while True: try: line = self.oqueue.get().splitlines()[0][:500] self._obuffer += line + '\r\n' while self._obuffer: sent = self._socke...
python
def _send_loop(self): """ Waits for data in the output queue to send. """ while True: try: line = self.oqueue.get().splitlines()[0][:500] self._obuffer += line + '\r\n' while self._obuffer: sent = self._socke...
[ "def", "_send_loop", "(", "self", ")", ":", "while", "True", ":", "try", ":", "line", "=", "self", ".", "oqueue", ".", "get", "(", ")", ".", "splitlines", "(", ")", "[", "0", "]", "[", ":", "500", "]", "self", ".", "_obuffer", "+=", "line", "+"...
Waits for data in the output queue to send.
[ "Waits", "for", "data", "in", "the", "output", "queue", "to", "send", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/tcp.py#L87-L99
mdeous/fatbotslim
fatbotslim/irc/tcp.py
TCP.connect
def connect(self): """ Connects the socket and spawns the send/receive loops. """ jobs = [] self._socket.connect((self.host, self.port)) try: jobs = [spawn(self._recv_loop), spawn(self._send_loop)] joinall(jobs) finally: killall...
python
def connect(self): """ Connects the socket and spawns the send/receive loops. """ jobs = [] self._socket.connect((self.host, self.port)) try: jobs = [spawn(self._recv_loop), spawn(self._send_loop)] joinall(jobs) finally: killall...
[ "def", "connect", "(", "self", ")", ":", "jobs", "=", "[", "]", "self", ".", "_socket", ".", "connect", "(", "(", "self", ".", "host", ",", "self", ".", "port", ")", ")", "try", ":", "jobs", "=", "[", "spawn", "(", "self", ".", "_recv_loop", ")...
Connects the socket and spawns the send/receive loops.
[ "Connects", "the", "socket", "and", "spawns", "the", "send", "/", "receive", "loops", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/tcp.py#L101-L111
mdeous/fatbotslim
fatbotslim/irc/tcp.py
SSL._create_socket
def _create_socket(self): """ Creates a new SSL enabled socket and sets its timeout. """ log.warning('No certificate check is performed for SSL connections') s = super(SSL, self)._create_socket() return wrap_socket(s)
python
def _create_socket(self): """ Creates a new SSL enabled socket and sets its timeout. """ log.warning('No certificate check is performed for SSL connections') s = super(SSL, self)._create_socket() return wrap_socket(s)
[ "def", "_create_socket", "(", "self", ")", ":", "log", ".", "warning", "(", "'No certificate check is performed for SSL connections'", ")", "s", "=", "super", "(", "SSL", ",", "self", ")", ".", "_create_socket", "(", ")", "return", "wrap_socket", "(", "s", ")"...
Creates a new SSL enabled socket and sets its timeout.
[ "Creates", "a", "new", "SSL", "enabled", "socket", "and", "sets", "its", "timeout", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/tcp.py#L125-L131
openstack/stacktach-stackdistiller
stackdistiller/distiller.py
load_config
def load_config(filename): """Load the event definitions from yaml config file.""" logger.debug("Event Definitions configuration file: %s", filename) with open(filename, 'r') as cf: config = cf.read() try: events_config = yaml.safe_load(config) except yaml.YAMLError as err: ...
python
def load_config(filename): """Load the event definitions from yaml config file.""" logger.debug("Event Definitions configuration file: %s", filename) with open(filename, 'r') as cf: config = cf.read() try: events_config = yaml.safe_load(config) except yaml.YAMLError as err: ...
[ "def", "load_config", "(", "filename", ")", ":", "logger", ".", "debug", "(", "\"Event Definitions configuration file: %s\"", ",", "filename", ")", "with", "open", "(", "filename", ",", "'r'", ")", "as", "cf", ":", "config", "=", "cf", ".", "read", "(", ")...
Load the event definitions from yaml config file.
[ "Load", "the", "event", "definitions", "from", "yaml", "config", "file", "." ]
train
https://github.com/openstack/stacktach-stackdistiller/blob/38cc32994cc5411c3f7c76f31ef3ea8b3245e871/stackdistiller/distiller.py#L47-L72
openstack/stacktach-stackdistiller
stackdistiller/distiller.py
EventDefinition._extract_when
def _extract_when(body): """Extract the generated datetime from the notification.""" # NOTE: I am keeping the logic the same as it was in openstack # code, However, *ALL* notifications should have a 'timestamp' # field, it's part of the notification envelope spec. If this was # ...
python
def _extract_when(body): """Extract the generated datetime from the notification.""" # NOTE: I am keeping the logic the same as it was in openstack # code, However, *ALL* notifications should have a 'timestamp' # field, it's part of the notification envelope spec. If this was # ...
[ "def", "_extract_when", "(", "body", ")", ":", "# NOTE: I am keeping the logic the same as it was in openstack", "# code, However, *ALL* notifications should have a 'timestamp'", "# field, it's part of the notification envelope spec. If this was", "# put here because some openstack project is gene...
Extract the generated datetime from the notification.
[ "Extract", "the", "generated", "datetime", "from", "the", "notification", "." ]
train
https://github.com/openstack/stacktach-stackdistiller/blob/38cc32994cc5411c3f7c76f31ef3ea8b3245e871/stackdistiller/distiller.py#L259-L271
ErikBjare/pyzenobase
pyzenobase/zenobase_api.py
ZenobaseAPI.list_buckets
def list_buckets(self, offset=0, limit=100): """Limit breaks above 100""" # TODO: If limit > 100, do multiple fetches if limit > 100: raise Exception("Zenobase can't handle limits over 100") return self._get("/users/{}/buckets/?order=label&offset={}&limit={}".format(self.clie...
python
def list_buckets(self, offset=0, limit=100): """Limit breaks above 100""" # TODO: If limit > 100, do multiple fetches if limit > 100: raise Exception("Zenobase can't handle limits over 100") return self._get("/users/{}/buckets/?order=label&offset={}&limit={}".format(self.clie...
[ "def", "list_buckets", "(", "self", ",", "offset", "=", "0", ",", "limit", "=", "100", ")", ":", "# TODO: If limit > 100, do multiple fetches", "if", "limit", ">", "100", ":", "raise", "Exception", "(", "\"Zenobase can't handle limits over 100\"", ")", "return", "...
Limit breaks above 100
[ "Limit", "breaks", "above", "100" ]
train
https://github.com/ErikBjare/pyzenobase/blob/eb0572c7441a350bf5578bc5287f3be53d32ea19/pyzenobase/zenobase_api.py#L54-L59
TkTech/pytextql
pytextql/core.py
_create_table
def _create_table(db, table_name, columns, overwrite=False): """ Create's `table_name` in `db` if it does not already exist, and adds any missing columns. :param db: An active SQLite3 Connection. :param table_name: The (unicode) name of the table to setup. :param columns: An iterable of column ...
python
def _create_table(db, table_name, columns, overwrite=False): """ Create's `table_name` in `db` if it does not already exist, and adds any missing columns. :param db: An active SQLite3 Connection. :param table_name: The (unicode) name of the table to setup. :param columns: An iterable of column ...
[ "def", "_create_table", "(", "db", ",", "table_name", ",", "columns", ",", "overwrite", "=", "False", ")", ":", "with", "contextlib", ".", "closing", "(", "db", ".", "cursor", "(", ")", ")", "as", "c", ":", "table_exists", "=", "c", ".", "execute", "...
Create's `table_name` in `db` if it does not already exist, and adds any missing columns. :param db: An active SQLite3 Connection. :param table_name: The (unicode) name of the table to setup. :param columns: An iterable of column names to ensure exist. :param overwrite: If ``True`` and the table al...
[ "Create", "s", "table_name", "in", "db", "if", "it", "does", "not", "already", "exist", "and", "adds", "any", "missing", "columns", "." ]
train
https://github.com/TkTech/pytextql/blob/e054a7a4df7262deaca49bdbf748c00acf011b51/pytextql/core.py#L104-L159