repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
OpenVolunteeringPlatform/django-ovp-projects
ovp_projects/decorators.py
hide_address
def hide_address(func): """ Used to decorate Serializer.to_representation method. It hides the address field if the Project has 'hidden_address' == True and the request user is neither owner or member of the organization """ @wraps(func) def _impl(self, instance): # We pop address field to avoid A...
python
def hide_address(func): """ Used to decorate Serializer.to_representation method. It hides the address field if the Project has 'hidden_address' == True and the request user is neither owner or member of the organization """ @wraps(func) def _impl(self, instance): # We pop address field to avoid A...
[ "def", "hide_address", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "_impl", "(", "self", ",", "instance", ")", ":", "# We pop address field to avoid AttributeError on default Serializer.to_representation", "if", "instance", ".", "hidden_address", ":"...
Used to decorate Serializer.to_representation method. It hides the address field if the Project has 'hidden_address' == True and the request user is neither owner or member of the organization
[ "Used", "to", "decorate", "Serializer", ".", "to_representation", "method", ".", "It", "hides", "the", "address", "field", "if", "the", "Project", "has", "hidden_address", "==", "True", "and", "the", "request", "user", "is", "neither", "owner", "or", "member",...
train
https://github.com/OpenVolunteeringPlatform/django-ovp-projects/blob/239e27027ca99c7b44ee4f30bf55d06439d49251/ovp_projects/decorators.py#L5-L40
OpenVolunteeringPlatform/django-ovp-projects
ovp_projects/decorators.py
add_current_user_is_applied_representation
def add_current_user_is_applied_representation(func): """ Used to decorate Serializer.to_representation method. It sets the field "current_user_is_applied" if the user is applied to the project """ @wraps(func) def _impl(self, instance): # We pop current_user_is_applied field to avoid AttributeError o...
python
def add_current_user_is_applied_representation(func): """ Used to decorate Serializer.to_representation method. It sets the field "current_user_is_applied" if the user is applied to the project """ @wraps(func) def _impl(self, instance): # We pop current_user_is_applied field to avoid AttributeError o...
[ "def", "add_current_user_is_applied_representation", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "_impl", "(", "self", ",", "instance", ")", ":", "# We pop current_user_is_applied field to avoid AttributeError on default Serializer.to_representation", "ret",...
Used to decorate Serializer.to_representation method. It sets the field "current_user_is_applied" if the user is applied to the project
[ "Used", "to", "decorate", "Serializer", ".", "to_representation", "method", ".", "It", "sets", "the", "field", "current_user_is_applied", "if", "the", "user", "is", "applied", "to", "the", "project" ]
train
https://github.com/OpenVolunteeringPlatform/django-ovp-projects/blob/239e27027ca99c7b44ee4f30bf55d06439d49251/ovp_projects/decorators.py#L43-L63
klorenz/python-argdeco
argdeco/main.py
Main.configure
def configure(self, debug=None, quiet=None, verbosity=None, compile=None, compiler_factory=None, **kwargs): """configure managed args """ if debug is not None: self.arg_debug = debug if quiet is not None: self.arg_quiet = quiet if verbosity is not None: ...
python
def configure(self, debug=None, quiet=None, verbosity=None, compile=None, compiler_factory=None, **kwargs): """configure managed args """ if debug is not None: self.arg_debug = debug if quiet is not None: self.arg_quiet = quiet if verbosity is not None: ...
[ "def", "configure", "(", "self", ",", "debug", "=", "None", ",", "quiet", "=", "None", ",", "verbosity", "=", "None", ",", "compile", "=", "None", ",", "compiler_factory", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "debug", "is", "not", ...
configure managed args
[ "configure", "managed", "args" ]
train
https://github.com/klorenz/python-argdeco/blob/8d01acef8c19d6883873689d017b14857876412d/argdeco/main.py#L212-L228
klorenz/python-argdeco
argdeco/main.py
Main.uninstall_bash_completion
def uninstall_bash_completion(self, script_name=None, dest="~/.bashrc"): '''remove line to activate bash_completion for given script_name from given dest You can use this for letting the user uninstall bash_completion:: from argdeco import command, main @command("uninstall-bas...
python
def uninstall_bash_completion(self, script_name=None, dest="~/.bashrc"): '''remove line to activate bash_completion for given script_name from given dest You can use this for letting the user uninstall bash_completion:: from argdeco import command, main @command("uninstall-bas...
[ "def", "uninstall_bash_completion", "(", "self", ",", "script_name", "=", "None", ",", "dest", "=", "\"~/.bashrc\"", ")", ":", "if", "'USERPROFILE'", "in", "os", ".", "environ", "and", "'HOME'", "not", "in", "os", ".", "environ", ":", "os", ".", "environ",...
remove line to activate bash_completion for given script_name from given dest You can use this for letting the user uninstall bash_completion:: from argdeco import command, main @command("uninstall-bash-completion", arg('--dest', help="destination", default="~/.bashrc"...
[ "remove", "line", "to", "activate", "bash_completion", "for", "given", "script_name", "from", "given", "dest" ]
train
https://github.com/klorenz/python-argdeco/blob/8d01acef8c19d6883873689d017b14857876412d/argdeco/main.py#L289-L318
klorenz/python-argdeco
argdeco/main.py
Main.install_bash_completion
def install_bash_completion(self, script_name=None, dest="~/.bashrc"): '''add line to activate bash_completion for given script_name into dest You can use this for letting the user install bash_completion:: from argdeco import command, main @command("install-bash-completion", ...
python
def install_bash_completion(self, script_name=None, dest="~/.bashrc"): '''add line to activate bash_completion for given script_name into dest You can use this for letting the user install bash_completion:: from argdeco import command, main @command("install-bash-completion", ...
[ "def", "install_bash_completion", "(", "self", ",", "script_name", "=", "None", ",", "dest", "=", "\"~/.bashrc\"", ")", ":", "if", "'USERPROFILE'", "in", "os", ".", "environ", "and", "'HOME'", "not", "in", "os", ".", "environ", ":", "os", ".", "environ", ...
add line to activate bash_completion for given script_name into dest You can use this for letting the user install bash_completion:: from argdeco import command, main @command("install-bash-completion", arg('--dest', help="destination", default="~/.bashrc") ...
[ "add", "line", "to", "activate", "bash_completion", "for", "given", "script_name", "into", "dest" ]
train
https://github.com/klorenz/python-argdeco/blob/8d01acef8c19d6883873689d017b14857876412d/argdeco/main.py#L320-L342
refinery29/chassis
chassis/util/params.py
_fetch_arguments
def _fetch_arguments(handler, method): """Get the arguments depending on the type of HTTP method.""" if method.__name__ == 'get': arguments = {} for key, value in six.iteritems(handler.request.arguments): # Tornado supports comma-separated lists of values in # parameters...
python
def _fetch_arguments(handler, method): """Get the arguments depending on the type of HTTP method.""" if method.__name__ == 'get': arguments = {} for key, value in six.iteritems(handler.request.arguments): # Tornado supports comma-separated lists of values in # parameters...
[ "def", "_fetch_arguments", "(", "handler", ",", "method", ")", ":", "if", "method", ".", "__name__", "==", "'get'", ":", "arguments", "=", "{", "}", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "handler", ".", "request", ".", "argume...
Get the arguments depending on the type of HTTP method.
[ "Get", "the", "arguments", "depending", "on", "the", "type", "of", "HTTP", "method", "." ]
train
https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/params.py#L10-L26
refinery29/chassis
chassis/util/params.py
_apply_validator_chain
def _apply_validator_chain(chain, value, handler): """Apply validators in sequence to a value.""" if hasattr(chain, 'validate'): # not a list chain = [chain, ] for validator in chain: if hasattr(validator, 'validate'): value = validator.validate(value, handler) else: ...
python
def _apply_validator_chain(chain, value, handler): """Apply validators in sequence to a value.""" if hasattr(chain, 'validate'): # not a list chain = [chain, ] for validator in chain: if hasattr(validator, 'validate'): value = validator.validate(value, handler) else: ...
[ "def", "_apply_validator_chain", "(", "chain", ",", "value", ",", "handler", ")", ":", "if", "hasattr", "(", "chain", ",", "'validate'", ")", ":", "# not a list", "chain", "=", "[", "chain", ",", "]", "for", "validator", "in", "chain", ":", "if", "hasatt...
Apply validators in sequence to a value.
[ "Apply", "validators", "in", "sequence", "to", "a", "value", "." ]
train
https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/params.py#L29-L40
refinery29/chassis
chassis/util/params.py
_parse_arguments
def _parse_arguments(self, method, parameters): """Parse arguments to method, returning a dictionary.""" # TODO: Consider raising an exception if there are extra arguments. arguments = _fetch_arguments(self, method) arg_dict = {} errors = [] for key, properties in parameters: if key i...
python
def _parse_arguments(self, method, parameters): """Parse arguments to method, returning a dictionary.""" # TODO: Consider raising an exception if there are extra arguments. arguments = _fetch_arguments(self, method) arg_dict = {} errors = [] for key, properties in parameters: if key i...
[ "def", "_parse_arguments", "(", "self", ",", "method", ",", "parameters", ")", ":", "# TODO: Consider raising an exception if there are extra arguments.", "arguments", "=", "_fetch_arguments", "(", "self", ",", "method", ")", "arg_dict", "=", "{", "}", "errors", "=", ...
Parse arguments to method, returning a dictionary.
[ "Parse", "arguments", "to", "method", "returning", "a", "dictionary", "." ]
train
https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/params.py#L43-L75
refinery29/chassis
chassis/util/params.py
parse
def parse(parameters): """Decorator to parse parameters according to a set of criteria. This outer method is called to set up the decorator. Arguments: parameters: An array of parameter declarations tuples in the format: ('<param_name>', {'validate': [<ValidatorClass>,...], <options...>}) ...
python
def parse(parameters): """Decorator to parse parameters according to a set of criteria. This outer method is called to set up the decorator. Arguments: parameters: An array of parameter declarations tuples in the format: ('<param_name>', {'validate': [<ValidatorClass>,...], <options...>}) ...
[ "def", "parse", "(", "parameters", ")", ":", "# pylint: disable=protected-access", "@", "decorators", ".", "include_original", "def", "decorate", "(", "method", ")", ":", "\"\"\"Setup returns this decorator, which is called on the method.\"\"\"", "def", "call", "(", "self",...
Decorator to parse parameters according to a set of criteria. This outer method is called to set up the decorator. Arguments: parameters: An array of parameter declarations tuples in the format: ('<param_name>', {'validate': [<ValidatorClass>,...], <options...>}) Usage: @chassis.util...
[ "Decorator", "to", "parse", "parameters", "according", "to", "a", "set", "of", "criteria", "." ]
train
https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/params.py#L78-L111
refinery29/chassis
chassis/util/params.py
parse_dict
def parse_dict(parameters): """Decorator to parse parameters as a dict according to a set of criteria. This outer method is called to set up the decorator. Arguments: parameters: An array of parameter declarations tuples in the format: ('<param_name>', {'validate': [<ValidatorClass>,...], ...
python
def parse_dict(parameters): """Decorator to parse parameters as a dict according to a set of criteria. This outer method is called to set up the decorator. Arguments: parameters: An array of parameter declarations tuples in the format: ('<param_name>', {'validate': [<ValidatorClass>,...], ...
[ "def", "parse_dict", "(", "parameters", ")", ":", "# pylint: disable=protected-access", "@", "decorators", ".", "include_original", "def", "decorate", "(", "method", ")", ":", "\"\"\"Setup returns this decorator, which is called on the method.\"\"\"", "def", "call", "(", "s...
Decorator to parse parameters as a dict according to a set of criteria. This outer method is called to set up the decorator. Arguments: parameters: An array of parameter declarations tuples in the format: ('<param_name>', {'validate': [<ValidatorClass>,...], <options...>}) Usage: @ch...
[ "Decorator", "to", "parse", "parameters", "as", "a", "dict", "according", "to", "a", "set", "of", "criteria", "." ]
train
https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/params.py#L114-L148
nicktgr15/sac
sac/methods/sm_analysis/kernel.py
get_checkerboard_matrix
def get_checkerboard_matrix(kernel_width, kernel_type="default", gaussian_param=0.1): """ example matrix for width = 2 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 :param kernel_type: :param kernel_width: :return: """ if kernel_type is "gaussian": ...
python
def get_checkerboard_matrix(kernel_width, kernel_type="default", gaussian_param=0.1): """ example matrix for width = 2 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 :param kernel_type: :param kernel_width: :return: """ if kernel_type is "gaussian": ...
[ "def", "get_checkerboard_matrix", "(", "kernel_width", ",", "kernel_type", "=", "\"default\"", ",", "gaussian_param", "=", "0.1", ")", ":", "if", "kernel_type", "is", "\"gaussian\"", ":", "return", "get_gaussian_kernel", "(", "kernel_width", ",", "gaussian_param", "...
example matrix for width = 2 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 :param kernel_type: :param kernel_width: :return:
[ "example", "matrix", "for", "width", "=", "2" ]
train
https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/sm_analysis/kernel.py#L66-L112
nicktgr15/sac
sac/methods/sm_analysis/kernel.py
checkerboard_matrix_filtering
def checkerboard_matrix_filtering(similarity_matrix, kernel_width, kernel_type="default", thresh=0.25): """ Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time. :param kernel_type: :param thresh: :param similarity_matrix: :param kernel_width: the...
python
def checkerboard_matrix_filtering(similarity_matrix, kernel_width, kernel_type="default", thresh=0.25): """ Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time. :param kernel_type: :param thresh: :param similarity_matrix: :param kernel_width: the...
[ "def", "checkerboard_matrix_filtering", "(", "similarity_matrix", ",", "kernel_width", ",", "kernel_type", "=", "\"default\"", ",", "thresh", "=", "0.25", ")", ":", "checkerboard_matrix", "=", "get_checkerboard_matrix", "(", "kernel_width", ",", "kernel_type", ")", "#...
Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time. :param kernel_type: :param thresh: :param similarity_matrix: :param kernel_width: the size of one quarter of the checkerboard matrix :return: peaks and convolution values
[ "Moving", "the", "checkerboard", "matrix", "over", "the", "main", "diagonal", "of", "the", "similarity", "matrix", "one", "sample", "at", "a", "time", "." ]
train
https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/sm_analysis/kernel.py#L115-L149
fstab50/metal
metal/logd.py
mode_assignment
def mode_assignment(arg): """ Translates arg to enforce proper assignment """ arg = arg.upper() stream_args = ('STREAM', 'CONSOLE', 'STDOUT') try: if arg in stream_args: return 'STREAM' else: return arg except Exception: return None
python
def mode_assignment(arg): """ Translates arg to enforce proper assignment """ arg = arg.upper() stream_args = ('STREAM', 'CONSOLE', 'STDOUT') try: if arg in stream_args: return 'STREAM' else: return arg except Exception: return None
[ "def", "mode_assignment", "(", "arg", ")", ":", "arg", "=", "arg", ".", "upper", "(", ")", "stream_args", "=", "(", "'STREAM'", ",", "'CONSOLE'", ",", "'STDOUT'", ")", "try", ":", "if", "arg", "in", "stream_args", ":", "return", "'STREAM'", "else", ":"...
Translates arg to enforce proper assignment
[ "Translates", "arg", "to", "enforce", "proper", "assignment" ]
train
https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/logd.py#L15-L27
fstab50/metal
metal/logd.py
getLogger
def getLogger(*args, **kwargs): """ Summary: custom format logger Args: mode (str): The Logger module supprts the following log modes: - log to console / stdout. Log_mode = 'stream' - log to file - log to system logger (syslog) Returns: log...
python
def getLogger(*args, **kwargs): """ Summary: custom format logger Args: mode (str): The Logger module supprts the following log modes: - log to console / stdout. Log_mode = 'stream' - log to file - log to system logger (syslog) Returns: log...
[ "def", "getLogger", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "log_mode", "=", "local_config", "[", "'LOGGING'", "]", "[", "'LOG_MODE'", "]", "# log format - file", "file_format", "=", "'%(asctime)s - %(pathname)s - %(name)s - [%(levelname)s]: %(message)s'", ...
Summary: custom format logger Args: mode (str): The Logger module supprts the following log modes: - log to console / stdout. Log_mode = 'stream' - log to file - log to system logger (syslog) Returns: logger object | TYPE: logging
[ "Summary", ":", "custom", "format", "logger" ]
train
https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/logd.py#L30-L110
boronine/discipline
discipline/models.py
Editor.save_object
def save_object(self, obj): """Save an object with Discipline Only argument is a Django object. This function saves the object (regardless of whether it already exists or not) and registers with Discipline, creating a new Action object. Do not use obj.save()! """ obj.sav...
python
def save_object(self, obj): """Save an object with Discipline Only argument is a Django object. This function saves the object (regardless of whether it already exists or not) and registers with Discipline, creating a new Action object. Do not use obj.save()! """ obj.sav...
[ "def", "save_object", "(", "self", ",", "obj", ")", ":", "obj", ".", "save", "(", ")", "try", ":", "save_object", "(", "obj", ",", "editor", "=", "self", ")", "except", "DisciplineException", ":", "pass" ]
Save an object with Discipline Only argument is a Django object. This function saves the object (regardless of whether it already exists or not) and registers with Discipline, creating a new Action object. Do not use obj.save()!
[ "Save", "an", "object", "with", "Discipline" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L112-L123
boronine/discipline
discipline/models.py
Editor.delete_object
def delete_object(self, obj, post_delete=False): """Delete an object with Discipline Only argument is a Django object. Analogous to Editor.save_object. """ # Collect related objects that will be deleted by cascading links = [rel.get_accessor_name() for rel in \ ...
python
def delete_object(self, obj, post_delete=False): """Delete an object with Discipline Only argument is a Django object. Analogous to Editor.save_object. """ # Collect related objects that will be deleted by cascading links = [rel.get_accessor_name() for rel in \ ...
[ "def", "delete_object", "(", "self", ",", "obj", ",", "post_delete", "=", "False", ")", ":", "# Collect related objects that will be deleted by cascading", "links", "=", "[", "rel", ".", "get_accessor_name", "(", ")", "for", "rel", "in", "obj", ".", "_meta", "."...
Delete an object with Discipline Only argument is a Django object. Analogous to Editor.save_object.
[ "Delete", "an", "object", "with", "Discipline" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L125-L139
boronine/discipline
discipline/models.py
Action._description
def _description(self): """A concise html explanation of this Action.""" inst = self.timemachine.presently if self.action_type == "dl": return "Deleted %s" % inst.content_type.name elif self.action_type == "cr": return "Created %s" % inst._object_type_html() ...
python
def _description(self): """A concise html explanation of this Action.""" inst = self.timemachine.presently if self.action_type == "dl": return "Deleted %s" % inst.content_type.name elif self.action_type == "cr": return "Created %s" % inst._object_type_html() ...
[ "def", "_description", "(", "self", ")", ":", "inst", "=", "self", ".", "timemachine", ".", "presently", "if", "self", ".", "action_type", "==", "\"dl\"", ":", "return", "\"Deleted %s\"", "%", "inst", ".", "content_type", ".", "name", "elif", "self", ".", ...
A concise html explanation of this Action.
[ "A", "concise", "html", "explanation", "of", "this", "Action", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L232-L242
boronine/discipline
discipline/models.py
Action.__get_timemachine
def __get_timemachine(self): """Return a TimeMachine for the object on which this action was performed and at the time of this action.""" if not self.__timemachine: self.__timemachine = TimeMachine( self.object_uid, step = self.id, ) ...
python
def __get_timemachine(self): """Return a TimeMachine for the object on which this action was performed and at the time of this action.""" if not self.__timemachine: self.__timemachine = TimeMachine( self.object_uid, step = self.id, ) ...
[ "def", "__get_timemachine", "(", "self", ")", ":", "if", "not", "self", ".", "__timemachine", ":", "self", ".", "__timemachine", "=", "TimeMachine", "(", "self", ".", "object_uid", ",", "step", "=", "self", ".", "id", ",", ")", "return", "self", ".", "...
Return a TimeMachine for the object on which this action was performed and at the time of this action.
[ "Return", "a", "TimeMachine", "for", "the", "object", "on", "which", "this", "action", "was", "performed", "and", "at", "the", "time", "of", "this", "action", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L249-L258
boronine/discipline
discipline/models.py
Action.__get_is_revertible
def __get_is_revertible(self): """Return a boolean representing whether this Action is revertible or not""" # If it was already reverted if self.reverted: return False errors = [] inst = self.timemachine if inst.fields != inst.presently.fiel...
python
def __get_is_revertible(self): """Return a boolean representing whether this Action is revertible or not""" # If it was already reverted if self.reverted: return False errors = [] inst = self.timemachine if inst.fields != inst.presently.fiel...
[ "def", "__get_is_revertible", "(", "self", ")", ":", "# If it was already reverted", "if", "self", ".", "reverted", ":", "return", "False", "errors", "=", "[", "]", "inst", "=", "self", ".", "timemachine", "if", "inst", ".", "fields", "!=", "inst", ".", "p...
Return a boolean representing whether this Action is revertible or not
[ "Return", "a", "boolean", "representing", "whether", "this", "Action", "is", "revertible", "or", "not" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L262-L332
boronine/discipline
discipline/models.py
Action.undo
def undo(self, editor): """Create a new Action that undos the effects of this one, or, more accurately, reverts the object of this Action to the state at which it was right before the Action took place.""" inst = self.timemachine if not self.is_revertible: raise Disci...
python
def undo(self, editor): """Create a new Action that undos the effects of this one, or, more accurately, reverts the object of this Action to the state at which it was right before the Action took place.""" inst = self.timemachine if not self.is_revertible: raise Disci...
[ "def", "undo", "(", "self", ",", "editor", ")", ":", "inst", "=", "self", ".", "timemachine", "if", "not", "self", ".", "is_revertible", ":", "raise", "DisciplineException", "(", "\"You tried to undo a non-revertible action! \"", "\"Check action.is_revertible and action...
Create a new Action that undos the effects of this one, or, more accurately, reverts the object of this Action to the state at which it was right before the Action took place.
[ "Create", "a", "new", "Action", "that", "undos", "the", "effects", "of", "this", "one", "or", "more", "accurately", "reverts", "the", "object", "of", "this", "Action", "to", "the", "state", "at", "which", "it", "was", "right", "before", "the", "Action", ...
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L342-L369
boronine/discipline
discipline/models.py
Action._status
def _status(self): """Return html saying whether this Action is reverted by another one or reverts another one.""" text = "" # Turns out that is related field in null, Django # doesn't even make it a property of the object # http://code.djangoproject.com/ticket/11920 ...
python
def _status(self): """Return html saying whether this Action is reverted by another one or reverts another one.""" text = "" # Turns out that is related field in null, Django # doesn't even make it a property of the object # http://code.djangoproject.com/ticket/11920 ...
[ "def", "_status", "(", "self", ")", ":", "text", "=", "\"\"", "# Turns out that is related field in null, Django", "# doesn't even make it a property of the object", "# http://code.djangoproject.com/ticket/11920", "if", "hasattr", "(", "self", ",", "\"reverts\"", ")", ":", "t...
Return html saying whether this Action is reverted by another one or reverts another one.
[ "Return", "html", "saying", "whether", "this", "Action", "is", "reverted", "by", "another", "one", "or", "reverts", "another", "one", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L371-L388
boronine/discipline
discipline/models.py
Action.__summary
def __summary(self): """A plaintext summary of the Action, useful for debugging.""" text = "Time: %s\n" % self.when text += "Comitter: %s\n" % self.editor inst = self.timemachine.presently if self.action_type == "dl": text += "Deleted %s\n" % inst._object_type_text(...
python
def __summary(self): """A plaintext summary of the Action, useful for debugging.""" text = "Time: %s\n" % self.when text += "Comitter: %s\n" % self.editor inst = self.timemachine.presently if self.action_type == "dl": text += "Deleted %s\n" % inst._object_type_text(...
[ "def", "__summary", "(", "self", ")", ":", "text", "=", "\"Time: %s\\n\"", "%", "self", ".", "when", "text", "+=", "\"Comitter: %s\\n\"", "%", "self", ".", "editor", "inst", "=", "self", ".", "timemachine", ".", "presently", "if", "self", ".", "action_type...
A plaintext summary of the Action, useful for debugging.
[ "A", "plaintext", "summary", "of", "the", "Action", "useful", "for", "debugging", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L398-L412
boronine/discipline
discipline/models.py
Action._details
def _details(self, nohtml=False): """Return the html representation of the Action.""" text = "" inst = self.timemachine # If deleted or created, show every field, otherwise only # the modified if self.action_type in ("dl","cr",): fields = inst.fields + inst.f...
python
def _details(self, nohtml=False): """Return the html representation of the Action.""" text = "" inst = self.timemachine # If deleted or created, show every field, otherwise only # the modified if self.action_type in ("dl","cr",): fields = inst.fields + inst.f...
[ "def", "_details", "(", "self", ",", "nohtml", "=", "False", ")", ":", "text", "=", "\"\"", "inst", "=", "self", ".", "timemachine", "# If deleted or created, show every field, otherwise only", "# the modified", "if", "self", ".", "action_type", "in", "(", "\"dl\"...
Return the html representation of the Action.
[ "Return", "the", "html", "representation", "of", "the", "Action", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L416-L447
boronine/discipline
discipline/models.py
TimeMachine.__update_information
def __update_information(self): """Gether information that doesn't change at different points in time""" info = {} info["actions_count"] = Action.objects.count() info["creation_times"] = [] info["deletion_times"] = [] info["content_type"] = None ...
python
def __update_information(self): """Gether information that doesn't change at different points in time""" info = {} info["actions_count"] = Action.objects.count() info["creation_times"] = [] info["deletion_times"] = [] info["content_type"] = None ...
[ "def", "__update_information", "(", "self", ")", ":", "info", "=", "{", "}", "info", "[", "\"actions_count\"", "]", "=", "Action", ".", "objects", ".", "count", "(", ")", "info", "[", "\"creation_times\"", "]", "=", "[", "]", "info", "[", "\"deletion_tim...
Gether information that doesn't change at different points in time
[ "Gether", "information", "that", "doesn", "t", "change", "at", "different", "points", "in", "time" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L563-L595
boronine/discipline
discipline/models.py
TimeMachine.at
def at(self, step): """Return a TimeMachine for the same object at a different time. Takes an integer argument representing the id field of an Action. Returns the TimeMachine at the time of that Action. (Less ambiguously: at the time right after the Action. """ return T...
python
def at(self, step): """Return a TimeMachine for the same object at a different time. Takes an integer argument representing the id field of an Action. Returns the TimeMachine at the time of that Action. (Less ambiguously: at the time right after the Action. """ return T...
[ "def", "at", "(", "self", ",", "step", ")", ":", "return", "TimeMachine", "(", "self", ".", "uid", ",", "step", "=", "step", ",", "info", "=", "copy", ".", "deepcopy", "(", "self", ".", "info", ")", ")" ]
Return a TimeMachine for the same object at a different time. Takes an integer argument representing the id field of an Action. Returns the TimeMachine at the time of that Action. (Less ambiguously: at the time right after the Action.
[ "Return", "a", "TimeMachine", "for", "the", "same", "object", "at", "a", "different", "time", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L597-L609
boronine/discipline
discipline/models.py
TimeMachine._get_modcommit
def _get_modcommit(self, key): """Return the last modcommit of the given field. If no modcommit exists (for example after a migration that created new fields) returns None. """ try: return ModificationCommit.objects.filter( object_uid = self.uid, ...
python
def _get_modcommit(self, key): """Return the last modcommit of the given field. If no modcommit exists (for example after a migration that created new fields) returns None. """ try: return ModificationCommit.objects.filter( object_uid = self.uid, ...
[ "def", "_get_modcommit", "(", "self", ",", "key", ")", ":", "try", ":", "return", "ModificationCommit", ".", "objects", ".", "filter", "(", "object_uid", "=", "self", ".", "uid", ",", "key", "=", "key", ",", "action__id__lte", "=", "self", ".", "step", ...
Return the last modcommit of the given field. If no modcommit exists (for example after a migration that created new fields) returns None.
[ "Return", "the", "last", "modcommit", "of", "the", "given", "field", ".", "If", "no", "modcommit", "exists", "(", "for", "example", "after", "a", "migration", "that", "created", "new", "fields", ")", "returns", "None", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L621-L633
boronine/discipline
discipline/models.py
TimeMachine.get
def get(self, key): """Return the value of a field. Take a string argument representing a field name, return the value of that field at the time of this TimeMachine. When restoring a ForeignKey-pointer object that doesn't exist, raise DisciplineException """ ...
python
def get(self, key): """Return the value of a field. Take a string argument representing a field name, return the value of that field at the time of this TimeMachine. When restoring a ForeignKey-pointer object that doesn't exist, raise DisciplineException """ ...
[ "def", "get", "(", "self", ",", "key", ")", ":", "modcommit", "=", "self", ".", "_get_modcommit", "(", "key", ")", "if", "not", "modcommit", ":", "return", "None", "# If this isn't a ForeignKey, then just return the value", "if", "key", "not", "in", "self", "....
Return the value of a field. Take a string argument representing a field name, return the value of that field at the time of this TimeMachine. When restoring a ForeignKey-pointer object that doesn't exist, raise DisciplineException
[ "Return", "the", "value", "of", "a", "field", ".", "Take", "a", "string", "argument", "representing", "a", "field", "name", "return", "the", "value", "of", "that", "field", "at", "the", "time", "of", "this", "TimeMachine", ".", "When", "restoring", "a", ...
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L635-L654
boronine/discipline
discipline/models.py
TimeMachine.get_timemachine_instance
def get_timemachine_instance(self, key): """Return a TimeMachine for a related object. Take a string argument representing a ForeignKey field name, find what object was related to this one at the time of this TimeMachine and return a TimeMachine for that related object. """ ...
python
def get_timemachine_instance(self, key): """Return a TimeMachine for a related object. Take a string argument representing a ForeignKey field name, find what object was related to this one at the time of this TimeMachine and return a TimeMachine for that related object. """ ...
[ "def", "get_timemachine_instance", "(", "self", ",", "key", ")", ":", "modcommit", "=", "self", ".", "_get_modcommit", "(", "key", ")", "if", "not", "modcommit", ":", "return", "None", "return", "TimeMachine", "(", "uid", "=", "modcommit", ".", "value", ")...
Return a TimeMachine for a related object. Take a string argument representing a ForeignKey field name, find what object was related to this one at the time of this TimeMachine and return a TimeMachine for that related object.
[ "Return", "a", "TimeMachine", "for", "a", "related", "object", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L656-L667
boronine/discipline
discipline/models.py
TimeMachine.get_object
def get_object(self): """Return the object of this TimeMachine""" return self.content_type.model_class().objects.get(uid = self.uid)
python
def get_object(self): """Return the object of this TimeMachine""" return self.content_type.model_class().objects.get(uid = self.uid)
[ "def", "get_object", "(", "self", ")", ":", "return", "self", ".", "content_type", ".", "model_class", "(", ")", ".", "objects", ".", "get", "(", "uid", "=", "self", ".", "uid", ")" ]
Return the object of this TimeMachine
[ "Return", "the", "object", "of", "this", "TimeMachine" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L669-L671
boronine/discipline
discipline/models.py
TimeMachine.restore
def restore(self, nosave=False): """Restore all of the object attributes to the attributes. Return the Django object. """ if self.exists: obj = self.content_type.model_class().objects.get(uid=self.uid) else: obj = self.content_type.model_class()(uid=self.u...
python
def restore(self, nosave=False): """Restore all of the object attributes to the attributes. Return the Django object. """ if self.exists: obj = self.content_type.model_class().objects.get(uid=self.uid) else: obj = self.content_type.model_class()(uid=self.u...
[ "def", "restore", "(", "self", ",", "nosave", "=", "False", ")", ":", "if", "self", ".", "exists", ":", "obj", "=", "self", ".", "content_type", ".", "model_class", "(", ")", ".", "objects", ".", "get", "(", "uid", "=", "self", ".", "uid", ")", "...
Restore all of the object attributes to the attributes. Return the Django object.
[ "Restore", "all", "of", "the", "object", "attributes", "to", "the", "attributes", ".", "Return", "the", "Django", "object", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L711-L722
boronine/discipline
discipline/models.py
TimeMachine.url
def url(self): """Return the admin url of the object.""" return urlresolvers.reverse( "admin:%s_%s_change" % (self.content_type.app_label, self.content_type.model), args = (self.get_object().uid,))
python
def url(self): """Return the admin url of the object.""" return urlresolvers.reverse( "admin:%s_%s_change" % (self.content_type.app_label, self.content_type.model), args = (self.get_object().uid,))
[ "def", "url", "(", "self", ")", ":", "return", "urlresolvers", ".", "reverse", "(", "\"admin:%s_%s_change\"", "%", "(", "self", ".", "content_type", ".", "app_label", ",", "self", ".", "content_type", ".", "model", ")", ",", "args", "=", "(", "self", "."...
Return the admin url of the object.
[ "Return", "the", "admin", "url", "of", "the", "object", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L727-L732
boronine/discipline
discipline/models.py
TimeMachine._object_type_html
def _object_type_html(self): """Return an html admin link with the object's type as text. If the object doesn't exist, return the object's type crossed out. """ if self.exists: return "<a href=\"%s\">%s</a>" % (self.url(), self...
python
def _object_type_html(self): """Return an html admin link with the object's type as text. If the object doesn't exist, return the object's type crossed out. """ if self.exists: return "<a href=\"%s\">%s</a>" % (self.url(), self...
[ "def", "_object_type_html", "(", "self", ")", ":", "if", "self", ".", "exists", ":", "return", "\"<a href=\\\"%s\\\">%s</a>\"", "%", "(", "self", ".", "url", "(", ")", ",", "self", ".", "content_type", ".", "name", ",", ")", "else", ":", "return", "\"<s>...
Return an html admin link with the object's type as text. If the object doesn't exist, return the object's type crossed out.
[ "Return", "an", "html", "admin", "link", "with", "the", "object", "s", "type", "as", "text", ".", "If", "the", "object", "doesn", "t", "exist", "return", "the", "object", "s", "type", "crossed", "out", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L735-L744
boronine/discipline
discipline/models.py
TimeMachine._object_name_html
def _object_name_html(self): """Return an html admin link with the object's name as text. If the object doesn't exist, return "(deleted)". """ if self.presently.exists: url = self.url() return "<a href=\"%s\">%s</a>" % (url, ...
python
def _object_name_html(self): """Return an html admin link with the object's name as text. If the object doesn't exist, return "(deleted)". """ if self.presently.exists: url = self.url() return "<a href=\"%s\">%s</a>" % (url, ...
[ "def", "_object_name_html", "(", "self", ")", ":", "if", "self", ".", "presently", ".", "exists", ":", "url", "=", "self", ".", "url", "(", ")", "return", "\"<a href=\\\"%s\\\">%s</a>\"", "%", "(", "url", ",", "unicode", "(", "self", ".", "get_object", "...
Return an html admin link with the object's name as text. If the object doesn't exist, return "(deleted)".
[ "Return", "an", "html", "admin", "link", "with", "the", "object", "s", "name", "as", "text", ".", "If", "the", "object", "doesn", "t", "exist", "return", "(", "deleted", ")", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L746-L755
boronine/discipline
discipline/models.py
TimeMachine._field_value_html
def _field_value_html(self, field): """Return the html representation of the value of the given field""" if field in self.fields: return unicode(self.get(field)) else: return self.get_timemachine_instance(field)._object_name_html()
python
def _field_value_html(self, field): """Return the html representation of the value of the given field""" if field in self.fields: return unicode(self.get(field)) else: return self.get_timemachine_instance(field)._object_name_html()
[ "def", "_field_value_html", "(", "self", ",", "field", ")", ":", "if", "field", "in", "self", ".", "fields", ":", "return", "unicode", "(", "self", ".", "get", "(", "field", ")", ")", "else", ":", "return", "self", ".", "get_timemachine_instance", "(", ...
Return the html representation of the value of the given field
[ "Return", "the", "html", "representation", "of", "the", "value", "of", "the", "given", "field" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L757-L762
boronine/discipline
discipline/models.py
TimeMachine._field_value_text
def _field_value_text(self, field): """Return the html representation of the value of the given field""" if field in self.fields: return unicode(self.get(field)) else: return self.get_timemachine_instance(field)._object_name_text()
python
def _field_value_text(self, field): """Return the html representation of the value of the given field""" if field in self.fields: return unicode(self.get(field)) else: return self.get_timemachine_instance(field)._object_name_text()
[ "def", "_field_value_text", "(", "self", ",", "field", ")", ":", "if", "field", "in", "self", ".", "fields", ":", "return", "unicode", "(", "self", ".", "get", "(", "field", ")", ")", "else", ":", "return", "self", ".", "get_timemachine_instance", "(", ...
Return the html representation of the value of the given field
[ "Return", "the", "html", "representation", "of", "the", "value", "of", "the", "given", "field" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L764-L769
boronine/discipline
discipline/models.py
SchemaState.get_for_content_type
def get_for_content_type(self, ct): """Return the schema for the model of the given ContentType object""" try: return json.loads(self.state)[ct.app_label][ct.model] except KeyError: return None
python
def get_for_content_type(self, ct): """Return the schema for the model of the given ContentType object""" try: return json.loads(self.state)[ct.app_label][ct.model] except KeyError: return None
[ "def", "get_for_content_type", "(", "self", ",", "ct", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "self", ".", "state", ")", "[", "ct", ".", "app_label", "]", "[", "ct", ".", "model", "]", "except", "KeyError", ":", "return", "None" ]
Return the schema for the model of the given ContentType object
[ "Return", "the", "schema", "for", "the", "model", "of", "the", "given", "ContentType", "object" ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L798-L803
boronine/discipline
discipline/models.py
SchemaState.html_state
def html_state(self): """Display state in HTML format for the admin form.""" ret = "" state = json.loads(self.state) for (app, appstate) in state.items(): for (model, modelstate) in appstate.items(): ret += "<p>%s.models.%s</p>" % (app, model,) ...
python
def html_state(self): """Display state in HTML format for the admin form.""" ret = "" state = json.loads(self.state) for (app, appstate) in state.items(): for (model, modelstate) in appstate.items(): ret += "<p>%s.models.%s</p>" % (app, model,) ...
[ "def", "html_state", "(", "self", ")", ":", "ret", "=", "\"\"", "state", "=", "json", ".", "loads", "(", "self", ".", "state", ")", "for", "(", "app", ",", "appstate", ")", "in", "state", ".", "items", "(", ")", ":", "for", "(", "model", ",", "...
Display state in HTML format for the admin form.
[ "Display", "state", "in", "HTML", "format", "for", "the", "admin", "form", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/discipline/models.py#L808-L821
ryanjdillon/pyotelem
pyotelem/plots/plotdynamics.py
plot_prh_des_asc
def plot_prh_des_asc(p, r, h, asc, des): '''Plot pitch, roll, and heading during the descent and ascent dive phases Args ---- p: ndarray Derived pitch data r: ndarray Derived roll data h: ndarray Derived heading data des: ndarray boolean mask for slicing desc...
python
def plot_prh_des_asc(p, r, h, asc, des): '''Plot pitch, roll, and heading during the descent and ascent dive phases Args ---- p: ndarray Derived pitch data r: ndarray Derived roll data h: ndarray Derived heading data des: ndarray boolean mask for slicing desc...
[ "def", "plot_prh_des_asc", "(", "p", ",", "r", ",", "h", ",", "asc", ",", "des", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "numpy", "from", ".", "import", "plotutils", "# Convert boolean mask to indices", "des_ind", "=", "numpy"...
Plot pitch, roll, and heading during the descent and ascent dive phases Args ---- p: ndarray Derived pitch data r: ndarray Derived roll data h: ndarray Derived heading data des: ndarray boolean mask for slicing descent phases of dives from tag dta asc: ndarra...
[ "Plot", "pitch", "roll", "and", "heading", "during", "the", "descent", "and", "ascent", "dive", "phases" ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdynamics.py#L11-L58
ryanjdillon/pyotelem
pyotelem/plots/plotdynamics.py
plot_prh_filtered
def plot_prh_filtered(p, r, h, p_lf, r_lf, h_lf): '''Plot original and low-pass filtered PRH data Args ---- p: ndarray Derived pitch data r: ndarray Derived roll data h: ndarray Derived heading data p_lf: ndarray Low-pass filtered pitch data r_lf: ndarray...
python
def plot_prh_filtered(p, r, h, p_lf, r_lf, h_lf): '''Plot original and low-pass filtered PRH data Args ---- p: ndarray Derived pitch data r: ndarray Derived roll data h: ndarray Derived heading data p_lf: ndarray Low-pass filtered pitch data r_lf: ndarray...
[ "def", "plot_prh_filtered", "(", "p", ",", "r", ",", "h", ",", "p_lf", ",", "r_lf", ",", "h_lf", ")", ":", "import", "numpy", "fig", ",", "(", "ax1", ",", "ax2", ",", "ax3", ")", "=", "plt", ".", "subplots", "(", "3", ",", "1", ",", "sharex", ...
Plot original and low-pass filtered PRH data Args ---- p: ndarray Derived pitch data r: ndarray Derived roll data h: ndarray Derived heading data p_lf: ndarray Low-pass filtered pitch data r_lf: ndarray Low-pass filtered roll data h_lf: ndarray ...
[ "Plot", "original", "and", "low", "-", "pass", "filtered", "PRH", "data" ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdynamics.py#L61-L110
ryanjdillon/pyotelem
pyotelem/plots/plotdynamics.py
plot_swim_speed
def plot_swim_speed(exp_ind, swim_speed): '''Plot the swim speed during experimental indices Args ---- exp_ind: ndarray Indices of tag data where experiment is active swim_speed: ndarray Swim speed data at sensor sampling rate ''' import numpy fig, ax = plt.subplots() ...
python
def plot_swim_speed(exp_ind, swim_speed): '''Plot the swim speed during experimental indices Args ---- exp_ind: ndarray Indices of tag data where experiment is active swim_speed: ndarray Swim speed data at sensor sampling rate ''' import numpy fig, ax = plt.subplots() ...
[ "def", "plot_swim_speed", "(", "exp_ind", ",", "swim_speed", ")", ":", "import", "numpy", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "ax", ".", "title", ".", "set_text", "(", "'Swim speed from depth change and pitch angle (m/s^2'", ")", "ax", "."...
Plot the swim speed during experimental indices Args ---- exp_ind: ndarray Indices of tag data where experiment is active swim_speed: ndarray Swim speed data at sensor sampling rate
[ "Plot", "the", "swim", "speed", "during", "experimental", "indices" ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdynamics.py#L113-L135
spookey/photon
photon/settings.py
Settings.load
def load(self, skey, sdesc, sdict=None, loaders=None, merge=False, writeback=False): ''' Loads a dictionary into current settings :param skey: Type of data to load. Is be used to reference the data \ in the files sections within settings :param sdesc...
python
def load(self, skey, sdesc, sdict=None, loaders=None, merge=False, writeback=False): ''' Loads a dictionary into current settings :param skey: Type of data to load. Is be used to reference the data \ in the files sections within settings :param sdesc...
[ "def", "load", "(", "self", ",", "skey", ",", "sdesc", ",", "sdict", "=", "None", ",", "loaders", "=", "None", ",", "merge", "=", "False", ",", "writeback", "=", "False", ")", ":", "y", "=", "sdict", "if", "sdict", "else", "read_yaml", "(", "sdesc"...
Loads a dictionary into current settings :param skey: Type of data to load. Is be used to reference the data \ in the files sections within settings :param sdesc: Either filename of yaml-file to load or further description of \ imported data when `sdict` ...
[ "Loads", "a", "dictionary", "into", "current", "settings" ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/settings.py#L134-L183
jmgilman/Neolib
neolib/pyamf/sol.py
decode
def decode(stream, strict=True): """ Decodes a SOL stream. L{strict} mode ensures that the sol stream is as spec compatible as possible. @return: A C{tuple} containing the C{root_name} and a C{dict} of name, value pairs. """ if not isinstance(stream, util.BufferedByteStream): st...
python
def decode(stream, strict=True): """ Decodes a SOL stream. L{strict} mode ensures that the sol stream is as spec compatible as possible. @return: A C{tuple} containing the C{root_name} and a C{dict} of name, value pairs. """ if not isinstance(stream, util.BufferedByteStream): st...
[ "def", "decode", "(", "stream", ",", "strict", "=", "True", ")", ":", "if", "not", "isinstance", "(", "stream", ",", "util", ".", "BufferedByteStream", ")", ":", "stream", "=", "util", ".", "BufferedByteStream", "(", "stream", ")", "# read the version", "v...
Decodes a SOL stream. L{strict} mode ensures that the sol stream is as spec compatible as possible. @return: A C{tuple} containing the C{root_name} and a C{dict} of name, value pairs.
[ "Decodes", "a", "SOL", "stream", ".", "L", "{", "strict", "}", "mode", "ensures", "that", "the", "sol", "stream", "is", "as", "spec", "compatible", "as", "possible", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/sol.py#L28-L82
jmgilman/Neolib
neolib/pyamf/sol.py
encode
def encode(name, values, strict=True, encoding=pyamf.AMF0): """ Produces a SharedObject encoded stream based on the name and values. @param name: The root name of the SharedObject. @param values: A `dict` of name value pairs to be encoded in the stream. @param strict: Ensure that the SOL stream is ...
python
def encode(name, values, strict=True, encoding=pyamf.AMF0): """ Produces a SharedObject encoded stream based on the name and values. @param name: The root name of the SharedObject. @param values: A `dict` of name value pairs to be encoded in the stream. @param strict: Ensure that the SOL stream is ...
[ "def", "encode", "(", "name", ",", "values", ",", "strict", "=", "True", ",", "encoding", "=", "pyamf", ".", "AMF0", ")", ":", "encoder", "=", "pyamf", ".", "get_encoder", "(", "encoding", ")", "stream", "=", "encoder", ".", "stream", "# write the header...
Produces a SharedObject encoded stream based on the name and values. @param name: The root name of the SharedObject. @param values: A `dict` of name value pairs to be encoded in the stream. @param strict: Ensure that the SOL stream is as spec compatible as possible. @return: A SharedObject encoded stre...
[ "Produces", "a", "SharedObject", "encoded", "stream", "based", "on", "the", "name", "and", "values", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/sol.py#L85-L133
jmgilman/Neolib
neolib/pyamf/sol.py
load
def load(name_or_file): """ Loads a sol file and returns a L{SOL} object. @param name_or_file: Name of file, or file-object. @type name_or_file: C{string} """ f = name_or_file opened = False if isinstance(name_or_file, basestring): f = open(name_or_file, 'rb') opened = ...
python
def load(name_or_file): """ Loads a sol file and returns a L{SOL} object. @param name_or_file: Name of file, or file-object. @type name_or_file: C{string} """ f = name_or_file opened = False if isinstance(name_or_file, basestring): f = open(name_or_file, 'rb') opened = ...
[ "def", "load", "(", "name_or_file", ")", ":", "f", "=", "name_or_file", "opened", "=", "False", "if", "isinstance", "(", "name_or_file", ",", "basestring", ")", ":", "f", "=", "open", "(", "name_or_file", ",", "'rb'", ")", "opened", "=", "True", "elif", ...
Loads a sol file and returns a L{SOL} object. @param name_or_file: Name of file, or file-object. @type name_or_file: C{string}
[ "Loads", "a", "sol", "file", "and", "returns", "a", "L", "{", "SOL", "}", "object", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/sol.py#L136-L161
jmgilman/Neolib
neolib/pyamf/sol.py
save
def save(sol, name_or_file, encoding=pyamf.AMF0): """ Writes a L{SOL} object to C{name_or_file}. @param name_or_file: Name of file or file-object to write to. @param encoding: AMF encoding type. """ f = name_or_file opened = False if isinstance(name_or_file, basestring): f = op...
python
def save(sol, name_or_file, encoding=pyamf.AMF0): """ Writes a L{SOL} object to C{name_or_file}. @param name_or_file: Name of file or file-object to write to. @param encoding: AMF encoding type. """ f = name_or_file opened = False if isinstance(name_or_file, basestring): f = op...
[ "def", "save", "(", "sol", ",", "name_or_file", ",", "encoding", "=", "pyamf", ".", "AMF0", ")", ":", "f", "=", "name_or_file", "opened", "=", "False", "if", "isinstance", "(", "name_or_file", ",", "basestring", ")", ":", "f", "=", "open", "(", "name_o...
Writes a L{SOL} object to C{name_or_file}. @param name_or_file: Name of file or file-object to write to. @param encoding: AMF encoding type.
[ "Writes", "a", "L", "{", "SOL", "}", "object", "to", "C", "{", "name_or_file", "}", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/sol.py#L164-L183
jamieleshaw/lurklib
lurklib/__init__.py
Client.process_once
def process_once(self, timeout=0.01): """ Handles an event and calls it's handler Optional arguments: * timeout=0.01 - Wait for an event until the timeout is reached. """ try: event = self.recv(timeout) if event: event_t = event[0] ...
python
def process_once(self, timeout=0.01): """ Handles an event and calls it's handler Optional arguments: * timeout=0.01 - Wait for an event until the timeout is reached. """ try: event = self.recv(timeout) if event: event_t = event[0] ...
[ "def", "process_once", "(", "self", ",", "timeout", "=", "0.01", ")", ":", "try", ":", "event", "=", "self", ".", "recv", "(", "timeout", ")", "if", "event", ":", "event_t", "=", "event", "[", "0", "]", "event_c", "=", "event", "[", "1", "]", "if...
Handles an event and calls it's handler Optional arguments: * timeout=0.01 - Wait for an event until the timeout is reached.
[ "Handles", "an", "event", "and", "calls", "it", "s", "handler", "Optional", "arguments", ":", "*", "timeout", "=", "0", ".", "01", "-", "Wait", "for", "an", "event", "until", "the", "timeout", "is", "reached", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/__init__.py#L27-L84
jamieleshaw/lurklib
lurklib/__init__.py
Client.mainloop
def mainloop(self): """ Handles events and calls their handler for infinity. """ while self.keep_going: with self.lock: if self.on_connect and not self.readable(2): self.on_connect() self.on_connect = None ...
python
def mainloop(self): """ Handles events and calls their handler for infinity. """ while self.keep_going: with self.lock: if self.on_connect and not self.readable(2): self.on_connect() self.on_connect = None ...
[ "def", "mainloop", "(", "self", ")", ":", "while", "self", ".", "keep_going", ":", "with", "self", ".", "lock", ":", "if", "self", ".", "on_connect", "and", "not", "self", ".", "readable", "(", "2", ")", ":", "self", ".", "on_connect", "(", ")", "s...
Handles events and calls their handler for infinity.
[ "Handles", "events", "and", "calls", "their", "handler", "for", "infinity", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/__init__.py#L86-L97
openpermissions/perch
perch/migrations/user_22e76f4ff8bd41e19aa52839fc8f13a1.py
migrate_user
def migrate_user(instance): """ Move User.organisations['global']['role'] to top-level property and remove verified flag """ instance._resource.pop('verified', None) if 'role' in instance._resource: return instance global_org = instance.organisations.pop('global', {}) instance....
python
def migrate_user(instance): """ Move User.organisations['global']['role'] to top-level property and remove verified flag """ instance._resource.pop('verified', None) if 'role' in instance._resource: return instance global_org = instance.organisations.pop('global', {}) instance....
[ "def", "migrate_user", "(", "instance", ")", ":", "instance", ".", "_resource", ".", "pop", "(", "'verified'", ",", "None", ")", "if", "'role'", "in", "instance", ".", "_resource", ":", "return", "instance", "global_org", "=", "instance", ".", "organisations...
Move User.organisations['global']['role'] to top-level property and remove verified flag
[ "Move", "User", ".", "organisations", "[", "global", "]", "[", "role", "]", "to", "top", "-", "level", "property", "and", "remove", "verified", "flag" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/migrations/user_22e76f4ff8bd41e19aa52839fc8f13a1.py#L10-L23
20c/twentyc.tools
twentyc/tools/config.py
dict_conf
def dict_conf(filename): """ Return dict object for *.conf file """ f, ext = os.path.splitext(filename) ext = ext.lower() if ext == "conf" or ext == "ini": # python config via config parser config = ConfigParser() config.optionxform=str config.read(filename) rv = {} for section in...
python
def dict_conf(filename): """ Return dict object for *.conf file """ f, ext = os.path.splitext(filename) ext = ext.lower() if ext == "conf" or ext == "ini": # python config via config parser config = ConfigParser() config.optionxform=str config.read(filename) rv = {} for section in...
[ "def", "dict_conf", "(", "filename", ")", ":", "f", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "ext", "=", "ext", ".", "lower", "(", ")", "if", "ext", "==", "\"conf\"", "or", "ext", "==", "\"ini\"", ":", "# python co...
Return dict object for *.conf file
[ "Return", "dict", "object", "for", "*", ".", "conf", "file" ]
train
https://github.com/20c/twentyc.tools/blob/f8f681e64f58d449bfc32646ba8bcc57db90a233/twentyc/tools/config.py#L9-L35
treycucco/bidon
bidon/spreadsheet/excel.py
ExcelWorksheet.parse_cell
def parse_cell(self, cell, coords, cell_mode=CellMode.cooked): """Parses a cell according to the cell.ctype.""" # pylint: disable=too-many-return-statements if cell_mode == CellMode.cooked: if cell.ctype == xlrd.XL_CELL_BLANK: return None if cell.ctype == xlrd.XL_CELL_BOOLEAN: r...
python
def parse_cell(self, cell, coords, cell_mode=CellMode.cooked): """Parses a cell according to the cell.ctype.""" # pylint: disable=too-many-return-statements if cell_mode == CellMode.cooked: if cell.ctype == xlrd.XL_CELL_BLANK: return None if cell.ctype == xlrd.XL_CELL_BOOLEAN: r...
[ "def", "parse_cell", "(", "self", ",", "cell", ",", "coords", ",", "cell_mode", "=", "CellMode", ".", "cooked", ")", ":", "# pylint: disable=too-many-return-statements", "if", "cell_mode", "==", "CellMode", ".", "cooked", ":", "if", "cell", ".", "ctype", "==",...
Parses a cell according to the cell.ctype.
[ "Parses", "a", "cell", "according", "to", "the", "cell", ".", "ctype", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/excel.py#L22-L55
treycucco/bidon
bidon/spreadsheet/excel.py
ExcelWorksheet.merged_cell_ranges
def merged_cell_ranges(self): """Generates the sequence of merged cell ranges in the format: ((col_low, row_low), (col_hi, row_hi)) """ for rlo, rhi, clo, chi in self.raw_sheet.merged_cells: yield ((clo, rlo), (chi, rhi))
python
def merged_cell_ranges(self): """Generates the sequence of merged cell ranges in the format: ((col_low, row_low), (col_hi, row_hi)) """ for rlo, rhi, clo, chi in self.raw_sheet.merged_cells: yield ((clo, rlo), (chi, rhi))
[ "def", "merged_cell_ranges", "(", "self", ")", ":", "for", "rlo", ",", "rhi", ",", "clo", ",", "chi", "in", "self", ".", "raw_sheet", ".", "merged_cells", ":", "yield", "(", "(", "clo", ",", "rlo", ")", ",", "(", "chi", ",", "rhi", ")", ")" ]
Generates the sequence of merged cell ranges in the format: ((col_low, row_low), (col_hi, row_hi))
[ "Generates", "the", "sequence", "of", "merged", "cell", "ranges", "in", "the", "format", ":" ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/excel.py#L61-L67
treycucco/bidon
bidon/spreadsheet/excel.py
ExcelWorksheet.get_note
def get_note(self, coords): """Get the note for the cell at the given coordinates. coords is a tuple of (col, row) """ col, row = coords note = self.raw_sheet.cell_note_map.get((row, col)) return note.text if note else None
python
def get_note(self, coords): """Get the note for the cell at the given coordinates. coords is a tuple of (col, row) """ col, row = coords note = self.raw_sheet.cell_note_map.get((row, col)) return note.text if note else None
[ "def", "get_note", "(", "self", ",", "coords", ")", ":", "col", ",", "row", "=", "coords", "note", "=", "self", ".", "raw_sheet", ".", "cell_note_map", ".", "get", "(", "(", "row", ",", "col", ")", ")", "return", "note", ".", "text", "if", "note", ...
Get the note for the cell at the given coordinates. coords is a tuple of (col, row)
[ "Get", "the", "note", "for", "the", "cell", "at", "the", "given", "coordinates", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/excel.py#L69-L76
treycucco/bidon
bidon/spreadsheet/excel.py
ExcelWorksheet._parse_date
def _parse_date(self, cell_value): """Attempts to parse a cell_value as a date.""" date_tuple = xlrd.xldate_as_tuple(cell_value, self.raw_sheet.book.datemode) return self.tuple_to_datetime(date_tuple)
python
def _parse_date(self, cell_value): """Attempts to parse a cell_value as a date.""" date_tuple = xlrd.xldate_as_tuple(cell_value, self.raw_sheet.book.datemode) return self.tuple_to_datetime(date_tuple)
[ "def", "_parse_date", "(", "self", ",", "cell_value", ")", ":", "date_tuple", "=", "xlrd", ".", "xldate_as_tuple", "(", "cell_value", ",", "self", ".", "raw_sheet", ".", "book", ".", "datemode", ")", "return", "self", ".", "tuple_to_datetime", "(", "date_tup...
Attempts to parse a cell_value as a date.
[ "Attempts", "to", "parse", "a", "cell_value", "as", "a", "date", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/excel.py#L78-L81
djangothon/ab
setup.py
reqfile
def reqfile(filepath): """Turns a text file into a list (one element per line)""" result = [] import re url_re = re.compile(".+:.+#egg=(.+)") with open(filepath, "r") as f: for line in f: line = line.strip() if not line or line.startswith("#"): continu...
python
def reqfile(filepath): """Turns a text file into a list (one element per line)""" result = [] import re url_re = re.compile(".+:.+#egg=(.+)") with open(filepath, "r") as f: for line in f: line = line.strip() if not line or line.startswith("#"): continu...
[ "def", "reqfile", "(", "filepath", ")", ":", "result", "=", "[", "]", "import", "re", "url_re", "=", "re", ".", "compile", "(", "\".+:.+#egg=(.+)\"", ")", "with", "open", "(", "filepath", ",", "\"r\"", ")", "as", "f", ":", "for", "line", "in", "f", ...
Turns a text file into a list (one element per line)
[ "Turns", "a", "text", "file", "into", "a", "list", "(", "one", "element", "per", "line", ")" ]
train
https://github.com/djangothon/ab/blob/2075d27805ad94b11535a11439027ce8d0c8ab83/setup.py#L6-L20
itsnauman/termrule
tr/termrule.py
TermRule._parse_args
def _parse_args(cls): """ Method to parse command line arguments """ cls.parser = argparse.ArgumentParser() cls.parser.add_argument( "symbol", help="Symbol for horizontal line", nargs="*") cls.parser.add_argument( "--color", "-c", help="Color of th...
python
def _parse_args(cls): """ Method to parse command line arguments """ cls.parser = argparse.ArgumentParser() cls.parser.add_argument( "symbol", help="Symbol for horizontal line", nargs="*") cls.parser.add_argument( "--color", "-c", help="Color of th...
[ "def", "_parse_args", "(", "cls", ")", ":", "cls", ".", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "cls", ".", "parser", ".", "add_argument", "(", "\"symbol\"", ",", "help", "=", "\"Symbol for horizontal line\"", ",", "nargs", "=", "\"*\"", ...
Method to parse command line arguments
[ "Method", "to", "parse", "command", "line", "arguments" ]
train
https://github.com/itsnauman/termrule/blob/62b8cc7e9a7fc4476ccdaf84fe2685eb529dc48c/tr/termrule.py#L45-L57
itsnauman/termrule
tr/termrule.py
TermRule.run_args
def run_args(self): """ Pass in the parsed args to the script """ self.arg_parser = self._parse_args() self.args = self.arg_parser.parse_args() color_name = self.args.color if color_name is not None: color_name = color_name[0] symbol = self.arg...
python
def run_args(self): """ Pass in the parsed args to the script """ self.arg_parser = self._parse_args() self.args = self.arg_parser.parse_args() color_name = self.args.color if color_name is not None: color_name = color_name[0] symbol = self.arg...
[ "def", "run_args", "(", "self", ")", ":", "self", ".", "arg_parser", "=", "self", ".", "_parse_args", "(", ")", "self", ".", "args", "=", "self", ".", "arg_parser", ".", "parse_args", "(", ")", "color_name", "=", "self", ".", "args", ".", "color", "i...
Pass in the parsed args to the script
[ "Pass", "in", "the", "parsed", "args", "to", "the", "script" ]
train
https://github.com/itsnauman/termrule/blob/62b8cc7e9a7fc4476ccdaf84fe2685eb529dc48c/tr/termrule.py#L59-L72
itsnauman/termrule
tr/termrule.py
TermRule._term_size
def _term_size(self): """ Method returns lines and columns according to terminal size """ for fd in (0, 1, 2): try: return self._ioctl_GWINSZ(fd) except: pass # try os.ctermid() try: fd = os.open(os.cterm...
python
def _term_size(self): """ Method returns lines and columns according to terminal size """ for fd in (0, 1, 2): try: return self._ioctl_GWINSZ(fd) except: pass # try os.ctermid() try: fd = os.open(os.cterm...
[ "def", "_term_size", "(", "self", ")", ":", "for", "fd", "in", "(", "0", ",", "1", ",", "2", ")", ":", "try", ":", "return", "self", ".", "_ioctl_GWINSZ", "(", "fd", ")", "except", ":", "pass", "# try os.ctermid()", "try", ":", "fd", "=", "os", "...
Method returns lines and columns according to terminal size
[ "Method", "returns", "lines", "and", "columns", "according", "to", "terminal", "size" ]
train
https://github.com/itsnauman/termrule/blob/62b8cc7e9a7fc4476ccdaf84fe2685eb529dc48c/tr/termrule.py#L77-L106
itsnauman/termrule
tr/termrule.py
TermRule.tr
def tr(self, args, color=None): """ Method to print ASCII patterns to terminal """ width = self._term_size()[1] if not args: if color is not None: print(self._echo("#" * width, color)) else: print(self._echo("#" * width, "gr...
python
def tr(self, args, color=None): """ Method to print ASCII patterns to terminal """ width = self._term_size()[1] if not args: if color is not None: print(self._echo("#" * width, color)) else: print(self._echo("#" * width, "gr...
[ "def", "tr", "(", "self", ",", "args", ",", "color", "=", "None", ")", ":", "width", "=", "self", ".", "_term_size", "(", ")", "[", "1", "]", "if", "not", "args", ":", "if", "color", "is", "not", "None", ":", "print", "(", "self", ".", "_echo",...
Method to print ASCII patterns to terminal
[ "Method", "to", "print", "ASCII", "patterns", "to", "terminal" ]
train
https://github.com/itsnauman/termrule/blob/62b8cc7e9a7fc4476ccdaf84fe2685eb529dc48c/tr/termrule.py#L108-L125
heikomuller/sco-client
scocli/__init__.py
SCOClient.cache_add
def cache_add(self, resource_url, cache_id): """Add entry permanently to local cache. Parameters ---------- resource_url : string Resource Url cache_id : string Unique cache identifier for resource """ # Add entry to cache index se...
python
def cache_add(self, resource_url, cache_id): """Add entry permanently to local cache. Parameters ---------- resource_url : string Resource Url cache_id : string Unique cache identifier for resource """ # Add entry to cache index se...
[ "def", "cache_add", "(", "self", ",", "resource_url", ",", "cache_id", ")", ":", "# Add entry to cache index", "self", ".", "cache", "[", "resource_url", "]", "=", "cache_id", "# Write cache index content to database file", "with", "open", "(", "self", ".", "db_file...
Add entry permanently to local cache. Parameters ---------- resource_url : string Resource Url cache_id : string Unique cache identifier for resource
[ "Add", "entry", "permanently", "to", "local", "cache", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L109-L124
heikomuller/sco-client
scocli/__init__.py
SCOClient.cache_clear
def cache_clear(self): """Clear local cache by deleting all cached resources and their downloaded files. """ # Delete content of local cache directory for f in os.listdir(self.directory): f = os.path.join(self.directory, f) if os.path.isfile(f): ...
python
def cache_clear(self): """Clear local cache by deleting all cached resources and their downloaded files. """ # Delete content of local cache directory for f in os.listdir(self.directory): f = os.path.join(self.directory, f) if os.path.isfile(f): ...
[ "def", "cache_clear", "(", "self", ")", ":", "# Delete content of local cache directory", "for", "f", "in", "os", ".", "listdir", "(", "self", ".", "directory", ")", ":", "f", "=", "os", ".", "path", ".", "join", "(", "self", ".", "directory", ",", "f", ...
Clear local cache by deleting all cached resources and their downloaded files.
[ "Clear", "local", "cache", "by", "deleting", "all", "cached", "resources", "and", "their", "downloaded", "files", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L126-L138
heikomuller/sco-client
scocli/__init__.py
SCOClient.get_api_references
def get_api_references(self, api_url=None): """Get set of HATEOAS reference for the given SCO-API. Use the default SCO-API if none is given. References are cached as they are not expected to change. Parameters ---------- Returns ------- """ # Get...
python
def get_api_references(self, api_url=None): """Get set of HATEOAS reference for the given SCO-API. Use the default SCO-API if none is given. References are cached as they are not expected to change. Parameters ---------- Returns ------- """ # Get...
[ "def", "get_api_references", "(", "self", ",", "api_url", "=", "None", ")", ":", "# Get subject listing Url for SCO-API", "if", "not", "api_url", "is", "None", ":", "url", "=", "api_url", "else", ":", "url", "=", "self", ".", "api_url", "# Check if API reference...
Get set of HATEOAS reference for the given SCO-API. Use the default SCO-API if none is given. References are cached as they are not expected to change. Parameters ---------- Returns -------
[ "Get", "set", "of", "HATEOAS", "reference", "for", "the", "given", "SCO", "-", "API", ".", "Use", "the", "default", "SCO", "-", "API", "if", "none", "is", "given", ".", "References", "are", "cached", "as", "they", "are", "not", "expected", "to", "chang...
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L140-L162
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_create
def experiments_create(self, name, subject_id, image_group_id, api_url=None, properties=None): """Create a new experiment at the given SCO-API. Subject and image group reference existing resources at the SCO-API. Parameters ---------- name : string User-defined name ...
python
def experiments_create(self, name, subject_id, image_group_id, api_url=None, properties=None): """Create a new experiment at the given SCO-API. Subject and image group reference existing resources at the SCO-API. Parameters ---------- name : string User-defined name ...
[ "def", "experiments_create", "(", "self", ",", "name", ",", "subject_id", ",", "image_group_id", ",", "api_url", "=", "None", ",", "properties", "=", "None", ")", ":", "# Create experiment and return handle for created resource", "return", "self", ".", "experiments_ge...
Create a new experiment at the given SCO-API. Subject and image group reference existing resources at the SCO-API. Parameters ---------- name : string User-defined name for experiment subject_id : string Unique identifier for subject at given SCO-API ...
[ "Create", "a", "new", "experiment", "at", "the", "given", "SCO", "-", "API", ".", "Subject", "and", "image", "group", "reference", "existing", "resources", "at", "the", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L168-L200
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_get
def experiments_get(self, resource_url): """Get handle for experiment resource at given Url. Parameters ---------- resource_url : string Url for experiment resource at SCO-API Returns ------- scoserv.ExperimentHandle Handle for local copy...
python
def experiments_get(self, resource_url): """Get handle for experiment resource at given Url. Parameters ---------- resource_url : string Url for experiment resource at SCO-API Returns ------- scoserv.ExperimentHandle Handle for local copy...
[ "def", "experiments_get", "(", "self", ",", "resource_url", ")", ":", "# Get resource directory, Json representation, active flag, and cache id", "obj_dir", ",", "obj_json", ",", "is_active", ",", "cache_id", "=", "self", ".", "get_object", "(", "resource_url", ")", "# ...
Get handle for experiment resource at given Url. Parameters ---------- resource_url : string Url for experiment resource at SCO-API Returns ------- scoserv.ExperimentHandle Handle for local copy of experiment resource
[ "Get", "handle", "for", "experiment", "resource", "at", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L202-L224
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_list
def experiments_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of experiment resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, option...
python
def experiments_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of experiment resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, option...
[ "def", "experiments_list", "(", "self", ",", "api_url", "=", "None", ",", "offset", "=", "0", ",", "limit", "=", "-", "1", ",", "properties", "=", "None", ")", ":", "# Get subject listing Url for given SCO-API and return the retrieved", "# resource listing", "return...
Get list of experiment resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional Starting offset for returned list items limit : int, optional ...
[ "Get", "list", "of", "experiment", "resources", "from", "a", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L226-L253
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_fmri_create
def experiments_fmri_create(self, experiment_url, data_file): """Upload given data file as fMRI for experiment with given Url. Parameters ---------- experiment_url : string Url for experiment resource data_file: Abs. Path to file on disk Functional data f...
python
def experiments_fmri_create(self, experiment_url, data_file): """Upload given data file as fMRI for experiment with given Url. Parameters ---------- experiment_url : string Url for experiment resource data_file: Abs. Path to file on disk Functional data f...
[ "def", "experiments_fmri_create", "(", "self", ",", "experiment_url", ",", "data_file", ")", ":", "# Get the experiment", "experiment", "=", "self", ".", "experiments_get", "(", "experiment_url", ")", "# Upload data", "FunctionalDataHandle", ".", "create", "(", "exper...
Upload given data file as fMRI for experiment with given Url. Parameters ---------- experiment_url : string Url for experiment resource data_file: Abs. Path to file on disk Functional data file Returns ------- scoserv.FunctionalDataHandle...
[ "Upload", "given", "data", "file", "as", "fMRI", "for", "experiment", "with", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L259-L282
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_fmri_get
def experiments_fmri_get(self, resource_url): """Get handle for functional fMRI resource at given Url. Parameters ---------- resource_url : string Url for fMRI resource at SCO-API Returns ------- scoserv.FunctionalDataHandle Handle for fu...
python
def experiments_fmri_get(self, resource_url): """Get handle for functional fMRI resource at given Url. Parameters ---------- resource_url : string Url for fMRI resource at SCO-API Returns ------- scoserv.FunctionalDataHandle Handle for fu...
[ "def", "experiments_fmri_get", "(", "self", ",", "resource_url", ")", ":", "# Get resource directory, Json representation, active flag, and cache id", "obj_dir", ",", "obj_json", ",", "is_active", ",", "cache_id", "=", "self", ".", "get_object", "(", "resource_url", ")", ...
Get handle for functional fMRI resource at given Url. Parameters ---------- resource_url : string Url for fMRI resource at SCO-API Returns ------- scoserv.FunctionalDataHandle Handle for funcrional MRI data resource
[ "Get", "handle", "for", "functional", "fMRI", "resource", "at", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L284-L306
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_predictions_create
def experiments_predictions_create(self, model_id, name, api_url, arguments={}, properties=None): """Create a new model run at the given SCO-API. Parameters ---------- model_id : string Unique model identifier name : string User-defined name for experimen...
python
def experiments_predictions_create(self, model_id, name, api_url, arguments={}, properties=None): """Create a new model run at the given SCO-API. Parameters ---------- model_id : string Unique model identifier name : string User-defined name for experimen...
[ "def", "experiments_predictions_create", "(", "self", ",", "model_id", ",", "name", ",", "api_url", ",", "arguments", "=", "{", "}", ",", "properties", "=", "None", ")", ":", "# Create experiment and return handle for created resource", "return", "self", ".", "exper...
Create a new model run at the given SCO-API. Parameters ---------- model_id : string Unique model identifier name : string User-defined name for experiment api_url : string Url to POST create model run request arguments : Dictionary ...
[ "Create", "a", "new", "model", "run", "at", "the", "given", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L312-L342
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_predictions_get
def experiments_predictions_get(self, resource_url): """Get handle for model run resource at given Url. Parameters ---------- resource_url : string Url for model run resource at SCO-API Returns ------- scoserv.ModelRunHandle Handle for lo...
python
def experiments_predictions_get(self, resource_url): """Get handle for model run resource at given Url. Parameters ---------- resource_url : string Url for model run resource at SCO-API Returns ------- scoserv.ModelRunHandle Handle for lo...
[ "def", "experiments_predictions_get", "(", "self", ",", "resource_url", ")", ":", "# Get resource directory, Json representation, active flag, and cache id", "obj_dir", ",", "obj_json", ",", "is_active", ",", "cache_id", "=", "self", ".", "get_object", "(", "resource_url", ...
Get handle for model run resource at given Url. Parameters ---------- resource_url : string Url for model run resource at SCO-API Returns ------- scoserv.ModelRunHandle Handle for local copy of model run resource
[ "Get", "handle", "for", "model", "run", "resource", "at", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L344-L366
heikomuller/sco-client
scocli/__init__.py
SCOClient.experiments_predictions_list
def experiments_predictions_list(self, listing_url, offset=0, limit=-1, properties=None): """Get list of experiment resources from a SCO-API. Parameters ---------- listing_url : string url for experiments run listing. offset : int, optional Starting offse...
python
def experiments_predictions_list(self, listing_url, offset=0, limit=-1, properties=None): """Get list of experiment resources from a SCO-API. Parameters ---------- listing_url : string url for experiments run listing. offset : int, optional Starting offse...
[ "def", "experiments_predictions_list", "(", "self", ",", "listing_url", ",", "offset", "=", "0", ",", "limit", "=", "-", "1", ",", "properties", "=", "None", ")", ":", "return", "sco", ".", "get_run_listing", "(", "listing_url", ",", "offset", "=", "offset...
Get list of experiment resources from a SCO-API. Parameters ---------- listing_url : string url for experiments run listing. offset : int, optional Starting offset for returned list items limit : int, optional Limit the number of items in the ...
[ "Get", "list", "of", "experiment", "resources", "from", "a", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L368-L393
heikomuller/sco-client
scocli/__init__.py
SCOClient.get_object
def get_object(self, resource_url): """Get remote resource information. Creates a local directory for the resource if this is the first access to the resource. Downloads the resource Json representation and writes it into a .json file in the cache directory. Raises ValueError if...
python
def get_object(self, resource_url): """Get remote resource information. Creates a local directory for the resource if this is the first access to the resource. Downloads the resource Json representation and writes it into a .json file in the cache directory. Raises ValueError if...
[ "def", "get_object", "(", "self", ",", "resource_url", ")", ":", "# Check if resource is in local cache. If not, create a new cache", "# identifier and set is_cached flag to false", "if", "resource_url", "in", "self", ".", "cache", ":", "cache_id", "=", "self", ".", "cache"...
Get remote resource information. Creates a local directory for the resource if this is the first access to the resource. Downloads the resource Json representation and writes it into a .json file in the cache directory. Raises ValueError if resource is not cached and does not exist. If ...
[ "Get", "remote", "resource", "information", ".", "Creates", "a", "local", "directory", "for", "the", "resource", "if", "this", "is", "the", "first", "access", "to", "the", "resource", ".", "Downloads", "the", "resource", "Json", "representation", "and", "write...
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L459-L517
heikomuller/sco-client
scocli/__init__.py
SCOClient.image_groups_create
def image_groups_create(self, filename, api_url=None, options=None, properties=None): """Create new image group at given SCO-API by uploading local file. Expects an tar-archive containing images in the image group. Allows to update properties of created resource. Parameters ----...
python
def image_groups_create(self, filename, api_url=None, options=None, properties=None): """Create new image group at given SCO-API by uploading local file. Expects an tar-archive containing images in the image group. Allows to update properties of created resource. Parameters ----...
[ "def", "image_groups_create", "(", "self", ",", "filename", ",", "api_url", "=", "None", ",", "options", "=", "None", ",", "properties", "=", "None", ")", ":", "# Create image group and return handle for created resource", "return", "self", ".", "image_groups_get", ...
Create new image group at given SCO-API by uploading local file. Expects an tar-archive containing images in the image group. Allows to update properties of created resource. Parameters ---------- filename : string Path to tar-archive on local disk api_url : ...
[ "Create", "new", "image", "group", "at", "given", "SCO", "-", "API", "by", "uploading", "local", "file", ".", "Expects", "an", "tar", "-", "archive", "containing", "images", "in", "the", "image", "group", ".", "Allows", "to", "update", "properties", "of", ...
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L523-L552
heikomuller/sco-client
scocli/__init__.py
SCOClient.image_groups_get
def image_groups_get(self, resource_url): """Get handle for image group resource at given Url. Parameters ---------- resource_url : string Url for image group resource at SCO-API Returns ------- scoserv.ImageGroupHandle Handle for local c...
python
def image_groups_get(self, resource_url): """Get handle for image group resource at given Url. Parameters ---------- resource_url : string Url for image group resource at SCO-API Returns ------- scoserv.ImageGroupHandle Handle for local c...
[ "def", "image_groups_get", "(", "self", ",", "resource_url", ")", ":", "# Get resource directory, Json representation, active flag, and cache id", "obj_dir", ",", "obj_json", ",", "is_active", ",", "cache_id", "=", "self", ".", "get_object", "(", "resource_url", ")", "#...
Get handle for image group resource at given Url. Parameters ---------- resource_url : string Url for image group resource at SCO-API Returns ------- scoserv.ImageGroupHandle Handle for local copy of image group resource
[ "Get", "handle", "for", "image", "group", "resource", "at", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L554-L576
heikomuller/sco-client
scocli/__init__.py
SCOClient.image_groups_list
def image_groups_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of image group resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, opti...
python
def image_groups_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of image group resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, opti...
[ "def", "image_groups_list", "(", "self", ",", "api_url", "=", "None", ",", "offset", "=", "0", ",", "limit", "=", "-", "1", ",", "properties", "=", "None", ")", ":", "# Get subject listing Url for given SCO-API and return the retrieved", "# resource listing", "retur...
Get list of image group resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional Starting offset for returned list items limit : int, optional ...
[ "Get", "list", "of", "image", "group", "resources", "from", "a", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L578-L605
heikomuller/sco-client
scocli/__init__.py
SCOClient.models_get
def models_get(self, resource_url): """Get handle for model resource at given Url. Parameters ---------- resource_url : string Url for subject resource at SCO-API Returns ------- models.ModelHandle Handle for local copy of subject resourc...
python
def models_get(self, resource_url): """Get handle for model resource at given Url. Parameters ---------- resource_url : string Url for subject resource at SCO-API Returns ------- models.ModelHandle Handle for local copy of subject resourc...
[ "def", "models_get", "(", "self", ",", "resource_url", ")", ":", "# Get resource directory, Json representation, active flag, and cache id", "obj_dir", ",", "obj_json", ",", "is_active", ",", "cache_id", "=", "self", ".", "get_object", "(", "resource_url", ")", "# Creat...
Get handle for model resource at given Url. Parameters ---------- resource_url : string Url for subject resource at SCO-API Returns ------- models.ModelHandle Handle for local copy of subject resource
[ "Get", "handle", "for", "model", "resource", "at", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L611-L632
heikomuller/sco-client
scocli/__init__.py
SCOClient.models_list
def models_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of model resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional ...
python
def models_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of model resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional ...
[ "def", "models_list", "(", "self", ",", "api_url", "=", "None", ",", "offset", "=", "0", ",", "limit", "=", "-", "1", ",", "properties", "=", "None", ")", ":", "# Get subject listing Url for given SCO-API and return the retrieved", "# resource listing", "return", ...
Get list of model resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional Starting offset for returned list items limit : int, optional ...
[ "Get", "list", "of", "model", "resources", "from", "a", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L634-L661
heikomuller/sco-client
scocli/__init__.py
SCOClient.subjects_create
def subjects_create(self, filename, api_url=None, properties=None): """Create new anatomy subject at given SCO-API by uploading local file. Expects an tar-archive containing a FreeSurfer anatomy. Parameters ---------- filename : string Path to tar-archive on local di...
python
def subjects_create(self, filename, api_url=None, properties=None): """Create new anatomy subject at given SCO-API by uploading local file. Expects an tar-archive containing a FreeSurfer anatomy. Parameters ---------- filename : string Path to tar-archive on local di...
[ "def", "subjects_create", "(", "self", ",", "filename", ",", "api_url", "=", "None", ",", "properties", "=", "None", ")", ":", "# Create image group and return handle for created resource", "return", "self", ".", "subjects_get", "(", "SubjectHandle", ".", "create", ...
Create new anatomy subject at given SCO-API by uploading local file. Expects an tar-archive containing a FreeSurfer anatomy. Parameters ---------- filename : string Path to tar-archive on local disk api_url : string, optional Base Url of SCO-API where sub...
[ "Create", "new", "anatomy", "subject", "at", "given", "SCO", "-", "API", "by", "uploading", "local", "file", ".", "Expects", "an", "tar", "-", "archive", "containing", "a", "FreeSurfer", "anatomy", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L667-L692
heikomuller/sco-client
scocli/__init__.py
SCOClient.subjects_get
def subjects_get(self, resource_url): """Get handle for subject resource at given Url. Parameters ---------- resource_url : string Url for subject resource at SCO-API Returns ------- scoserv.SubjectHandle Handle for local copy of subject ...
python
def subjects_get(self, resource_url): """Get handle for subject resource at given Url. Parameters ---------- resource_url : string Url for subject resource at SCO-API Returns ------- scoserv.SubjectHandle Handle for local copy of subject ...
[ "def", "subjects_get", "(", "self", ",", "resource_url", ")", ":", "# Get resource directory, Json representation, active flag, and cache id", "obj_dir", ",", "obj_json", ",", "is_active", ",", "cache_id", "=", "self", ".", "get_object", "(", "resource_url", ")", "# Cre...
Get handle for subject resource at given Url. Parameters ---------- resource_url : string Url for subject resource at SCO-API Returns ------- scoserv.SubjectHandle Handle for local copy of subject resource
[ "Get", "handle", "for", "subject", "resource", "at", "given", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L694-L716
heikomuller/sco-client
scocli/__init__.py
SCOClient.subjects_list
def subjects_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of subject resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional ...
python
def subjects_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of subject resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional ...
[ "def", "subjects_list", "(", "self", ",", "api_url", "=", "None", ",", "offset", "=", "0", ",", "limit", "=", "-", "1", ",", "properties", "=", "None", ")", ":", "# Get subject listing Url for given SCO-API and return the retrieved", "# resource listing", "return", ...
Get list of subject resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional Starting offset for returned list items limit : int, optional ...
[ "Get", "list", "of", "subject", "resources", "from", "a", "SCO", "-", "API", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L718-L745
mattbierner/blotre-py
blotre.py
create_disposable
def create_disposable(clientInfo, config = {}): """ Create a new disposable client. """ response = requests.put( _format_url( _extend(DEFAULT_CONFIG, config), OAUTH2_ROOT + 'disposable'), json = clientInfo) if response.status_code != 200: return ...
python
def create_disposable(clientInfo, config = {}): """ Create a new disposable client. """ response = requests.put( _format_url( _extend(DEFAULT_CONFIG, config), OAUTH2_ROOT + 'disposable'), json = clientInfo) if response.status_code != 200: return ...
[ "def", "create_disposable", "(", "clientInfo", ",", "config", "=", "{", "}", ")", ":", "response", "=", "requests", ".", "put", "(", "_format_url", "(", "_extend", "(", "DEFAULT_CONFIG", ",", "config", ")", ",", "OAUTH2_ROOT", "+", "'disposable'", ")", ","...
Create a new disposable client.
[ "Create", "a", "new", "disposable", "client", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L328-L346
mattbierner/blotre-py
blotre.py
_get_existing_disposable_app
def _get_existing_disposable_app(file, clientInfo, conf): """ Attempt to load an existing """ if not os.path.isfile(file): return None else: data = None with open(file, 'r') as f: data = json.load(f) if not 'client' in data or not 'creds' in data: ...
python
def _get_existing_disposable_app(file, clientInfo, conf): """ Attempt to load an existing """ if not os.path.isfile(file): return None else: data = None with open(file, 'r') as f: data = json.load(f) if not 'client' in data or not 'creds' in data: ...
[ "def", "_get_existing_disposable_app", "(", "file", ",", "clientInfo", ",", "conf", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file", ")", ":", "return", "None", "else", ":", "data", "=", "None", "with", "open", "(", "file", ",", ...
Attempt to load an existing
[ "Attempt", "to", "load", "an", "existing" ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L373-L388
mattbierner/blotre-py
blotre.py
_try_redeem_disposable_app
def _try_redeem_disposable_app(file, client): """ Attempt to redeem a one time code registred on the client. """ redeemedClient = client.redeem_onetime_code(None) if redeemedClient is None: return None else: return _BlotreDisposableApp(file, redeemedClient.client, ...
python
def _try_redeem_disposable_app(file, client): """ Attempt to redeem a one time code registred on the client. """ redeemedClient = client.redeem_onetime_code(None) if redeemedClient is None: return None else: return _BlotreDisposableApp(file, redeemedClient.client, ...
[ "def", "_try_redeem_disposable_app", "(", "file", ",", "client", ")", ":", "redeemedClient", "=", "client", ".", "redeem_onetime_code", "(", "None", ")", "if", "redeemedClient", "is", "None", ":", "return", "None", "else", ":", "return", "_BlotreDisposableApp", ...
Attempt to redeem a one time code registred on the client.
[ "Attempt", "to", "redeem", "a", "one", "time", "code", "registred", "on", "the", "client", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L390-L401
mattbierner/blotre-py
blotre.py
_check_app_is_valid
def _check_app_is_valid(client): """ Check to see if the app has valid creds. """ try: if 'refresh_token' in client.creds: client.exchange_refresh_token() else: existing.get_token_info() return True except TokenEndpointError as e: return False
python
def _check_app_is_valid(client): """ Check to see if the app has valid creds. """ try: if 'refresh_token' in client.creds: client.exchange_refresh_token() else: existing.get_token_info() return True except TokenEndpointError as e: return False
[ "def", "_check_app_is_valid", "(", "client", ")", ":", "try", ":", "if", "'refresh_token'", "in", "client", ".", "creds", ":", "client", ".", "exchange_refresh_token", "(", ")", "else", ":", "existing", ".", "get_token_info", "(", ")", "return", "True", "exc...
Check to see if the app has valid creds.
[ "Check", "to", "see", "if", "the", "app", "has", "valid", "creds", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L411-L422
mattbierner/blotre-py
blotre.py
create_disposable_app
def create_disposable_app(clientInfo, config={}): """ Use an existing disposable app if data exists or create a new one and persist the data. """ file = _get_disposable_app_filename(clientInfo) existing = _get_existing_disposable_app(file, clientInfo, config) if existing: if _check_a...
python
def create_disposable_app(clientInfo, config={}): """ Use an existing disposable app if data exists or create a new one and persist the data. """ file = _get_disposable_app_filename(clientInfo) existing = _get_existing_disposable_app(file, clientInfo, config) if existing: if _check_a...
[ "def", "create_disposable_app", "(", "clientInfo", ",", "config", "=", "{", "}", ")", ":", "file", "=", "_get_disposable_app_filename", "(", "clientInfo", ")", "existing", "=", "_get_existing_disposable_app", "(", "file", ",", "clientInfo", ",", "config", ")", "...
Use an existing disposable app if data exists or create a new one and persist the data.
[ "Use", "an", "existing", "disposable", "app", "if", "data", "exists", "or", "create", "a", "new", "one", "and", "persist", "the", "data", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L424-L437
mattbierner/blotre-py
blotre.py
Blotre.set_creds
def set_creds(self, newCreds): """Manually update the current creds.""" self.creds = newCreds self.on_creds_changed(newCreds) return self
python
def set_creds(self, newCreds): """Manually update the current creds.""" self.creds = newCreds self.on_creds_changed(newCreds) return self
[ "def", "set_creds", "(", "self", ",", "newCreds", ")", ":", "self", ".", "creds", "=", "newCreds", "self", ".", "on_creds_changed", "(", "newCreds", ")", "return", "self" ]
Manually update the current creds.
[ "Manually", "update", "the", "current", "creds", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L86-L90
mattbierner/blotre-py
blotre.py
Blotre.normalize_uri
def normalize_uri(self, uri): """Convert a stream path into it's normalized form.""" return urllib.quote( re.sub(r"\s", '+', uri.strip().lower()), safe = '~@#$&()*!+=:),.?/\'')
python
def normalize_uri(self, uri): """Convert a stream path into it's normalized form.""" return urllib.quote( re.sub(r"\s", '+', uri.strip().lower()), safe = '~@#$&()*!+=:),.?/\'')
[ "def", "normalize_uri", "(", "self", ",", "uri", ")", ":", "return", "urllib", ".", "quote", "(", "re", ".", "sub", "(", "r\"\\s\"", ",", "'+'", ",", "uri", ".", "strip", "(", ")", ".", "lower", "(", ")", ")", ",", "safe", "=", "'~@#$&()*!+=:),.?/\...
Convert a stream path into it's normalized form.
[ "Convert", "a", "stream", "path", "into", "it", "s", "normalized", "form", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L98-L102
mattbierner/blotre-py
blotre.py
Blotre.get_authorization_url
def get_authorization_url(self): """Get the authorization Url for the current client.""" return self._format_url( OAUTH2_ROOT + 'authorize', query = { 'response_type': 'code', 'client_id': self.client.get('client_id', ''), 'redirect...
python
def get_authorization_url(self): """Get the authorization Url for the current client.""" return self._format_url( OAUTH2_ROOT + 'authorize', query = { 'response_type': 'code', 'client_id': self.client.get('client_id', ''), 'redirect...
[ "def", "get_authorization_url", "(", "self", ")", ":", "return", "self", ".", "_format_url", "(", "OAUTH2_ROOT", "+", "'authorize'", ",", "query", "=", "{", "'response_type'", ":", "'code'", ",", "'client_id'", ":", "self", ".", "client", ".", "get", "(", ...
Get the authorization Url for the current client.
[ "Get", "the", "authorization", "Url", "for", "the", "current", "client", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L121-L129
mattbierner/blotre-py
blotre.py
Blotre._access_token_endpoint
def _access_token_endpoint(self, grantType, extraParams={}): """ Base exchange of data for an access_token. """ response = requests.post( self._format_url(OAUTH2_ROOT + 'access_token'), data = _extend({ 'grant_type': grantType, 'cli...
python
def _access_token_endpoint(self, grantType, extraParams={}): """ Base exchange of data for an access_token. """ response = requests.post( self._format_url(OAUTH2_ROOT + 'access_token'), data = _extend({ 'grant_type': grantType, 'cli...
[ "def", "_access_token_endpoint", "(", "self", ",", "grantType", ",", "extraParams", "=", "{", "}", ")", ":", "response", "=", "requests", ".", "post", "(", "self", ".", "_format_url", "(", "OAUTH2_ROOT", "+", "'access_token'", ")", ",", "data", "=", "_exte...
Base exchange of data for an access_token.
[ "Base", "exchange", "of", "data", "for", "an", "access_token", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L138-L155
mattbierner/blotre-py
blotre.py
Blotre.get_token_info
def get_token_info(self): """ Get information about the current access token. """ response = requests.get( self._format_url(OAUTH2_ROOT + 'token_info', { 'token': self.creds['access_token'] })) data = response.json() if response.sta...
python
def get_token_info(self): """ Get information about the current access token. """ response = requests.get( self._format_url(OAUTH2_ROOT + 'token_info', { 'token': self.creds['access_token'] })) data = response.json() if response.sta...
[ "def", "get_token_info", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "self", ".", "_format_url", "(", "OAUTH2_ROOT", "+", "'token_info'", ",", "{", "'token'", ":", "self", ".", "creds", "[", "'access_token'", "]", "}", ")", ")", ...
Get information about the current access token.
[ "Get", "information", "about", "the", "current", "access", "token", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L185-L197
mattbierner/blotre-py
blotre.py
Blotre._add_auth_headers
def _add_auth_headers(self, base): """Attach the acces_token to a request.""" if 'access_token' in self.creds: return _extend(base, { 'authorization': 'Bearer ' + self.creds['access_token'] }) return base
python
def _add_auth_headers(self, base): """Attach the acces_token to a request.""" if 'access_token' in self.creds: return _extend(base, { 'authorization': 'Bearer ' + self.creds['access_token'] }) return base
[ "def", "_add_auth_headers", "(", "self", ",", "base", ")", ":", "if", "'access_token'", "in", "self", ".", "creds", ":", "return", "_extend", "(", "base", ",", "{", "'authorization'", ":", "'Bearer '", "+", "self", ".", "creds", "[", "'access_token'", "]",...
Attach the acces_token to a request.
[ "Attach", "the", "acces_token", "to", "a", "request", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L200-L206
mattbierner/blotre-py
blotre.py
Blotre._is_expired_response
def _is_expired_response(self, response): """ Check if the response failed because of an expired access token. """ if response.status_code != 401: return False challenge = response.headers.get('www-authenticate', '') return 'error="invalid_token"' in challenge
python
def _is_expired_response(self, response): """ Check if the response failed because of an expired access token. """ if response.status_code != 401: return False challenge = response.headers.get('www-authenticate', '') return 'error="invalid_token"' in challenge
[ "def", "_is_expired_response", "(", "self", ",", "response", ")", ":", "if", "response", ".", "status_code", "!=", "401", ":", "return", "False", "challenge", "=", "response", ".", "headers", ".", "get", "(", "'www-authenticate'", ",", "''", ")", "return", ...
Check if the response failed because of an expired access token.
[ "Check", "if", "the", "response", "failed", "because", "of", "an", "expired", "access", "token", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L208-L215
mattbierner/blotre-py
blotre.py
Blotre._make_request
def _make_request(self, type, path, args, noRetry=False): """ Make a request to Blot're. Attempts to reply the request if it fails due to an expired access token. """ response = getattr(requests, type)(path, headers = self._add_auth_headers(_JSON_HEADERS), **args...
python
def _make_request(self, type, path, args, noRetry=False): """ Make a request to Blot're. Attempts to reply the request if it fails due to an expired access token. """ response = getattr(requests, type)(path, headers = self._add_auth_headers(_JSON_HEADERS), **args...
[ "def", "_make_request", "(", "self", ",", "type", ",", "path", ",", "args", ",", "noRetry", "=", "False", ")", ":", "response", "=", "getattr", "(", "requests", ",", "type", ")", "(", "path", ",", "headers", "=", "self", ".", "_add_auth_headers", "(", ...
Make a request to Blot're. Attempts to reply the request if it fails due to an expired access token.
[ "Make", "a", "request", "to", "Blot", "re", ".", "Attempts", "to", "reply", "the", "request", "if", "it", "fails", "due", "to", "an", "expired", "access", "token", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L217-L234
mattbierner/blotre-py
blotre.py
Blotre.get
def get(self, path, query={}): """GET request.""" return self._make_request('get', self._format_url(API_ROOT + path, query=query), {})
python
def get(self, path, query={}): """GET request.""" return self._make_request('get', self._format_url(API_ROOT + path, query=query), {})
[ "def", "get", "(", "self", ",", "path", ",", "query", "=", "{", "}", ")", ":", "return", "self", ".", "_make_request", "(", "'get'", ",", "self", ".", "_format_url", "(", "API_ROOT", "+", "path", ",", "query", "=", "query", ")", ",", "{", "}", ")...
GET request.
[ "GET", "request", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L236-L239
mattbierner/blotre-py
blotre.py
Blotre.post
def post(self, path, body): """POST request.""" return self._make_request('post', self._format_url(API_ROOT + path), { 'json': body })
python
def post(self, path, body): """POST request.""" return self._make_request('post', self._format_url(API_ROOT + path), { 'json': body })
[ "def", "post", "(", "self", ",", "path", ",", "body", ")", ":", "return", "self", ".", "_make_request", "(", "'post'", ",", "self", ".", "_format_url", "(", "API_ROOT", "+", "path", ")", ",", "{", "'json'", ":", "body", "}", ")" ]
POST request.
[ "POST", "request", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L241-L246
mattbierner/blotre-py
blotre.py
Blotre.put
def put(self, path, body): """PUT request.""" return self._make_request('put', self._format_url(API_ROOT + path), { 'json': body })
python
def put(self, path, body): """PUT request.""" return self._make_request('put', self._format_url(API_ROOT + path), { 'json': body })
[ "def", "put", "(", "self", ",", "path", ",", "body", ")", ":", "return", "self", ".", "_make_request", "(", "'put'", ",", "self", ".", "_format_url", "(", "API_ROOT", "+", "path", ")", ",", "{", "'json'", ":", "body", "}", ")" ]
PUT request.
[ "PUT", "request", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L248-L253
mattbierner/blotre-py
blotre.py
Blotre.get_child
def get_child(self, streamId, childId, options={}): """Get the child of a stream.""" return self.get('stream/' + streamId + '/children/' + childId, options)
python
def get_child(self, streamId, childId, options={}): """Get the child of a stream.""" return self.get('stream/' + streamId + '/children/' + childId, options)
[ "def", "get_child", "(", "self", ",", "streamId", ",", "childId", ",", "options", "=", "{", "}", ")", ":", "return", "self", ".", "get", "(", "'stream/'", "+", "streamId", "+", "'/children/'", "+", "childId", ",", "options", ")" ]
Get the child of a stream.
[ "Get", "the", "child", "of", "a", "stream", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L294-L296
mattbierner/blotre-py
blotre.py
_BlotreDisposableApp._persist
def _persist(self): """Persist client data.""" with open(self.file, 'w') as f: json.dump({ 'client': self.client, 'creds': self.creds, 'config': self.config }, f)
python
def _persist(self): """Persist client data.""" with open(self.file, 'w') as f: json.dump({ 'client': self.client, 'creds': self.creds, 'config': self.config }, f)
[ "def", "_persist", "(", "self", ")", ":", "with", "open", "(", "self", ".", "file", ",", "'w'", ")", "as", "f", ":", "json", ".", "dump", "(", "{", "'client'", ":", "self", ".", "client", ",", "'creds'", ":", "self", ".", "creds", ",", "'config'"...
Persist client data.
[ "Persist", "client", "data", "." ]
train
https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L358-L365
etscrivner/nose-perfdump
perfdump/plugin.py
PerfDumpPlugin.options
def options(self, parser, env=os.environ): """Handle parsing additional command-line options""" super(PerfDumpPlugin, self).options(parser, env=env) parser.add_option("", "--perfdump-html", dest="perfdump_html_file", help="Set destination for HTML report output")
python
def options(self, parser, env=os.environ): """Handle parsing additional command-line options""" super(PerfDumpPlugin, self).options(parser, env=env) parser.add_option("", "--perfdump-html", dest="perfdump_html_file", help="Set destination for HTML report output")
[ "def", "options", "(", "self", ",", "parser", ",", "env", "=", "os", ".", "environ", ")", ":", "super", "(", "PerfDumpPlugin", ",", "self", ")", ".", "options", "(", "parser", ",", "env", "=", "env", ")", "parser", ".", "add_option", "(", "\"\"", "...
Handle parsing additional command-line options
[ "Handle", "parsing", "additional", "command", "-", "line", "options" ]
train
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/plugin.py#L87-L91
etscrivner/nose-perfdump
perfdump/plugin.py
PerfDumpPlugin.configure
def configure(self, options, conf): """Configure this plugin using the given options""" super(PerfDumpPlugin, self).configure(options, conf) if not self.enabled: return try: self.html_output_file = options.perfdump_html_file except: pass ...
python
def configure(self, options, conf): """Configure this plugin using the given options""" super(PerfDumpPlugin, self).configure(options, conf) if not self.enabled: return try: self.html_output_file = options.perfdump_html_file except: pass ...
[ "def", "configure", "(", "self", ",", "options", ",", "conf", ")", ":", "super", "(", "PerfDumpPlugin", ",", "self", ")", ".", "configure", "(", "options", ",", "conf", ")", "if", "not", "self", ".", "enabled", ":", "return", "try", ":", "self", ".",...
Configure this plugin using the given options
[ "Configure", "this", "plugin", "using", "the", "given", "options" ]
train
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/plugin.py#L93-L102
etscrivner/nose-perfdump
perfdump/plugin.py
PerfDumpPlugin.report
def report(self, stream): """Displays the slowest tests""" self.db.commit() stream.writeln() self.draw_header(stream, "10 SLOWEST SETUPS") self.display_slowest_setups(stream) stream.writeln() self.draw_header(stream, "10 SLOWEST TESTS") self.display_slow...
python
def report(self, stream): """Displays the slowest tests""" self.db.commit() stream.writeln() self.draw_header(stream, "10 SLOWEST SETUPS") self.display_slowest_setups(stream) stream.writeln() self.draw_header(stream, "10 SLOWEST TESTS") self.display_slow...
[ "def", "report", "(", "self", ",", "stream", ")", ":", "self", ".", "db", ".", "commit", "(", ")", "stream", ".", "writeln", "(", ")", "self", ".", "draw_header", "(", "stream", ",", "\"10 SLOWEST SETUPS\"", ")", "self", ".", "display_slowest_setups", "(...
Displays the slowest tests
[ "Displays", "the", "slowest", "tests" ]
train
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/plugin.py#L130-L144
etscrivner/nose-perfdump
perfdump/plugin.py
PerfDumpPlugin.draw_header
def draw_header(self, stream, header): """Draw header with underline""" stream.writeln('=' * (len(header) + 4)) stream.writeln('| ' + header + ' |') stream.writeln('=' * (len(header) + 4)) stream.writeln()
python
def draw_header(self, stream, header): """Draw header with underline""" stream.writeln('=' * (len(header) + 4)) stream.writeln('| ' + header + ' |') stream.writeln('=' * (len(header) + 4)) stream.writeln()
[ "def", "draw_header", "(", "self", ",", "stream", ",", "header", ")", ":", "stream", ".", "writeln", "(", "'='", "*", "(", "len", "(", "header", ")", "+", "4", ")", ")", "stream", ".", "writeln", "(", "'| '", "+", "header", "+", "' |'", ")", "str...
Draw header with underline
[ "Draw", "header", "with", "underline" ]
train
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/plugin.py#L146-L151