repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
cfobel/si-prefix
si_prefix/__init__.py
si_format
def si_format(value, precision=1, format_str=u'{value} {prefix}', exp_format_str=u'{value}e{expof10}'): ''' Format value to string with SI prefix, using the specified precision. Parameters ---------- value : int, float Input value. precision : int Number of digits ...
python
def si_format(value, precision=1, format_str=u'{value} {prefix}', exp_format_str=u'{value}e{expof10}'): ''' Format value to string with SI prefix, using the specified precision. Parameters ---------- value : int, float Input value. precision : int Number of digits ...
[ "def", "si_format", "(", "value", ",", "precision", "=", "1", ",", "format_str", "=", "u'{value} {prefix}'", ",", "exp_format_str", "=", "u'{value}e{expof10}'", ")", ":", "svalue", ",", "expof10", "=", "split", "(", "value", ",", "precision", ")", "value_forma...
Format value to string with SI prefix, using the specified precision. Parameters ---------- value : int, float Input value. precision : int Number of digits after decimal place to include. format_str : str or unicode Format string where ``{prefix}`` and ``{value}`` represent...
[ "Format", "value", "to", "string", "with", "SI", "prefix", "using", "the", "specified", "precision", "." ]
274fdf47f65d87d0b7a2e3c80f267db63d042c59
https://github.com/cfobel/si-prefix/blob/274fdf47f65d87d0b7a2e3c80f267db63d042c59/si_prefix/__init__.py#L128-L221
train
cfobel/si-prefix
si_prefix/__init__.py
si_parse
def si_parse(value): ''' Parse a value expressed using SI prefix units to a floating point number. Parameters ---------- value : str or unicode Value expressed using SI prefix units (as returned by :func:`si_format` function). .. versionchanged:: 1.0 Use unicode string...
python
def si_parse(value): ''' Parse a value expressed using SI prefix units to a floating point number. Parameters ---------- value : str or unicode Value expressed using SI prefix units (as returned by :func:`si_format` function). .. versionchanged:: 1.0 Use unicode string...
[ "def", "si_parse", "(", "value", ")", ":", "CRE_10E_NUMBER", "=", "re", ".", "compile", "(", "r'^\\s*(?P<integer>[\\+\\-]?\\d+)?'", "r'(?P<fraction>.\\d+)?\\s*([eE]\\s*'", "r'(?P<expof10>[\\+\\-]?\\d+))?$'", ")", "CRE_SI_NUMBER", "=", "re", ".", "compile", "(", "r'^\\s*(?...
Parse a value expressed using SI prefix units to a floating point number. Parameters ---------- value : str or unicode Value expressed using SI prefix units (as returned by :func:`si_format` function). .. versionchanged:: 1.0 Use unicode string for SI unit to support micro (i....
[ "Parse", "a", "value", "expressed", "using", "SI", "prefix", "units", "to", "a", "floating", "point", "number", "." ]
274fdf47f65d87d0b7a2e3c80f267db63d042c59
https://github.com/cfobel/si-prefix/blob/274fdf47f65d87d0b7a2e3c80f267db63d042c59/si_prefix/__init__.py#L224-L263
train
tuomas2/automate
src/automate/extensions/rpc/rpc.py
ExternalApi.set_status
def set_status(self, name, status): """ Set sensor ``name`` status to ``status``. """ getattr(self.system, name).status = status return True
python
def set_status(self, name, status): """ Set sensor ``name`` status to ``status``. """ getattr(self.system, name).status = status return True
[ "def", "set_status", "(", "self", ",", "name", ",", "status", ")", ":", "getattr", "(", "self", ".", "system", ",", "name", ")", ".", "status", "=", "status", "return", "True" ]
Set sensor ``name`` status to ``status``.
[ "Set", "sensor", "name", "status", "to", "status", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/rpc/rpc.py#L31-L36
train
tuomas2/automate
src/automate/extensions/rpc/rpc.py
ExternalApi.toggle_object_status
def toggle_object_status(self, objname): """ Toggle boolean-valued sensor status between ``True`` and ``False``. """ o = getattr(self.system, objname) o.status = not o.status self.system.flush() return o.status
python
def toggle_object_status(self, objname): """ Toggle boolean-valued sensor status between ``True`` and ``False``. """ o = getattr(self.system, objname) o.status = not o.status self.system.flush() return o.status
[ "def", "toggle_object_status", "(", "self", ",", "objname", ")", ":", "o", "=", "getattr", "(", "self", ".", "system", ",", "objname", ")", "o", ".", "status", "=", "not", "o", ".", "status", "self", ".", "system", ".", "flush", "(", ")", "return", ...
Toggle boolean-valued sensor status between ``True`` and ``False``.
[ "Toggle", "boolean", "-", "valued", "sensor", "status", "between", "True", "and", "False", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/rpc/rpc.py#L52-L59
train
tuomas2/automate
src/automate/extensions/rpc/rpc.py
ExternalApi.log
def log(self): """ Return recent log entries as a string. """ logserv = self.system.request_service('LogStoreService') return logserv.lastlog(html=False)
python
def log(self): """ Return recent log entries as a string. """ logserv = self.system.request_service('LogStoreService') return logserv.lastlog(html=False)
[ "def", "log", "(", "self", ")", ":", "logserv", "=", "self", ".", "system", ".", "request_service", "(", "'LogStoreService'", ")", "return", "logserv", ".", "lastlog", "(", "html", "=", "False", ")" ]
Return recent log entries as a string.
[ "Return", "recent", "log", "entries", "as", "a", "string", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/rpc/rpc.py#L93-L98
train
tuomas2/automate
src/automate/system.py
System.load_or_create
def load_or_create(cls, filename=None, no_input=False, create_new=False, **kwargs): """ Load system from a dump, if dump file exists, or create a new system if it does not exist. """ parser = argparse.ArgumentParser() parser.add_argument('--no_input', action='store_true') ...
python
def load_or_create(cls, filename=None, no_input=False, create_new=False, **kwargs): """ Load system from a dump, if dump file exists, or create a new system if it does not exist. """ parser = argparse.ArgumentParser() parser.add_argument('--no_input', action='store_true') ...
[ "def", "load_or_create", "(", "cls", ",", "filename", "=", "None", ",", "no_input", "=", "False", ",", "create_new", "=", "False", ",", "**", "kwargs", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "...
Load system from a dump, if dump file exists, or create a new system if it does not exist.
[ "Load", "system", "from", "a", "dump", "if", "dump", "file", "exists", "or", "create", "a", "new", "system", "if", "it", "does", "not", "exist", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L200-L261
train
tuomas2/automate
src/automate/system.py
System.cmd_namespace
def cmd_namespace(self): """ A read-only property that gives the namespace of the system for evaluating commands. """ import automate ns = dict(list(automate.__dict__.items()) + list(self.namespace.items())) return ns
python
def cmd_namespace(self): """ A read-only property that gives the namespace of the system for evaluating commands. """ import automate ns = dict(list(automate.__dict__.items()) + list(self.namespace.items())) return ns
[ "def", "cmd_namespace", "(", "self", ")", ":", "import", "automate", "ns", "=", "dict", "(", "list", "(", "automate", ".", "__dict__", ".", "items", "(", ")", ")", "+", "list", "(", "self", ".", "namespace", ".", "items", "(", ")", ")", ")", "retur...
A read-only property that gives the namespace of the system for evaluating commands.
[ "A", "read", "-", "only", "property", "that", "gives", "the", "namespace", "of", "the", "system", "for", "evaluating", "commands", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L287-L293
train
tuomas2/automate
src/automate/system.py
System.services_by_name
def services_by_name(self): """ A property that gives a dictionary that contains services as values and their names as keys. """ srvs = defaultdict(list) for i in self.services: srvs[i.__class__.__name__].append(i) return srvs
python
def services_by_name(self): """ A property that gives a dictionary that contains services as values and their names as keys. """ srvs = defaultdict(list) for i in self.services: srvs[i.__class__.__name__].append(i) return srvs
[ "def", "services_by_name", "(", "self", ")", ":", "srvs", "=", "defaultdict", "(", "list", ")", "for", "i", "in", "self", ".", "services", ":", "srvs", "[", "i", ".", "__class__", ".", "__name__", "]", ".", "append", "(", "i", ")", "return", "srvs" ]
A property that gives a dictionary that contains services as values and their names as keys.
[ "A", "property", "that", "gives", "a", "dictionary", "that", "contains", "services", "as", "values", "and", "their", "names", "as", "keys", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L323-L330
train
tuomas2/automate
src/automate/system.py
System.name_to_system_object
def name_to_system_object(self, name): """ Give SystemObject instance corresponding to the name """ if isinstance(name, str): if self.allow_name_referencing: name = name else: raise NameError('System.allow_name_referencing is se...
python
def name_to_system_object(self, name): """ Give SystemObject instance corresponding to the name """ if isinstance(name, str): if self.allow_name_referencing: name = name else: raise NameError('System.allow_name_referencing is se...
[ "def", "name_to_system_object", "(", "self", ",", "name", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "if", "self", ".", "allow_name_referencing", ":", "name", "=", "name", "else", ":", "raise", "NameError", "(", "'System.allow_name_refe...
Give SystemObject instance corresponding to the name
[ "Give", "SystemObject", "instance", "corresponding", "to", "the", "name" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L345-L356
train
tuomas2/automate
src/automate/system.py
System.register_service_functions
def register_service_functions(self, *funcs): """ Register function in the system namespace. Called by Services. """ for func in funcs: self.namespace[func.__name__] = func
python
def register_service_functions(self, *funcs): """ Register function in the system namespace. Called by Services. """ for func in funcs: self.namespace[func.__name__] = func
[ "def", "register_service_functions", "(", "self", ",", "*", "funcs", ")", ":", "for", "func", "in", "funcs", ":", "self", ".", "namespace", "[", "func", ".", "__name__", "]", "=", "func" ]
Register function in the system namespace. Called by Services.
[ "Register", "function", "in", "the", "system", "namespace", ".", "Called", "by", "Services", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L369-L374
train
tuomas2/automate
src/automate/system.py
System.register_service
def register_service(self, service): """ Register service into the system. Called by Services. """ if service not in self.services: self.services.append(service)
python
def register_service(self, service): """ Register service into the system. Called by Services. """ if service not in self.services: self.services.append(service)
[ "def", "register_service", "(", "self", ",", "service", ")", ":", "if", "service", "not", "in", "self", ".", "services", ":", "self", ".", "services", ".", "append", "(", "service", ")" ]
Register service into the system. Called by Services.
[ "Register", "service", "into", "the", "system", ".", "Called", "by", "Services", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L376-L381
train
tuomas2/automate
src/automate/system.py
System.cleanup
def cleanup(self): """ Clean up before quitting """ self.pre_exit_trigger = True self.logger.info("Shutting down %s, please wait a moment.", self.name) for t in threading.enumerate(): if isinstance(t, TimerClass): t.cancel() self....
python
def cleanup(self): """ Clean up before quitting """ self.pre_exit_trigger = True self.logger.info("Shutting down %s, please wait a moment.", self.name) for t in threading.enumerate(): if isinstance(t, TimerClass): t.cancel() self....
[ "def", "cleanup", "(", "self", ")", ":", "self", ".", "pre_exit_trigger", "=", "True", "self", ".", "logger", ".", "info", "(", "\"Shutting down %s, please wait a moment.\"", ",", "self", ".", "name", ")", "for", "t", "in", "threading", ".", "enumerate", "("...
Clean up before quitting
[ "Clean", "up", "before", "quitting" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L398-L429
train
tuomas2/automate
src/automate/system.py
System.cmd_exec
def cmd_exec(self, cmd): """ Execute commands in automate namespace """ if not cmd: return ns = self.cmd_namespace import copy rval = True nscopy = copy.copy(ns) try: r = eval(cmd, ns) if isinstance(r, Syste...
python
def cmd_exec(self, cmd): """ Execute commands in automate namespace """ if not cmd: return ns = self.cmd_namespace import copy rval = True nscopy = copy.copy(ns) try: r = eval(cmd, ns) if isinstance(r, Syste...
[ "def", "cmd_exec", "(", "self", ",", "cmd", ")", ":", "if", "not", "cmd", ":", "return", "ns", "=", "self", ".", "cmd_namespace", "import", "copy", "rval", "=", "True", "nscopy", "=", "copy", ".", "copy", "(", "ns", ")", "try", ":", "r", "=", "ev...
Execute commands in automate namespace
[ "Execute", "commands", "in", "automate", "namespace" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/system.py#L431-L474
train
tuomas2/automate
src/automate/services/plantumlserv.py
PlantUMLService.write_puml
def write_puml(self, filename=''): """ Writes PUML from the system. If filename is given, stores result in the file. Otherwise returns result as a string. """ def get_type(o): type = 'program' if isinstance(o, AbstractSensor): type ...
python
def write_puml(self, filename=''): """ Writes PUML from the system. If filename is given, stores result in the file. Otherwise returns result as a string. """ def get_type(o): type = 'program' if isinstance(o, AbstractSensor): type ...
[ "def", "write_puml", "(", "self", ",", "filename", "=", "''", ")", ":", "def", "get_type", "(", "o", ")", ":", "type", "=", "'program'", "if", "isinstance", "(", "o", ",", "AbstractSensor", ")", ":", "type", "=", "'sensor'", "elif", "isinstance", "(", ...
Writes PUML from the system. If filename is given, stores result in the file. Otherwise returns result as a string.
[ "Writes", "PUML", "from", "the", "system", ".", "If", "filename", "is", "given", "stores", "result", "in", "the", "file", ".", "Otherwise", "returns", "result", "as", "a", "string", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/plantumlserv.py#L54-L112
train
tuomas2/automate
src/automate/services/plantumlserv.py
PlantUMLService.write_svg
def write_svg(self): """ Returns PUML from the system as a SVG image. Requires plantuml library. """ import plantuml puml = self.write_puml() server = plantuml.PlantUML(url=self.url) svg = server.processes(puml) return svg
python
def write_svg(self): """ Returns PUML from the system as a SVG image. Requires plantuml library. """ import plantuml puml = self.write_puml() server = plantuml.PlantUML(url=self.url) svg = server.processes(puml) return svg
[ "def", "write_svg", "(", "self", ")", ":", "import", "plantuml", "puml", "=", "self", ".", "write_puml", "(", ")", "server", "=", "plantuml", ".", "PlantUML", "(", "url", "=", "self", ".", "url", ")", "svg", "=", "server", ".", "processes", "(", "pum...
Returns PUML from the system as a SVG image. Requires plantuml library.
[ "Returns", "PUML", "from", "the", "system", "as", "a", "SVG", "image", ".", "Requires", "plantuml", "library", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/plantumlserv.py#L114-L122
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
median_kneighbour_distance
def median_kneighbour_distance(X, k=5): """ Calculate the median kneighbor distance. Find the distance between a set of random datapoints and their kth nearest neighbours. This is a heuristic for setting the kernel length scale. """ N_all = X.shape[0] k = min(k, N_all) N_subset = mi...
python
def median_kneighbour_distance(X, k=5): """ Calculate the median kneighbor distance. Find the distance between a set of random datapoints and their kth nearest neighbours. This is a heuristic for setting the kernel length scale. """ N_all = X.shape[0] k = min(k, N_all) N_subset = mi...
[ "def", "median_kneighbour_distance", "(", "X", ",", "k", "=", "5", ")", ":", "N_all", "=", "X", ".", "shape", "[", "0", "]", "k", "=", "min", "(", "k", ",", "N_all", ")", "N_subset", "=", "min", "(", "N_all", ",", "2000", ")", "sample_idx_train", ...
Calculate the median kneighbor distance. Find the distance between a set of random datapoints and their kth nearest neighbours. This is a heuristic for setting the kernel length scale.
[ "Calculate", "the", "median", "kneighbor", "distance", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L12-L27
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
pair_distance_centile
def pair_distance_centile(X, centile, max_pairs=5000): """ Calculate centiles of distances between random pairs in a dataset. This an alternative to the median kNN distance for setting the kernel length scale. """ N = X.shape[0] n_pairs = min(max_pairs, N**2) # randorder1 = np.random.pe...
python
def pair_distance_centile(X, centile, max_pairs=5000): """ Calculate centiles of distances between random pairs in a dataset. This an alternative to the median kNN distance for setting the kernel length scale. """ N = X.shape[0] n_pairs = min(max_pairs, N**2) # randorder1 = np.random.pe...
[ "def", "pair_distance_centile", "(", "X", ",", "centile", ",", "max_pairs", "=", "5000", ")", ":", "N", "=", "X", ".", "shape", "[", "0", "]", "n_pairs", "=", "min", "(", "max_pairs", ",", "N", "**", "2", ")", "dists", "=", "np", ".", "zeros", "(...
Calculate centiles of distances between random pairs in a dataset. This an alternative to the median kNN distance for setting the kernel length scale.
[ "Calculate", "centiles", "of", "distances", "between", "random", "pairs", "in", "a", "dataset", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L30-L51
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
LSAnomaly.fit
def fit(self, X, y=None): """ Fit the inlier model given training data. This function attempts to choose reasonable defaults for parameters sigma and rho if none are specified, which could then be adjusted to improve performance. Parameters ---------- X ...
python
def fit(self, X, y=None): """ Fit the inlier model given training data. This function attempts to choose reasonable defaults for parameters sigma and rho if none are specified, which could then be adjusted to improve performance. Parameters ---------- X ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "N", "=", "X", ".", "shape", "[", "0", "]", "if", "y", "is", "None", ":", "y", "=", "np", ".", "zeros", "(", "N", ")", "self", ".", "classes", "=", "list", "(", "set", ...
Fit the inlier model given training data. This function attempts to choose reasonable defaults for parameters sigma and rho if none are specified, which could then be adjusted to improve performance. Parameters ---------- X : array Examples of inlier data, o...
[ "Fit", "the", "inlier", "model", "given", "training", "data", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L108-L164
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
LSAnomaly.predict
def predict(self, X): """ Assign classes to test data. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns ------- y_predicted : array A vector of ...
python
def predict(self, X): """ Assign classes to test data. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns ------- y_predicted : array A vector of ...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "predictions_proba", "=", "self", ".", "predict_proba", "(", "X", ")", "predictions", "=", "[", "]", "allclasses", "=", "copy", ".", "copy", "(", "self", ".", "classes", ")", "allclasses", ".", "append...
Assign classes to test data. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns ------- y_predicted : array A vector of length N containing assigned classes. If n...
[ "Assign", "classes", "to", "test", "data", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L166-L192
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
LSAnomaly.predict_proba
def predict_proba(self, X): """ Calculate posterior probabilities of test data. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- y_prob : array ...
python
def predict_proba(self, X): """ Calculate posterior probabilities of test data. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- y_prob : array ...
[ "def", "predict_proba", "(", "self", ",", "X", ")", ":", "Phi", "=", "metrics", ".", "pairwise", ".", "rbf_kernel", "(", "X", ",", "self", ".", "kernel_pos", ",", "self", ".", "gamma", ")", "N", "=", "X", ".", "shape", "[", "0", "]", "predictions",...
Calculate posterior probabilities of test data. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- y_prob : array An array of dimension N times n_inlier_...
[ "Calculate", "posterior", "probabilities", "of", "test", "data", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L194-L223
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
LSAnomaly.decision_function
def decision_function(self, X): """ Generate an inlier score for each test data example. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- scores : ...
python
def decision_function(self, X): """ Generate an inlier score for each test data example. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- scores : ...
[ "def", "decision_function", "(", "self", ",", "X", ")", ":", "predictions", "=", "self", ".", "predict_proba", "(", "X", ")", "out", "=", "np", ".", "zeros", "(", "(", "predictions", ".", "shape", "[", "0", "]", ",", "1", ")", ")", "out", "[", ":...
Generate an inlier score for each test data example. Parameters ---------- X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- scores : array A vector of length N, where each e...
[ "Generate", "an", "inlier", "score", "for", "each", "test", "data", "example", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L225-L245
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
LSAnomaly.score
def score(self, X, y): """ Calculate accuracy score. Needed because of bug in metrics.accuracy_score when comparing list with numpy array. """ predictions = self.predict(X) true = 0.0 total = 0.0 for i in range(len(predictions)): total...
python
def score(self, X, y): """ Calculate accuracy score. Needed because of bug in metrics.accuracy_score when comparing list with numpy array. """ predictions = self.predict(X) true = 0.0 total = 0.0 for i in range(len(predictions)): total...
[ "def", "score", "(", "self", ",", "X", ",", "y", ")", ":", "predictions", "=", "self", ".", "predict", "(", "X", ")", "true", "=", "0.0", "total", "=", "0.0", "for", "i", "in", "range", "(", "len", "(", "predictions", ")", ")", ":", "total", "+...
Calculate accuracy score. Needed because of bug in metrics.accuracy_score when comparing list with numpy array.
[ "Calculate", "accuracy", "score", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L247-L261
train
lsanomaly/lsanomaly
lsanomaly/__init__.py
LSAnomaly.predict_sequence
def predict_sequence(self, X, A, pi, inference='smoothing'): """ Calculate class probabilities for a sequence of data. Parameters ---------- X : array Test data, of dimension N times d (rows are time frames, columns are data dimensions) A : class ...
python
def predict_sequence(self, X, A, pi, inference='smoothing'): """ Calculate class probabilities for a sequence of data. Parameters ---------- X : array Test data, of dimension N times d (rows are time frames, columns are data dimensions) A : class ...
[ "def", "predict_sequence", "(", "self", ",", "X", ",", "A", ",", "pi", ",", "inference", "=", "'smoothing'", ")", ":", "obsll", "=", "self", ".", "predict_proba", "(", "X", ")", "T", ",", "S", "=", "obsll", ".", "shape", "alpha", "=", "np", ".", ...
Calculate class probabilities for a sequence of data. Parameters ---------- X : array Test data, of dimension N times d (rows are time frames, columns are data dimensions) A : class transition matrix, where A[i,j] contains p(y_t=j|y_{t-1}=i) pi : vector o...
[ "Calculate", "class", "probabilities", "for", "a", "sequence", "of", "data", "." ]
7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e
https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L263-L310
train
tuomas2/automate
src/automate/extensions/webui/djangoapp/views.py
toggle_sensor
def toggle_sensor(request, sensorname): """ This is used only if websocket fails """ if service.read_only: service.logger.warning("Could not perform operation: read only mode enabled") raise Http404 source = request.GET.get('source', 'main') sensor = service.system.namespace[sens...
python
def toggle_sensor(request, sensorname): """ This is used only if websocket fails """ if service.read_only: service.logger.warning("Could not perform operation: read only mode enabled") raise Http404 source = request.GET.get('source', 'main') sensor = service.system.namespace[sens...
[ "def", "toggle_sensor", "(", "request", ",", "sensorname", ")", ":", "if", "service", ".", "read_only", ":", "service", ".", "logger", ".", "warning", "(", "\"Could not perform operation: read only mode enabled\"", ")", "raise", "Http404", "source", "=", "request", ...
This is used only if websocket fails
[ "This", "is", "used", "only", "if", "websocket", "fails" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/webui/djangoapp/views.py#L279-L290
train
tuomas2/automate
src/automate/extensions/webui/djangoapp/views.py
toggle_value
def toggle_value(request, name): """ For manual shortcut links to perform toggle actions """ obj = service.system.namespace.get(name, None) if not obj or service.read_only: raise Http404 new_status = obj.status = not obj.status if service.redirect_from_setters: return HttpRes...
python
def toggle_value(request, name): """ For manual shortcut links to perform toggle actions """ obj = service.system.namespace.get(name, None) if not obj or service.read_only: raise Http404 new_status = obj.status = not obj.status if service.redirect_from_setters: return HttpRes...
[ "def", "toggle_value", "(", "request", ",", "name", ")", ":", "obj", "=", "service", ".", "system", ".", "namespace", ".", "get", "(", "name", ",", "None", ")", "if", "not", "obj", "or", "service", ".", "read_only", ":", "raise", "Http404", "new_status...
For manual shortcut links to perform toggle actions
[ "For", "manual", "shortcut", "links", "to", "perform", "toggle", "actions" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/webui/djangoapp/views.py#L294-L305
train
tuomas2/automate
src/automate/extensions/webui/djangoapp/views.py
set_value
def set_value(request, name, value): """ For manual shortcut links to perform set value actions """ obj = service.system.namespace.get(name, None) if not obj or service.read_only: raise Http404 obj.status = value if service.redirect_from_setters: return HttpResponseRedirect(r...
python
def set_value(request, name, value): """ For manual shortcut links to perform set value actions """ obj = service.system.namespace.get(name, None) if not obj or service.read_only: raise Http404 obj.status = value if service.redirect_from_setters: return HttpResponseRedirect(r...
[ "def", "set_value", "(", "request", ",", "name", ",", "value", ")", ":", "obj", "=", "service", ".", "system", ".", "namespace", ".", "get", "(", "name", ",", "None", ")", "if", "not", "obj", "or", "service", ".", "read_only", ":", "raise", "Http404"...
For manual shortcut links to perform set value actions
[ "For", "manual", "shortcut", "links", "to", "perform", "set", "value", "actions" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/webui/djangoapp/views.py#L309-L320
train
tuomas2/automate
src/automate/systemobject.py
SystemObject.object_type
def object_type(self): """ A read-only property that gives the object type as string; sensor, actuator, program, other. Used by WEB interface templates. """ from .statusobject import AbstractSensor, AbstractActuator from .program import Program if isinsta...
python
def object_type(self): """ A read-only property that gives the object type as string; sensor, actuator, program, other. Used by WEB interface templates. """ from .statusobject import AbstractSensor, AbstractActuator from .program import Program if isinsta...
[ "def", "object_type", "(", "self", ")", ":", "from", ".", "statusobject", "import", "AbstractSensor", ",", "AbstractActuator", "from", ".", "program", "import", "Program", "if", "isinstance", "(", "self", ",", "AbstractSensor", ")", ":", "return", "'sensor'", ...
A read-only property that gives the object type as string; sensor, actuator, program, other. Used by WEB interface templates.
[ "A", "read", "-", "only", "property", "that", "gives", "the", "object", "type", "as", "string", ";", "sensor", "actuator", "program", "other", ".", "Used", "by", "WEB", "interface", "templates", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/systemobject.py#L115-L130
train
tuomas2/automate
src/automate/systemobject.py
SystemObject.get_as_datadict
def get_as_datadict(self): """ Get information about this object as a dictionary. Used by WebSocket interface to pass some relevant information to client applications. """ return dict(type=self.__class__.__name__, tags=list(self.tags))
python
def get_as_datadict(self): """ Get information about this object as a dictionary. Used by WebSocket interface to pass some relevant information to client applications. """ return dict(type=self.__class__.__name__, tags=list(self.tags))
[ "def", "get_as_datadict", "(", "self", ")", ":", "return", "dict", "(", "type", "=", "self", ".", "__class__", ".", "__name__", ",", "tags", "=", "list", "(", "self", ".", "tags", ")", ")" ]
Get information about this object as a dictionary. Used by WebSocket interface to pass some relevant information to client applications.
[ "Get", "information", "about", "this", "object", "as", "a", "dictionary", ".", "Used", "by", "WebSocket", "interface", "to", "pass", "some", "relevant", "information", "to", "client", "applications", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/systemobject.py#L156-L161
train
tuomas2/automate
src/automate/systemobject.py
SystemObject.setup_system
def setup_system(self, system, name_from_system='', **kwargs): """ Set system attribute and do some initialization. Used by System. """ if not self.system: self.system = system name, traits = self._passed_arguments new_name = self.system.get_unique_name(s...
python
def setup_system(self, system, name_from_system='', **kwargs): """ Set system attribute and do some initialization. Used by System. """ if not self.system: self.system = system name, traits = self._passed_arguments new_name = self.system.get_unique_name(s...
[ "def", "setup_system", "(", "self", ",", "system", ",", "name_from_system", "=", "''", ",", "**", "kwargs", ")", ":", "if", "not", "self", ".", "system", ":", "self", ".", "system", "=", "system", "name", ",", "traits", "=", "self", ".", "_passed_argum...
Set system attribute and do some initialization. Used by System.
[ "Set", "system", "attribute", "and", "do", "some", "initialization", ".", "Used", "by", "System", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/systemobject.py#L169-L194
train
tuomas2/automate
src/automate/systemobject.py
SystemObject.setup_callables
def setup_callables(self): """ Setup Callable attributes that belong to this object. """ defaults = self.get_default_callables() for key, value in list(defaults.items()): self._postponed_callables.setdefault(key, value) for key in self.callables: ...
python
def setup_callables(self): """ Setup Callable attributes that belong to this object. """ defaults = self.get_default_callables() for key, value in list(defaults.items()): self._postponed_callables.setdefault(key, value) for key in self.callables: ...
[ "def", "setup_callables", "(", "self", ")", ":", "defaults", "=", "self", ".", "get_default_callables", "(", ")", "for", "key", ",", "value", "in", "list", "(", "defaults", ".", "items", "(", ")", ")", ":", "self", ".", "_postponed_callables", ".", "setd...
Setup Callable attributes that belong to this object.
[ "Setup", "Callable", "attributes", "that", "belong", "to", "this", "object", "." ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/systemobject.py#L196-L206
train
ofa/django-bouncy
django_bouncy/utils.py
grab_keyfile
def grab_keyfile(cert_url): """ Function to acqure the keyfile SNS keys expire and Amazon does not promise they will use the same key for all SNS requests. So we need to keep a copy of the cert in our cache """ key_cache = caches[getattr(settings, 'BOUNCY_KEY_CACHE', 'default')] pemfil...
python
def grab_keyfile(cert_url): """ Function to acqure the keyfile SNS keys expire and Amazon does not promise they will use the same key for all SNS requests. So we need to keep a copy of the cert in our cache """ key_cache = caches[getattr(settings, 'BOUNCY_KEY_CACHE', 'default')] pemfil...
[ "def", "grab_keyfile", "(", "cert_url", ")", ":", "key_cache", "=", "caches", "[", "getattr", "(", "settings", ",", "'BOUNCY_KEY_CACHE'", ",", "'default'", ")", "]", "pemfile", "=", "key_cache", ".", "get", "(", "cert_url", ")", "if", "not", "pemfile", ":"...
Function to acqure the keyfile SNS keys expire and Amazon does not promise they will use the same key for all SNS requests. So we need to keep a copy of the cert in our cache
[ "Function", "to", "acqure", "the", "keyfile" ]
a386dfa8c4ce59bd18978a3537c03cd6ad07bf06
https://github.com/ofa/django-bouncy/blob/a386dfa8c4ce59bd18978a3537c03cd6ad07bf06/django_bouncy/utils.py#L67-L91
train
ofa/django-bouncy
django_bouncy/utils.py
verify_notification
def verify_notification(data): """ Function to verify notification came from a trusted source Returns True if verfied, False if not verified """ pemfile = grab_keyfile(data['SigningCertURL']) cert = crypto.load_certificate(crypto.FILETYPE_PEM, pemfile) signature = base64.decodestring(six.b(...
python
def verify_notification(data): """ Function to verify notification came from a trusted source Returns True if verfied, False if not verified """ pemfile = grab_keyfile(data['SigningCertURL']) cert = crypto.load_certificate(crypto.FILETYPE_PEM, pemfile) signature = base64.decodestring(six.b(...
[ "def", "verify_notification", "(", "data", ")", ":", "pemfile", "=", "grab_keyfile", "(", "data", "[", "'SigningCertURL'", "]", ")", "cert", "=", "crypto", ".", "load_certificate", "(", "crypto", ".", "FILETYPE_PEM", ",", "pemfile", ")", "signature", "=", "b...
Function to verify notification came from a trusted source Returns True if verfied, False if not verified
[ "Function", "to", "verify", "notification", "came", "from", "a", "trusted", "source" ]
a386dfa8c4ce59bd18978a3537c03cd6ad07bf06
https://github.com/ofa/django-bouncy/blob/a386dfa8c4ce59bd18978a3537c03cd6ad07bf06/django_bouncy/utils.py#L94-L114
train
ofa/django-bouncy
django_bouncy/utils.py
approve_subscription
def approve_subscription(data): """ Function to approve a SNS subscription with Amazon We don't do a ton of verification here, past making sure that the endpoint we're told to go to to verify the subscription is on the correct host """ url = data['SubscribeURL'] domain = urlparse(url).netl...
python
def approve_subscription(data): """ Function to approve a SNS subscription with Amazon We don't do a ton of verification here, past making sure that the endpoint we're told to go to to verify the subscription is on the correct host """ url = data['SubscribeURL'] domain = urlparse(url).netl...
[ "def", "approve_subscription", "(", "data", ")", ":", "url", "=", "data", "[", "'SubscribeURL'", "]", "domain", "=", "urlparse", "(", "url", ")", ".", "netloc", "pattern", "=", "getattr", "(", "settings", ",", "'BOUNCY_SUBSCRIBE_DOMAIN_REGEX'", ",", "r\"sns.[a...
Function to approve a SNS subscription with Amazon We don't do a ton of verification here, past making sure that the endpoint we're told to go to to verify the subscription is on the correct host
[ "Function", "to", "approve", "a", "SNS", "subscription", "with", "Amazon" ]
a386dfa8c4ce59bd18978a3537c03cd6ad07bf06
https://github.com/ofa/django-bouncy/blob/a386dfa8c4ce59bd18978a3537c03cd6ad07bf06/django_bouncy/utils.py#L117-L150
train
ofa/django-bouncy
django_bouncy/utils.py
clean_time
def clean_time(time_string): """Return a datetime from the Amazon-provided datetime string""" # Get a timezone-aware datetime object from the string time = dateutil.parser.parse(time_string) if not settings.USE_TZ: # If timezone support is not active, convert the time to UTC and # remove...
python
def clean_time(time_string): """Return a datetime from the Amazon-provided datetime string""" # Get a timezone-aware datetime object from the string time = dateutil.parser.parse(time_string) if not settings.USE_TZ: # If timezone support is not active, convert the time to UTC and # remove...
[ "def", "clean_time", "(", "time_string", ")", ":", "time", "=", "dateutil", ".", "parser", ".", "parse", "(", "time_string", ")", "if", "not", "settings", ".", "USE_TZ", ":", "time", "=", "time", ".", "astimezone", "(", "timezone", ".", "utc", ")", "."...
Return a datetime from the Amazon-provided datetime string
[ "Return", "a", "datetime", "from", "the", "Amazon", "-", "provided", "datetime", "string" ]
a386dfa8c4ce59bd18978a3537c03cd6ad07bf06
https://github.com/ofa/django-bouncy/blob/a386dfa8c4ce59bd18978a3537c03cd6ad07bf06/django_bouncy/utils.py#L153-L161
train
bruth/django-preserialize
preserialize/utils.py
parse_selectors
def parse_selectors(model, fields=None, exclude=None, key_map=None, **options): """Validates fields are valid and maps pseudo-fields to actual fields for a given model class. """ fields = fields or DEFAULT_SELECTORS exclude = exclude or () key_map = key_map or {} validated = [] for alia...
python
def parse_selectors(model, fields=None, exclude=None, key_map=None, **options): """Validates fields are valid and maps pseudo-fields to actual fields for a given model class. """ fields = fields or DEFAULT_SELECTORS exclude = exclude or () key_map = key_map or {} validated = [] for alia...
[ "def", "parse_selectors", "(", "model", ",", "fields", "=", "None", ",", "exclude", "=", "None", ",", "key_map", "=", "None", ",", "**", "options", ")", ":", "fields", "=", "fields", "or", "DEFAULT_SELECTORS", "exclude", "=", "exclude", "or", "(", ")", ...
Validates fields are valid and maps pseudo-fields to actual fields for a given model class.
[ "Validates", "fields", "are", "valid", "and", "maps", "pseudo", "-", "fields", "to", "actual", "fields", "for", "a", "given", "model", "class", "." ]
d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6
https://github.com/bruth/django-preserialize/blob/d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6/preserialize/utils.py#L96-L125
train
bruth/django-preserialize
preserialize/utils.py
ModelFieldResolver._get_local_fields
def _get_local_fields(self, model): "Return the names of all locally defined fields on the model class." local = [f for f in model._meta.fields] m2m = [f for f in model._meta.many_to_many] fields = local + m2m names = tuple([x.name for x in fields]) return { ...
python
def _get_local_fields(self, model): "Return the names of all locally defined fields on the model class." local = [f for f in model._meta.fields] m2m = [f for f in model._meta.many_to_many] fields = local + m2m names = tuple([x.name for x in fields]) return { ...
[ "def", "_get_local_fields", "(", "self", ",", "model", ")", ":", "\"Return the names of all locally defined fields on the model class.\"", "local", "=", "[", "f", "for", "f", "in", "model", ".", "_meta", ".", "fields", "]", "m2m", "=", "[", "f", "for", "f", "i...
Return the names of all locally defined fields on the model class.
[ "Return", "the", "names", "of", "all", "locally", "defined", "fields", "on", "the", "model", "class", "." ]
d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6
https://github.com/bruth/django-preserialize/blob/d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6/preserialize/utils.py#L42-L51
train
bruth/django-preserialize
preserialize/utils.py
ModelFieldResolver._get_related_fields
def _get_related_fields(self, model): "Returns the names of all related fields for model class." reverse_fk = self._get_all_related_objects(model) reverse_m2m = self._get_all_related_many_to_many_objects(model) fields = tuple(reverse_fk + reverse_m2m) names = tuple([x.get_access...
python
def _get_related_fields(self, model): "Returns the names of all related fields for model class." reverse_fk = self._get_all_related_objects(model) reverse_m2m = self._get_all_related_many_to_many_objects(model) fields = tuple(reverse_fk + reverse_m2m) names = tuple([x.get_access...
[ "def", "_get_related_fields", "(", "self", ",", "model", ")", ":", "\"Returns the names of all related fields for model class.\"", "reverse_fk", "=", "self", ".", "_get_all_related_objects", "(", "model", ")", "reverse_m2m", "=", "self", ".", "_get_all_related_many_to_many_...
Returns the names of all related fields for model class.
[ "Returns", "the", "names", "of", "all", "related", "fields", "for", "model", "class", "." ]
d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6
https://github.com/bruth/django-preserialize/blob/d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6/preserialize/utils.py#L53-L63
train
cokelaer/reports
reports/htmltable.py
HTMLTable.to_html
def to_html(self, index=False, escape=False, header=True, collapse_table=True, class_outer="table_outer", **kargs): """Return HTML version of the table This is a wrapper of the to_html method of the pandas dataframe. :param bool index: do not include the index :param bool e...
python
def to_html(self, index=False, escape=False, header=True, collapse_table=True, class_outer="table_outer", **kargs): """Return HTML version of the table This is a wrapper of the to_html method of the pandas dataframe. :param bool index: do not include the index :param bool e...
[ "def", "to_html", "(", "self", ",", "index", "=", "False", ",", "escape", "=", "False", ",", "header", "=", "True", ",", "collapse_table", "=", "True", ",", "class_outer", "=", "\"table_outer\"", ",", "**", "kargs", ")", ":", "_buffer", "=", "{", "}", ...
Return HTML version of the table This is a wrapper of the to_html method of the pandas dataframe. :param bool index: do not include the index :param bool escape: do not escape special characters :param bool header: include header :param bool collapse_table: long tables are shor...
[ "Return", "HTML", "version", "of", "the", "table" ]
7703b1e27d440c3193ee6cc90bfecd78cc98b737
https://github.com/cokelaer/reports/blob/7703b1e27d440c3193ee6cc90bfecd78cc98b737/reports/htmltable.py#L75-L108
train
cokelaer/reports
reports/htmltable.py
HTMLTable.add_bgcolor
def add_bgcolor(self, colname, cmap='copper', mode='absmax', threshold=2): """Change column content into HTML paragraph with background color :param colname: :param cmap: a colormap (matplotlib) or created using colormap package (from pypi). :param mode: type of ...
python
def add_bgcolor(self, colname, cmap='copper', mode='absmax', threshold=2): """Change column content into HTML paragraph with background color :param colname: :param cmap: a colormap (matplotlib) or created using colormap package (from pypi). :param mode: type of ...
[ "def", "add_bgcolor", "(", "self", ",", "colname", ",", "cmap", "=", "'copper'", ",", "mode", "=", "'absmax'", ",", "threshold", "=", "2", ")", ":", "try", ":", "cmap", "=", "cmap_builder", "(", "cmap", ")", "except", ":", "pass", "data", "=", "self"...
Change column content into HTML paragraph with background color :param colname: :param cmap: a colormap (matplotlib) or created using colormap package (from pypi). :param mode: type of normalisation in 'absmax', 'max', 'clip' (see details below) :param threshold:...
[ "Change", "column", "content", "into", "HTML", "paragraph", "with", "background", "color" ]
7703b1e27d440c3193ee6cc90bfecd78cc98b737
https://github.com/cokelaer/reports/blob/7703b1e27d440c3193ee6cc90bfecd78cc98b737/reports/htmltable.py#L110-L180
train
makinacorpus/django-tracking-fields
tracking_fields/admin.py
TrackingEventAdmin.changelist_view
def changelist_view(self, request, extra_context=None): """ Get object currently tracked and add a button to get back to it """ extra_context = extra_context or {} if 'object' in request.GET.keys(): value = request.GET['object'].split(':') content_type = get_object_or_404...
python
def changelist_view(self, request, extra_context=None): """ Get object currently tracked and add a button to get back to it """ extra_context = extra_context or {} if 'object' in request.GET.keys(): value = request.GET['object'].split(':') content_type = get_object_or_404...
[ "def", "changelist_view", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "extra_context", "=", "extra_context", "or", "{", "}", "if", "'object'", "in", "request", ".", "GET", ".", "keys", "(", ")", ":", "value", "=", "request",...
Get object currently tracked and add a button to get back to it
[ "Get", "object", "currently", "tracked", "and", "add", "a", "button", "to", "get", "back", "to", "it" ]
463313d0f9c0f8107a0413f4d418d1a8c2311981
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/admin.py#L118-L134
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.list
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of configs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields ...
python
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of configs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields ...
[ "def", "list", "(", "self", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "sort", "=", "None", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "schema", "=", "self", ".", "LIST_SCHEMA", "resp", "=", "self", ".", "servi...
Get a list of configs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Pag...
[ "Get", "a", "list", "of", "configs", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L187-L200
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.iter_list
def iter_list(self, *args, **kwargs): """Get a list of configs. Whereas ``list`` fetches a single page of configs according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all configs by internally making successive calls to ``list``. :param args: Arguments that ...
python
def iter_list(self, *args, **kwargs): """Get a list of configs. Whereas ``list`` fetches a single page of configs according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all configs by internally making successive calls to ``list``. :param args: Arguments that ...
[ "def", "iter_list", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "service", ".", "iter_list", "(", "self", ".", "list", ",", "*", "args", ",", "**", "kwargs", ")" ]
Get a list of configs. Whereas ``list`` fetches a single page of configs according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all configs by internally making successive calls to ``list``. :param args: Arguments that ``list`` takes. :param kwargs: Optional a...
[ "Get", "a", "list", "of", "configs", ".", "Whereas", "list", "fetches", "a", "single", "page", "of", "configs", "according", "to", "its", "limit", "and", "page", "arguments", "iter_list", "returns", "all", "configs", "by", "internally", "making", "successive",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L202-L213
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.get_plaintext
def get_plaintext(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a config as plaintext. :param id: Config ID as an int. :rtype: string """ return self.service.get_id(self.base, id, params={'format': 'text'}).text
python
def get_plaintext(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a config as plaintext. :param id: Config ID as an int. :rtype: string """ return self.service.get_id(self.base, id, params={'format': 'text'}).text
[ "def", "get_plaintext", "(", "self", ",", "id", ")", ":", "return", "self", ".", "service", ".", "get_id", "(", "self", ".", "base", ",", "id", ",", "params", "=", "{", "'format'", ":", "'text'", "}", ")", ".", "text" ]
Get a config as plaintext. :param id: Config ID as an int. :rtype: string
[ "Get", "a", "config", "as", "plaintext", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L233-L239
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.create
def create(self, resource): """Create a new config. :param resource: :class:`configs.Config <configs.Config>` object :return: :class:`configs.Config <configs.Config>` object :rtype: configs.Config """ schema = self.CREATE_SCHEMA json = self.service.encode(schema,...
python
def create(self, resource): """Create a new config. :param resource: :class:`configs.Config <configs.Config>` object :return: :class:`configs.Config <configs.Config>` object :rtype: configs.Config """ schema = self.CREATE_SCHEMA json = self.service.encode(schema,...
[ "def", "create", "(", "self", ",", "resource", ")", ":", "schema", "=", "self", ".", "CREATE_SCHEMA", "json", "=", "self", ".", "service", ".", "encode", "(", "schema", ",", "resource", ")", "schema", "=", "self", ".", "GET_SCHEMA", "resp", "=", "self"...
Create a new config. :param resource: :class:`configs.Config <configs.Config>` object :return: :class:`configs.Config <configs.Config>` object :rtype: configs.Config
[ "Create", "a", "new", "config", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L253-L265
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.edit
def edit(self, resource): """Edit a config. :param resource: :class:`configs.Config <configs.Config>` object :return: :class:`configs.Config <configs.Config>` object :rtype: configs.Config """ schema = self.EDIT_SCHEMA json = self.service.encode(schema, resource)...
python
def edit(self, resource): """Edit a config. :param resource: :class:`configs.Config <configs.Config>` object :return: :class:`configs.Config <configs.Config>` object :rtype: configs.Config """ schema = self.EDIT_SCHEMA json = self.service.encode(schema, resource)...
[ "def", "edit", "(", "self", ",", "resource", ")", ":", "schema", "=", "self", ".", "EDIT_SCHEMA", "json", "=", "self", ".", "service", ".", "encode", "(", "schema", ",", "resource", ")", "schema", "=", "self", ".", "GET_SCHEMA", "resp", "=", "self", ...
Edit a config. :param resource: :class:`configs.Config <configs.Config>` object :return: :class:`configs.Config <configs.Config>` object :rtype: configs.Config
[ "Edit", "a", "config", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L267-L279
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.edit_shares
def edit_shares(self, id, user_ids): # pylint: disable=invalid-name,redefined-builtin """Edit shares for a config. :param id: Config ID as an int. :param user_ids: User IDs as int list. :return: :class:`cdrouter.Share <cdrouter.Share>` list """ return self.service.edit_s...
python
def edit_shares(self, id, user_ids): # pylint: disable=invalid-name,redefined-builtin """Edit shares for a config. :param id: Config ID as an int. :param user_ids: User IDs as int list. :return: :class:`cdrouter.Share <cdrouter.Share>` list """ return self.service.edit_s...
[ "def", "edit_shares", "(", "self", ",", "id", ",", "user_ids", ")", ":", "return", "self", ".", "service", ".", "edit_shares", "(", "self", ".", "base", ",", "id", ",", "user_ids", ")" ]
Edit shares for a config. :param id: Config ID as an int. :param user_ids: User IDs as int list. :return: :class:`cdrouter.Share <cdrouter.Share>` list
[ "Edit", "shares", "for", "a", "config", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L296-L303
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.check_config
def check_config(self, contents): """Process config contents with cdrouter-cli -check-config. :param contents: Config contents as string. :return: :class:`configs.CheckConfig <configs.CheckConfig>` object :rtype: configs.CheckConfig """ schema = CheckConfigSchema() ...
python
def check_config(self, contents): """Process config contents with cdrouter-cli -check-config. :param contents: Config contents as string. :return: :class:`configs.CheckConfig <configs.CheckConfig>` object :rtype: configs.CheckConfig """ schema = CheckConfigSchema() ...
[ "def", "check_config", "(", "self", ",", "contents", ")", ":", "schema", "=", "CheckConfigSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'process'", ":", "'check'", "}", ",", "...
Process config contents with cdrouter-cli -check-config. :param contents: Config contents as string. :return: :class:`configs.CheckConfig <configs.CheckConfig>` object :rtype: configs.CheckConfig
[ "Process", "config", "contents", "with", "cdrouter", "-", "cli", "-", "check", "-", "config", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L313-L323
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.upgrade_config
def upgrade_config(self, contents): """Process config contents with cdrouter-cli -upgrade-config. :param contents: Config contents as string. :return: :class:`configs.UpgradeConfig <configs.UpgradeConfig>` object :rtype: configs.UpgradeConfig """ schema = UpgradeConfigSc...
python
def upgrade_config(self, contents): """Process config contents with cdrouter-cli -upgrade-config. :param contents: Config contents as string. :return: :class:`configs.UpgradeConfig <configs.UpgradeConfig>` object :rtype: configs.UpgradeConfig """ schema = UpgradeConfigSc...
[ "def", "upgrade_config", "(", "self", ",", "contents", ")", ":", "schema", "=", "UpgradeConfigSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'process'", ":", "'upgrade'", "}", ",...
Process config contents with cdrouter-cli -upgrade-config. :param contents: Config contents as string. :return: :class:`configs.UpgradeConfig <configs.UpgradeConfig>` object :rtype: configs.UpgradeConfig
[ "Process", "config", "contents", "with", "cdrouter", "-", "cli", "-", "upgrade", "-", "config", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L325-L335
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.get_networks
def get_networks(self, contents): """Process config contents with cdrouter-cli -print-networks-json. :param contents: Config contents as string. :return: :class:`configs.Networks <configs.Networks>` object :rtype: configs.Networks """ schema = NetworksSchema() re...
python
def get_networks(self, contents): """Process config contents with cdrouter-cli -print-networks-json. :param contents: Config contents as string. :return: :class:`configs.Networks <configs.Networks>` object :rtype: configs.Networks """ schema = NetworksSchema() re...
[ "def", "get_networks", "(", "self", ",", "contents", ")", ":", "schema", "=", "NetworksSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'process'", ":", "'networks'", "}", ",", "...
Process config contents with cdrouter-cli -print-networks-json. :param contents: Config contents as string. :return: :class:`configs.Networks <configs.Networks>` object :rtype: configs.Networks
[ "Process", "config", "contents", "with", "cdrouter", "-", "cli", "-", "print", "-", "networks", "-", "json", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L337-L347
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.bulk_copy
def bulk_copy(self, ids): """Bulk copy a set of configs. :param ids: Int list of config IDs. :return: :class:`configs.Config <configs.Config>` list """ schema = self.GET_SCHEMA return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
python
def bulk_copy(self, ids): """Bulk copy a set of configs. :param ids: Int list of config IDs. :return: :class:`configs.Config <configs.Config>` list """ schema = self.GET_SCHEMA return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
[ "def", "bulk_copy", "(", "self", ",", "ids", ")", ":", "schema", "=", "self", ".", "GET_SCHEMA", "return", "self", ".", "service", ".", "bulk_copy", "(", "self", ".", "base", ",", "self", ".", "RESOURCE", ",", "ids", ",", "schema", ")" ]
Bulk copy a set of configs. :param ids: Int list of config IDs. :return: :class:`configs.Config <configs.Config>` list
[ "Bulk", "copy", "a", "set", "of", "configs", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L357-L364
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.bulk_edit
def bulk_edit(self, _fields, ids=None, filter=None, type=None, all=False, testvars=None): # pylint: disable=redefined-builtin """Bulk edit a set of configs. :param _fields: :class:`configs.Config <configs.Config>` object :param ids: (optional) Int list of config IDs. :param filter: (opt...
python
def bulk_edit(self, _fields, ids=None, filter=None, type=None, all=False, testvars=None): # pylint: disable=redefined-builtin """Bulk edit a set of configs. :param _fields: :class:`configs.Config <configs.Config>` object :param ids: (optional) Int list of config IDs. :param filter: (opt...
[ "def", "bulk_edit", "(", "self", ",", "_fields", ",", "ids", "=", "None", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "all", "=", "False", ",", "testvars", "=", "None", ")", ":", "schema", "=", "self", ".", "EDIT_SCHEMA", "_fields", ...
Bulk edit a set of configs. :param _fields: :class:`configs.Config <configs.Config>` object :param ids: (optional) Int list of config IDs. :param filter: (optional) String list of filters. :param type: (optional) `union` or `inter` as string. :param all: (optional) Apply to all ...
[ "Bulk", "edit", "a", "set", "of", "configs", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L366-L379
train
qacafe/cdrouter.py
cdrouter/configs.py
ConfigsService.bulk_delete
def bulk_delete(self, ids=None, filter=None, type=None, all=False): # pylint: disable=redefined-builtin """Bulk delete a set of configs. :param ids: (optional) Int list of config IDs. :param filter: (optional) String list of filters. :param type: (optional) `union` or `inter` as string....
python
def bulk_delete(self, ids=None, filter=None, type=None, all=False): # pylint: disable=redefined-builtin """Bulk delete a set of configs. :param ids: (optional) Int list of config IDs. :param filter: (optional) String list of filters. :param type: (optional) `union` or `inter` as string....
[ "def", "bulk_delete", "(", "self", ",", "ids", "=", "None", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "all", "=", "False", ")", ":", "return", "self", ".", "service", ".", "bulk_delete", "(", "self", ".", "base", ",", "self", ".", ...
Bulk delete a set of configs. :param ids: (optional) Int list of config IDs. :param filter: (optional) String list of filters. :param type: (optional) `union` or `inter` as string. :param all: (optional) Apply to all if bool `True`.
[ "Bulk", "delete", "a", "set", "of", "configs", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L381-L390
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
response_token_setter
def response_token_setter(remote, resp): """Extract token from response and set it for the user. :param remote: The remote application. :param resp: The response. :raises invenio_oauthclient.errors.OAuthClientError: If authorization with remote service failed. :raises invenio_oauthclient.er...
python
def response_token_setter(remote, resp): """Extract token from response and set it for the user. :param remote: The remote application. :param resp: The response. :raises invenio_oauthclient.errors.OAuthClientError: If authorization with remote service failed. :raises invenio_oauthclient.er...
[ "def", "response_token_setter", "(", "remote", ",", "resp", ")", ":", "if", "resp", "is", "None", ":", "raise", "OAuthRejectedRequestError", "(", "'User rejected request.'", ",", "remote", ",", "resp", ")", "else", ":", "if", "'access_token'", "in", "resp", ":...
Extract token from response and set it for the user. :param remote: The remote application. :param resp: The response. :raises invenio_oauthclient.errors.OAuthClientError: If authorization with remote service failed. :raises invenio_oauthclient.errors.OAuthResponseError: In case of bad ...
[ "Extract", "token", "from", "response", "and", "set", "it", "for", "the", "user", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L69-L92
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
oauth1_token_setter
def oauth1_token_setter(remote, resp, token_type='', extra_data=None): """Set an OAuth1 token. :param remote: The remote application. :param resp: The response. :param token_type: The token type. (Default: ``''``) :param extra_data: Extra information. (Default: ``None``) :returns: A :class:`inv...
python
def oauth1_token_setter(remote, resp, token_type='', extra_data=None): """Set an OAuth1 token. :param remote: The remote application. :param resp: The response. :param token_type: The token type. (Default: ``''``) :param extra_data: Extra information. (Default: ``None``) :returns: A :class:`inv...
[ "def", "oauth1_token_setter", "(", "remote", ",", "resp", ",", "token_type", "=", "''", ",", "extra_data", "=", "None", ")", ":", "return", "token_setter", "(", "remote", ",", "resp", "[", "'oauth_token'", "]", ",", "secret", "=", "resp", "[", "'oauth_toke...
Set an OAuth1 token. :param remote: The remote application. :param resp: The response. :param token_type: The token type. (Default: ``''``) :param extra_data: Extra information. (Default: ``None``) :returns: A :class:`invenio_oauthclient.models.RemoteToken` instance.
[ "Set", "an", "OAuth1", "token", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L95-L110
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
oauth2_token_setter
def oauth2_token_setter(remote, resp, token_type='', extra_data=None): """Set an OAuth2 token. The refresh_token can be used to obtain a new access_token after the old one is expired. It is saved in the database for long term use. A refresh_token will be present only if `access_type=offline` is include...
python
def oauth2_token_setter(remote, resp, token_type='', extra_data=None): """Set an OAuth2 token. The refresh_token can be used to obtain a new access_token after the old one is expired. It is saved in the database for long term use. A refresh_token will be present only if `access_type=offline` is include...
[ "def", "oauth2_token_setter", "(", "remote", ",", "resp", ",", "token_type", "=", "''", ",", "extra_data", "=", "None", ")", ":", "return", "token_setter", "(", "remote", ",", "resp", "[", "'access_token'", "]", ",", "secret", "=", "''", ",", "token_type",...
Set an OAuth2 token. The refresh_token can be used to obtain a new access_token after the old one is expired. It is saved in the database for long term use. A refresh_token will be present only if `access_type=offline` is included in the authorization code request. :param remote: The remote applic...
[ "Set", "an", "OAuth2", "token", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L113-L133
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
token_setter
def token_setter(remote, token, secret='', token_type='', extra_data=None, user=None): """Set token for user. :param remote: The remote application. :param token: The token to set. :param token_type: The token type. (Default: ``''``) :param extra_data: Extra information. (Default: ...
python
def token_setter(remote, token, secret='', token_type='', extra_data=None, user=None): """Set token for user. :param remote: The remote application. :param token: The token to set. :param token_type: The token type. (Default: ``''``) :param extra_data: Extra information. (Default: ...
[ "def", "token_setter", "(", "remote", ",", "token", ",", "secret", "=", "''", ",", "token_type", "=", "''", ",", "extra_data", "=", "None", ",", "user", "=", "None", ")", ":", "session", "[", "token_session_key", "(", "remote", ".", "name", ")", "]", ...
Set token for user. :param remote: The remote application. :param token: The token to set. :param token_type: The token type. (Default: ``''``) :param extra_data: Extra information. (Default: ``None``) :param user: The user owner of the remote token. If it's not defined, the current user is...
[ "Set", "token", "for", "user", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L136-L169
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
token_getter
def token_getter(remote, token=''): """Retrieve OAuth access token. Used by flask-oauthlib to get the access token when making requests. :param remote: The remote application. :param token: Type of token to get. Data passed from ``oauth.request()`` to identify which token to retrieve. (Default...
python
def token_getter(remote, token=''): """Retrieve OAuth access token. Used by flask-oauthlib to get the access token when making requests. :param remote: The remote application. :param token: Type of token to get. Data passed from ``oauth.request()`` to identify which token to retrieve. (Default...
[ "def", "token_getter", "(", "remote", ",", "token", "=", "''", ")", ":", "session_key", "=", "token_session_key", "(", "remote", ".", "name", ")", "if", "session_key", "not", "in", "session", "and", "current_user", ".", "is_authenticated", ":", "remote_token",...
Retrieve OAuth access token. Used by flask-oauthlib to get the access token when making requests. :param remote: The remote application. :param token: Type of token to get. Data passed from ``oauth.request()`` to identify which token to retrieve. (Default: ``''``) :returns: The token.
[ "Retrieve", "OAuth", "access", "token", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L172-L199
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
token_delete
def token_delete(remote, token=''): """Remove OAuth access tokens from session. :param remote: The remote application. :param token: Type of token to get. Data passed from ``oauth.request()`` to identify which token to retrieve. (Default: ``''``) :returns: The token. """ session_key = t...
python
def token_delete(remote, token=''): """Remove OAuth access tokens from session. :param remote: The remote application. :param token: Type of token to get. Data passed from ``oauth.request()`` to identify which token to retrieve. (Default: ``''``) :returns: The token. """ session_key = t...
[ "def", "token_delete", "(", "remote", ",", "token", "=", "''", ")", ":", "session_key", "=", "token_session_key", "(", "remote", ".", "name", ")", "return", "session", ".", "pop", "(", "session_key", ",", "None", ")" ]
Remove OAuth access tokens from session. :param remote: The remote application. :param token: Type of token to get. Data passed from ``oauth.request()`` to identify which token to retrieve. (Default: ``''``) :returns: The token.
[ "Remove", "OAuth", "access", "tokens", "from", "session", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L202-L211
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
oauth_error_handler
def oauth_error_handler(f): """Decorator to handle exceptions.""" @wraps(f) def inner(*args, **kwargs): # OAuthErrors should not happen, so they are not caught here. Hence # they will result in a 500 Internal Server Error which is what we # are interested in. try: ...
python
def oauth_error_handler(f): """Decorator to handle exceptions.""" @wraps(f) def inner(*args, **kwargs): # OAuthErrors should not happen, so they are not caught here. Hence # they will result in a 500 Internal Server Error which is what we # are interested in. try: ...
[ "def", "oauth_error_handler", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "inner", "(", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "**", "kwargs", ")", "except", "OAuthClientError", "as...
Decorator to handle exceptions.
[ "Decorator", "to", "handle", "exceptions", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L217-L244
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
authorized_default_handler
def authorized_default_handler(resp, remote, *args, **kwargs): """Store access token in session. Default authorized handler. :param remote: The remote application. :param resp: The response. :returns: Redirect response. """ response_token_setter(remote, resp) db.session.commit() re...
python
def authorized_default_handler(resp, remote, *args, **kwargs): """Store access token in session. Default authorized handler. :param remote: The remote application. :param resp: The response. :returns: Redirect response. """ response_token_setter(remote, resp) db.session.commit() re...
[ "def", "authorized_default_handler", "(", "resp", ",", "remote", ",", "*", "args", ",", "**", "kwargs", ")", ":", "response_token_setter", "(", "remote", ",", "resp", ")", "db", ".", "session", ".", "commit", "(", ")", "return", "redirect", "(", "url_for",...
Store access token in session. Default authorized handler. :param remote: The remote application. :param resp: The response. :returns: Redirect response.
[ "Store", "access", "token", "in", "session", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L251-L262
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
signup_handler
def signup_handler(remote, *args, **kwargs): """Handle extra signup information. :param remote: The remote application. :returns: Redirect response or the template rendered. """ # User already authenticated so move on if current_user.is_authenticated: return redirect('/') # Retriev...
python
def signup_handler(remote, *args, **kwargs): """Handle extra signup information. :param remote: The remote application. :returns: Redirect response or the template rendered. """ # User already authenticated so move on if current_user.is_authenticated: return redirect('/') # Retriev...
[ "def", "signup_handler", "(", "remote", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "current_user", ".", "is_authenticated", ":", "return", "redirect", "(", "'/'", ")", "oauth_token", "=", "token_getter", "(", "remote", ")", "if", "not", "oauth_...
Handle extra signup information. :param remote: The remote application. :returns: Redirect response or the template rendered.
[ "Handle", "extra", "signup", "information", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L376-L466
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
oauth_logout_handler
def oauth_logout_handler(sender_app, user=None): """Remove all access tokens from session on logout.""" oauth = current_app.extensions['oauthlib.client'] for remote in oauth.remote_apps.values(): token_delete(remote) db.session.commit()
python
def oauth_logout_handler(sender_app, user=None): """Remove all access tokens from session on logout.""" oauth = current_app.extensions['oauthlib.client'] for remote in oauth.remote_apps.values(): token_delete(remote) db.session.commit()
[ "def", "oauth_logout_handler", "(", "sender_app", ",", "user", "=", "None", ")", ":", "oauth", "=", "current_app", ".", "extensions", "[", "'oauthlib.client'", "]", "for", "remote", "in", "oauth", ".", "remote_apps", ".", "values", "(", ")", ":", "token_dele...
Remove all access tokens from session on logout.
[ "Remove", "all", "access", "tokens", "from", "session", "on", "logout", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L469-L474
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/handlers.py
make_handler
def make_handler(f, remote, with_response=True): """Make a handler for authorized and disconnect callbacks. :param f: Callable or an import path to a callable """ if isinstance(f, six.string_types): f = import_string(f) @wraps(f) def inner(*args, **kwargs): if with_response: ...
python
def make_handler(f, remote, with_response=True): """Make a handler for authorized and disconnect callbacks. :param f: Callable or an import path to a callable """ if isinstance(f, six.string_types): f = import_string(f) @wraps(f) def inner(*args, **kwargs): if with_response: ...
[ "def", "make_handler", "(", "f", ",", "remote", ",", "with_response", "=", "True", ")", ":", "if", "isinstance", "(", "f", ",", "six", ".", "string_types", ")", ":", "f", "=", "import_string", "(", "f", ")", "@", "wraps", "(", "f", ")", "def", "inn...
Make a handler for authorized and disconnect callbacks. :param f: Callable or an import path to a callable
[ "Make", "a", "handler", "for", "authorized", "and", "disconnect", "callbacks", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L480-L494
train
SylvanasSun/python-common-cache
common_cache/__init__.py
_enable_lock
def _enable_lock(func): """ The decorator for ensuring thread-safe when current cache instance is concurrent status. """ @functools.wraps(func) def wrapper(*args, **kwargs): self = args[0] if self.is_concurrent: only_read = kwargs.get('only_read') if only_rea...
python
def _enable_lock(func): """ The decorator for ensuring thread-safe when current cache instance is concurrent status. """ @functools.wraps(func) def wrapper(*args, **kwargs): self = args[0] if self.is_concurrent: only_read = kwargs.get('only_read') if only_rea...
[ "def", "_enable_lock", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "if", "self", ".", "is_concurrent", ":", "only_re...
The decorator for ensuring thread-safe when current cache instance is concurrent status.
[ "The", "decorator", "for", "ensuring", "thread", "-", "safe", "when", "current", "cache", "instance", "is", "concurrent", "status", "." ]
f113eb3cd751eed5ab5373e8610a31a444220cf8
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L18-L40
train
SylvanasSun/python-common-cache
common_cache/__init__.py
_enable_cleanup
def _enable_cleanup(func): """ Execute cleanup operation when the decorated function completed. """ @functools.wraps(func) def wrapper(*args, **kwargs): self = args[0] result = func(*args, **kwargs) self.cleanup(self) return result return wrapper
python
def _enable_cleanup(func): """ Execute cleanup operation when the decorated function completed. """ @functools.wraps(func) def wrapper(*args, **kwargs): self = args[0] result = func(*args, **kwargs) self.cleanup(self) return result return wrapper
[ "def", "_enable_cleanup", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "result", "=", "func", "(", "*", "args", ","...
Execute cleanup operation when the decorated function completed.
[ "Execute", "cleanup", "operation", "when", "the", "decorated", "function", "completed", "." ]
f113eb3cd751eed5ab5373e8610a31a444220cf8
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L43-L55
train
SylvanasSun/python-common-cache
common_cache/__init__.py
_enable_thread_pool
def _enable_thread_pool(func): """ Use thread pool for executing a task if self.enable_thread_pool is True. Return an instance of future when flag is_async is True otherwise will to block waiting for the result until timeout then returns the result. """ @functools.wraps(func) def wrapper(*...
python
def _enable_thread_pool(func): """ Use thread pool for executing a task if self.enable_thread_pool is True. Return an instance of future when flag is_async is True otherwise will to block waiting for the result until timeout then returns the result. """ @functools.wraps(func) def wrapper(*...
[ "def", "_enable_thread_pool", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "if", "self", ".", "enable_thread_pool", "an...
Use thread pool for executing a task if self.enable_thread_pool is True. Return an instance of future when flag is_async is True otherwise will to block waiting for the result until timeout then returns the result.
[ "Use", "thread", "pool", "for", "executing", "a", "task", "if", "self", ".", "enable_thread_pool", "is", "True", "." ]
f113eb3cd751eed5ab5373e8610a31a444220cf8
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L58-L86
train
SylvanasSun/python-common-cache
common_cache/__init__.py
Cache.statistic_record
def statistic_record(self, desc=True, timeout=3, is_async=False, only_read=True, *keys): """ Returns a list that each element is a dictionary of the statistic info of the cache item. """ if len(keys) == 0: records = self._generate_statistic_records() else: ...
python
def statistic_record(self, desc=True, timeout=3, is_async=False, only_read=True, *keys): """ Returns a list that each element is a dictionary of the statistic info of the cache item. """ if len(keys) == 0: records = self._generate_statistic_records() else: ...
[ "def", "statistic_record", "(", "self", ",", "desc", "=", "True", ",", "timeout", "=", "3", ",", "is_async", "=", "False", ",", "only_read", "=", "True", ",", "*", "keys", ")", ":", "if", "len", "(", "keys", ")", "==", "0", ":", "records", "=", "...
Returns a list that each element is a dictionary of the statistic info of the cache item.
[ "Returns", "a", "list", "that", "each", "element", "is", "a", "dictionary", "of", "the", "statistic", "info", "of", "the", "cache", "item", "." ]
f113eb3cd751eed5ab5373e8610a31a444220cf8
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L589-L597
train
dourvaris/nano-python
src/nano/ed25519_blake2.py
signature_unsafe
def signature_unsafe(m, sk, pk, hash_func=H): """ Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only. """ h = hash_func(sk) a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2)) r = Hint(bytearray([h[j] for j in...
python
def signature_unsafe(m, sk, pk, hash_func=H): """ Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only. """ h = hash_func(sk) a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2)) r = Hint(bytearray([h[j] for j in...
[ "def", "signature_unsafe", "(", "m", ",", "sk", ",", "pk", ",", "hash_func", "=", "H", ")", ":", "h", "=", "hash_func", "(", "sk", ")", "a", "=", "2", "**", "(", "b", "-", "2", ")", "+", "sum", "(", "2", "**", "i", "*", "bit", "(", "h", "...
Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only.
[ "Not", "safe", "to", "use", "with", "secret", "keys", "or", "secret", "data", ".", "See", "module", "docstring", ".", "This", "function", "should", "be", "used", "for", "testing", "only", "." ]
f26b8bc895b997067780f925049a70e82c0c2479
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/ed25519_blake2.py#L214-L224
train
dourvaris/nano-python
src/nano/ed25519_blake2.py
checkvalid
def checkvalid(s, m, pk): """ Not safe to use when any argument is secret. See module docstring. This function should be used only for verifying public signatures of public messages. """ if len(s) != b // 4: raise ValueError("signature length is wrong") if len(pk) != b // 8: ...
python
def checkvalid(s, m, pk): """ Not safe to use when any argument is secret. See module docstring. This function should be used only for verifying public signatures of public messages. """ if len(s) != b // 4: raise ValueError("signature length is wrong") if len(pk) != b // 8: ...
[ "def", "checkvalid", "(", "s", ",", "m", ",", "pk", ")", ":", "if", "len", "(", "s", ")", "!=", "b", "//", "4", ":", "raise", "ValueError", "(", "\"signature length is wrong\"", ")", "if", "len", "(", "pk", ")", "!=", "b", "//", "8", ":", "raise"...
Not safe to use when any argument is secret. See module docstring. This function should be used only for verifying public signatures of public messages.
[ "Not", "safe", "to", "use", "when", "any", "argument", "is", "secret", ".", "See", "module", "docstring", ".", "This", "function", "should", "be", "used", "only", "for", "verifying", "public", "signatures", "of", "public", "messages", "." ]
f26b8bc895b997067780f925049a70e82c0c2479
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/ed25519_blake2.py#L255-L285
train
prosegrinder/python-cmudict
cmudict/__init__.py
dict
def dict(): """ Compatibility with NLTK. Returns the cmudict lexicon as a dictionary, whose keys are lowercase words and whose values are lists of pronunciations. """ default = defaultdict(list) for key, value in entries(): default[key].append(value) return default
python
def dict(): """ Compatibility with NLTK. Returns the cmudict lexicon as a dictionary, whose keys are lowercase words and whose values are lists of pronunciations. """ default = defaultdict(list) for key, value in entries(): default[key].append(value) return default
[ "def", "dict", "(", ")", ":", "default", "=", "defaultdict", "(", "list", ")", "for", "key", ",", "value", "in", "entries", "(", ")", ":", "default", "[", "key", "]", ".", "append", "(", "value", ")", "return", "default" ]
Compatibility with NLTK. Returns the cmudict lexicon as a dictionary, whose keys are lowercase words and whose values are lists of pronunciations.
[ "Compatibility", "with", "NLTK", ".", "Returns", "the", "cmudict", "lexicon", "as", "a", "dictionary", "whose", "keys", "are", "lowercase", "words", "and", "whose", "values", "are", "lists", "of", "pronunciations", "." ]
e7af7ae9e923add04e14fa303ad44d5abd0cc20a
https://github.com/prosegrinder/python-cmudict/blob/e7af7ae9e923add04e14fa303ad44d5abd0cc20a/cmudict/__init__.py#L42-L51
train
prosegrinder/python-cmudict
cmudict/__init__.py
symbols
def symbols(): """Return a list of symbols.""" symbols = [] for line in symbols_stream(): symbols.append(line.decode('utf-8').strip()) return symbols
python
def symbols(): """Return a list of symbols.""" symbols = [] for line in symbols_stream(): symbols.append(line.decode('utf-8').strip()) return symbols
[ "def", "symbols", "(", ")", ":", "symbols", "=", "[", "]", "for", "line", "in", "symbols_stream", "(", ")", ":", "symbols", ".", "append", "(", "line", ".", "decode", "(", "'utf-8'", ")", ".", "strip", "(", ")", ")", "return", "symbols" ]
Return a list of symbols.
[ "Return", "a", "list", "of", "symbols", "." ]
e7af7ae9e923add04e14fa303ad44d5abd0cc20a
https://github.com/prosegrinder/python-cmudict/blob/e7af7ae9e923add04e14fa303ad44d5abd0cc20a/cmudict/__init__.py#L92-L97
train
mcieslik-mctp/papy
src/papy/core.py
Dagger.connect_inputs
def connect_inputs(self, datas): """ Connects input ``Pipers`` to "datas" input data in the correct order determined, by the ``Piper.ornament`` attribute and the ``Dagger._cmp`` function. It is assumed that the input data is in the form of an iterator and that all inp...
python
def connect_inputs(self, datas): """ Connects input ``Pipers`` to "datas" input data in the correct order determined, by the ``Piper.ornament`` attribute and the ``Dagger._cmp`` function. It is assumed that the input data is in the form of an iterator and that all inp...
[ "def", "connect_inputs", "(", "self", ",", "datas", ")", ":", "start_pipers", "=", "self", ".", "get_inputs", "(", ")", "self", ".", "log", ".", "debug", "(", "'%s trying to connect inputs in the order %s'", "%", "(", "repr", "(", "self", ")", ",", "repr", ...
Connects input ``Pipers`` to "datas" input data in the correct order determined, by the ``Piper.ornament`` attribute and the ``Dagger._cmp`` function. It is assumed that the input data is in the form of an iterator and that all inputs have the same number of input items. A pipeline w...
[ "Connects", "input", "Pipers", "to", "datas", "input", "data", "in", "the", "correct", "order", "determined", "by", "the", "Piper", ".", "ornament", "attribute", "and", "the", "Dagger", ".", "_cmp", "function", "." ]
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L188-L209
train
mcieslik-mctp/papy
src/papy/core.py
Dagger.start
def start(self): """ Given the pipeline topology starts ``Pipers`` in the order input -> output. See ``Piper.start``. ``Pipers`` instances are started in two stages, which allows them to share ``NuMaps``. """ # top - > bottom of pipeline pipers = self.p...
python
def start(self): """ Given the pipeline topology starts ``Pipers`` in the order input -> output. See ``Piper.start``. ``Pipers`` instances are started in two stages, which allows them to share ``NuMaps``. """ # top - > bottom of pipeline pipers = self.p...
[ "def", "start", "(", "self", ")", ":", "pipers", "=", "self", ".", "postorder", "(", ")", "for", "piper", "in", "pipers", ":", "piper", ".", "start", "(", "stages", "=", "(", "0", ",", "1", ")", ")", "for", "piper", "in", "pipers", ":", "piper", ...
Given the pipeline topology starts ``Pipers`` in the order input -> output. See ``Piper.start``. ``Pipers`` instances are started in two stages, which allows them to share ``NuMaps``.
[ "Given", "the", "pipeline", "topology", "starts", "Pipers", "in", "the", "order", "input", "-", ">", "output", ".", "See", "Piper", ".", "start", ".", "Pipers", "instances", "are", "started", "in", "two", "stages", "which", "allows", "them", "to", "share",...
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L234-L247
train
mcieslik-mctp/papy
src/papy/core.py
Dagger.stop
def stop(self): """ Stops the ``Pipers`` according to pipeline topology. """ self.log.debug('%s begins stopping routine' % repr(self)) self.log.debug('%s triggers stopping in input pipers' % repr(self)) inputs = self.get_inputs() for piper in inputs: ...
python
def stop(self): """ Stops the ``Pipers`` according to pipeline topology. """ self.log.debug('%s begins stopping routine' % repr(self)) self.log.debug('%s triggers stopping in input pipers' % repr(self)) inputs = self.get_inputs() for piper in inputs: ...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "'%s begins stopping routine'", "%", "repr", "(", "self", ")", ")", "self", ".", "log", ".", "debug", "(", "'%s triggers stopping in input pipers'", "%", "repr", "(", "self", ")",...
Stops the ``Pipers`` according to pipeline topology.
[ "Stops", "the", "Pipers", "according", "to", "pipeline", "topology", "." ]
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L249-L283
train
mcieslik-mctp/papy
src/papy/core.py
Dagger.del_piper
def del_piper(self, piper, forced=False): """ Removes a ``Piper`` from the ``Dagger`` instance. Arguments: - piper(``Piper`` or id(``Piper``)) ``Piper`` instance or ``Piper`` instance id. - forced(bool) [default: ``False``] If "forced" is ``True``, wil...
python
def del_piper(self, piper, forced=False): """ Removes a ``Piper`` from the ``Dagger`` instance. Arguments: - piper(``Piper`` or id(``Piper``)) ``Piper`` instance or ``Piper`` instance id. - forced(bool) [default: ``False``] If "forced" is ``True``, wil...
[ "def", "del_piper", "(", "self", ",", "piper", ",", "forced", "=", "False", ")", ":", "self", ".", "log", ".", "debug", "(", "'%s trying to delete piper %s'", "%", "(", "repr", "(", "self", ")", ",", "repr", "(", "piper", ")", ")", ")", "try", ":", ...
Removes a ``Piper`` from the ``Dagger`` instance. Arguments: - piper(``Piper`` or id(``Piper``)) ``Piper`` instance or ``Piper`` instance id. - forced(bool) [default: ``False``] If "forced" is ``True``, will not raise a ``DaggerError`` if the ``Piper`` ha...
[ "Removes", "a", "Piper", "from", "the", "Dagger", "instance", "." ]
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L346-L374
train
mcieslik-mctp/papy
src/papy/core.py
Plumber.start
def start(self, datas): """ Starts the pipeline by connecting the input ``Pipers`` of the pipeline to the input data, connecting the pipeline and starting the ``NuMap`` instances. The order of items in the "datas" argument sequence should correspond to the orde...
python
def start(self, datas): """ Starts the pipeline by connecting the input ``Pipers`` of the pipeline to the input data, connecting the pipeline and starting the ``NuMap`` instances. The order of items in the "datas" argument sequence should correspond to the orde...
[ "def", "start", "(", "self", ",", "datas", ")", ":", "if", "not", "self", ".", "_started", ".", "isSet", "(", ")", "and", "not", "self", ".", "_running", ".", "isSet", "(", ")", "and", "not", "self", ".", "_pausing", ".", "isSet", "(", ")", ":", ...
Starts the pipeline by connecting the input ``Pipers`` of the pipeline to the input data, connecting the pipeline and starting the ``NuMap`` instances. The order of items in the "datas" argument sequence should correspond to the order of the input ``Pipers`` defined by ``Dagge...
[ "Starts", "the", "pipeline", "by", "connecting", "the", "input", "Pipers", "of", "the", "pipeline", "to", "the", "input", "data", "connecting", "the", "pipeline", "and", "starting", "the", "NuMap", "instances", ".", "The", "order", "of", "items", "in", "the"...
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L650-L692
train
mcieslik-mctp/papy
src/papy/core.py
Plumber.pause
def pause(self): """ Pauses a running pipeline. This will stop retrieving results from the pipeline. Parallel parts of the pipeline will stop after the ``NuMap`` buffer is has been filled. A paused pipeline can be run or stopped. """ # 1. stop the plumbing thr...
python
def pause(self): """ Pauses a running pipeline. This will stop retrieving results from the pipeline. Parallel parts of the pipeline will stop after the ``NuMap`` buffer is has been filled. A paused pipeline can be run or stopped. """ # 1. stop the plumbing thr...
[ "def", "pause", "(", "self", ")", ":", "if", "self", ".", "_started", ".", "isSet", "(", ")", "and", "self", ".", "_running", ".", "isSet", "(", ")", "and", "not", "self", ".", "_pausing", ".", "isSet", "(", ")", ":", "self", ".", "_pausing", "."...
Pauses a running pipeline. This will stop retrieving results from the pipeline. Parallel parts of the pipeline will stop after the ``NuMap`` buffer is has been filled. A paused pipeline can be run or stopped.
[ "Pauses", "a", "running", "pipeline", ".", "This", "will", "stop", "retrieving", "results", "from", "the", "pipeline", ".", "Parallel", "parts", "of", "the", "pipeline", "will", "stop", "after", "the", "NuMap", "buffer", "is", "has", "been", "filled", ".", ...
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L737-L755
train
mcieslik-mctp/papy
src/papy/core.py
Plumber.stop
def stop(self): """ Stops a paused pipeline. This will a trigger a ``StopIteration`` in the inputs of the pipeline. And retrieve the buffered results. This will stop all ``Pipers`` and ``NuMaps``. Python will not terminate cleanly if a pipeline is running or paused. ...
python
def stop(self): """ Stops a paused pipeline. This will a trigger a ``StopIteration`` in the inputs of the pipeline. And retrieve the buffered results. This will stop all ``Pipers`` and ``NuMaps``. Python will not terminate cleanly if a pipeline is running or paused. ...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_started", ".", "isSet", "(", ")", "and", "not", "self", ".", "_running", ".", "isSet", "(", ")", "and", "not", "self", ".", "_pausing", ".", "isSet", "(", ")", ":", "super", "(", "Plumber...
Stops a paused pipeline. This will a trigger a ``StopIteration`` in the inputs of the pipeline. And retrieve the buffered results. This will stop all ``Pipers`` and ``NuMaps``. Python will not terminate cleanly if a pipeline is running or paused.
[ "Stops", "a", "paused", "pipeline", ".", "This", "will", "a", "trigger", "a", "StopIteration", "in", "the", "inputs", "of", "the", "pipeline", ".", "And", "retrieve", "the", "buffered", "results", ".", "This", "will", "stop", "all", "Pipers", "and", "NuMap...
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L757-L775
train
mcieslik-mctp/papy
src/papy/core.py
_Consume.next
def next(self): """ Returns the next sequence of results, given stride and n. """ try: results = self._stride_buffer.pop() except (IndexError, AttributeError): self._rebuffer() results = self._stride_buffer.pop() if not results...
python
def next(self): """ Returns the next sequence of results, given stride and n. """ try: results = self._stride_buffer.pop() except (IndexError, AttributeError): self._rebuffer() results = self._stride_buffer.pop() if not results...
[ "def", "next", "(", "self", ")", ":", "try", ":", "results", "=", "self", ".", "_stride_buffer", ".", "pop", "(", ")", "except", "(", "IndexError", ",", "AttributeError", ")", ":", "self", ".", "_rebuffer", "(", ")", "results", "=", "self", ".", "_st...
Returns the next sequence of results, given stride and n.
[ "Returns", "the", "next", "sequence", "of", "results", "given", "stride", "and", "n", "." ]
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1490-L1502
train
mcieslik-mctp/papy
src/papy/core.py
_Chain.next
def next(self): """ Returns the next result from the chained iterables given ``"stride"``. """ if self.s: self.s -= 1 else: self.s = self.stride - 1 self.i = (self.i + 1) % self.l # new iterable return self.iterables[self.i].ne...
python
def next(self): """ Returns the next result from the chained iterables given ``"stride"``. """ if self.s: self.s -= 1 else: self.s = self.stride - 1 self.i = (self.i + 1) % self.l # new iterable return self.iterables[self.i].ne...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "s", ":", "self", ".", "s", "-=", "1", "else", ":", "self", ".", "s", "=", "self", ".", "stride", "-", "1", "self", ".", "i", "=", "(", "self", ".", "i", "+", "1", ")", "%", "self",...
Returns the next result from the chained iterables given ``"stride"``.
[ "Returns", "the", "next", "result", "from", "the", "chained", "iterables", "given", "stride", "." ]
708e50827b5db46bbea081982cb74b9b0e464064
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1557-L1567
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.list_csv
def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of results as CSV. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) S...
python
def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of results as CSV. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) S...
[ "def", "list_csv", "(", "self", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "sort", "=", "None", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "return", "self", ".", "service", ".", "list", "(", "self", ".", "base"...
Get a list of results as CSV. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (option...
[ "Get", "a", "list", "of", "results", "as", "CSV", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L600-L610
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.updates
def updates(self, id, update_id=None): # pylint: disable=invalid-name,redefined-builtin """Get updates of a running result via long-polling. If no updates are available, CDRouter waits up to 10 seconds before sending an empty response. :param id: Result ID as an int. :param update_id: (optiona...
python
def updates(self, id, update_id=None): # pylint: disable=invalid-name,redefined-builtin """Get updates of a running result via long-polling. If no updates are available, CDRouter waits up to 10 seconds before sending an empty response. :param id: Result ID as an int. :param update_id: (optiona...
[ "def", "updates", "(", "self", ",", "id", ",", "update_id", "=", "None", ")", ":", "if", "update_id", "is", "None", ":", "update_id", "=", "-", "1", "schema", "=", "UpdateSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get_id", "(", "...
Get updates of a running result via long-polling. If no updates are available, CDRouter waits up to 10 seconds before sending an empty response. :param id: Result ID as an int. :param update_id: (optional) Update ID as an int. :return: :class:`results.Update <results.Update>` object :r...
[ "Get", "updates", "of", "a", "running", "result", "via", "long", "-", "polling", ".", "If", "no", "updates", "are", "available", "CDRouter", "waits", "up", "to", "10", "seconds", "before", "sending", "an", "empty", "response", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L623-L636
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.pause
def pause(self, id, when=None): # pylint: disable=invalid-name,redefined-builtin """Pause a running result. :param id: Result ID as an int. :param when: Must be string `end-of-test` or `end-of-loop`. """ return self.service.post(self.base+str(id)+'/pause/', params={'when': when}...
python
def pause(self, id, when=None): # pylint: disable=invalid-name,redefined-builtin """Pause a running result. :param id: Result ID as an int. :param when: Must be string `end-of-test` or `end-of-loop`. """ return self.service.post(self.base+str(id)+'/pause/', params={'when': when}...
[ "def", "pause", "(", "self", ",", "id", ",", "when", "=", "None", ")", ":", "return", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/pause/'", ",", "params", "=", "{", "'when'", ":", "when", "...
Pause a running result. :param id: Result ID as an int. :param when: Must be string `end-of-test` or `end-of-loop`.
[ "Pause", "a", "running", "result", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L660-L666
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.unpause
def unpause(self, id): # pylint: disable=invalid-name,redefined-builtin """Unpause a running result. :param id: Result ID as an int. """ return self.service.post(self.base+str(id)+'/unpause/')
python
def unpause(self, id): # pylint: disable=invalid-name,redefined-builtin """Unpause a running result. :param id: Result ID as an int. """ return self.service.post(self.base+str(id)+'/unpause/')
[ "def", "unpause", "(", "self", ",", "id", ")", ":", "return", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/unpause/'", ")" ]
Unpause a running result. :param id: Result ID as an int.
[ "Unpause", "a", "running", "result", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L682-L687
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.export
def export(self, id, exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin """Export a result. :param id: Result ID as an int. :param exclude_captures: If bool `True`, don't export capture files :rtype: tuple `(io.BytesIO, 'filename')` """ return self...
python
def export(self, id, exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin """Export a result. :param id: Result ID as an int. :param exclude_captures: If bool `True`, don't export capture files :rtype: tuple `(io.BytesIO, 'filename')` """ return self...
[ "def", "export", "(", "self", ",", "id", ",", "exclude_captures", "=", "False", ")", ":", "return", "self", ".", "service", ".", "export", "(", "self", ".", "base", ",", "id", ",", "params", "=", "{", "'exclude_captures'", ":", "exclude_captures", "}", ...
Export a result. :param id: Result ID as an int. :param exclude_captures: If bool `True`, don't export capture files :rtype: tuple `(io.BytesIO, 'filename')`
[ "Export", "a", "result", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L727-L734
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.bulk_export
def bulk_export(self, ids, exclude_captures=False): """Bulk export a set of results. :param ids: Int list of result IDs. :rtype: tuple `(io.BytesIO, 'filename')` """ return self.service.bulk_export(self.base, ids, params={'exclude_captures': exclude_captures})
python
def bulk_export(self, ids, exclude_captures=False): """Bulk export a set of results. :param ids: Int list of result IDs. :rtype: tuple `(io.BytesIO, 'filename')` """ return self.service.bulk_export(self.base, ids, params={'exclude_captures': exclude_captures})
[ "def", "bulk_export", "(", "self", ",", "ids", ",", "exclude_captures", "=", "False", ")", ":", "return", "self", ".", "service", ".", "bulk_export", "(", "self", ".", "base", ",", "ids", ",", "params", "=", "{", "'exclude_captures'", ":", "exclude_capture...
Bulk export a set of results. :param ids: Int list of result IDs. :rtype: tuple `(io.BytesIO, 'filename')`
[ "Bulk", "export", "a", "set", "of", "results", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L736-L742
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.bulk_copy
def bulk_copy(self, ids): """Bulk copy a set of results. :param ids: Int list of result IDs. :return: :class:`results.Result <results.Result>` list """ schema = ResultSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
python
def bulk_copy(self, ids): """Bulk copy a set of results. :param ids: Int list of result IDs. :return: :class:`results.Result <results.Result>` list """ schema = ResultSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
[ "def", "bulk_copy", "(", "self", ",", "ids", ")", ":", "schema", "=", "ResultSchema", "(", ")", "return", "self", ".", "service", ".", "bulk_copy", "(", "self", ".", "base", ",", "self", ".", "RESOURCE", ",", "ids", ",", "schema", ")" ]
Bulk copy a set of results. :param ids: Int list of result IDs. :return: :class:`results.Result <results.Result>` list
[ "Bulk", "copy", "a", "set", "of", "results", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L744-L751
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.all_stats
def all_stats(self): """Compute stats for all results. :return: :class:`results.AllStats <results.AllStats>` object :rtype: results.AllStats """ schema = AllStatsSchema() resp = self.service.post(self.base, params={'stats': 'all'}) return self.service.decode(sche...
python
def all_stats(self): """Compute stats for all results. :return: :class:`results.AllStats <results.AllStats>` object :rtype: results.AllStats """ schema = AllStatsSchema() resp = self.service.post(self.base, params={'stats': 'all'}) return self.service.decode(sche...
[ "def", "all_stats", "(", "self", ")", ":", "schema", "=", "AllStatsSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'stats'", ":", "'all'", "}", ")", "return", "self", ".", "se...
Compute stats for all results. :return: :class:`results.AllStats <results.AllStats>` object :rtype: results.AllStats
[ "Compute", "stats", "for", "all", "results", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L776-L784
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.set_stats
def set_stats(self, ids): """Compute stats for a set of results. :param id: Result IDs as int list. :return: :class:`results.SetStats <results.SetStats>` object :rtype: results.SetStats """ schema = SetStatsSchema() resp = self.service.post(self.base, params={'st...
python
def set_stats(self, ids): """Compute stats for a set of results. :param id: Result IDs as int list. :return: :class:`results.SetStats <results.SetStats>` object :rtype: results.SetStats """ schema = SetStatsSchema() resp = self.service.post(self.base, params={'st...
[ "def", "set_stats", "(", "self", ",", "ids", ")", ":", "schema", "=", "SetStatsSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'stats'", ":", "'set'", "}", ",", "json", "=", ...
Compute stats for a set of results. :param id: Result IDs as int list. :return: :class:`results.SetStats <results.SetStats>` object :rtype: results.SetStats
[ "Compute", "stats", "for", "a", "set", "of", "results", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L786-L795
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.diff_stats
def diff_stats(self, ids): """Compute diff stats for a set of results. :param id: Result IDs as int list. :return: :class:`results.DiffStats <results.DiffStats>` object :rtype: results.DiffStats """ schema = DiffStatsSchema() resp = self.service.post(self.base, p...
python
def diff_stats(self, ids): """Compute diff stats for a set of results. :param id: Result IDs as int list. :return: :class:`results.DiffStats <results.DiffStats>` object :rtype: results.DiffStats """ schema = DiffStatsSchema() resp = self.service.post(self.base, p...
[ "def", "diff_stats", "(", "self", ",", "ids", ")", ":", "schema", "=", "DiffStatsSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'stats'", ":", "'diff'", "}", ",", "json", "="...
Compute diff stats for a set of results. :param id: Result IDs as int list. :return: :class:`results.DiffStats <results.DiffStats>` object :rtype: results.DiffStats
[ "Compute", "diff", "stats", "for", "a", "set", "of", "results", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L797-L806
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.single_stats
def single_stats(self, id): # pylint: disable=invalid-name,redefined-builtin """Compute stats for a result. :param id: Result ID as an int. :return: :class:`results.SingleStats <results.SingleStats>` object :rtype: results.SingleStats """ schema = SingleStatsSchema() ...
python
def single_stats(self, id): # pylint: disable=invalid-name,redefined-builtin """Compute stats for a result. :param id: Result ID as an int. :return: :class:`results.SingleStats <results.SingleStats>` object :rtype: results.SingleStats """ schema = SingleStatsSchema() ...
[ "def", "single_stats", "(", "self", ",", "id", ")", ":", "schema", "=", "SingleStatsSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/'", ",", "params", "=", "{", "'s...
Compute stats for a result. :param id: Result ID as an int. :return: :class:`results.SingleStats <results.SingleStats>` object :rtype: results.SingleStats
[ "Compute", "stats", "for", "a", "result", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L808-L817
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.progress_stats
def progress_stats(self, id): # pylint: disable=invalid-name,redefined-builtin """Compute progress stats for a result. :param id: Result ID as an int. :return: :class:`results.Progress <results.Progress>` object :rtype: results.Progress """ schema = ProgressSchema() ...
python
def progress_stats(self, id): # pylint: disable=invalid-name,redefined-builtin """Compute progress stats for a result. :param id: Result ID as an int. :return: :class:`results.Progress <results.Progress>` object :rtype: results.Progress """ schema = ProgressSchema() ...
[ "def", "progress_stats", "(", "self", ",", "id", ")", ":", "schema", "=", "ProgressSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/'", ",", "params", "=", "{", "'st...
Compute progress stats for a result. :param id: Result ID as an int. :return: :class:`results.Progress <results.Progress>` object :rtype: results.Progress
[ "Compute", "progress", "stats", "for", "a", "result", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L819-L828
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.summary_stats
def summary_stats(self, id): # pylint: disable=invalid-name,redefined-builtin """Compute summary stats for a result. :param id: Result ID as an int. :return: :class:`results.SummaryStats <results.SummaryStats>` object :rtype: results.SummaryStats """ schema = SummaryStat...
python
def summary_stats(self, id): # pylint: disable=invalid-name,redefined-builtin """Compute summary stats for a result. :param id: Result ID as an int. :return: :class:`results.SummaryStats <results.SummaryStats>` object :rtype: results.SummaryStats """ schema = SummaryStat...
[ "def", "summary_stats", "(", "self", ",", "id", ")", ":", "schema", "=", "SummaryStatsSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/'", ",", "params", "=", "{", "...
Compute summary stats for a result. :param id: Result ID as an int. :return: :class:`results.SummaryStats <results.SummaryStats>` object :rtype: results.SummaryStats
[ "Compute", "summary", "stats", "for", "a", "result", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L830-L839
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.list_logdir
def list_logdir(self, id, filter=None, sort=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of logdir files. :param id: Result ID as an int. :param filter: Filter to apply as string. :param sort: Sort field to apply as string. :return: :class:`results.LogDi...
python
def list_logdir(self, id, filter=None, sort=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of logdir files. :param id: Result ID as an int. :param filter: Filter to apply as string. :param sort: Sort field to apply as string. :return: :class:`results.LogDi...
[ "def", "list_logdir", "(", "self", ",", "id", ",", "filter", "=", "None", ",", "sort", "=", "None", ")", ":", "schema", "=", "LogDirFileSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "list", "(", "self", ".", "base", "+", "str", "(", ...
Get a list of logdir files. :param id: Result ID as an int. :param filter: Filter to apply as string. :param sort: Sort field to apply as string. :return: :class:`results.LogDirFile <results.LogDirFile>` list
[ "Get", "a", "list", "of", "logdir", "files", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L841-L851
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.get_logdir_file
def get_logdir_file(self, id, filename): # pylint: disable=invalid-name,redefined-builtin """Download a logdir file. :param id: Result ID as an int. :param filename: Logdir filename as string. :rtype: tuple `(io.BytesIO, 'filename')` """ resp = self.service.get(self.base...
python
def get_logdir_file(self, id, filename): # pylint: disable=invalid-name,redefined-builtin """Download a logdir file. :param id: Result ID as an int. :param filename: Logdir filename as string. :rtype: tuple `(io.BytesIO, 'filename')` """ resp = self.service.get(self.base...
[ "def", "get_logdir_file", "(", "self", ",", "id", ",", "filename", ")", ":", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/logdir/'", "+", "filename", "+", "'/'", ",", "stream", "=", ...
Download a logdir file. :param id: Result ID as an int. :param filename: Logdir filename as string. :rtype: tuple `(io.BytesIO, 'filename')`
[ "Download", "a", "logdir", "file", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L853-L865
train
qacafe/cdrouter.py
cdrouter/results.py
ResultsService.download_logdir_archive
def download_logdir_archive(self, id, format='zip', exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin """Download logdir archive in tgz or zip format. :param id: Result ID as an int. :param format: (optional) Format to download, must be string `zip` or `tgz`. :pa...
python
def download_logdir_archive(self, id, format='zip', exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin """Download logdir archive in tgz or zip format. :param id: Result ID as an int. :param format: (optional) Format to download, must be string `zip` or `tgz`. :pa...
[ "def", "download_logdir_archive", "(", "self", ",", "id", ",", "format", "=", "'zip'", ",", "exclude_captures", "=", "False", ")", ":", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/log...
Download logdir archive in tgz or zip format. :param id: Result ID as an int. :param format: (optional) Format to download, must be string `zip` or `tgz`. :param exclude_captures: If bool `True`, don't include capture files :rtype: tuple `(io.BytesIO, 'filename')`
[ "Download", "logdir", "archive", "in", "tgz", "or", "zip", "format", "." ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L867-L880
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/contrib/cern.py
logout
def logout(): """CERN logout view.""" logout_url = REMOTE_APP['logout_url'] apps = current_app.config.get('OAUTHCLIENT_REMOTE_APPS') if apps: cern_app = apps.get('cern', REMOTE_APP) logout_url = cern_app['logout_url'] return redirect(logout_url, code=302)
python
def logout(): """CERN logout view.""" logout_url = REMOTE_APP['logout_url'] apps = current_app.config.get('OAUTHCLIENT_REMOTE_APPS') if apps: cern_app = apps.get('cern', REMOTE_APP) logout_url = cern_app['logout_url'] return redirect(logout_url, code=302)
[ "def", "logout", "(", ")", ":", "logout_url", "=", "REMOTE_APP", "[", "'logout_url'", "]", "apps", "=", "current_app", ".", "config", ".", "get", "(", "'OAUTHCLIENT_REMOTE_APPS'", ")", "if", "apps", ":", "cern_app", "=", "apps", ".", "get", "(", "'cern'", ...
CERN logout view.
[ "CERN", "logout", "view", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L178-L187
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/contrib/cern.py
find_remote_by_client_id
def find_remote_by_client_id(client_id): """Return a remote application based with given client ID.""" for remote in current_oauthclient.oauth.remote_apps.values(): if remote.name == 'cern' and remote.consumer_key == client_id: return remote
python
def find_remote_by_client_id(client_id): """Return a remote application based with given client ID.""" for remote in current_oauthclient.oauth.remote_apps.values(): if remote.name == 'cern' and remote.consumer_key == client_id: return remote
[ "def", "find_remote_by_client_id", "(", "client_id", ")", ":", "for", "remote", "in", "current_oauthclient", ".", "oauth", ".", "remote_apps", ".", "values", "(", ")", ":", "if", "remote", ".", "name", "==", "'cern'", "and", "remote", ".", "consumer_key", "=...
Return a remote application based with given client ID.
[ "Return", "a", "remote", "application", "based", "with", "given", "client", "ID", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L190-L194
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/contrib/cern.py
fetch_groups
def fetch_groups(groups): """Prepare list of allowed group names. :param groups: The complete list of groups. :returns: A filtered list of groups. """ hidden_groups = current_app.config.get( 'OAUTHCLIENT_CERN_HIDDEN_GROUPS', OAUTHCLIENT_CERN_HIDDEN_GROUPS) hidden_groups_re = current_app...
python
def fetch_groups(groups): """Prepare list of allowed group names. :param groups: The complete list of groups. :returns: A filtered list of groups. """ hidden_groups = current_app.config.get( 'OAUTHCLIENT_CERN_HIDDEN_GROUPS', OAUTHCLIENT_CERN_HIDDEN_GROUPS) hidden_groups_re = current_app...
[ "def", "fetch_groups", "(", "groups", ")", ":", "hidden_groups", "=", "current_app", ".", "config", ".", "get", "(", "'OAUTHCLIENT_CERN_HIDDEN_GROUPS'", ",", "OAUTHCLIENT_CERN_HIDDEN_GROUPS", ")", "hidden_groups_re", "=", "current_app", ".", "config", ".", "get", "(...
Prepare list of allowed group names. :param groups: The complete list of groups. :returns: A filtered list of groups.
[ "Prepare", "list", "of", "allowed", "group", "names", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L197-L216
train
inveniosoftware/invenio-oauthclient
invenio_oauthclient/contrib/cern.py
fetch_extra_data
def fetch_extra_data(resource): """Return a dict with extra data retrieved from cern oauth.""" person_id = resource.get('PersonID', [None])[0] identity_class = resource.get('IdentityClass', [None])[0] department = resource.get('Department', [None])[0] return dict( person_id=person_id, ...
python
def fetch_extra_data(resource): """Return a dict with extra data retrieved from cern oauth.""" person_id = resource.get('PersonID', [None])[0] identity_class = resource.get('IdentityClass', [None])[0] department = resource.get('Department', [None])[0] return dict( person_id=person_id, ...
[ "def", "fetch_extra_data", "(", "resource", ")", ":", "person_id", "=", "resource", ".", "get", "(", "'PersonID'", ",", "[", "None", "]", ")", "[", "0", "]", "identity_class", "=", "resource", ".", "get", "(", "'IdentityClass'", ",", "[", "None", "]", ...
Return a dict with extra data retrieved from cern oauth.
[ "Return", "a", "dict", "with", "extra", "data", "retrieved", "from", "cern", "oauth", "." ]
2500dc6935738107617aeade79e050d7608004bb
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L219-L229
train