repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
redhat-cip/dci-control-server
dci/api/v1/components.py
get_component_types
def get_component_types(topic_id, remoteci_id, db_conn=None): """Returns either the topic component types or the rconfigration's component types.""" db_conn = db_conn or flask.g.db_conn rconfiguration = remotecis.get_remoteci_configuration(topic_id, ...
python
def get_component_types(topic_id, remoteci_id, db_conn=None): """Returns either the topic component types or the rconfigration's component types.""" db_conn = db_conn or flask.g.db_conn rconfiguration = remotecis.get_remoteci_configuration(topic_id, ...
[ "def", "get_component_types", "(", "topic_id", ",", "remoteci_id", ",", "db_conn", "=", "None", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "rconfiguration", "=", "remotecis", ".", "get_remoteci_configuration", "(", "topic_id", ...
Returns either the topic component types or the rconfigration's component types.
[ "Returns", "either", "the", "topic", "component", "types", "or", "the", "rconfigration", "s", "component", "types", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L350-L368
train
redhat-cip/dci-control-server
dci/api/v1/components.py
get_last_components_by_type
def get_last_components_by_type(component_types, topic_id, db_conn=None): """For each component type of a topic, get the last one.""" db_conn = db_conn or flask.g.db_conn schedule_components_ids = [] for ct in component_types: where_clause = sql.and_(models.COMPONENTS.c.type == ct, ...
python
def get_last_components_by_type(component_types, topic_id, db_conn=None): """For each component type of a topic, get the last one.""" db_conn = db_conn or flask.g.db_conn schedule_components_ids = [] for ct in component_types: where_clause = sql.and_(models.COMPONENTS.c.type == ct, ...
[ "def", "get_last_components_by_type", "(", "component_types", ",", "topic_id", ",", "db_conn", "=", "None", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "schedule_components_ids", "=", "[", "]", "for", "ct", "in", "component_ty...
For each component type of a topic, get the last one.
[ "For", "each", "component", "type", "of", "a", "topic", "get", "the", "last", "one", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L371-L395
train
redhat-cip/dci-control-server
dci/api/v1/components.py
verify_and_get_components_ids
def verify_and_get_components_ids(topic_id, components_ids, component_types, db_conn=None): """Process some verifications of the provided components ids.""" db_conn = db_conn or flask.g.db_conn if len(components_ids) != len(component_types): msg = 'The number of com...
python
def verify_and_get_components_ids(topic_id, components_ids, component_types, db_conn=None): """Process some verifications of the provided components ids.""" db_conn = db_conn or flask.g.db_conn if len(components_ids) != len(component_types): msg = 'The number of com...
[ "def", "verify_and_get_components_ids", "(", "topic_id", ",", "components_ids", ",", "component_types", ",", "db_conn", "=", "None", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "if", "len", "(", "components_ids", ")", "!=", ...
Process some verifications of the provided components ids.
[ "Process", "some", "verifications", "of", "the", "provided", "components", "ids", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L398-L428
train
redhat-cip/dci-control-server
dci/api/v1/components.py
retrieve_tags_from_component
def retrieve_tags_from_component(user, c_id): """Retrieve all tags attached to a component.""" JCT = models.JOIN_COMPONENTS_TAGS query = (sql.select([models.TAGS]) .select_from(JCT.join(models.TAGS)) .where(JCT.c.component_id == c_id)) rows = flask.g.db_conn.execute(query) ...
python
def retrieve_tags_from_component(user, c_id): """Retrieve all tags attached to a component.""" JCT = models.JOIN_COMPONENTS_TAGS query = (sql.select([models.TAGS]) .select_from(JCT.join(models.TAGS)) .where(JCT.c.component_id == c_id)) rows = flask.g.db_conn.execute(query) ...
[ "def", "retrieve_tags_from_component", "(", "user", ",", "c_id", ")", ":", "JCT", "=", "models", ".", "JOIN_COMPONENTS_TAGS", "query", "=", "(", "sql", ".", "select", "(", "[", "models", ".", "TAGS", "]", ")", ".", "select_from", "(", "JCT", ".", "join",...
Retrieve all tags attached to a component.
[ "Retrieve", "all", "tags", "attached", "to", "a", "component", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L464-L472
train
redhat-cip/dci-control-server
dci/api/v1/components.py
add_tag_for_component
def add_tag_for_component(user, c_id): """Add a tag on a specific component.""" v1_utils.verify_existence_and_get(c_id, _TABLE) values = { 'component_id': c_id } component_tagged = tags.add_tag_to_resource(values, models.JOIN_COMPONENTS_TAGS...
python
def add_tag_for_component(user, c_id): """Add a tag on a specific component.""" v1_utils.verify_existence_and_get(c_id, _TABLE) values = { 'component_id': c_id } component_tagged = tags.add_tag_to_resource(values, models.JOIN_COMPONENTS_TAGS...
[ "def", "add_tag_for_component", "(", "user", ",", "c_id", ")", ":", "v1_utils", ".", "verify_existence_and_get", "(", "c_id", ",", "_TABLE", ")", "values", "=", "{", "'component_id'", ":", "c_id", "}", "component_tagged", "=", "tags", ".", "add_tag_to_resource",...
Add a tag on a specific component.
[ "Add", "a", "tag", "on", "a", "specific", "component", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L477-L490
train
redhat-cip/dci-control-server
dci/api/v1/components.py
delete_tag_for_component
def delete_tag_for_component(user, c_id, tag_id): """Delete a tag on a specific component.""" # Todo : check c_id and tag_id exist in db query = _TABLE_TAGS.delete().where(_TABLE_TAGS.c.tag_id == tag_id and _TABLE_TAGS.c.component_id == c_id) try: flask.g...
python
def delete_tag_for_component(user, c_id, tag_id): """Delete a tag on a specific component.""" # Todo : check c_id and tag_id exist in db query = _TABLE_TAGS.delete().where(_TABLE_TAGS.c.tag_id == tag_id and _TABLE_TAGS.c.component_id == c_id) try: flask.g...
[ "def", "delete_tag_for_component", "(", "user", ",", "c_id", ",", "tag_id", ")", ":", "# Todo : check c_id and tag_id exist in db", "query", "=", "_TABLE_TAGS", ".", "delete", "(", ")", ".", "where", "(", "_TABLE_TAGS", ".", "c", ".", "tag_id", "==", "tag_id", ...
Delete a tag on a specific component.
[ "Delete", "a", "tag", "on", "a", "specific", "component", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L495-L507
train
smarie/python-valid8
valid8/base.py
should_be_hidden_as_cause
def should_be_hidden_as_cause(exc): """ Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error """ # reduced traceback in case of HasWrongType (instance_of checks) from valid8.validation_lib.types import HasWrongType, IsWrongType return isinstance(exc, (H...
python
def should_be_hidden_as_cause(exc): """ Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error """ # reduced traceback in case of HasWrongType (instance_of checks) from valid8.validation_lib.types import HasWrongType, IsWrongType return isinstance(exc, (H...
[ "def", "should_be_hidden_as_cause", "(", "exc", ")", ":", "# reduced traceback in case of HasWrongType (instance_of checks)", "from", "valid8", ".", "validation_lib", ".", "types", "import", "HasWrongType", ",", "IsWrongType", "return", "isinstance", "(", "exc", ",", "(",...
Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error
[ "Used", "everywhere", "to", "decide", "if", "some", "exception", "type", "should", "be", "displayed", "or", "hidden", "as", "the", "casue", "of", "an", "error" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L59-L63
train
smarie/python-valid8
valid8/base.py
is_error_of_type
def is_error_of_type(exc, ref_type): """ Helper function to determine if some exception is of some type, by also looking at its declared __cause__ :param exc: :param ref_type: :return: """ if isinstance(exc, ref_type): return True elif hasattr(exc, '__cause__') and exc.__cause__...
python
def is_error_of_type(exc, ref_type): """ Helper function to determine if some exception is of some type, by also looking at its declared __cause__ :param exc: :param ref_type: :return: """ if isinstance(exc, ref_type): return True elif hasattr(exc, '__cause__') and exc.__cause__...
[ "def", "is_error_of_type", "(", "exc", ",", "ref_type", ")", ":", "if", "isinstance", "(", "exc", ",", "ref_type", ")", ":", "return", "True", "elif", "hasattr", "(", "exc", ",", "'__cause__'", ")", "and", "exc", ".", "__cause__", "is", "not", "None", ...
Helper function to determine if some exception is of some type, by also looking at its declared __cause__ :param exc: :param ref_type: :return:
[ "Helper", "function", "to", "determine", "if", "some", "exception", "is", "of", "some", "type", "by", "also", "looking", "at", "its", "declared", "__cause__" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L103-L114
train
smarie/python-valid8
valid8/base.py
_failure_raiser
def _failure_raiser(validation_callable, # type: Callable failure_type=None, # type: Type[WrappingFailure] help_msg=None, # type: str **kw_context_args): # type: (...) -> Callable """ Wraps the provided validation function so that in ...
python
def _failure_raiser(validation_callable, # type: Callable failure_type=None, # type: Type[WrappingFailure] help_msg=None, # type: str **kw_context_args): # type: (...) -> Callable """ Wraps the provided validation function so that in ...
[ "def", "_failure_raiser", "(", "validation_callable", ",", "# type: Callable", "failure_type", "=", "None", ",", "# type: Type[WrappingFailure]", "help_msg", "=", "None", ",", "# type: str", "*", "*", "kw_context_args", ")", ":", "# type: (...) -> Callable", "# check fail...
Wraps the provided validation function so that in case of failure it raises the given failure_type or a WrappingFailure with the given help message. :param validation_callable: :param failure_type: an optional subclass of `WrappingFailure` that should be raised in case of failure, instead of `WrappingF...
[ "Wraps", "the", "provided", "validation", "function", "so", "that", "in", "case", "of", "failure", "it", "raises", "the", "given", "failure_type", "or", "a", "WrappingFailure", "with", "the", "given", "help", "message", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L413-L477
train
smarie/python-valid8
valid8/base.py
_none_accepter
def _none_accepter(validation_callable # type: Callable ): # type: (...) -> Callable """ Wraps the given validation callable to accept None values silently. When a None value is received by the wrapper, it is not passed to the validation_callable and instead this function will return...
python
def _none_accepter(validation_callable # type: Callable ): # type: (...) -> Callable """ Wraps the given validation callable to accept None values silently. When a None value is received by the wrapper, it is not passed to the validation_callable and instead this function will return...
[ "def", "_none_accepter", "(", "validation_callable", "# type: Callable", ")", ":", "# type: (...) -> Callable", "# option (a) use the `decorate()` helper method to preserve name and signature of the inner object", "# ==> NO, we want to support also non-function callable objects", "# option (b) s...
Wraps the given validation callable to accept None values silently. When a None value is received by the wrapper, it is not passed to the validation_callable and instead this function will return True. When any other value is received the validation_callable is called as usual. Note: the created wrapper ha...
[ "Wraps", "the", "given", "validation", "callable", "to", "accept", "None", "values", "silently", ".", "When", "a", "None", "value", "is", "received", "by", "the", "wrapper", "it", "is", "not", "passed", "to", "the", "validation_callable", "and", "instead", "...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L484-L512
train
smarie/python-valid8
valid8/base.py
_none_rejecter
def _none_rejecter(validation_callable # type: Callable ): # type: (...) -> Callable """ Wraps the given validation callable to reject None values. When a None value is received by the wrapper, it is not passed to the validation_callable and instead this function will raise a Wrappin...
python
def _none_rejecter(validation_callable # type: Callable ): # type: (...) -> Callable """ Wraps the given validation callable to reject None values. When a None value is received by the wrapper, it is not passed to the validation_callable and instead this function will raise a Wrappin...
[ "def", "_none_rejecter", "(", "validation_callable", "# type: Callable", ")", ":", "# type: (...) -> Callable", "# option (a) use the `decorate()` helper method to preserve name and signature of the inner object", "# ==> NO, we want to support also non-function callable objects", "# option (b) s...
Wraps the given validation callable to reject None values. When a None value is received by the wrapper, it is not passed to the validation_callable and instead this function will raise a WrappingFailure. When any other value is received the validation_callable is called as usual. :param validation_callabl...
[ "Wraps", "the", "given", "validation", "callable", "to", "reject", "None", "values", ".", "When", "a", "None", "value", "is", "received", "by", "the", "wrapper", "it", "is", "not", "passed", "to", "the", "validation_callable", "and", "instead", "this", "func...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L515-L539
train
smarie/python-valid8
valid8/base.py
HelpMsgMixIn.get_help_msg
def get_help_msg(self, dotspace_ending=False, # type: bool **kwargs): # type: (...) -> str """ The method used to get the formatted help message according to kwargs. By default it returns the 'help_msg' attribute, whether it is defined at the in...
python
def get_help_msg(self, dotspace_ending=False, # type: bool **kwargs): # type: (...) -> str """ The method used to get the formatted help message according to kwargs. By default it returns the 'help_msg' attribute, whether it is defined at the in...
[ "def", "get_help_msg", "(", "self", ",", "dotspace_ending", "=", "False", ",", "# type: bool", "*", "*", "kwargs", ")", ":", "# type: (...) -> str", "context", "=", "self", ".", "get_context_for_help_msgs", "(", "kwargs", ")", "if", "self", ".", "help_msg", "i...
The method used to get the formatted help message according to kwargs. By default it returns the 'help_msg' attribute, whether it is defined at the instance level or at the class level. The help message is formatted according to help_msg.format(**kwargs), and may be terminated with a dot and a ...
[ "The", "method", "used", "to", "get", "the", "formatted", "help", "message", "according", "to", "kwargs", ".", "By", "default", "it", "returns", "the", "help_msg", "attribute", "whether", "it", "is", "defined", "at", "the", "instance", "level", "or", "at", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L156-L201
train
smarie/python-valid8
valid8/base.py
Failure.get_details
def get_details(self): """ The function called to get the details appended to the help message when self.append_details is True """ strval = str(self.wrong_value) if len(strval) > self.__max_str_length_displayed__: return '(Actual value is too big to be printed in this message)' ...
python
def get_details(self): """ The function called to get the details appended to the help message when self.append_details is True """ strval = str(self.wrong_value) if len(strval) > self.__max_str_length_displayed__: return '(Actual value is too big to be printed in this message)' ...
[ "def", "get_details", "(", "self", ")", ":", "strval", "=", "str", "(", "self", ".", "wrong_value", ")", "if", "len", "(", "strval", ")", ">", "self", ".", "__max_str_length_displayed__", ":", "return", "'(Actual value is too big to be printed in this message)'", ...
The function called to get the details appended to the help message when self.append_details is True
[ "The", "function", "called", "to", "get", "the", "details", "appended", "to", "the", "help", "message", "when", "self", ".", "append_details", "is", "True" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L308-L314
train
smarie/python-valid8
valid8/base.py
WrappingFailure.get_details
def get_details(self): """ Overrides the method in Failure so as to add a few details about the wrapped function and outcome """ if isinstance(self.validation_outcome, Exception): if isinstance(self.validation_outcome, Failure): # do not say again what was the value, it is a...
python
def get_details(self): """ Overrides the method in Failure so as to add a few details about the wrapped function and outcome """ if isinstance(self.validation_outcome, Exception): if isinstance(self.validation_outcome, Failure): # do not say again what was the value, it is a...
[ "def", "get_details", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "validation_outcome", ",", "Exception", ")", ":", "if", "isinstance", "(", "self", ".", "validation_outcome", ",", "Failure", ")", ":", "# do not say again what was the value, it is...
Overrides the method in Failure so as to add a few details about the wrapped function and outcome
[ "Overrides", "the", "method", "in", "Failure", "so", "as", "to", "add", "a", "few", "details", "about", "the", "wrapped", "function", "and", "outcome" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L385-L404
train
smarie/python-valid8
valid8/base.py
WrappingFailure.get_context_for_help_msgs
def get_context_for_help_msgs(self, context_dict): """ We override this method from HelpMsgMixIn to replace wrapped_func with its name """ context_dict = copy(context_dict) context_dict['wrapped_func'] = get_callable_name(context_dict['wrapped_func']) return context_dict
python
def get_context_for_help_msgs(self, context_dict): """ We override this method from HelpMsgMixIn to replace wrapped_func with its name """ context_dict = copy(context_dict) context_dict['wrapped_func'] = get_callable_name(context_dict['wrapped_func']) return context_dict
[ "def", "get_context_for_help_msgs", "(", "self", ",", "context_dict", ")", ":", "context_dict", "=", "copy", "(", "context_dict", ")", "context_dict", "[", "'wrapped_func'", "]", "=", "get_callable_name", "(", "context_dict", "[", "'wrapped_func'", "]", ")", "retu...
We override this method from HelpMsgMixIn to replace wrapped_func with its name
[ "We", "override", "this", "method", "from", "HelpMsgMixIn", "to", "replace", "wrapped_func", "with", "its", "name" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L406-L410
train
smarie/python-valid8
valid8/entry_points_annotations.py
validate_field
def validate_field(cls, field_name, *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__, it wraps the d...
python
def validate_field(cls, field_name, *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__, it wraps the d...
[ "def", "validate_field", "(", "cls", ",", "field_name", ",", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "return", "decorate_cls_with_validation", "(", "cls", ",", "field_name", ",", "*", "valida...
A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__, it wraps the descriptors' setter function with a `validate_arg` annotation :param field_name: :param validation_func: :param help_msg: :param error_type: :param none_policy: :par...
[ "A", "class", "decorator", ".", "It", "goes", "through", "all", "class", "variables", "and", "for", "all", "of", "those", "that", "are", "descriptors", "with", "a", "__set__", "it", "wraps", "the", "descriptors", "setter", "function", "with", "a", "validate_...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L352-L369
train
smarie/python-valid8
valid8/entry_points_annotations.py
validate_io
def validate_io(f=DECORATED, none_policy=None, # type: int _out_=None, # type: ValidationFuncs **kw_validation_funcs # type: ValidationFuncs ): """ A function decorator to add input validation prior to the function execution. It sh...
python
def validate_io(f=DECORATED, none_policy=None, # type: int _out_=None, # type: ValidationFuncs **kw_validation_funcs # type: ValidationFuncs ): """ A function decorator to add input validation prior to the function execution. It sh...
[ "def", "validate_io", "(", "f", "=", "DECORATED", ",", "none_policy", "=", "None", ",", "# type: int", "_out_", "=", "None", ",", "# type: ValidationFuncs", "*", "*", "kw_validation_funcs", "# type: ValidationFuncs", ")", ":", "return", "decorate_several_with_validati...
A function decorator to add input validation prior to the function execution. It should be called with named arguments: for each function arg name, provide a single validation function or a list of validation functions to apply. If validation fails, it will raise an InputValidationError with details about the f...
[ "A", "function", "decorator", "to", "add", "input", "validation", "prior", "to", "the", "function", "execution", ".", "It", "should", "be", "called", "with", "named", "arguments", ":", "for", "each", "function", "arg", "name", "provide", "a", "single", "vali...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L373-L424
train
smarie/python-valid8
valid8/entry_points_annotations.py
validate_arg
def validate_arg(f, arg_name, *validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ A decorator to apply function input validation for the given argument name, with the provided base validation function(s)...
python
def validate_arg(f, arg_name, *validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ A decorator to apply function input validation for the given argument name, with the provided base validation function(s)...
[ "def", "validate_arg", "(", "f", ",", "arg_name", ",", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "return", "decorate_with_validation", "(", "f", ",", "arg_name", ",", "*", "validation_func", ...
A decorator to apply function input validation for the given argument name, with the provided base validation function(s). You may use several such decorators on a given function as long as they are stacked on top of each other (no external decorator in the middle) :param arg_name: :param validation_fu...
[ "A", "decorator", "to", "apply", "function", "input", "validation", "for", "the", "given", "argument", "name", "with", "the", "provided", "base", "validation", "function", "(", "s", ")", ".", "You", "may", "use", "several", "such", "decorators", "on", "a", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L442-L469
train
smarie/python-valid8
valid8/entry_points_annotations.py
validate_out
def validate_out(*validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ A decorator to apply function output validation to this function's output, with the provided base validation function(s). You may use several such decorators on a given function as long ...
python
def validate_out(*validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ A decorator to apply function output validation to this function's output, with the provided base validation function(s). You may use several such decorators on a given function as long ...
[ "def", "validate_out", "(", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "def", "decorate", "(", "f", ")", ":", "return", "decorate_with_validation", "(", "f", ",", "_OUT_KEY", ",", "*", "vali...
A decorator to apply function output validation to this function's output, with the provided base validation function(s). You may use several such decorators on a given function as long as they are stacked on top of each other (no external decorator in the middle) :param validation_func: the base validatio...
[ "A", "decorator", "to", "apply", "function", "output", "validation", "to", "this", "function", "s", "output", "with", "the", "provided", "base", "validation", "function", "(", "s", ")", ".", "You", "may", "use", "several", "such", "decorators", "on", "a", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L484-L504
train
smarie/python-valid8
valid8/entry_points_annotations.py
decorate_cls_with_validation
def decorate_cls_with_validation(cls, field_name, # type: str *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Type[Any] """ This method is equivalent to decorating a class with th...
python
def decorate_cls_with_validation(cls, field_name, # type: str *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Type[Any] """ This method is equivalent to decorating a class with th...
[ "def", "decorate_cls_with_validation", "(", "cls", ",", "field_name", ",", "# type: str", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Type[Any]", "error_type", ",", "help_msg", ",", "none_policy", "=", "pop_k...
This method is equivalent to decorating a class with the `@validate_field` decorator but can be used a posteriori. :param cls: the class to decorate :param field_name: the name of the argument to validate or _OUT_KEY for output validation :param validation_func: the validation function or list of v...
[ "This", "method", "is", "equivalent", "to", "decorating", "a", "class", "with", "the", "@validate_field", "decorator", "but", "can", "be", "used", "a", "posteriori", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L525-L663
train
smarie/python-valid8
valid8/entry_points_annotations.py
decorate_several_with_validation
def decorate_several_with_validation(func, _out_=None, # type: ValidationFuncs none_policy=None, # type: int **validation_funcs # type: ValidationFuncs ): # ...
python
def decorate_several_with_validation(func, _out_=None, # type: ValidationFuncs none_policy=None, # type: int **validation_funcs # type: ValidationFuncs ): # ...
[ "def", "decorate_several_with_validation", "(", "func", ",", "_out_", "=", "None", ",", "# type: ValidationFuncs", "none_policy", "=", "None", ",", "# type: int", "*", "*", "validation_funcs", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "# add valida...
This method is equivalent to applying `decorate_with_validation` once for each of the provided arguments of the function `func` as well as output `_out_`. validation_funcs keyword arguments are validation functions for each arg name. Note that this method is less flexible than decorate_with_validation sinc...
[ "This", "method", "is", "equivalent", "to", "applying", "decorate_with_validation", "once", "for", "each", "of", "the", "provided", "arguments", "of", "the", "function", "func", "as", "well", "as", "output", "_out_", ".", "validation_funcs", "keyword", "arguments"...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L666-L696
train
smarie/python-valid8
valid8/entry_points_annotations.py
decorate_with_validation
def decorate_with_validation(func, arg_name, # type: str *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ This method is the inner method used in `@validate_io`, `@validate_arg`...
python
def decorate_with_validation(func, arg_name, # type: str *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ This method is the inner method used in `@validate_io`, `@validate_arg`...
[ "def", "decorate_with_validation", "(", "func", ",", "arg_name", ",", "# type: str", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "error_type", ",", "help_msg", ",", "none_policy", ",", "_constructo...
This method is the inner method used in `@validate_io`, `@validate_arg` and `@validate_out`. It can be used if you with to perform decoration manually without a decorator. :param func: :param arg_name: the name of the argument to validate or _OUT_KEY for output validation :param validation_func: the va...
[ "This", "method", "is", "the", "inner", "method", "used", "in", "@validate_io", "@validate_arg", "and", "@validate_out", ".", "It", "can", "be", "used", "if", "you", "with", "to", "perform", "decoration", "manually", "without", "a", "decorator", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L714-L769
train
smarie/python-valid8
valid8/entry_points_annotations.py
_get_final_none_policy_for_validator
def _get_final_none_policy_for_validator(is_nonable, # type: bool none_policy # type: NoneArgPolicy ): """ Depending on none_policy and of the fact that the target parameter is nonable or not, returns a corresponding NoneP...
python
def _get_final_none_policy_for_validator(is_nonable, # type: bool none_policy # type: NoneArgPolicy ): """ Depending on none_policy and of the fact that the target parameter is nonable or not, returns a corresponding NoneP...
[ "def", "_get_final_none_policy_for_validator", "(", "is_nonable", ",", "# type: bool", "none_policy", "# type: NoneArgPolicy", ")", ":", "if", "none_policy", "in", "{", "NonePolicy", ".", "VALIDATE", ",", "NonePolicy", ".", "SKIP", ",", "NonePolicy", ".", "FAIL", "}...
Depending on none_policy and of the fact that the target parameter is nonable or not, returns a corresponding NonePolicy :param is_nonable: :param none_policy: :return:
[ "Depending", "on", "none_policy", "and", "of", "the", "fact", "that", "the", "target", "parameter", "is", "nonable", "or", "not", "returns", "a", "corresponding", "NonePolicy" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L772-L794
train
smarie/python-valid8
valid8/entry_points_annotations.py
decorate_with_validators
def decorate_with_validators(func, func_signature=None, # type: Signature **validators # type: Validator ): """ Utility method to decorate the provided function with the provided input and output Validator objects. ...
python
def decorate_with_validators(func, func_signature=None, # type: Signature **validators # type: Validator ): """ Utility method to decorate the provided function with the provided input and output Validator objects. ...
[ "def", "decorate_with_validators", "(", "func", ",", "func_signature", "=", "None", ",", "# type: Signature", "*", "*", "validators", "# type: Validator", ")", ":", "# first turn the dictionary values into lists only", "for", "arg_name", ",", "validator", "in", "validator...
Utility method to decorate the provided function with the provided input and output Validator objects. Since this method takes Validator objects as argument, it is for advanced users. :param func: the function to decorate. It might already be decorated, this method will check it and wont create another wra...
[ "Utility", "method", "to", "decorate", "the", "provided", "function", "with", "the", "provided", "input", "and", "output", "Validator", "objects", ".", "Since", "this", "method", "takes", "Validator", "objects", "as", "argument", "it", "is", "for", "advanced", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L872-L942
train
smarie/python-valid8
valid8/entry_points_annotations.py
_assert_input_is_valid
def _assert_input_is_valid(input_value, # type: Any validators, # type: List[InputValidator] validated_func, # type: Callable input_name # type: str ): """ Called by the `validating_wrappe...
python
def _assert_input_is_valid(input_value, # type: Any validators, # type: List[InputValidator] validated_func, # type: Callable input_name # type: str ): """ Called by the `validating_wrappe...
[ "def", "_assert_input_is_valid", "(", "input_value", ",", "# type: Any", "validators", ",", "# type: List[InputValidator]", "validated_func", ",", "# type: Callable", "input_name", "# type: str", ")", ":", "for", "validator", "in", "validators", ":", "validator", ".", "...
Called by the `validating_wrapper` in the first step (a) `apply_on_each_func_args` for each function input before executing the function. It simply delegates to the validator. The signature of this function is hardcoded to correspond to `apply_on_each_func_args`'s behaviour and should therefore not be changed. ...
[ "Called", "by", "the", "validating_wrapper", "in", "the", "first", "step", "(", "a", ")", "apply_on_each_func_args", "for", "each", "function", "input", "before", "executing", "the", "function", ".", "It", "simply", "delegates", "to", "the", "validator", ".", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L945-L963
train
smarie/python-valid8
valid8/entry_points_annotations.py
InputValidationError.get_what_txt
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the function. :return: """ return 'input [{var}] for function [{func}]'.format(var=self.get_variable_str(), ...
python
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the function. :return: """ return 'input [{var}] for function [{func}]'.format(var=self.get_variable_str(), ...
[ "def", "get_what_txt", "(", "self", ")", ":", "return", "'input [{var}] for function [{func}]'", ".", "format", "(", "var", "=", "self", ".", "get_variable_str", "(", ")", ",", "func", "=", "self", ".", "validator", ".", "get_validated_func_display_name", "(", "...
Overrides the base behaviour defined in ValidationError in order to add details about the function. :return:
[ "Overrides", "the", "base", "behaviour", "defined", "in", "ValidationError", "in", "order", "to", "add", "details", "about", "the", "function", ".", ":", "return", ":" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L42-L48
train
smarie/python-valid8
valid8/entry_points_annotations.py
ClassFieldValidationError.get_what_txt
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the class field. :return: """ return 'field [{field}] for class [{clazz}]'.format(field=self.get_variable_str(), ...
python
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the class field. :return: """ return 'field [{field}] for class [{clazz}]'.format(field=self.get_variable_str(), ...
[ "def", "get_what_txt", "(", "self", ")", ":", "return", "'field [{field}] for class [{clazz}]'", ".", "format", "(", "field", "=", "self", ".", "get_variable_str", "(", ")", ",", "clazz", "=", "self", ".", "validator", ".", "get_validated_class_display_name", "(",...
Overrides the base behaviour defined in ValidationError in order to add details about the class field. :return:
[ "Overrides", "the", "base", "behaviour", "defined", "in", "ValidationError", "in", "order", "to", "add", "details", "about", "the", "class", "field", ".", ":", "return", ":" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L80-L86
train
Antidote1911/cryptoshop
cryptoshop/_nonce_engine.py
generate_nonce_timestamp
def generate_nonce_timestamp(): """ Generate unique nonce with counter, uuid and rng.""" global count rng = botan.rng().get(30) uuid4 = uuid.uuid4().bytes # 16 byte tmpnonce = (bytes(str(count).encode('utf-8'))) + uuid4 + rng nonce = tmpnonce[:41] # 41 byte (328 bit) count += 1 return ...
python
def generate_nonce_timestamp(): """ Generate unique nonce with counter, uuid and rng.""" global count rng = botan.rng().get(30) uuid4 = uuid.uuid4().bytes # 16 byte tmpnonce = (bytes(str(count).encode('utf-8'))) + uuid4 + rng nonce = tmpnonce[:41] # 41 byte (328 bit) count += 1 return ...
[ "def", "generate_nonce_timestamp", "(", ")", ":", "global", "count", "rng", "=", "botan", ".", "rng", "(", ")", ".", "get", "(", "30", ")", "uuid4", "=", "uuid", ".", "uuid4", "(", ")", ".", "bytes", "# 16 byte", "tmpnonce", "=", "(", "bytes", "(", ...
Generate unique nonce with counter, uuid and rng.
[ "Generate", "unique", "nonce", "with", "counter", "uuid", "and", "rng", "." ]
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_nonce_engine.py#L45-L53
train
redhat-cip/dci-control-server
dci/common/schemas.py
dict_merge
def dict_merge(*dict_list): """recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. """ result = collections.defaultdict(dict) dicts_items = itert...
python
def dict_merge(*dict_list): """recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. """ result = collections.defaultdict(dict) dicts_items = itert...
[ "def", "dict_merge", "(", "*", "dict_list", ")", ":", "result", "=", "collections", ".", "defaultdict", "(", "dict", ")", "dicts_items", "=", "itertools", ".", "chain", "(", "*", "[", "six", ".", "iteritems", "(", "d", "or", "{", "}", ")", "for", "d"...
recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary.
[ "recursively", "merges", "dict", "s", ".", "not", "just", "simple", "a", "[", "key", "]", "=", "b", "[", "key", "]", "if", "both", "a", "and", "bhave", "a", "key", "who", "s", "value", "is", "a", "dict", "then", "dict_merge", "is", "called", "on", ...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/schemas.py#L108-L127
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
schedule_jobs
def schedule_jobs(user): """Dispatch jobs to remotecis. The remoteci can use this method to request a new job. Before a job is dispatched, the server will flag as 'killed' all the running jobs that were associated with the remoteci. This is because they will never be finished. """ values ...
python
def schedule_jobs(user): """Dispatch jobs to remotecis. The remoteci can use this method to request a new job. Before a job is dispatched, the server will flag as 'killed' all the running jobs that were associated with the remoteci. This is because they will never be finished. """ values ...
[ "def", "schedule_jobs", "(", "user", ")", ":", "values", "=", "schemas", ".", "job_schedule", ".", "post", "(", "flask", ".", "request", ".", "json", ")", "values", ".", "update", "(", "{", "'id'", ":", "utils", ".", "gen_uuid", "(", ")", ",", "'crea...
Dispatch jobs to remotecis. The remoteci can use this method to request a new job. Before a job is dispatched, the server will flag as 'killed' all the running jobs that were associated with the remoteci. This is because they will never be finished.
[ "Dispatch", "jobs", "to", "remotecis", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L195-L267
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
create_new_update_job_from_an_existing_job
def create_new_update_job_from_an_existing_job(user, job_id): """Create a new job in the same topic as the job_id provided and associate the latest components of this topic.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), 'updated_at': dat...
python
def create_new_update_job_from_an_existing_job(user, job_id): """Create a new job in the same topic as the job_id provided and associate the latest components of this topic.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), 'updated_at': dat...
[ "def", "create_new_update_job_from_an_existing_job", "(", "user", ",", "job_id", ")", ":", "values", "=", "{", "'id'", ":", "utils", ".", "gen_uuid", "(", ")", ",", "'created_at'", ":", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "isoformat", ...
Create a new job in the same topic as the job_id provided and associate the latest components of this topic.
[ "Create", "a", "new", "job", "in", "the", "same", "topic", "as", "the", "job_id", "provided", "and", "associate", "the", "latest", "components", "of", "this", "topic", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L272-L313
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
create_new_upgrade_job_from_an_existing_job
def create_new_upgrade_job_from_an_existing_job(user): """Create a new job in the 'next topic' of the topic of the provided job_id.""" values = schemas.job_upgrade.post(flask.request.json) values.update({ 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), ...
python
def create_new_upgrade_job_from_an_existing_job(user): """Create a new job in the 'next topic' of the topic of the provided job_id.""" values = schemas.job_upgrade.post(flask.request.json) values.update({ 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), ...
[ "def", "create_new_upgrade_job_from_an_existing_job", "(", "user", ")", ":", "values", "=", "schemas", ".", "job_upgrade", ".", "post", "(", "flask", ".", "request", ".", "json", ")", "values", ".", "update", "(", "{", "'id'", ":", "utils", ".", "gen_uuid", ...
Create a new job in the 'next topic' of the topic of the provided job_id.
[ "Create", "a", "new", "job", "in", "the", "next", "topic", "of", "the", "topic", "of", "the", "provided", "job_id", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L318-L367
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
get_all_jobs
def get_all_jobs(user, topic_id=None): """Get all jobs. If topic_id is not None, then return all the jobs with a topic pointed by topic_id. """ # get the diverse parameters args = schemas.args(flask.request.args.to_dict()) # build the query thanks to the QueryBuilder class query = v1_u...
python
def get_all_jobs(user, topic_id=None): """Get all jobs. If topic_id is not None, then return all the jobs with a topic pointed by topic_id. """ # get the diverse parameters args = schemas.args(flask.request.args.to_dict()) # build the query thanks to the QueryBuilder class query = v1_u...
[ "def", "get_all_jobs", "(", "user", ",", "topic_id", "=", "None", ")", ":", "# get the diverse parameters", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "# build the query thanks to the QueryBuild...
Get all jobs. If topic_id is not None, then return all the jobs with a topic pointed by topic_id.
[ "Get", "all", "jobs", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L372-L405
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
update_job_by_id
def update_job_by_id(user, job_id): """Update a job """ # get If-Match header if_match_etag = utils.check_and_get_etag(flask.request.headers) # get the diverse parameters values = schemas.job.put(flask.request.json) job = v1_utils.verify_existence_and_get(job_id, _TABLE) job = dict(job...
python
def update_job_by_id(user, job_id): """Update a job """ # get If-Match header if_match_etag = utils.check_and_get_etag(flask.request.headers) # get the diverse parameters values = schemas.job.put(flask.request.json) job = v1_utils.verify_existence_and_get(job_id, _TABLE) job = dict(job...
[ "def", "update_job_by_id", "(", "user", ",", "job_id", ")", ":", "# get If-Match header", "if_match_etag", "=", "utils", ".", "check_and_get_etag", "(", "flask", ".", "request", ".", "headers", ")", "# get the diverse parameters", "values", "=", "schemas", ".", "j...
Update a job
[ "Update", "a", "job" ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L437-L477
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
get_all_results_from_jobs
def get_all_results_from_jobs(user, j_id): """Get all results from job. """ job = v1_utils.verify_existence_and_get(j_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() # get testscases from tests_results query = sql.selec...
python
def get_all_results_from_jobs(user, j_id): """Get all results from job. """ job = v1_utils.verify_existence_and_get(j_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() # get testscases from tests_results query = sql.selec...
[ "def", "get_all_results_from_jobs", "(", "user", ",", "j_id", ")", ":", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "j_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team", "(", "job", "[", "'team_id'", "]", ")", "and", "not", ...
Get all results from job.
[ "Get", "all", "results", "from", "job", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L521-L551
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
get_tags_from_job
def get_tags_from_job(user, job_id): """Retrieve all tags attached to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() JTT = models.JOIN_JOBS_TAGS query = (sql.select([mod...
python
def get_tags_from_job(user, job_id): """Retrieve all tags attached to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() JTT = models.JOIN_JOBS_TAGS query = (sql.select([mod...
[ "def", "get_tags_from_job", "(", "user", ",", "job_id", ")", ":", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team", "(", "job", "[", "'team_id'", "]", ")", "and", "not", "u...
Retrieve all tags attached to a job.
[ "Retrieve", "all", "tags", "attached", "to", "a", "job", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L587-L600
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
add_tag_to_job
def add_tag_to_job(user, job_id): """Add a tag to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() values = { 'job_id': job_id } job_tagged = tags.add_tag_to_resource(values, models.JOIN_JOBS...
python
def add_tag_to_job(user, job_id): """Add a tag to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() values = { 'job_id': job_id } job_tagged = tags.add_tag_to_resource(values, models.JOIN_JOBS...
[ "def", "add_tag_to_job", "(", "user", ",", "job_id", ")", ":", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team", "(", "job", "[", "'team_id'", "]", ")", ":", "raise", "dci_...
Add a tag to a job.
[ "Add", "a", "tag", "to", "a", "job", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L605-L619
train
redhat-cip/dci-control-server
dci/api/v1/jobs.py
delete_tag_from_job
def delete_tag_from_job(user, job_id, tag_id): """Delete a tag from a job.""" _JJT = models.JOIN_JOBS_TAGS job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() v1_utils.verify_existence_and_get(tag_id, models.TAGS) ...
python
def delete_tag_from_job(user, job_id, tag_id): """Delete a tag from a job.""" _JJT = models.JOIN_JOBS_TAGS job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() v1_utils.verify_existence_and_get(tag_id, models.TAGS) ...
[ "def", "delete_tag_from_job", "(", "user", ",", "job_id", ",", "tag_id", ")", ":", "_JJT", "=", "models", ".", "JOIN_JOBS_TAGS", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team...
Delete a tag from a job.
[ "Delete", "a", "tag", "from", "a", "job", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L624-L641
train
jmurty/xml4h
xml4h/impls/xml_etree_elementtree.py
ElementTreeAdapter._lookup_node_parent
def _lookup_node_parent(self, node): """ Return the parent of the given node, based on an internal dictionary mapping of child nodes to the child's parent required since ElementTree doesn't make info about node ancestry/parentage available. """ # Basic caching of our inte...
python
def _lookup_node_parent(self, node): """ Return the parent of the given node, based on an internal dictionary mapping of child nodes to the child's parent required since ElementTree doesn't make info about node ancestry/parentage available. """ # Basic caching of our inte...
[ "def", "_lookup_node_parent", "(", "self", ",", "node", ")", ":", "# Basic caching of our internal ancestry dict to help performance", "if", "not", "node", "in", "self", ".", "CACHED_ANCESTRY_DICT", ":", "# Given node isn't in cached ancestry dictionary, rebuild this now", "ances...
Return the parent of the given node, based on an internal dictionary mapping of child nodes to the child's parent required since ElementTree doesn't make info about node ancestry/parentage available.
[ "Return", "the", "parent", "of", "the", "given", "node", "based", "on", "an", "internal", "dictionary", "mapping", "of", "child", "nodes", "to", "the", "child", "s", "parent", "required", "since", "ElementTree", "doesn", "t", "make", "info", "about", "node",...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L108-L120
train
jmurty/xml4h
xml4h/impls/xml_etree_elementtree.py
ElementTreeAdapter._is_node_an_element
def _is_node_an_element(self, node): """ Return True if the given node is an ElementTree Element, a fact that can be tricky to determine if the cElementTree implementation is used. """ # Try the simplest approach first, works for plain old ElementTree if isinstanc...
python
def _is_node_an_element(self, node): """ Return True if the given node is an ElementTree Element, a fact that can be tricky to determine if the cElementTree implementation is used. """ # Try the simplest approach first, works for plain old ElementTree if isinstanc...
[ "def", "_is_node_an_element", "(", "self", ",", "node", ")", ":", "# Try the simplest approach first, works for plain old ElementTree", "if", "isinstance", "(", "node", ",", "BaseET", ".", "Element", ")", ":", "return", "True", "# For cElementTree we need to be more cunning...
Return True if the given node is an ElementTree Element, a fact that can be tricky to determine if the cElementTree implementation is used.
[ "Return", "True", "if", "the", "given", "node", "is", "an", "ElementTree", "Element", "a", "fact", "that", "can", "be", "tricky", "to", "determine", "if", "the", "cElementTree", "implementation", "is", "used", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L122-L133
train
jmurty/xml4h
xml4h/impls/xml_etree_elementtree.py
ElementTreeAdapter.xpath_on_node
def xpath_on_node(self, node, xpath, **kwargs): """ Return result of performing the given XPath query on the given node. All known namespace prefix-to-URI mappings in the document are automatically included in the XPath invocation. If an empty/default namespace (i.e. None) is d...
python
def xpath_on_node(self, node, xpath, **kwargs): """ Return result of performing the given XPath query on the given node. All known namespace prefix-to-URI mappings in the document are automatically included in the XPath invocation. If an empty/default namespace (i.e. None) is d...
[ "def", "xpath_on_node", "(", "self", ",", "node", ",", "xpath", ",", "*", "*", "kwargs", ")", ":", "namespaces_dict", "=", "{", "}", "if", "'namespaces'", "in", "kwargs", ":", "namespaces_dict", ".", "update", "(", "kwargs", "[", "'namespaces'", "]", ")"...
Return result of performing the given XPath query on the given node. All known namespace prefix-to-URI mappings in the document are automatically included in the XPath invocation. If an empty/default namespace (i.e. None) is defined, this is converted to the prefix name '_' so it can b...
[ "Return", "result", "of", "performing", "the", "given", "XPath", "query", "on", "the", "given", "node", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L200-L228
train
redhat-cip/dci-control-server
dci/api/v1/base.py
get_to_purge_archived_resources
def get_to_purge_archived_resources(user, table): """List the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() archived_resources = get_archived_resources(table) return flask.jsonify({table.name: archived_resources, ...
python
def get_to_purge_archived_resources(user, table): """List the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() archived_resources = get_archived_resources(table) return flask.jsonify({table.name: archived_resources, ...
[ "def", "get_to_purge_archived_resources", "(", "user", ",", "table", ")", ":", "if", "user", ".", "is_not_super_admin", "(", ")", ":", "raise", "dci_exc", ".", "Unauthorized", "(", ")", "archived_resources", "=", "get_archived_resources", "(", "table", ")", "ret...
List the entries to be purged from the database.
[ "List", "the", "entries", "to", "be", "purged", "from", "the", "database", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L67-L76
train
redhat-cip/dci-control-server
dci/api/v1/base.py
purge_archived_resources
def purge_archived_resources(user, table): """Remove the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() where_clause = sql.and_( table.c.state == 'archived' ) query = table.delete().where(where_clause) flask.g.db_conn.exec...
python
def purge_archived_resources(user, table): """Remove the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() where_clause = sql.and_( table.c.state == 'archived' ) query = table.delete().where(where_clause) flask.g.db_conn.exec...
[ "def", "purge_archived_resources", "(", "user", ",", "table", ")", ":", "if", "user", ".", "is_not_super_admin", "(", ")", ":", "raise", "dci_exc", ".", "Unauthorized", "(", ")", "where_clause", "=", "sql", ".", "and_", "(", "table", ".", "c", ".", "stat...
Remove the entries to be purged from the database.
[ "Remove", "the", "entries", "to", "be", "purged", "from", "the", "database", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L79-L91
train
redhat-cip/dci-control-server
dci/api/v1/base.py
refresh_api_secret
def refresh_api_secret(user, resource, table): """Refresh the resource API Secret. """ resource_name = table.name[0:-1] where_clause = sql.and_( table.c.etag == resource['etag'], table.c.id == resource['id'], ) values = { 'api_secret': signature.gen_secret(), 'etag...
python
def refresh_api_secret(user, resource, table): """Refresh the resource API Secret. """ resource_name = table.name[0:-1] where_clause = sql.and_( table.c.etag == resource['etag'], table.c.id == resource['id'], ) values = { 'api_secret': signature.gen_secret(), 'etag...
[ "def", "refresh_api_secret", "(", "user", ",", "resource", ",", "table", ")", ":", "resource_name", "=", "table", ".", "name", "[", "0", ":", "-", "1", "]", "where_clause", "=", "sql", ".", "and_", "(", "table", ".", "c", ".", "etag", "==", "resource...
Refresh the resource API Secret.
[ "Refresh", "the", "resource", "API", "Secret", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L94-L118
train
inveniosoftware/invenio-assets
invenio_assets/cli.py
npm
def npm(package_json, output_file, pinned_file): """Generate a package.json file.""" amd_build_deprecation_warning() try: version = get_distribution(current_app.name).version except DistributionNotFound: version = '' output = { 'name': current_app.name, 'version': ma...
python
def npm(package_json, output_file, pinned_file): """Generate a package.json file.""" amd_build_deprecation_warning() try: version = get_distribution(current_app.name).version except DistributionNotFound: version = '' output = { 'name': current_app.name, 'version': ma...
[ "def", "npm", "(", "package_json", ",", "output_file", ",", "pinned_file", ")", ":", "amd_build_deprecation_warning", "(", ")", "try", ":", "version", "=", "get_distribution", "(", "current_app", ".", "name", ")", ".", "version", "except", "DistributionNotFound", ...
Generate a package.json file.
[ "Generate", "a", "package", ".", "json", "file", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/cli.py#L73-L111
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.getAnalyses
def getAnalyses(self, **kwargs): """Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer ...
python
def getAnalyses(self, **kwargs): """Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer ...
[ "def", "getAnalyses", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# 'from' is a reserved word, use time_from instead", "if", "kwargs", ".", "get", "(", "'time_from'", ")", ":", "kwargs", "[", "'from'", "]", "=", "kwargs", ".", "get", "(", "'time_from'", ...
Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer Default: 100 * offset -- O...
[ "Returns", "a", "list", "of", "the", "latest", "root", "cause", "analysis", "results", "for", "a", "specified", "check", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L87-L143
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.getDetails
def getDetails(self): """Update check details, returns dictionary of details""" response = self.pingdom.request('GET', 'checks/%s' % self.id) self.__addDetails__(response.json()['check']) return response.json()['check']
python
def getDetails(self): """Update check details, returns dictionary of details""" response = self.pingdom.request('GET', 'checks/%s' % self.id) self.__addDetails__(response.json()['check']) return response.json()['check']
[ "def", "getDetails", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'GET'", ",", "'checks/%s'", "%", "self", ".", "id", ")", "self", ".", "__addDetails__", "(", "response", ".", "json", "(", ")", "[", "'check'", ...
Update check details, returns dictionary of details
[ "Update", "check", "details", "returns", "dictionary", "of", "details" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L175-L180
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.modify
def modify(self, **kwargs): """Modify settings for a check. The provided settings will overwrite previous values. Settings not provided will stay the same as before the update. To clear an existing value, provide an empty value. Please note that you cannot change the type of ...
python
def modify(self, **kwargs): """Modify settings for a check. The provided settings will overwrite previous values. Settings not provided will stay the same as before the update. To clear an existing value, provide an empty value. Please note that you cannot change the type of ...
[ "def", "modify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'paused'", ",", "'resolution'", ",", "'contactids'", ",", "'sendtoemail'", ",", "'se...
Modify settings for a check. The provided settings will overwrite previous values. Settings not provided will stay the same as before the update. To clear an existing value, provide an empty value. Please note that you cannot change the type of a check once it has been cr...
[ "Modify", "settings", "for", "a", "check", ".", "The", "provided", "settings", "will", "overwrite", "previous", "values", ".", "Settings", "not", "provided", "will", "stay", "the", "same", "as", "before", "the", "update", ".", "To", "clear", "an", "existing"...
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L182-L382
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.averages
def averages(self, **kwargs): """Get the average time / uptime value for a specified check and time period. Optional parameters: * time_from -- Start time of period. Format is UNIX timestamp Type: Integer Default: 0 * time_to...
python
def averages(self, **kwargs): """Get the average time / uptime value for a specified check and time period. Optional parameters: * time_from -- Start time of period. Format is UNIX timestamp Type: Integer Default: 0 * time_to...
[ "def", "averages", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# 'from' is a reserved word, use time_from instead", "if", "kwargs", ".", "get", "(", "'time_from'", ")", ":", "kwargs", "[", "'from'", "]", "=", "kwargs", ".", "get", "(", "'time_from'", ")...
Get the average time / uptime value for a specified check and time period. Optional parameters: * time_from -- Start time of period. Format is UNIX timestamp Type: Integer Default: 0 * time_to -- End time of period. Format is UNIX ti...
[ "Get", "the", "average", "time", "/", "uptime", "value", "for", "a", "specified", "check", "and", "time", "period", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L392-L454
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.probes
def probes(self, fromtime, totime=None): """Get a list of probes that performed tests for a specified check during a specified period.""" args = {'from': fromtime} if totime: args['to'] = totime response = self.pingdom.request('GET', 'summary.probes/%s' % self.i...
python
def probes(self, fromtime, totime=None): """Get a list of probes that performed tests for a specified check during a specified period.""" args = {'from': fromtime} if totime: args['to'] = totime response = self.pingdom.request('GET', 'summary.probes/%s' % self.i...
[ "def", "probes", "(", "self", ",", "fromtime", ",", "totime", "=", "None", ")", ":", "args", "=", "{", "'from'", ":", "fromtime", "}", "if", "totime", ":", "args", "[", "'to'", "]", "=", "totime", "response", "=", "self", ".", "pingdom", ".", "requ...
Get a list of probes that performed tests for a specified check during a specified period.
[ "Get", "a", "list", "of", "probes", "that", "performed", "tests", "for", "a", "specified", "check", "during", "a", "specified", "period", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L639-L650
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.publishPublicReport
def publishPublicReport(self): """Activate public report for this check. Returns status message""" response = self.pingdom.request('PUT', 'reports.public/%s' % self.id) return response.json()['message']
python
def publishPublicReport(self): """Activate public report for this check. Returns status message""" response = self.pingdom.request('PUT', 'reports.public/%s' % self.id) return response.json()['message']
[ "def", "publishPublicReport", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'PUT'", ",", "'reports.public/%s'", "%", "self", ".", "id", ")", "return", "response", ".", "json", "(", ")", "[", "'message'", "]" ]
Activate public report for this check. Returns status message
[ "Activate", "public", "report", "for", "this", "check", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L740-L746
train
KennethWilke/PingdomLib
pingdomlib/check.py
PingdomCheck.removePublicReport
def removePublicReport(self): """Deactivate public report for this check. Returns status message""" response = self.pingdom.request('DELETE', 'reports.public/%s' % self.id) return response.json()['message']
python
def removePublicReport(self): """Deactivate public report for this check. Returns status message""" response = self.pingdom.request('DELETE', 'reports.public/%s' % self.id) return response.json()['message']
[ "def", "removePublicReport", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'DELETE'", ",", "'reports.public/%s'", "%", "self", ".", "id", ")", "return", "response", ".", "json", "(", ")", "[", "'message'", "]" ]
Deactivate public report for this check. Returns status message
[ "Deactivate", "public", "report", "for", "this", "check", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L748-L755
train
inveniosoftware/invenio-assets
invenio_assets/npm.py
extract_deps
def extract_deps(bundles, log=None): """Extract the dependencies from the bundle and its sub-bundles.""" def _flatten(bundle): deps = [] if hasattr(bundle, 'npm'): deps.append(bundle.npm) for content in bundle.contents: if isinstance(content, BundleBase): ...
python
def extract_deps(bundles, log=None): """Extract the dependencies from the bundle and its sub-bundles.""" def _flatten(bundle): deps = [] if hasattr(bundle, 'npm'): deps.append(bundle.npm) for content in bundle.contents: if isinstance(content, BundleBase): ...
[ "def", "extract_deps", "(", "bundles", ",", "log", "=", "None", ")", ":", "def", "_flatten", "(", "bundle", ")", ":", "deps", "=", "[", "]", "if", "hasattr", "(", "bundle", ",", "'npm'", ")", ":", "deps", ".", "append", "(", "bundle", ".", "npm", ...
Extract the dependencies from the bundle and its sub-bundles.
[ "Extract", "the", "dependencies", "from", "the", "bundle", "and", "its", "sub", "-", "bundles", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/npm.py#L54-L83
train
inveniosoftware/invenio-assets
invenio_assets/npm.py
make_semver
def make_semver(version_str): """Make a semantic version from Python PEP440 version. Semantic versions does not handle post-releases. """ v = parse_version(version_str) major = v._version.release[0] try: minor = v._version.release[1] except IndexError: minor = 0 try: ...
python
def make_semver(version_str): """Make a semantic version from Python PEP440 version. Semantic versions does not handle post-releases. """ v = parse_version(version_str) major = v._version.release[0] try: minor = v._version.release[1] except IndexError: minor = 0 try: ...
[ "def", "make_semver", "(", "version_str", ")", ":", "v", "=", "parse_version", "(", "version_str", ")", "major", "=", "v", ".", "_version", ".", "release", "[", "0", "]", "try", ":", "minor", "=", "v", ".", "_version", ".", "release", "[", "1", "]", ...
Make a semantic version from Python PEP440 version. Semantic versions does not handle post-releases.
[ "Make", "a", "semantic", "version", "from", "Python", "PEP440", "version", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/npm.py#L86-L118
train
ubc/ubcpi
ubcpi/answer_pool.py
get_max_size
def get_max_size(pool, num_option, item_length): """ Calculate the max number of item that an option can stored in the pool at give time. This is to limit the pool size to POOL_SIZE Args: option_index (int): the index of the option to calculate the size for pool (dict): answer pool ...
python
def get_max_size(pool, num_option, item_length): """ Calculate the max number of item that an option can stored in the pool at give time. This is to limit the pool size to POOL_SIZE Args: option_index (int): the index of the option to calculate the size for pool (dict): answer pool ...
[ "def", "get_max_size", "(", "pool", ",", "num_option", ",", "item_length", ")", ":", "max_items", "=", "POOL_SIZE", "/", "item_length", "# existing items plus the reserved for min size. If there is an option has 1 item, POOL_OPTION_MIN_SIZE - 1 space", "# is reserved.", "existing",...
Calculate the max number of item that an option can stored in the pool at give time. This is to limit the pool size to POOL_SIZE Args: option_index (int): the index of the option to calculate the size for pool (dict): answer pool num_option (int): total number of options available for ...
[ "Calculate", "the", "max", "number", "of", "item", "that", "an", "option", "can", "stored", "in", "the", "pool", "at", "give", "time", "." ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L21-L40
train
ubc/ubcpi
ubcpi/answer_pool.py
offer_answer
def offer_answer(pool, answer, rationale, student_id, algo, options): """ submit a student answer to the answer pool The answer maybe selected to stay in the pool depending on the selection algorithm Args: pool (dict): answer pool Answer pool format: { o...
python
def offer_answer(pool, answer, rationale, student_id, algo, options): """ submit a student answer to the answer pool The answer maybe selected to stay in the pool depending on the selection algorithm Args: pool (dict): answer pool Answer pool format: { o...
[ "def", "offer_answer", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "algo", ",", "options", ")", ":", "if", "algo", "[", "'name'", "]", "==", "'simple'", ":", "offer_simple", "(", "pool", ",", "answer", ",", "rationale", ",", "...
submit a student answer to the answer pool The answer maybe selected to stay in the pool depending on the selection algorithm Args: pool (dict): answer pool Answer pool format: { option1_index: { 'student_id': { can store algorithm specific i...
[ "submit", "a", "student", "answer", "to", "the", "answer", "pool" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L43-L73
train
ubc/ubcpi
ubcpi/answer_pool.py
offer_simple
def offer_simple(pool, answer, rationale, student_id, options): """ The simple selection algorithm. This algorithm randomly select an answer from the pool to discard and add the new one when the pool reaches the limit """ existing = pool.setdefault(answer, {}) if len(existing) >= get_max_si...
python
def offer_simple(pool, answer, rationale, student_id, options): """ The simple selection algorithm. This algorithm randomly select an answer from the pool to discard and add the new one when the pool reaches the limit """ existing = pool.setdefault(answer, {}) if len(existing) >= get_max_si...
[ "def", "offer_simple", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "options", ")", ":", "existing", "=", "pool", ".", "setdefault", "(", "answer", ",", "{", "}", ")", "if", "len", "(", "existing", ")", ">=", "get_max_size", "(...
The simple selection algorithm. This algorithm randomly select an answer from the pool to discard and add the new one when the pool reaches the limit
[ "The", "simple", "selection", "algorithm", "." ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L76-L88
train
ubc/ubcpi
ubcpi/answer_pool.py
offer_random
def offer_random(pool, answer, rationale, student_id, options): """ The random selection algorithm. The same as simple algorithm """ offer_simple(pool, answer, rationale, student_id, options)
python
def offer_random(pool, answer, rationale, student_id, options): """ The random selection algorithm. The same as simple algorithm """ offer_simple(pool, answer, rationale, student_id, options)
[ "def", "offer_random", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "options", ")", ":", "offer_simple", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "options", ")" ]
The random selection algorithm. The same as simple algorithm
[ "The", "random", "selection", "algorithm", ".", "The", "same", "as", "simple", "algorithm" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L91-L95
train
ubc/ubcpi
ubcpi/answer_pool.py
validate_seeded_answers_simple
def validate_seeded_answers_simple(answers, options, algo): """ This validator checks if the answers includes all possible options Args: answers (str): the answers to be checked options (dict): all options that should exist in the answers algo (str): selection algorithm Returns...
python
def validate_seeded_answers_simple(answers, options, algo): """ This validator checks if the answers includes all possible options Args: answers (str): the answers to be checked options (dict): all options that should exist in the answers algo (str): selection algorithm Returns...
[ "def", "validate_seeded_answers_simple", "(", "answers", ",", "options", ",", "algo", ")", ":", "seen_options", "=", "{", "}", "for", "answer", "in", "answers", ":", "if", "answer", ":", "key", "=", "options", "[", "answer", "[", "'answer'", "]", "]", "....
This validator checks if the answers includes all possible options Args: answers (str): the answers to be checked options (dict): all options that should exist in the answers algo (str): selection algorithm Returns: None if everything is good. Otherwise, the missing option erro...
[ "This", "validator", "checks", "if", "the", "answers", "includes", "all", "possible", "options" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L98-L131
train
ubc/ubcpi
ubcpi/answer_pool.py
validate_seeded_answers
def validate_seeded_answers(answers, options, algo): """ Validate answers based on selection algorithm This is called when instructor setup the tool and providing seeded answers to the question. This function is trying to validate if instructor provided enough seeds for a give algorithm. e.g. we re...
python
def validate_seeded_answers(answers, options, algo): """ Validate answers based on selection algorithm This is called when instructor setup the tool and providing seeded answers to the question. This function is trying to validate if instructor provided enough seeds for a give algorithm. e.g. we re...
[ "def", "validate_seeded_answers", "(", "answers", ",", "options", ",", "algo", ")", ":", "if", "algo", "[", "'name'", "]", "==", "'simple'", ":", "return", "validate_seeded_answers_simple", "(", "answers", ",", "options", ",", "algo", ")", "elif", "algo", "[...
Validate answers based on selection algorithm This is called when instructor setup the tool and providing seeded answers to the question. This function is trying to validate if instructor provided enough seeds for a give algorithm. e.g. we require 1 seed for each option in simple algorithm and at least 1 s...
[ "Validate", "answers", "based", "on", "selection", "algorithm" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L150-L173
train
ubc/ubcpi
ubcpi/answer_pool.py
get_other_answers
def get_other_answers(pool, seeded_answers, get_student_item_dict, algo, options): """ Select other student's answers from answer pool or seeded answers based on the selection algorithm Args: pool (dict): answer pool, format: { option1_index: { studen...
python
def get_other_answers(pool, seeded_answers, get_student_item_dict, algo, options): """ Select other student's answers from answer pool or seeded answers based on the selection algorithm Args: pool (dict): answer pool, format: { option1_index: { studen...
[ "def", "get_other_answers", "(", "pool", ",", "seeded_answers", ",", "get_student_item_dict", ",", "algo", ",", "options", ")", ":", "# \"#\" means the number of responses returned should be the same as the number of options.", "num_responses", "=", "len", "(", "options", ")"...
Select other student's answers from answer pool or seeded answers based on the selection algorithm Args: pool (dict): answer pool, format: { option1_index: { student_id: { can store algorithm specific info here } }, option2_ind...
[ "Select", "other", "student", "s", "answers", "from", "answer", "pool", "or", "seeded", "answers", "based", "on", "the", "selection", "algorithm" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L176-L212
train
ubc/ubcpi
ubcpi/answer_pool.py
get_other_answers_simple
def get_other_answers_simple(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with simple algorithm, which picks one answer for each option. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value may not ...
python
def get_other_answers_simple(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with simple algorithm, which picks one answer for each option. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value may not ...
[ "def", "get_other_answers_simple", "(", "pool", ",", "seeded_answers", ",", "get_student_item_dict", ",", "num_responses", ")", ":", "ret", "=", "[", "]", "# clean up answers so that all keys are int", "pool", "=", "{", "int", "(", "k", ")", ":", "v", "for", "k"...
Get answers from others with simple algorithm, which picks one answer for each option. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value may not be respected if there is not enough answers to return Returns: dict: answers ...
[ "Get", "answers", "from", "others", "with", "simple", "algorithm", "which", "picks", "one", "answer", "for", "each", "option", "." ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L215-L274
train
ubc/ubcpi
ubcpi/answer_pool.py
get_other_answers_random
def get_other_answers_random(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with random algorithm, which randomly select answer from the pool. Student may get three answers for option 1 or one answer for option 1 and two answers for option 2. Args: see...
python
def get_other_answers_random(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with random algorithm, which randomly select answer from the pool. Student may get three answers for option 1 or one answer for option 1 and two answers for option 2. Args: see...
[ "def", "get_other_answers_random", "(", "pool", ",", "seeded_answers", ",", "get_student_item_dict", ",", "num_responses", ")", ":", "ret", "=", "[", "]", "# clean up answers so that all keys are int", "pool", "=", "{", "int", "(", "k", ")", ":", "v", "for", "k"...
Get answers from others with random algorithm, which randomly select answer from the pool. Student may get three answers for option 1 or one answer for option 1 and two answers for option 2. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value m...
[ "Get", "answers", "from", "others", "with", "random", "algorithm", "which", "randomly", "select", "answer", "from", "the", "pool", "." ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L277-L323
train
ubc/ubcpi
ubcpi/answer_pool.py
convert_seeded_answers
def convert_seeded_answers(answers): """ Convert seeded answers into the format that can be merged into student answers. Args: answers (list): seeded answers Returns: dict: seeded answers with student answers format: { 0: { 'seeded0': 'ra...
python
def convert_seeded_answers(answers): """ Convert seeded answers into the format that can be merged into student answers. Args: answers (list): seeded answers Returns: dict: seeded answers with student answers format: { 0: { 'seeded0': 'ra...
[ "def", "convert_seeded_answers", "(", "answers", ")", ":", "converted", "=", "{", "}", "for", "index", ",", "answer", "in", "enumerate", "(", "answers", ")", ":", "converted", ".", "setdefault", "(", "answer", "[", "'answer'", "]", ",", "{", "}", ")", ...
Convert seeded answers into the format that can be merged into student answers. Args: answers (list): seeded answers Returns: dict: seeded answers with student answers format: { 0: { 'seeded0': 'rationaleA' } 1: { ...
[ "Convert", "seeded", "answers", "into", "the", "format", "that", "can", "be", "merged", "into", "student", "answers", "." ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L326-L349
train
twisted/axiom
axiom/batch.py
upgradeProcessor1to2
def upgradeProcessor1to2(oldProcessor): """ Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event...
python
def upgradeProcessor1to2(oldProcessor): """ Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event...
[ "def", "upgradeProcessor1to2", "(", "oldProcessor", ")", ":", "newProcessor", "=", "oldProcessor", ".", "upgradeVersion", "(", "oldProcessor", ".", "typeName", ",", "1", ",", "2", ",", "busyInterval", "=", "oldProcessor", ".", "busyInterval", ")", "newProcessor", ...
Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event here to make sure that they don't silently disa...
[ "Batch", "processors", "stopped", "polling", "at", "version", "2", "so", "they", "no", "longer", "needed", "the", "idleInterval", "attribute", ".", "They", "also", "gained", "a", "scheduled", "attribute", "which", "tracks", "their", "interaction", "with", "the",...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L428-L460
train
twisted/axiom
axiom/batch.py
processor
def processor(forType): """ Create an Axiom Item type which is suitable to use as a batch processor for the given Axiom Item type. Processors created this way depend on a L{iaxiom.IScheduler} powerup on the on which store they are installed. @type forType: L{item.MetaItem} @param forType: ...
python
def processor(forType): """ Create an Axiom Item type which is suitable to use as a batch processor for the given Axiom Item type. Processors created this way depend on a L{iaxiom.IScheduler} powerup on the on which store they are installed. @type forType: L{item.MetaItem} @param forType: ...
[ "def", "processor", "(", "forType", ")", ":", "MILLI", "=", "1000", "try", ":", "processor", "=", "_processors", "[", "forType", "]", "except", "KeyError", ":", "def", "__init__", "(", "self", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "item", "...
Create an Axiom Item type which is suitable to use as a batch processor for the given Axiom Item type. Processors created this way depend on a L{iaxiom.IScheduler} powerup on the on which store they are installed. @type forType: L{item.MetaItem} @param forType: The Axiom Item type for which to cre...
[ "Create", "an", "Axiom", "Item", "type", "which", "is", "suitable", "to", "use", "as", "a", "batch", "processor", "for", "the", "given", "Axiom", "Item", "type", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L462-L518
train
twisted/axiom
axiom/batch.py
storeBatchServiceSpecialCase
def storeBatchServiceSpecialCase(st, pups): """ Adapt a L{Store} to L{IBatchService}. If C{st} is a substore, return a simple wrapper that delegates to the site store's L{IBatchService} powerup. Return C{None} if C{st} has no L{BatchProcessingControllerService}. """ if st.parent is not Non...
python
def storeBatchServiceSpecialCase(st, pups): """ Adapt a L{Store} to L{IBatchService}. If C{st} is a substore, return a simple wrapper that delegates to the site store's L{IBatchService} powerup. Return C{None} if C{st} has no L{BatchProcessingControllerService}. """ if st.parent is not Non...
[ "def", "storeBatchServiceSpecialCase", "(", "st", ",", "pups", ")", ":", "if", "st", ".", "parent", "is", "not", "None", ":", "try", ":", "return", "_SubStoreBatchChannel", "(", "st", ")", "except", "TypeError", ":", "return", "None", "storeService", "=", ...
Adapt a L{Store} to L{IBatchService}. If C{st} is a substore, return a simple wrapper that delegates to the site store's L{IBatchService} powerup. Return C{None} if C{st} has no L{BatchProcessingControllerService}.
[ "Adapt", "a", "L", "{", "Store", "}", "to", "L", "{", "IBatchService", "}", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L1017-L1034
train
twisted/axiom
axiom/batch.py
_ProcessingFailure.mark
def mark(self): """ Mark the unit of work as failed in the database and update the listener so as to skip it next time. """ self.reliableListener.lastRun = extime.Time() BatchProcessingError( store=self.reliableListener.store, processor=self.reliab...
python
def mark(self): """ Mark the unit of work as failed in the database and update the listener so as to skip it next time. """ self.reliableListener.lastRun = extime.Time() BatchProcessingError( store=self.reliableListener.store, processor=self.reliab...
[ "def", "mark", "(", "self", ")", ":", "self", ".", "reliableListener", ".", "lastRun", "=", "extime", ".", "Time", "(", ")", "BatchProcessingError", "(", "store", "=", "self", ".", "reliableListener", ".", "store", ",", "processor", "=", "self", ".", "re...
Mark the unit of work as failed in the database and update the listener so as to skip it next time.
[ "Mark", "the", "unit", "of", "work", "as", "failed", "in", "the", "database", "and", "update", "the", "listener", "so", "as", "to", "skip", "it", "next", "time", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L53-L64
train
twisted/axiom
axiom/batch.py
_BatchProcessorMixin.run
def run(self): """ Try to run one unit of work through one listener. If there are more listeners or more work, reschedule this item to be run again in C{self.busyInterval} milliseconds, otherwise unschedule it. @rtype: L{extime.Time} or C{None} @return: The next time at...
python
def run(self): """ Try to run one unit of work through one listener. If there are more listeners or more work, reschedule this item to be run again in C{self.busyInterval} milliseconds, otherwise unschedule it. @rtype: L{extime.Time} or C{None} @return: The next time at...
[ "def", "run", "(", "self", ")", ":", "now", "=", "extime", ".", "Time", "(", ")", "if", "self", ".", "step", "(", ")", ":", "self", ".", "scheduled", "=", "now", "+", "datetime", ".", "timedelta", "(", "milliseconds", "=", "self", ".", "busyInterva...
Try to run one unit of work through one listener. If there are more listeners or more work, reschedule this item to be run again in C{self.busyInterval} milliseconds, otherwise unschedule it. @rtype: L{extime.Time} or C{None} @return: The next time at which to run this item, used by th...
[ "Try", "to", "run", "one", "unit", "of", "work", "through", "one", "listener", ".", "If", "there", "are", "more", "listeners", "or", "more", "work", "reschedule", "this", "item", "to", "be", "run", "again", "in", "C", "{", "self", ".", "busyInterval", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L297-L312
train
twisted/axiom
axiom/batch.py
_BatchProcessorMixin.addReliableListener
def addReliableListener(self, listener, style=iaxiom.LOCAL): """ Add the given Item to the set which will be notified of Items available for processing. Note: Each Item is processed synchronously. Adding too many listeners to a single batch processor will cause the L{step} ...
python
def addReliableListener(self, listener, style=iaxiom.LOCAL): """ Add the given Item to the set which will be notified of Items available for processing. Note: Each Item is processed synchronously. Adding too many listeners to a single batch processor will cause the L{step} ...
[ "def", "addReliableListener", "(", "self", ",", "listener", ",", "style", "=", "iaxiom", ".", "LOCAL", ")", ":", "existing", "=", "self", ".", "store", ".", "findUnique", "(", "_ReliableListener", ",", "attributes", ".", "AND", "(", "_ReliableListener", ".",...
Add the given Item to the set which will be notified of Items available for processing. Note: Each Item is processed synchronously. Adding too many listeners to a single batch processor will cause the L{step} method to block while it sends notification to each listener. @param...
[ "Add", "the", "given", "Item", "to", "the", "set", "which", "will", "be", "notified", "of", "Items", "available", "for", "processing", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L323-L363
train
twisted/axiom
axiom/batch.py
_BatchProcessorMixin.removeReliableListener
def removeReliableListener(self, listener): """ Remove a previously added listener. """ self.store.query(_ReliableListener, attributes.AND(_ReliableListener.processor == self, _ReliableListener.listener == listener)).delete...
python
def removeReliableListener(self, listener): """ Remove a previously added listener. """ self.store.query(_ReliableListener, attributes.AND(_ReliableListener.processor == self, _ReliableListener.listener == listener)).delete...
[ "def", "removeReliableListener", "(", "self", ",", "listener", ")", ":", "self", ".", "store", ".", "query", "(", "_ReliableListener", ",", "attributes", ".", "AND", "(", "_ReliableListener", ".", "processor", "==", "self", ",", "_ReliableListener", ".", "list...
Remove a previously added listener.
[ "Remove", "a", "previously", "added", "listener", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L366-L375
train
twisted/axiom
axiom/batch.py
_BatchProcessorMixin.getReliableListeners
def getReliableListeners(self): """ Return an iterable of the listeners which have been added to this batch processor. """ for rellist in self.store.query(_ReliableListener, _ReliableListener.processor == self): yield rellist.listener
python
def getReliableListeners(self): """ Return an iterable of the listeners which have been added to this batch processor. """ for rellist in self.store.query(_ReliableListener, _ReliableListener.processor == self): yield rellist.listener
[ "def", "getReliableListeners", "(", "self", ")", ":", "for", "rellist", "in", "self", ".", "store", ".", "query", "(", "_ReliableListener", ",", "_ReliableListener", ".", "processor", "==", "self", ")", ":", "yield", "rellist", ".", "listener" ]
Return an iterable of the listeners which have been added to this batch processor.
[ "Return", "an", "iterable", "of", "the", "listeners", "which", "have", "been", "added", "to", "this", "batch", "processor", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L378-L384
train
twisted/axiom
axiom/batch.py
_BatchProcessorMixin.getFailedItems
def getFailedItems(self): """ Return an iterable of two-tuples of listeners which raised an exception from C{processItem} and the item which was passed as the argument to that method. """ for failed in self.store.query(BatchProcessingError, BatchProcessingError.processor ...
python
def getFailedItems(self): """ Return an iterable of two-tuples of listeners which raised an exception from C{processItem} and the item which was passed as the argument to that method. """ for failed in self.store.query(BatchProcessingError, BatchProcessingError.processor ...
[ "def", "getFailedItems", "(", "self", ")", ":", "for", "failed", "in", "self", ".", "store", ".", "query", "(", "BatchProcessingError", ",", "BatchProcessingError", ".", "processor", "==", "self", ")", ":", "yield", "(", "failed", ".", "listener", ",", "fa...
Return an iterable of two-tuples of listeners which raised an exception from C{processItem} and the item which was passed as the argument to that method.
[ "Return", "an", "iterable", "of", "two", "-", "tuples", "of", "listeners", "which", "raised", "an", "exception", "from", "C", "{", "processItem", "}", "and", "the", "item", "which", "was", "passed", "as", "the", "argument", "to", "that", "method", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L387-L394
train
twisted/axiom
axiom/batch.py
_BatchProcessorMixin.itemAdded
def itemAdded(self): """ Called to indicate that a new item of the type monitored by this batch processor is being added to the database. If this processor is not already scheduled to run, this will schedule it. It will also start the batch process if it is not yet running and ...
python
def itemAdded(self): """ Called to indicate that a new item of the type monitored by this batch processor is being added to the database. If this processor is not already scheduled to run, this will schedule it. It will also start the batch process if it is not yet running and ...
[ "def", "itemAdded", "(", "self", ")", ":", "localCount", "=", "self", ".", "store", ".", "query", "(", "_ReliableListener", ",", "attributes", ".", "AND", "(", "_ReliableListener", ".", "processor", "==", "self", ",", "_ReliableListener", ".", "style", "==",...
Called to indicate that a new item of the type monitored by this batch processor is being added to the database. If this processor is not already scheduled to run, this will schedule it. It will also start the batch process if it is not yet running and there are any registered remote l...
[ "Called", "to", "indicate", "that", "a", "new", "item", "of", "the", "type", "monitored", "by", "this", "batch", "processor", "is", "being", "added", "to", "the", "database", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L397-L424
train
twisted/axiom
axiom/batch.py
BatchProcessingControllerService.call
def call(self, itemMethod): """ Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked. """ item = itemMethod.im_self method = itemMethod.im_func.func_name return self.batchController.getProcess().a...
python
def call(self, itemMethod): """ Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked. """ item = itemMethod.im_self method = itemMethod.im_func.func_name return self.batchController.getProcess().a...
[ "def", "call", "(", "self", ",", "itemMethod", ")", ":", "item", "=", "itemMethod", ".", "im_self", "method", "=", "itemMethod", ".", "im_func", ".", "func_name", "return", "self", ".", "batchController", ".", "getProcess", "(", ")", ".", "addCallback", "(...
Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked.
[ "Invoke", "the", "given", "bound", "item", "method", "in", "the", "batch", "process", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L956-L967
train
twisted/axiom
axiom/batch.py
BatchProcessingService.processWhileRunning
def processWhileRunning(self): """ Run tasks until stopService is called. """ work = self.step() for result, more in work: yield result if not self.running: break if more: delay = 0.1 else: ...
python
def processWhileRunning(self): """ Run tasks until stopService is called. """ work = self.step() for result, more in work: yield result if not self.running: break if more: delay = 0.1 else: ...
[ "def", "processWhileRunning", "(", "self", ")", ":", "work", "=", "self", ".", "step", "(", ")", "for", "result", ",", "more", "in", "work", ":", "yield", "result", "if", "not", "self", ".", "running", ":", "break", "if", "more", ":", "delay", "=", ...
Run tasks until stopService is called.
[ "Run", "tasks", "until", "stopService", "is", "called", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L1158-L1171
train
swharden/PyOriginTools
PyOriginTools/scratch.py
getcols
def getcols(sheetMatch=None,colMatch="Decay"): """find every column in every sheet and put it in a new sheet or book.""" book=BOOK() if sheetMatch is None: matchingSheets=book.sheetNames print('all %d sheets selected '%(len(matchingSheets))) else: matchingSheets=[x for x in book....
python
def getcols(sheetMatch=None,colMatch="Decay"): """find every column in every sheet and put it in a new sheet or book.""" book=BOOK() if sheetMatch is None: matchingSheets=book.sheetNames print('all %d sheets selected '%(len(matchingSheets))) else: matchingSheets=[x for x in book....
[ "def", "getcols", "(", "sheetMatch", "=", "None", ",", "colMatch", "=", "\"Decay\"", ")", ":", "book", "=", "BOOK", "(", ")", "if", "sheetMatch", "is", "None", ":", "matchingSheets", "=", "book", ".", "sheetNames", "print", "(", "'all %d sheets selected '", ...
find every column in every sheet and put it in a new sheet or book.
[ "find", "every", "column", "in", "every", "sheet", "and", "put", "it", "in", "a", "new", "sheet", "or", "book", "." ]
536fb8e11234ffdc27e26b1800e0358179ca7d26
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/scratch.py#L55-L75
train
twisted/axiom
axiom/plugins/axiom_plugins.py
Upgrade.upgradeStore
def upgradeStore(self, store): """ Recursively upgrade C{store}. """ self.upgradeEverything(store) upgradeExplicitOid(store) for substore in store.query(SubStore): print 'Upgrading: {!r}'.format(substore) self.upgradeStore(substore.open())
python
def upgradeStore(self, store): """ Recursively upgrade C{store}. """ self.upgradeEverything(store) upgradeExplicitOid(store) for substore in store.query(SubStore): print 'Upgrading: {!r}'.format(substore) self.upgradeStore(substore.open())
[ "def", "upgradeStore", "(", "self", ",", "store", ")", ":", "self", ".", "upgradeEverything", "(", "store", ")", "upgradeExplicitOid", "(", "store", ")", "for", "substore", "in", "store", ".", "query", "(", "SubStore", ")", ":", "print", "'Upgrading: {!r}'",...
Recursively upgrade C{store}.
[ "Recursively", "upgrade", "C", "{", "store", "}", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L56-L65
train
twisted/axiom
axiom/plugins/axiom_plugins.py
Upgrade.perform
def perform(self, store, count): """ Upgrade C{store} performing C{count} upgrades per transaction. Also, catch any exceptions and print out something useful. """ self.count = count try: self.upgradeStore(store) print 'Upgrade complete' e...
python
def perform(self, store, count): """ Upgrade C{store} performing C{count} upgrades per transaction. Also, catch any exceptions and print out something useful. """ self.count = count try: self.upgradeStore(store) print 'Upgrade complete' e...
[ "def", "perform", "(", "self", ",", "store", ",", "count", ")", ":", "self", ".", "count", "=", "count", "try", ":", "self", ".", "upgradeStore", "(", "store", ")", "print", "'Upgrade complete'", "except", "errors", ".", "ItemUpgradeError", "as", "e", ":...
Upgrade C{store} performing C{count} upgrades per transaction. Also, catch any exceptions and print out something useful.
[ "Upgrade", "C", "{", "store", "}", "performing", "C", "{", "count", "}", "upgrades", "per", "transaction", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L67-L83
train
twisted/axiom
axiom/plugins/axiom_plugins.py
AxiomConsole.runcode
def runcode(self, code): """ Override L{code.InteractiveConsole.runcode} to run the code in a transaction unless the local C{autocommit} is currently set to a true value. """ if not self.locals.get('autocommit', None): return self.locals['db'].transact(code.In...
python
def runcode(self, code): """ Override L{code.InteractiveConsole.runcode} to run the code in a transaction unless the local C{autocommit} is currently set to a true value. """ if not self.locals.get('autocommit', None): return self.locals['db'].transact(code.In...
[ "def", "runcode", "(", "self", ",", "code", ")", ":", "if", "not", "self", ".", "locals", ".", "get", "(", "'autocommit'", ",", "None", ")", ":", "return", "self", ".", "locals", "[", "'db'", "]", ".", "transact", "(", "code", ".", "InteractiveConsol...
Override L{code.InteractiveConsole.runcode} to run the code in a transaction unless the local C{autocommit} is currently set to a true value.
[ "Override", "L", "{", "code", ".", "InteractiveConsole", ".", "runcode", "}", "to", "run", "the", "code", "in", "a", "transaction", "unless", "the", "local", "C", "{", "autocommit", "}", "is", "currently", "set", "to", "a", "true", "value", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L98-L106
train
twisted/axiom
axiom/plugins/axiom_plugins.py
Browse.namespace
def namespace(self): """ Return a dictionary representing the namespace which should be available to the user. """ self._ns = { 'db': self.store, 'store': store, 'autocommit': False, } return self._ns
python
def namespace(self): """ Return a dictionary representing the namespace which should be available to the user. """ self._ns = { 'db': self.store, 'store': store, 'autocommit': False, } return self._ns
[ "def", "namespace", "(", "self", ")", ":", "self", ".", "_ns", "=", "{", "'db'", ":", "self", ".", "store", ",", "'store'", ":", "store", ",", "'autocommit'", ":", "False", ",", "}", "return", "self", ".", "_ns" ]
Return a dictionary representing the namespace which should be available to the user.
[ "Return", "a", "dictionary", "representing", "the", "namespace", "which", "should", "be", "available", "to", "the", "user", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L137-L147
train
twisted/axiom
axiom/plugins/axiom_plugins.py
Create.addAccount
def addAccount(self, siteStore, username, domain, password): """ Create a new account in the given store. @param siteStore: A site Store to which login credentials will be added. @param username: Local part of the username for the credentials to add. @param domain: Domai...
python
def addAccount(self, siteStore, username, domain, password): """ Create a new account in the given store. @param siteStore: A site Store to which login credentials will be added. @param username: Local part of the username for the credentials to add. @param domain: Domai...
[ "def", "addAccount", "(", "self", ",", "siteStore", ",", "username", ",", "domain", ",", "password", ")", ":", "for", "ls", "in", "siteStore", ".", "query", "(", "userbase", ".", "LoginSystem", ")", ":", "break", "else", ":", "ls", "=", "self", ".", ...
Create a new account in the given store. @param siteStore: A site Store to which login credentials will be added. @param username: Local part of the username for the credentials to add. @param domain: Domain part of the username for the credentials to add. @param password: Passw...
[ "Create", "a", "new", "account", "in", "the", "given", "store", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L191-L211
train
twisted/axiom
benchmark/benchlib.py
itemTypeWithSomeAttributes
def itemTypeWithSomeAttributes(attributeTypes): """ Create a new L{Item} subclass with L{numAttributes} integers in its schema. """ class SomeItem(Item): typeName = 'someitem_' + str(typeNameCounter()) for i, attributeType in enumerate(attributeTypes): locals()['attr_' + ...
python
def itemTypeWithSomeAttributes(attributeTypes): """ Create a new L{Item} subclass with L{numAttributes} integers in its schema. """ class SomeItem(Item): typeName = 'someitem_' + str(typeNameCounter()) for i, attributeType in enumerate(attributeTypes): locals()['attr_' + ...
[ "def", "itemTypeWithSomeAttributes", "(", "attributeTypes", ")", ":", "class", "SomeItem", "(", "Item", ")", ":", "typeName", "=", "'someitem_'", "+", "str", "(", "typeNameCounter", "(", ")", ")", "for", "i", ",", "attributeType", "in", "enumerate", "(", "at...
Create a new L{Item} subclass with L{numAttributes} integers in its schema.
[ "Create", "a", "new", "L", "{", "Item", "}", "subclass", "with", "L", "{", "numAttributes", "}", "integers", "in", "its", "schema", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/benchmark/benchlib.py#L13-L22
train
twisted/axiom
benchmark/benchlib.py
createSomeItems
def createSomeItems(store, itemType, values, counter): """ Create some instances of a particular type in a store. """ for i in counter: itemType(store=store, **values)
python
def createSomeItems(store, itemType, values, counter): """ Create some instances of a particular type in a store. """ for i in counter: itemType(store=store, **values)
[ "def", "createSomeItems", "(", "store", ",", "itemType", ",", "values", ",", "counter", ")", ":", "for", "i", "in", "counter", ":", "itemType", "(", "store", "=", "store", ",", "*", "*", "values", ")" ]
Create some instances of a particular type in a store.
[ "Create", "some", "instances", "of", "a", "particular", "type", "in", "a", "store", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/benchmark/benchlib.py#L25-L30
train
stephrdev/django-mongoforms
mongoforms/forms.py
MongoForm.save
def save(self, commit=True): """save the instance or create a new one..""" # walk through the document fields for field_name, field in iter_valid_fields(self._meta): setattr(self.instance, field_name, self.cleaned_data.get(field_name)) if commit: self.instance.s...
python
def save(self, commit=True): """save the instance or create a new one..""" # walk through the document fields for field_name, field in iter_valid_fields(self._meta): setattr(self.instance, field_name, self.cleaned_data.get(field_name)) if commit: self.instance.s...
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "# walk through the document fields", "for", "field_name", ",", "field", "in", "iter_valid_fields", "(", "self", ".", "_meta", ")", ":", "setattr", "(", "self", ".", "instance", ",", "field_na...
save the instance or create a new one..
[ "save", "the", "instance", "or", "create", "a", "new", "one", ".." ]
6fa46824c438555c703f293d682ca92710938985
https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/forms.py#L95-L105
train
twisted/axiom
axiom/item.py
transacted
def transacted(func): """ Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble...
python
def transacted(func): """ Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble...
[ "def", "transacted", "(", "func", ")", ":", "def", "transactionified", "(", "item", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "return", "item", ".", "store", ".", "transact", "(", "func", ",", "item", ",", "*", "a", ",", "*", "*", "kw", ")"...
Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble those of C{func} as closely a...
[ "Return", "a", "callable", "which", "will", "invoke", "C", "{", "func", "}", "in", "a", "transaction", "using", "the", "C", "{", "store", "}", "attribute", "of", "the", "first", "parameter", "passed", "to", "it", ".", "Typically", "this", "is", "used", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L403-L414
train
twisted/axiom
axiom/item.py
dependentItems
def dependentItems(store, tableClass, comparisonFactory): """ Collect all the items that should be deleted when an item or items of a particular item type are deleted. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxi...
python
def dependentItems(store, tableClass, comparisonFactory): """ Collect all the items that should be deleted when an item or items of a particular item type are deleted. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxi...
[ "def", "dependentItems", "(", "store", ",", "tableClass", ",", "comparisonFactory", ")", ":", "for", "cascadingAttr", "in", "(", "_cascadingDeletes", ".", "get", "(", "tableClass", ",", "[", "]", ")", "+", "_cascadingDeletes", ".", "get", "(", "None", ",", ...
Collect all the items that should be deleted when an item or items of a particular item type are deleted. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxiom.IComparison} describing the items to collect. @return: An ...
[ "Collect", "all", "the", "items", "that", "should", "be", "deleted", "when", "an", "item", "or", "items", "of", "a", "particular", "item", "type", "are", "deleted", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L419-L436
train
twisted/axiom
axiom/item.py
allowDeletion
def allowDeletion(store, tableClass, comparisonFactory): """ Returns a C{bool} indicating whether deletion of an item or items of a particular item type should be allowed to proceed. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and retu...
python
def allowDeletion(store, tableClass, comparisonFactory): """ Returns a C{bool} indicating whether deletion of an item or items of a particular item type should be allowed to proceed. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and retu...
[ "def", "allowDeletion", "(", "store", ",", "tableClass", ",", "comparisonFactory", ")", ":", "for", "cascadingAttr", "in", "(", "_disallows", ".", "get", "(", "tableClass", ",", "[", "]", ")", "+", "_disallows", ".", "get", "(", "None", ",", "[", "]", ...
Returns a C{bool} indicating whether deletion of an item or items of a particular item type should be allowed to proceed. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxiom.IComparison} describing the items to collect. ...
[ "Returns", "a", "C", "{", "bool", "}", "indicating", "whether", "deletion", "of", "an", "item", "or", "items", "of", "a", "particular", "item", "type", "should", "be", "allowed", "to", "proceed", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L440-L460
train
twisted/axiom
axiom/item.py
declareLegacyItem
def declareLegacyItem(typeName, schemaVersion, attributes, dummyBases=()): """ Generate a dummy subclass of Item that will have the given attributes, and the base Item methods, but no methods of its own. This is for use with upgrading. @param typeName: a string, the Axiom TypeName to have attribut...
python
def declareLegacyItem(typeName, schemaVersion, attributes, dummyBases=()): """ Generate a dummy subclass of Item that will have the given attributes, and the base Item methods, but no methods of its own. This is for use with upgrading. @param typeName: a string, the Axiom TypeName to have attribut...
[ "def", "declareLegacyItem", "(", "typeName", ",", "schemaVersion", ",", "attributes", ",", "dummyBases", "=", "(", ")", ")", ":", "if", "(", "typeName", ",", "schemaVersion", ")", "in", "_legacyTypes", ":", "return", "_legacyTypes", "[", "typeName", ",", "sc...
Generate a dummy subclass of Item that will have the given attributes, and the base Item methods, but no methods of its own. This is for use with upgrading. @param typeName: a string, the Axiom TypeName to have attributes for. @param schemaVersion: an int, the (old) version of the schema this is a pro...
[ "Generate", "a", "dummy", "subclass", "of", "Item", "that", "will", "have", "the", "given", "attributes", "and", "the", "base", "Item", "methods", "but", "no", "methods", "of", "its", "own", ".", "This", "is", "for", "use", "with", "upgrading", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L1094-L1126
train
twisted/axiom
axiom/item.py
empowerment
def empowerment(iface, priority=0): """ Class decorator for indicating a powerup's powerup interfaces. The class will also be declared as implementing the interface. @type iface: L{zope.interface.Interface} @param iface: The powerup interface. @type priority: int @param priority: The prio...
python
def empowerment(iface, priority=0): """ Class decorator for indicating a powerup's powerup interfaces. The class will also be declared as implementing the interface. @type iface: L{zope.interface.Interface} @param iface: The powerup interface. @type priority: int @param priority: The prio...
[ "def", "empowerment", "(", "iface", ",", "priority", "=", "0", ")", ":", "def", "_deco", "(", "cls", ")", ":", "cls", ".", "powerupInterfaces", "=", "(", "tuple", "(", "getattr", "(", "cls", ",", "'powerupInterfaces'", ",", "(", ")", ")", ")", "+", ...
Class decorator for indicating a powerup's powerup interfaces. The class will also be declared as implementing the interface. @type iface: L{zope.interface.Interface} @param iface: The powerup interface. @type priority: int @param priority: The priority the powerup will be installed at.
[ "Class", "decorator", "for", "indicating", "a", "powerup", "s", "powerup", "interfaces", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L1147-L1165
train
twisted/axiom
axiom/item.py
Empowered.powerUp
def powerUp(self, powerup, interface=None, priority=0): """ Installs a powerup (e.g. plugin) on an item or store. Powerups will be returned in an iterator when queried for using the 'powerupsFor' method. Normally they will be returned in order of installation [this may change i...
python
def powerUp(self, powerup, interface=None, priority=0): """ Installs a powerup (e.g. plugin) on an item or store. Powerups will be returned in an iterator when queried for using the 'powerupsFor' method. Normally they will be returned in order of installation [this may change i...
[ "def", "powerUp", "(", "self", ",", "powerup", ",", "interface", "=", "None", ",", "priority", "=", "0", ")", ":", "if", "interface", "is", "None", ":", "for", "iface", ",", "priority", "in", "powerup", ".", "_getPowerupInterfaces", "(", ")", ":", "sel...
Installs a powerup (e.g. plugin) on an item or store. Powerups will be returned in an iterator when queried for using the 'powerupsFor' method. Normally they will be returned in order of installation [this may change in future versions, so please don't depend on it]. Higher priorities...
[ "Installs", "a", "powerup", "(", "e", ".", "g", ".", "plugin", ")", "on", "an", "item", "or", "store", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L213-L270
train
twisted/axiom
axiom/item.py
Empowered.powerDown
def powerDown(self, powerup, interface=None): """ Remove a powerup. If no interface is specified, and the type of the object being installed has a "powerupInterfaces" attribute (containing either a sequence of interfaces, or a sequence of (interface, priority) tuples), t...
python
def powerDown(self, powerup, interface=None): """ Remove a powerup. If no interface is specified, and the type of the object being installed has a "powerupInterfaces" attribute (containing either a sequence of interfaces, or a sequence of (interface, priority) tuples), t...
[ "def", "powerDown", "(", "self", ",", "powerup", ",", "interface", "=", "None", ")", ":", "if", "interface", "is", "None", ":", "for", "interface", ",", "priority", "in", "powerup", ".", "_getPowerupInterfaces", "(", ")", ":", "self", ".", "powerDown", "...
Remove a powerup. If no interface is specified, and the type of the object being installed has a "powerupInterfaces" attribute (containing either a sequence of interfaces, or a sequence of (interface, priority) tuples), the target will be powered down with this object on those i...
[ "Remove", "a", "powerup", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L273-L303
train
twisted/axiom
axiom/item.py
Empowered.powerupsFor
def powerupsFor(self, interface): """ Returns powerups installed using C{powerUp}, in order of descending priority. Powerups found to have been deleted, either during the course of this powerupsFor iteration, during an upgrader, or previously, will not be returned. ...
python
def powerupsFor(self, interface): """ Returns powerups installed using C{powerUp}, in order of descending priority. Powerups found to have been deleted, either during the course of this powerupsFor iteration, during an upgrader, or previously, will not be returned. ...
[ "def", "powerupsFor", "(", "self", ",", "interface", ")", ":", "inMemoryPowerup", "=", "self", ".", "_inMemoryPowerups", ".", "get", "(", "interface", ",", "None", ")", "if", "inMemoryPowerup", "is", "not", "None", ":", "yield", "inMemoryPowerup", "if", "sel...
Returns powerups installed using C{powerUp}, in order of descending priority. Powerups found to have been deleted, either during the course of this powerupsFor iteration, during an upgrader, or previously, will not be returned.
[ "Returns", "powerups", "installed", "using", "C", "{", "powerUp", "}", "in", "order", "of", "descending", "priority", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L330-L359
train
twisted/axiom
axiom/item.py
Empowered.interfacesFor
def interfacesFor(self, powerup): """ Return an iterator of the interfaces for which the given powerup is installed on this object. This is not implemented for in-memory powerups. It will probably fail in an unpredictable, implementation-dependent way if used on one. ""...
python
def interfacesFor(self, powerup): """ Return an iterator of the interfaces for which the given powerup is installed on this object. This is not implemented for in-memory powerups. It will probably fail in an unpredictable, implementation-dependent way if used on one. ""...
[ "def", "interfacesFor", "(", "self", ",", "powerup", ")", ":", "pc", "=", "_PowerupConnector", "for", "iface", "in", "self", ".", "store", ".", "query", "(", "pc", ",", "AND", "(", "pc", ".", "item", "==", "self", ",", "pc", ".", "powerup", "==", "...
Return an iterator of the interfaces for which the given powerup is installed on this object. This is not implemented for in-memory powerups. It will probably fail in an unpredictable, implementation-dependent way if used on one.
[ "Return", "an", "iterator", "of", "the", "interfaces", "for", "which", "the", "given", "powerup", "is", "installed", "on", "this", "object", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L361-L373
train
twisted/axiom
axiom/item.py
Empowered._getPowerupInterfaces
def _getPowerupInterfaces(self): """ Collect powerup interfaces this object declares that it can be installed on. """ powerupInterfaces = getattr(self.__class__, "powerupInterfaces", ()) pifs = [] for x in powerupInterfaces: if isinstance(x, type(Inter...
python
def _getPowerupInterfaces(self): """ Collect powerup interfaces this object declares that it can be installed on. """ powerupInterfaces = getattr(self.__class__, "powerupInterfaces", ()) pifs = [] for x in powerupInterfaces: if isinstance(x, type(Inter...
[ "def", "_getPowerupInterfaces", "(", "self", ")", ":", "powerupInterfaces", "=", "getattr", "(", "self", ".", "__class__", ",", "\"powerupInterfaces\"", ",", "(", ")", ")", "pifs", "=", "[", "]", "for", "x", "in", "powerupInterfaces", ":", "if", "isinstance"...
Collect powerup interfaces this object declares that it can be installed on.
[ "Collect", "powerup", "interfaces", "this", "object", "declares", "that", "it", "can", "be", "installed", "on", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L376-L399
train
twisted/axiom
axiom/item.py
Item._currentlyValidAsReferentFor
def _currentlyValidAsReferentFor(self, store): """ Is this object currently valid as a reference? Objects which will be deleted in this transaction, or objects which are not in the same store are not valid. See attributes.reference.__get__. """ if store is None: ...
python
def _currentlyValidAsReferentFor(self, store): """ Is this object currently valid as a reference? Objects which will be deleted in this transaction, or objects which are not in the same store are not valid. See attributes.reference.__get__. """ if store is None: ...
[ "def", "_currentlyValidAsReferentFor", "(", "self", ",", "store", ")", ":", "if", "store", "is", "None", ":", "# If your store is None, you can refer to whoever you want. I'm in", "# a store but it doesn't matter that you're not.", "return", "True", "if", "self", ".", "store...
Is this object currently valid as a reference? Objects which will be deleted in this transaction, or objects which are not in the same store are not valid. See attributes.reference.__get__.
[ "Is", "this", "object", "currently", "valid", "as", "a", "reference?", "Objects", "which", "will", "be", "deleted", "in", "this", "transaction", "or", "objects", "which", "are", "not", "in", "the", "same", "store", "are", "not", "valid", ".", "See", "attri...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L500-L514
train
twisted/axiom
axiom/item.py
Item._schemaPrepareInsert
def _schemaPrepareInsert(self, store): """ Prepare each attribute in my schema for insertion into a given store, either by upgrade or by creation. This makes sure all references point to this store and all relative paths point to this store's files directory. """ ...
python
def _schemaPrepareInsert(self, store): """ Prepare each attribute in my schema for insertion into a given store, either by upgrade or by creation. This makes sure all references point to this store and all relative paths point to this store's files directory. """ ...
[ "def", "_schemaPrepareInsert", "(", "self", ",", "store", ")", ":", "for", "name", ",", "atr", "in", "self", ".", "getSchema", "(", ")", ":", "atr", ".", "prepareInsert", "(", "self", ",", "store", ")" ]
Prepare each attribute in my schema for insertion into a given store, either by upgrade or by creation. This makes sure all references point to this store and all relative paths point to this store's files directory.
[ "Prepare", "each", "attribute", "in", "my", "schema", "for", "insertion", "into", "a", "given", "store", "either", "by", "upgrade", "or", "by", "creation", ".", "This", "makes", "sure", "all", "references", "point", "to", "this", "store", "and", "all", "re...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L517-L525
train
twisted/axiom
axiom/item.py
Item.existingInStore
def existingInStore(cls, store, storeID, attrs): """Create and return a new instance from a row from the store.""" self = cls.__new__(cls) self.__justCreated = False self.__subinit__(__store=store, storeID=storeID, __everInserted=True) ...
python
def existingInStore(cls, store, storeID, attrs): """Create and return a new instance from a row from the store.""" self = cls.__new__(cls) self.__justCreated = False self.__subinit__(__store=store, storeID=storeID, __everInserted=True) ...
[ "def", "existingInStore", "(", "cls", ",", "store", ",", "storeID", ",", "attrs", ")", ":", "self", "=", "cls", ".", "__new__", "(", "cls", ")", "self", ".", "__justCreated", "=", "False", "self", ".", "__subinit__", "(", "__store", "=", "store", ",", ...
Create and return a new instance from a row from the store.
[ "Create", "and", "return", "a", "new", "instance", "from", "a", "row", "from", "the", "store", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L647-L661
train
twisted/axiom
axiom/item.py
Item.getSchema
def getSchema(cls): """ return all persistent class attributes """ schema = [] for name, atr in cls.__attributes__: atr = atr.__get__(None, cls) if isinstance(atr, SQLAttribute): schema.append((name, atr)) cls.getSchema = staticmeth...
python
def getSchema(cls): """ return all persistent class attributes """ schema = [] for name, atr in cls.__attributes__: atr = atr.__get__(None, cls) if isinstance(atr, SQLAttribute): schema.append((name, atr)) cls.getSchema = staticmeth...
[ "def", "getSchema", "(", "cls", ")", ":", "schema", "=", "[", "]", "for", "name", ",", "atr", "in", "cls", ".", "__attributes__", ":", "atr", "=", "atr", ".", "__get__", "(", "None", ",", "cls", ")", "if", "isinstance", "(", "atr", ",", "SQLAttribu...
return all persistent class attributes
[ "return", "all", "persistent", "class", "attributes" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L668-L678
train
twisted/axiom
axiom/item.py
Item.persistentValues
def persistentValues(self): """ Return a dictionary of all attributes which will be/have been/are being stored in the database. """ return dict((k, getattr(self, k)) for (k, attr) in self.getSchema())
python
def persistentValues(self): """ Return a dictionary of all attributes which will be/have been/are being stored in the database. """ return dict((k, getattr(self, k)) for (k, attr) in self.getSchema())
[ "def", "persistentValues", "(", "self", ")", ":", "return", "dict", "(", "(", "k", ",", "getattr", "(", "self", ",", "k", ")", ")", "for", "(", "k", ",", "attr", ")", "in", "self", ".", "getSchema", "(", ")", ")" ]
Return a dictionary of all attributes which will be/have been/are being stored in the database.
[ "Return", "a", "dictionary", "of", "all", "attributes", "which", "will", "be", "/", "have", "been", "/", "are", "being", "stored", "in", "the", "database", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L682-L687
train