repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
smarie/python-valid8
valid8/validation_lib/comparables.py
gt
def gt(min_value, # type: Any strict=False # type: bool ): """ 'Greater than' validation_function generator. Returns a validation_function to check that x >= min_value (strict=False, default) or x > min_value (strict=True) :param min_value: minimum value for x :param strict: Boole...
python
def gt(min_value, # type: Any strict=False # type: bool ): """ 'Greater than' validation_function generator. Returns a validation_function to check that x >= min_value (strict=False, default) or x > min_value (strict=True) :param min_value: minimum value for x :param strict: Boole...
[ "def", "gt", "(", "min_value", ",", "# type: Any", "strict", "=", "False", "# type: bool", ")", ":", "if", "strict", ":", "def", "gt_", "(", "x", ")", ":", "if", "x", ">", "min_value", ":", "return", "True", "else", ":", "# raise Failure('x > ' + str(min_v...
'Greater than' validation_function generator. Returns a validation_function to check that x >= min_value (strict=False, default) or x > min_value (strict=True) :param min_value: minimum value for x :param strict: Boolean flag to switch between x >= min_value (strict=False) and x > min_value (strict=True) ...
[ "Greater", "than", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", ">", "=", "min_value", "(", "strict", "=", "False", "default", ")", "or", "x", ">", "min_value", "(", "strict", "=", "True", ")" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L24-L53
smarie/python-valid8
valid8/validation_lib/comparables.py
lt
def lt(max_value, # type: Any strict=False # type: bool ): """ 'Lesser than' validation_function generator. Returns a validation_function to check that x <= max_value (strict=False, default) or x < max_value (strict=True) :param max_value: maximum value for x :param strict: Boolea...
python
def lt(max_value, # type: Any strict=False # type: bool ): """ 'Lesser than' validation_function generator. Returns a validation_function to check that x <= max_value (strict=False, default) or x < max_value (strict=True) :param max_value: maximum value for x :param strict: Boolea...
[ "def", "lt", "(", "max_value", ",", "# type: Any", "strict", "=", "False", "# type: bool", ")", ":", "if", "strict", ":", "def", "lt_", "(", "x", ")", ":", "if", "x", "<", "max_value", ":", "return", "True", "else", ":", "# raise Failure('x < ' + str(max_v...
'Lesser than' validation_function generator. Returns a validation_function to check that x <= max_value (strict=False, default) or x < max_value (strict=True) :param max_value: maximum value for x :param strict: Boolean flag to switch between x <= max_value (strict=False) and x < max_value (strict=True) ...
[ "Lesser", "than", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "<", "=", "max_value", "(", "strict", "=", "False", "default", ")", "or", "x", "<", "max_value", "(", "strict", "=", "True", ")" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L70-L99
smarie/python-valid8
valid8/validation_lib/comparables.py
between
def between(min_val, # type: Any max_val, # type: Any open_left=False, # type: bool open_right=False # type: bool ): """ 'Is between' validation_function generator. Returns a validation_function to check that min_val <= x <= max_val (defaul...
python
def between(min_val, # type: Any max_val, # type: Any open_left=False, # type: bool open_right=False # type: bool ): """ 'Is between' validation_function generator. Returns a validation_function to check that min_val <= x <= max_val (defaul...
[ "def", "between", "(", "min_val", ",", "# type: Any", "max_val", ",", "# type: Any", "open_left", "=", "False", ",", "# type: bool", "open_right", "=", "False", "# type: bool", ")", ":", "if", "open_left", "and", "open_right", ":", "def", "between_", "(", "x",...
'Is between' validation_function generator. Returns a validation_function to check that min_val <= x <= max_val (default). open_right and open_left flags allow to transform each side into strict mode. For example setting open_left=True will enforce min_val < x <= max_val :param min_val: minimum value for x...
[ "Is", "between", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "min_val", "<", "=", "x", "<", "=", "max_val", "(", "default", ")", ".", "open_right", "and", "open_left", "flags", "allow", "to", "transfor...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L118-L168
BrighterCommand/Brightside
brightside/dispatch.py
_sub_process_main
def _sub_process_main(started_event: Event, channel_name: str, connection: Connection, consumer_configuration: BrightsideConsumerConfiguration, consumer_factory: Callable[[Connection, BrightsideConsumerConfiguration, logging.Logger]...
python
def _sub_process_main(started_event: Event, channel_name: str, connection: Connection, consumer_configuration: BrightsideConsumerConfiguration, consumer_factory: Callable[[Connection, BrightsideConsumerConfiguration, logging.Logger]...
[ "def", "_sub_process_main", "(", "started_event", ":", "Event", ",", "channel_name", ":", "str", ",", "connection", ":", "Connection", ",", "consumer_configuration", ":", "BrightsideConsumerConfiguration", ",", "consumer_factory", ":", "Callable", "[", "[", "Connectio...
This is the main method for the sub=process, everything we need to create the message pump and channel it needs to be passed in as parameters that can be pickled as when we run they will be serialized into this process. The data should be value types, not reference types as we will receive a copy of the origina...
[ "This", "is", "the", "main", "method", "for", "the", "sub", "=", "process", "everything", "we", "need", "to", "create", "the", "message", "pump", "and", "channel", "it", "needs", "to", "be", "passed", "in", "as", "parameters", "that", "can", "be", "pickl...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/dispatch.py#L106-L141
redhat-cip/dci-control-server
dci/alembic/env.py
run_migrations_offline
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
python
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
[ "def", "run_migrations_offline", "(", ")", ":", "app_conf", "=", "dci_config", ".", "generate_conf", "(", ")", "url", "=", "app_conf", "[", "'SQLALCHEMY_DATABASE_URI'", "]", "context", ".", "configure", "(", "url", "=", "url", ",", "target_metadata", "=", "tar...
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
[ "Run", "migrations", "in", "offline", "mode", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/alembic/env.py#L34-L53
redhat-cip/dci-control-server
dci/alembic/env.py
run_migrations_online
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ app_conf = dci_config.generate_conf() connectable = dci_config.get_engine(app_conf) with connectable.connect() as connection: ...
python
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ app_conf = dci_config.generate_conf() connectable = dci_config.get_engine(app_conf) with connectable.connect() as connection: ...
[ "def", "run_migrations_online", "(", ")", ":", "app_conf", "=", "dci_config", ".", "generate_conf", "(", ")", "connectable", "=", "dci_config", ".", "get_engine", "(", "app_conf", ")", "with", "connectable", ".", "connect", "(", ")", "as", "connection", ":", ...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "online", "mode", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/alembic/env.py#L56-L72
redhat-cip/dci-control-server
dci/decorators.py
reject
def reject(): """Sends a 401 reject response that enables basic auth.""" auth_message = ('Could not verify your access level for that URL.' 'Please login with proper credentials.') auth_message = json.dumps({'_status': 'Unauthorized', 'message': auth_messa...
python
def reject(): """Sends a 401 reject response that enables basic auth.""" auth_message = ('Could not verify your access level for that URL.' 'Please login with proper credentials.') auth_message = json.dumps({'_status': 'Unauthorized', 'message': auth_messa...
[ "def", "reject", "(", ")", ":", "auth_message", "=", "(", "'Could not verify your access level for that URL.'", "'Please login with proper credentials.'", ")", "auth_message", "=", "json", ".", "dumps", "(", "{", "'_status'", ":", "'Unauthorized'", ",", "'message'", ":"...
Sends a 401 reject response that enables basic auth.
[ "Sends", "a", "401", "reject", "response", "that", "enables", "basic", "auth", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/decorators.py#L26-L36
KennethWilke/PingdomLib
pingdomlib/contact.py
PingdomContact.modify
def modify(self, **kwargs): """Modify a contact. Returns status message Optional Parameters: * name -- Contact name Type: String * email -- Contact email address Type: String * cellphone -- Cellphone number, without...
python
def modify(self, **kwargs): """Modify a contact. Returns status message Optional Parameters: * name -- Contact name Type: String * email -- Contact email address Type: String * cellphone -- Cellphone number, without...
[ "def", "modify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'email'", ",", "'cellphone'", ",", "'countrycode'", ",", "'countryiso'", ",", "'defa...
Modify a contact. Returns status message Optional Parameters: * name -- Contact name Type: String * email -- Contact email address Type: String * cellphone -- Cellphone number, without the country code part. In ...
[ "Modify", "a", "contact", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/contact.py#L44-L93
BrighterCommand/Brightside
arame/gateway.py
ArameConsumer._establish_connection
def _establish_connection(self, conn: BrokerConnection) -> None: """ We don't use a pool here. We only have one consumer connection per process, so we get no value from a pool, and we want to use a heartbeat to keep the consumer collection alive, which does not work with a pool :...
python
def _establish_connection(self, conn: BrokerConnection) -> None: """ We don't use a pool here. We only have one consumer connection per process, so we get no value from a pool, and we want to use a heartbeat to keep the consumer collection alive, which does not work with a pool :...
[ "def", "_establish_connection", "(", "self", ",", "conn", ":", "BrokerConnection", ")", "->", "None", ":", "try", ":", "self", ".", "_logger", ".", "debug", "(", "\"Establishing connection.\"", ")", "self", ".", "_conn", "=", "conn", ".", "ensure_connection", ...
We don't use a pool here. We only have one consumer connection per process, so we get no value from a pool, and we want to use a heartbeat to keep the consumer collection alive, which does not work with a pool :return: the connection to the transport
[ "We", "don", "t", "use", "a", "pool", "here", ".", "We", "only", "have", "one", "consumer", "connection", "per", "process", "so", "we", "get", "no", "value", "from", "a", "pool", "and", "we", "want", "to", "use", "a", "heartbeat", "to", "keep", "the"...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/arame/gateway.py#L159-L176
BrighterCommand/Brightside
arame/gateway.py
ArameConsumer.run_heartbeat_continuously
def run_heartbeat_continuously(self) -> threading.Event: """ For a long runing handler, there is a danger that we do not send a heartbeat message or activity on the connection whilst we are running the handler. With a default heartbeat of 30s, for example, there is a risk that a handler ...
python
def run_heartbeat_continuously(self) -> threading.Event: """ For a long runing handler, there is a danger that we do not send a heartbeat message or activity on the connection whilst we are running the handler. With a default heartbeat of 30s, for example, there is a risk that a handler ...
[ "def", "run_heartbeat_continuously", "(", "self", ")", "->", "threading", ".", "Event", ":", "cancellation_event", "=", "threading", ".", "Event", "(", ")", "# Effectively a no-op if we are not actually a long-running thread", "if", "not", "self", ".", "_is_long_running_h...
For a long runing handler, there is a danger that we do not send a heartbeat message or activity on the connection whilst we are running the handler. With a default heartbeat of 30s, for example, there is a risk that a handler which takes more than 15s will fail to send the heartbeat in time and then th...
[ "For", "a", "long", "runing", "handler", "there", "is", "a", "danger", "that", "we", "do", "not", "send", "a", "heartbeat", "message", "or", "activity", "on", "the", "connection", "whilst", "we", "are", "running", "the", "handler", ".", "With", "a", "def...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/arame/gateway.py#L252-L281
redhat-cip/dci-control-server
dci/api/v1/export_control.py
_check
def _check(user, topic): """If the topic has it's export_control set to True then all the teams under the product team can access to the topic's resources. :param user: :param topic: :return: True if check is ok, False otherwise """ # if export_control then check the team is associated to t...
python
def _check(user, topic): """If the topic has it's export_control set to True then all the teams under the product team can access to the topic's resources. :param user: :param topic: :return: True if check is ok, False otherwise """ # if export_control then check the team is associated to t...
[ "def", "_check", "(", "user", ",", "topic", ")", ":", "# if export_control then check the team is associated to the product, ie.:", "# - the current user belongs to the product's team", "# OR", "# - the product's team belongs to the user's parents teams", "if", "topic", "[", "'ex...
If the topic has it's export_control set to True then all the teams under the product team can access to the topic's resources. :param user: :param topic: :return: True if check is ok, False otherwise
[ "If", "the", "topic", "has", "it", "s", "export_control", "set", "to", "True", "then", "all", "the", "teams", "under", "the", "product", "team", "can", "access", "to", "the", "topic", "s", "resources", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/export_control.py#L21-L38
redhat-cip/dci-control-server
dci/stores/files_utils.py
get_stream_or_content_from_request
def get_stream_or_content_from_request(request): """Ensure the proper content is uploaded. Stream might be already consumed by authentication process. Hence flask.request.stream might not be readable and return improper value. This methods checks if the stream has already been consumed and if so r...
python
def get_stream_or_content_from_request(request): """Ensure the proper content is uploaded. Stream might be already consumed by authentication process. Hence flask.request.stream might not be readable and return improper value. This methods checks if the stream has already been consumed and if so r...
[ "def", "get_stream_or_content_from_request", "(", "request", ")", ":", "if", "request", ".", "stream", ".", "tell", "(", ")", ":", "logger", ".", "info", "(", "'Request stream already consumed. '", "'Storing file content using in-memory data.'", ")", "return", "request"...
Ensure the proper content is uploaded. Stream might be already consumed by authentication process. Hence flask.request.stream might not be readable and return improper value. This methods checks if the stream has already been consumed and if so retrieve the data from flask.request.data where it has be...
[ "Ensure", "the", "proper", "content", "is", "uploaded", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/stores/files_utils.py#L24-L41
jmurty/xml4h
xml4h/impls/lxml_etree.py
LXMLAdapter.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", ")", ":", "if", "isinstance", "(", "node", ",", "etree", ".", "_ElementTree", ")", ":", "# Document node lxml.etree._ElementTree has no nsmap, lookup root", "root", "=", "se...
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", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/lxml_etree.py#L133-L159
jmurty/xml4h
xml4h/impls/lxml_etree.py
LXMLAdapter._is_ns_in_ancestor
def _is_ns_in_ancestor(self, node, name, value): """ Return True if the given namespace name/value is defined in an ancestor of the given node, meaning that the given node need not have its own attributes to apply that namespacing. """ curr_node = self.get_node_parent(nod...
python
def _is_ns_in_ancestor(self, node, name, value): """ Return True if the given namespace name/value is defined in an ancestor of the given node, meaning that the given node need not have its own attributes to apply that namespacing. """ curr_node = self.get_node_parent(nod...
[ "def", "_is_ns_in_ancestor", "(", "self", ",", "node", ",", "name", ",", "value", ")", ":", "curr_node", "=", "self", ".", "get_node_parent", "(", "node", ")", "while", "curr_node", ".", "__class__", "==", "etree", ".", "_Element", ":", "if", "(", "hasat...
Return True if the given namespace name/value is defined in an ancestor of the given node, meaning that the given node need not have its own attributes to apply that namespacing.
[ "Return", "True", "if", "the", "given", "namespace", "name", "/", "value", "is", "defined", "in", "an", "ancestor", "of", "the", "given", "node", "meaning", "that", "the", "given", "node", "need", "not", "have", "its", "own", "attributes", "to", "apply", ...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/lxml_etree.py#L440-L455
coleifer/django-generic-aggregation
generic_aggregation/utils.py
generic_annotate
def generic_annotate(qs_model, generic_qs_model, aggregator, gfk_field=None, alias='score'): """ Find blog entries with the most comments: qs = generic_annotate(Entry.objects.public(), Comment.objects.public(), Count('comments__id')) for entry in qs: print entry.title, entry.sco...
python
def generic_annotate(qs_model, generic_qs_model, aggregator, gfk_field=None, alias='score'): """ Find blog entries with the most comments: qs = generic_annotate(Entry.objects.public(), Comment.objects.public(), Count('comments__id')) for entry in qs: print entry.title, entry.sco...
[ "def", "generic_annotate", "(", "qs_model", ",", "generic_qs_model", ",", "aggregator", ",", "gfk_field", "=", "None", ",", "alias", "=", "'score'", ")", ":", "return", "fallback_generic_annotate", "(", "qs_model", ",", "generic_qs_model", ",", "aggregator", ",", ...
Find blog entries with the most comments: qs = generic_annotate(Entry.objects.public(), Comment.objects.public(), Count('comments__id')) for entry in qs: print entry.title, entry.score Find the highest rated foods: generic_annotate(Food, Rating, Avg('ratings__ratin...
[ "Find", "blog", "entries", "with", "the", "most", "comments", ":", "qs", "=", "generic_annotate", "(", "Entry", ".", "objects", ".", "public", "()", "Comment", ".", "objects", ".", "public", "()", "Count", "(", "comments__id", "))", "for", "entry", "in", ...
train
https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L30-L62
coleifer/django-generic-aggregation
generic_aggregation/utils.py
generic_aggregate
def generic_aggregate(qs_model, generic_qs_model, aggregator, gfk_field=None): """ Find total number of comments on blog entries: generic_aggregate(Entry.objects.public(), Comment.objects.public(), Count('comments__id')) Find the average rating for foods starting with 'a': a_f...
python
def generic_aggregate(qs_model, generic_qs_model, aggregator, gfk_field=None): """ Find total number of comments on blog entries: generic_aggregate(Entry.objects.public(), Comment.objects.public(), Count('comments__id')) Find the average rating for foods starting with 'a': a_f...
[ "def", "generic_aggregate", "(", "qs_model", ",", "generic_qs_model", ",", "aggregator", ",", "gfk_field", "=", "None", ")", ":", "return", "fallback_generic_aggregate", "(", "qs_model", ",", "generic_qs_model", ",", "aggregator", ",", "gfk_field", ")" ]
Find total number of comments on blog entries: generic_aggregate(Entry.objects.public(), Comment.objects.public(), Count('comments__id')) Find the average rating for foods starting with 'a': a_foods = Food.objects.filter(name__startswith='a') generic_aggregate(a_foods, Rating,...
[ "Find", "total", "number", "of", "comments", "on", "blog", "entries", ":", "generic_aggregate", "(", "Entry", ".", "objects", ".", "public", "()", "Comment", ".", "objects", ".", "public", "()", "Count", "(", "comments__id", "))", "Find", "the", "average", ...
train
https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L65-L93
coleifer/django-generic-aggregation
generic_aggregation/utils.py
generic_filter
def generic_filter(generic_qs_model, filter_qs_model, gfk_field=None): """ Only show me ratings made on foods that start with "a": a_foods = Food.objects.filter(name__startswith='a') generic_filter(Rating.objects.all(), a_foods) Only show me comments from entries that are marked as...
python
def generic_filter(generic_qs_model, filter_qs_model, gfk_field=None): """ Only show me ratings made on foods that start with "a": a_foods = Food.objects.filter(name__startswith='a') generic_filter(Rating.objects.all(), a_foods) Only show me comments from entries that are marked as...
[ "def", "generic_filter", "(", "generic_qs_model", ",", "filter_qs_model", ",", "gfk_field", "=", "None", ")", ":", "generic_qs", "=", "normalize_qs_model", "(", "generic_qs_model", ")", "filter_qs", "=", "normalize_qs_model", "(", "filter_qs_model", ")", "if", "not"...
Only show me ratings made on foods that start with "a": a_foods = Food.objects.filter(name__startswith='a') generic_filter(Rating.objects.all(), a_foods) Only show me comments from entries that are marked as public: generic_filter(Comment.objects.public(), Entry.objects.public...
[ "Only", "show", "me", "ratings", "made", "on", "foods", "that", "start", "with", "a", ":", "a_foods", "=", "Food", ".", "objects", ".", "filter", "(", "name__startswith", "=", "a", ")", "generic_filter", "(", "Rating", ".", "objects", ".", "all", "()", ...
train
https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L96-L125
redhat-cip/dci-control-server
dci/common/utils.py
gen_etag
def gen_etag(): """Generate random etag based on MD5.""" my_salt = gen_uuid() if six.PY2: my_salt = my_salt.decode('utf-8') elif six.PY3: my_salt = my_salt.encode('utf-8') md5 = hashlib.md5() md5.update(my_salt) return md5.hexdigest()
python
def gen_etag(): """Generate random etag based on MD5.""" my_salt = gen_uuid() if six.PY2: my_salt = my_salt.decode('utf-8') elif six.PY3: my_salt = my_salt.encode('utf-8') md5 = hashlib.md5() md5.update(my_salt) return md5.hexdigest()
[ "def", "gen_etag", "(", ")", ":", "my_salt", "=", "gen_uuid", "(", ")", "if", "six", ".", "PY2", ":", "my_salt", "=", "my_salt", ".", "decode", "(", "'utf-8'", ")", "elif", "six", ".", "PY3", ":", "my_salt", "=", "my_salt", ".", "encode", "(", "'ut...
Generate random etag based on MD5.
[ "Generate", "random", "etag", "based", "on", "MD5", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/utils.py#L64-L74
KennethWilke/PingdomLib
pingdomlib/reports.py
PingdomSharedReport.delete
def delete(self): """Delete this email report""" response = self.pingdom.request('DELETE', 'reports.shared/%s' % self.id) return response.json()['message']
python
def delete(self): """Delete this email report""" response = self.pingdom.request('DELETE', 'reports.shared/%s' % self.id) return response.json()['message']
[ "def", "delete", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'DELETE'", ",", "'reports.shared/%s'", "%", "self", ".", "id", ")", "return", "response", ".", "json", "(", ")", "[", "'message'", "]" ]
Delete this email report
[ "Delete", "this", "email", "report" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/reports.py#L101-L106
smarie/python-valid8
valid8/validation_lib/numbers.py
is_multiple_of
def is_multiple_of(ref): """ Validates that x is a multiple of the reference (`x % ref == 0`) """ def is_multiple_of_ref(x): if x % ref == 0: return True else: raise IsNotMultipleOf(wrong_value=x, ref=ref) # raise Failure('x % {ref} == 0 does not hold for x={v...
python
def is_multiple_of(ref): """ Validates that x is a multiple of the reference (`x % ref == 0`) """ def is_multiple_of_ref(x): if x % ref == 0: return True else: raise IsNotMultipleOf(wrong_value=x, ref=ref) # raise Failure('x % {ref} == 0 does not hold for x={v...
[ "def", "is_multiple_of", "(", "ref", ")", ":", "def", "is_multiple_of_ref", "(", "x", ")", ":", "if", "x", "%", "ref", "==", "0", ":", "return", "True", "else", ":", "raise", "IsNotMultipleOf", "(", "wrong_value", "=", "x", ",", "ref", "=", "ref", ")...
Validates that x is a multiple of the reference (`x % ref == 0`)
[ "Validates", "that", "x", "is", "a", "multiple", "of", "the", "reference", "(", "x", "%", "ref", "==", "0", ")" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/numbers.py#L42-L52
redhat-cip/dci-control-server
dci/api/v1/components.py
get_all_components
def get_all_components(user, topic_id): """Get all components of a topic.""" args = schemas.args(flask.request.args.to_dict()) query = v1_utils.QueryBuilder(_TABLE, args, _C_COLUMNS) query.add_extra_condition(sql.and_( _TABLE.c.topic_id == topic_id, _TABLE.c.state != 'archived')) ...
python
def get_all_components(user, topic_id): """Get all components of a topic.""" args = schemas.args(flask.request.args.to_dict()) query = v1_utils.QueryBuilder(_TABLE, args, _C_COLUMNS) query.add_extra_condition(sql.and_( _TABLE.c.topic_id == topic_id, _TABLE.c.state != 'archived')) ...
[ "def", "get_all_components", "(", "user", ",", "topic_id", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "query", "=", "v1_utils", ".", "QueryBuilder", "(", "_TABLE", ",", "args...
Get all components of a topic.
[ "Get", "all", "components", "of", "a", "topic", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L139-L160
redhat-cip/dci-control-server
dci/api/v1/components.py
get_component_types_from_topic
def get_component_types_from_topic(topic_id, db_conn=None): """Returns the component types of a topic.""" db_conn = db_conn or flask.g.db_conn query = sql.select([models.TOPICS]).\ where(models.TOPICS.c.id == topic_id) topic = db_conn.execute(query).fetchone() topic = dict(topic) return ...
python
def get_component_types_from_topic(topic_id, db_conn=None): """Returns the component types of a topic.""" db_conn = db_conn or flask.g.db_conn query = sql.select([models.TOPICS]).\ where(models.TOPICS.c.id == topic_id) topic = db_conn.execute(query).fetchone() topic = dict(topic) return ...
[ "def", "get_component_types_from_topic", "(", "topic_id", ",", "db_conn", "=", "None", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "query", "=", "sql", ".", "select", "(", "[", "models", ".", "TOPICS", "]", ")", ".", "...
Returns the component types of a topic.
[ "Returns", "the", "component", "types", "of", "a", "topic", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L340-L347
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L350-L368
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L371-L395
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L398-L428
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L464-L472
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L477-L490
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L495-L507
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" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L59-L63
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__" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L103-L114
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", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L413-L477
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", "...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L484-L512
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...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L515-L539
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", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L156-L201
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" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L308-L314
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" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L385-L404
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" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L406-L410
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_...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L352-L369
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...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L373-L424
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", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L442-L469
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", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L484-L504
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", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L525-L663
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"...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L666-L696
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", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L714-L769
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" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L772-L794
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", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L872-L942
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", ".", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L945-L963
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", ":" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L42-L48
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", ":" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L80-L86
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", "." ]
train
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_nonce_engine.py#L45-L53
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", ...
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/schemas.py#L108-L127
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L195-L267
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L272-L313
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L318-L367
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L372-L405
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" ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L437-L477
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L521-L551
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L587-L600
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L605-L619
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L624-L641
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",...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L108-L120
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", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L122-L133
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", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L200-L228
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L67-L76
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L79-L91
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", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L94-L118
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", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/cli.py#L73-L111
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", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L87-L143
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" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L175-L180
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"...
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L182-L382
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", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L392-L454
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", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L639-L650
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", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L740-L746
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", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L748-L755
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", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/npm.py#L54-L83
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", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/npm.py#L86-L118
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", "." ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L21-L40
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" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L43-L73
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", "." ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L76-L88
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" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L91-L95
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" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L98-L131
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" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L150-L173
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" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L176-L212
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", "." ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L215-L274
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", "." ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L277-L323
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", "." ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L326-L349
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",...
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L428-L460
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L462-L518
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", "}", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L1017-L1034
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L53-L64
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", ...
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L297-L312
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L323-L363
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L366-L375
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L378-L384
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L387-L394
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L397-L424
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L956-L967
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", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L1158-L1171
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", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/scratch.py#L55-L75
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", "}", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L56-L65