partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Q._op
A basic operation operating on a single value.
marrow/mongo/query/query.py
def _op(self, operation, other, *allowed): """A basic operation operating on a single value.""" f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self._combining, (q._op(operation, other, *allowed) for q in f)) # pylint:disable=pr...
def _op(self, operation, other, *allowed): """A basic operation operating on a single value.""" f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self._combining, (q._op(operation, other, *allowed) for q in f)) # pylint:disable=pr...
[ "A", "basic", "operation", "operating", "on", "a", "single", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L154-L170
[ "def", "_op", "(", "self", ",", "operation", ",", "other", ",", "*", "allowed", ")", ":", "f", "=", "self", ".", "_field", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "return", "reduce", "(", "self...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q._iop
An iterative operation operating on multiple values. Consumes iterators to construct a concrete list at time of execution.
marrow/mongo/query/query.py
def _iop(self, operation, other, *allowed): """An iterative operation operating on multiple values. Consumes iterators to construct a concrete list at time of execution. """ f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self....
def _iop(self, operation, other, *allowed): """An iterative operation operating on multiple values. Consumes iterators to construct a concrete list at time of execution. """ f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self....
[ "An", "iterative", "operation", "operating", "on", "multiple", "values", ".", "Consumes", "iterators", "to", "construct", "a", "concrete", "list", "at", "time", "of", "execution", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L172-L196
[ "def", "_iop", "(", "self", ",", "operation", ",", "other", ",", "*", "allowed", ")", ":", "f", "=", "self", ".", "_field", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "return", "reduce", "(", "sel...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.S
Allow for the projection (and update) of nested values contained within the single match of an array. Projection operator: https://docs.mongodb.com/manual/reference/operator/projection/positional/#proj._S_ Array update operator: https://docs.mongodb.com/manual/reference/operator/update/positional/
marrow/mongo/query/query.py
def S(self): """Allow for the projection (and update) of nested values contained within the single match of an array. Projection operator: https://docs.mongodb.com/manual/reference/operator/projection/positional/#proj._S_ Array update operator: https://docs.mongodb.com/manual/reference/operator/update/position...
def S(self): """Allow for the projection (and update) of nested values contained within the single match of an array. Projection operator: https://docs.mongodb.com/manual/reference/operator/projection/positional/#proj._S_ Array update operator: https://docs.mongodb.com/manual/reference/operator/update/position...
[ "Allow", "for", "the", "projection", "(", "and", "update", ")", "of", "nested", "values", "contained", "within", "the", "single", "match", "of", "an", "array", ".", "Projection", "operator", ":", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L201-L213
[ "def", "S", "(", "self", ")", ":", "if", "self", ".", "_combining", ":", "raise", "TypeError", "(", "\"Unable to dereference after combining fields.\"", ")", "instance", "=", "self", ".", "__class__", "(", "self", ".", "_document", ",", "self", ".", "_field", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.re
Matches string values against a regular expression compiled of individual parts. Document.field.re(r'^', variable_part, r'\\.') Regex operator: {$regex: value} Documentation: https://docs.mongodb.com/manual/reference/operator/query/regex/
marrow/mongo/query/query.py
def re(self, *parts): """Matches string values against a regular expression compiled of individual parts. Document.field.re(r'^', variable_part, r'\\.') Regex operator: {$regex: value} Documentation: https://docs.mongodb.com/manual/reference/operator/query/regex/ """ if self._combining: # We are ...
def re(self, *parts): """Matches string values against a regular expression compiled of individual parts. Document.field.re(r'^', variable_part, r'\\.') Regex operator: {$regex: value} Documentation: https://docs.mongodb.com/manual/reference/operator/query/regex/ """ if self._combining: # We are ...
[ "Matches", "string", "values", "against", "a", "regular", "expression", "compiled", "of", "individual", "parts", ".", "Document", ".", "field", ".", "re", "(", "r", "^", "variable_part", "r", "\\\\", ".", ")", "Regex", "operator", ":", "{", "$regex", ":", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L387-L399
[ "def", "re", "(", "self", ",", "*", "parts", ")", ":", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "return", "reduce", "(", "self", ".", "_combining", ",", "(", "q", ".", "re", "(", "*", "parts",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.match
Selects documents if element in the array field matches all the specified conditions. Document.field.match(...) Array operator: {$elemMatch: value} Documentation: https://docs.mongodb.org/manual/reference/operator/query/elemMatch/#op._S_elemMatch
marrow/mongo/query/query.py
def match(self, q): """Selects documents if element in the array field matches all the specified conditions. Document.field.match(...) Array operator: {$elemMatch: value} Documentation: https://docs.mongodb.org/manual/reference/operator/query/elemMatch/#op._S_elemMatch """ if self._combining: # W...
def match(self, q): """Selects documents if element in the array field matches all the specified conditions. Document.field.match(...) Array operator: {$elemMatch: value} Documentation: https://docs.mongodb.org/manual/reference/operator/query/elemMatch/#op._S_elemMatch """ if self._combining: # W...
[ "Selects", "documents", "if", "element", "in", "the", "array", "field", "matches", "all", "the", "specified", "conditions", ".", "Document", ".", "field", ".", "match", "(", "...", ")", "Array", "operator", ":", "{", "$elemMatch", ":", "value", "}", "Docum...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L415-L434
[ "def", "match", "(", "self", ",", "q", ")", ":", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "return", "reduce", "(", "self", ".", "_combining", ",", "(", "qp", ".", "match", "(", "q", ")", "for"...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.range
Matches values that are between a minimum and maximum value, semi-inclusive. Document.field.range(4, 12) This will find documents with a field whose value is greater than or equal to 4, and less than 12. Comparison operator: {$gte: gte, $lt: lt}
marrow/mongo/query/query.py
def range(self, gte, lt): """Matches values that are between a minimum and maximum value, semi-inclusive. Document.field.range(4, 12) This will find documents with a field whose value is greater than or equal to 4, and less than 12. Comparison operator: {$gte: gte, $lt: lt} """ if self._combini...
def range(self, gte, lt): """Matches values that are between a minimum and maximum value, semi-inclusive. Document.field.range(4, 12) This will find documents with a field whose value is greater than or equal to 4, and less than 12. Comparison operator: {$gte: gte, $lt: lt} """ if self._combini...
[ "Matches", "values", "that", "are", "between", "a", "minimum", "and", "maximum", "value", "semi", "-", "inclusive", ".", "Document", ".", "field", ".", "range", "(", "4", "12", ")", "This", "will", "find", "documents", "with", "a", "field", "whose", "val...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L436-L454
[ "def", "range", "(", "self", ",", "gte", ",", "lt", ")", ":", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "print", "(", "\"Combining\"", ",", "self", ".", "_combining", ",", "self", ".", "_field", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.size
Selects documents if the array field is a specified size. Document.field.size(5) Array operator: {$size: value} Documentation: https://docs.mongodb.org/manual/reference/operator/query/size/#op._S_size
marrow/mongo/query/query.py
def size(self, value): """Selects documents if the array field is a specified size. Document.field.size(5) Array operator: {$size: value} Documentation: https://docs.mongodb.org/manual/reference/operator/query/size/#op._S_size """ if self._combining: # We are a field-compound query fragment, e.g....
def size(self, value): """Selects documents if the array field is a specified size. Document.field.size(5) Array operator: {$size: value} Documentation: https://docs.mongodb.org/manual/reference/operator/query/size/#op._S_size """ if self._combining: # We are a field-compound query fragment, e.g....
[ "Selects", "documents", "if", "the", "array", "field", "is", "a", "specified", "size", ".", "Document", ".", "field", ".", "size", "(", "5", ")", "Array", "operator", ":", "{", "$size", ":", "value", "}", "Documentation", ":", "https", ":", "//", "docs...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L456-L472
[ "def", "size", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "return", "reduce", "(", "self", ".", "_combining", ",", "(", "q", ".", "size", "(", "value", ")", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.of_type
Selects documents if a field is of the correct type. Document.field.of_type() Document.field.of_type('string') Element operator: {$type: self.__foreign__} Documentation: https://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type
marrow/mongo/query/query.py
def of_type(self, *kinds): """Selects documents if a field is of the correct type. Document.field.of_type() Document.field.of_type('string') Element operator: {$type: self.__foreign__} Documentation: https://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type """ if self._combinin...
def of_type(self, *kinds): """Selects documents if a field is of the correct type. Document.field.of_type() Document.field.of_type('string') Element operator: {$type: self.__foreign__} Documentation: https://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type """ if self._combinin...
[ "Selects", "documents", "if", "a", "field", "is", "of", "the", "correct", "type", ".", "Document", ".", "field", ".", "of_type", "()", "Document", ".", "field", ".", "of_type", "(", "string", ")", "Element", "operator", ":", "{", "$type", ":", "self", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L505-L526
[ "def", "of_type", "(", "self", ",", "*", "kinds", ")", ":", "if", "self", ".", "_combining", ":", "# We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).", "return", "reduce", "(", "self", ".", "_combining", ",", "(", "q", ".", "of_type", "(", "*", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.near
Order results by their distance from the given point, optionally with range limits in meters. Geospatial operator: {$near: {...}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/near/#op._S_near { $near: { $geometry: <center; Point or (long, lat)>, $minDistance: <min; ...
marrow/mongo/query/query.py
def near(self, center, sphere=False, min=None, max=None): """Order results by their distance from the given point, optionally with range limits in meters. Geospatial operator: {$near: {...}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/near/#op._S_near { $near: { $geom...
def near(self, center, sphere=False, min=None, max=None): """Order results by their distance from the given point, optionally with range limits in meters. Geospatial operator: {$near: {...}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/near/#op._S_near { $near: { $geom...
[ "Order", "results", "by", "their", "distance", "from", "the", "given", "point", "optionally", "with", "range", "limits", "in", "meters", ".", "Geospatial", "operator", ":", "{", "$near", ":", "{", "...", "}}", "Documentation", ":", "https", ":", "//", "doc...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L531-L567
[ "def", "near", "(", "self", ",", "center", ",", "sphere", "=", "False", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "from", "marrow", ".", "mongo", ".", "geo", "import", "Point", "near", "=", "{", "'$geometry'", ":", "Point", "(", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.within
Select geometries within a bounding GeoJSON geometry. Documentation: https://docs.mongodb.com/manual/reference/operator/query/geoWithin/#op._S_geoWithin Geospatial operator: {$geoWithin: {$geometry: ...}}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/geometry/#op._S_geometry ...
marrow/mongo/query/query.py
def within(self, geometry=None, center=None, sphere=None, radius=None, box=None, polygon=None, crs=None): """Select geometries within a bounding GeoJSON geometry. Documentation: https://docs.mongodb.com/manual/reference/operator/query/geoWithin/#op._S_geoWithin Geospatial operator: {$geoWithin: {$geometry: ...
def within(self, geometry=None, center=None, sphere=None, radius=None, box=None, polygon=None, crs=None): """Select geometries within a bounding GeoJSON geometry. Documentation: https://docs.mongodb.com/manual/reference/operator/query/geoWithin/#op._S_geoWithin Geospatial operator: {$geoWithin: {$geometry: ...
[ "Select", "geometries", "within", "a", "bounding", "GeoJSON", "geometry", ".", "Documentation", ":", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/", "manual", "/", "reference", "/", "operator", "/", "query", "/", "geoWithin", "/", "#op", ".", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L569-L633
[ "def", "within", "(", "self", ",", "geometry", "=", "None", ",", "center", "=", "None", ",", "sphere", "=", "None", ",", "radius", "=", "None", ",", "box", "=", "None", ",", "polygon", "=", "None", ",", "crs", "=", "None", ")", ":", "if", "geomet...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Q.intersects
Select geometries that intersect with a GeoJSON geometry. Geospatial operator: {$geoIntersects: {...}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/geoIntersects/#op._S_geoIntersects { $geoIntersects: { $geometry: <geometry; a GeoJSON object> } }
marrow/mongo/query/query.py
def intersects(self, geometry, crs=None): """Select geometries that intersect with a GeoJSON geometry. Geospatial operator: {$geoIntersects: {...}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/geoIntersects/#op._S_geoIntersects { $geoIntersects: { $geometry: <geometry; a Ge...
def intersects(self, geometry, crs=None): """Select geometries that intersect with a GeoJSON geometry. Geospatial operator: {$geoIntersects: {...}} Documentation: https://docs.mongodb.com/manual/reference/operator/query/geoIntersects/#op._S_geoIntersects { $geoIntersects: { $geometry: <geometry; a Ge...
[ "Select", "geometries", "that", "intersect", "with", "a", "GeoJSON", "geometry", ".", "Geospatial", "operator", ":", "{", "$geoIntersects", ":", "{", "...", "}}", "Documentation", ":", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/", "manual", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L635-L650
[ "def", "intersects", "(", "self", ",", "geometry", ",", "crs", "=", "None", ")", ":", "if", "crs", ":", "geometry", "=", "dict", "(", "geometry", ")", "geometry", "[", "'crs'", "]", "=", "{", "'type'", ":", "'name'", ",", "'properties'", ":", "{", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
HopcroftKarp.__dfs
we recursively run dfs on each vertices in free_vertex, :param v: vertices in free_vertex :return: True if P is not empty (i.e., the maximal set of vertex-disjoint alternating path of length k) and false otherwise.
hopcroftkarp/__init__.py
def __dfs(self, v, index, layers): """ we recursively run dfs on each vertices in free_vertex, :param v: vertices in free_vertex :return: True if P is not empty (i.e., the maximal set of vertex-disjoint alternating path of length k) and false otherwise. """ if in...
def __dfs(self, v, index, layers): """ we recursively run dfs on each vertices in free_vertex, :param v: vertices in free_vertex :return: True if P is not empty (i.e., the maximal set of vertex-disjoint alternating path of length k) and false otherwise. """ if in...
[ "we", "recursively", "run", "dfs", "on", "each", "vertices", "in", "free_vertex" ]
sofiatolaosebikan/hopcroftkarp
python
https://github.com/sofiatolaosebikan/hopcroftkarp/blob/5e6cf4f95702304847307a07d369f8041edff8c9/hopcroftkarp/__init__.py#L84-L109
[ "def", "__dfs", "(", "self", ",", "v", ",", "index", ",", "layers", ")", ":", "if", "index", "==", "0", ":", "path", "=", "[", "v", "]", "while", "self", ".", "_dfs_parent", "[", "v", "]", "!=", "v", ":", "path", ".", "append", "(", "self", "...
5e6cf4f95702304847307a07d369f8041edff8c9
train
Parser.symbol
Gets (and create if not exists) as named symbol. Optionally, you can specify a binding power (bp) value, which will be used to control operator presedence; the higher the value, the tighter a token binds to the tokens that follow.
parser/base.py
def symbol(self, ident, bp=0): ''' Gets (and create if not exists) as named symbol. Optionally, you can specify a binding power (bp) value, which will be used to control operator presedence; the higher the value, the tighter a token binds to the tokens that follow. ''' ...
def symbol(self, ident, bp=0): ''' Gets (and create if not exists) as named symbol. Optionally, you can specify a binding power (bp) value, which will be used to control operator presedence; the higher the value, the tighter a token binds to the tokens that follow. ''' ...
[ "Gets", "(", "and", "create", "if", "not", "exists", ")", "as", "named", "symbol", "." ]
tehmaze/parser
python
https://github.com/tehmaze/parser/blob/ccc69236304b2f00671f14c62433e8830b838101/parser/base.py#L22-L41
[ "def", "symbol", "(", "self", ",", "ident", ",", "bp", "=", "0", ")", ":", "try", ":", "s", "=", "self", ".", "symbols", "[", "ident", "]", "except", "KeyError", ":", "class", "s", "(", "SymbolBase", ")", ":", "pass", "s", ".", "__name__", "=", ...
ccc69236304b2f00671f14c62433e8830b838101
train
Parser.method
Symbol decorator.
parser/base.py
def method(self, symbol): ''' Symbol decorator. ''' assert issubclass(symbol, SymbolBase) def wrapped(fn): setattr(symbol, fn.__name__, fn) return wrapped
def method(self, symbol): ''' Symbol decorator. ''' assert issubclass(symbol, SymbolBase) def wrapped(fn): setattr(symbol, fn.__name__, fn) return wrapped
[ "Symbol", "decorator", "." ]
tehmaze/parser
python
https://github.com/tehmaze/parser/blob/ccc69236304b2f00671f14c62433e8830b838101/parser/base.py#L69-L76
[ "def", "method", "(", "self", ",", "symbol", ")", ":", "assert", "issubclass", "(", "symbol", ",", "SymbolBase", ")", "def", "wrapped", "(", "fn", ")", ":", "setattr", "(", "symbol", ",", "fn", ".", "__name__", ",", "fn", ")", "return", "wrapped" ]
ccc69236304b2f00671f14c62433e8830b838101
train
_simpleparsefun
Simple date parsing function
business_calendar/business_calendar.py
def _simpleparsefun(date): """Simple date parsing function""" if hasattr(date, 'year'): return date try: date = datetime.datetime.strptime(date, '%Y-%m-%d') except ValueError: date = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S') return date
def _simpleparsefun(date): """Simple date parsing function""" if hasattr(date, 'year'): return date try: date = datetime.datetime.strptime(date, '%Y-%m-%d') except ValueError: date = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S') return date
[ "Simple", "date", "parsing", "function" ]
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L63-L71
[ "def", "_simpleparsefun", "(", "date", ")", ":", "if", "hasattr", "(", "date", ",", "'year'", ")", ":", "return", "date", "try", ":", "date", "=", "datetime", ".", "datetime", ".", "strptime", "(", "date", ",", "'%Y-%m-%d'", ")", "except", "ValueError", ...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.isworkday
Check if a given date is a work date, ignoring holidays. Args: date (date, datetime or str): Date to be checked. Returns: bool: True if the date is a work date, False otherwise.
business_calendar/business_calendar.py
def isworkday(self, date): """ Check if a given date is a work date, ignoring holidays. Args: date (date, datetime or str): Date to be checked. Returns: bool: True if the date is a work date, False otherwise. """ date = parsefun(date) ...
def isworkday(self, date): """ Check if a given date is a work date, ignoring holidays. Args: date (date, datetime or str): Date to be checked. Returns: bool: True if the date is a work date, False otherwise. """ date = parsefun(date) ...
[ "Check", "if", "a", "given", "date", "is", "a", "work", "date", "ignoring", "holidays", ".", "Args", ":", "date", "(", "date", "datetime", "or", "str", ")", ":", "Date", "to", "be", "checked", ".", "Returns", ":", "bool", ":", "True", "if", "the", ...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L188-L199
[ "def", "isworkday", "(", "self", ",", "date", ")", ":", "date", "=", "parsefun", "(", "date", ")", "return", "self", ".", "weekdaymap", "[", "date", ".", "weekday", "(", ")", "]", ".", "isworkday" ]
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.isholiday
Check if a given date is a holiday. Args: date (date, datetime or str): Date to be checked. Returns: bool: True if the date is a holiday, False otherwise.
business_calendar/business_calendar.py
def isholiday(self, date): """ Check if a given date is a holiday. Args: date (date, datetime or str): Date to be checked. Returns: bool: True if the date is a holiday, False otherwise. """ date = parsefun(date) if self.holiday...
def isholiday(self, date): """ Check if a given date is a holiday. Args: date (date, datetime or str): Date to be checked. Returns: bool: True if the date is a holiday, False otherwise. """ date = parsefun(date) if self.holiday...
[ "Check", "if", "a", "given", "date", "is", "a", "holiday", ".", "Args", ":", "date", "(", "date", "datetime", "or", "str", ")", ":", "Date", "to", "be", "checked", ".", "Returns", ":", "bool", ":", "True", "if", "the", "date", "is", "a", "holiday",...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L201-L223
[ "def", "isholiday", "(", "self", ",", "date", ")", ":", "date", "=", "parsefun", "(", "date", ")", "if", "self", ".", "holidays", ":", "# i is the index of first holiday >= date\r", "i", "=", "bisect", ".", "bisect_left", "(", "self", ".", "holidays", ",", ...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.adjust
Adjust the date to the closest work date. Args: date (date, datetime or str): Date to be adjusted. mode (integer): FOLLOWING, PREVIOUS or MODIFIEDFOLLOWING. Note: If date is already a business date than it is returned unchanged. How to use the ad...
business_calendar/business_calendar.py
def adjust(self, date, mode): """ Adjust the date to the closest work date. Args: date (date, datetime or str): Date to be adjusted. mode (integer): FOLLOWING, PREVIOUS or MODIFIEDFOLLOWING. Note: If date is already a business date than it i...
def adjust(self, date, mode): """ Adjust the date to the closest work date. Args: date (date, datetime or str): Date to be adjusted. mode (integer): FOLLOWING, PREVIOUS or MODIFIEDFOLLOWING. Note: If date is already a business date than it i...
[ "Adjust", "the", "date", "to", "the", "closest", "work", "date", ".", "Args", ":", "date", "(", "date", "datetime", "or", "str", ")", ":", "Date", "to", "be", "adjusted", ".", "mode", "(", "integer", ")", ":", "FOLLOWING", "PREVIOUS", "or", "MODIFIEDFO...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L238-L277
[ "def", "adjust", "(", "self", ",", "date", ",", "mode", ")", ":", "date", "=", "parsefun", "(", "date", ")", "if", "self", ".", "isbusday", "(", "date", ")", ":", "return", "date", "if", "mode", "==", "FOLLOWING", ":", "dateadj", "=", "self", ".", ...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.addworkdays
Add work days to a given date, ignoring holidays. Note: By definition, a zero offset causes the function to return the initial date, even it is not a work date. An offset of 1 represents the next work date, regardless of date being a work date or not. ...
business_calendar/business_calendar.py
def addworkdays(self, date, offset): """ Add work days to a given date, ignoring holidays. Note: By definition, a zero offset causes the function to return the initial date, even it is not a work date. An offset of 1 represents the next work date, rega...
def addworkdays(self, date, offset): """ Add work days to a given date, ignoring holidays. Note: By definition, a zero offset causes the function to return the initial date, even it is not a work date. An offset of 1 represents the next work date, rega...
[ "Add", "work", "days", "to", "a", "given", "date", "ignoring", "holidays", ".", "Note", ":", "By", "definition", "a", "zero", "offset", "causes", "the", "function", "to", "return", "the", "initial", "date", "even", "it", "is", "not", "a", "work", "date",...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L279-L331
[ "def", "addworkdays", "(", "self", ",", "date", ",", "offset", ")", ":", "date", "=", "parsefun", "(", "date", ")", "if", "offset", "==", "0", ":", "return", "date", "if", "offset", ">", "0", ":", "direction", "=", "1", "idx_offset", "=", "Calendar",...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.addbusdays
Add business days to a given date, taking holidays into consideration. Note: By definition, a zero offset causes the function to return the initial date, even it is not a business date. An offset of 1 represents the next business date, regardless of date being a ...
business_calendar/business_calendar.py
def addbusdays(self, date, offset): """ Add business days to a given date, taking holidays into consideration. Note: By definition, a zero offset causes the function to return the initial date, even it is not a business date. An offset of 1 represents ...
def addbusdays(self, date, offset): """ Add business days to a given date, taking holidays into consideration. Note: By definition, a zero offset causes the function to return the initial date, even it is not a business date. An offset of 1 represents ...
[ "Add", "business", "days", "to", "a", "given", "date", "taking", "holidays", "into", "consideration", ".", "Note", ":", "By", "definition", "a", "zero", "offset", "causes", "the", "function", "to", "return", "the", "initial", "date", "even", "it", "is", "n...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L333-L401
[ "def", "addbusdays", "(", "self", ",", "date", ",", "offset", ")", ":", "date", "=", "parsefun", "(", "date", ")", "if", "offset", "==", "0", ":", "return", "date", "dateoffset", "=", "self", ".", "addworkdays", "(", "date", ",", "offset", ")", "holi...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar._workdaycount
(PRIVATE) Count work days between two dates, ignoring holidays.
business_calendar/business_calendar.py
def _workdaycount(self, date1, date2): """ (PRIVATE) Count work days between two dates, ignoring holidays. """ assert date2 >= date1 date1wd = date1.weekday() date2wd = date2.weekday() if not self.weekdaymap[date2wd].isworkday: date2 += datetim...
def _workdaycount(self, date1, date2): """ (PRIVATE) Count work days between two dates, ignoring holidays. """ assert date2 >= date1 date1wd = date1.weekday() date2wd = date2.weekday() if not self.weekdaymap[date2wd].isworkday: date2 += datetim...
[ "(", "PRIVATE", ")", "Count", "work", "days", "between", "two", "dates", "ignoring", "holidays", "." ]
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L403-L424
[ "def", "_workdaycount", "(", "self", ",", "date1", ",", "date2", ")", ":", "assert", "date2", ">=", "date1", "date1wd", "=", "date1", ".", "weekday", "(", ")", "date2wd", "=", "date2", ".", "weekday", "(", ")", "if", "not", "self", ".", "weekdaymap", ...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.workdaycount
Count work days between two dates, ignoring holidays. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval. Note: The adopted notation is COB to COB, so effectively date1 is not included...
business_calendar/business_calendar.py
def workdaycount(self, date1, date2): """ Count work days between two dates, ignoring holidays. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval. Note: The adopted notation is C...
def workdaycount(self, date1, date2): """ Count work days between two dates, ignoring holidays. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval. Note: The adopted notation is C...
[ "Count", "work", "days", "between", "two", "dates", "ignoring", "holidays", ".", "Args", ":", "date1", "(", "date", "datetime", "or", "str", ")", ":", "Date", "start", "of", "interval", ".", "date2", "(", "date", "datetime", "or", "str", ")", ":", "Dat...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L426-L461
[ "def", "workdaycount", "(", "self", ",", "date1", ",", "date2", ")", ":", "date1", "=", "parsefun", "(", "date1", ")", "date2", "=", "parsefun", "(", "date2", ")", "if", "date1", "==", "date2", ":", "return", "0", "elif", "date1", ">", "date2", ":", ...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.busdaycount
Count business days between two dates (private), taking holidays into consideration. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval. Note: The adopted notation is COB to COB, so effect...
business_calendar/business_calendar.py
def busdaycount(self, date1, date2): """ Count business days between two dates (private), taking holidays into consideration. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval. Note:...
def busdaycount(self, date1, date2): """ Count business days between two dates (private), taking holidays into consideration. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval. Note:...
[ "Count", "business", "days", "between", "two", "dates", "(", "private", ")", "taking", "holidays", "into", "consideration", ".", "Args", ":", "date1", "(", "date", "datetime", "or", "str", ")", ":", "Date", "start", "of", "interval", ".", "date2", "(", "...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L463-L528
[ "def", "busdaycount", "(", "self", ",", "date1", ",", "date2", ")", ":", "date1", "=", "parsefun", "(", "date1", ")", "date2", "=", "parsefun", "(", "date2", ")", "if", "date1", "==", "date2", ":", "return", "0", "elif", "date1", ">", "date2", ":", ...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.caleom
Adjust date to last day of the month, regardless of work days. Args: date (date, datetime or str): Date to be adjusted. Returns: datetime: Adjusted date.
business_calendar/business_calendar.py
def caleom(date): """ Adjust date to last day of the month, regardless of work days. Args: date (date, datetime or str): Date to be adjusted. Returns: datetime: Adjusted date. """ date = parsefun(date) date += datetime.timedelt...
def caleom(date): """ Adjust date to last day of the month, regardless of work days. Args: date (date, datetime or str): Date to be adjusted. Returns: datetime: Adjusted date. """ date = parsefun(date) date += datetime.timedelt...
[ "Adjust", "date", "to", "last", "day", "of", "the", "month", "regardless", "of", "work", "days", ".", "Args", ":", "date", "(", "date", "datetime", "or", "str", ")", ":", "Date", "to", "be", "adjusted", ".", "Returns", ":", "datetime", ":", "Adjusted",...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L531-L544
[ "def", "caleom", "(", "date", ")", ":", "date", "=", "parsefun", "(", "date", ")", "date", "+=", "datetime", ".", "timedelta", "(", "days", "=", "32", "-", "date", ".", "day", ")", "date", "-=", "datetime", ".", "timedelta", "(", "days", "=", "date...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
Calendar.range
Generate business days between two dates, taking holidays into consideration. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval, not included. Note: All business days between date1 (inc) ...
business_calendar/business_calendar.py
def range(self, date1, date2): """ Generate business days between two dates, taking holidays into consideration. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval, not included. Note...
def range(self, date1, date2): """ Generate business days between two dates, taking holidays into consideration. Args: date1 (date, datetime or str): Date start of interval. date2 (date, datetime or str): Date end of interval, not included. Note...
[ "Generate", "business", "days", "between", "two", "dates", "taking", "holidays", "into", "consideration", ".", "Args", ":", "date1", "(", "date", "datetime", "or", "str", ")", ":", "Date", "start", "of", "interval", ".", "date2", "(", "date", "datetime", "...
antoniobotelho/py-business-calendar
python
https://github.com/antoniobotelho/py-business-calendar/blob/92365fbddd043e41e33b01f1ddd9dd6a5094c031/business_calendar/business_calendar.py#L559-L594
[ "def", "range", "(", "self", ",", "date1", ",", "date2", ")", ":", "date1", "=", "self", ".", "adjust", "(", "parsefun", "(", "date1", ")", ",", "FOLLOWING", ")", "date2", "=", "parsefun", "(", "date2", ")", "holidays", "=", "[", "]", "holidx", "="...
92365fbddd043e41e33b01f1ddd9dd6a5094c031
train
KnockerModel._connect
Connect signal to current model
knocker/mixins.py
def _connect(cls): """ Connect signal to current model """ post_save.connect( notify_items, sender=cls, dispatch_uid='knocker_{0}'.format(cls.__name__) )
def _connect(cls): """ Connect signal to current model """ post_save.connect( notify_items, sender=cls, dispatch_uid='knocker_{0}'.format(cls.__name__) )
[ "Connect", "signal", "to", "current", "model" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/mixins.py#L31-L38
[ "def", "_connect", "(", "cls", ")", ":", "post_save", ".", "connect", "(", "notify_items", ",", "sender", "=", "cls", ",", "dispatch_uid", "=", "'knocker_{0}'", ".", "format", "(", "cls", ".", "__name__", ")", ")" ]
d25380d43a1f91285f1581dcf9db8510fe87f354
train
KnockerModel._disconnect
Disconnect signal from current model
knocker/mixins.py
def _disconnect(cls): """ Disconnect signal from current model """ post_save.disconnect( notify_items, sender=cls, dispatch_uid='knocker_{0}'.format(cls.__name__) )
def _disconnect(cls): """ Disconnect signal from current model """ post_save.disconnect( notify_items, sender=cls, dispatch_uid='knocker_{0}'.format(cls.__name__) )
[ "Disconnect", "signal", "from", "current", "model" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/mixins.py#L41-L48
[ "def", "_disconnect", "(", "cls", ")", ":", "post_save", ".", "disconnect", "(", "notify_items", ",", "sender", "=", "cls", ",", "dispatch_uid", "=", "'knocker_{0}'", ".", "format", "(", "cls", ".", "__name__", ")", ")" ]
d25380d43a1f91285f1581dcf9db8510fe87f354
train
KnockerModel.as_knock
Returns a dictionary with the knock data built from _knocker_data
knocker/mixins.py
def as_knock(self, created=False): """ Returns a dictionary with the knock data built from _knocker_data """ knock = {} if self.should_knock(created): for field, data in self._retrieve_data(None, self._knocker_data): knock[field] = data return ...
def as_knock(self, created=False): """ Returns a dictionary with the knock data built from _knocker_data """ knock = {} if self.should_knock(created): for field, data in self._retrieve_data(None, self._knocker_data): knock[field] = data return ...
[ "Returns", "a", "dictionary", "with", "the", "knock", "data", "built", "from", "_knocker_data" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/mixins.py#L97-L105
[ "def", "as_knock", "(", "self", ",", "created", "=", "False", ")", ":", "knock", "=", "{", "}", "if", "self", ".", "should_knock", "(", "created", ")", ":", "for", "field", ",", "data", "in", "self", ".", "_retrieve_data", "(", "None", ",", "self", ...
d25380d43a1f91285f1581dcf9db8510fe87f354
train
KnockerModel.send_knock
Send the knock in the associated channels Group
knocker/mixins.py
def send_knock(self, created=False): """ Send the knock in the associated channels Group """ knock = self.as_knock(created) if knock: gr = Group('knocker-{0}'.format(knock['language'])) gr.send({'text': json.dumps(knock)})
def send_knock(self, created=False): """ Send the knock in the associated channels Group """ knock = self.as_knock(created) if knock: gr = Group('knocker-{0}'.format(knock['language'])) gr.send({'text': json.dumps(knock)})
[ "Send", "the", "knock", "in", "the", "associated", "channels", "Group" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/mixins.py#L107-L114
[ "def", "send_knock", "(", "self", ",", "created", "=", "False", ")", ":", "knock", "=", "self", ".", "as_knock", "(", "created", ")", "if", "knock", ":", "gr", "=", "Group", "(", "'knocker-{0}'", ".", "format", "(", "knock", "[", "'language'", "]", "...
d25380d43a1f91285f1581dcf9db8510fe87f354
train
colorize
Colorize some message with ANSI colors specification :param printable: interface whose has __str__ or __repr__ method :param color: the colors defined in COLOR_MAP to colorize the text :style: can be 'normal', 'bold' or 'underline' :returns: the 'printable' colorized with style
decorating/color.py
def colorize(printable, color, style='normal', autoreset=True): """Colorize some message with ANSI colors specification :param printable: interface whose has __str__ or __repr__ method :param color: the colors defined in COLOR_MAP to colorize the text :style: can be 'normal', 'bold' or 'underline' ...
def colorize(printable, color, style='normal', autoreset=True): """Colorize some message with ANSI colors specification :param printable: interface whose has __str__ or __repr__ method :param color: the colors defined in COLOR_MAP to colorize the text :style: can be 'normal', 'bold' or 'underline' ...
[ "Colorize", "some", "message", "with", "ANSI", "colors", "specification" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/color.py#L45-L63
[ "def", "colorize", "(", "printable", ",", "color", ",", "style", "=", "'normal'", ",", "autoreset", "=", "True", ")", ":", "if", "not", "COLORED", ":", "# disable color", "return", "printable", "if", "color", "not", "in", "COLOR_MAP", ":", "raise", "Runtim...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
cache
Function: cache Summary: Decorator used to cache the input->output Examples: An fib memoized executes at O(1) time instead O(e^n) Attributes: @param (function): function Returns: wrapped function TODO: Give support to functions with kwargs
decorating/general.py
def cache(function): """ Function: cache Summary: Decorator used to cache the input->output Examples: An fib memoized executes at O(1) time instead O(e^n) Attributes: @param (function): function Returns: wrapped function TODO: Give support to functions with kwargs ...
def cache(function): """ Function: cache Summary: Decorator used to cache the input->output Examples: An fib memoized executes at O(1) time instead O(e^n) Attributes: @param (function): function Returns: wrapped function TODO: Give support to functions with kwargs ...
[ "Function", ":", "cache", "Summary", ":", "Decorator", "used", "to", "cache", "the", "input", "-", ">", "output", "Examples", ":", "An", "fib", "memoized", "executes", "at", "O", "(", "1", ")", "time", "instead", "O", "(", "e^n", ")", "Attributes", ":"...
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/general.py#L50-L75
[ "def", "cache", "(", "function", ")", ":", "memory", "=", "{", "}", "miss", "=", "object", "(", ")", "@", "wraps", "(", "function", ")", "def", "_wrapper", "(", "*", "args", ")", ":", "result", "=", "memory", ".", "get", "(", "args", ",", "miss",...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
color
Change text color for the linux terminal, defaults to green. Set "warning=True" for red.
hashes/common/helpers.py
def color(string, status=True, warning=False, bold=True): """ Change text color for the linux terminal, defaults to green. Set "warning=True" for red. """ attr = [] if status: # green attr.append('32') if warning: # red attr.append('31') if bold: a...
def color(string, status=True, warning=False, bold=True): """ Change text color for the linux terminal, defaults to green. Set "warning=True" for red. """ attr = [] if status: # green attr.append('32') if warning: # red attr.append('31') if bold: a...
[ "Change", "text", "color", "for", "the", "linux", "terminal", "defaults", "to", "green", ".", "Set", "warning", "=", "True", "for", "red", "." ]
FortyNorthSecurity/Hasher
python
https://github.com/FortyNorthSecurity/Hasher/blob/40173c56b36680ab1ddc57a9c13c36b3a1ec51c3/hashes/common/helpers.py#L10-L24
[ "def", "color", "(", "string", ",", "status", "=", "True", ",", "warning", "=", "False", ",", "bold", "=", "True", ")", ":", "attr", "=", "[", "]", "if", "status", ":", "# green", "attr", ".", "append", "(", "'32'", ")", "if", "warning", ":", "# ...
40173c56b36680ab1ddc57a9c13c36b3a1ec51c3
train
tail
A generator which will block and yield entries as they are added to a capped collection. Only use this on capped collections; behaviour is undefined against non-tailable cursors. Accepts a timeout as an integer or floating point number of seconds, indicating how long to wait for a result. Correct operation requires...
marrow/mongo/util/capped.py
def tail(collection, filter=None, projection=None, limit=0, timeout=None, aggregate=False): """A generator which will block and yield entries as they are added to a capped collection. Only use this on capped collections; behaviour is undefined against non-tailable cursors. Accepts a timeout as an integer or floati...
def tail(collection, filter=None, projection=None, limit=0, timeout=None, aggregate=False): """A generator which will block and yield entries as they are added to a capped collection. Only use this on capped collections; behaviour is undefined against non-tailable cursors. Accepts a timeout as an integer or floati...
[ "A", "generator", "which", "will", "block", "and", "yield", "entries", "as", "they", "are", "added", "to", "a", "capped", "collection", ".", "Only", "use", "this", "on", "capped", "collections", ";", "behaviour", "is", "undefined", "against", "non", "-", "...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/util/capped.py#L11-L46
[ "def", "tail", "(", "collection", ",", "filter", "=", "None", ",", "projection", "=", "None", ",", "limit", "=", "0", ",", "timeout", "=", "None", ",", "aggregate", "=", "False", ")", ":", "if", "not", "collection", ".", "options", "(", ")", ".", "...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
_patch
Patch pymongo's Collection object to add a tail method. While not nessicarily recommended, you can use this to inject `tail` as a method into Collection, making it generally accessible.
marrow/mongo/util/capped.py
def _patch(): """Patch pymongo's Collection object to add a tail method. While not nessicarily recommended, you can use this to inject `tail` as a method into Collection, making it generally accessible. """ if not __debug__: # pragma: no cover import warnings warnings.warn("A catgirl has died.", ImportWar...
def _patch(): """Patch pymongo's Collection object to add a tail method. While not nessicarily recommended, you can use this to inject `tail` as a method into Collection, making it generally accessible. """ if not __debug__: # pragma: no cover import warnings warnings.warn("A catgirl has died.", ImportWar...
[ "Patch", "pymongo", "s", "Collection", "object", "to", "add", "a", "tail", "method", ".", "While", "not", "nessicarily", "recommended", "you", "can", "use", "this", "to", "inject", "tail", "as", "a", "method", "into", "Collection", "making", "it", "generally...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/util/capped.py#L49-L61
[ "def", "_patch", "(", ")", ":", "if", "not", "__debug__", ":", "# pragma: no cover", "import", "warnings", "warnings", ".", "warn", "(", "\"A catgirl has died.\"", ",", "ImportWarning", ")", "from", "pymongo", ".", "collection", "import", "Collection", "Collection...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable._prepare_query
Process arguments to query methods. For internal use only. Positional arguments are treated as query components, combined using boolean AND reduction. Keyword arguments are processed depending on the passed in mapping and set of valid options, with non- option arguments treated as parametric query component...
marrow/mongo/core/trait/queryable.py
def _prepare_query(cls, mapping, valid, *args, **kw): """Process arguments to query methods. For internal use only. Positional arguments are treated as query components, combined using boolean AND reduction. Keyword arguments are processed depending on the passed in mapping and set of valid options, with no...
def _prepare_query(cls, mapping, valid, *args, **kw): """Process arguments to query methods. For internal use only. Positional arguments are treated as query components, combined using boolean AND reduction. Keyword arguments are processed depending on the passed in mapping and set of valid options, with no...
[ "Process", "arguments", "to", "query", "methods", ".", "For", "internal", "use", "only", ".", "Positional", "arguments", "are", "treated", "as", "query", "components", "combined", "using", "boolean", "AND", "reduction", ".", "Keyword", "arguments", "are", "proce...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L68-L110
[ "def", "_prepare_query", "(", "cls", ",", "mapping", ",", "valid", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "collection", "=", "cls", ".", "get_collection", "(", "kw", ".", "pop", "(", "'source'", ",", "None", ")", ")", "query", "=", "Filte...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable._prepare_find
Execute a find and return the resulting queryset using combined plain and parametric query generation. Additionally, performs argument case normalization, refer to the `_prepare_query` method's docstring.
marrow/mongo/core/trait/queryable.py
def _prepare_find(cls, *args, **kw): """Execute a find and return the resulting queryset using combined plain and parametric query generation. Additionally, performs argument case normalization, refer to the `_prepare_query` method's docstring. """ cls, collection, query, options = cls._prepare_query( ...
def _prepare_find(cls, *args, **kw): """Execute a find and return the resulting queryset using combined plain and parametric query generation. Additionally, performs argument case normalization, refer to the `_prepare_query` method's docstring. """ cls, collection, query, options = cls._prepare_query( ...
[ "Execute", "a", "find", "and", "return", "the", "resulting", "queryset", "using", "combined", "plain", "and", "parametric", "query", "generation", ".", "Additionally", "performs", "argument", "case", "normalization", "refer", "to", "the", "_prepare_query", "method",...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L113-L146
[ "def", "_prepare_find", "(", "cls", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "cls", ",", "collection", ",", "query", ",", "options", "=", "cls", ".", "_prepare_query", "(", "cls", ".", "FIND_MAPPING", ",", "cls", ".", "FIND_OPTIONS", ",", "*"...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable._prepare_aggregate
Generate and execute an aggregate query pipline using combined plain and parametric query generation. Additionally, performs argument case normalization, refer to the `_prepare_query` method's docstring. This provides a find-like interface for generating aggregate pipelines with a few shortcuts that make ag...
marrow/mongo/core/trait/queryable.py
def _prepare_aggregate(cls, *args, **kw): """Generate and execute an aggregate query pipline using combined plain and parametric query generation. Additionally, performs argument case normalization, refer to the `_prepare_query` method's docstring. This provides a find-like interface for generating aggregat...
def _prepare_aggregate(cls, *args, **kw): """Generate and execute an aggregate query pipline using combined plain and parametric query generation. Additionally, performs argument case normalization, refer to the `_prepare_query` method's docstring. This provides a find-like interface for generating aggregat...
[ "Generate", "and", "execute", "an", "aggregate", "query", "pipline", "using", "combined", "plain", "and", "parametric", "query", "generation", ".", "Additionally", "performs", "argument", "case", "normalization", "refer", "to", "the", "_prepare_query", "method", "s"...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L149-L192
[ "def", "_prepare_aggregate", "(", "cls", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "stages", "=", "[", "]", "stage_args", "=", "[", "]", "fragments", "=", "[", "]", "for", "arg", "in", "args", ":", "# Split the positional arguments into filter fragm...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable.find
Query the collection this class is bound to. Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyword arguments passed along with minor transformation. ...
marrow/mongo/core/trait/queryable.py
def find(cls, *args, **kw): """Query the collection this class is bound to. Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyword arguments passed al...
def find(cls, *args, **kw): """Query the collection this class is bound to. Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyword arguments passed al...
[ "Query", "the", "collection", "this", "class", "is", "bound", "to", ".", "Additional", "arguments", "are", "processed", "according", "to", "_prepare_find", "prior", "to", "passing", "to", "PyMongo", "where", "positional", "parameters", "are", "interpreted", "as", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L195-L206
[ "def", "find", "(", "cls", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "Doc", ",", "collection", ",", "query", ",", "options", "=", "cls", ".", "_prepare_find", "(", "*", "args", ",", "*", "*", "kw", ")", "return", "collection", ".", "find",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable.find_one
Get a single document from the collection this class is bound to. Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyword arguments passed along with min...
marrow/mongo/core/trait/queryable.py
def find_one(cls, *args, **kw): """Get a single document from the collection this class is bound to. Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyw...
def find_one(cls, *args, **kw): """Get a single document from the collection this class is bound to. Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyw...
[ "Get", "a", "single", "document", "from", "the", "collection", "this", "class", "is", "bound", "to", ".", "Additional", "arguments", "are", "processed", "according", "to", "_prepare_find", "prior", "to", "passing", "to", "PyMongo", "where", "positional", "parame...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L209-L227
[ "def", "find_one", "(", "cls", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "len", "(", "args", ")", "==", "1", "and", "not", "isinstance", "(", "args", "[", "0", "]", ",", "Filter", ")", ":", "args", "=", "(", "getattr", "(", "cls"...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable.find_in_sequence
Return a QuerySet iterating the results of a query in a defined order. Technically an aggregate. To be successful one must be running MongoDB 3.4 or later. Document order will not be represented otherwise. Based on the technique described here: http://s.webcore.io/2O3i0N2E3h0r See also: https://jira.mongodb...
marrow/mongo/core/trait/queryable.py
def find_in_sequence(cls, field, order, *args, **kw): """Return a QuerySet iterating the results of a query in a defined order. Technically an aggregate. To be successful one must be running MongoDB 3.4 or later. Document order will not be represented otherwise. Based on the technique described here: http:/...
def find_in_sequence(cls, field, order, *args, **kw): """Return a QuerySet iterating the results of a query in a defined order. Technically an aggregate. To be successful one must be running MongoDB 3.4 or later. Document order will not be represented otherwise. Based on the technique described here: http:/...
[ "Return", "a", "QuerySet", "iterating", "the", "results", "of", "a", "query", "in", "a", "defined", "order", ".", "Technically", "an", "aggregate", ".", "To", "be", "successful", "one", "must", "be", "running", "MongoDB", "3", ".", "4", "or", "later", "....
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L234-L260
[ "def", "find_in_sequence", "(", "cls", ",", "field", ",", "order", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "field", "=", "traverse", "(", "cls", ",", "field", ")", "order", "=", "list", "(", "order", ")", "# We need to coalesce the value to prep...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Queryable.reload
Reload the entire document from the database, or refresh specific named top-level fields.
marrow/mongo/core/trait/queryable.py
def reload(self, *fields, **kw): """Reload the entire document from the database, or refresh specific named top-level fields.""" Doc, collection, query, options = self._prepare_find(id=self.id, projection=fields, **kw) result = collection.find_one(query, **options) if fields: # Refresh only the requested...
def reload(self, *fields, **kw): """Reload the entire document from the database, or refresh specific named top-level fields.""" Doc, collection, query, options = self._prepare_find(id=self.id, projection=fields, **kw) result = collection.find_one(query, **options) if fields: # Refresh only the requested...
[ "Reload", "the", "entire", "document", "from", "the", "database", "or", "refresh", "specific", "named", "top", "-", "level", "fields", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L271-L284
[ "def", "reload", "(", "self", ",", "*", "fields", ",", "*", "*", "kw", ")", ":", "Doc", ",", "collection", ",", "query", ",", "options", "=", "self", ".", "_prepare_find", "(", "id", "=", "self", ".", "id", ",", "projection", "=", "fields", ",", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Pconf.get
Get values gathered from the previously set hierarchy. Respects the order in which sources are set, the first source set has the highest priority, overrides values with the same key that exist in sources with lower priority. Returns: dict: The dictionary containing values g...
pconf/pconf.py
def get(cls): """Get values gathered from the previously set hierarchy. Respects the order in which sources are set, the first source set has the highest priority, overrides values with the same key that exist in sources with lower priority. Returns: dict: The dicti...
def get(cls): """Get values gathered from the previously set hierarchy. Respects the order in which sources are set, the first source set has the highest priority, overrides values with the same key that exist in sources with lower priority. Returns: dict: The dicti...
[ "Get", "values", "gathered", "from", "the", "previously", "set", "hierarchy", "." ]
andrasmaroy/pconf
python
https://github.com/andrasmaroy/pconf/blob/1f930bf4e88bf8b4732fcc95557c66f3608b8821/pconf/pconf.py#L27-L45
[ "def", "get", "(", "cls", ")", ":", "results", "=", "{", "}", "hierarchy", "=", "cls", ".", "__hierarchy", "hierarchy", ".", "reverse", "(", ")", "for", "storeMethod", "in", "hierarchy", ":", "cls", ".", "merger", ".", "merge", "(", "results", ",", "...
1f930bf4e88bf8b4732fcc95557c66f3608b8821
train
Pconf.argv
Set command line arguments as a source Parses the command line arguments described by the parameters. Args: name: the long name of the argument (foo) short_name: the optional short name of the argument (f) type: the optional type of the argument, defaults to bool ...
pconf/pconf.py
def argv(cls, name, short_name=None, type=None, help=None): """ Set command line arguments as a source Parses the command line arguments described by the parameters. Args: name: the long name of the argument (foo) short_name: the optional short name of the argument (f) ...
def argv(cls, name, short_name=None, type=None, help=None): """ Set command line arguments as a source Parses the command line arguments described by the parameters. Args: name: the long name of the argument (foo) short_name: the optional short name of the argument (f) ...
[ "Set", "command", "line", "arguments", "as", "a", "source" ]
andrasmaroy/pconf
python
https://github.com/andrasmaroy/pconf/blob/1f930bf4e88bf8b4732fcc95557c66f3608b8821/pconf/pconf.py#L72-L83
[ "def", "argv", "(", "cls", ",", "name", ",", "short_name", "=", "None", ",", "type", "=", "None", ",", "help", "=", "None", ")", ":", "cls", ".", "__hierarchy", ".", "append", "(", "argv", ".", "Argv", "(", "name", ",", "short_name", ",", "type", ...
1f930bf4e88bf8b4732fcc95557c66f3608b8821
train
Pconf.env
Set environment variables as a source. By default all environment variables available to the process are used. This can be narrowed by the args. Args: separator: Keys are split along this character, the resulting splits are considered nested values. matc...
pconf/pconf.py
def env(cls, separator=None, match=None, whitelist=None, parse_values=None, to_lower=None, convert_underscores=None): """Set environment variables as a source. By default all environment variables available to the process are used. This can be narrowed by the args. Args: se...
def env(cls, separator=None, match=None, whitelist=None, parse_values=None, to_lower=None, convert_underscores=None): """Set environment variables as a source. By default all environment variables available to the process are used. This can be narrowed by the args. Args: se...
[ "Set", "environment", "variables", "as", "a", "source", "." ]
andrasmaroy/pconf
python
https://github.com/andrasmaroy/pconf/blob/1f930bf4e88bf8b4732fcc95557c66f3608b8821/pconf/pconf.py#L86-L104
[ "def", "env", "(", "cls", ",", "separator", "=", "None", ",", "match", "=", "None", ",", "whitelist", "=", "None", ",", "parse_values", "=", "None", ",", "to_lower", "=", "None", ",", "convert_underscores", "=", "None", ")", ":", "cls", ".", "__hierarc...
1f930bf4e88bf8b4732fcc95557c66f3608b8821
train
Pconf.file
Set a file as a source. File are parsed as literal python dicts by default, this behaviour can be configured. Args: path: The path to the file to be parsed encoding: The encoding of the file. Defaults to 'raw'. Available built-in values: 'ini', 'json', '...
pconf/pconf.py
def file(cls, path, encoding=None, parser=None): """Set a file as a source. File are parsed as literal python dicts by default, this behaviour can be configured. Args: path: The path to the file to be parsed encoding: The encoding of the file. De...
def file(cls, path, encoding=None, parser=None): """Set a file as a source. File are parsed as literal python dicts by default, this behaviour can be configured. Args: path: The path to the file to be parsed encoding: The encoding of the file. De...
[ "Set", "a", "file", "as", "a", "source", "." ]
andrasmaroy/pconf
python
https://github.com/andrasmaroy/pconf/blob/1f930bf4e88bf8b4732fcc95557c66f3608b8821/pconf/pconf.py#L107-L122
[ "def", "file", "(", "cls", ",", "path", ",", "encoding", "=", "None", ",", "parser", "=", "None", ")", ":", "cls", ".", "__hierarchy", ".", "append", "(", "file", ".", "File", "(", "path", ",", "encoding", ",", "parser", ")", ")" ]
1f930bf4e88bf8b4732fcc95557c66f3608b8821
train
P
Generate a MongoDB projection dictionary using the Django ORM style.
marrow/mongo/param/project.py
def P(Document, *fields, **kw): """Generate a MongoDB projection dictionary using the Django ORM style.""" __always__ = kw.pop('__always__', set()) projected = set() omitted = set() for field in fields: if field[0] in ('-', '!'): omitted.add(field[1:]) elif field[0] == '+': projected.add(field[1:]) ...
def P(Document, *fields, **kw): """Generate a MongoDB projection dictionary using the Django ORM style.""" __always__ = kw.pop('__always__', set()) projected = set() omitted = set() for field in fields: if field[0] in ('-', '!'): omitted.add(field[1:]) elif field[0] == '+': projected.add(field[1:]) ...
[ "Generate", "a", "MongoDB", "projection", "dictionary", "using", "the", "Django", "ORM", "style", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/param/project.py#L11-L35
[ "def", "P", "(", "Document", ",", "*", "fields", ",", "*", "*", "kw", ")", ":", "__always__", "=", "kw", ".", "pop", "(", "'__always__'", ",", "set", "(", ")", ")", "projected", "=", "set", "(", ")", "omitted", "=", "set", "(", ")", "for", "fie...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
do_login
Performs a login handshake with a user on the command-line. This method will handle all of the follow-up requests (e.g. capcha or two-factor). A login that requires two-factor looks like this:: >>> import mwapi.cli >>> import mwapi >>> mwapi.cli.do_login(mwapi.Session("https://en.wiki...
mwapi/cli.py
def do_login(session, for_what): """ Performs a login handshake with a user on the command-line. This method will handle all of the follow-up requests (e.g. capcha or two-factor). A login that requires two-factor looks like this:: >>> import mwapi.cli >>> import mwapi >>> mwap...
def do_login(session, for_what): """ Performs a login handshake with a user on the command-line. This method will handle all of the follow-up requests (e.g. capcha or two-factor). A login that requires two-factor looks like this:: >>> import mwapi.cli >>> import mwapi >>> mwap...
[ "Performs", "a", "login", "handshake", "with", "a", "user", "on", "the", "command", "-", "line", ".", "This", "method", "will", "handle", "all", "of", "the", "follow", "-", "up", "requests", "(", "e", ".", "g", ".", "capcha", "or", "two", "-", "facto...
mediawiki-utilities/python-mwapi
python
https://github.com/mediawiki-utilities/python-mwapi/blob/7a653c29207ecd318ae4b369d398aed13f26951d/mwapi/cli.py#L16-L42
[ "def", "do_login", "(", "session", ",", "for_what", ")", ":", "# noqa", "username", ",", "password", "=", "request_username_password", "(", "for_what", ")", "try", ":", "session", ".", "login", "(", "username", ",", "password", ")", "except", "ClientInteractio...
7a653c29207ecd318ae4b369d398aed13f26951d
train
MongoSession.is_valid
Identify if the given session ID is currently valid. Return True if valid, False if explicitly invalid, None if unknown.
web/session/mongo.py
def is_valid(self, context, sid): """Identify if the given session ID is currently valid. Return True if valid, False if explicitly invalid, None if unknown. """ record = self._Document.find_one(sid, project=('expires', )) if not record: return return not record._expired
def is_valid(self, context, sid): """Identify if the given session ID is currently valid. Return True if valid, False if explicitly invalid, None if unknown. """ record = self._Document.find_one(sid, project=('expires', )) if not record: return return not record._expired
[ "Identify", "if", "the", "given", "session", "ID", "is", "currently", "valid", ".", "Return", "True", "if", "valid", "False", "if", "explicitly", "invalid", "None", "if", "unknown", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/web/session/mongo.py#L55-L66
[ "def", "is_valid", "(", "self", ",", "context", ",", "sid", ")", ":", "record", "=", "self", ".", "_Document", ".", "find_one", "(", "sid", ",", "project", "=", "(", "'expires'", ",", ")", ")", "if", "not", "record", ":", "return", "return", "not", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
MongoSession.invalidate
Immediately expire a session from the backing store.
web/session/mongo.py
def invalidate(self, context, sid): """Immediately expire a session from the backing store.""" result = self._Document.get_collection().delete_one({'_id': sid}) return result.deleted_count == 1
def invalidate(self, context, sid): """Immediately expire a session from the backing store.""" result = self._Document.get_collection().delete_one({'_id': sid}) return result.deleted_count == 1
[ "Immediately", "expire", "a", "session", "from", "the", "backing", "store", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/web/session/mongo.py#L68-L73
[ "def", "invalidate", "(", "self", ",", "context", ",", "sid", ")", ":", "result", "=", "self", ".", "_Document", ".", "get_collection", "(", ")", ".", "delete_one", "(", "{", "'_id'", ":", "sid", "}", ")", "return", "result", ".", "deleted_count", "=="...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
MongoSession.persist
Update or insert the session document into the configured collection
web/session/mongo.py
def persist(self, context): """Update or insert the session document into the configured collection""" D = self._Document document = context.session[self.name] D.get_collection().replace_one(D.id == document.id, document, True)
def persist(self, context): """Update or insert the session document into the configured collection""" D = self._Document document = context.session[self.name] D.get_collection().replace_one(D.id == document.id, document, True)
[ "Update", "or", "insert", "the", "session", "document", "into", "the", "configured", "collection" ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/web/session/mongo.py#L92-L98
[ "def", "persist", "(", "self", ",", "context", ")", ":", "D", "=", "self", ".", "_Document", "document", "=", "context", ".", "session", "[", "self", ".", "name", "]", "D", ".", "get_collection", "(", ")", ".", "replace_one", "(", "D", ".", "id", "...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
ws_connect
Channels connection setup. Register the current client on the related Group according to the language
knocker/consumers.py
def ws_connect(message): """ Channels connection setup. Register the current client on the related Group according to the language """ prefix, language = message['path'].strip('/').split('/') gr = Group('knocker-{0}'.format(language)) gr.add(message.reply_channel) message.channel_session...
def ws_connect(message): """ Channels connection setup. Register the current client on the related Group according to the language """ prefix, language = message['path'].strip('/').split('/') gr = Group('knocker-{0}'.format(language)) gr.add(message.reply_channel) message.channel_session...
[ "Channels", "connection", "setup", ".", "Register", "the", "current", "client", "on", "the", "related", "Group", "according", "to", "the", "language" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/consumers.py#L9-L18
[ "def", "ws_connect", "(", "message", ")", ":", "prefix", ",", "language", "=", "message", "[", "'path'", "]", ".", "strip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "gr", "=", "Group", "(", "'knocker-{0}'", ".", "format", "(", "language", ")",...
d25380d43a1f91285f1581dcf9db8510fe87f354
train
ws_disconnect
Channels connection close. Deregister the client
knocker/consumers.py
def ws_disconnect(message): """ Channels connection close. Deregister the client """ language = message.channel_session['knocker'] gr = Group('knocker-{0}'.format(language)) gr.discard(message.reply_channel)
def ws_disconnect(message): """ Channels connection close. Deregister the client """ language = message.channel_session['knocker'] gr = Group('knocker-{0}'.format(language)) gr.discard(message.reply_channel)
[ "Channels", "connection", "close", ".", "Deregister", "the", "client" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/consumers.py#L30-L37
[ "def", "ws_disconnect", "(", "message", ")", ":", "language", "=", "message", ".", "channel_session", "[", "'knocker'", "]", "gr", "=", "Group", "(", "'knocker-{0}'", ".", "format", "(", "language", ")", ")", "gr", ".", "discard", "(", "message", ".", "r...
d25380d43a1f91285f1581dcf9db8510fe87f354
train
Ops.copy
Return a shallow copy.
marrow/mongo/query/ops.py
def copy(self): """Return a shallow copy.""" return self.__class__(self.operations.copy(), self.collection, self.document)
def copy(self): """Return a shallow copy.""" return self.__class__(self.operations.copy(), self.collection, self.document)
[ "Return", "a", "shallow", "copy", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/ops.py#L105-L107
[ "def", "copy", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "operations", ".", "copy", "(", ")", ",", "self", ".", "collection", ",", "self", ".", "document", ")" ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Reference.to_foreign
Transform to a MongoDB-safe value.
marrow/mongo/core/field/reference.py
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument """Transform to a MongoDB-safe value.""" if self.cache: return self._populate_cache(value) identifier = value # First, we handle the typcial Document object case. if isinstance(value, Document): identifier = value.__data_...
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument """Transform to a MongoDB-safe value.""" if self.cache: return self._populate_cache(value) identifier = value # First, we handle the typcial Document object case. if isinstance(value, Document): identifier = value.__data_...
[ "Transform", "to", "a", "MongoDB", "-", "safe", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/reference.py#L87-L118
[ "def", "to_foreign", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "# pylint:disable=unused-argument", "if", "self", ".", "cache", ":", "return", "self", ".", "_populate_cache", "(", "value", ")", "identifier", "=", "value", "# First, we handle...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
space_wave
Function: space_wave Summary: This function is used to generate a wave-like padding spacement based on the variable lambda Examples: >>> print('\n'.join(space_wave(x) for x in range(100)) █ ███ ████ ██████ ███████ █...
decorating/animation.py
def space_wave(phase, amplitude=12, frequency=0.1): """ Function: space_wave Summary: This function is used to generate a wave-like padding spacement based on the variable lambda Examples: >>> print('\n'.join(space_wave(x) for x in range(100)) █ ███ ...
def space_wave(phase, amplitude=12, frequency=0.1): """ Function: space_wave Summary: This function is used to generate a wave-like padding spacement based on the variable lambda Examples: >>> print('\n'.join(space_wave(x) for x in range(100)) █ ███ ...
[ "Function", ":", "space_wave", "Summary", ":", "This", "function", "is", "used", "to", "generate", "a", "wave", "-", "like", "padding", "spacement", "based", "on", "the", "variable", "lambda", "Examples", ":", ">>>", "print", "(", "\\", "n", ".", "join", ...
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/animation.py#L114-L151
[ "def", "space_wave", "(", "phase", ",", "amplitude", "=", "12", ",", "frequency", "=", "0.1", ")", ":", "wave", "=", "cycle", "(", "horizontal", ")", "return", "''", ".", "join", "(", "(", "next", "(", "wave", ")", "for", "x", "in", "range", "(", ...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
AnimatedDecorator.start
Start a new animation instance
decorating/animation.py
def start(self, autopush=True): """Start a new animation instance""" if self.enabled: if autopush: self.push_message(self.message) self.spinner.message = ' - '.join(self.animation.messages) if not self.spinner.running: self.animatio...
def start(self, autopush=True): """Start a new animation instance""" if self.enabled: if autopush: self.push_message(self.message) self.spinner.message = ' - '.join(self.animation.messages) if not self.spinner.running: self.animatio...
[ "Start", "a", "new", "animation", "instance" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/animation.py#L235-L246
[ "def", "start", "(", "self", ",", "autopush", "=", "True", ")", ":", "if", "self", ".", "enabled", ":", "if", "autopush", ":", "self", ".", "push_message", "(", "self", ".", "message", ")", "self", ".", "spinner", ".", "message", "=", "' - '", ".", ...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
AnimatedDecorator.stop
Stop the thread animation gracefully and reset_message
decorating/animation.py
def stop(cls): """Stop the thread animation gracefully and reset_message""" if AnimatedDecorator._enabled: if cls.spinner.running: cls.spinner.running = False cls.animation.thread.join() if any(cls.animation.messages): cls.pop_mess...
def stop(cls): """Stop the thread animation gracefully and reset_message""" if AnimatedDecorator._enabled: if cls.spinner.running: cls.spinner.running = False cls.animation.thread.join() if any(cls.animation.messages): cls.pop_mess...
[ "Stop", "the", "thread", "animation", "gracefully", "and", "reset_message" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/animation.py#L249-L259
[ "def", "stop", "(", "cls", ")", ":", "if", "AnimatedDecorator", ".", "_enabled", ":", "if", "cls", ".", "spinner", ".", "running", ":", "cls", ".", "spinner", ".", "running", "=", "False", "cls", ".", "animation", ".", "thread", ".", "join", "(", ")"...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
AnimatedDecorator.auto_message
Try guess the message by the args passed args: a set of args passed on the wrapper __call__ in the definition above. if the object already have some message (defined in __init__), we don't change that. If the first arg is a function, so is decorated without argument, use ...
decorating/animation.py
def auto_message(self, args): """Try guess the message by the args passed args: a set of args passed on the wrapper __call__ in the definition above. if the object already have some message (defined in __init__), we don't change that. If the first arg is a function, so is...
def auto_message(self, args): """Try guess the message by the args passed args: a set of args passed on the wrapper __call__ in the definition above. if the object already have some message (defined in __init__), we don't change that. If the first arg is a function, so is...
[ "Try", "guess", "the", "message", "by", "the", "args", "passed" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/animation.py#L296-L315
[ "def", "auto_message", "(", "self", ",", "args", ")", ":", "if", "any", "(", "args", ")", "and", "callable", "(", "args", "[", "0", "]", ")", "and", "not", "self", ".", "message", ":", "return", "args", "[", "0", "]", ".", "__name__", "elif", "no...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
WritingDecorator.start
Activate the TypingStream on stdout
decorating/animation.py
def start(self): """Activate the TypingStream on stdout""" self.streams.append(sys.stdout) sys.stdout = self.stream
def start(self): """Activate the TypingStream on stdout""" self.streams.append(sys.stdout) sys.stdout = self.stream
[ "Activate", "the", "TypingStream", "on", "stdout" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/animation.py#L353-L356
[ "def", "start", "(", "self", ")", ":", "self", ".", "streams", ".", "append", "(", "sys", ".", "stdout", ")", "sys", ".", "stdout", "=", "self", ".", "stream" ]
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
WritingDecorator.stop
Change back the normal stdout after the end
decorating/animation.py
def stop(cls): """Change back the normal stdout after the end""" if any(cls.streams): sys.stdout = cls.streams.pop(-1) else: sys.stdout = sys.__stdout__
def stop(cls): """Change back the normal stdout after the end""" if any(cls.streams): sys.stdout = cls.streams.pop(-1) else: sys.stdout = sys.__stdout__
[ "Change", "back", "the", "normal", "stdout", "after", "the", "end" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/animation.py#L359-L364
[ "def", "stop", "(", "cls", ")", ":", "if", "any", "(", "cls", ".", "streams", ")", ":", "sys", ".", "stdout", "=", "cls", ".", "streams", ".", "pop", "(", "-", "1", ")", "else", ":", "sys", ".", "stdout", "=", "sys", ".", "__stdout__" ]
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Lockable.acquire
Attempt to acquire an exclusive lock on this record. If a timeout is given (in seconds) then the acquire call will block for up to that much time attempting to acquire the lock. If the lock can not be acquired (either because it is already set or we time out) a Locked exception will be raised.
marrow/mongo/core/trait/lockable.py
def acquire(self, timeout=0, force=False): """Attempt to acquire an exclusive lock on this record. If a timeout is given (in seconds) then the acquire call will block for up to that much time attempting to acquire the lock. If the lock can not be acquired (either because it is already set or we time out) a Loc...
def acquire(self, timeout=0, force=False): """Attempt to acquire an exclusive lock on this record. If a timeout is given (in seconds) then the acquire call will block for up to that much time attempting to acquire the lock. If the lock can not be acquired (either because it is already set or we time out) a Loc...
[ "Attempt", "to", "acquire", "an", "exclusive", "lock", "on", "this", "record", ".", "If", "a", "timeout", "is", "given", "(", "in", "seconds", ")", "then", "the", "acquire", "call", "will", "block", "for", "up", "to", "that", "much", "time", "attempting"...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/lockable.py#L195-L243
[ "def", "acquire", "(", "self", ",", "timeout", "=", "0", ",", "force", "=", "False", ")", ":", "if", "timeout", "and", "not", "(", "self", ".", "Queue", ".", "__collection__", "and", "self", ".", "Queue", ".", "__capped__", ")", ":", "raise", "NotImp...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Lockable.prolong
Prolong the working duration of an already held lock. Attempting to prolong a lock not already owned will result in a Locked exception.
marrow/mongo/core/trait/lockable.py
def prolong(self): """Prolong the working duration of an already held lock. Attempting to prolong a lock not already owned will result in a Locked exception. """ D = self.__class__ collection = self.get_collection() identity = self.Lock() query = D.id == self query &= D.lock.instance == identit...
def prolong(self): """Prolong the working duration of an already held lock. Attempting to prolong a lock not already owned will result in a Locked exception. """ D = self.__class__ collection = self.get_collection() identity = self.Lock() query = D.id == self query &= D.lock.instance == identit...
[ "Prolong", "the", "working", "duration", "of", "an", "already", "held", "lock", ".", "Attempting", "to", "prolong", "a", "lock", "not", "already", "owned", "will", "result", "in", "a", "Locked", "exception", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/lockable.py#L245-L271
[ "def", "prolong", "(", "self", ")", ":", "D", "=", "self", ".", "__class__", "collection", "=", "self", ".", "get_collection", "(", ")", "identity", "=", "self", ".", "Lock", "(", ")", "query", "=", "D", ".", "id", "==", "self", "query", "&=", "D",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Lockable.release
Release an exclusive lock on this integration task. Unless forcing, if we are not the current owners of the lock a Locked exception will be raised.
marrow/mongo/core/trait/lockable.py
def release(self, force=False): """Release an exclusive lock on this integration task. Unless forcing, if we are not the current owners of the lock a Locked exception will be raised. """ D = self.__class__ collection = self.get_collection() identity = self.Lock() query = D.id == self if not ...
def release(self, force=False): """Release an exclusive lock on this integration task. Unless forcing, if we are not the current owners of the lock a Locked exception will be raised. """ D = self.__class__ collection = self.get_collection() identity = self.Lock() query = D.id == self if not ...
[ "Release", "an", "exclusive", "lock", "on", "this", "integration", "task", ".", "Unless", "forcing", "if", "we", "are", "not", "the", "current", "owners", "of", "the", "lock", "a", "Locked", "exception", "will", "be", "raised", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/lockable.py#L273-L299
[ "def", "release", "(", "self", ",", "force", "=", "False", ")", ":", "D", "=", "self", ".", "__class__", "collection", "=", "self", ".", "get_collection", "(", ")", "identity", "=", "self", ".", "Lock", "(", ")", "query", "=", "D", ".", "id", "==",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
PluginReference.to_native
Transform the MongoDB value into a Marrow Mongo value.
marrow/mongo/core/field/plugin.py
def to_native(self, obj, name, value): # pylint:disable=unused-argument """Transform the MongoDB value into a Marrow Mongo value.""" if self.mapping: for original, new in self.mapping.items(): value = value.replace(original, new) return load(value, self.namespace)
def to_native(self, obj, name, value): # pylint:disable=unused-argument """Transform the MongoDB value into a Marrow Mongo value.""" if self.mapping: for original, new in self.mapping.items(): value = value.replace(original, new) return load(value, self.namespace)
[ "Transform", "the", "MongoDB", "value", "into", "a", "Marrow", "Mongo", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/plugin.py#L36-L43
[ "def", "to_native", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "# pylint:disable=unused-argument", "if", "self", ".", "mapping", ":", "for", "original", ",", "new", "in", "self", ".", "mapping", ".", "items", "(", ")", ":", "value", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
PluginReference.to_foreign
Transform to a MongoDB-safe value.
marrow/mongo/core/field/plugin.py
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument """Transform to a MongoDB-safe value.""" namespace = self.namespace try: explicit = self.explicit except AttributeError: explicit = not namespace if not isinstance(value, (str, unicode)): value = canon(value) if n...
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument """Transform to a MongoDB-safe value.""" namespace = self.namespace try: explicit = self.explicit except AttributeError: explicit = not namespace if not isinstance(value, (str, unicode)): value = canon(value) if n...
[ "Transform", "to", "a", "MongoDB", "-", "safe", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/plugin.py#L45-L78
[ "def", "to_foreign", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "# pylint:disable=unused-argument", "namespace", "=", "self", ".", "namespace", "try", ":", "explicit", "=", "self", ".", "explicit", "except", "AttributeError", ":", "explicit"...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
F
Generate a MongoDB filter document through parameter interpolation. Arguments passed by name have their name interpreted as an optional prefix (currently only `not`), a double- underscore Because this utility is likely going to be used frequently it has been given a single-character name.
marrow/mongo/param/filter.py
def F(Document, __raw__=None, **filters): """Generate a MongoDB filter document through parameter interpolation. Arguments passed by name have their name interpreted as an optional prefix (currently only `not`), a double- underscore Because this utility is likely going to be used frequently it has been given a ...
def F(Document, __raw__=None, **filters): """Generate a MongoDB filter document through parameter interpolation. Arguments passed by name have their name interpreted as an optional prefix (currently only `not`), a double- underscore Because this utility is likely going to be used frequently it has been given a ...
[ "Generate", "a", "MongoDB", "filter", "document", "through", "parameter", "interpolation", ".", "Arguments", "passed", "by", "name", "have", "their", "name", "interpreted", "as", "an", "optional", "prefix", "(", "currently", "only", "not", ")", "a", "double", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/param/filter.py#L67-L90
[ "def", "F", "(", "Document", ",", "__raw__", "=", "None", ",", "*", "*", "filters", ")", ":", "ops", "=", "Filter", "(", "__raw__", ")", "args", "=", "_process_arguments", "(", "Document", ",", "FILTER_PREFIX_MAP", ",", "FILTER_OPERATION_MAP", ",", "filter...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Unbuffered.write
Function: write Summary: write method on the default stream Examples: >>> stream.write('message') 'message' Attributes: @param (message): str-like content to send on stream @param (flush) default=True: flush the stdout after write Returns: None
decorating/stream.py
def write(self, message, flush=True): """ Function: write Summary: write method on the default stream Examples: >>> stream.write('message') 'message' Attributes: @param (message): str-like content to send on stream @param (flush) default=...
def write(self, message, flush=True): """ Function: write Summary: write method on the default stream Examples: >>> stream.write('message') 'message' Attributes: @param (message): str-like content to send on stream @param (flush) default=...
[ "Function", ":", "write", "Summary", ":", "write", "method", "on", "the", "default", "stream", "Examples", ":", ">>>", "stream", ".", "write", "(", "message", ")", "message", "Attributes", ":" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/stream.py#L45-L58
[ "def", "write", "(", "self", ",", "message", ",", "flush", "=", "True", ")", ":", "self", ".", "stream", ".", "write", "(", "message", ")", "if", "flush", ":", "self", ".", "stream", ".", "flush", "(", ")" ]
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Animation.write
Send something for stdout and erased after delay
decorating/stream.py
def write(self, message, autoerase=True): """Send something for stdout and erased after delay""" super(Animation, self).write(message) self.last_message = message if autoerase: time.sleep(self.interval) self.erase(message)
def write(self, message, autoerase=True): """Send something for stdout and erased after delay""" super(Animation, self).write(message) self.last_message = message if autoerase: time.sleep(self.interval) self.erase(message)
[ "Send", "something", "for", "stdout", "and", "erased", "after", "delay" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/stream.py#L82-L88
[ "def", "write", "(", "self", ",", "message", ",", "autoerase", "=", "True", ")", ":", "super", "(", "Animation", ",", "self", ")", ".", "write", "(", "message", ")", "self", ".", "last_message", "=", "message", "if", "autoerase", ":", "time", ".", "s...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Animation.erase
Erase something whose you write before: message
decorating/stream.py
def erase(self, message=None): """Erase something whose you write before: message""" if not message: message = self.last_message # Move cursor to the beginning of line super(Animation, self).write("\033[G") # Erase in line from cursor super(Animation, self).wr...
def erase(self, message=None): """Erase something whose you write before: message""" if not message: message = self.last_message # Move cursor to the beginning of line super(Animation, self).write("\033[G") # Erase in line from cursor super(Animation, self).wr...
[ "Erase", "something", "whose", "you", "write", "before", ":", "message" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/stream.py#L90-L97
[ "def", "erase", "(", "self", ",", "message", "=", "None", ")", ":", "if", "not", "message", ":", "message", "=", "self", ".", "last_message", "# Move cursor to the beginning of line", "super", "(", "Animation", ",", "self", ")", ".", "write", "(", "\"\\033[G...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Clean.write
Write something on the default stream with a prefixed message
decorating/stream.py
def write(self, message, flush=False): """Write something on the default stream with a prefixed message""" # this need be threadsafe because the concurrent spinning running on # the stderr with self.lock: self.paralell_stream.erase() super(Clean, self).write(messa...
def write(self, message, flush=False): """Write something on the default stream with a prefixed message""" # this need be threadsafe because the concurrent spinning running on # the stderr with self.lock: self.paralell_stream.erase() super(Clean, self).write(messa...
[ "Write", "something", "on", "the", "default", "stream", "with", "a", "prefixed", "message" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/stream.py#L120-L126
[ "def", "write", "(", "self", ",", "message", ",", "flush", "=", "False", ")", ":", "# this need be threadsafe because the concurrent spinning running on", "# the stderr", "with", "self", ".", "lock", ":", "self", ".", "paralell_stream", ".", "erase", "(", ")", "su...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Writting.write
A Writting like write method, delayed at each char
decorating/stream.py
def write(self, message, flush=True): if isinstance(message, bytes): # pragma: no cover message = message.decode('utf-8') """A Writting like write method, delayed at each char""" for char in message: time.sleep(self.delay * (4 if char == '\n' else 1)) super(...
def write(self, message, flush=True): if isinstance(message, bytes): # pragma: no cover message = message.decode('utf-8') """A Writting like write method, delayed at each char""" for char in message: time.sleep(self.delay * (4 if char == '\n' else 1)) super(...
[ "A", "Writting", "like", "write", "method", "delayed", "at", "each", "char" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/stream.py#L148-L155
[ "def", "write", "(", "self", ",", "message", ",", "flush", "=", "True", ")", ":", "if", "isinstance", "(", "message", ",", "bytes", ")", ":", "# pragma: no cover", "message", "=", "message", ".", "decode", "(", "'utf-8'", ")", "for", "char", "in", "mes...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Collection.bind
Bind a copy of the collection to the class, modified per our class' settings. The given target (and eventual collection returned) must be safe within the context the document sublcass being bound is constructed within. E.g. at the module scope this binding must be thread-safe.
marrow/mongo/core/trait/collection.py
def bind(cls, target): """Bind a copy of the collection to the class, modified per our class' settings. The given target (and eventual collection returned) must be safe within the context the document sublcass being bound is constructed within. E.g. at the module scope this binding must be thread-safe. """ ...
def bind(cls, target): """Bind a copy of the collection to the class, modified per our class' settings. The given target (and eventual collection returned) must be safe within the context the document sublcass being bound is constructed within. E.g. at the module scope this binding must be thread-safe. """ ...
[ "Bind", "a", "copy", "of", "the", "collection", "to", "the", "class", "modified", "per", "our", "class", "settings", ".", "The", "given", "target", "(", "and", "eventual", "collection", "returned", ")", "must", "be", "safe", "within", "the", "context", "th...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L70-L82
[ "def", "bind", "(", "cls", ",", "target", ")", ":", "if", "cls", ".", "__bound__", "is", "not", "None", ":", "return", "cls", "cls", ".", "__bound__", "=", "cls", ".", "get_collection", "(", "target", ")", "return", "cls" ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection.get_collection
Retrieve a properly configured collection object as configured by this document class. If given an existing collection, will instead call `collection.with_options`. http://api.mongodb.com/python/current/api/pymongo/database.html#pymongo.database.Database.get_collection
marrow/mongo/core/trait/collection.py
def get_collection(cls, target=None): """Retrieve a properly configured collection object as configured by this document class. If given an existing collection, will instead call `collection.with_options`. http://api.mongodb.com/python/current/api/pymongo/database.html#pymongo.database.Database.get_collecti...
def get_collection(cls, target=None): """Retrieve a properly configured collection object as configured by this document class. If given an existing collection, will instead call `collection.with_options`. http://api.mongodb.com/python/current/api/pymongo/database.html#pymongo.database.Database.get_collecti...
[ "Retrieve", "a", "properly", "configured", "collection", "object", "as", "configured", "by", "this", "document", "class", ".", "If", "given", "an", "existing", "collection", "will", "instead", "call", "collection", ".", "with_options", ".", "http", ":", "//", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L87-L107
[ "def", "get_collection", "(", "cls", ",", "target", "=", "None", ")", ":", "if", "target", "is", "None", ":", "if", "cls", ".", "__bound__", "is", "None", ":", "raise", "TypeError", "(", "\"Target required when document class not bound.\"", ")", "return", "cls...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection.create_collection
Ensure the collection identified by this document class exists, creating it if not, also creating indexes. **Warning:** enabling the `recreate` option **will drop the collection, erasing all data within**. http://api.mongodb.com/python/current/api/pymongo/database.html#pymongo.database.Database.create_collect...
marrow/mongo/core/trait/collection.py
def create_collection(cls, target=None, drop=False, indexes=True): """Ensure the collection identified by this document class exists, creating it if not, also creating indexes. **Warning:** enabling the `recreate` option **will drop the collection, erasing all data within**. http://api.mongodb.com/python/cu...
def create_collection(cls, target=None, drop=False, indexes=True): """Ensure the collection identified by this document class exists, creating it if not, also creating indexes. **Warning:** enabling the `recreate` option **will drop the collection, erasing all data within**. http://api.mongodb.com/python/cu...
[ "Ensure", "the", "collection", "identified", "by", "this", "document", "class", "exists", "creating", "it", "if", "not", "also", "creating", "indexes", ".", "**", "Warning", ":", "**", "enabling", "the", "recreate", "option", "**", "will", "drop", "the", "co...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L110-L140
[ "def", "create_collection", "(", "cls", ",", "target", "=", "None", ",", "drop", "=", "False", ",", "indexes", "=", "True", ")", ":", "if", "target", "is", "None", ":", "if", "cls", ".", "__bound__", "is", "None", ":", "raise", "TypeError", "(", "\"T...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection.create_indexes
Iterate all known indexes and construct them. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_indexes
marrow/mongo/core/trait/collection.py
def create_indexes(cls, target=None, recreate=False): """Iterate all known indexes and construct them. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_indexes """ # TODO: Nested indexes. results = [] collection = cls.get_collection(target) ...
def create_indexes(cls, target=None, recreate=False): """Iterate all known indexes and construct them. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_indexes """ # TODO: Nested indexes. results = [] collection = cls.get_collection(target) ...
[ "Iterate", "all", "known", "indexes", "and", "construct", "them", ".", "https", ":", "//", "api", ".", "mongodb", ".", "com", "/", "python", "/", "current", "/", "api", "/", "pymongo", "/", "collection", ".", "html#pymongo", ".", "collection", ".", "Coll...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L145-L162
[ "def", "create_indexes", "(", "cls", ",", "target", "=", "None", ",", "recreate", "=", "False", ")", ":", "# TODO: Nested indexes.", "results", "=", "[", "]", "collection", "=", "cls", ".", "get_collection", "(", "target", ")", "if", "recreate", ":", "coll...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection._get_default_projection
Construct the default projection document.
marrow/mongo/core/trait/collection.py
def _get_default_projection(cls): """Construct the default projection document.""" projected = [] # The fields explicitly requested for inclusion. neutral = [] # Fields returning neutral (None) status. omitted = False # Have any fields been explicitly omitted? for name, field in cls.__fields__.items(...
def _get_default_projection(cls): """Construct the default projection document.""" projected = [] # The fields explicitly requested for inclusion. neutral = [] # Fields returning neutral (None) status. omitted = False # Have any fields been explicitly omitted? for name, field in cls.__fields__.items(...
[ "Construct", "the", "default", "projection", "document", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L203-L226
[ "def", "_get_default_projection", "(", "cls", ")", ":", "projected", "=", "[", "]", "# The fields explicitly requested for inclusion.", "neutral", "=", "[", "]", "# Fields returning neutral (None) status.", "omitted", "=", "False", "# Have any fields been explicitly omitted?", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection.insert_one
Insert this document. The `validate` argument translates to the inverse of the `bypass_document_validation` PyMongo option. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.insert_one
marrow/mongo/core/trait/collection.py
def insert_one(self, validate=True): """Insert this document. The `validate` argument translates to the inverse of the `bypass_document_validation` PyMongo option. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.insert_one """ kw = {} kw['bypass_docu...
def insert_one(self, validate=True): """Insert this document. The `validate` argument translates to the inverse of the `bypass_document_validation` PyMongo option. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.insert_one """ kw = {} kw['bypass_docu...
[ "Insert", "this", "document", ".", "The", "validate", "argument", "translates", "to", "the", "inverse", "of", "the", "bypass_document_validation", "PyMongo", "option", ".", "https", ":", "//", "api", ".", "mongodb", ".", "com", "/", "python", "/", "current", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L228-L240
[ "def", "insert_one", "(", "self", ",", "validate", "=", "True", ")", ":", "kw", "=", "{", "}", "kw", "[", "'bypass_document_validation'", "]", "=", "not", "validate", "collection", "=", "self", ".", "get_collection", "(", "kw", ".", "pop", "(", "'source'...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection.update_one
Update this document in the database. Local representations will not be affected. A single positional parameter, `update`, may be provided as a mapping. Keyword arguments (other than those identified in UPDATE_MAPPING) are interpreted as parametric updates, added to any `update` passed in. https://api.mongo...
marrow/mongo/core/trait/collection.py
def update_one(self, update=None, validate=True, **kw): """Update this document in the database. Local representations will not be affected. A single positional parameter, `update`, may be provided as a mapping. Keyword arguments (other than those identified in UPDATE_MAPPING) are interpreted as parametric upd...
def update_one(self, update=None, validate=True, **kw): """Update this document in the database. Local representations will not be affected. A single positional parameter, `update`, may be provided as a mapping. Keyword arguments (other than those identified in UPDATE_MAPPING) are interpreted as parametric upd...
[ "Update", "this", "document", "in", "the", "database", ".", "Local", "representations", "will", "not", "be", "affected", ".", "A", "single", "positional", "parameter", "update", "may", "be", "provided", "as", "a", "mapping", ".", "Keyword", "arguments", "(", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L242-L262
[ "def", "update_one", "(", "self", ",", "update", "=", "None", ",", "validate", "=", "True", ",", "*", "*", "kw", ")", ":", "D", "=", "self", ".", "__class__", "collection", "=", "self", ".", "get_collection", "(", "kw", ".", "pop", "(", "'source'", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Collection.delete_one
Remove this document from the database, passing additional arguments through to PyMongo. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.delete_one
marrow/mongo/core/trait/collection.py
def delete_one(self, source=None, **kw): """Remove this document from the database, passing additional arguments through to PyMongo. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.delete_one """ collection = self.get_collection(source) return collection....
def delete_one(self, source=None, **kw): """Remove this document from the database, passing additional arguments through to PyMongo. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.delete_one """ collection = self.get_collection(source) return collection....
[ "Remove", "this", "document", "from", "the", "database", "passing", "additional", "arguments", "through", "to", "PyMongo", ".", "https", ":", "//", "api", ".", "mongodb", ".", "com", "/", "python", "/", "current", "/", "api", "/", "pymongo", "/", "collecti...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/collection.py#L264-L271
[ "def", "delete_one", "(", "self", ",", "source", "=", "None", ",", "*", "*", "kw", ")", ":", "collection", "=", "self", ".", "get_collection", "(", "source", ")", "return", "collection", ".", "delete_one", "(", "self", ".", "__class__", ".", "id", "=="...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
force_text
Returns a bytestring version of 's', encoded as specified in 'encoding'. If strings_only is True, don't convert (some) non-string-like objects. Based on the `django.utils.encoding.smart_str' (https://github.com/django/django/blob/master/django/utils/encoding.py)
dgis/utils.py
def force_text(s, encoding='utf-8', errors='strict'): """ Returns a bytestring version of 's', encoded as specified in 'encoding'. If strings_only is True, don't convert (some) non-string-like objects. Based on the `django.utils.encoding.smart_str' (https://github.com/django/django/blob/master/django/...
def force_text(s, encoding='utf-8', errors='strict'): """ Returns a bytestring version of 's', encoded as specified in 'encoding'. If strings_only is True, don't convert (some) non-string-like objects. Based on the `django.utils.encoding.smart_str' (https://github.com/django/django/blob/master/django/...
[ "Returns", "a", "bytestring", "version", "of", "s", "encoded", "as", "specified", "in", "encoding", "." ]
svartalf/python-2gis
python
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/utils.py#L6-L30
[ "def", "force_text", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "not", "isinstance", "(", "s", ",", "six", ".", "string_types", ")", ":", "try", ":", "return", "str", "(", "s", ")", "except", "UnicodeEn...
6eccd6073c99494b7abf20b38a5455cbd55d6420
train
adjust_attribute_sequence
Move marrow.schema fields around to control positional instantiation order.
marrow/mongo/util/__init__.py
def adjust_attribute_sequence(*fields): """Move marrow.schema fields around to control positional instantiation order.""" amount = None if fields and isinstance(fields[0], int): amount, fields = fields[0], fields[1:] def adjust_inner(cls): for field in fields: if field not in cls.__dict__: # TODO: ...
def adjust_attribute_sequence(*fields): """Move marrow.schema fields around to control positional instantiation order.""" amount = None if fields and isinstance(fields[0], int): amount, fields = fields[0], fields[1:] def adjust_inner(cls): for field in fields: if field not in cls.__dict__: # TODO: ...
[ "Move", "marrow", ".", "schema", "fields", "around", "to", "control", "positional", "instantiation", "order", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/util/__init__.py#L26-L55
[ "def", "adjust_attribute_sequence", "(", "*", "fields", ")", ":", "amount", "=", "None", "if", "fields", "and", "isinstance", "(", "fields", "[", "0", "]", ",", "int", ")", ":", "amount", ",", "fields", "=", "fields", "[", "0", "]", ",", "fields", "[...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
datetime_period
Round a datetime object down to the start of a defined period. The `base` argument may be used to find the period start for an arbitrary datetime, defaults to `utcnow()`.
marrow/mongo/util/__init__.py
def datetime_period(base=None, hours=None, minutes=None, seconds=None): """Round a datetime object down to the start of a defined period. The `base` argument may be used to find the period start for an arbitrary datetime, defaults to `utcnow()`. """ if base is None: base = utcnow() base -= timedelta( ho...
def datetime_period(base=None, hours=None, minutes=None, seconds=None): """Round a datetime object down to the start of a defined period. The `base` argument may be used to find the period start for an arbitrary datetime, defaults to `utcnow()`. """ if base is None: base = utcnow() base -= timedelta( ho...
[ "Round", "a", "datetime", "object", "down", "to", "the", "start", "of", "a", "defined", "period", ".", "The", "base", "argument", "may", "be", "used", "to", "find", "the", "period", "start", "for", "an", "arbitrary", "datetime", "defaults", "to", "utcnow",...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/util/__init__.py#L101-L117
[ "def", "datetime_period", "(", "base", "=", "None", ",", "hours", "=", "None", ",", "minutes", "=", "None", ",", "seconds", "=", "None", ")", ":", "if", "base", "is", "None", ":", "base", "=", "utcnow", "(", ")", "base", "-=", "timedelta", "(", "ho...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
get_hashes
Get a dictionary of file paths and timestamps. Paths matching `exclude` regex will be excluded.
retox/__main__.py
def get_hashes(path, exclude=None): ''' Get a dictionary of file paths and timestamps. Paths matching `exclude` regex will be excluded. ''' out = {} for f in Path(path).rglob('*'): if f.is_dir(): # We want to watch files, not directories. continue if excl...
def get_hashes(path, exclude=None): ''' Get a dictionary of file paths and timestamps. Paths matching `exclude` regex will be excluded. ''' out = {} for f in Path(path).rglob('*'): if f.is_dir(): # We want to watch files, not directories. continue if excl...
[ "Get", "a", "dictionary", "of", "file", "paths", "and", "timestamps", "." ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/__main__.py#L103-L119
[ "def", "get_hashes", "(", "path", ",", "exclude", "=", "None", ")", ":", "out", "=", "{", "}", "for", "f", "in", "Path", "(", "path", ")", ".", "rglob", "(", "'*'", ")", ":", "if", "f", ".", "is_dir", "(", ")", ":", "# We want to watch files, not d...
4635e31001d2ac083423f46766249ac8daca7c9c
train
Session.request
Sends an HTTP request to the API. :Parameters: method : `str` Which HTTP method to use for the request? (Usually "POST" or "GET") params : `dict` A set of parameters to send with the request. These parameters will be inclu...
mwapi/session.py
def request(self, method, params=None, query_continue=None, files=None, auth=None, continuation=False): """ Sends an HTTP request to the API. :Parameters: method : `str` Which HTTP method to use for the request? (Usually "POST" or "GET...
def request(self, method, params=None, query_continue=None, files=None, auth=None, continuation=False): """ Sends an HTTP request to the API. :Parameters: method : `str` Which HTTP method to use for the request? (Usually "POST" or "GET...
[ "Sends", "an", "HTTP", "request", "to", "the", "API", "." ]
mediawiki-utilities/python-mwapi
python
https://github.com/mediawiki-utilities/python-mwapi/blob/7a653c29207ecd318ae4b369d398aed13f26951d/mwapi/session.py#L136-L171
[ "def", "request", "(", "self", ",", "method", ",", "params", "=", "None", ",", "query_continue", "=", "None", ",", "files", "=", "None", ",", "auth", "=", "None", ",", "continuation", "=", "False", ")", ":", "normal_params", "=", "_normalize_params", "("...
7a653c29207ecd318ae4b369d398aed13f26951d
train
Session.login
Authenticate with the given credentials. If authentication is successful, all further requests sent will be signed the authenticated user. Note that passwords are sent as plaintext. This is a limitation of the Mediawiki API. Use a https host if you want your password to be secure ...
mwapi/session.py
def login(self, username, password, login_token=None): """ Authenticate with the given credentials. If authentication is successful, all further requests sent will be signed the authenticated user. Note that passwords are sent as plaintext. This is a limitation of the M...
def login(self, username, password, login_token=None): """ Authenticate with the given credentials. If authentication is successful, all further requests sent will be signed the authenticated user. Note that passwords are sent as plaintext. This is a limitation of the M...
[ "Authenticate", "with", "the", "given", "credentials", ".", "If", "authentication", "is", "successful", "all", "further", "requests", "sent", "will", "be", "signed", "the", "authenticated", "user", "." ]
mediawiki-utilities/python-mwapi
python
https://github.com/mediawiki-utilities/python-mwapi/blob/7a653c29207ecd318ae4b369d398aed13f26951d/mwapi/session.py#L213-L246
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "login_token", "=", "None", ")", ":", "if", "login_token", "is", "None", ":", "token_doc", "=", "self", ".", "post", "(", "action", "=", "'query'", ",", "meta", "=", "'tokens'", ",", ...
7a653c29207ecd318ae4b369d398aed13f26951d
train
Session.continue_login
Continues a login that requires an additional step. This is common for when login requires completing a captcha or supplying a two-factor authentication token. :Parameters: login_token : `str` A login token generated by the MediaWiki API (and used in a ...
mwapi/session.py
def continue_login(self, login_token, **params): """ Continues a login that requires an additional step. This is common for when login requires completing a captcha or supplying a two-factor authentication token. :Parameters: login_token : `str` A lo...
def continue_login(self, login_token, **params): """ Continues a login that requires an additional step. This is common for when login requires completing a captcha or supplying a two-factor authentication token. :Parameters: login_token : `str` A lo...
[ "Continues", "a", "login", "that", "requires", "an", "additional", "step", ".", "This", "is", "common", "for", "when", "login", "requires", "completing", "a", "captcha", "or", "supplying", "a", "two", "-", "factor", "authentication", "token", "." ]
mediawiki-utilities/python-mwapi
python
https://github.com/mediawiki-utilities/python-mwapi/blob/7a653c29207ecd318ae4b369d398aed13f26951d/mwapi/session.py#L248-L273
[ "def", "continue_login", "(", "self", ",", "login_token", ",", "*", "*", "params", ")", ":", "login_params", "=", "{", "'action'", ":", "\"clientlogin\"", ",", "'logintoken'", ":", "login_token", ",", "'logincontinue'", ":", "1", "}", "login_params", ".", "u...
7a653c29207ecd318ae4b369d398aed13f26951d
train
Session.get
Makes an API request with the GET method :Parameters: query_continue : `dict` Optionally, the value of a query continuation 'continue' field. auth : mixed Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth. continuation : `bool` ...
mwapi/session.py
def get(self, query_continue=None, auth=None, continuation=False, **params): """Makes an API request with the GET method :Parameters: query_continue : `dict` Optionally, the value of a query continuation 'continue' field. auth : mixed ...
def get(self, query_continue=None, auth=None, continuation=False, **params): """Makes an API request with the GET method :Parameters: query_continue : `dict` Optionally, the value of a query continuation 'continue' field. auth : mixed ...
[ "Makes", "an", "API", "request", "with", "the", "GET", "method" ]
mediawiki-utilities/python-mwapi
python
https://github.com/mediawiki-utilities/python-mwapi/blob/7a653c29207ecd318ae4b369d398aed13f26951d/mwapi/session.py#L284-L309
[ "def", "get", "(", "self", ",", "query_continue", "=", "None", ",", "auth", "=", "None", ",", "continuation", "=", "False", ",", "*", "*", "params", ")", ":", "return", "self", ".", "request", "(", "'GET'", ",", "params", "=", "params", ",", "auth", ...
7a653c29207ecd318ae4b369d398aed13f26951d
train
Session.post
Makes an API request with the POST method :Parameters: query_continue : `dict` Optionally, the value of a query continuation 'continue' field. upload_file : `bytes` The bytes of a file to upload. auth : mixed Auth tuple or call...
mwapi/session.py
def post(self, query_continue=None, upload_file=None, auth=None, continuation=False, **params): """Makes an API request with the POST method :Parameters: query_continue : `dict` Optionally, the value of a query continuation 'continue' field. upload_f...
def post(self, query_continue=None, upload_file=None, auth=None, continuation=False, **params): """Makes an API request with the POST method :Parameters: query_continue : `dict` Optionally, the value of a query continuation 'continue' field. upload_f...
[ "Makes", "an", "API", "request", "with", "the", "POST", "method" ]
mediawiki-utilities/python-mwapi
python
https://github.com/mediawiki-utilities/python-mwapi/blob/7a653c29207ecd318ae4b369d398aed13f26951d/mwapi/session.py#L311-L342
[ "def", "post", "(", "self", ",", "query_continue", "=", "None", ",", "upload_file", "=", "None", ",", "auth", "=", "None", ",", "continuation", "=", "False", ",", "*", "*", "params", ")", ":", "if", "upload_file", "is", "not", "None", ":", "files", "...
7a653c29207ecd318ae4b369d398aed13f26951d
train
Published.only_published
Produce a query fragment suitable for selecting documents public. Now (no arguments), at a specific time (datetime argument), or relative to now (timedelta).
marrow/mongo/core/trait/published.py
def only_published(cls, at=None): """Produce a query fragment suitable for selecting documents public. Now (no arguments), at a specific time (datetime argument), or relative to now (timedelta). """ if isinstance(at, timedelta): at = utcnow() + at else: at = at or utcnow() pub, ret = cls.publ...
def only_published(cls, at=None): """Produce a query fragment suitable for selecting documents public. Now (no arguments), at a specific time (datetime argument), or relative to now (timedelta). """ if isinstance(at, timedelta): at = utcnow() + at else: at = at or utcnow() pub, ret = cls.publ...
[ "Produce", "a", "query", "fragment", "suitable", "for", "selecting", "documents", "public", ".", "Now", "(", "no", "arguments", ")", "at", "a", "specific", "time", "(", "datetime", "argument", ")", "or", "relative", "to", "now", "(", "timedelta", ")", "." ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/published.py#L21-L37
[ "def", "only_published", "(", "cls", ",", "at", "=", "None", ")", ":", "if", "isinstance", "(", "at", ",", "timedelta", ")", ":", "at", "=", "utcnow", "(", ")", "+", "at", "else", ":", "at", "=", "at", "or", "utcnow", "(", ")", "pub", ",", "ret...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
_CastingKind.to_native
Transform the MongoDB value into a Marrow Mongo value.
marrow/mongo/core/field/base.py
def to_native(self, obj, name, value): # pylint:disable=unused-argument """Transform the MongoDB value into a Marrow Mongo value.""" from marrow.mongo import Document from marrow.mongo.trait import Derived kind = self._kind(obj.__class__) if isinstance(value, Document): if __debug__ and kind and ...
def to_native(self, obj, name, value): # pylint:disable=unused-argument """Transform the MongoDB value into a Marrow Mongo value.""" from marrow.mongo import Document from marrow.mongo.trait import Derived kind = self._kind(obj.__class__) if isinstance(value, Document): if __debug__ and kind and ...
[ "Transform", "the", "MongoDB", "value", "into", "a", "Marrow", "Mongo", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/base.py#L246-L263
[ "def", "to_native", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "# pylint:disable=unused-argument", "from", "marrow", ".", "mongo", "import", "Document", "from", "marrow", ".", "mongo", ".", "trait", "import", "Derived", "kind", "=", "self"...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
_CastingKind.to_foreign
Transform to a MongoDB-safe value.
marrow/mongo/core/field/base.py
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument """Transform to a MongoDB-safe value.""" from marrow.mongo import Document kind = self._kind(obj if isclass(obj) else obj.__class__) if isinstance(value, Document): if __debug__ and kind and issubclass(kind, Document) and not ...
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument """Transform to a MongoDB-safe value.""" from marrow.mongo import Document kind = self._kind(obj if isclass(obj) else obj.__class__) if isinstance(value, Document): if __debug__ and kind and issubclass(kind, Document) and not ...
[ "Transform", "to", "a", "MongoDB", "-", "safe", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/base.py#L265-L285
[ "def", "to_foreign", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "# pylint:disable=unused-argument", "from", "marrow", ".", "mongo", "import", "Document", "kind", "=", "self", ".", "_kind", "(", "obj", "if", "isclass", "(", "obj", ")", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Derived.promote
Transform this record into an instance of a more specialized subclass.
marrow/mongo/core/trait/derived.py
def promote(self, cls, update=False, preserve=True): """Transform this record into an instance of a more specialized subclass.""" if not issubclass(cls, self.__class__): raise TypeError("Must promote to a subclass of " + self.__class__.__name__) return self._as(cls, update, preserve)
def promote(self, cls, update=False, preserve=True): """Transform this record into an instance of a more specialized subclass.""" if not issubclass(cls, self.__class__): raise TypeError("Must promote to a subclass of " + self.__class__.__name__) return self._as(cls, update, preserve)
[ "Transform", "this", "record", "into", "an", "instance", "of", "a", "more", "specialized", "subclass", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/derived.py#L36-L42
[ "def", "promote", "(", "self", ",", "cls", ",", "update", "=", "False", ",", "preserve", "=", "True", ")", ":", "if", "not", "issubclass", "(", "cls", ",", "self", ".", "__class__", ")", ":", "raise", "TypeError", "(", "\"Must promote to a subclass of \"",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Array.to_native
Transform the MongoDB value into a Marrow Mongo value.
marrow/mongo/core/field/array.py
def to_native(self, obj, name, value): """Transform the MongoDB value into a Marrow Mongo value.""" if isinstance(value, self.List): return value result = self.List(super(Array, self).to_native(obj, name, i) for i in value) obj.__data__[self.__name__] = result return result
def to_native(self, obj, name, value): """Transform the MongoDB value into a Marrow Mongo value.""" if isinstance(value, self.List): return value result = self.List(super(Array, self).to_native(obj, name, i) for i in value) obj.__data__[self.__name__] = result return result
[ "Transform", "the", "MongoDB", "value", "into", "a", "Marrow", "Mongo", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/array.py#L28-L37
[ "def", "to_native", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "self", ".", "List", ")", ":", "return", "value", "result", "=", "self", ".", "List", "(", "super", "(", "Array", ",", "self", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Array.to_foreign
Transform to a MongoDB-safe value.
marrow/mongo/core/field/array.py
def to_foreign(self, obj, name, value): """Transform to a MongoDB-safe value.""" if isinstance(value, Iterable) and not isinstance(value, Mapping): return self.List(super(Array, self).to_foreign(obj, name, i) for i in value) return super(Array, self).to_foreign(obj, name, value)
def to_foreign(self, obj, name, value): """Transform to a MongoDB-safe value.""" if isinstance(value, Iterable) and not isinstance(value, Mapping): return self.List(super(Array, self).to_foreign(obj, name, i) for i in value) return super(Array, self).to_foreign(obj, name, value)
[ "Transform", "to", "a", "MongoDB", "-", "safe", "value", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/array.py#L39-L45
[ "def", "to_foreign", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Iterable", ")", "and", "not", "isinstance", "(", "value", ",", "Mapping", ")", ":", "return", "self", ".", "List", "(", "super"...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
cut_levels
cutting nodes away from menus
cms_bootstrap/templatetags/bootstrap_tags.py
def cut_levels(nodes, start_level): """ cutting nodes away from menus """ final = [] removed = [] for node in nodes: if not hasattr(node, 'level'): # remove and ignore nodes that don't have level information remove(node, removed) continue if no...
def cut_levels(nodes, start_level): """ cutting nodes away from menus """ final = [] removed = [] for node in nodes: if not hasattr(node, 'level'): # remove and ignore nodes that don't have level information remove(node, removed) continue if no...
[ "cutting", "nodes", "away", "from", "menus" ]
jrief/djangocms-bootstrap
python
https://github.com/jrief/djangocms-bootstrap/blob/293a7050602d6e9a728acea2fb13893e5ec7992e/cms_bootstrap/templatetags/bootstrap_tags.py#L18-L53
[ "def", "cut_levels", "(", "nodes", ",", "start_level", ")", ":", "final", "=", "[", "]", "removed", "=", "[", "]", "for", "node", "in", "nodes", ":", "if", "not", "hasattr", "(", "node", ",", "'level'", ")", ":", "# remove and ignore nodes that don't have ...
293a7050602d6e9a728acea2fb13893e5ec7992e
train
U
Generate a MongoDB update document through paramater interpolation. Arguments passed by name have their name interpreted as an optional operation prefix (defaulting to `set`, e.g. `push`), a double-underscore separated field reference (e.g. `foo`, or `foo__bar`, or `foo__S__bar`, or `foo__27__bar`) Because this...
marrow/mongo/param/update.py
def U(Document, __raw__=None, **update): """Generate a MongoDB update document through paramater interpolation. Arguments passed by name have their name interpreted as an optional operation prefix (defaulting to `set`, e.g. `push`), a double-underscore separated field reference (e.g. `foo`, or `foo__bar`, or `foo_...
def U(Document, __raw__=None, **update): """Generate a MongoDB update document through paramater interpolation. Arguments passed by name have their name interpreted as an optional operation prefix (defaulting to `set`, e.g. `push`), a double-underscore separated field reference (e.g. `foo`, or `foo__bar`, or `foo_...
[ "Generate", "a", "MongoDB", "update", "document", "through", "paramater", "interpolation", ".", "Arguments", "passed", "by", "name", "have", "their", "name", "interpreted", "as", "an", "optional", "operation", "prefix", "(", "defaulting", "to", "set", "e", ".", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/param/update.py#L98-L131
[ "def", "U", "(", "Document", ",", "__raw__", "=", "None", ",", "*", "*", "update", ")", ":", "ops", "=", "Update", "(", "__raw__", ")", "args", "=", "_process_arguments", "(", "Document", ",", "UPDATE_ALIASES", ",", "{", "}", ",", "update", ",", "UPD...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
debug
Function: debug Summary: decorator to debug a function Examples: at the execution of the function wrapped, the decorator will allows to print the input and output of each execution Attributes: @param (function): function Returns: wrapped function
decorating/debugging.py
def debug(function): """ Function: debug Summary: decorator to debug a function Examples: at the execution of the function wrapped, the decorator will allows to print the input and output of each execution Attributes: @param (function): function Returns: wrapp...
def debug(function): """ Function: debug Summary: decorator to debug a function Examples: at the execution of the function wrapped, the decorator will allows to print the input and output of each execution Attributes: @param (function): function Returns: wrapp...
[ "Function", ":", "debug", "Summary", ":", "decorator", "to", "debug", "a", "function", "Examples", ":", "at", "the", "execution", "of", "the", "function", "wrapped", "the", "decorator", "will", "allows", "to", "print", "the", "input", "and", "output", "of", ...
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/debugging.py#L20-L43
[ "def", "debug", "(", "function", ")", ":", "@", "wraps", "(", "function", ")", "def", "_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "function", "(", "*", "args", ",", "*", "*", "kwargs", ")", "for", "key", ",", ...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
counter
Function: counter Summary: Decorator to count the number of a function is executed each time Examples: You can use that to had a progress of heally heavy computation without progress feedback Attributes: @param (function): function Returns: wrapped function
decorating/debugging.py
def counter(function): """ Function: counter Summary: Decorator to count the number of a function is executed each time Examples: You can use that to had a progress of heally heavy computation without progress feedback Attributes: @param (function): function Returns: wrappe...
def counter(function): """ Function: counter Summary: Decorator to count the number of a function is executed each time Examples: You can use that to had a progress of heally heavy computation without progress feedback Attributes: @param (function): function Returns: wrappe...
[ "Function", ":", "counter", "Summary", ":", "Decorator", "to", "count", "the", "number", "of", "a", "function", "is", "executed", "each", "time", "Examples", ":", "You", "can", "use", "that", "to", "had", "a", "progress", "of", "heally", "heavy", "computat...
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/debugging.py#L46-L66
[ "def", "counter", "(", "function", ")", ":", "@", "wraps", "(", "function", ")", "def", "_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_wrapper", ".", "count", "+=", "1", "res", "=", "function", "(", "*", "args", ",", "*", "*",...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
count_time
Function: count_time Summary: get the time to finish a function print at the end that time to stdout Examples: <NONE> Attributes: @param (function): function Returns: wrapped function
decorating/debugging.py
def count_time(function): """ Function: count_time Summary: get the time to finish a function print at the end that time to stdout Examples: <NONE> Attributes: @param (function): function Returns: wrapped function """ @wraps(function) def _wrapper(*args, **kwargs...
def count_time(function): """ Function: count_time Summary: get the time to finish a function print at the end that time to stdout Examples: <NONE> Attributes: @param (function): function Returns: wrapped function """ @wraps(function) def _wrapper(*args, **kwargs...
[ "Function", ":", "count_time", "Summary", ":", "get", "the", "time", "to", "finish", "a", "function", "print", "at", "the", "end", "that", "time", "to", "stdout", "Examples", ":", "<NONE", ">", "Attributes", ":" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/debugging.py#L69-L90
[ "def", "count_time", "(", "function", ")", ":", "@", "wraps", "(", "function", ")", "def", "_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "before", "=", "time", "(", ")", "result", "=", "function", "(", "*", "args", ",", "*", "*...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Expires.from_mongo
In the event a value that has technically already expired is loaded, swap it for None.
marrow/mongo/core/trait/expires.py
def from_mongo(cls, data, expired=False, **kw): """In the event a value that has technically already expired is loaded, swap it for None.""" value = super(Expires, cls).from_mongo(data, **kw) if not expired and value.is_expired: return None return value
def from_mongo(cls, data, expired=False, **kw): """In the event a value that has technically already expired is loaded, swap it for None.""" value = super(Expires, cls).from_mongo(data, **kw) if not expired and value.is_expired: return None return value
[ "In", "the", "event", "a", "value", "that", "has", "technically", "already", "expired", "is", "loaded", "swap", "it", "for", "None", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/expires.py#L36-L44
[ "def", "from_mongo", "(", "cls", ",", "data", ",", "expired", "=", "False", ",", "*", "*", "kw", ")", ":", "value", "=", "super", "(", "Expires", ",", "cls", ")", ".", "from_mongo", "(", "data", ",", "*", "*", "kw", ")", "if", "not", "expired", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467