repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
google/dotty
efilter/parsers/dottysql/parser.py
Parser.accept_operator
def accept_operator(self, precedence): """Accept the next binary operator only if it's of higher precedence.""" match = grammar.infix(self.tokens) if not match: return if match.operator.precedence < precedence: return # The next thing is an operator that...
python
def accept_operator(self, precedence): """Accept the next binary operator only if it's of higher precedence.""" match = grammar.infix(self.tokens) if not match: return if match.operator.precedence < precedence: return # The next thing is an operator that...
[ "def", "accept_operator", "(", "self", ",", "precedence", ")", ":", "match", "=", "grammar", ".", "infix", "(", "self", ".", "tokens", ")", "if", "not", "match", ":", "return", "if", "match", ".", "operator", ".", "precedence", "<", "precedence", ":", ...
Accept the next binary operator only if it's of higher precedence.
[ "Accept", "the", "next", "binary", "operator", "only", "if", "it", "s", "of", "higher", "precedence", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L315-L325
google/dotty
efilter/parsers/dottysql/parser.py
Parser.operator
def operator(self, lhs, min_precedence): """Climb operator precedence as long as there are operators. This function implements a basic precedence climbing parser to deal with binary operators in a sane fashion. The outer loop will keep spinning as long as the next token is an operator w...
python
def operator(self, lhs, min_precedence): """Climb operator precedence as long as there are operators. This function implements a basic precedence climbing parser to deal with binary operators in a sane fashion. The outer loop will keep spinning as long as the next token is an operator w...
[ "def", "operator", "(", "self", ",", "lhs", ",", "min_precedence", ")", ":", "# Spin as long as the next token is an operator of higher", "# precedence. (This may not do anything, which is fine.)", "while", "self", ".", "accept_operator", "(", "precedence", "=", "min_precedence...
Climb operator precedence as long as there are operators. This function implements a basic precedence climbing parser to deal with binary operators in a sane fashion. The outer loop will keep spinning as long as the next token is an operator with a precedence of at least 'min_precedence...
[ "Climb", "operator", "precedence", "as", "long", "as", "there", "are", "operators", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L327-L377
google/dotty
efilter/parsers/dottysql/parser.py
Parser.dot_rhs
def dot_rhs(self): """Match the right-hand side of a dot (.) operator. The RHS must be a symbol token, but it is interpreted as a literal string (because that's what goes in the AST of Resolve.) """ self.tokens.expect(common_grammar.symbol) return ast.Literal(self.tokens...
python
def dot_rhs(self): """Match the right-hand side of a dot (.) operator. The RHS must be a symbol token, but it is interpreted as a literal string (because that's what goes in the AST of Resolve.) """ self.tokens.expect(common_grammar.symbol) return ast.Literal(self.tokens...
[ "def", "dot_rhs", "(", "self", ")", ":", "self", ".", "tokens", ".", "expect", "(", "common_grammar", ".", "symbol", ")", "return", "ast", ".", "Literal", "(", "self", ".", "tokens", ".", "matched", ".", "value", ",", "start", "=", "self", ".", "toke...
Match the right-hand side of a dot (.) operator. The RHS must be a symbol token, but it is interpreted as a literal string (because that's what goes in the AST of Resolve.)
[ "Match", "the", "right", "-", "hand", "side", "of", "a", "dot", "(", ".", ")", "operator", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L379-L388
google/dotty
efilter/parsers/dottysql/parser.py
Parser.select
def select(self): """First part of an SQL query.""" # Try to match the asterisk, any or list of vars. if self.tokens.accept(grammar.select_any): return self.select_any() if self.tokens.accept(grammar.select_all): # The FROM after SELECT * is required. ...
python
def select(self): """First part of an SQL query.""" # Try to match the asterisk, any or list of vars. if self.tokens.accept(grammar.select_any): return self.select_any() if self.tokens.accept(grammar.select_all): # The FROM after SELECT * is required. ...
[ "def", "select", "(", "self", ")", ":", "# Try to match the asterisk, any or list of vars.", "if", "self", ".", "tokens", ".", "accept", "(", "grammar", ".", "select_any", ")", ":", "return", "self", ".", "select_any", "(", ")", "if", "self", ".", "tokens", ...
First part of an SQL query.
[ "First", "part", "of", "an", "SQL", "query", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L392-L403
google/dotty
efilter/parsers/dottysql/parser.py
Parser._guess_name_of
def _guess_name_of(self, expr): """Tries to guess what variable name 'expr' ends in. This is a heuristic that roughly emulates what most SQL databases name columns, based on selected variable names or applied functions. """ if isinstance(expr, ast.Var): return expr.v...
python
def _guess_name_of(self, expr): """Tries to guess what variable name 'expr' ends in. This is a heuristic that roughly emulates what most SQL databases name columns, based on selected variable names or applied functions. """ if isinstance(expr, ast.Var): return expr.v...
[ "def", "_guess_name_of", "(", "self", ",", "expr", ")", ":", "if", "isinstance", "(", "expr", ",", "ast", ".", "Var", ")", ":", "return", "expr", ".", "value", "if", "isinstance", "(", "expr", ",", "ast", ".", "Resolve", ")", ":", "# We know the RHS of...
Tries to guess what variable name 'expr' ends in. This is a heuristic that roughly emulates what most SQL databases name columns, based on selected variable names or applied functions.
[ "Tries", "to", "guess", "what", "variable", "name", "expr", "ends", "in", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L439-L459
google/dotty
efilter/parsers/dottysql/parser.py
Parser.select_limit
def select_limit(self, source_expression): """Match LIMIT take [OFFSET drop].""" start = self.tokens.matched.start # The expression right after LIMIT is the count to take. limit_count_expression = self.expression() # Optional OFFSET follows. if self.tokens.accept(gramma...
python
def select_limit(self, source_expression): """Match LIMIT take [OFFSET drop].""" start = self.tokens.matched.start # The expression right after LIMIT is the count to take. limit_count_expression = self.expression() # Optional OFFSET follows. if self.tokens.accept(gramma...
[ "def", "select_limit", "(", "self", ",", "source_expression", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "# The expression right after LIMIT is the count to take.", "limit_count_expression", "=", "self", ".", "expression", "(", ")", ...
Match LIMIT take [OFFSET drop].
[ "Match", "LIMIT", "take", "[", "OFFSET", "drop", "]", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L573-L607
google/dotty
efilter/parsers/dottysql/parser.py
Parser.builtin
def builtin(self, keyword): """Parse the pseudo-function application subgrammar.""" # The match includes the lparen token, so the keyword is just the first # token in the match, not the whole thing. keyword_start = self.tokens.matched.first.start keyword_end = self.tokens.matched...
python
def builtin(self, keyword): """Parse the pseudo-function application subgrammar.""" # The match includes the lparen token, so the keyword is just the first # token in the match, not the whole thing. keyword_start = self.tokens.matched.first.start keyword_end = self.tokens.matched...
[ "def", "builtin", "(", "self", ",", "keyword", ")", ":", "# The match includes the lparen token, so the keyword is just the first", "# token in the match, not the whole thing.", "keyword_start", "=", "self", ".", "tokens", ".", "matched", ".", "first", ".", "start", "keywor...
Parse the pseudo-function application subgrammar.
[ "Parse", "the", "pseudo", "-", "function", "application", "subgrammar", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L611-L638
google/dotty
efilter/parsers/dottysql/parser.py
Parser.application
def application(self, func): """Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, ...
python
def application(self, func): """Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, ...
[ "def", "application", "(", "self", ",", "func", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "if", "self", ".", "tokens", ".", "accept", "(", "common_grammar", ".", "rparen", ")", ":", "# That was easy.", "return", "ast", ...
Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, because doing so would permit queries t...
[ "Parse", "the", "function", "application", "subgrammar", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L666-L695
google/dotty
efilter/parsers/dottysql/parser.py
Parser.list
def list(self): """Parse a list (tuple) which can contain any combination of types.""" start = self.tokens.matched.start if self.tokens.accept(common_grammar.rbracket): return ast.Tuple(start=start, end=self.tokens.matched.end, source=self.original) ...
python
def list(self): """Parse a list (tuple) which can contain any combination of types.""" start = self.tokens.matched.start if self.tokens.accept(common_grammar.rbracket): return ast.Tuple(start=start, end=self.tokens.matched.end, source=self.original) ...
[ "def", "list", "(", "self", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "if", "self", ".", "tokens", ".", "accept", "(", "common_grammar", ".", "rbracket", ")", ":", "return", "ast", ".", "Tuple", "(", "start", "=", ...
Parse a list (tuple) which can contain any combination of types.
[ "Parse", "a", "list", "(", "tuple", ")", "which", "can", "contain", "any", "combination", "of", "types", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L699-L714
google/dotty
efilter/ext/row_tuple.py
RowTuple.get_singleton
def get_singleton(self): """If the row only has one column, return that value; otherwise raise. Raises: ValueError, if count of columns is not 1. """ only_value = None for value in six.itervalues(self.ordered_dict): # This loop will raise if it runs more ...
python
def get_singleton(self): """If the row only has one column, return that value; otherwise raise. Raises: ValueError, if count of columns is not 1. """ only_value = None for value in six.itervalues(self.ordered_dict): # This loop will raise if it runs more ...
[ "def", "get_singleton", "(", "self", ")", ":", "only_value", "=", "None", "for", "value", "in", "six", ".", "itervalues", "(", "self", ".", "ordered_dict", ")", ":", "# This loop will raise if it runs more than once.", "if", "only_value", "is", "not", "None", ":...
If the row only has one column, return that value; otherwise raise. Raises: ValueError, if count of columns is not 1.
[ "If", "the", "row", "only", "has", "one", "column", "return", "that", "value", ";", "otherwise", "raise", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/ext/row_tuple.py#L93-L110
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._cpu
def _cpu(self): """Record CPU usage.""" value = int(psutil.cpu_percent()) set_metric("cpu", value, category=self.category) gauge("cpu", value)
python
def _cpu(self): """Record CPU usage.""" value = int(psutil.cpu_percent()) set_metric("cpu", value, category=self.category) gauge("cpu", value)
[ "def", "_cpu", "(", "self", ")", ":", "value", "=", "int", "(", "psutil", ".", "cpu_percent", "(", ")", ")", "set_metric", "(", "\"cpu\"", ",", "value", ",", "category", "=", "self", ".", "category", ")", "gauge", "(", "\"cpu\"", ",", "value", ")" ]
Record CPU usage.
[ "Record", "CPU", "usage", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L83-L87
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._mem
def _mem(self): """Record Memory usage.""" value = int(psutil.virtual_memory().percent) set_metric("memory", value, category=self.category) gauge("memory", value)
python
def _mem(self): """Record Memory usage.""" value = int(psutil.virtual_memory().percent) set_metric("memory", value, category=self.category) gauge("memory", value)
[ "def", "_mem", "(", "self", ")", ":", "value", "=", "int", "(", "psutil", ".", "virtual_memory", "(", ")", ".", "percent", ")", "set_metric", "(", "\"memory\"", ",", "value", ",", "category", "=", "self", ".", "category", ")", "gauge", "(", "\"memory\"...
Record Memory usage.
[ "Record", "Memory", "usage", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L89-L93
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._disk
def _disk(self): """Record Disk usage.""" mountpoints = [ p.mountpoint for p in psutil.disk_partitions() if p.device.endswith(self.device) ] if len(mountpoints) != 1: raise CommandError("Unknown device: {0}".format(self.device)) value = int(ps...
python
def _disk(self): """Record Disk usage.""" mountpoints = [ p.mountpoint for p in psutil.disk_partitions() if p.device.endswith(self.device) ] if len(mountpoints) != 1: raise CommandError("Unknown device: {0}".format(self.device)) value = int(ps...
[ "def", "_disk", "(", "self", ")", ":", "mountpoints", "=", "[", "p", ".", "mountpoint", "for", "p", "in", "psutil", ".", "disk_partitions", "(", ")", "if", "p", ".", "device", ".", "endswith", "(", "self", ".", "device", ")", "]", "if", "len", "(",...
Record Disk usage.
[ "Record", "Disk", "usage", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L95-L106
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._net
def _net(self): """Record Network usage.""" data = psutil.network_io_counters(pernic=True) if self.device not in data: raise CommandError("Unknown device: {0}".format(self.device)) # Network bytes sent value = data[self.device].bytes_sent metric("net-{0}-sent...
python
def _net(self): """Record Network usage.""" data = psutil.network_io_counters(pernic=True) if self.device not in data: raise CommandError("Unknown device: {0}".format(self.device)) # Network bytes sent value = data[self.device].bytes_sent metric("net-{0}-sent...
[ "def", "_net", "(", "self", ")", ":", "data", "=", "psutil", ".", "network_io_counters", "(", "pernic", "=", "True", ")", "if", "self", ".", "device", "not", "in", "data", ":", "raise", "CommandError", "(", "\"Unknown device: {0}\"", ".", "format", "(", ...
Record Network usage.
[ "Record", "Network", "usage", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L108-L121
google/dotty
efilter/protocol.py
implements
def implements(obj, protocol): """Does the object 'obj' implement the 'prococol'?""" if isinstance(obj, type): raise TypeError("First argument to implements must be an instance. " "Got %r." % obj) return isinstance(obj, protocol) or issubclass(AnyType, protocol)
python
def implements(obj, protocol): """Does the object 'obj' implement the 'prococol'?""" if isinstance(obj, type): raise TypeError("First argument to implements must be an instance. " "Got %r." % obj) return isinstance(obj, protocol) or issubclass(AnyType, protocol)
[ "def", "implements", "(", "obj", ",", "protocol", ")", ":", "if", "isinstance", "(", "obj", ",", "type", ")", ":", "raise", "TypeError", "(", "\"First argument to implements must be an instance. \"", "\"Got %r.\"", "%", "obj", ")", "return", "isinstance", "(", "...
Does the object 'obj' implement the 'prococol'?
[ "Does", "the", "object", "obj", "implement", "the", "prococol", "?" ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L73-L78
google/dotty
efilter/protocol.py
isa
def isa(cls, protocol): """Does the type 'cls' participate in the 'protocol'?""" if not isinstance(cls, type): raise TypeError("First argument to isa must be a type. Got %s." % repr(cls)) if not isinstance(protocol, type): raise TypeError(("Second argument to isa mus...
python
def isa(cls, protocol): """Does the type 'cls' participate in the 'protocol'?""" if not isinstance(cls, type): raise TypeError("First argument to isa must be a type. Got %s." % repr(cls)) if not isinstance(protocol, type): raise TypeError(("Second argument to isa mus...
[ "def", "isa", "(", "cls", ",", "protocol", ")", ":", "if", "not", "isinstance", "(", "cls", ",", "type", ")", ":", "raise", "TypeError", "(", "\"First argument to isa must be a type. Got %s.\"", "%", "repr", "(", "cls", ")", ")", "if", "not", "isinstance", ...
Does the type 'cls' participate in the 'protocol'?
[ "Does", "the", "type", "cls", "participate", "in", "the", "protocol", "?" ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L81-L90
google/dotty
efilter/protocol.py
Protocol.implemented
def implemented(cls, for_type): """Assert that protocol 'cls' is implemented for type 'for_type'. This will cause 'for_type' to be registered with the protocol 'cls'. Subsequently, protocol.isa(for_type, cls) will return True, as will isinstance, issubclass and others. Raises: ...
python
def implemented(cls, for_type): """Assert that protocol 'cls' is implemented for type 'for_type'. This will cause 'for_type' to be registered with the protocol 'cls'. Subsequently, protocol.isa(for_type, cls) will return True, as will isinstance, issubclass and others. Raises: ...
[ "def", "implemented", "(", "cls", ",", "for_type", ")", ":", "for", "function", "in", "cls", ".", "required", "(", ")", ":", "if", "not", "function", ".", "implemented_for_type", "(", "for_type", ")", ":", "raise", "TypeError", "(", "\"%r doesn't implement %...
Assert that protocol 'cls' is implemented for type 'for_type'. This will cause 'for_type' to be registered with the protocol 'cls'. Subsequently, protocol.isa(for_type, cls) will return True, as will isinstance, issubclass and others. Raises: TypeError if 'for_type' doesn't...
[ "Assert", "that", "protocol", "cls", "is", "implemented", "for", "type", "for_type", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L126-L144
google/dotty
efilter/protocol.py
Protocol.__get_type_args
def __get_type_args(for_type=None, for_types=None): """Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate. """ if for_type: if for_types: raise ValueError("Cannot pass both for_type and...
python
def __get_type_args(for_type=None, for_types=None): """Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate. """ if for_type: if for_types: raise ValueError("Cannot pass both for_type and...
[ "def", "__get_type_args", "(", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "if", "for_type", ":", "if", "for_types", ":", "raise", "ValueError", "(", "\"Cannot pass both for_type and for_types.\"", ")", "for_types", "=", "(", "for_type", ",...
Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate.
[ "Parse", "the", "arguments", "and", "return", "a", "tuple", "of", "types", "to", "implement", "for", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L147-L164
google/dotty
efilter/protocol.py
Protocol.implicit_static
def implicit_static(cls, for_type=None, for_types=None): """Automatically generate implementations for a type. Implement the protocol for the 'for_type' type by dispatching each member function of the protocol to an instance method of the same name declared on the type 'for_type'. ...
python
def implicit_static(cls, for_type=None, for_types=None): """Automatically generate implementations for a type. Implement the protocol for the 'for_type' type by dispatching each member function of the protocol to an instance method of the same name declared on the type 'for_type'. ...
[ "def", "implicit_static", "(", "cls", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for", "type_", "in", "cls", ".", "__get_type_args", "(", "for_type", ",", "for_types", ")", ":", "implementations", "=", "{", "}", "for", "funct...
Automatically generate implementations for a type. Implement the protocol for the 'for_type' type by dispatching each member function of the protocol to an instance method of the same name declared on the type 'for_type'. Arguments: for_type: The type to implictly implement...
[ "Automatically", "generate", "implementations", "for", "a", "type", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L187-L219
google/dotty
efilter/protocol.py
Protocol._build_late_dispatcher
def _build_late_dispatcher(func_name): """Return a function that calls method 'func_name' on objects. This is useful for building late-bound dynamic dispatch. Arguments: func_name: The name of the instance method that should be called. Returns: A function that ...
python
def _build_late_dispatcher(func_name): """Return a function that calls method 'func_name' on objects. This is useful for building late-bound dynamic dispatch. Arguments: func_name: The name of the instance method that should be called. Returns: A function that ...
[ "def", "_build_late_dispatcher", "(", "func_name", ")", ":", "def", "_late_dynamic_dispatcher", "(", "obj", ",", "*", "args", ")", ":", "method", "=", "getattr", "(", "obj", ",", "func_name", ",", "None", ")", "if", "not", "callable", "(", "method", ")", ...
Return a function that calls method 'func_name' on objects. This is useful for building late-bound dynamic dispatch. Arguments: func_name: The name of the instance method that should be called. Returns: A function that takes an 'obj' parameter, followed by *args and ...
[ "Return", "a", "function", "that", "calls", "method", "func_name", "on", "objects", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L222-L245
google/dotty
efilter/protocol.py
Protocol.implicit_dynamic
def implicit_dynamic(cls, for_type=None, for_types=None): """Automatically generate late dynamic dispatchers to type. This is similar to 'implicit_static', except instead of binding the instance methods, it generates a dispatcher that will call whatever instance method of the same name ...
python
def implicit_dynamic(cls, for_type=None, for_types=None): """Automatically generate late dynamic dispatchers to type. This is similar to 'implicit_static', except instead of binding the instance methods, it generates a dispatcher that will call whatever instance method of the same name ...
[ "def", "implicit_dynamic", "(", "cls", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for", "type_", "in", "cls", ".", "__get_type_args", "(", "for_type", ",", "for_types", ")", ":", "implementations", "=", "{", "}", "for", "func...
Automatically generate late dynamic dispatchers to type. This is similar to 'implicit_static', except instead of binding the instance methods, it generates a dispatcher that will call whatever instance method of the same name happens to be available at time of dispatch. This ha...
[ "Automatically", "generate", "late", "dynamic", "dispatchers", "to", "type", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L248-L268
google/dotty
efilter/protocol.py
Protocol.implement
def implement(cls, implementations, for_type=None, for_types=None): """Provide protocol implementation for a type. Register all implementations of multimethod functions in this protocol and add the type into the abstract base class of the protocol. Arguments: implem...
python
def implement(cls, implementations, for_type=None, for_types=None): """Provide protocol implementation for a type. Register all implementations of multimethod functions in this protocol and add the type into the abstract base class of the protocol. Arguments: implem...
[ "def", "implement", "(", "cls", ",", "implementations", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for", "type_", "in", "cls", ".", "__get_type_args", "(", "for_type", ",", "for_types", ")", ":", "cls", ".", "_implement_for_typ...
Provide protocol implementation for a type. Register all implementations of multimethod functions in this protocol and add the type into the abstract base class of the protocol. Arguments: implementations: A dict of (function, implementation), where each fun...
[ "Provide", "protocol", "implementation", "for", "a", "type", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L271-L294
google/dotty
sample_projects/tagging/tag.py
TagFile._parse_query
def _parse_query(self, source): """Parse one of the rules as either objectfilter or dottysql. Example: _parse_query("5 + 5") # Returns Sum(Literal(5), Literal(5)) Arguments: source: A rule in either objectfilter or dottysql syntax. Returns: ...
python
def _parse_query(self, source): """Parse one of the rules as either objectfilter or dottysql. Example: _parse_query("5 + 5") # Returns Sum(Literal(5), Literal(5)) Arguments: source: A rule in either objectfilter or dottysql syntax. Returns: ...
[ "def", "_parse_query", "(", "self", ",", "source", ")", ":", "if", "self", ".", "OBJECTFILTER_WORDS", ".", "search", "(", "source", ")", ":", "syntax_", "=", "\"objectfilter\"", "else", ":", "syntax_", "=", "None", "# Default it is.", "return", "query", ".",...
Parse one of the rules as either objectfilter or dottysql. Example: _parse_query("5 + 5") # Returns Sum(Literal(5), Literal(5)) Arguments: source: A rule in either objectfilter or dottysql syntax. Returns: The AST to represent the rule.
[ "Parse", "one", "of", "the", "rules", "as", "either", "objectfilter", "or", "dottysql", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/sample_projects/tagging/tag.py#L96-L114
google/dotty
sample_projects/tagging/tag.py
TagFile._parse_tagfile
def _parse_tagfile(self): """Parse the tagfile and yield tuples of tag_name, list of rule ASTs.""" rules = None tag = None for line in self.original: match = self.TAG_DECL_LINE.match(line) if match: if tag and rules: yield tag, ...
python
def _parse_tagfile(self): """Parse the tagfile and yield tuples of tag_name, list of rule ASTs.""" rules = None tag = None for line in self.original: match = self.TAG_DECL_LINE.match(line) if match: if tag and rules: yield tag, ...
[ "def", "_parse_tagfile", "(", "self", ")", ":", "rules", "=", "None", "tag", "=", "None", "for", "line", "in", "self", ".", "original", ":", "match", "=", "self", ".", "TAG_DECL_LINE", ".", "match", "(", "line", ")", "if", "match", ":", "if", "tag", ...
Parse the tagfile and yield tuples of tag_name, list of rule ASTs.
[ "Parse", "the", "tagfile", "and", "yield", "tuples", "of", "tag_name", "list", "of", "rule", "ASTs", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/sample_projects/tagging/tag.py#L116-L132
google/dotty
efilter/transforms/normalize.py
normalize
def normalize(expr): """Normalize both sides, but don't eliminate the expression.""" lhs = normalize(expr.lhs) rhs = normalize(expr.rhs) return type(expr)(lhs, rhs, start=lhs.start, end=rhs.end)
python
def normalize(expr): """Normalize both sides, but don't eliminate the expression.""" lhs = normalize(expr.lhs) rhs = normalize(expr.rhs) return type(expr)(lhs, rhs, start=lhs.start, end=rhs.end)
[ "def", "normalize", "(", "expr", ")", ":", "lhs", "=", "normalize", "(", "expr", ".", "lhs", ")", "rhs", "=", "normalize", "(", "expr", ".", "rhs", ")", "return", "type", "(", "expr", ")", "(", "lhs", ",", "rhs", ",", "start", "=", "lhs", ".", ...
Normalize both sides, but don't eliminate the expression.
[ "Normalize", "both", "sides", "but", "don", "t", "eliminate", "the", "expression", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/normalize.py#L64-L68
google/dotty
efilter/transforms/normalize.py
normalize
def normalize(expr): """No elimination, but normalize arguments.""" args = [normalize(arg) for arg in expr.args] return type(expr)(expr.func, *args, start=expr.start, end=expr.end)
python
def normalize(expr): """No elimination, but normalize arguments.""" args = [normalize(arg) for arg in expr.args] return type(expr)(expr.func, *args, start=expr.start, end=expr.end)
[ "def", "normalize", "(", "expr", ")", ":", "args", "=", "[", "normalize", "(", "arg", ")", "for", "arg", "in", "expr", ".", "args", "]", "return", "type", "(", "expr", ")", "(", "expr", ".", "func", ",", "*", "args", ",", "start", "=", "expr", ...
No elimination, but normalize arguments.
[ "No", "elimination", "but", "normalize", "arguments", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/normalize.py#L72-L76
google/dotty
efilter/transforms/normalize.py
normalize
def normalize(expr): """Pass through n-ary expressions, and eliminate empty branches. Variadic and binary expressions recursively visit all their children. If all children are eliminated then the parent expression is also eliminated: (& [removed] [removed]) => [removed] If only one child is ...
python
def normalize(expr): """Pass through n-ary expressions, and eliminate empty branches. Variadic and binary expressions recursively visit all their children. If all children are eliminated then the parent expression is also eliminated: (& [removed] [removed]) => [removed] If only one child is ...
[ "def", "normalize", "(", "expr", ")", ":", "children", "=", "[", "]", "for", "child", "in", "expr", ".", "children", ":", "branch", "=", "normalize", "(", "child", ")", "if", "branch", "is", "None", ":", "continue", "if", "type", "(", "branch", ")", ...
Pass through n-ary expressions, and eliminate empty branches. Variadic and binary expressions recursively visit all their children. If all children are eliminated then the parent expression is also eliminated: (& [removed] [removed]) => [removed] If only one child is left, it is promoted to repl...
[ "Pass", "through", "n", "-", "ary", "expressions", "and", "eliminate", "empty", "branches", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/normalize.py#L80-L112
bradmontgomery/django-redis-metrics
redis_metrics/models.py
dedupe
def dedupe(items): """Remove duplicates from a sequence (of hashable items) while maintaining order. NOTE: This only works if items in the list are hashable types. Taken from the Python Cookbook, 3rd ed. Such a great book! """ seen = set() for item in items: if item not in seen: ...
python
def dedupe(items): """Remove duplicates from a sequence (of hashable items) while maintaining order. NOTE: This only works if items in the list are hashable types. Taken from the Python Cookbook, 3rd ed. Such a great book! """ seen = set() for item in items: if item not in seen: ...
[ "def", "dedupe", "(", "items", ")", ":", "seen", "=", "set", "(", ")", "for", "item", "in", "items", ":", "if", "item", "not", "in", "seen", ":", "yield", "item", "seen", ".", "add", "(", "item", ")" ]
Remove duplicates from a sequence (of hashable items) while maintaining order. NOTE: This only works if items in the list are hashable types. Taken from the Python Cookbook, 3rd ed. Such a great book!
[ "Remove", "duplicates", "from", "a", "sequence", "(", "of", "hashable", "items", ")", "while", "maintaining", "order", ".", "NOTE", ":", "This", "only", "works", "if", "items", "in", "the", "list", "are", "hashable", "types", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L18-L29
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R._date_range
def _date_range(self, granularity, since, to=None): """Returns a generator that yields ``datetime.datetime`` objects from the ``since`` date until ``to`` (default: *now*). * ``granularity`` -- The granularity at which the generated datetime objects should be created: seconds, minutes,...
python
def _date_range(self, granularity, since, to=None): """Returns a generator that yields ``datetime.datetime`` objects from the ``since`` date until ``to`` (default: *now*). * ``granularity`` -- The granularity at which the generated datetime objects should be created: seconds, minutes,...
[ "def", "_date_range", "(", "self", ",", "granularity", ",", "since", ",", "to", "=", "None", ")", ":", "if", "since", "is", "None", ":", "since", "=", "datetime", ".", "utcnow", "(", ")", "-", "timedelta", "(", "days", "=", "7", ")", "# Default to 7 ...
Returns a generator that yields ``datetime.datetime`` objects from the ``since`` date until ``to`` (default: *now*). * ``granularity`` -- The granularity at which the generated datetime objects should be created: seconds, minutes, hourly, daily, weekly, monthly, or yearly * ...
[ "Returns", "a", "generator", "that", "yields", "datetime", ".", "datetime", "objects", "from", "the", "since", "date", "until", "to", "(", "default", ":", "*", "now", "*", ")", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L91-L144
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R._category_slugs
def _category_slugs(self, category): """Returns a set of the metric slugs for the given category""" key = self._category_key(category) slugs = self.r.smembers(key) return slugs
python
def _category_slugs(self, category): """Returns a set of the metric slugs for the given category""" key = self._category_key(category) slugs = self.r.smembers(key) return slugs
[ "def", "_category_slugs", "(", "self", ",", "category", ")", ":", "key", "=", "self", ".", "_category_key", "(", "category", ")", "slugs", "=", "self", ".", "r", ".", "smembers", "(", "key", ")", "return", "slugs" ]
Returns a set of the metric slugs for the given category
[ "Returns", "a", "set", "of", "the", "metric", "slugs", "for", "the", "given", "category" ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L154-L158
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R._categorize
def _categorize(self, slug, category): """Add the ``slug`` to the ``category``. We store category data as as set, with a key of the form:: c:<category name> The data is set of metric slugs:: "slug-a", "slug-b", ... """ key = self._category_key(category...
python
def _categorize(self, slug, category): """Add the ``slug`` to the ``category``. We store category data as as set, with a key of the form:: c:<category name> The data is set of metric slugs:: "slug-a", "slug-b", ... """ key = self._category_key(category...
[ "def", "_categorize", "(", "self", ",", "slug", ",", "category", ")", ":", "key", "=", "self", ".", "_category_key", "(", "category", ")", "self", ".", "r", ".", "sadd", "(", "key", ",", "slug", ")", "# Store all category names in a Redis set, for easy retriev...
Add the ``slug`` to the ``category``. We store category data as as set, with a key of the form:: c:<category name> The data is set of metric slugs:: "slug-a", "slug-b", ...
[ "Add", "the", "slug", "to", "the", "category", ".", "We", "store", "category", "data", "as", "as", "set", "with", "a", "key", "of", "the", "form", "::" ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L160-L175
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R._granularities
def _granularities(self): """Returns a generator of all possible granularities based on the MIN_GRANULARITY and MAX_GRANULARITY settings. """ keep = False for g in GRANULARITIES: if g == app_settings.MIN_GRANULARITY and not keep: keep = True ...
python
def _granularities(self): """Returns a generator of all possible granularities based on the MIN_GRANULARITY and MAX_GRANULARITY settings. """ keep = False for g in GRANULARITIES: if g == app_settings.MIN_GRANULARITY and not keep: keep = True ...
[ "def", "_granularities", "(", "self", ")", ":", "keep", "=", "False", "for", "g", "in", "GRANULARITIES", ":", "if", "g", "==", "app_settings", ".", "MIN_GRANULARITY", "and", "not", "keep", ":", "keep", "=", "True", "elif", "g", "==", "app_settings", ".",...
Returns a generator of all possible granularities based on the MIN_GRANULARITY and MAX_GRANULARITY settings.
[ "Returns", "a", "generator", "of", "all", "possible", "granularities", "based", "on", "the", "MIN_GRANULARITY", "and", "MAX_GRANULARITY", "settings", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L177-L189
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R._build_key_patterns
def _build_key_patterns(self, slug, date): """Builds an OrderedDict of metric keys and patterns for the given slug and date.""" # we want to keep the order, from smallest to largest granularity patts = OrderedDict() metric_key_patterns = self._metric_key_patterns() for g ...
python
def _build_key_patterns(self, slug, date): """Builds an OrderedDict of metric keys and patterns for the given slug and date.""" # we want to keep the order, from smallest to largest granularity patts = OrderedDict() metric_key_patterns = self._metric_key_patterns() for g ...
[ "def", "_build_key_patterns", "(", "self", ",", "slug", ",", "date", ")", ":", "# we want to keep the order, from smallest to largest granularity", "patts", "=", "OrderedDict", "(", ")", "metric_key_patterns", "=", "self", ".", "_metric_key_patterns", "(", ")", "for", ...
Builds an OrderedDict of metric keys and patterns for the given slug and date.
[ "Builds", "an", "OrderedDict", "of", "metric", "keys", "and", "patterns", "for", "the", "given", "slug", "and", "date", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L206-L215
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R._build_keys
def _build_keys(self, slug, date=None, granularity='all'): """Builds redis keys used to store metrics. * ``slug`` -- a slug used for a metric, e.g. "user-signups" * ``date`` -- (optional) A ``datetime.datetime`` object used to generate the time period for the metric. If omitted, the c...
python
def _build_keys(self, slug, date=None, granularity='all'): """Builds redis keys used to store metrics. * ``slug`` -- a slug used for a metric, e.g. "user-signups" * ``date`` -- (optional) A ``datetime.datetime`` object used to generate the time period for the metric. If omitted, the c...
[ "def", "_build_keys", "(", "self", ",", "slug", ",", "date", "=", "None", ",", "granularity", "=", "'all'", ")", ":", "slug", "=", "slugify", "(", "slug", ")", "# Ensure slugs have a consistent format", "if", "date", "is", "None", ":", "date", "=", "dateti...
Builds redis keys used to store metrics. * ``slug`` -- a slug used for a metric, e.g. "user-signups" * ``date`` -- (optional) A ``datetime.datetime`` object used to generate the time period for the metric. If omitted, the current date and time (in UTC) will be used. * ``gran...
[ "Builds", "redis", "keys", "used", "to", "store", "metrics", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L217-L236
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.metric_slugs_by_category
def metric_slugs_by_category(self): """Return a dictionary of metrics data indexed by category: {<category_name>: set(<slug1>, <slug2>, ...)} """ result = OrderedDict() categories = sorted(self.r.smembers(self._categories_key)) for category in categories: ...
python
def metric_slugs_by_category(self): """Return a dictionary of metrics data indexed by category: {<category_name>: set(<slug1>, <slug2>, ...)} """ result = OrderedDict() categories = sorted(self.r.smembers(self._categories_key)) for category in categories: ...
[ "def", "metric_slugs_by_category", "(", "self", ")", ":", "result", "=", "OrderedDict", "(", ")", "categories", "=", "sorted", "(", "self", ".", "r", ".", "smembers", "(", "self", ".", "_categories_key", ")", ")", "for", "category", "in", "categories", ":"...
Return a dictionary of metrics data indexed by category: {<category_name>: set(<slug1>, <slug2>, ...)}
[ "Return", "a", "dictionary", "of", "metrics", "data", "indexed", "by", "category", ":" ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L243-L263
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.delete_metric
def delete_metric(self, slug): """Removes all keys for the given ``slug``.""" # To remove all keys for a slug, I need to retrieve them all from # the set of metric keys, This uses the redis "keys" command, which is # inefficient, but this shouldn't be used all that often. prefix...
python
def delete_metric(self, slug): """Removes all keys for the given ``slug``.""" # To remove all keys for a slug, I need to retrieve them all from # the set of metric keys, This uses the redis "keys" command, which is # inefficient, but this shouldn't be used all that often. prefix...
[ "def", "delete_metric", "(", "self", ",", "slug", ")", ":", "# To remove all keys for a slug, I need to retrieve them all from", "# the set of metric keys, This uses the redis \"keys\" command, which is", "# inefficient, but this shouldn't be used all that often.", "prefix", "=", "\"m:{0}:...
Removes all keys for the given ``slug``.
[ "Removes", "all", "keys", "for", "the", "given", "slug", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L265-L276
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.set_metric
def set_metric(self, slug, value, category=None, expire=None, date=None): """Assigns a specific value to the *current* metric. You can use this to start a metric at a value greater than 0 or to reset a metric. The given slug will be used to generate Redis keys at the following granulari...
python
def set_metric(self, slug, value, category=None, expire=None, date=None): """Assigns a specific value to the *current* metric. You can use this to start a metric at a value greater than 0 or to reset a metric. The given slug will be used to generate Redis keys at the following granulari...
[ "def", "set_metric", "(", "self", ",", "slug", ",", "value", ",", "category", "=", "None", ",", "expire", "=", "None", ",", "date", "=", "None", ")", ":", "keys", "=", "self", ".", "_build_keys", "(", "slug", ",", "date", "=", "date", ")", "# Add t...
Assigns a specific value to the *current* metric. You can use this to start a metric at a value greater than 0 or to reset a metric. The given slug will be used to generate Redis keys at the following granularities: Seconds, Minutes, Hours, Day, Week, Month, and Year. Parameters: ...
[ "Assigns", "a", "specific", "value", "to", "the", "*", "current", "*", "metric", ".", "You", "can", "use", "this", "to", "start", "a", "metric", "at", "a", "value", "greater", "than", "0", "or", "to", "reset", "a", "metric", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L278-L325
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.metric
def metric(self, slug, num=1, category=None, expire=None, date=None): """Records a metric, creating it if it doesn't exist or incrementing it if it does. All metrics are prefixed with 'm', and automatically aggregate for Seconds, Minutes, Hours, Day, Week, Month, and Year. Parameters: ...
python
def metric(self, slug, num=1, category=None, expire=None, date=None): """Records a metric, creating it if it doesn't exist or incrementing it if it does. All metrics are prefixed with 'm', and automatically aggregate for Seconds, Minutes, Hours, Day, Week, Month, and Year. Parameters: ...
[ "def", "metric", "(", "self", ",", "slug", ",", "num", "=", "1", ",", "category", "=", "None", ",", "expire", "=", "None", ",", "date", "=", "None", ")", ":", "# Add the slug to the set of metric slugs", "self", ".", "r", ".", "sadd", "(", "self", ".",...
Records a metric, creating it if it doesn't exist or incrementing it if it does. All metrics are prefixed with 'm', and automatically aggregate for Seconds, Minutes, Hours, Day, Week, Month, and Year. Parameters: * ``slug`` -- a unique value to identify the metric; used in co...
[ "Records", "a", "metric", "creating", "it", "if", "it", "doesn", "t", "exist", "or", "incrementing", "it", "if", "it", "does", ".", "All", "metrics", "are", "prefixed", "with", "m", "and", "automatically", "aggregate", "for", "Seconds", "Minutes", "Hours", ...
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L327-L370
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.get_metric
def get_metric(self, slug): """Get the current values for a metric. Returns a dictionary with metric values accumulated for the seconds, minutes, hours, day, week, month, and year. """ results = OrderedDict() granularities = self._granularities() keys = self._bu...
python
def get_metric(self, slug): """Get the current values for a metric. Returns a dictionary with metric values accumulated for the seconds, minutes, hours, day, week, month, and year. """ results = OrderedDict() granularities = self._granularities() keys = self._bu...
[ "def", "get_metric", "(", "self", ",", "slug", ")", ":", "results", "=", "OrderedDict", "(", ")", "granularities", "=", "self", ".", "_granularities", "(", ")", "keys", "=", "self", ".", "_build_keys", "(", "slug", ")", "for", "granularity", ",", "key", ...
Get the current values for a metric. Returns a dictionary with metric values accumulated for the seconds, minutes, hours, day, week, month, and year.
[ "Get", "the", "current", "values", "for", "a", "metric", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L372-L384
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.get_metrics
def get_metrics(self, slug_list): """Get the metrics for multiple slugs. Returns a list of two-tuples containing the metric slug and a dictionary like the one returned by ``get_metric``:: ( some-metric, { 'seconds': 0, 'minutes': 0, 'hours': 0, ...
python
def get_metrics(self, slug_list): """Get the metrics for multiple slugs. Returns a list of two-tuples containing the metric slug and a dictionary like the one returned by ``get_metric``:: ( some-metric, { 'seconds': 0, 'minutes': 0, 'hours': 0, ...
[ "def", "get_metrics", "(", "self", ",", "slug_list", ")", ":", "# meh. I should have been consistent here, but I'm lazy, so support these", "# value names instead of granularity names, but respect the min/max", "# granularity settings.", "keys", "=", "[", "'seconds'", ",", "'minutes'...
Get the metrics for multiple slugs. Returns a list of two-tuples containing the metric slug and a dictionary like the one returned by ``get_metric``:: ( some-metric, { 'seconds': 0, 'minutes': 0, 'hours': 0, 'day': 0, 'week': 0, 'mont...
[ "Get", "the", "metrics", "for", "multiple", "slugs", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L386-L412
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.get_category_metrics
def get_category_metrics(self, category): """Get metrics belonging to the given category""" slug_list = self._category_slugs(category) return self.get_metrics(slug_list)
python
def get_category_metrics(self, category): """Get metrics belonging to the given category""" slug_list = self._category_slugs(category) return self.get_metrics(slug_list)
[ "def", "get_category_metrics", "(", "self", ",", "category", ")", ":", "slug_list", "=", "self", ".", "_category_slugs", "(", "category", ")", "return", "self", ".", "get_metrics", "(", "slug_list", ")" ]
Get metrics belonging to the given category
[ "Get", "metrics", "belonging", "to", "the", "given", "category" ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L414-L417
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.delete_category
def delete_category(self, category): """Removes the category from Redis. This doesn't touch the metrics; they simply become uncategorized.""" # Remove mapping of metrics-to-category category_key = self._category_key(category) self.r.delete(category_key) # Remove category...
python
def delete_category(self, category): """Removes the category from Redis. This doesn't touch the metrics; they simply become uncategorized.""" # Remove mapping of metrics-to-category category_key = self._category_key(category) self.r.delete(category_key) # Remove category...
[ "def", "delete_category", "(", "self", ",", "category", ")", ":", "# Remove mapping of metrics-to-category", "category_key", "=", "self", ".", "_category_key", "(", "category", ")", "self", ".", "r", ".", "delete", "(", "category_key", ")", "# Remove category from S...
Removes the category from Redis. This doesn't touch the metrics; they simply become uncategorized.
[ "Removes", "the", "category", "from", "Redis", ".", "This", "doesn", "t", "touch", "the", "metrics", ";", "they", "simply", "become", "uncategorized", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L419-L427
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.reset_category
def reset_category(self, category, metric_slugs): """Resets (or creates) a category containing a list of metrics. * ``category`` -- A category name * ``metric_slugs`` -- a list of all metrics that are members of the category. """ key = self._category_key(category) ...
python
def reset_category(self, category, metric_slugs): """Resets (or creates) a category containing a list of metrics. * ``category`` -- A category name * ``metric_slugs`` -- a list of all metrics that are members of the category. """ key = self._category_key(category) ...
[ "def", "reset_category", "(", "self", ",", "category", ",", "metric_slugs", ")", ":", "key", "=", "self", ".", "_category_key", "(", "category", ")", "if", "len", "(", "metric_slugs", ")", "==", "0", ":", "# If there are no metrics, just remove the category", "s...
Resets (or creates) a category containing a list of metrics. * ``category`` -- A category name * ``metric_slugs`` -- a list of all metrics that are members of the category.
[ "Resets", "(", "or", "creates", ")", "a", "category", "containing", "a", "list", "of", "metrics", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L429-L444
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.get_metric_history
def get_metric_history(self, slugs, since=None, to=None, granularity='daily'): """Get history for one or more metrics. * ``slugs`` -- a slug OR a list of slugs * ``since`` -- the date from which we start pulling metrics * ``to`` -- the date until which we start pulling metrics *...
python
def get_metric_history(self, slugs, since=None, to=None, granularity='daily'): """Get history for one or more metrics. * ``slugs`` -- a slug OR a list of slugs * ``since`` -- the date from which we start pulling metrics * ``to`` -- the date until which we start pulling metrics *...
[ "def", "get_metric_history", "(", "self", ",", "slugs", ",", "since", "=", "None", ",", "to", "=", "None", ",", "granularity", "=", "'daily'", ")", ":", "if", "not", "type", "(", "slugs", ")", "==", "list", ":", "slugs", "=", "[", "slugs", "]", "# ...
Get history for one or more metrics. * ``slugs`` -- a slug OR a list of slugs * ``since`` -- the date from which we start pulling metrics * ``to`` -- the date until which we start pulling metrics * ``granularity`` -- seconds, minutes, hourly, daily, weekly, ...
[ "Get", "history", "for", "one", "or", "more", "metrics", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L446-L487
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.get_metric_history_as_columns
def get_metric_history_as_columns(self, slugs, since=None, granularity='daily'): """Provides the same data as ``get_metric_history``, but in a columnar format. If you had the following yearly history, for example:: [ ('m:bar:y:2012', '1'...
python
def get_metric_history_as_columns(self, slugs, since=None, granularity='daily'): """Provides the same data as ``get_metric_history``, but in a columnar format. If you had the following yearly history, for example:: [ ('m:bar:y:2012', '1'...
[ "def", "get_metric_history_as_columns", "(", "self", ",", "slugs", ",", "since", "=", "None", ",", "granularity", "=", "'daily'", ")", ":", "history", "=", "self", ".", "get_metric_history", "(", "slugs", ",", "since", ",", "granularity", "=", "granularity", ...
Provides the same data as ``get_metric_history``, but in a columnar format. If you had the following yearly history, for example:: [ ('m:bar:y:2012', '1'), ('m:bar:y:2013', '2'), ('m:foo:y:2012', '3'), ('m:foo:y:2013', '4') ...
[ "Provides", "the", "same", "data", "as", "get_metric_history", "but", "in", "a", "columnar", "format", ".", "If", "you", "had", "the", "following", "yearly", "history", "for", "example", "::" ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L489-L535
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.get_metric_history_chart_data
def get_metric_history_chart_data(self, slugs, since=None, granularity='daily'): """Provides the same data as ``get_metric_history``, but with metrics data arranged in a format that's easy to plot with Chart.js. If you had the following yearly history, for example:: [ ...
python
def get_metric_history_chart_data(self, slugs, since=None, granularity='daily'): """Provides the same data as ``get_metric_history``, but with metrics data arranged in a format that's easy to plot with Chart.js. If you had the following yearly history, for example:: [ ...
[ "def", "get_metric_history_chart_data", "(", "self", ",", "slugs", ",", "since", "=", "None", ",", "granularity", "=", "'daily'", ")", ":", "slugs", "=", "sorted", "(", "slugs", ")", "history", "=", "self", ".", "get_metric_history", "(", "slugs", ",", "si...
Provides the same data as ``get_metric_history``, but with metrics data arranged in a format that's easy to plot with Chart.js. If you had the following yearly history, for example:: [ ('m:bar:y:2012', '1'), ('m:bar:y:2013', '2'), ('m:bar:y:20...
[ "Provides", "the", "same", "data", "as", "get_metric_history", "but", "with", "metrics", "data", "arranged", "in", "a", "format", "that", "s", "easy", "to", "plot", "with", "Chart", ".", "js", ".", "If", "you", "had", "the", "following", "yearly", "history...
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L537-L592
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.gauge
def gauge(self, slug, current_value): """Set the value for a Gauge. * ``slug`` -- the unique identifier (or key) for the Gauge * ``current_value`` -- the value that the gauge should display """ k = self._gauge_key(slug) self.r.sadd(self._gauge_slugs_key, slug) # keep t...
python
def gauge(self, slug, current_value): """Set the value for a Gauge. * ``slug`` -- the unique identifier (or key) for the Gauge * ``current_value`` -- the value that the gauge should display """ k = self._gauge_key(slug) self.r.sadd(self._gauge_slugs_key, slug) # keep t...
[ "def", "gauge", "(", "self", ",", "slug", ",", "current_value", ")", ":", "k", "=", "self", ".", "_gauge_key", "(", "slug", ")", "self", ".", "r", ".", "sadd", "(", "self", ".", "_gauge_slugs_key", ",", "slug", ")", "# keep track of all Gauges", "self", ...
Set the value for a Gauge. * ``slug`` -- the unique identifier (or key) for the Gauge * ``current_value`` -- the value that the gauge should display
[ "Set", "the", "value", "for", "a", "Gauge", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L605-L614
bradmontgomery/django-redis-metrics
redis_metrics/models.py
R.delete_gauge
def delete_gauge(self, slug): """Removes all gauges with the given ``slug``.""" key = self._gauge_key(slug) self.r.delete(key) # Remove the Gauge self.r.srem(self._gauge_slugs_key, slug)
python
def delete_gauge(self, slug): """Removes all gauges with the given ``slug``.""" key = self._gauge_key(slug) self.r.delete(key) # Remove the Gauge self.r.srem(self._gauge_slugs_key, slug)
[ "def", "delete_gauge", "(", "self", ",", "slug", ")", ":", "key", "=", "self", ".", "_gauge_key", "(", "slug", ")", "self", ".", "r", ".", "delete", "(", "key", ")", "# Remove the Gauge", "self", ".", "r", ".", "srem", "(", "self", ".", "_gauge_slugs...
Removes all gauges with the given ``slug``.
[ "Removes", "all", "gauges", "with", "the", "given", "slug", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L620-L624
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metric_tags.py
metrics_since
def metrics_since(slugs, years, link_type="detail", granularity=None): """Renders a template with a menu to view a metric (or metrics) for a given number of years. * ``slugs`` -- A Slug or a set/list of slugs * ``years`` -- Number of years to show past metrics * ``link_type`` -- What type of chart ...
python
def metrics_since(slugs, years, link_type="detail", granularity=None): """Renders a template with a menu to view a metric (or metrics) for a given number of years. * ``slugs`` -- A Slug or a set/list of slugs * ``years`` -- Number of years to show past metrics * ``link_type`` -- What type of chart ...
[ "def", "metrics_since", "(", "slugs", ",", "years", ",", "link_type", "=", "\"detail\"", ",", "granularity", "=", "None", ")", ":", "now", "=", "datetime", ".", "utcnow", "(", ")", "# Determine if we're looking at one slug or multiple slugs", "if", "type", "(", ...
Renders a template with a menu to view a metric (or metrics) for a given number of years. * ``slugs`` -- A Slug or a set/list of slugs * ``years`` -- Number of years to show past metrics * ``link_type`` -- What type of chart do we want ("history" or "aggregate") * history -- use when displayin...
[ "Renders", "a", "template", "with", "a", "menu", "to", "view", "a", "metric", "(", "or", "metrics", ")", "for", "a", "given", "number", "of", "years", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L12-L49
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metric_tags.py
gauge
def gauge(slug, maximum=9000, size=200, coerce='float'): """Include a Donut Chart for the specified Gauge. * ``slug`` -- the unique slug for the Gauge. * ``maximum`` -- The maximum value for the gauge (default is 9000) * ``size`` -- The size (in pixels) of the gauge (default is 200) * ``coerce`` --...
python
def gauge(slug, maximum=9000, size=200, coerce='float'): """Include a Donut Chart for the specified Gauge. * ``slug`` -- the unique slug for the Gauge. * ``maximum`` -- The maximum value for the gauge (default is 9000) * ``size`` -- The size (in pixels) of the gauge (default is 200) * ``coerce`` --...
[ "def", "gauge", "(", "slug", ",", "maximum", "=", "9000", ",", "size", "=", "200", ",", "coerce", "=", "'float'", ")", ":", "coerce_options", "=", "{", "'float'", ":", "float", ",", "'int'", ":", "int", ",", "'str'", ":", "str", "}", "coerce", "=",...
Include a Donut Chart for the specified Gauge. * ``slug`` -- the unique slug for the Gauge. * ``maximum`` -- The maximum value for the gauge (default is 9000) * ``size`` -- The size (in pixels) of the gauge (default is 200) * ``coerce`` -- type to which gauge values should be coerced. The default ...
[ "Include", "a", "Donut", "Chart", "for", "the", "specified", "Gauge", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L53-L81
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metric_tags.py
metric_detail
def metric_detail(slug, with_data_table=False): """Template Tag to display a metric's *current* detail. * ``slug`` -- the metric's unique slug * ``with_data_table`` -- if True, prints the raw data in a table. """ r = get_r() granularities = list(r._granularities()) metrics = r.get_metric(s...
python
def metric_detail(slug, with_data_table=False): """Template Tag to display a metric's *current* detail. * ``slug`` -- the metric's unique slug * ``with_data_table`` -- if True, prints the raw data in a table. """ r = get_r() granularities = list(r._granularities()) metrics = r.get_metric(s...
[ "def", "metric_detail", "(", "slug", ",", "with_data_table", "=", "False", ")", ":", "r", "=", "get_r", "(", ")", "granularities", "=", "list", "(", "r", ".", "_granularities", "(", ")", ")", "metrics", "=", "r", ".", "get_metric", "(", "slug", ")", ...
Template Tag to display a metric's *current* detail. * ``slug`` -- the metric's unique slug * ``with_data_table`` -- if True, prints the raw data in a table.
[ "Template", "Tag", "to", "display", "a", "metric", "s", "*", "current", "*", "detail", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L93-L112
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metric_tags.py
metric_history
def metric_history(slug, granularity="daily", since=None, to=None, with_data_table=False): """Template Tag to display a metric's history. * ``slug`` -- the metric's unique slug * ``granularity`` -- the granularity: daily, hourly, weekly, monthly, yearly * ``since`` -- a datetime obje...
python
def metric_history(slug, granularity="daily", since=None, to=None, with_data_table=False): """Template Tag to display a metric's history. * ``slug`` -- the metric's unique slug * ``granularity`` -- the granularity: daily, hourly, weekly, monthly, yearly * ``since`` -- a datetime obje...
[ "def", "metric_history", "(", "slug", ",", "granularity", "=", "\"daily\"", ",", "since", "=", "None", ",", "to", "=", "None", ",", "with_data_table", "=", "False", ")", ":", "r", "=", "get_r", "(", ")", "try", ":", "if", "since", "and", "len", "(", ...
Template Tag to display a metric's history. * ``slug`` -- the metric's unique slug * ``granularity`` -- the granularity: daily, hourly, weekly, monthly, yearly * ``since`` -- a datetime object or a string string matching one of the following patterns: "YYYY-mm-dd" for a date or "YYYY-mm-dd HH:MM:SS" ...
[ "Template", "Tag", "to", "display", "a", "metric", "s", "history", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L116-L159
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metric_tags.py
aggregate_detail
def aggregate_detail(slug_list, with_data_table=False): """Template Tag to display multiple metrics. * ``slug_list`` -- A list of slugs to display * ``with_data_table`` -- if True, prints the raw data in a table. """ r = get_r() metrics_data = [] granularities = r._granularities() # X...
python
def aggregate_detail(slug_list, with_data_table=False): """Template Tag to display multiple metrics. * ``slug_list`` -- A list of slugs to display * ``with_data_table`` -- if True, prints the raw data in a table. """ r = get_r() metrics_data = [] granularities = r._granularities() # X...
[ "def", "aggregate_detail", "(", "slug_list", ",", "with_data_table", "=", "False", ")", ":", "r", "=", "get_r", "(", ")", "metrics_data", "=", "[", "]", "granularities", "=", "r", ".", "_granularities", "(", ")", "# XXX converting granularties into their key-name ...
Template Tag to display multiple metrics. * ``slug_list`` -- A list of slugs to display * ``with_data_table`` -- if True, prints the raw data in a table.
[ "Template", "Tag", "to", "display", "multiple", "metrics", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L163-L195
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metric_tags.py
aggregate_history
def aggregate_history(slugs, granularity="daily", since=None, with_data_table=False): """Template Tag to display history for multiple metrics. * ``slug_list`` -- A list of slugs to display * ``granularity`` -- the granularity: seconds, minutes, hourly, daily, weekly, monthly, yearl...
python
def aggregate_history(slugs, granularity="daily", since=None, with_data_table=False): """Template Tag to display history for multiple metrics. * ``slug_list`` -- A list of slugs to display * ``granularity`` -- the granularity: seconds, minutes, hourly, daily, weekly, monthly, yearl...
[ "def", "aggregate_history", "(", "slugs", ",", "granularity", "=", "\"daily\"", ",", "since", "=", "None", ",", "with_data_table", "=", "False", ")", ":", "r", "=", "get_r", "(", ")", "slugs", "=", "list", "(", "slugs", ")", "try", ":", "if", "since", ...
Template Tag to display history for multiple metrics. * ``slug_list`` -- A list of slugs to display * ``granularity`` -- the granularity: seconds, minutes, hourly, daily, weekly, monthly, yearly * ``since`` -- a datetime object or a string string matching one of the following...
[ "Template", "Tag", "to", "display", "history", "for", "multiple", "metrics", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L199-L236
google/dotty
efilter/api.py
apply
def apply(query, replacements=None, vars=None, allow_io=False, libs=("stdcore", "stdmath")): """Run 'query' on 'vars' and return the result(s). Arguments: query: A query object or string with the query. replacements: Built-time parameters to the query, either as dict or as...
python
def apply(query, replacements=None, vars=None, allow_io=False, libs=("stdcore", "stdmath")): """Run 'query' on 'vars' and return the result(s). Arguments: query: A query object or string with the query. replacements: Built-time parameters to the query, either as dict or as...
[ "def", "apply", "(", "query", ",", "replacements", "=", "None", ",", "vars", "=", "None", ",", "allow_io", "=", "False", ",", "libs", "=", "(", "\"stdcore\"", ",", "\"stdmath\"", ")", ")", ":", "if", "vars", "is", "None", ":", "vars", "=", "{", "}"...
Run 'query' on 'vars' and return the result(s). Arguments: query: A query object or string with the query. replacements: Built-time parameters to the query, either as dict or as an array (for positional interpolation). vars: The variables to be supplied to the query solver. ...
[ "Run", "query", "on", "vars", "and", "return", "the", "result", "(", "s", ")", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L35-L127
google/dotty
efilter/api.py
user_func
def user_func(func, arg_types=None, return_type=None): """Create an EFILTER-callable version of function 'func'. As a security precaution, EFILTER will not execute Python callables unless they implement the IApplicative protocol. There is a perfectly good implementation of this protocol in the standard...
python
def user_func(func, arg_types=None, return_type=None): """Create an EFILTER-callable version of function 'func'. As a security precaution, EFILTER will not execute Python callables unless they implement the IApplicative protocol. There is a perfectly good implementation of this protocol in the standard...
[ "def", "user_func", "(", "func", ",", "arg_types", "=", "None", ",", "return_type", "=", "None", ")", ":", "class", "UserFunction", "(", "std_core", ".", "TypedFunction", ")", ":", "name", "=", "func", ".", "__name__", "def", "__call__", "(", "self", ","...
Create an EFILTER-callable version of function 'func'. As a security precaution, EFILTER will not execute Python callables unless they implement the IApplicative protocol. There is a perfectly good implementation of this protocol in the standard library and user functions can inherit from it. This...
[ "Create", "an", "EFILTER", "-", "callable", "version", "of", "function", "func", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L148-L193
google/dotty
efilter/api.py
infer
def infer(query, replacements=None, root_type=None, libs=("stdcore", "stdmath")): """Determine the type of the query's output without actually running it. Arguments: query: A query object or string with the query. replacements: Built-time parameters to the query, either as dict or as ...
python
def infer(query, replacements=None, root_type=None, libs=("stdcore", "stdmath")): """Determine the type of the query's output without actually running it. Arguments: query: A query object or string with the query. replacements: Built-time parameters to the query, either as dict or as ...
[ "def", "infer", "(", "query", ",", "replacements", "=", "None", ",", "root_type", "=", "None", ",", "libs", "=", "(", "\"stdcore\"", ",", "\"stdmath\"", ")", ")", ":", "# Always make the scope stack start with stdcore.", "if", "root_type", ":", "type_scope", "="...
Determine the type of the query's output without actually running it. Arguments: query: A query object or string with the query. replacements: Built-time parameters to the query, either as dict or as an array (for positional interpolation). root_type: The types of variables to b...
[ "Determine", "the", "type", "of", "the", "query", "s", "output", "without", "actually", "running", "it", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L196-L247
google/dotty
efilter/api.py
search
def search(query, data, replacements=None): """Yield objects from 'data' that match the 'query'.""" query = q.Query(query, params=replacements) for entry in data: if solve.solve(query, entry).value: yield entry
python
def search(query, data, replacements=None): """Yield objects from 'data' that match the 'query'.""" query = q.Query(query, params=replacements) for entry in data: if solve.solve(query, entry).value: yield entry
[ "def", "search", "(", "query", ",", "data", ",", "replacements", "=", "None", ")", ":", "query", "=", "q", ".", "Query", "(", "query", ",", "params", "=", "replacements", ")", "for", "entry", "in", "data", ":", "if", "solve", ".", "solve", "(", "qu...
Yield objects from 'data' that match the 'query'.
[ "Yield", "objects", "from", "data", "that", "match", "the", "query", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L250-L255
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer.peek
def peek(self, steps=1): """Look ahead, doesn't affect current_token and next_token.""" try: tokens = iter(self) for _ in six.moves.range(steps): next(tokens) return next(tokens) except StopIteration: return None
python
def peek(self, steps=1): """Look ahead, doesn't affect current_token and next_token.""" try: tokens = iter(self) for _ in six.moves.range(steps): next(tokens) return next(tokens) except StopIteration: return None
[ "def", "peek", "(", "self", ",", "steps", "=", "1", ")", ":", "try", ":", "tokens", "=", "iter", "(", "self", ")", "for", "_", "in", "six", ".", "moves", ".", "range", "(", "steps", ")", ":", "next", "(", "tokens", ")", "return", "next", "(", ...
Look ahead, doesn't affect current_token and next_token.
[ "Look", "ahead", "doesn", "t", "affect", "current_token", "and", "next_token", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L226-L235
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer.skip
def skip(self, steps=1): """Skip ahead by 'steps' tokens.""" for _ in six.moves.range(steps): self.next_token()
python
def skip(self, steps=1): """Skip ahead by 'steps' tokens.""" for _ in six.moves.range(steps): self.next_token()
[ "def", "skip", "(", "self", ",", "steps", "=", "1", ")", ":", "for", "_", "in", "six", ".", "moves", ".", "range", "(", "steps", ")", ":", "self", ".", "next_token", "(", ")" ]
Skip ahead by 'steps' tokens.
[ "Skip", "ahead", "by", "steps", "tokens", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L237-L240
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer.next_token
def next_token(self): """Returns the next logical token, advancing the tokenizer.""" if self.lookahead: self.current_token = self.lookahead.popleft() return self.current_token self.current_token = self._parse_next_token() return self.current_token
python
def next_token(self): """Returns the next logical token, advancing the tokenizer.""" if self.lookahead: self.current_token = self.lookahead.popleft() return self.current_token self.current_token = self._parse_next_token() return self.current_token
[ "def", "next_token", "(", "self", ")", ":", "if", "self", ".", "lookahead", ":", "self", ".", "current_token", "=", "self", ".", "lookahead", ".", "popleft", "(", ")", "return", "self", ".", "current_token", "self", ".", "current_token", "=", "self", "."...
Returns the next logical token, advancing the tokenizer.
[ "Returns", "the", "next", "logical", "token", "advancing", "the", "tokenizer", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L242-L249
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer._parse_next_token
def _parse_next_token(self): """Will parse patterns until it gets to the next token or EOF.""" while self._position < self.limit: token = self._next_pattern() if token: return token return None
python
def _parse_next_token(self): """Will parse patterns until it gets to the next token or EOF.""" while self._position < self.limit: token = self._next_pattern() if token: return token return None
[ "def", "_parse_next_token", "(", "self", ")", ":", "while", "self", ".", "_position", "<", "self", ".", "limit", ":", "token", "=", "self", ".", "_next_pattern", "(", ")", "if", "token", ":", "return", "token", "return", "None" ]
Will parse patterns until it gets to the next token or EOF.
[ "Will", "parse", "patterns", "until", "it", "gets", "to", "the", "next", "token", "or", "EOF", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L259-L266
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer._next_pattern
def _next_pattern(self): """Parses the next pattern by matching each in turn.""" current_state = self.state_stack[-1] position = self._position for pattern in self.patterns: if current_state not in pattern.states: continue m = pattern.regex.match(...
python
def _next_pattern(self): """Parses the next pattern by matching each in turn.""" current_state = self.state_stack[-1] position = self._position for pattern in self.patterns: if current_state not in pattern.states: continue m = pattern.regex.match(...
[ "def", "_next_pattern", "(", "self", ")", ":", "current_state", "=", "self", ".", "state_stack", "[", "-", "1", "]", "position", "=", "self", ".", "_position", "for", "pattern", "in", "self", ".", "patterns", ":", "if", "current_state", "not", "in", "pat...
Parses the next pattern by matching each in turn.
[ "Parses", "the", "next", "pattern", "by", "matching", "each", "in", "turn", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L268-L305
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer._error
def _error(self, message, start, end=None): """Raise a nice error, with the token highlighted.""" raise errors.EfilterParseError( source=self.source, start=start, end=end, message=message)
python
def _error(self, message, start, end=None): """Raise a nice error, with the token highlighted.""" raise errors.EfilterParseError( source=self.source, start=start, end=end, message=message)
[ "def", "_error", "(", "self", ",", "message", ",", "start", ",", "end", "=", "None", ")", ":", "raise", "errors", ".", "EfilterParseError", "(", "source", "=", "self", ".", "source", ",", "start", "=", "start", ",", "end", "=", "end", ",", "message",...
Raise a nice error, with the token highlighted.
[ "Raise", "a", "nice", "error", "with", "the", "token", "highlighted", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L307-L310
google/dotty
efilter/parsers/common/tokenizer.py
LazyTokenizer.emit
def emit(self, string, match, pattern, **_): """Emits a token using the current pattern match and pattern label.""" return grammar.Token(name=pattern.name, value=string, start=match.start(), end=match.end())
python
def emit(self, string, match, pattern, **_): """Emits a token using the current pattern match and pattern label.""" return grammar.Token(name=pattern.name, value=string, start=match.start(), end=match.end())
[ "def", "emit", "(", "self", ",", "string", ",", "match", ",", "pattern", ",", "*", "*", "_", ")", ":", "return", "grammar", ".", "Token", "(", "name", "=", "pattern", ".", "name", ",", "value", "=", "string", ",", "start", "=", "match", ".", "sta...
Emits a token using the current pattern match and pattern label.
[ "Emits", "a", "token", "using", "the", "current", "pattern", "match", "and", "pattern", "label", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L314-L317
google/dotty
efilter/version.py
get_pkg_version
def get_pkg_version(): """Get version string by parsing PKG-INFO.""" try: with open("PKG-INFO", "r") as fp: rgx = re.compile(r"Version: (\d+)") for line in fp.readlines(): match = rgx.match(line) if match: return match.group(1) ...
python
def get_pkg_version(): """Get version string by parsing PKG-INFO.""" try: with open("PKG-INFO", "r") as fp: rgx = re.compile(r"Version: (\d+)") for line in fp.readlines(): match = rgx.match(line) if match: return match.group(1) ...
[ "def", "get_pkg_version", "(", ")", ":", "try", ":", "with", "open", "(", "\"PKG-INFO\"", ",", "\"r\"", ")", "as", "fp", ":", "rgx", "=", "re", ".", "compile", "(", "r\"Version: (\\d+)\"", ")", "for", "line", "in", "fp", ".", "readlines", "(", ")", "...
Get version string by parsing PKG-INFO.
[ "Get", "version", "string", "by", "parsing", "PKG", "-", "INFO", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/version.py#L78-L88
google/dotty
efilter/version.py
get_version
def get_version(dev_version=False): """Generates a version string. Arguments: dev_version: Generate a verbose development version from git commits. Examples: 1.1 1.1.dev43 # If 'dev_version' was passed. """ if dev_version: version = git_dev_version() if not ...
python
def get_version(dev_version=False): """Generates a version string. Arguments: dev_version: Generate a verbose development version from git commits. Examples: 1.1 1.1.dev43 # If 'dev_version' was passed. """ if dev_version: version = git_dev_version() if not ...
[ "def", "get_version", "(", "dev_version", "=", "False", ")", ":", "if", "dev_version", ":", "version", "=", "git_dev_version", "(", ")", "if", "not", "version", ":", "raise", "RuntimeError", "(", "\"Could not generate dev version from git.\"", ")", "return", "vers...
Generates a version string. Arguments: dev_version: Generate a verbose development version from git commits. Examples: 1.1 1.1.dev43 # If 'dev_version' was passed.
[ "Generates", "a", "version", "string", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/version.py#L100-L117
radical-cybertools/radical.entk
src/radical/entk/execman/base/task_manager.py
Base_TaskManager._heartbeat
def _heartbeat(self): """ **Purpose**: Method to be executed in the heartbeat thread. This method sends a 'request' to the heartbeat-req queue. It expects a 'response' message from the 'heartbeart-res' queue within 10 seconds. This message should contain the same correlation id. If no me...
python
def _heartbeat(self): """ **Purpose**: Method to be executed in the heartbeat thread. This method sends a 'request' to the heartbeat-req queue. It expects a 'response' message from the 'heartbeart-res' queue within 10 seconds. This message should contain the same correlation id. If no me...
[ "def", "_heartbeat", "(", "self", ")", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'heartbeat thread started'", ",", "uid", "=", "self", ".", "_uid", ")", "mq_connection", "=", "pika", ".", "BlockingConnection", "(", "pika", ".", "ConnectionP...
**Purpose**: Method to be executed in the heartbeat thread. This method sends a 'request' to the heartbeat-req queue. It expects a 'response' message from the 'heartbeart-res' queue within 10 seconds. This message should contain the same correlation id. If no message if received in 10 seconds, the tmgr ...
[ "**", "Purpose", "**", ":", "Method", "to", "be", "executed", "in", "the", "heartbeat", "thread", ".", "This", "method", "sends", "a", "request", "to", "the", "heartbeat", "-", "req", "queue", ".", "It", "expects", "a", "response", "message", "from", "th...
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L110-L179
radical-cybertools/radical.entk
src/radical/entk/execman/base/task_manager.py
Base_TaskManager._tmgr
def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue): """ **Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue and submits it to the RTS. At all state transititons, they are synced (blocking) with the AppManager ...
python
def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue): """ **Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue and submits it to the RTS. At all state transititons, they are synced (blocking) with the AppManager ...
[ "def", "_tmgr", "(", "self", ",", "uid", ",", "rmgr", ",", "logger", ",", "mq_hostname", ",", "port", ",", "pending_queue", ",", "completed_queue", ")", ":", "raise", "NotImplementedError", "(", "'_tmgr() method '", "+", "'not implemented in TaskManager for %s'", ...
**Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue and submits it to the RTS. At all state transititons, they are synced (blocking) with the AppManager in the master process. In addition, the tmgr also receives heartbeat 'request' msgs from the...
[ "**", "Purpose", "**", ":", "Method", "to", "be", "run", "by", "the", "tmgr", "process", ".", "This", "method", "receives", "a", "Task", "from", "the", "pending_queue", "and", "submits", "it", "to", "the", "RTS", ".", "At", "all", "state", "transititons"...
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L181-L196
radical-cybertools/radical.entk
src/radical/entk/execman/base/task_manager.py
Base_TaskManager.start_heartbeat
def start_heartbeat(self): """ **Purpose**: Method to start the heartbeat thread. The heartbeat function is not to be accessed directly. The function is started in a separate thread using this method. """ if not self._hb_thread: try: self._l...
python
def start_heartbeat(self): """ **Purpose**: Method to start the heartbeat thread. The heartbeat function is not to be accessed directly. The function is started in a separate thread using this method. """ if not self._hb_thread: try: self._l...
[ "def", "start_heartbeat", "(", "self", ")", ":", "if", "not", "self", ".", "_hb_thread", ":", "try", ":", "self", ".", "_logger", ".", "info", "(", "'Starting heartbeat thread'", ")", "self", ".", "_prof", ".", "prof", "(", "'creating heartbeat thread'", ","...
**Purpose**: Method to start the heartbeat thread. The heartbeat function is not to be accessed directly. The function is started in a separate thread using this method.
[ "**", "Purpose", "**", ":", "Method", "to", "start", "the", "heartbeat", "thread", ".", "The", "heartbeat", "function", "is", "not", "to", "be", "accessed", "directly", ".", "The", "function", "is", "started", "in", "a", "separate", "thread", "using", "thi...
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L202-L230
radical-cybertools/radical.entk
src/radical/entk/execman/base/task_manager.py
Base_TaskManager.terminate_heartbeat
def terminate_heartbeat(self): """ **Purpose**: Method to terminate the heartbeat thread. This method is blocking as it waits for the heartbeat thread to terminate (aka join). This is the last method that is executed from the TaskManager and hence closes the profiler. "...
python
def terminate_heartbeat(self): """ **Purpose**: Method to terminate the heartbeat thread. This method is blocking as it waits for the heartbeat thread to terminate (aka join). This is the last method that is executed from the TaskManager and hence closes the profiler. "...
[ "def", "terminate_heartbeat", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_hb_thread", ":", "self", ".", "_hb_terminate", ".", "set", "(", ")", "if", "self", ".", "check_heartbeat", "(", ")", ":", "self", ".", "_hb_thread", ".", "join", "(",...
**Purpose**: Method to terminate the heartbeat thread. This method is blocking as it waits for the heartbeat thread to terminate (aka join). This is the last method that is executed from the TaskManager and hence closes the profiler.
[ "**", "Purpose", "**", ":", "Method", "to", "terminate", "the", "heartbeat", "thread", ".", "This", "method", "is", "blocking", "as", "it", "waits", "for", "the", "heartbeat", "thread", "to", "terminate", "(", "aka", "join", ")", "." ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L232-L274
radical-cybertools/radical.entk
src/radical/entk/execman/base/task_manager.py
Base_TaskManager.terminate_manager
def terminate_manager(self): """ **Purpose**: Method to terminate the tmgr process. This method is blocking as it waits for the tmgr process to terminate (aka join). """ try: if self._tmgr_process: if not self._tmgr_terminate.is_set(): ...
python
def terminate_manager(self): """ **Purpose**: Method to terminate the tmgr process. This method is blocking as it waits for the tmgr process to terminate (aka join). """ try: if self._tmgr_process: if not self._tmgr_terminate.is_set(): ...
[ "def", "terminate_manager", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_tmgr_process", ":", "if", "not", "self", ".", "_tmgr_terminate", ".", "is_set", "(", ")", ":", "self", ".", "_tmgr_terminate", ".", "set", "(", ")", "if", "self", ".", ...
**Purpose**: Method to terminate the tmgr process. This method is blocking as it waits for the tmgr process to terminate (aka join).
[ "**", "Purpose", "**", ":", "Method", "to", "terminate", "the", "tmgr", "process", ".", "This", "method", "is", "blocking", "as", "it", "waits", "for", "the", "tmgr", "process", "to", "terminate", "(", "aka", "join", ")", "." ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L286-L309
google/dotty
efilter/ext/lazy_repetition.py
LazyRepetition.getvalues
def getvalues(self): """Yields all the values from 'generator_func' and type-checks. Yields: Whatever 'generator_func' yields. Raises: TypeError: if subsequent values are of a different type than first value. ValueError: if subsequent iterat...
python
def getvalues(self): """Yields all the values from 'generator_func' and type-checks. Yields: Whatever 'generator_func' yields. Raises: TypeError: if subsequent values are of a different type than first value. ValueError: if subsequent iterat...
[ "def", "getvalues", "(", "self", ")", ":", "idx", "=", "0", "generator", "=", "self", ".", "_generator_func", "(", ")", "first_value", "=", "next", "(", "generator", ")", "self", ".", "_value_type", "=", "type", "(", "first_value", ")", "yield", "first_v...
Yields all the values from 'generator_func' and type-checks. Yields: Whatever 'generator_func' yields. Raises: TypeError: if subsequent values are of a different type than first value. ValueError: if subsequent iteration returns a different number o...
[ "Yields", "all", "the", "values", "from", "generator_func", "and", "type", "-", "checks", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/ext/lazy_repetition.py#L66-L117
google/dotty
efilter/ext/lazy_repetition.py
LazyRepetition.value_eq
def value_eq(self, other): """Sorted comparison of values.""" self_sorted = ordered.ordered(self.getvalues()) other_sorted = ordered.ordered(repeated.getvalues(other)) return self_sorted == other_sorted
python
def value_eq(self, other): """Sorted comparison of values.""" self_sorted = ordered.ordered(self.getvalues()) other_sorted = ordered.ordered(repeated.getvalues(other)) return self_sorted == other_sorted
[ "def", "value_eq", "(", "self", ",", "other", ")", ":", "self_sorted", "=", "ordered", ".", "ordered", "(", "self", ".", "getvalues", "(", ")", ")", "other_sorted", "=", "ordered", ".", "ordered", "(", "repeated", ".", "getvalues", "(", "other", ")", "...
Sorted comparison of values.
[ "Sorted", "comparison", "of", "values", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/ext/lazy_repetition.py#L127-L131
google/dotty
efilter/dispatch.py
call_audit
def call_audit(func): """Print a detailed audit of all calls to this function.""" def audited_func(*args, **kwargs): import traceback stack = traceback.extract_stack() r = func(*args, **kwargs) func_name = func.__name__ print("@depth %d, trace %s -> %s(*%r, **%r) => %r" ...
python
def call_audit(func): """Print a detailed audit of all calls to this function.""" def audited_func(*args, **kwargs): import traceback stack = traceback.extract_stack() r = func(*args, **kwargs) func_name = func.__name__ print("@depth %d, trace %s -> %s(*%r, **%r) => %r" ...
[ "def", "call_audit", "(", "func", ")", ":", "def", "audited_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "traceback", "stack", "=", "traceback", ".", "extract_stack", "(", ")", "r", "=", "func", "(", "*", "args", ",", "*", ...
Print a detailed audit of all calls to this function.
[ "Print", "a", "detailed", "audit", "of", "all", "calls", "to", "this", "function", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L51-L68
google/dotty
efilter/dispatch.py
_class_dispatch
def _class_dispatch(args, kwargs): """See 'class_multimethod'.""" _ = kwargs if not args: raise ValueError( "Multimethods must be passed at least one positional arg.") if not isinstance(args[0], type): raise TypeError( "class_multimethod must be called with a typ...
python
def _class_dispatch(args, kwargs): """See 'class_multimethod'.""" _ = kwargs if not args: raise ValueError( "Multimethods must be passed at least one positional arg.") if not isinstance(args[0], type): raise TypeError( "class_multimethod must be called with a typ...
[ "def", "_class_dispatch", "(", "args", ",", "kwargs", ")", ":", "_", "=", "kwargs", "if", "not", "args", ":", "raise", "ValueError", "(", "\"Multimethods must be passed at least one positional arg.\"", ")", "if", "not", "isinstance", "(", "args", "[", "0", "]", ...
See 'class_multimethod'.
[ "See", "class_multimethod", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L71-L82
google/dotty
efilter/dispatch.py
multimethod.prefer_type
def prefer_type(self, prefer, over): """Prefer one type over another type, all else being equivalent. With abstract base classes (Python's abc module) it is possible for a type to appear to be a subclass of another type without the supertype appearing in the subtype's MRO. As such, the ...
python
def prefer_type(self, prefer, over): """Prefer one type over another type, all else being equivalent. With abstract base classes (Python's abc module) it is possible for a type to appear to be a subclass of another type without the supertype appearing in the subtype's MRO. As such, the ...
[ "def", "prefer_type", "(", "self", ",", "prefer", ",", "over", ")", ":", "self", ".", "_write_lock", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "_preferred", "(", "preferred", "=", "over", ",", "over", "=", "prefer", ")", ":", "raise", ...
Prefer one type over another type, all else being equivalent. With abstract base classes (Python's abc module) it is possible for a type to appear to be a subclass of another type without the supertype appearing in the subtype's MRO. As such, the supertype has no order with respect to o...
[ "Prefer", "one", "type", "over", "another", "type", "all", "else", "being", "equivalent", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L225-L252
google/dotty
efilter/dispatch.py
multimethod._find_and_cache_best_function
def _find_and_cache_best_function(self, dispatch_type): """Finds the best implementation of this function given a type. This function caches the result, and uses locking for thread safety. Returns: Implementing function, in below order of preference: 1. Explicitly regis...
python
def _find_and_cache_best_function(self, dispatch_type): """Finds the best implementation of this function given a type. This function caches the result, and uses locking for thread safety. Returns: Implementing function, in below order of preference: 1. Explicitly regis...
[ "def", "_find_and_cache_best_function", "(", "self", ",", "dispatch_type", ")", ":", "result", "=", "self", ".", "_dispatch_table", ".", "get", "(", "dispatch_type", ")", "if", "result", ":", "return", "result", "# The outer try ensures the lock is always released.", ...
Finds the best implementation of this function given a type. This function caches the result, and uses locking for thread safety. Returns: Implementing function, in below order of preference: 1. Explicitly registered implementations (through multimethod.implement...
[ "Finds", "the", "best", "implementation", "of", "this", "function", "given", "a", "type", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L254-L335
google/dotty
efilter/dispatch.py
multimethod.__get_types
def __get_types(for_type=None, for_types=None): """Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate. """ if for_type: if for_types: raise ValueError("Cannot pass both for_type and for...
python
def __get_types(for_type=None, for_types=None): """Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate. """ if for_type: if for_types: raise ValueError("Cannot pass both for_type and for...
[ "def", "__get_types", "(", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "if", "for_type", ":", "if", "for_types", ":", "raise", "ValueError", "(", "\"Cannot pass both for_type and for_types.\"", ")", "for_types", "=", "(", "for_type", ",", ...
Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate.
[ "Parse", "the", "arguments", "and", "return", "a", "tuple", "of", "types", "to", "implement", "for", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L338-L355
google/dotty
efilter/dispatch.py
multimethod.implementation
def implementation(self, for_type=None, for_types=None): """Return a decorator that will register the implementation. Example: @multimethod def add(x, y): pass @add.implementation(for_type=int) def add(x, y): return x + y ...
python
def implementation(self, for_type=None, for_types=None): """Return a decorator that will register the implementation. Example: @multimethod def add(x, y): pass @add.implementation(for_type=int) def add(x, y): return x + y ...
[ "def", "implementation", "(", "self", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for_types", "=", "self", ".", "__get_types", "(", "for_type", ",", "for_types", ")", "def", "_decorator", "(", "implementation", ")", ":", "self",...
Return a decorator that will register the implementation. Example: @multimethod def add(x, y): pass @add.implementation(for_type=int) def add(x, y): return x + y @add.implementation(for_type=SomeType) def ...
[ "Return", "a", "decorator", "that", "will", "register", "the", "implementation", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L357-L379
google/dotty
efilter/dispatch.py
multimethod.implement
def implement(self, implementation, for_type=None, for_types=None): """Registers an implementing function for for_type. Arguments: implementation: Callable implementation for this type. for_type: The type this implementation applies to. for_types: Same as for_type, b...
python
def implement(self, implementation, for_type=None, for_types=None): """Registers an implementing function for for_type. Arguments: implementation: Callable implementation for this type. for_type: The type this implementation applies to. for_types: Same as for_type, b...
[ "def", "implement", "(", "self", ",", "implementation", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "unbound_implementation", "=", "self", ".", "__get_unbound_function", "(", "implementation", ")", "for_types", "=", "self", ".", "__g...
Registers an implementing function for for_type. Arguments: implementation: Callable implementation for this type. for_type: The type this implementation applies to. for_types: Same as for_type, but takes a tuple of types. for_type and for_types cannot both be p...
[ "Registers", "an", "implementing", "function", "for", "for_type", "." ]
train
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L388-L409
bradmontgomery/django-redis-metrics
redis_metrics/templatetags/redis_metrics_filters.py
to_int_list
def to_int_list(values): """Converts the given list of vlues into a list of integers. If the integer conversion fails (e.g. non-numeric strings or None-values), this filter will include a 0 instead.""" results = [] for v in values: try: results.append(int(v)) except (Type...
python
def to_int_list(values): """Converts the given list of vlues into a list of integers. If the integer conversion fails (e.g. non-numeric strings or None-values), this filter will include a 0 instead.""" results = [] for v in values: try: results.append(int(v)) except (Type...
[ "def", "to_int_list", "(", "values", ")", ":", "results", "=", "[", "]", "for", "v", "in", "values", ":", "try", ":", "results", ".", "append", "(", "int", "(", "v", ")", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "results", ".",...
Converts the given list of vlues into a list of integers. If the integer conversion fails (e.g. non-numeric strings or None-values), this filter will include a 0 instead.
[ "Converts", "the", "given", "list", "of", "vlues", "into", "a", "list", "of", "integers", ".", "If", "the", "integer", "conversion", "fails", "(", "e", ".", "g", ".", "non", "-", "numeric", "strings", "or", "None", "-", "values", ")", "this", "filter",...
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metrics_filters.py#L15-L25
radical-cybertools/radical.entk
src/radical/entk/execman/base/resource_manager.py
Base_ResourceManager._validate_resource_desc
def _validate_resource_desc(self): """ **Purpose**: Validate the resource description provided to the ResourceManager """ self._prof.prof('validating rdesc', uid=self._uid) self._logger.debug('Validating resource description') expected_keys = ['resource', ...
python
def _validate_resource_desc(self): """ **Purpose**: Validate the resource description provided to the ResourceManager """ self._prof.prof('validating rdesc', uid=self._uid) self._logger.debug('Validating resource description') expected_keys = ['resource', ...
[ "def", "_validate_resource_desc", "(", "self", ")", ":", "self", ".", "_prof", ".", "prof", "(", "'validating rdesc'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_logger", ".", "debug", "(", "'Validating resource description'", ")", "expected_key...
**Purpose**: Validate the resource description provided to the ResourceManager
[ "**", "Purpose", "**", ":", "Validate", "the", "resource", "description", "provided", "to", "the", "ResourceManager" ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/resource_manager.py#L147-L196
radical-cybertools/radical.entk
src/radical/entk/execman/base/resource_manager.py
Base_ResourceManager._populate
def _populate(self): """ **Purpose**: Populate the ResourceManager class with the validated resource description """ if self._validated: self._prof.prof('populating rmgr', uid=self._uid) self._logger.debug('Populating resource manager ...
python
def _populate(self): """ **Purpose**: Populate the ResourceManager class with the validated resource description """ if self._validated: self._prof.prof('populating rmgr', uid=self._uid) self._logger.debug('Populating resource manager ...
[ "def", "_populate", "(", "self", ")", ":", "if", "self", ".", "_validated", ":", "self", ".", "_prof", ".", "prof", "(", "'populating rmgr'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_logger", ".", "debug", "(", "'Populating resource mana...
**Purpose**: Populate the ResourceManager class with the validated resource description
[ "**", "Purpose", "**", ":", "Populate", "the", "ResourceManager", "class", "with", "the", "validated", "resource", "description" ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/resource_manager.py#L198-L221
bradmontgomery/django-redis-metrics
redis_metrics/views.py
GaugesView.get_context_data
def get_context_data(self, **kwargs): """Includes the Gauge slugs and data in the context.""" data = super(GaugesView, self).get_context_data(**kwargs) data.update({'gauges': get_r().gauge_slugs()}) return data
python
def get_context_data(self, **kwargs): """Includes the Gauge slugs and data in the context.""" data = super(GaugesView, self).get_context_data(**kwargs) data.update({'gauges': get_r().gauge_slugs()}) return data
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "super", "(", "GaugesView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "data", ".", "update", "(", "{", "'gauges'", ":", "get_r", "(...
Includes the Gauge slugs and data in the context.
[ "Includes", "the", "Gauge", "slugs", "and", "data", "in", "the", "context", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L51-L55
bradmontgomery/django-redis-metrics
redis_metrics/views.py
MetricsListView.get_context_data
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" data = super(MetricsListView, self).get_context_data(**kwargs) # Metrics organized by category, like so: # { <category_name>: [ <slug1>, <slug2>, ... ]} data.update({'metrics': get_r().metric_...
python
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" data = super(MetricsListView, self).get_context_data(**kwargs) # Metrics organized by category, like so: # { <category_name>: [ <slug1>, <slug2>, ... ]} data.update({'metrics': get_r().metric_...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "super", "(", "MetricsListView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "# Metrics organized by category, like so:", "# { <category_name>: [ <...
Includes the metrics slugs in the context.
[ "Includes", "the", "metrics", "slugs", "in", "the", "context", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L61-L68
bradmontgomery/django-redis-metrics
redis_metrics/views.py
MetricDetailView.get_context_data
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" data = super(MetricDetailView, self).get_context_data(**kwargs) data['slug'] = kwargs['slug'] data['granularities'] = list(get_r()._granularities()) return data
python
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" data = super(MetricDetailView, self).get_context_data(**kwargs) data['slug'] = kwargs['slug'] data['granularities'] = list(get_r()._granularities()) return data
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "super", "(", "MetricDetailView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "data", "[", "'slug'", "]", "=", "kwargs", "[", "'slug'",...
Includes the metrics slugs in the context.
[ "Includes", "the", "metrics", "slugs", "in", "the", "context", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L74-L79
bradmontgomery/django-redis-metrics
redis_metrics/views.py
MetricHistoryView.get_context_data
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" data = super(MetricHistoryView, self).get_context_data(**kwargs) # Accept GET query params for ``since`` since = self.request.GET.get('since', None) if since and len(since) == 10: # yyyy-mm-d...
python
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" data = super(MetricHistoryView, self).get_context_data(**kwargs) # Accept GET query params for ``since`` since = self.request.GET.get('since', None) if since and len(since) == 10: # yyyy-mm-d...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "super", "(", "MetricHistoryView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "# Accept GET query params for ``since``", "since", "=", "self",...
Includes the metrics slugs in the context.
[ "Includes", "the", "metrics", "slugs", "in", "the", "context", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L85-L102
bradmontgomery/django-redis-metrics
redis_metrics/views.py
AggregateFormView.get_success_url
def get_success_url(self): """Reverses the ``redis_metric_aggregate_detail`` URL using ``self.metric_slugs`` as an argument.""" slugs = '+'.join(self.metric_slugs) url = reverse('redis_metric_aggregate_detail', args=[slugs]) # Django 1.6 quotes reversed URLs, which changes + into...
python
def get_success_url(self): """Reverses the ``redis_metric_aggregate_detail`` URL using ``self.metric_slugs`` as an argument.""" slugs = '+'.join(self.metric_slugs) url = reverse('redis_metric_aggregate_detail', args=[slugs]) # Django 1.6 quotes reversed URLs, which changes + into...
[ "def", "get_success_url", "(", "self", ")", ":", "slugs", "=", "'+'", ".", "join", "(", "self", ".", "metric_slugs", ")", "url", "=", "reverse", "(", "'redis_metric_aggregate_detail'", ",", "args", "=", "[", "slugs", "]", ")", "# Django 1.6 quotes reversed URL...
Reverses the ``redis_metric_aggregate_detail`` URL using ``self.metric_slugs`` as an argument.
[ "Reverses", "the", "redis_metric_aggregate_detail", "URL", "using", "self", ".", "metric_slugs", "as", "an", "argument", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L111-L119
bradmontgomery/django-redis-metrics
redis_metrics/views.py
AggregateFormView.form_valid
def form_valid(self, form): """Pull the metrics from the submitted form, and store them as a list of strings in ``self.metric_slugs``. """ self.metric_slugs = [k.strip() for k in form.cleaned_data['metrics']] return super(AggregateFormView, self).form_valid(form)
python
def form_valid(self, form): """Pull the metrics from the submitted form, and store them as a list of strings in ``self.metric_slugs``. """ self.metric_slugs = [k.strip() for k in form.cleaned_data['metrics']] return super(AggregateFormView, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "self", ".", "metric_slugs", "=", "[", "k", ".", "strip", "(", ")", "for", "k", "in", "form", ".", "cleaned_data", "[", "'metrics'", "]", "]", "return", "super", "(", "AggregateFormView", ",", ...
Pull the metrics from the submitted form, and store them as a list of strings in ``self.metric_slugs``.
[ "Pull", "the", "metrics", "from", "the", "submitted", "form", "and", "store", "them", "as", "a", "list", "of", "strings", "in", "self", ".", "metric_slugs", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L121-L126
bradmontgomery/django-redis-metrics
redis_metrics/views.py
AggregateDetailView.get_context_data
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" r = get_r() category = kwargs.pop('category', None) data = super(AggregateDetailView, self).get_context_data(**kwargs) if category: slug_set = r._category_slugs(category) ...
python
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" r = get_r() category = kwargs.pop('category', None) data = super(AggregateDetailView, self).get_context_data(**kwargs) if category: slug_set = r._category_slugs(category) ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "r", "=", "get_r", "(", ")", "category", "=", "kwargs", ".", "pop", "(", "'category'", ",", "None", ")", "data", "=", "super", "(", "AggregateDetailView", ",", "self", ")", "....
Includes the metrics slugs in the context.
[ "Includes", "the", "metrics", "slugs", "in", "the", "context", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L132-L146
bradmontgomery/django-redis-metrics
redis_metrics/views.py
AggregateHistoryView.get_context_data
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" r = get_r() data = super(AggregateHistoryView, self).get_context_data(**kwargs) slug_set = set(kwargs['slugs'].split('+')) granularity = kwargs.get('granularity', 'daily') # Accept GET...
python
def get_context_data(self, **kwargs): """Includes the metrics slugs in the context.""" r = get_r() data = super(AggregateHistoryView, self).get_context_data(**kwargs) slug_set = set(kwargs['slugs'].split('+')) granularity = kwargs.get('granularity', 'daily') # Accept GET...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "r", "=", "get_r", "(", ")", "data", "=", "super", "(", "AggregateHistoryView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "slug_set", "=", "set", ...
Includes the metrics slugs in the context.
[ "Includes", "the", "metrics", "slugs", "in", "the", "context", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L152-L172
bradmontgomery/django-redis-metrics
redis_metrics/views.py
CategoryFormView.get
def get(self, *args, **kwargs): """See if this view was called with a specified category.""" self.initial = {"category_name": kwargs.get('category_name', None)} return super(CategoryFormView, self).get(*args, **kwargs)
python
def get(self, *args, **kwargs): """See if this view was called with a specified category.""" self.initial = {"category_name": kwargs.get('category_name', None)} return super(CategoryFormView, self).get(*args, **kwargs)
[ "def", "get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "initial", "=", "{", "\"category_name\"", ":", "kwargs", ".", "get", "(", "'category_name'", ",", "None", ")", "}", "return", "super", "(", "CategoryFormView",...
See if this view was called with a specified category.
[ "See", "if", "this", "view", "was", "called", "with", "a", "specified", "category", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L180-L183
bradmontgomery/django-redis-metrics
redis_metrics/views.py
CategoryFormView.form_valid
def form_valid(self, form): """Get the category name/metric slugs from the form, and update the category so contains the given metrics.""" form.categorize_metrics() return super(CategoryFormView, self).form_valid(form)
python
def form_valid(self, form): """Get the category name/metric slugs from the form, and update the category so contains the given metrics.""" form.categorize_metrics() return super(CategoryFormView, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "form", ".", "categorize_metrics", "(", ")", "return", "super", "(", "CategoryFormView", ",", "self", ")", ".", "form_valid", "(", "form", ")" ]
Get the category name/metric slugs from the form, and update the category so contains the given metrics.
[ "Get", "the", "category", "name", "/", "metric", "slugs", "from", "the", "form", "and", "update", "the", "category", "so", "contains", "the", "given", "metrics", "." ]
train
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L193-L197
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline.rerun
def rerun(self): """ Rerun sets the state of the Pipeline to scheduling so that the Pipeline can be checked for new stages """ self._state = states.SCHEDULING self._completed_flag = threading.Event() print 'Pipeline %s in %s state'%(self._uid, self._state)
python
def rerun(self): """ Rerun sets the state of the Pipeline to scheduling so that the Pipeline can be checked for new stages """ self._state = states.SCHEDULING self._completed_flag = threading.Event() print 'Pipeline %s in %s state'%(self._uid, self._state)
[ "def", "rerun", "(", "self", ")", ":", "self", ".", "_state", "=", "states", ".", "SCHEDULING", "self", ".", "_completed_flag", "=", "threading", ".", "Event", "(", ")", "print", "'Pipeline %s in %s state'", "%", "(", "self", ".", "_uid", ",", "self", "....
Rerun sets the state of the Pipeline to scheduling so that the Pipeline can be checked for new stages
[ "Rerun", "sets", "the", "state", "of", "the", "Pipeline", "to", "scheduling", "so", "that", "the", "Pipeline", "can", "be", "checked", "for", "new", "stages" ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L204-L213
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline.to_dict
def to_dict(self): """ Convert current Pipeline (i.e. its attributes) into a dictionary :return: python dictionary """ pipeline_desc_as_dict = { 'uid': self._uid, 'name': self._name, 'state': self._state, 'state_history': self._s...
python
def to_dict(self): """ Convert current Pipeline (i.e. its attributes) into a dictionary :return: python dictionary """ pipeline_desc_as_dict = { 'uid': self._uid, 'name': self._name, 'state': self._state, 'state_history': self._s...
[ "def", "to_dict", "(", "self", ")", ":", "pipeline_desc_as_dict", "=", "{", "'uid'", ":", "self", ".", "_uid", ",", "'name'", ":", "self", ".", "_name", ",", "'state'", ":", "self", ".", "_state", ",", "'state_history'", ":", "self", ".", "_state_history...
Convert current Pipeline (i.e. its attributes) into a dictionary :return: python dictionary
[ "Convert", "current", "Pipeline", "(", "i", ".", "e", ".", "its", "attributes", ")", "into", "a", "dictionary" ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L215-L231
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline.from_dict
def from_dict(self, d): """ Create a Pipeline from a dictionary. The change is in inplace. :argument: python dictionary :return: None """ if 'uid' in d: if d['uid']: self._uid = d['uid'] if 'name' in d: if d['name']: ...
python
def from_dict(self, d): """ Create a Pipeline from a dictionary. The change is in inplace. :argument: python dictionary :return: None """ if 'uid' in d: if d['uid']: self._uid = d['uid'] if 'name' in d: if d['name']: ...
[ "def", "from_dict", "(", "self", ",", "d", ")", ":", "if", "'uid'", "in", "d", ":", "if", "d", "[", "'uid'", "]", ":", "self", ".", "_uid", "=", "d", "[", "'uid'", "]", "if", "'name'", "in", "d", ":", "if", "d", "[", "'name'", "]", ":", "se...
Create a Pipeline from a dictionary. The change is in inplace. :argument: python dictionary :return: None
[ "Create", "a", "Pipeline", "from", "a", "dictionary", ".", "The", "change", "is", "in", "inplace", "." ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L233-L278
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline._increment_stage
def _increment_stage(self): """ Purpose: Increment stage pointer. Also check if Pipeline has completed. """ try: if self._cur_stage < self._stage_count: self._cur_stage += 1 else: self._completed_flag.set() except Excepti...
python
def _increment_stage(self): """ Purpose: Increment stage pointer. Also check if Pipeline has completed. """ try: if self._cur_stage < self._stage_count: self._cur_stage += 1 else: self._completed_flag.set() except Excepti...
[ "def", "_increment_stage", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_cur_stage", "<", "self", ".", "_stage_count", ":", "self", ".", "_cur_stage", "+=", "1", "else", ":", "self", ".", "_completed_flag", ".", "set", "(", ")", "except", "Ex...
Purpose: Increment stage pointer. Also check if Pipeline has completed.
[ "Purpose", ":", "Increment", "stage", "pointer", ".", "Also", "check", "if", "Pipeline", "has", "completed", "." ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L300-L313
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline._decrement_stage
def _decrement_stage(self): """ Purpose: Decrement stage pointer. Reset completed flag. """ try: if self._cur_stage > 0: self._cur_stage -= 1 self._completed_flag = threading.Event() # reset except Exception, ex: raise E...
python
def _decrement_stage(self): """ Purpose: Decrement stage pointer. Reset completed flag. """ try: if self._cur_stage > 0: self._cur_stage -= 1 self._completed_flag = threading.Event() # reset except Exception, ex: raise E...
[ "def", "_decrement_stage", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_cur_stage", ">", "0", ":", "self", ".", "_cur_stage", "-=", "1", "self", ".", "_completed_flag", "=", "threading", ".", "Event", "(", ")", "# reset", "except", "Exception"...
Purpose: Decrement stage pointer. Reset completed flag.
[ "Purpose", ":", "Decrement", "stage", "pointer", ".", "Reset", "completed", "flag", "." ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L315-L327
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline._validate_entities
def _validate_entities(self, stages): """ Purpose: Validate whether the argument 'stages' is of list of Stage objects :argument: list of Stage objects """ if not stages: raise TypeError(expected_type=Stage, actual_type=type(stages)) if not isinstance(stages,...
python
def _validate_entities(self, stages): """ Purpose: Validate whether the argument 'stages' is of list of Stage objects :argument: list of Stage objects """ if not stages: raise TypeError(expected_type=Stage, actual_type=type(stages)) if not isinstance(stages,...
[ "def", "_validate_entities", "(", "self", ",", "stages", ")", ":", "if", "not", "stages", ":", "raise", "TypeError", "(", "expected_type", "=", "Stage", ",", "actual_type", "=", "type", "(", "stages", ")", ")", "if", "not", "isinstance", "(", "stages", "...
Purpose: Validate whether the argument 'stages' is of list of Stage objects :argument: list of Stage objects
[ "Purpose", ":", "Validate", "whether", "the", "argument", "stages", "is", "of", "list", "of", "Stage", "objects" ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L330-L346