Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
cache_page
(timeout, *, cache=None, key_prefix=None)
Decorator for views that tries getting the page from the cache and populates the cache if the page isn't in the cache yet. The cache is keyed by the URL and some data from the headers. Additionally there is the key prefix that is used to distinguish different cache areas in a multi-site setup. You...
Decorator for views that tries getting the page from the cache and populates the cache if the page isn't in the cache yet.
def cache_page(timeout, *, cache=None, key_prefix=None): """ Decorator for views that tries getting the page from the cache and populates the cache if the page isn't in the cache yet. The cache is keyed by the URL and some data from the headers. Additionally there is the key prefix that is used to ...
[ "def", "cache_page", "(", "timeout", ",", "*", ",", "cache", "=", "None", ",", "key_prefix", "=", "None", ")", ":", "return", "decorator_from_middleware_with_args", "(", "CacheMiddleware", ")", "(", "cache_timeout", "=", "timeout", ",", "cache_alias", "=", "ca...
[ 7, 0 ]
[ 23, 5 ]
python
en
['en', 'error', 'th']
False
never_cache
(view_func)
Decorator that adds headers to a response so that it will never be cached.
Decorator that adds headers to a response so that it will never be cached.
def never_cache(view_func): """ Decorator that adds headers to a response so that it will never be cached. """ @wraps(view_func) def _wrapped_view_func(request, *args, **kwargs): response = view_func(request, *args, **kwargs) add_never_cache_headers(response) return response ...
[ "def", "never_cache", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "_wrapped_view_func", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "view_func", "(", "request", ",", "*", "args", ","...
[ 37, 0 ]
[ 46, 29 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.changes
(self, graph, trim_to_apps=None, convert_apps=None, migration_name=None)
Main entry point to produce a list of appliable changes. Takes a graph to base names on and an optional set of apps to try and restrict to (restriction is not guaranteed)
Main entry point to produce a list of appliable changes. Takes a graph to base names on and an optional set of apps to try and restrict to (restriction is not guaranteed)
def changes(self, graph, trim_to_apps=None, convert_apps=None, migration_name=None): """ Main entry point to produce a list of appliable changes. Takes a graph to base names on and an optional set of apps to try and restrict to (restriction is not guaranteed) """ changes ...
[ "def", "changes", "(", "self", ",", "graph", ",", "trim_to_apps", "=", "None", ",", "convert_apps", "=", "None", ",", "migration_name", "=", "None", ")", ":", "changes", "=", "self", ".", "_detect_changes", "(", "convert_apps", ",", "graph", ")", "changes"...
[ 35, 4 ]
[ 45, 22 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.deep_deconstruct
(self, obj)
Recursive deconstruction for a field and its arguments. Used for full comparison for rename/alter; sometimes a single-level deconstruction will not compare correctly.
Recursive deconstruction for a field and its arguments. Used for full comparison for rename/alter; sometimes a single-level deconstruction will not compare correctly.
def deep_deconstruct(self, obj): """ Recursive deconstruction for a field and its arguments. Used for full comparison for rename/alter; sometimes a single-level deconstruction will not compare correctly. """ if not hasattr(obj, 'deconstruct') or isinstance(obj, type): ...
[ "def", "deep_deconstruct", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'deconstruct'", ")", "or", "isinstance", "(", "obj", ",", "type", ")", ":", "return", "obj", "deconstructed", "=", "obj", ".", "deconstruct", "(", "...
[ 47, 4 ]
[ 67, 9 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.only_relation_agnostic_fields
(self, fields)
Return a definition of the fields that ignores field names and what related fields actually relate to. Used for detecting renames (as, of course, the related fields change during renames)
Return a definition of the fields that ignores field names and what related fields actually relate to. Used for detecting renames (as, of course, the related fields change during renames)
def only_relation_agnostic_fields(self, fields): """ Return a definition of the fields that ignores field names and what related fields actually relate to. Used for detecting renames (as, of course, the related fields change during renames) """ fields_def = [] ...
[ "def", "only_relation_agnostic_fields", "(", "self", ",", "fields", ")", ":", "fields_def", "=", "[", "]", "for", "name", ",", "field", "in", "fields", ":", "deconstruction", "=", "self", ".", "deep_deconstruct", "(", "field", ")", "if", "field", ".", "rel...
[ 69, 4 ]
[ 82, 25 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector._detect_changes
(self, convert_apps=None, graph=None)
Returns a dict of migration plans which will achieve the change from from_state to to_state. The dict has app labels as keys and a list of migrations as values. The resulting migrations aren't specially named, but the names do matter for dependencies inside the set. co...
Returns a dict of migration plans which will achieve the change from from_state to to_state. The dict has app labels as keys and a list of migrations as values.
def _detect_changes(self, convert_apps=None, graph=None): """ Returns a dict of migration plans which will achieve the change from from_state to to_state. The dict has app labels as keys and a list of migrations as values. The resulting migrations aren't specially named, but the...
[ "def", "_detect_changes", "(", "self", ",", "convert_apps", "=", "None", ",", "graph", "=", "None", ")", ":", "# The first phase is generating all the operations for each app", "# and gathering them into a big per-app list.", "# We'll then go through that list later and order it and ...
[ 84, 4 ]
[ 316, 30 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.check_dependency
(self, operation, dependency)
Checks if an operation dependency matches an operation.
Checks if an operation dependency matches an operation.
def check_dependency(self, operation, dependency): """ Checks if an operation dependency matches an operation. """ # Created model if dependency[2] is None and dependency[3] is True: return ( isinstance(operation, operations.CreateModel) and ...
[ "def", "check_dependency", "(", "self", ",", "operation", ",", "dependency", ")", ":", "# Created model", "if", "dependency", "[", "2", "]", "is", "None", "and", "dependency", "[", "3", "]", "is", "True", ":", "return", "(", "isinstance", "(", "operation",...
[ 318, 4 ]
[ 371, 75 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.swappable_first_key
(self, item)
Sorting key function that places potential swappable models first in lists of created models (only real way to solve #22783)
Sorting key function that places potential swappable models first in lists of created models (only real way to solve #22783)
def swappable_first_key(self, item): """ Sorting key function that places potential swappable models first in lists of created models (only real way to solve #22783) """ try: model = self.new_apps.get_model(item[0], item[1]) base_names = [base.__name__ for...
[ "def", "swappable_first_key", "(", "self", ",", "item", ")", ":", "try", ":", "model", "=", "self", ".", "new_apps", ".", "get_model", "(", "item", "[", "0", "]", ",", "item", "[", "1", "]", ")", "base_names", "=", "[", "base", ".", "__name__", "fo...
[ 381, 4 ]
[ 399, 19 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_renamed_models
(self)
Finds any renamed models, and generates the operations for them, and removes the old entry from the model lists. Must be run before other model-level generation.
Finds any renamed models, and generates the operations for them, and removes the old entry from the model lists. Must be run before other model-level generation.
def generate_renamed_models(self): """ Finds any renamed models, and generates the operations for them, and removes the old entry from the model lists. Must be run before other model-level generation. """ self.renamed_models = {} self.renamed_models_rel = {} ...
[ "def", "generate_renamed_models", "(", "self", ")", ":", "self", ".", "renamed_models", "=", "{", "}", "self", ".", "renamed_models_rel", "=", "{", "}", "added_models", "=", "set", "(", "self", ".", "new_model_keys", ")", "-", "set", "(", "self", ".", "o...
[ 401, 4 ]
[ 432, 33 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_created_models
(self)
Find all new models (both managed and unmanaged) and make create operations for them as well as separate operations to create any foreign key or M2M relationships (we'll optimize these back in later if we can). We also defer any model options that refer to collections of fields...
Find all new models (both managed and unmanaged) and make create operations for them as well as separate operations to create any foreign key or M2M relationships (we'll optimize these back in later if we can).
def generate_created_models(self): """ Find all new models (both managed and unmanaged) and make create operations for them as well as separate operations to create any foreign key or M2M relationships (we'll optimize these back in later if we can). We also defer any mod...
[ "def", "generate_created_models", "(", "self", ")", ":", "added_models", "=", "set", "(", "self", ".", "new_model_keys", ")", "-", "set", "(", "self", ".", "old_model_keys", ")", "added_unmanaged_models", "=", "set", "(", "self", ".", "new_unmanaged_keys", ")"...
[ 434, 4 ]
[ 575, 17 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_created_proxies
(self)
Makes CreateModel statements for proxy models. We use the same statements as that way there's less code duplication, but of course for proxy models we can skip all that pointless field stuff and just chuck out an operation.
Makes CreateModel statements for proxy models. We use the same statements as that way there's less code duplication, but of course for proxy models we can skip all that pointless field stuff and just chuck out an operation.
def generate_created_proxies(self): """ Makes CreateModel statements for proxy models. We use the same statements as that way there's less code duplication, but of course for proxy models we can skip all that pointless field stuff and just chuck out an operation. """ ...
[ "def", "generate_created_proxies", "(", "self", ")", ":", "added", "=", "set", "(", "self", ".", "new_proxy_keys", ")", "-", "set", "(", "self", ".", "old_proxy_keys", ")", "for", "app_label", ",", "model_name", "in", "sorted", "(", "added", ")", ":", "m...
[ 577, 4 ]
[ 608, 13 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_deleted_models
(self)
Find all deleted models (managed and unmanaged) and make delete operations for them as well as separate operations to delete any foreign key or M2M relationships (we'll optimize these back in later if we can). We also bring forward removal of any model options that refer to ...
Find all deleted models (managed and unmanaged) and make delete operations for them as well as separate operations to delete any foreign key or M2M relationships (we'll optimize these back in later if we can).
def generate_deleted_models(self): """ Find all deleted models (managed and unmanaged) and make delete operations for them as well as separate operations to delete any foreign key or M2M relationships (we'll optimize these back in later if we can). We also bring forward ...
[ "def", "generate_deleted_models", "(", "self", ")", ":", "deleted_models", "=", "set", "(", "self", ".", "old_model_keys", ")", "-", "set", "(", "self", ".", "new_model_keys", ")", "deleted_unmanaged_models", "=", "set", "(", "self", ".", "old_unmanaged_keys", ...
[ 610, 4 ]
[ 717, 13 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_deleted_proxies
(self)
Makes DeleteModel statements for proxy models.
Makes DeleteModel statements for proxy models.
def generate_deleted_proxies(self): """ Makes DeleteModel statements for proxy models. """ deleted = set(self.old_proxy_keys) - set(self.new_proxy_keys) for app_label, model_name in sorted(deleted): model_state = self.from_state.models[app_label, model_name] ...
[ "def", "generate_deleted_proxies", "(", "self", ")", ":", "deleted", "=", "set", "(", "self", ".", "old_proxy_keys", ")", "-", "set", "(", "self", ".", "new_proxy_keys", ")", "for", "app_label", ",", "model_name", "in", "sorted", "(", "deleted", ")", ":", ...
[ 719, 4 ]
[ 732, 13 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_renamed_fields
(self)
Works out renamed fields
Works out renamed fields
def generate_renamed_fields(self): """ Works out renamed fields """ self.renamed_fields = {} for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_field_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) ...
[ "def", "generate_renamed_fields", "(", "self", ")", ":", "self", ".", "renamed_fields", "=", "{", "}", "for", "app_label", ",", "model_name", ",", "field_name", "in", "sorted", "(", "self", ".", "new_field_keys", "-", "self", ".", "old_field_keys", ")", ":",...
[ 734, 4 ]
[ 765, 33 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_added_fields
(self)
Fields that have been added
Fields that have been added
def generate_added_fields(self): """ Fields that have been added """ for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_field_keys): field = self.new_apps.get_model(app_label, model_name)._meta.get_field_by_name(field_name)[0] # Fields ...
[ "def", "generate_added_fields", "(", "self", ")", ":", "for", "app_label", ",", "model_name", ",", "field_name", "in", "sorted", "(", "self", ".", "new_field_keys", "-", "self", ".", "old_field_keys", ")", ":", "field", "=", "self", ".", "new_apps", ".", "...
[ 767, 4 ]
[ 815, 17 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_removed_fields
(self)
Fields that have been removed.
Fields that have been removed.
def generate_removed_fields(self): """ Fields that have been removed. """ for app_label, model_name, field_name in sorted(self.old_field_keys - self.new_field_keys): self.add_operation( app_label, operations.RemoveField( mod...
[ "def", "generate_removed_fields", "(", "self", ")", ":", "for", "app_label", ",", "model_name", ",", "field_name", "in", "sorted", "(", "self", ".", "old_field_keys", "-", "self", ".", "new_field_keys", ")", ":", "self", ".", "add_operation", "(", "app_label",...
[ 817, 4 ]
[ 831, 13 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_altered_fields
(self)
Fields that have been altered.
Fields that have been altered.
def generate_altered_fields(self): """ Fields that have been altered. """ for app_label, model_name, field_name in sorted(self.old_field_keys.intersection(self.new_field_keys)): # Did the field change? old_model_name = self.renamed_models.get((app_label, model_nam...
[ "def", "generate_altered_fields", "(", "self", ")", ":", "for", "app_label", ",", "model_name", ",", "field_name", "in", "sorted", "(", "self", ".", "old_field_keys", ".", "intersection", "(", "self", ".", "new_field_keys", ")", ")", ":", "# Did the field change...
[ 833, 4 ]
[ 873, 17 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.generate_altered_options
(self)
Works out if any non-schema-affecting options have changed and makes an operation to represent them in state changes (in case Python code in migrations needs them)
Works out if any non-schema-affecting options have changed and makes an operation to represent them in state changes (in case Python code in migrations needs them)
def generate_altered_options(self): """ Works out if any non-schema-affecting options have changed and makes an operation to represent them in state changes (in case Python code in migrations needs them) """ models_to_check = self.kept_model_keys.union(self.kept_proxy_key...
[ "def", "generate_altered_options", "(", "self", ")", ":", "models_to_check", "=", "self", ".", "kept_model_keys", ".", "union", "(", "self", ".", "kept_proxy_keys", ")", ".", "union", "(", "self", ".", "kept_unmanaged_keys", ")", "for", "app_label", ",", "mode...
[ 912, 4 ]
[ 938, 17 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.arrange_for_graph
(self, changes, graph, migration_name=None)
Takes in a result from changes() and a MigrationGraph, and fixes the names and dependencies of the changes so they extend the graph from the leaf nodes for each app.
Takes in a result from changes() and a MigrationGraph, and fixes the names and dependencies of the changes so they extend the graph from the leaf nodes for each app.
def arrange_for_graph(self, changes, graph, migration_name=None): """ Takes in a result from changes() and a MigrationGraph, and fixes the names and dependencies of the changes so they extend the graph from the leaf nodes for each app. """ leaves = graph.leaf_nodes() ...
[ "def", "arrange_for_graph", "(", "self", ",", "changes", ",", "graph", ",", "migration_name", "=", "None", ")", ":", "leaves", "=", "graph", ".", "leaf_nodes", "(", ")", "name_map", "=", "{", "}", "for", "app_label", ",", "migrations", "in", "list", "(",...
[ 966, 4 ]
[ 1013, 22 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector._trim_to_apps
(self, changes, app_labels)
Takes changes from arrange_for_graph and set of app labels and returns a modified set of changes which trims out as many migrations that are not in app_labels as possible. Note that some other migrations may still be present, as they may be required dependencies.
Takes changes from arrange_for_graph and set of app labels and returns a modified set of changes which trims out as many migrations that are not in app_labels as possible. Note that some other migrations may still be present, as they may be required dependencies.
def _trim_to_apps(self, changes, app_labels): """ Takes changes from arrange_for_graph and set of app labels and returns a modified set of changes which trims out as many migrations that are not in app_labels as possible. Note that some other migrations may still be present, as t...
[ "def", "_trim_to_apps", "(", "self", ",", "changes", ",", "app_labels", ")", ":", "# Gather other app dependencies in a first pass", "app_dependencies", "=", "{", "}", "for", "app_label", ",", "migrations", "in", "changes", ".", "items", "(", ")", ":", "for", "m...
[ 1015, 4 ]
[ 1040, 22 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.suggest_name
(cls, ops)
Given a set of operations, suggests a name for the migration they might represent. Names are not guaranteed to be unique, but we put some effort in to the fallback name to avoid VCS conflicts if we can.
Given a set of operations, suggests a name for the migration they might represent. Names are not guaranteed to be unique, but we put some effort in to the fallback name to avoid VCS conflicts if we can.
def suggest_name(cls, ops): """ Given a set of operations, suggests a name for the migration they might represent. Names are not guaranteed to be unique, but we put some effort in to the fallback name to avoid VCS conflicts if we can. """ if len(ops) == 1: ...
[ "def", "suggest_name", "(", "cls", ",", "ops", ")", ":", "if", "len", "(", "ops", ")", "==", "1", ":", "if", "isinstance", "(", "ops", "[", "0", "]", ",", "operations", ".", "CreateModel", ")", ":", "return", "ops", "[", "0", "]", ".", "name", ...
[ 1043, 4 ]
[ 1062, 74 ]
python
en
['en', 'error', 'th']
False
MigrationAutodetector.parse_number
(cls, name)
Given a migration name, tries to extract a number from the beginning of it. If no number found, returns None.
Given a migration name, tries to extract a number from the beginning of it. If no number found, returns None.
def parse_number(cls, name): """ Given a migration name, tries to extract a number from the beginning of it. If no number found, returns None. """ if re.match(r"^\d+_", name): return int(name.split("_")[0]) return None
[ "def", "parse_number", "(", "cls", ",", "name", ")", ":", "if", "re", ".", "match", "(", "r\"^\\d+_\"", ",", "name", ")", ":", "return", "int", "(", "name", ".", "split", "(", "\"_\"", ")", "[", "0", "]", ")", "return", "None" ]
[ 1065, 4 ]
[ 1072, 19 ]
python
en
['en', 'error', 'th']
False
infix
(bp, func)
Create an infix operator, given a binding power and a function that evaluates the node.
Create an infix operator, given a binding power and a function that evaluates the node.
def infix(bp, func): """ Create an infix operator, given a binding power and a function that evaluates the node. """ class Operator(TokenBase): lbp = bp def led(self, left, parser): self.first = left self.second = parser.expression(bp) return self...
[ "def", "infix", "(", "bp", ",", "func", ")", ":", "class", "Operator", "(", "TokenBase", ")", ":", "lbp", "=", "bp", "def", "led", "(", "self", ",", "left", ",", "parser", ")", ":", "self", ".", "first", "=", "left", "self", ".", "second", "=", ...
[ 42, 0 ]
[ 64, 19 ]
python
en
['en', 'error', 'th']
False
prefix
(bp, func)
Create a prefix operator, given a binding power and a function that evaluates the node.
Create a prefix operator, given a binding power and a function that evaluates the node.
def prefix(bp, func): """ Create a prefix operator, given a binding power and a function that evaluates the node. """ class Operator(TokenBase): lbp = bp def nud(self, parser): self.first = parser.expression(bp) self.second = None return self ...
[ "def", "prefix", "(", "bp", ",", "func", ")", ":", "class", "Operator", "(", "TokenBase", ")", ":", "lbp", "=", "bp", "def", "nud", "(", "self", ",", "parser", ")", ":", "self", ".", "first", "=", "parser", ".", "expression", "(", "bp", ")", "sel...
[ 67, 0 ]
[ 86, 19 ]
python
en
['en', 'error', 'th']
False
TokenBase.display
(self)
Return what to display in error messages for this node
Return what to display in error messages for this node
def display(self): """ Return what to display in error messages for this node """ return self.id
[ "def", "display", "(", "self", ")", ":", "return", "self", ".", "id" ]
[ 31, 4 ]
[ 35, 22 ]
python
en
['en', 'error', 'th']
False
ExchangeSession.soap
(self, request, timeout=10)
Send an EWSRequest by SOAP. :type request: respa_exchange.base.EWSRequest :param timeout: request timeout (see `requests` docs) :type timeout: float|None|tuple[float, float] :rtype: lxml.etree.Element
Send an EWSRequest by SOAP.
def soap(self, request, timeout=10): """ Send an EWSRequest by SOAP. :type request: respa_exchange.base.EWSRequest :param timeout: request timeout (see `requests` docs) :type timeout: float|None|tuple[float, float] :rtype: lxml.etree.Element """ resp = s...
[ "def", "soap", "(", "self", ",", "request", ",", "timeout", "=", "10", ")", ":", "resp", "=", "self", ".", "post", "(", "self", ".", "url", ",", "timeout", "=", "timeout", ",", "*", "*", "self", ".", "_prepare_soap", "(", "request", ")", ")", "if...
[ 75, 4 ]
[ 94, 56 ]
python
en
['en', 'error', 'th']
False
ExchangeSession.soap_stream
(self, request, timeout=10)
Send an EWSRequest by SOAP and stream the response.
Send an EWSRequest by SOAP and stream the response.
def soap_stream(self, request, timeout=10): """ Send an EWSRequest by SOAP and stream the response. """ resp = self.post(self.url, timeout=timeout, stream=True, **self._prepare_soap(request)) for data in resp.iter_content(chunk_size=None): data = data.strip() ...
[ "def", "soap_stream", "(", "self", ",", "request", ",", "timeout", "=", "10", ")", ":", "resp", "=", "self", ".", "post", "(", "self", ".", "url", ",", "timeout", "=", "timeout", ",", "stream", "=", "True", ",", "*", "*", "self", ".", "_prepare_soa...
[ 96, 4 ]
[ 105, 51 ]
python
en
['en', 'error', 'th']
False
PostGISSchemaEditor._alter_column_type_sql
(self, table, old_field, new_field, new_type)
Special case when dimension changed.
Special case when dimension changed.
def _alter_column_type_sql(self, table, old_field, new_field, new_type): """ Special case when dimension changed. """ if not hasattr(old_field, 'dim') or not hasattr(new_field, 'dim'): return super()._alter_column_type_sql(table, old_field, new_field, new_type) if ol...
[ "def", "_alter_column_type_sql", "(", "self", ",", "table", ",", "old_field", ",", "new_field", ",", "new_type", ")", ":", "if", "not", "hasattr", "(", "old_field", ",", "'dim'", ")", "or", "not", "hasattr", "(", "new_field", ",", "'dim'", ")", ":", "ret...
[ 43, 4 ]
[ 65, 9 ]
python
en
['en', 'error', 'th']
False
uninstall_if_needed
(setting, value, enter, **kwargs)
Undo the effects of PostgresConfig.ready() when django.contrib.postgres is "uninstalled" by override_settings().
Undo the effects of PostgresConfig.ready() when django.contrib.postgres is "uninstalled" by override_settings().
def uninstall_if_needed(setting, value, enter, **kwargs): """ Undo the effects of PostgresConfig.ready() when django.contrib.postgres is "uninstalled" by override_settings(). """ if not enter and setting == 'INSTALLED_APPS' and 'django.contrib.postgres' not in set(value): connection_created....
[ "def", "uninstall_if_needed", "(", "setting", ",", "value", ",", "enter", ",", "*", "*", "kwargs", ")", ":", "if", "not", "enter", "and", "setting", "==", "'INSTALLED_APPS'", "and", "'django.contrib.postgres'", "not", "in", "set", "(", "value", ")", ":", "...
[ 19, 0 ]
[ 36, 58 ]
python
en
['en', 'error', 'th']
False
TestSerial.test_save_and_load_var
(self)
test_save_and_load_var: Test that we can save and load a PicklableVariable with joblib
test_save_and_load_var: Test that we can save and load a PicklableVariable with joblib
def test_save_and_load_var(self): """test_save_and_load_var: Test that we can save and load a PicklableVariable with joblib """ sess = tf.Session() with sess.as_default(): x = np.ones(1) xv = PicklableVariable(x) xv.var.initializer.run() ...
[ "def", "test_save_and_load_var", "(", "self", ")", ":", "sess", "=", "tf", ".", "Session", "(", ")", "with", "sess", ".", "as_default", "(", ")", ":", "x", "=", "np", ".", "ones", "(", "1", ")", "xv", "=", "PicklableVariable", "(", "x", ")", "xv", ...
[ 15, 4 ]
[ 28, 62 ]
python
en
['en', 'en', 'en']
True
RelativeFieldTests.test_symmetric_self_reference_with_intermediate_table_and_through_fields
(self)
Using through_fields in a m2m with an intermediate model shouldn't mask its incompatibility with symmetry.
Using through_fields in a m2m with an intermediate model shouldn't mask its incompatibility with symmetry.
def test_symmetric_self_reference_with_intermediate_table_and_through_fields(self): """Using through_fields in a m2m with an intermediate model shouldn't mask its incompatibility with symmetry.""" class Person(models.Model): # Explicit symmetrical=True. friends = models.ManyToMan...
[ "def", "test_symmetric_self_reference_with_intermediate_table_and_through_fields", "(", "self", ")", ":", "class", "Person", "(", "models", ".", "Model", ")", ":", "# Explicit symmetrical=True.", "friends", "=", "models", ".", "ManyToManyField", "(", "'self'", ",", "sym...
[ 270, 4 ]
[ 294, 42 ]
python
en
['en', 'en', 'en']
True
AccessorClashTests.test_m2m_to_m2m_with_inheritance
(self)
Ref #22047.
Ref #22047.
def test_m2m_to_m2m_with_inheritance(self): """ Ref #22047. """ class Target(models.Model): pass class Model(models.Model): children = models.ManyToManyField('Child', related_name="m2m_clash", related_query_name="no_clash") class Parent(models.M...
[ "def", "test_m2m_to_m2m_with_inheritance", "(", "self", ")", ":", "class", "Target", "(", "models", ".", "Model", ")", ":", "pass", "class", "Model", "(", "models", ".", "Model", ")", ":", "children", "=", "models", ".", "ManyToManyField", "(", "'Child'", ...
[ 698, 4 ]
[ 725, 42 ]
python
en
['en', 'kk', 'ur']
False
M2mThroughFieldsTests.test_m2m_field_argument_validation
(self)
Tests that ManyToManyField accepts the ``through_fields`` kwarg only if an intermediary table is specified.
Tests that ManyToManyField accepts the ``through_fields`` kwarg only if an intermediary table is specified.
def test_m2m_field_argument_validation(self): """ Tests that ManyToManyField accepts the ``through_fields`` kwarg only if an intermediary table is specified. """ class Fan(models.Model): pass self.assertRaisesMessage( ValueError, 'Cannot specify t...
[ "def", "test_m2m_field_argument_validation", "(", "self", ")", ":", "class", "Fan", "(", "models", ".", "Model", ")", ":", "pass", "self", ".", "assertRaisesMessage", "(", "ValueError", ",", "'Cannot specify through_fields without a through model'", ",", "models", "."...
[ 1182, 4 ]
[ 1192, 69 ]
python
en
['en', 'error', 'th']
False
M2mThroughFieldsTests.test_invalid_order
(self)
Tests that mixing up the order of link fields to ManyToManyField.through_fields triggers validation errors.
Tests that mixing up the order of link fields to ManyToManyField.through_fields triggers validation errors.
def test_invalid_order(self): """ Tests that mixing up the order of link fields to ManyToManyField.through_fields triggers validation errors. """ class Fan(models.Model): pass class Event(models.Model): invitees = models.ManyToManyField(Fan, throu...
[ "def", "test_invalid_order", "(", "self", ")", ":", "class", "Fan", "(", "models", ".", "Model", ")", ":", "pass", "class", "Event", "(", "models", ".", "Model", ")", ":", "invitees", "=", "models", ".", "ManyToManyField", "(", "Fan", ",", "through", "...
[ 1194, 4 ]
[ 1224, 42 ]
python
en
['en', 'error', 'th']
False
M2mThroughFieldsTests.test_invalid_field
(self)
Tests that providing invalid field names to ManyToManyField.through_fields triggers validation errors.
Tests that providing invalid field names to ManyToManyField.through_fields triggers validation errors.
def test_invalid_field(self): """ Tests that providing invalid field names to ManyToManyField.through_fields triggers validation errors. """ class Fan(models.Model): pass class Event(models.Model): invitees = models.ManyToManyField(Fan, through='I...
[ "def", "test_invalid_field", "(", "self", ")", ":", "class", "Fan", "(", "models", ".", "Model", ")", ":", "pass", "class", "Event", "(", "models", ".", "Model", ")", ":", "invitees", "=", "models", ".", "ManyToManyField", "(", "Fan", ",", "through", "...
[ 1226, 4 ]
[ 1256, 42 ]
python
en
['en', 'error', 'th']
False
M2mThroughFieldsTests.test_explicit_field_names
(self)
Tests that if ``through_fields`` kwarg is given, it must specify both link fields of the intermediary table.
Tests that if ``through_fields`` kwarg is given, it must specify both link fields of the intermediary table.
def test_explicit_field_names(self): """ Tests that if ``through_fields`` kwarg is given, it must specify both link fields of the intermediary table. """ class Fan(models.Model): pass class Event(models.Model): invitees = models.ManyToManyField(Fa...
[ "def", "test_explicit_field_names", "(", "self", ")", ":", "class", "Fan", "(", "models", ".", "Model", ")", ":", "pass", "class", "Event", "(", "models", ".", "Model", ")", ":", "invitees", "=", "models", ".", "ManyToManyField", "(", "Fan", ",", "throug...
[ 1258, 4 ]
[ 1285, 42 ]
python
en
['en', 'error', 'th']
False
getmode
(mode)
Gets a mode descriptor for the given mode.
Gets a mode descriptor for the given mode.
def getmode(mode): """Gets a mode descriptor for the given mode.""" global _modes if not _modes: # initialize mode cache from . import Image modes = {} # core modes for m, (basemode, basetype, bands) in Image._MODEINFO.items(): modes[m] = ModeDescriptor(...
[ "def", "getmode", "(", "mode", ")", ":", "global", "_modes", "if", "not", "_modes", ":", "# initialize mode cache", "from", ".", "import", "Image", "modes", "=", "{", "}", "# core modes", "for", "m", ",", "(", "basemode", ",", "basetype", ",", "bands", "...
[ 32, 0 ]
[ 63, 23 ]
python
en
['en', 'gl', 'en']
True
Timeout._validate_timeout
(cls, value, name)
Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is used to specify in error messages. :return: The validated and casted version of the given value. :raises ValueError: If i...
Check that a timeout attribute is valid.
def _validate_timeout(cls, value, name): """ Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is used to specify in error messages. :return: The validated and casted version ...
[ "def", "_validate_timeout", "(", "cls", ",", "value", ",", "name", ")", ":", "if", "value", "is", "_Default", ":", "return", "cls", ".", "DEFAULT_TIMEOUT", "if", "value", "is", "None", "or", "value", "is", "cls", ".", "DEFAULT_TIMEOUT", ":", "return", "v...
[ 109, 4 ]
[ 152, 20 ]
python
en
['en', 'en', 'en']
True
Timeout.from_float
(cls, timeout)
Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` object that sets the individual timeouts to the ``timeout`` value passed to this function. ...
Create a new Timeout from a legacy timeout value.
def from_float(cls, timeout): """ Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` object that sets the individual timeouts to the ``timeout`` value ...
[ "def", "from_float", "(", "cls", ",", "timeout", ")", ":", "return", "Timeout", "(", "read", "=", "timeout", ",", "connect", "=", "timeout", ")" ]
[ 155, 4 ]
[ 168, 53 ]
python
en
['en', 'en', 'en']
True
Timeout.clone
(self)
Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. :return: a copy of the timeout object :rtype: :class:`Timeout`
Create a copy of the timeout object
def clone(self): """ Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. :return: a copy of the timeout object :rtype: :class:`Timeout` """ ...
[ "def", "clone", "(", "self", ")", ":", "# We can't use copy.deepcopy because that will also create a new object", "# for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to", "# detect the user default.", "return", "Timeout", "(", "connect", "=", "self", ".", "_connect", ...
[ 170, 4 ]
[ 182, 80 ]
python
en
['en', 'en', 'en']
True
Timeout.start_connect
(self)
Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already.
Start the timeout clock, used during a connect() attempt
def start_connect(self): """ Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already. """ if self._start_connect is not None: raise TimeoutStateError("Tim...
[ "def", "start_connect", "(", "self", ")", ":", "if", "self", ".", "_start_connect", "is", "not", "None", ":", "raise", "TimeoutStateError", "(", "\"Timeout timer has already been started.\"", ")", "self", ".", "_start_connect", "=", "current_time", "(", ")", "retu...
[ 184, 4 ]
[ 193, 34 ]
python
en
['en', 'en', 'en']
True
Timeout.get_connect_duration
(self)
Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float :raises urllib3.exceptions.TimeoutStateError: if you attempt to get duration for a timer that hasn't been started.
Gets the time elapsed since the call to :meth:`start_connect`.
def get_connect_duration(self): """ Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float :raises urllib3.exceptions.TimeoutStateError: if you attempt to get duration for a timer that hasn't been started. """ ...
[ "def", "get_connect_duration", "(", "self", ")", ":", "if", "self", ".", "_start_connect", "is", "None", ":", "raise", "TimeoutStateError", "(", "\"Can't get connect duration for timer that has not started.\"", ")", "return", "current_time", "(", ")", "-", "self", "."...
[ 195, 4 ]
[ 207, 51 ]
python
en
['en', 'en', 'en']
True
Timeout.connect_timeout
(self)
Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
Get the value to use when setting a connection timeout.
def connect_timeout(self): """ Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None ...
[ "def", "connect_timeout", "(", "self", ")", ":", "if", "self", ".", "total", "is", "None", ":", "return", "self", ".", "_connect", "if", "self", ".", "_connect", "is", "None", "or", "self", ".", "_connect", "is", "self", ".", "DEFAULT_TIMEOUT", ":", "r...
[ 210, 4 ]
[ 225, 45 ]
python
en
['en', 'en', 'en']
True
Timeout.read_timeout
(self)
Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. If self.total is set, the read timeout is dependent on the amount of time taken by the connect timeout. If the connection time has not been ...
Get the value for the read timeout.
def read_timeout(self): """ Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. If self.total is set, the read timeout is dependent on the amount of time taken by the connect timeout. If t...
[ "def", "read_timeout", "(", "self", ")", ":", "if", "(", "self", ".", "total", "is", "not", "None", "and", "self", ".", "total", "is", "not", "self", ".", "DEFAULT_TIMEOUT", "and", "self", ".", "_read", "is", "not", "None", "and", "self", ".", "_read...
[ 228, 4 ]
[ 257, 29 ]
python
en
['en', 'en', 'en']
True
is_iterable
(x)
An implementation independent way of checking for iterables
An implementation independent way of checking for iterables
def is_iterable(x): "An implementation independent way of checking for iterables" try: iter(x) except TypeError: return False else: return True
[ "def", "is_iterable", "(", "x", ")", ":", "try", ":", "iter", "(", "x", ")", "except", "TypeError", ":", "return", "False", "else", ":", "return", "True" ]
[ 0, 0 ]
[ 7, 19 ]
python
en
['en', 'en', 'en']
True
lookup
(code)
Lookup an error code and return its exception class. Raise `!KeyError` if the code is not found.
Lookup an error code and return its exception class.
def lookup(code): """Lookup an error code and return its exception class. Raise `!KeyError` if the code is not found. """ from psycopg2._psycopg import sqlstate_errors # avoid circular import return sqlstate_errors[code]
[ "def", "lookup", "(", "code", ")", ":", "from", "psycopg2", ".", "_psycopg", "import", "sqlstate_errors", "# avoid circular import", "return", "sqlstate_errors", "[", "code", "]" ]
[ 31, 0 ]
[ 37, 32 ]
python
en
['en', 'en', 'en']
True
TestRegistration.test_abstract_model
(self)
Exception is raised when trying to register an abstract model. Refs #12004.
Exception is raised when trying to register an abstract model. Refs #12004.
def test_abstract_model(self): """ Exception is raised when trying to register an abstract model. Refs #12004. """ self.assertRaises(ImproperlyConfigured, self.site.register, Location)
[ "def", "test_abstract_model", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ",", "self", ".", "site", ".", "register", ",", "Location", ")" ]
[ 65, 4 ]
[ 70, 77 ]
python
en
['en', 'error', 'th']
False
TestRegistration.test_is_registered_model
(self)
Checks for registered models should return true.
Checks for registered models should return true.
def test_is_registered_model(self): "Checks for registered models should return true." self.site.register(Person) self.assertTrue(self.site.is_registered(Person))
[ "def", "test_is_registered_model", "(", "self", ")", ":", "self", ".", "site", ".", "register", "(", "Person", ")", "self", ".", "assertTrue", "(", "self", ".", "site", ".", "is_registered", "(", "Person", ")", ")" ]
[ 72, 4 ]
[ 75, 56 ]
python
en
['en', 'no', 'en']
True
TestRegistration.test_is_registered_not_registered_model
(self)
Checks for unregistered models should return false.
Checks for unregistered models should return false.
def test_is_registered_not_registered_model(self): "Checks for unregistered models should return false." self.assertFalse(self.site.is_registered(Person))
[ "def", "test_is_registered_not_registered_model", "(", "self", ")", ":", "self", ".", "assertFalse", "(", "self", ".", "site", ".", "is_registered", "(", "Person", ")", ")" ]
[ 77, 4 ]
[ 79, 57 ]
python
en
['en', 'da', 'en']
True
read_mandyoc_data
( path, parameters_file=PARAMETERS_FILE, datasets=DATASETS, steps_slice=None, filetype="ascii", )
Read the files generate by Mandyoc code Parameters ---------- path : str Path to the folder where the Mandyoc files are located. parameters_file : str (optional) Name of the parameters file. It must be located inside the ``path`` directory. Default to ``"param_1.5....
Read the files generate by Mandyoc code
def read_mandyoc_data( path, parameters_file=PARAMETERS_FILE, datasets=DATASETS, steps_slice=None, filetype="ascii", ): """ Read the files generate by Mandyoc code Parameters ---------- path : str Path to the folder where the Mandyoc files are located. parameters_fi...
[ "def", "read_mandyoc_data", "(", "path", ",", "parameters_file", "=", "PARAMETERS_FILE", ",", "datasets", "=", "DATASETS", ",", "steps_slice", "=", "None", ",", "filetype", "=", "\"ascii\"", ",", ")", ":", "# Check valid filetype", "_check_filetype", "(", "filetyp...
[ 37, 0 ]
[ 115, 65 ]
python
en
['en', 'error', 'th']
False
_check_filetype
(filetype)
Checks if passed filetype is either ascii or binary
Checks if passed filetype is either ascii or binary
def _check_filetype(filetype): """ Checks if passed filetype is either ascii or binary """ if filetype not in ("ascii", "binary"): raise ValueError(f"Invalid filetype '{filetype}'")
[ "def", "_check_filetype", "(", "filetype", ")", ":", "if", "filetype", "not", "in", "(", "\"ascii\"", ",", "\"binary\"", ")", ":", "raise", "ValueError", "(", "f\"Invalid filetype '{filetype}'\"", ")" ]
[ 118, 0 ]
[ 123, 58 ]
python
en
['en', 'error', 'th']
False
_build_coordinates
(region, shape)
Create grid coordinates Parameters ---------- region : tuple Boundary coordinates for each direction. If reading 2D data, they must be passed in the following order: ``x_min``, ``x_max``, ``z_min``, ``z_max``. All coordinates should be in meters. shape : tuple ...
Create grid coordinates
def _build_coordinates(region, shape): """ Create grid coordinates Parameters ---------- region : tuple Boundary coordinates for each direction. If reading 2D data, they must be passed in the following order: ``x_min``, ``x_max``, ``z_min``, ``z_max``. All coordinate...
[ "def", "_build_coordinates", "(", "region", ",", "shape", ")", ":", "# Get number of dimensions", "x_min", ",", "x_max", ",", "z_min", ",", "z_max", "=", "region", "[", ":", "]", "nx", ",", "nz", "=", "shape", "[", ":", "]", "x", "=", "np", ".", "lin...
[ 126, 0 ]
[ 154, 15 ]
python
en
['en', 'error', 'th']
False
_read_scalars
(path, shape, steps, quantity, filetype)
Read Mandyoc scalar data Read ``temperature``, ``density``, ``radiogenic_heat``, ``viscosity``, ``strain``, ``strain_rate`` and ``pressure``. Parameters ---------- path : str Path to the folder where the Mandyoc files are located. shape: tuple Shape of the expected grid. ...
Read Mandyoc scalar data
def _read_scalars(path, shape, steps, quantity, filetype): """ Read Mandyoc scalar data Read ``temperature``, ``density``, ``radiogenic_heat``, ``viscosity``, ``strain``, ``strain_rate`` and ``pressure``. Parameters ---------- path : str Path to the folder where the Mandyoc files a...
[ "def", "_read_scalars", "(", "path", ",", "shape", ",", "steps", ",", "quantity", ",", "filetype", ")", ":", "data", "=", "[", "]", "for", "step", "in", "steps", ":", "filename", "=", "\"{}_{}\"", ".", "format", "(", "BASENAMES", "[", "quantity", "]", ...
[ 157, 0 ]
[ 204, 15 ]
python
en
['en', 'error', 'th']
False
_read_velocity
(path, shape, steps, filetype)
Read velocity data generated by Mandyoc code Parameters ---------- path : str Path to the folder where the Mandyoc output files are located. shape: tuple Shape of the expected grid. steps : array Array containing the saved steps. Returns ------- data: tuple...
Read velocity data generated by Mandyoc code
def _read_velocity(path, shape, steps, filetype): """ Read velocity data generated by Mandyoc code Parameters ---------- path : str Path to the folder where the Mandyoc output files are located. shape: tuple Shape of the expected grid. steps : array Array containing ...
[ "def", "_read_velocity", "(", "path", ",", "shape", ",", "steps", ",", "filetype", ")", ":", "# Determine the dimension of the velocity data", "dimension", "=", "len", "(", "shape", ")", "velocity_x", ",", "velocity_z", "=", "[", "]", ",", "[", "]", "for", "...
[ 207, 0 ]
[ 249, 35 ]
python
en
['en', 'error', 'th']
False
do_cache
(parser, token)
This will cache the contents of a template fragment for a given amount of time. Usage:: {% load cache %} {% cache [expire_time] [fragment_name] %} .. some expensive processing .. {% endcache %} This tag also supports varying by a list of arguments:: {% lo...
This will cache the contents of a template fragment for a given amount of time.
def do_cache(parser, token): """ This will cache the contents of a template fragment for a given amount of time. Usage:: {% load cache %} {% cache [expire_time] [fragment_name] %} .. some expensive processing .. {% endcache %} This tag also supports varying by ...
[ "def", "do_cache", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endcache'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "tokens", "=", "token", ".", "split_contents", "(", ")", "if", "len...
[ 51, 0 ]
[ 91, 5 ]
python
en
['en', 'error', 'th']
False
AdaBound.step
(self, closure=None)
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss.
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss.
def step(self, closure=None): """Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for ...
[ "def", "step", "(", "self", ",", "closure", "=", "None", ")", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", ",", "base_lr", "in", "zip", "(", "self", ".", "param_groups", ",",...
[ 52, 4 ]
[ 120, 19 ]
python
en
['en', 'en', 'en']
True
AdaBoundW.step
(self, closure=None)
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss.
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss.
def step(self, closure=None): """Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for ...
[ "def", "step", "(", "self", ",", "closure", "=", "None", ")", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", ",", "base_lr", "in", "zip", "(", "self", ".", "param_groups", ",",...
[ 166, 4 ]
[ 236, 19 ]
python
en
['en', 'en', 'en']
True
LocaleMiddleware.is_language_prefix_patterns_used
(self)
Returns `True` if the `LocaleRegexURLResolver` is used at root level of the urlpatterns, else it returns `False`.
Returns `True` if the `LocaleRegexURLResolver` is used at root level of the urlpatterns, else it returns `False`.
def is_language_prefix_patterns_used(self): """ Returns `True` if the `LocaleRegexURLResolver` is used at root level of the urlpatterns, else it returns `False`. """ return self._is_language_prefix_patterns_used
[ "def", "is_language_prefix_patterns_used", "(", "self", ")", ":", "return", "self", ".", "_is_language_prefix_patterns_used" ]
[ 68, 4 ]
[ 73, 53 ]
python
en
['en', 'error', 'th']
False
FieldDeconstructionTests.test_name
(self)
Tests the outputting of the correct name if assigned one.
Tests the outputting of the correct name if assigned one.
def test_name(self): """ Tests the outputting of the correct name if assigned one. """ # First try using a "normal" field field = models.CharField(max_length=65) name, path, args, kwargs = field.deconstruct() self.assertIsNone(name) field.set_attributes_fr...
[ "def", "test_name", "(", "self", ")", ":", "# First try using a \"normal\" field", "field", "=", "models", ".", "CharField", "(", "max_length", "=", "65", ")", "name", ",", "path", ",", "args", ",", "kwargs", "=", "field", ".", "deconstruct", "(", ")", "se...
[ 14, 4 ]
[ 32, 40 ]
python
en
['en', 'error', 'th']
False
FieldDeconstructionTests.test_decimal_field_0_decimal_places
(self)
A DecimalField with decimal_places=0 should work (#22272).
A DecimalField with decimal_places=0 should work (#22272).
def test_decimal_field_0_decimal_places(self): """ A DecimalField with decimal_places=0 should work (#22272). """ field = models.DecimalField(max_digits=5, decimal_places=0) name, path, args, kwargs = field.deconstruct() self.assertEqual(path, "django.db.models.DecimalFie...
[ "def", "test_decimal_field_0_decimal_places", "(", "self", ")", ":", "field", "=", "models", ".", "DecimalField", "(", "max_digits", "=", "5", ",", "decimal_places", "=", "0", ")", "name", ",", "path", ",", "args", ",", "kwargs", "=", "field", ".", "decons...
[ 117, 4 ]
[ 125, 72 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_get_tag_uri
(self)
Test get_tag_uri() correctly generates TagURIs.
Test get_tag_uri() correctly generates TagURIs.
def test_get_tag_uri(self): """ Test get_tag_uri() correctly generates TagURIs. """ self.assertEqual( feedgenerator.get_tag_uri('http://example.org/foo/bar#headline', datetime.date(2004, 10, 25)), 'tag:example.org,2004-10-25:/foo/bar/headline')
[ "def", "test_get_tag_uri", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "get_tag_uri", "(", "'http://example.org/foo/bar#headline'", ",", "datetime", ".", "date", "(", "2004", ",", "10", ",", "25", ")", ")", ",", "'tag:example....
[ 14, 4 ]
[ 20, 59 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_get_tag_uri_with_port
(self)
Test that get_tag_uri() correctly generates TagURIs from URLs with port numbers.
Test that get_tag_uri() correctly generates TagURIs from URLs with port numbers.
def test_get_tag_uri_with_port(self): """ Test that get_tag_uri() correctly generates TagURIs from URLs with port numbers. """ self.assertEqual( feedgenerator.get_tag_uri('http://www.example.org:8000/2008/11/14/django#headline', datetime.datetime(2008, 11, 14, 13, 37,...
[ "def", "test_get_tag_uri_with_port", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "get_tag_uri", "(", "'http://www.example.org:8000/2008/11/14/django#headline'", ",", "datetime", ".", "datetime", "(", "2008", ",", "11", ",", "14", ",...
[ 22, 4 ]
[ 29, 73 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rfc2822_date
(self)
Test rfc2822_date() correctly formats datetime objects.
Test rfc2822_date() correctly formats datetime objects.
def test_rfc2822_date(self): """ Test rfc2822_date() correctly formats datetime objects. """ self.assertEqual( feedgenerator.rfc2822_date(datetime.datetime(2008, 11, 14, 13, 37, 0)), "Fri, 14 Nov 2008 13:37:00 -0000" )
[ "def", "test_rfc2822_date", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "rfc2822_date", "(", "datetime", ".", "datetime", "(", "2008", ",", "11", ",", "14", ",", "13", ",", "37", ",", "0", ")", ")", ",", "\"Fri, 14 Nov...
[ 31, 4 ]
[ 38, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rfc2822_date_with_timezone
(self)
Test rfc2822_date() correctly formats datetime objects with tzinfo.
Test rfc2822_date() correctly formats datetime objects with tzinfo.
def test_rfc2822_date_with_timezone(self): """ Test rfc2822_date() correctly formats datetime objects with tzinfo. """ self.assertEqual( feedgenerator.rfc2822_date(datetime.datetime(2008, 11, 14, 13, 37, 0, tzinfo=get_fixed_timezone(60))), "Fri, 14 Nov 2008 13:37:...
[ "def", "test_rfc2822_date_with_timezone", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "rfc2822_date", "(", "datetime", ".", "datetime", "(", "2008", ",", "11", ",", "14", ",", "13", ",", "37", ",", "0", ",", "tzinfo", "=...
[ 40, 4 ]
[ 47, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rfc2822_date_without_time
(self)
Test rfc2822_date() correctly formats date objects.
Test rfc2822_date() correctly formats date objects.
def test_rfc2822_date_without_time(self): """ Test rfc2822_date() correctly formats date objects. """ self.assertEqual( feedgenerator.rfc2822_date(datetime.date(2008, 11, 14)), "Fri, 14 Nov 2008 00:00:00 -0000" )
[ "def", "test_rfc2822_date_without_time", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "rfc2822_date", "(", "datetime", ".", "date", "(", "2008", ",", "11", ",", "14", ")", ")", ",", "\"Fri, 14 Nov 2008 00:00:00 -0000\"", ")" ]
[ 49, 4 ]
[ 56, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rfc3339_date
(self)
Test rfc3339_date() correctly formats datetime objects.
Test rfc3339_date() correctly formats datetime objects.
def test_rfc3339_date(self): """ Test rfc3339_date() correctly formats datetime objects. """ self.assertEqual( feedgenerator.rfc3339_date(datetime.datetime(2008, 11, 14, 13, 37, 0)), "2008-11-14T13:37:00Z" )
[ "def", "test_rfc3339_date", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "rfc3339_date", "(", "datetime", ".", "datetime", "(", "2008", ",", "11", ",", "14", ",", "13", ",", "37", ",", "0", ")", ")", ",", "\"2008-11-14T...
[ 58, 4 ]
[ 65, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rfc3339_date_with_timezone
(self)
Test rfc3339_date() correctly formats datetime objects with tzinfo.
Test rfc3339_date() correctly formats datetime objects with tzinfo.
def test_rfc3339_date_with_timezone(self): """ Test rfc3339_date() correctly formats datetime objects with tzinfo. """ self.assertEqual( feedgenerator.rfc3339_date(datetime.datetime(2008, 11, 14, 13, 37, 0, tzinfo=get_fixed_timezone(120))), "2008-11-14T13:37:00+02...
[ "def", "test_rfc3339_date_with_timezone", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "rfc3339_date", "(", "datetime", ".", "datetime", "(", "2008", ",", "11", ",", "14", ",", "13", ",", "37", ",", "0", ",", "tzinfo", "=...
[ 67, 4 ]
[ 74, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rfc3339_date_without_time
(self)
Test rfc3339_date() correctly formats date objects.
Test rfc3339_date() correctly formats date objects.
def test_rfc3339_date_without_time(self): """ Test rfc3339_date() correctly formats date objects. """ self.assertEqual( feedgenerator.rfc3339_date(datetime.date(2008, 11, 14)), "2008-11-14T00:00:00Z" )
[ "def", "test_rfc3339_date_without_time", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "feedgenerator", ".", "rfc3339_date", "(", "datetime", ".", "date", "(", "2008", ",", "11", ",", "14", ")", ")", ",", "\"2008-11-14T00:00:00Z\"", ")" ]
[ 76, 4 ]
[ 83, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_atom1_mime_type
(self)
Test to make sure Atom MIME type has UTF8 Charset parameter set
Test to make sure Atom MIME type has UTF8 Charset parameter set
def test_atom1_mime_type(self): """ Test to make sure Atom MIME type has UTF8 Charset parameter set """ atom_feed = feedgenerator.Atom1Feed("title", "link", "description") self.assertEqual( atom_feed.mime_type, "application/atom+xml; charset=utf-8" )
[ "def", "test_atom1_mime_type", "(", "self", ")", ":", "atom_feed", "=", "feedgenerator", ".", "Atom1Feed", "(", "\"title\"", ",", "\"link\"", ",", "\"description\"", ")", "self", ".", "assertEqual", "(", "atom_feed", ".", "mime_type", ",", "\"application/atom+xml;...
[ 85, 4 ]
[ 92, 9 ]
python
en
['en', 'error', 'th']
False
FeedgeneratorTest.test_rss_mime_type
(self)
Test to make sure RSS MIME type has UTF8 Charset parameter set
Test to make sure RSS MIME type has UTF8 Charset parameter set
def test_rss_mime_type(self): """ Test to make sure RSS MIME type has UTF8 Charset parameter set """ rss_feed = feedgenerator.Rss201rev2Feed("title", "link", "description") self.assertEqual( rss_feed.mime_type, "application/rss+xml; charset=utf-8" )
[ "def", "test_rss_mime_type", "(", "self", ")", ":", "rss_feed", "=", "feedgenerator", ".", "Rss201rev2Feed", "(", "\"title\"", ",", "\"link\"", ",", "\"description\"", ")", "self", ".", "assertEqual", "(", "rss_feed", ".", "mime_type", ",", "\"application/rss+xml;...
[ 94, 4 ]
[ 101, 9 ]
python
en
['en', 'error', 'th']
False
sequencer
()
Use like this: NEXT_ID = sequencer() message_id = NEXT_ID('message')
Use like this:
def sequencer() -> Callable[[str], int]: """ Use like this: NEXT_ID = sequencer() message_id = NEXT_ID('message') """ seq_dict: Dict[str, Callable[[], int]] = {} def next_one(name: str) -> int: if name not in seq_dict: seq_dict[name] = _seq() seq = seq_dict[name...
[ "def", "sequencer", "(", ")", "->", "Callable", "[", "[", "str", "]", ",", "int", "]", ":", "seq_dict", ":", "Dict", "[", "str", ",", "Callable", "[", "[", "]", ",", "int", "]", "]", "=", "{", "}", "def", "next_one", "(", "name", ":", "str", ...
[ 25, 0 ]
[ 40, 19 ]
python
en
['en', 'error', 'th']
False
test_pyboard_connect
(connect_mock)
should connect
should connect
def test_pyboard_connect(connect_mock): """should connect""" pyb = PyboardWrapper("/dev/PORT") connect_mock.assert_called_once_with("/dev/PORT") assert pyb.connected
[ "def", "test_pyboard_connect", "(", "connect_mock", ")", ":", "pyb", "=", "PyboardWrapper", "(", "\"/dev/PORT\"", ")", "connect_mock", ".", "assert_called_once_with", "(", "\"/dev/PORT\"", ")", "assert", "pyb", ".", "connected" ]
[ 25, 0 ]
[ 29, 24 ]
python
en
['en', 'fr', 'en']
False
test_pyboard_fail_connect
()
should fail
should fail
def test_pyboard_fail_connect(): """should fail""" with pytest.raises(SystemExit): PyboardWrapper("/dev/BADPORTPARAM")
[ "def", "test_pyboard_fail_connect", "(", ")", ":", "with", "pytest", ".", "raises", "(", "SystemExit", ")", ":", "PyboardWrapper", "(", "\"/dev/BADPORTPARAM\"", ")" ]
[ 32, 0 ]
[ 35, 43 ]
python
en
['en', 'ca', 'en']
False
test_pyboard_list_dir
(mocker, connect_mock, root_mock)
should list directory
should list directory
def test_pyboard_list_dir(mocker, connect_mock, root_mock): """should list directory""" mocked_auto = mocker.patch("rshell.main.auto") mocked_auto.return_value = ["main.py", "boot.py"] pyb = PyboardWrapper("/dev/PORT") value = pyb.list_dir("/path") mocked_auto.assert_called_once_with(mocker.ANY,...
[ "def", "test_pyboard_list_dir", "(", "mocker", ",", "connect_mock", ",", "root_mock", ")", ":", "mocked_auto", "=", "mocker", ".", "patch", "(", "\"rshell.main.auto\"", ")", "mocked_auto", ".", "return_value", "=", "[", "\"main.py\"", ",", "\"boot.py\"", "]", "p...
[ 38, 0 ]
[ 45, 42 ]
python
en
['en', 'en', 'en']
True
test_pyboard_copy_dir
(mocker, connect_mock, root_mock, tmp_path)
should copy directory
should copy directory
def test_pyboard_copy_dir(mocker, connect_mock, root_mock, tmp_path): """should copy directory""" mocked_rsync = mocker.patch("rshell.main.rsync") dest_path = tmp_path / "dest" dest_path.mkdir() pyb = PyboardWrapper("/dev/PORT") out_dir = pyb.copy_dir("/foobar/bar", dest_path) assert out_dir...
[ "def", "test_pyboard_copy_dir", "(", "mocker", ",", "connect_mock", ",", "root_mock", ",", "tmp_path", ")", ":", "mocked_rsync", "=", "mocker", ".", "patch", "(", "\"rshell.main.rsync\"", ")", "dest_path", "=", "tmp_path", "/", "\"dest\"", "dest_path", ".", "mkd...
[ 48, 0 ]
[ 64, 93 ]
python
en
['en', 'ca', 'en']
True
test_pyboard_copy_file
(mocker, connect_mock, root_mock, tmp_path)
should copy file
should copy file
def test_pyboard_copy_file(mocker, connect_mock, root_mock, tmp_path): """should copy file""" mocked_cp = mocker.patch("rshell.main.cp") pyb = PyboardWrapper("/dev/PORT") # No Dest Test out_file = pyb.copy_file("/foobar/file.py") assert Path(out_file) == Path("/mock/file.py") mocked_cp.asser...
[ "def", "test_pyboard_copy_file", "(", "mocker", ",", "connect_mock", ",", "root_mock", ",", "tmp_path", ")", ":", "mocked_cp", "=", "mocker", ".", "patch", "(", "\"rshell.main.cp\"", ")", "pyb", "=", "PyboardWrapper", "(", "\"/dev/PORT\"", ")", "# No Dest Test", ...
[ 67, 0 ]
[ 77, 57 ]
python
en
['en', 'fr', 'en']
True
test_pyboard_run
(mocker, connect_mock, tmp_path)
should execute script
should execute script
def test_pyboard_run(mocker, connect_mock, tmp_path): """should execute script""" tmp_script = tmp_path / "script.py" tmp_script.touch() tmp_string = tmp_script.open("r").read() pyb_mock = mocker.patch.object(PyboardWrapper, "pyboard") pyb_mock.exec_raw.side_effect = [(b"abc", None), (b"abc", No...
[ "def", "test_pyboard_run", "(", "mocker", ",", "connect_mock", ",", "tmp_path", ")", ":", "tmp_script", "=", "tmp_path", "/", "\"script.py\"", "tmp_script", ".", "touch", "(", ")", "tmp_string", "=", "tmp_script", ".", "open", "(", "\"r\"", ")", ".", "read",...
[ 80, 0 ]
[ 94, 27 ]
python
en
['en', 'ca', 'en']
True
test_pyboard_attr
(mocker, connect_mock)
should return pyboard
should return pyboard
def test_pyboard_attr(mocker, connect_mock): """should return pyboard""" find_mock = mocker.patch("rshell.main.find_serial_device_by_port") pyb = PyboardWrapper("/dev/PORT") pyb.pyboard find_mock.assert_called_once_with("/dev/PORT") pyb = PyboardWrapper("/dev/PORT2", connect=False) pyb.pyboa...
[ "def", "test_pyboard_attr", "(", "mocker", ",", "connect_mock", ")", ":", "find_mock", "=", "mocker", ".", "patch", "(", "\"rshell.main.find_serial_device_by_port\"", ")", "pyb", "=", "PyboardWrapper", "(", "\"/dev/PORT\"", ")", "pyb", ".", "pyboard", "find_mock", ...
[ 97, 0 ]
[ 105, 34 ]
python
en
['en', 'ig', 'en']
True
test_pyboard_root
(mocker, connect_mock)
should get root
should get root
def test_pyboard_root(mocker, connect_mock): """should get root""" find_mock = mocker.patch("rshell.main.find_serial_device_by_port") pyb = PyboardWrapper("/dev/PORT") pyb.pyb_root find_mock.assert_called_once_with("/dev/PORT") pyb = PyboardWrapper("/dev/PORT2", connect=False) pyb.pyb_root ...
[ "def", "test_pyboard_root", "(", "mocker", ",", "connect_mock", ")", ":", "find_mock", "=", "mocker", ".", "patch", "(", "\"rshell.main.find_serial_device_by_port\"", ")", "pyb", "=", "PyboardWrapper", "(", "\"/dev/PORT\"", ")", "pyb", ".", "pyb_root", "find_mock", ...
[ 108, 0 ]
[ 116, 34 ]
python
en
['en', 'nl', 'en']
True
test_pyboard_output
(mocker)
should consume till a newline
should consume till a newline
def test_pyboard_output(mocker): """should consume till a newline""" line_bytes = list("a line to consume\n") mocker.patch.object(pybwrapper, "Log") pyb = pybwrapper.PyboardWrapper("/dev/foo", connect=False) for char in line_bytes: pyb._consumer(char.encode("utf-8")) pyb.log.info.assert_...
[ "def", "test_pyboard_output", "(", "mocker", ")", ":", "line_bytes", "=", "list", "(", "\"a line to consume\\n\"", ")", "mocker", ".", "patch", ".", "object", "(", "pybwrapper", ",", "\"Log\"", ")", "pyb", "=", "pybwrapper", ".", "PyboardWrapper", "(", "\"/dev...
[ 119, 0 ]
[ 131, 58 ]
python
en
['en', 'ca', 'en']
True
spread_purelib_into_root
(wheel_dir: str)
Unpacks purelib directories into the root. Args: wheel_dir: The root of the extracted wheel directory.
Unpacks purelib directories into the root.
def spread_purelib_into_root(wheel_dir: str) -> None: """Unpacks purelib directories into the root. Args: wheel_dir: The root of the extracted wheel directory. """ dist_info = wheel.get_dist_info(wheel_dir) wheel_metadata_file_path = pathlib.Path(dist_info, "WHEEL") wheel_metadata_dict...
[ "def", "spread_purelib_into_root", "(", "wheel_dir", ":", "str", ")", "->", "None", ":", "dist_info", "=", "wheel", ".", "get_dist_info", "(", "wheel_dir", ")", "wheel_metadata_file_path", "=", "pathlib", ".", "Path", "(", "dist_info", ",", "\"WHEEL\"", ")", "...
[ 7, 0 ]
[ 37, 45 ]
python
en
['en', 'la', 'en']
True
_spread_purelib
(purelib_dir: pathlib.Path, root_dir: str)
Recursively moves all sibling directories of the purelib to the root. Args: purelib_dir: The directory of the purelib. root_dir: The directory to move files into.
Recursively moves all sibling directories of the purelib to the root.
def _spread_purelib(purelib_dir: pathlib.Path, root_dir: str) -> None: """Recursively moves all sibling directories of the purelib to the root. Args: purelib_dir: The directory of the purelib. root_dir: The directory to move files into. """ for grandchild in purelib_dir.iterdir(): ...
[ "def", "_spread_purelib", "(", "purelib_dir", ":", "pathlib", ".", "Path", ",", "root_dir", ":", "str", ")", "->", "None", ":", "for", "grandchild", "in", "purelib_dir", ".", "iterdir", "(", ")", ":", "# Some purelib Wheels, like Tensorflow 2.0.0, have directories",...
[ 40, 0 ]
[ 55, 13 ]
python
en
['en', 'en', 'en']
True
indent_log
(num=2)
A context manager which will cause the log output to be indented for any log messages emitted inside it.
A context manager which will cause the log output to be indented for any log messages emitted inside it.
def indent_log(num=2): """ A context manager which will cause the log output to be indented for any log messages emitted inside it. """ # For thread-safety _log_state.indentation = get_indentation() _log_state.indentation += num try: yield finally: _log_state.indentat...
[ "def", "indent_log", "(", "num", "=", "2", ")", ":", "# For thread-safety", "_log_state", ".", "indentation", "=", "get_indentation", "(", ")", "_log_state", ".", "indentation", "+=", "num", "try", ":", "yield", "finally", ":", "_log_state", ".", "indentation"...
[ 100, 0 ]
[ 111, 37 ]
python
en
['en', 'error', 'th']
False
setup_logging
(verbosity, no_color, user_log_file)
Configures and sets up all of the logging Returns the requested logging level, as its integer value.
Configures and sets up all of the logging
def setup_logging(verbosity, no_color, user_log_file): """Configures and sets up all of the logging Returns the requested logging level, as its integer value. """ # Determine the level to be logging at. if verbosity >= 1: level = "DEBUG" elif verbosity == -1: level = "WARNING" ...
[ "def", "setup_logging", "(", "verbosity", ",", "no_color", ",", "user_log_file", ")", ":", "# Determine the level to be logging at.", "if", "verbosity", ">=", "1", ":", "level", "=", "\"DEBUG\"", "elif", "verbosity", "==", "-", "1", ":", "level", "=", "\"WARNING...
[ 277, 0 ]
[ 398, 23 ]
python
en
['en', 'en', 'en']
True
IndentingFormatter.__init__
(self, *args, **kwargs)
A logging.Formatter that obeys the indent_log() context manager. :param add_timestamp: A bool indicating output lines should be prefixed with their record's timestamp.
A logging.Formatter that obeys the indent_log() context manager.
def __init__(self, *args, **kwargs): """ A logging.Formatter that obeys the indent_log() context manager. :param add_timestamp: A bool indicating output lines should be prefixed with their record's timestamp. """ self.add_timestamp = kwargs.pop("add_timestamp", False...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "add_timestamp", "=", "kwargs", ".", "pop", "(", "\"add_timestamp\"", ",", "False", ")", "super", "(", "IndentingFormatter", ",", "self", ")", ".", "__ini...
[ 120, 4 ]
[ 128, 65 ]
python
en
['en', 'error', 'th']
False
IndentingFormatter.get_message_start
(self, formatted, levelno)
Return the start of the formatted log message (not counting the prefix to add to each line).
Return the start of the formatted log message (not counting the prefix to add to each line).
def get_message_start(self, formatted, levelno): """ Return the start of the formatted log message (not counting the prefix to add to each line). """ if levelno < logging.WARNING: return '' if formatted.startswith(DEPRECATION_MSG_PREFIX): # Then th...
[ "def", "get_message_start", "(", "self", ",", "formatted", ",", "levelno", ")", ":", "if", "levelno", "<", "logging", ".", "WARNING", ":", "return", "''", "if", "formatted", ".", "startswith", "(", "DEPRECATION_MSG_PREFIX", ")", ":", "# Then the message already ...
[ 130, 4 ]
[ 144, 24 ]
python
en
['en', 'error', 'th']
False
IndentingFormatter.format
(self, record)
Calls the standard formatter, but will indent all of the log message lines by our current indentation level.
Calls the standard formatter, but will indent all of the log message lines by our current indentation level.
def format(self, record): """ Calls the standard formatter, but will indent all of the log message lines by our current indentation level. """ formatted = super(IndentingFormatter, self).format(record) message_start = self.get_message_start(formatted, record.levelno) ...
[ "def", "format", "(", "self", ",", "record", ")", ":", "formatted", "=", "super", "(", "IndentingFormatter", ",", "self", ")", ".", "format", "(", "record", ")", "message_start", "=", "self", ".", "get_message_start", "(", "formatted", ",", "record", ".", ...
[ 146, 4 ]
[ 165, 24 ]
python
en
['en', 'error', 'th']
False
ColorizedStreamHandler._using_stdout
(self)
Return whether the handler is using sys.stdout.
Return whether the handler is using sys.stdout.
def _using_stdout(self): """ Return whether the handler is using sys.stdout. """ if WINDOWS and colorama: # Then self.stream is an AnsiToWin32 object. return self.stream.wrapped is sys.stdout return self.stream is sys.stdout
[ "def", "_using_stdout", "(", "self", ")", ":", "if", "WINDOWS", "and", "colorama", ":", "# Then self.stream is an AnsiToWin32 object.", "return", "self", ".", "stream", ".", "wrapped", "is", "sys", ".", "stdout", "return", "self", ".", "stream", "is", "sys", "...
[ 193, 4 ]
[ 201, 40 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_project_update_successful_message
(self)
Tests if ansibletower project update successful notification is handled correctly
Tests if ansibletower project update successful notification is handled correctly
def test_ansibletower_project_update_successful_message(self) -> None: """ Tests if ansibletower project update successful notification is handled correctly """ expected_topic = "AWX - Project Update" expected_message = ( "Project Update: [#2677 AWX - Project Update]"...
[ "def", "test_ansibletower_project_update_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Project Update\"", "expected_message", "=", "(", "\"Project Update: [#2677 AWX - Project Update]\"", "\"(http://awx.example.co.uk/#/jobs/project/2677) was ...
[ 8, 4 ]
[ 18, 89 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_project_update_failed_message
(self)
Tests if ansibletower project update failed notification is handled correctly
Tests if ansibletower project update failed notification is handled correctly
def test_ansibletower_project_update_failed_message(self) -> None: """ Tests if ansibletower project update failed notification is handled correctly """ expected_topic = "AWX - Project Update" expected_message = ( "Project Update: [#2678 AWX - Project Update]" ...
[ "def", "test_ansibletower_project_update_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Project Update\"", "expected_message", "=", "(", "\"Project Update: [#2678 AWX - Project Update]\"", "\"(http://awx.example.co.uk/#/jobs/project/2678) failed.\...
[ 20, 4 ]
[ 30, 85 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_successful_multiple_hosts_message
(self)
Tests if ansibletower job successful multiple hosts notification is handled correctly
Tests if ansibletower job successful multiple hosts notification is handled correctly
def test_ansibletower_job_successful_multiple_hosts_message(self) -> None: """ Tests if ansibletower job successful multiple hosts notification is handled correctly """ expected_topic = "System - Deploy - Zabbix Agent" expected_message = """ Job: [#2674 System - Deploy - Zabbix A...
[ "def", "test_ansibletower_job_successful_multiple_hosts_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Deploy - Zabbix Agent\"", "expected_message", "=", "\"\"\"\nJob: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk/#/jobs/playbook/2674) w...
[ 32, 4 ]
[ 46, 93 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_successful_message
(self)
Tests if ansibletower job successful notification is handled correctly
Tests if ansibletower job successful notification is handled correctly
def test_ansibletower_job_successful_message(self) -> None: """ Tests if ansibletower job successful notification is handled correctly """ expected_topic = "System - Deploy - Zabbix Agent" expected_message = """ Job: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk...
[ "def", "test_ansibletower_job_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Deploy - Zabbix Agent\"", "expected_message", "=", "\"\"\"\nJob: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk/#/jobs/playbook/2674) was successful:\...
[ 48, 4 ]
[ 58, 78 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_nine_job_successful_message
(self)
Test to see if awx/ansibletower 9.x.x job successful notifications are handled just as successfully as prior to 9.x.x.
Test to see if awx/ansibletower 9.x.x job successful notifications are handled just as successfully as prior to 9.x.x.
def test_ansibletower_nine_job_successful_message(self) -> None: """ Test to see if awx/ansibletower 9.x.x job successful notifications are handled just as successfully as prior to 9.x.x. """ expected_topic = "Demo Job Template" expected_message = """ Job: [#1 Demo Job Te...
[ "def", "test_ansibletower_nine_job_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Demo Job Template\"", "expected_message", "=", "\"\"\"\nJob: [#1 Demo Job Template](https://towerhost/#/jobs/playbook/1) was successful:\n* localhost: Success\n\"\"\"", ...
[ 60, 4 ]
[ 71, 97 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_failed_message
(self)
Tests if ansibletower job failed notification is handled correctly
Tests if ansibletower job failed notification is handled correctly
def test_ansibletower_job_failed_message(self) -> None: """ Tests if ansibletower job failed notification is handled correctly """ expected_topic = "System - Updates - Ubuntu" expected_message = """ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/2...
[ "def", "test_ansibletower_job_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Updates - Ubuntu\"", "expected_message", "=", "\"\"\"\nJob: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/2722) failed:\n* chat.example.co.uk:...
[ 73, 4 ]
[ 83, 74 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_failed_multiple_hosts_message
(self)
Tests if ansibletower job failed notification is handled correctly
Tests if ansibletower job failed notification is handled correctly
def test_ansibletower_job_failed_multiple_hosts_message(self) -> None: """ Tests if ansibletower job failed notification is handled correctly """ expected_topic = "System - Updates - Ubuntu" expected_message = """ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/...
[ "def", "test_ansibletower_job_failed_multiple_hosts_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Updates - Ubuntu\"", "expected_message", "=", "\"\"\"\nJob: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/2722) failed:\n* chat...
[ 85, 4 ]
[ 99, 89 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_inventory_update_successful_message
(self)
Tests if ansibletower inventory update successful notification is handled correctly
Tests if ansibletower inventory update successful notification is handled correctly
def test_ansibletower_inventory_update_successful_message(self) -> None: """ Tests if ansibletower inventory update successful notification is handled correctly """ expected_topic = "AWX - Inventory Update" expected_message = ( "Inventory Update: [#2724 AWX - Inventor...
[ "def", "test_ansibletower_inventory_update_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Inventory Update\"", "expected_message", "=", "(", "\"Inventory Update: [#2724 AWX - Inventory Update]\"", "\"(http://awx.example.co.uk/#/jobs/inventory/...
[ 101, 4 ]
[ 111, 91 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_inventory_update_failed_message
(self)
Tests if ansibletower inventory update failed notification is handled correctly
Tests if ansibletower inventory update failed notification is handled correctly
def test_ansibletower_inventory_update_failed_message(self) -> None: """ Tests if ansibletower inventory update failed notification is handled correctly """ expected_topic = "AWX - Inventory Update" expected_message = ( "Inventory Update: [#2724 AWX - Inventory Update...
[ "def", "test_ansibletower_inventory_update_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Inventory Update\"", "expected_message", "=", "(", "\"Inventory Update: [#2724 AWX - Inventory Update]\"", "\"(http://awx.example.co.uk/#/jobs/inventory/2724...
[ 113, 4 ]
[ 123, 87 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_adhoc_command_successful_message
(self)
Tests if ansibletower adhoc command successful notification is handled correctly
Tests if ansibletower adhoc command successful notification is handled correctly
def test_ansibletower_adhoc_command_successful_message(self) -> None: """ Tests if ansibletower adhoc command successful notification is handled correctly """ expected_topic = "shell: uname -r" expected_message = ( "AdHoc Command: [#2726 shell: uname -r]" ...
[ "def", "test_ansibletower_adhoc_command_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"shell: uname -r\"", "expected_message", "=", "(", "\"AdHoc Command: [#2726 shell: uname -r]\"", "\"(http://awx.example.co.uk/#/jobs/command/2726) was successful.\...
[ 125, 4 ]
[ 135, 88 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_adhoc_command_failed_message
(self)
Tests if ansibletower adhoc command failed notification is handled correctly
Tests if ansibletower adhoc command failed notification is handled correctly
def test_ansibletower_adhoc_command_failed_message(self) -> None: """ Tests if ansibletower adhoc command failed notification is handled correctly """ expected_topic = "shell: uname -r" expected_message = ( "AdHoc Command: [#2726 shell: uname -r]" "(http:/...
[ "def", "test_ansibletower_adhoc_command_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"shell: uname -r\"", "expected_message", "=", "(", "\"AdHoc Command: [#2726 shell: uname -r]\"", "\"(http://awx.example.co.uk/#/jobs/command/2726) failed.\"", ")", ...
[ 137, 4 ]
[ 147, 84 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_system_job_successful_message
(self)
Tests if ansibletower system job successful notification is handled correctly
Tests if ansibletower system job successful notification is handled correctly
def test_ansibletower_system_job_successful_message(self) -> None: """ Tests if ansibletower system job successful notification is handled correctly """ expected_topic = "Cleanup Job Details" expected_message = ( "System Job: [#2721 Cleanup Job Details]" "...
[ "def", "test_ansibletower_system_job_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Cleanup Job Details\"", "expected_message", "=", "(", "\"System Job: [#2721 Cleanup Job Details]\"", "\"(http://awx.example.co.uk/#/jobs/system/2721) was successful....
[ 149, 4 ]
[ 159, 85 ]
python
en
['en', 'error', 'th']
False