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
AnsibletowerHookTests.test_ansibletower_system_job_failed_message
(self)
Tests if ansibletower system job failed notification is handled correctly
Tests if ansibletower system job failed notification is handled correctly
def test_ansibletower_system_job_failed_message(self) -> None: """ Tests if ansibletower system job failed notification is handled correctly """ expected_topic = "Cleanup Job Details" expected_message = ( "System Job: [#2721 Cleanup Job Details]" "(http://...
[ "def", "test_ansibletower_system_job_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Cleanup Job Details\"", "expected_message", "=", "(", "\"System Job: [#2721 Cleanup Job Details]\"", "\"(http://awx.example.co.uk/#/jobs/system/2721) failed.\"", ")", ...
[ 161, 4 ]
[ 171, 81 ]
python
en
['en', 'error', 'th']
False
eval
(expression, _dict={}, **kw)
Evaluates an image expression. :param expression: A string containing a Python-style expression. :param options: Values to add to the evaluation context. You can either use a dictionary, or one or more keyword arguments. :return: The evaluated expression. This ...
Evaluates an image expression.
def eval(expression, _dict={}, **kw): """ Evaluates an image expression. :param expression: A string containing a Python-style expression. :param options: Values to add to the evaluation context. You can either use a dictionary, or one or more keyword arguments....
[ "def", "eval", "(", "expression", ",", "_dict", "=", "{", "}", ",", "*", "*", "kw", ")", ":", "# build execution namespace", "args", "=", "ops", ".", "copy", "(", ")", "args", ".", "update", "(", "_dict", ")", "args", ".", "update", "(", "kw", ")",...
[ 227, 0 ]
[ 252, 18 ]
python
en
['en', 'error', 'th']
False
TestRunMultiGPU.helper_run_multi_gpu_madryetal
(self, extra_flags=None)
Compare the single GPU performance to multiGPU performance.
Compare the single GPU performance to multiGPU performance.
def helper_run_multi_gpu_madryetal(self, extra_flags=None): """ Compare the single GPU performance to multiGPU performance. """ # Run the trainers on a dataset of reduced size flags = { "train_start": 0, "train_end": 5000, "test_start": 0, ...
[ "def", "helper_run_multi_gpu_madryetal", "(", "self", ",", "extra_flags", "=", "None", ")", ":", "# Run the trainers on a dataset of reduced size", "flags", "=", "{", "\"train_start\"", ":", "0", ",", "\"train_end\"", ":", "5000", ",", "\"test_start\"", ":", "0", ",...
[ 18, 4 ]
[ 92, 9 ]
python
en
['en', 'error', 'th']
False
TestRunMultiGPU.test_run_single_gpu_fgsm
(self)
Test the basic single GPU performance by comparing to the FGSM tutorial.
Test the basic single GPU performance by comparing to the FGSM tutorial.
def test_run_single_gpu_fgsm(self): """ Test the basic single GPU performance by comparing to the FGSM tutorial. """ from cleverhans_tutorials import mnist_tutorial_tf # Run the MNIST tutorial on a dataset of reduced size flags = { "train_start": 0, ...
[ "def", "test_run_single_gpu_fgsm", "(", "self", ")", ":", "from", "cleverhans_tutorials", "import", "mnist_tutorial_tf", "# Run the MNIST tutorial on a dataset of reduced size", "flags", "=", "{", "\"train_start\"", ":", "0", ",", "\"train_end\"", ":", "5000", ",", "\"tes...
[ 94, 4 ]
[ 179, 9 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.load_disk
(self)
Loads the migrations from all INSTALLED_APPS from disk.
Loads the migrations from all INSTALLED_APPS from disk.
def load_disk(self): """ Loads the migrations from all INSTALLED_APPS from disk. """ self.disk_migrations = {} self.unmigrated_apps = set() self.migrated_apps = set() for app_config in apps.get_app_configs(): if app_config.models_module is None: ...
[ "def", "load_disk", "(", "self", ")", ":", "self", ".", "disk_migrations", "=", "{", "}", "self", ".", "unmigrated_apps", "=", "set", "(", ")", "self", ".", "migrated_apps", "=", "set", "(", ")", "for", "app_config", "in", "apps", ".", "get_app_configs",...
[ 57, 4 ]
[ 117, 58 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.get_migration
(self, app_label, name_prefix)
Gets the migration exactly named, or raises KeyError
Gets the migration exactly named, or raises KeyError
def get_migration(self, app_label, name_prefix): "Gets the migration exactly named, or raises KeyError" return self.graph.nodes[app_label, name_prefix]
[ "def", "get_migration", "(", "self", ",", "app_label", ",", "name_prefix", ")", ":", "return", "self", ".", "graph", ".", "nodes", "[", "app_label", ",", "name_prefix", "]" ]
[ 119, 4 ]
[ 121, 55 ]
python
en
['en', 'en', 'en']
True
MigrationLoader.get_migration_by_prefix
(self, app_label, name_prefix)
Returns the migration(s) which match the given app label and name _prefix_
Returns the migration(s) which match the given app label and name _prefix_
def get_migration_by_prefix(self, app_label, name_prefix): "Returns the migration(s) which match the given app label and name _prefix_" # Do the search results = [] for l, n in self.disk_migrations: if l == app_label and n.startswith(name_prefix): results.appe...
[ "def", "get_migration_by_prefix", "(", "self", ",", "app_label", ",", "name_prefix", ")", ":", "# Do the search", "results", "=", "[", "]", "for", "l", ",", "n", "in", "self", ".", "disk_migrations", ":", "if", "l", "==", "app_label", "and", "n", ".", "s...
[ 123, 4 ]
[ 135, 51 ]
python
en
['en', 'en', 'en']
True
MigrationLoader.build_graph
(self)
Builds a migration dependency graph using both the disk and database. You'll need to rebuild the graph if you apply migrations. This isn't usually a problem as generally migration stuff runs in a one-shot process.
Builds a migration dependency graph using both the disk and database. You'll need to rebuild the graph if you apply migrations. This isn't usually a problem as generally migration stuff runs in a one-shot process.
def build_graph(self): """ Builds a migration dependency graph using both the disk and database. You'll need to rebuild the graph if you apply migrations. This isn't usually a problem as generally migration stuff runs in a one-shot process. """ # Load disk data se...
[ "def", "build_graph", "(", "self", ")", ":", "# Load disk data", "self", ".", "load_disk", "(", ")", "# Load database data", "if", "self", ".", "connection", "is", "None", ":", "self", ".", "applied_migrations", "=", "set", "(", ")", "else", ":", "recorder",...
[ 165, 4 ]
[ 244, 68 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.detect_conflicts
(self)
Looks through the loaded graph and detects any conflicts - apps with more than one leaf migration. Returns a dict of the app labels that conflict with the migration names that conflict.
Looks through the loaded graph and detects any conflicts - apps with more than one leaf migration. Returns a dict of the app labels that conflict with the migration names that conflict.
def detect_conflicts(self): """ Looks through the loaded graph and detects any conflicts - apps with more than one leaf migration. Returns a dict of the app labels that conflict with the migration names that conflict. """ seen_apps = {} conflicting_apps = set() ...
[ "def", "detect_conflicts", "(", "self", ")", ":", "seen_apps", "=", "{", "}", "conflicting_apps", "=", "set", "(", ")", "for", "app_label", ",", "migration_name", "in", "self", ".", "graph", ".", "leaf_nodes", "(", ")", ":", "if", "app_label", "in", "see...
[ 246, 4 ]
[ 258, 88 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.project_state
(self, nodes=None, at_end=True)
Returns a ProjectState object representing the most recent state that the migrations we loaded represent. See graph.make_state for the meaning of "nodes" and "at_end"
Returns a ProjectState object representing the most recent state that the migrations we loaded represent.
def project_state(self, nodes=None, at_end=True): """ Returns a ProjectState object representing the most recent state that the migrations we loaded represent. See graph.make_state for the meaning of "nodes" and "at_end" """ return self.graph.make_state(nodes=nodes, at_e...
[ "def", "project_state", "(", "self", ",", "nodes", "=", "None", ",", "at_end", "=", "True", ")", ":", "return", "self", ".", "graph", ".", "make_state", "(", "nodes", "=", "nodes", ",", "at_end", "=", "at_end", ",", "real_apps", "=", "list", "(", "se...
[ 260, 4 ]
[ 267, 102 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.ensure_timezone
(self)
Ensure the connection's timezone is set to `self.timezone_name` and return whether it changed or not.
Ensure the connection's timezone is set to `self.timezone_name` and return whether it changed or not.
def ensure_timezone(self): """ Ensure the connection's timezone is set to `self.timezone_name` and return whether it changed or not. """ return False
[ "def", "ensure_timezone", "(", "self", ")", ":", "return", "False" ]
[ 109, 4 ]
[ 114, 20 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.timezone
(self)
Time zone for datetimes stored as naive values in the database. Return a tzinfo object or None. This is only needed when time zone support is enabled and the database doesn't support time zones. (When the database supports time zones, the adapter handles aware datetimes so Dja...
Time zone for datetimes stored as naive values in the database.
def timezone(self): """ Time zone for datetimes stored as naive values in the database. Return a tzinfo object or None. This is only needed when time zone support is enabled and the database doesn't support time zones. (When the database supports time zones, the adapter...
[ "def", "timezone", "(", "self", ")", ":", "if", "not", "settings", ".", "USE_TZ", ":", "return", "None", "elif", "self", ".", "features", ".", "supports_timezones", ":", "return", "None", "elif", "self", ".", "settings_dict", "[", "'TIME_ZONE'", "]", "is",...
[ 117, 4 ]
[ 134, 65 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.timezone_name
(self)
Name of the time zone of the database connection.
Name of the time zone of the database connection.
def timezone_name(self): """ Name of the time zone of the database connection. """ if not settings.USE_TZ: return settings.TIME_ZONE elif self.settings_dict['TIME_ZONE'] is None: return 'UTC' else: return self.settings_dict['TIME_ZONE']
[ "def", "timezone_name", "(", "self", ")", ":", "if", "not", "settings", ".", "USE_TZ", ":", "return", "settings", ".", "TIME_ZONE", "elif", "self", ".", "settings_dict", "[", "'TIME_ZONE'", "]", "is", "None", ":", "return", "'UTC'", "else", ":", "return", ...
[ 137, 4 ]
[ 146, 50 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.get_connection_params
(self)
Return a dict of parameters suitable for get_new_connection.
Return a dict of parameters suitable for get_new_connection.
def get_connection_params(self): """Return a dict of parameters suitable for get_new_connection.""" raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a get_connection_params() method')
[ "def", "get_connection_params", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseWrapper may require a get_connection_params() method'", ")" ]
[ 162, 4 ]
[ 164, 115 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.get_new_connection
(self, conn_params)
Open a connection to the database.
Open a connection to the database.
def get_new_connection(self, conn_params): """Open a connection to the database.""" raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a get_new_connection() method')
[ "def", "get_new_connection", "(", "self", ",", "conn_params", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseWrapper may require a get_new_connection() method'", ")" ]
[ 166, 4 ]
[ 168, 112 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.init_connection_state
(self)
Initialize the database connection settings.
Initialize the database connection settings.
def init_connection_state(self): """Initialize the database connection settings.""" raise NotImplementedError('subclasses of BaseDatabaseWrapper may require an init_connection_state() method')
[ "def", "init_connection_state", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseWrapper may require an init_connection_state() method'", ")" ]
[ 170, 4 ]
[ 172, 116 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.create_cursor
(self, name=None)
Create a cursor. Assume that a connection is established.
Create a cursor. Assume that a connection is established.
def create_cursor(self, name=None): """Create a cursor. Assume that a connection is established.""" raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a create_cursor() method')
[ "def", "create_cursor", "(", "self", ",", "name", "=", "None", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseWrapper may require a create_cursor() method'", ")" ]
[ 174, 4 ]
[ 176, 107 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.connect
(self)
Connect to the database. Assume that the connection is closed.
Connect to the database. Assume that the connection is closed.
def connect(self): """Connect to the database. Assume that the connection is closed.""" # Check for invalid configurations. self.check_settings() # In case the previous connection was closed while in an atomic block self.in_atomic_block = False self.savepoint_ids = [] ...
[ "def", "connect", "(", "self", ")", ":", "# Check for invalid configurations.", "self", ".", "check_settings", "(", ")", "# In case the previous connection was closed while in an atomic block", "self", ".", "in_atomic_block", "=", "False", "self", ".", "savepoint_ids", "=",...
[ 181, 4 ]
[ 201, 31 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.ensure_connection
(self)
Guarantee that a connection to the database is established.
Guarantee that a connection to the database is established.
def ensure_connection(self): """Guarantee that a connection to the database is established.""" if self.connection is None: with self.wrap_database_errors: self.connect()
[ "def", "ensure_connection", "(", "self", ")", ":", "if", "self", ".", "connection", "is", "None", ":", "with", "self", ".", "wrap_database_errors", ":", "self", ".", "connect", "(", ")" ]
[ 215, 4 ]
[ 219, 30 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper._prepare_cursor
(self, cursor)
Validate the connection is usable and perform database cursor wrapping.
Validate the connection is usable and perform database cursor wrapping.
def _prepare_cursor(self, cursor): """ Validate the connection is usable and perform database cursor wrapping. """ self.validate_thread_sharing() if self.queries_logged: wrapped_cursor = self.make_debug_cursor(cursor) else: wrapped_cursor = self.ma...
[ "def", "_prepare_cursor", "(", "self", ",", "cursor", ")", ":", "self", ".", "validate_thread_sharing", "(", ")", "if", "self", ".", "queries_logged", ":", "wrapped_cursor", "=", "self", ".", "make_debug_cursor", "(", "cursor", ")", "else", ":", "wrapped_curso...
[ 223, 4 ]
[ 232, 29 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.cursor
(self)
Create a cursor, opening a connection if necessary.
Create a cursor, opening a connection if necessary.
def cursor(self): """Create a cursor, opening a connection if necessary.""" return self._cursor()
[ "def", "cursor", "(", "self", ")", ":", "return", "self", ".", "_cursor", "(", ")" ]
[ 257, 4 ]
[ 259, 29 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.commit
(self)
Commit a transaction and reset the dirty flag.
Commit a transaction and reset the dirty flag.
def commit(self): """Commit a transaction and reset the dirty flag.""" self.validate_thread_sharing() self.validate_no_atomic_block() self._commit() # A successful commit means that the database connection works. self.errors_occurred = False self.run_commit_hooks_...
[ "def", "commit", "(", "self", ")", ":", "self", ".", "validate_thread_sharing", "(", ")", "self", ".", "validate_no_atomic_block", "(", ")", "self", ".", "_commit", "(", ")", "# A successful commit means that the database connection works.", "self", ".", "errors_occur...
[ 262, 4 ]
[ 269, 57 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.rollback
(self)
Roll back a transaction and reset the dirty flag.
Roll back a transaction and reset the dirty flag.
def rollback(self): """Roll back a transaction and reset the dirty flag.""" self.validate_thread_sharing() self.validate_no_atomic_block() self._rollback() # A successful rollback means that the database connection works. self.errors_occurred = False self.needs_ro...
[ "def", "rollback", "(", "self", ")", ":", "self", ".", "validate_thread_sharing", "(", ")", "self", ".", "validate_no_atomic_block", "(", ")", "self", ".", "_rollback", "(", ")", "# A successful rollback means that the database connection works.", "self", ".", "errors...
[ 272, 4 ]
[ 280, 31 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.close
(self)
Close the connection to the database.
Close the connection to the database.
def close(self): """Close the connection to the database.""" self.validate_thread_sharing() self.run_on_commit = [] # Don't call validate_no_atomic_block() to avoid making it difficult # to get rid of a connection in an invalid state. The next connect() # will reset the ...
[ "def", "close", "(", "self", ")", ":", "self", ".", "validate_thread_sharing", "(", ")", "self", ".", "run_on_commit", "=", "[", "]", "# Don't call validate_no_atomic_block() to avoid making it difficult", "# to get rid of a connection in an invalid state. The next connect()", ...
[ 283, 4 ]
[ 300, 38 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.savepoint
(self)
Create a savepoint inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit. Do nothing if savepoints are not supported.
Create a savepoint inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit. Do nothing if savepoints are not supported.
def savepoint(self): """ Create a savepoint inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit. Do nothing if savepoints are not supported. """ if not self._savepoint_allowed(): return...
[ "def", "savepoint", "(", "self", ")", ":", "if", "not", "self", ".", "_savepoint_allowed", "(", ")", ":", "return", "thread_ident", "=", "_thread", ".", "get_ident", "(", ")", "tid", "=", "str", "(", "thread_ident", ")", ".", "replace", "(", "'-'", ","...
[ 323, 4 ]
[ 341, 18 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.savepoint_rollback
(self, sid)
Roll back to a savepoint. Do nothing if savepoints are not supported.
Roll back to a savepoint. Do nothing if savepoints are not supported.
def savepoint_rollback(self, sid): """ Roll back to a savepoint. Do nothing if savepoints are not supported. """ if not self._savepoint_allowed(): return self.validate_thread_sharing() self._savepoint_rollback(sid) # Remove any callbacks registered w...
[ "def", "savepoint_rollback", "(", "self", ",", "sid", ")", ":", "if", "not", "self", ".", "_savepoint_allowed", "(", ")", ":", "return", "self", ".", "validate_thread_sharing", "(", ")", "self", ".", "_savepoint_rollback", "(", "sid", ")", "# Remove any callba...
[ 344, 4 ]
[ 357, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.savepoint_commit
(self, sid)
Release a savepoint. Do nothing if savepoints are not supported.
Release a savepoint. Do nothing if savepoints are not supported.
def savepoint_commit(self, sid): """ Release a savepoint. Do nothing if savepoints are not supported. """ if not self._savepoint_allowed(): return self.validate_thread_sharing() self._savepoint_commit(sid)
[ "def", "savepoint_commit", "(", "self", ",", "sid", ")", ":", "if", "not", "self", ".", "_savepoint_allowed", "(", ")", ":", "return", "self", ".", "validate_thread_sharing", "(", ")", "self", ".", "_savepoint_commit", "(", "sid", ")" ]
[ 360, 4 ]
[ 368, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.clean_savepoints
(self)
Reset the counter used to generate unique savepoint ids in this thread.
Reset the counter used to generate unique savepoint ids in this thread.
def clean_savepoints(self): """ Reset the counter used to generate unique savepoint ids in this thread. """ self.savepoint_state = 0
[ "def", "clean_savepoints", "(", "self", ")", ":", "self", ".", "savepoint_state", "=", "0" ]
[ 371, 4 ]
[ 375, 32 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper._set_autocommit
(self, autocommit)
Backend-specific implementation to enable or disable autocommit.
Backend-specific implementation to enable or disable autocommit.
def _set_autocommit(self, autocommit): """ Backend-specific implementation to enable or disable autocommit. """ raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a _set_autocommit() method')
[ "def", "_set_autocommit", "(", "self", ",", "autocommit", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseWrapper may require a _set_autocommit() method'", ")" ]
[ 379, 4 ]
[ 383, 109 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.get_autocommit
(self)
Get the autocommit state.
Get the autocommit state.
def get_autocommit(self): """Get the autocommit state.""" self.ensure_connection() return self.autocommit
[ "def", "get_autocommit", "(", "self", ")", ":", "self", ".", "ensure_connection", "(", ")", "return", "self", ".", "autocommit" ]
[ 387, 4 ]
[ 390, 30 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.set_autocommit
(self, autocommit, force_begin_transaction_with_broken_autocommit=False)
Enable or disable autocommit. The usual way to start a transaction is to turn autocommit off. SQLite does not properly start a transaction when disabling autocommit. To avoid this buggy behavior and to actually enter a new transaction, an explicit BEGIN is required. Using ...
Enable or disable autocommit.
def set_autocommit(self, autocommit, force_begin_transaction_with_broken_autocommit=False): """ Enable or disable autocommit. The usual way to start a transaction is to turn autocommit off. SQLite does not properly start a transaction when disabling autocommit. To avoid this bug...
[ "def", "set_autocommit", "(", "self", ",", "autocommit", ",", "force_begin_transaction_with_broken_autocommit", "=", "False", ")", ":", "self", ".", "validate_no_atomic_block", "(", ")", "self", ".", "ensure_connection", "(", ")", "start_transaction_under_autocommit", "...
[ 392, 4 ]
[ 421, 62 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.get_rollback
(self)
Get the "needs rollback" flag -- for *advanced use* only.
Get the "needs rollback" flag -- for *advanced use* only.
def get_rollback(self): """Get the "needs rollback" flag -- for *advanced use* only.""" if not self.in_atomic_block: raise TransactionManagementError( "The rollback flag doesn't work outside of an 'atomic' block.") return self.needs_rollback
[ "def", "get_rollback", "(", "self", ")", ":", "if", "not", "self", ".", "in_atomic_block", ":", "raise", "TransactionManagementError", "(", "\"The rollback flag doesn't work outside of an 'atomic' block.\"", ")", "return", "self", ".", "needs_rollback" ]
[ 423, 4 ]
[ 428, 34 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.set_rollback
(self, rollback)
Set or unset the "needs rollback" flag -- for *advanced use* only.
Set or unset the "needs rollback" flag -- for *advanced use* only.
def set_rollback(self, rollback): """ Set or unset the "needs rollback" flag -- for *advanced use* only. """ if not self.in_atomic_block: raise TransactionManagementError( "The rollback flag doesn't work outside of an 'atomic' block.") self.needs_rollb...
[ "def", "set_rollback", "(", "self", ",", "rollback", ")", ":", "if", "not", "self", ".", "in_atomic_block", ":", "raise", "TransactionManagementError", "(", "\"The rollback flag doesn't work outside of an 'atomic' block.\"", ")", "self", ".", "needs_rollback", "=", "rol...
[ 430, 4 ]
[ 437, 38 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.validate_no_atomic_block
(self)
Raise an error if an atomic block is active.
Raise an error if an atomic block is active.
def validate_no_atomic_block(self): """Raise an error if an atomic block is active.""" if self.in_atomic_block: raise TransactionManagementError( "This is forbidden when an 'atomic' block is active.")
[ "def", "validate_no_atomic_block", "(", "self", ")", ":", "if", "self", ".", "in_atomic_block", ":", "raise", "TransactionManagementError", "(", "\"This is forbidden when an 'atomic' block is active.\"", ")" ]
[ 439, 4 ]
[ 443, 70 ]
python
en
['en', 'lb', 'en']
True
BaseDatabaseWrapper.constraint_checks_disabled
(self)
Disable foreign key constraint checking.
Disable foreign key constraint checking.
def constraint_checks_disabled(self): """ Disable foreign key constraint checking. """ disabled = self.disable_constraint_checking() try: yield finally: if disabled: self.enable_constraint_checking()
[ "def", "constraint_checks_disabled", "(", "self", ")", ":", "disabled", "=", "self", ".", "disable_constraint_checking", "(", ")", "try", ":", "yield", "finally", ":", "if", "disabled", ":", "self", ".", "enable_constraint_checking", "(", ")" ]
[ 454, 4 ]
[ 463, 49 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.disable_constraint_checking
(self)
Backends can implement as needed to temporarily disable foreign key constraint checking. Should return True if the constraints were disabled and will need to be reenabled.
Backends can implement as needed to temporarily disable foreign key constraint checking. Should return True if the constraints were disabled and will need to be reenabled.
def disable_constraint_checking(self): """ Backends can implement as needed to temporarily disable foreign key constraint checking. Should return True if the constraints were disabled and will need to be reenabled. """ return False
[ "def", "disable_constraint_checking", "(", "self", ")", ":", "return", "False" ]
[ 465, 4 ]
[ 471, 20 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.enable_constraint_checking
(self)
Backends can implement as needed to re-enable foreign key constraint checking.
Backends can implement as needed to re-enable foreign key constraint checking.
def enable_constraint_checking(self): """ Backends can implement as needed to re-enable foreign key constraint checking. """ pass
[ "def", "enable_constraint_checking", "(", "self", ")", ":", "pass" ]
[ 473, 4 ]
[ 478, 12 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.check_constraints
(self, table_names=None)
Backends can override this method if they can apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE"). Should raise an IntegrityError if any invalid foreign key references are encountered.
Backends can override this method if they can apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE"). Should raise an IntegrityError if any invalid foreign key references are encountered.
def check_constraints(self, table_names=None): """ Backends can override this method if they can apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE"). Should raise an IntegrityError if any invalid foreign key references are encountered. """ pass
[ "def", "check_constraints", "(", "self", ",", "table_names", "=", "None", ")", ":", "pass" ]
[ 480, 4 ]
[ 486, 12 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.is_usable
(self)
Test if the database connection is usable. This method may assume that self.connection is not None. Actual implementations should take care not to raise exceptions as that may prevent Django from recycling unusable connections.
Test if the database connection is usable.
def is_usable(self): """ Test if the database connection is usable. This method may assume that self.connection is not None. Actual implementations should take care not to raise exceptions as that may prevent Django from recycling unusable connections. """ raise...
[ "def", "is_usable", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "\"subclasses of BaseDatabaseWrapper may require an is_usable() method\"", ")" ]
[ 490, 4 ]
[ 500, 82 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.close_if_unusable_or_obsolete
(self)
Close the current connection if unrecoverable errors have occurred or if it outlived its maximum age.
Close the current connection if unrecoverable errors have occurred or if it outlived its maximum age.
def close_if_unusable_or_obsolete(self): """ Close the current connection if unrecoverable errors have occurred or if it outlived its maximum age. """ if self.connection is not None: # If the application didn't restore the original autocommit setting, # do...
[ "def", "close_if_unusable_or_obsolete", "(", "self", ")", ":", "if", "self", ".", "connection", "is", "not", "None", ":", "# If the application didn't restore the original autocommit setting,", "# don't take chances, drop the connection.", "if", "self", ".", "get_autocommit", ...
[ 502, 4 ]
[ 525, 22 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.validate_thread_sharing
(self)
Validate that the connection isn't accessed by another thread than the one which originally created it, unless the connection was explicitly authorized to be shared between threads (via the `inc_thread_sharing()` method). Raise an exception if the validation fails.
Validate that the connection isn't accessed by another thread than the one which originally created it, unless the connection was explicitly authorized to be shared between threads (via the `inc_thread_sharing()` method). Raise an exception if the validation fails.
def validate_thread_sharing(self): """ Validate that the connection isn't accessed by another thread than the one which originally created it, unless the connection was explicitly authorized to be shared between threads (via the `inc_thread_sharing()` method). Raise an exception ...
[ "def", "validate_thread_sharing", "(", "self", ")", ":", "if", "not", "(", "self", ".", "allow_thread_sharing", "or", "self", ".", "_thread_ident", "==", "_thread", ".", "get_ident", "(", ")", ")", ":", "raise", "DatabaseError", "(", "\"DatabaseWrapper objects c...
[ 544, 4 ]
[ 558, 13 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.prepare_database
(self)
Hook to do any database check or preparation, generally called before migrating a project or an app.
Hook to do any database check or preparation, generally called before migrating a project or an app.
def prepare_database(self): """ Hook to do any database check or preparation, generally called before migrating a project or an app. """ pass
[ "def", "prepare_database", "(", "self", ")", ":", "pass" ]
[ 562, 4 ]
[ 567, 12 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.wrap_database_errors
(self)
Context manager and decorator that re-throws backend-specific database exceptions using Django's common wrappers.
Context manager and decorator that re-throws backend-specific database exceptions using Django's common wrappers.
def wrap_database_errors(self): """ Context manager and decorator that re-throws backend-specific database exceptions using Django's common wrappers. """ return DatabaseErrorWrapper(self)
[ "def", "wrap_database_errors", "(", "self", ")", ":", "return", "DatabaseErrorWrapper", "(", "self", ")" ]
[ 570, 4 ]
[ 575, 41 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.chunked_cursor
(self)
Return a cursor that tries to avoid caching in the database (if supported by the database), otherwise return a regular cursor.
Return a cursor that tries to avoid caching in the database (if supported by the database), otherwise return a regular cursor.
def chunked_cursor(self): """ Return a cursor that tries to avoid caching in the database (if supported by the database), otherwise return a regular cursor. """ return self.cursor()
[ "def", "chunked_cursor", "(", "self", ")", ":", "return", "self", ".", "cursor", "(", ")" ]
[ 577, 4 ]
[ 582, 28 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.make_debug_cursor
(self, cursor)
Create a cursor that logs all queries in self.queries_log.
Create a cursor that logs all queries in self.queries_log.
def make_debug_cursor(self, cursor): """Create a cursor that logs all queries in self.queries_log.""" return utils.CursorDebugWrapper(cursor, self)
[ "def", "make_debug_cursor", "(", "self", ",", "cursor", ")", ":", "return", "utils", ".", "CursorDebugWrapper", "(", "cursor", ",", "self", ")" ]
[ 584, 4 ]
[ 586, 53 ]
python
en
['en', 'gd', 'en']
True
BaseDatabaseWrapper.make_cursor
(self, cursor)
Create a cursor without debug logging.
Create a cursor without debug logging.
def make_cursor(self, cursor): """Create a cursor without debug logging.""" return utils.CursorWrapper(cursor, self)
[ "def", "make_cursor", "(", "self", ",", "cursor", ")", ":", "return", "utils", ".", "CursorWrapper", "(", "cursor", ",", "self", ")" ]
[ 588, 4 ]
[ 590, 48 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseWrapper.temporary_connection
(self)
Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. Provide a cursor: with self.temporary_connection() as cursor: ...
Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle.
def temporary_connection(self): """ Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. Provide a cursor: with self.temporary_c...
[ "def", "temporary_connection", "(", "self", ")", ":", "must_close", "=", "self", ".", "connection", "is", "None", "try", ":", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "yield", "cursor", "finally", ":", "if", "must_close", ":", "self"...
[ 593, 4 ]
[ 607, 28 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper._nodb_connection
(self)
Return an alternative connection to be used when there is no need to access the main database, specifically for test db creation/deletion. This also prevents the production database from being exposed to potential child threads while (or after) the test database is destroyed. Re...
Return an alternative connection to be used when there is no need to access the main database, specifically for test db creation/deletion. This also prevents the production database from being exposed to potential child threads while (or after) the test database is destroyed. Re...
def _nodb_connection(self): """ Return an alternative connection to be used when there is no need to access the main database, specifically for test db creation/deletion. This also prevents the production database from being exposed to potential child threads while (or after) the...
[ "def", "_nodb_connection", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "{", "*", "*", "self", ".", "settings_dict", ",", "'NAME'", ":", "None", "}", ",", "alias", "=", "NO_DB_ALIAS", ")" ]
[ 610, 4 ]
[ 618, 86 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.schema_editor
(self, *args, **kwargs)
Return a new instance of this backend's SchemaEditor.
Return a new instance of this backend's SchemaEditor.
def schema_editor(self, *args, **kwargs): """ Return a new instance of this backend's SchemaEditor. """ if self.SchemaEditorClass is None: raise NotImplementedError( 'The SchemaEditorClass attribute of this database wrapper is still None') return self....
[ "def", "schema_editor", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "SchemaEditorClass", "is", "None", ":", "raise", "NotImplementedError", "(", "'The SchemaEditorClass attribute of this database wrapper is still None'", ")", ...
[ 620, 4 ]
[ 627, 60 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.execute_wrapper
(self, wrapper)
Return a context manager under which the wrapper is applied to suitable database query executions.
Return a context manager under which the wrapper is applied to suitable database query executions.
def execute_wrapper(self, wrapper): """ Return a context manager under which the wrapper is applied to suitable database query executions. """ self.execute_wrappers.append(wrapper) try: yield finally: self.execute_wrappers.pop()
[ "def", "execute_wrapper", "(", "self", ",", "wrapper", ")", ":", "self", ".", "execute_wrappers", ".", "append", "(", "wrapper", ")", "try", ":", "yield", "finally", ":", "self", ".", "execute_wrappers", ".", "pop", "(", ")" ]
[ 649, 4 ]
[ 658, 39 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.copy
(self, alias=None)
Return a copy of this connection. For tests that require two connections to the same database.
Return a copy of this connection.
def copy(self, alias=None): """ Return a copy of this connection. For tests that require two connections to the same database. """ settings_dict = copy.deepcopy(self.settings_dict) if alias is None: alias = self.alias return type(self)(settings_dict, ...
[ "def", "copy", "(", "self", ",", "alias", "=", "None", ")", ":", "settings_dict", "=", "copy", ".", "deepcopy", "(", "self", ".", "settings_dict", ")", "if", "alias", "is", "None", ":", "alias", "=", "self", ".", "alias", "return", "type", "(", "self...
[ 660, 4 ]
[ 669, 47 ]
python
en
['en', 'error', 'th']
False
TemporaryUploadedFile.temporary_file_path
(self)
Returns the full path of this file.
Returns the full path of this file.
def temporary_file_path(self): """ Returns the full path of this file. """ return self.file.name
[ "def", "temporary_file_path", "(", "self", ")", ":", "return", "self", ".", "file", ".", "name" ]
[ 70, 4 ]
[ 74, 29 ]
python
en
['en', 'error', 'th']
False
SimpleUploadedFile.from_dict
(cls, file_dict)
Creates a SimpleUploadedFile object from a dictionary object with the following keys: - filename - content-type - content
Creates a SimpleUploadedFile object from a dictionary object with the following keys: - filename - content-type - content
def from_dict(cls, file_dict): """ Creates a SimpleUploadedFile object from a dictionary object with the following keys: - filename - content-type - content """ return cls(file_dict['filename'], file_dict['content'], ...
[ "def", "from_dict", "(", "cls", ",", "file_dict", ")", ":", "return", "cls", "(", "file_dict", "[", "'filename'", "]", ",", "file_dict", "[", "'content'", "]", ",", "file_dict", ".", "get", "(", "'content-type'", ",", "'text/plain'", ")", ")" ]
[ 117, 4 ]
[ 127, 63 ]
python
en
['en', 'error', 'th']
False
conv_2d
(filters, kernel_shape, strides, padding, input_shape=None)
Defines the right convolutional layer according to the version of Keras that is installed. :param filters: (required integer) the dimensionality of the output space (i.e. the number output of filters in the convolution) :param kernel_shape: (required tuple or lis...
Defines the right convolutional layer according to the version of Keras that is installed. :param filters: (required integer) the dimensionality of the output space (i.e. the number output of filters in the convolution) :param kernel_shape: (required tuple or lis...
def conv_2d(filters, kernel_shape, strides, padding, input_shape=None): """ Defines the right convolutional layer according to the version of Keras that is installed. :param filters: (required integer) the dimensionality of the output space (i.e. the number output of filters in the ...
[ "def", "conv_2d", "(", "filters", ",", "kernel_shape", ",", "strides", ",", "padding", ",", "input_shape", "=", "None", ")", ":", "if", "input_shape", "is", "not", "None", ":", "return", "Conv2D", "(", "filters", "=", "filters", ",", "kernel_size", "=", ...
[ 19, 0 ]
[ 49, 9 ]
python
en
['en', 'error', 'th']
False
cnn_model
( logits=False, input_ph=None, img_rows=28, img_cols=28, channels=1, nb_filters=64, nb_classes=10, )
Defines a CNN model using Keras sequential model :param logits: If set to False, returns a Keras model, otherwise will also return logits tensor :param input_ph: The TensorFlow tensor for the input (needed if returning logits) ("ph" stands for pla...
Defines a CNN model using Keras sequential model :param logits: If set to False, returns a Keras model, otherwise will also return logits tensor :param input_ph: The TensorFlow tensor for the input (needed if returning logits) ("ph" stands for pla...
def cnn_model( logits=False, input_ph=None, img_rows=28, img_cols=28, channels=1, nb_filters=64, nb_classes=10, ): """ Defines a CNN model using Keras sequential model :param logits: If set to False, returns a Keras model, otherwise will also return logits ten...
[ "def", "cnn_model", "(", "logits", "=", "False", ",", "input_ph", "=", "None", ",", "img_rows", "=", "28", ",", "img_cols", "=", "28", ",", "channels", "=", "1", ",", "nb_filters", "=", "64", ",", "nb_classes", "=", "10", ",", ")", ":", "model", "=...
[ 52, 0 ]
[ 106, 20 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper.__init__
(self, model)
Create a wrapper for a Keras model :param model: A Keras model
Create a wrapper for a Keras model :param model: A Keras model
def __init__(self, model): """ Create a wrapper for a Keras model :param model: A Keras model """ super(KerasModelWrapper, self).__init__(None, None, {}) if model is None: raise ValueError("model argument must be supplied.") self.model = model ...
[ "def", "__init__", "(", "self", ",", "model", ")", ":", "super", "(", "KerasModelWrapper", ",", "self", ")", ".", "__init__", "(", "None", ",", "None", ",", "{", "}", ")", "if", "model", "is", "None", ":", "raise", "ValueError", "(", "\"model argument ...
[ 117, 4 ]
[ 128, 31 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper._get_softmax_name
(self)
Looks for the name of the softmax layer. :return: Softmax layer name
Looks for the name of the softmax layer. :return: Softmax layer name
def _get_softmax_name(self): """ Looks for the name of the softmax layer. :return: Softmax layer name """ for layer in self.model.layers: cfg = layer.get_config() if "activation" in cfg and cfg["activation"] == "softmax": return layer.name ...
[ "def", "_get_softmax_name", "(", "self", ")", ":", "for", "layer", "in", "self", ".", "model", ".", "layers", ":", "cfg", "=", "layer", ".", "get_config", "(", ")", "if", "\"activation\"", "in", "cfg", "and", "cfg", "[", "\"activation\"", "]", "==", "\...
[ 130, 4 ]
[ 140, 50 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper._get_abstract_layer_name
(self)
Looks for the name of abstracted layer. Usually these layers appears when model is stacked. :return: List of abstracted layers
Looks for the name of abstracted layer. Usually these layers appears when model is stacked. :return: List of abstracted layers
def _get_abstract_layer_name(self): """ Looks for the name of abstracted layer. Usually these layers appears when model is stacked. :return: List of abstracted layers """ abstract_layers = [] for layer in self.model.layers: if "layers" in layer.get_con...
[ "def", "_get_abstract_layer_name", "(", "self", ")", ":", "abstract_layers", "=", "[", "]", "for", "layer", "in", "self", ".", "model", ".", "layers", ":", "if", "\"layers\"", "in", "layer", ".", "get_config", "(", ")", ":", "abstract_layers", ".", "append...
[ 142, 4 ]
[ 153, 30 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper._get_logits_name
(self)
Looks for the name of the layer producing the logits. :return: name of layer producing the logits
Looks for the name of the layer producing the logits. :return: name of layer producing the logits
def _get_logits_name(self): """ Looks for the name of the layer producing the logits. :return: name of layer producing the logits """ softmax_name = self._get_softmax_name() softmax_layer = self.model.get_layer(softmax_name) if not isinstance(softmax_layer, Activ...
[ "def", "_get_logits_name", "(", "self", ")", ":", "softmax_name", "=", "self", ".", "_get_softmax_name", "(", ")", "softmax_layer", "=", "self", ".", "model", ".", "get_layer", "(", "softmax_name", ")", "if", "not", "isinstance", "(", "softmax_layer", ",", "...
[ 155, 4 ]
[ 177, 26 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper.get_logits
(self, x)
:param x: A symbolic representation of the network input. :return: A symbolic representation of the logits
:param x: A symbolic representation of the network input. :return: A symbolic representation of the logits
def get_logits(self, x): """ :param x: A symbolic representation of the network input. :return: A symbolic representation of the logits """ logits_name = self._get_logits_name() logits_layer = self.get_layer(x, logits_name) # Need to deal with the case where soft...
[ "def", "get_logits", "(", "self", ",", "x", ")", ":", "logits_name", "=", "self", ".", "_get_logits_name", "(", ")", "logits_layer", "=", "self", ".", "get_layer", "(", "x", ",", "logits_name", ")", "# Need to deal with the case where softmax is part of the", "# l...
[ 179, 4 ]
[ 195, 27 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper.get_probs
(self, x)
:param x: A symbolic representation of the network input. :return: A symbolic representation of the probs
:param x: A symbolic representation of the network input. :return: A symbolic representation of the probs
def get_probs(self, x): """ :param x: A symbolic representation of the network input. :return: A symbolic representation of the probs """ name = self._get_softmax_name() return self.get_layer(x, name)
[ "def", "get_probs", "(", "self", ",", "x", ")", ":", "name", "=", "self", ".", "_get_softmax_name", "(", ")", "return", "self", ".", "get_layer", "(", "x", ",", "name", ")" ]
[ 197, 4 ]
[ 204, 38 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper.get_layer_names
(self)
:return: Names of all the layers kept by Keras
:return: Names of all the layers kept by Keras
def get_layer_names(self): """ :return: Names of all the layers kept by Keras """ layer_names = [x.name for x in self.model.layers] return layer_names
[ "def", "get_layer_names", "(", "self", ")", ":", "layer_names", "=", "[", "x", ".", "name", "for", "x", "in", "self", ".", "model", ".", "layers", "]", "return", "layer_names" ]
[ 206, 4 ]
[ 211, 26 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper.fprop
(self, x)
Exposes all the layers of the model returned by get_layer_names. :param x: A symbolic representation of the network input :return: A dictionary mapping layer names to the symbolic representation of their output.
Exposes all the layers of the model returned by get_layer_names. :param x: A symbolic representation of the network input :return: A dictionary mapping layer names to the symbolic representation of their output.
def fprop(self, x): """ Exposes all the layers of the model returned by get_layer_names. :param x: A symbolic representation of the network input :return: A dictionary mapping layer names to the symbolic representation of their output. """ if self.keras_...
[ "def", "fprop", "(", "self", ",", "x", ")", ":", "if", "self", ".", "keras_model", "is", "None", ":", "# Get the input layer", "new_input", "=", "self", ".", "model", ".", "get_input_at", "(", "0", ")", "# Make a new model that returns each of the layers as output...
[ 213, 4 ]
[ 255, 25 ]
python
en
['en', 'error', 'th']
False
KerasModelWrapper.get_layer
(self, x, layer)
Expose the hidden features of a model given a layer name. :param x: A symbolic representation of the network input :param layer: The name of the hidden layer to return features at. :return: A symbolic representation of the hidden features :raise: NoSuchLayerError if `layer` is n...
Expose the hidden features of a model given a layer name. :param x: A symbolic representation of the network input :param layer: The name of the hidden layer to return features at. :return: A symbolic representation of the hidden features :raise: NoSuchLayerError if `layer` is n...
def get_layer(self, x, layer): """ Expose the hidden features of a model given a layer name. :param x: A symbolic representation of the network input :param layer: The name of the hidden layer to return features at. :return: A symbolic representation of the hidden features ...
[ "def", "get_layer", "(", "self", ",", "x", ",", "layer", ")", ":", "# Return the symbolic representation for this layer.", "output", "=", "self", ".", "fprop", "(", "x", ")", "try", ":", "requested", "=", "output", "[", "layer", "]", "except", "KeyError", ":...
[ 257, 4 ]
[ 271, 24 ]
python
en
['en', 'error', 'th']
False
render_curl_example
( function: str, api_url: str, exclude: Optional[List[str]] = None, include: Optional[List[str]] = None, )
A simple wrapper around generate_curl_example.
A simple wrapper around generate_curl_example.
def render_curl_example( function: str, api_url: str, exclude: Optional[List[str]] = None, include: Optional[List[str]] = None, ) -> List[str]: """ A simple wrapper around generate_curl_example. """ parts = function.split(":") endpoint = parts[0] method = parts[1] kwargs: Dict[str, A...
[ "def", "render_curl_example", "(", "function", ":", "str", ",", "api_url", ":", "str", ",", "exclude", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "include", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ...
[ 333, 0 ]
[ 351, 60 ]
python
en
['de', 'en', 'en']
True
conditional_content_removal
(request, response)
Simulate the behavior of most Web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensure compliance with RFC 7230, section 3.3.3.
Simulate the behavior of most Web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensure compliance with RFC 7230, section 3.3.3.
def conditional_content_removal(request, response): """ Simulate the behavior of most Web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensure compliance with RFC 7230, section 3.3.3. """ if 100 <= response.status_code < 200 or response.status_code ...
[ "def", "conditional_content_removal", "(", "request", ",", "response", ")", ":", "if", "100", "<=", "response", ".", "status_code", "<", "200", "or", "response", ".", "status_code", "in", "(", "204", ",", "304", ")", ":", "if", "response", ".", "streaming"...
[ 92, 0 ]
[ 108, 19 ]
python
en
['en', 'error', 'th']
False
store_rendered_templates
(store, signal, sender, template, context, **kwargs)
Store templates and contexts that are rendered. The context is copied so that it is an accurate representation at the time of rendering.
Store templates and contexts that are rendered.
def store_rendered_templates(store, signal, sender, template, context, **kwargs): """ Store templates and contexts that are rendered. The context is copied so that it is an accurate representation at the time of rendering. """ store.setdefault('templates', []).append(template) if 'context' ...
[ "def", "store_rendered_templates", "(", "store", ",", "signal", ",", "sender", ",", "template", ",", "context", ",", "*", "*", "kwargs", ")", ":", "store", ".", "setdefault", "(", "'templates'", ",", "[", "]", ")", ".", "append", "(", "template", ")", ...
[ 159, 0 ]
[ 169, 42 ]
python
en
['en', 'error', 'th']
False
encode_multipart
(boundary, data)
Encode multipart POST data from a dictionary of form values. The key will be used as the form data name; the value will be transmitted as content. If the value is a file, the contents of the file will be sent as an application/octet-stream; otherwise, str(value) will be sent.
Encode multipart POST data from a dictionary of form values.
def encode_multipart(boundary, data): """ Encode multipart POST data from a dictionary of form values. The key will be used as the form data name; the value will be transmitted as content. If the value is a file, the contents of the file will be sent as an application/octet-stream; otherwise, str(v...
[ "def", "encode_multipart", "(", "boundary", ",", "data", ")", ":", "lines", "=", "[", "]", "def", "to_bytes", "(", "s", ")", ":", "return", "force_bytes", "(", "s", ",", "settings", ".", "DEFAULT_CHARSET", ")", "# Not by any means perfect, but good enough for ou...
[ 172, 0 ]
[ 223, 30 ]
python
en
['en', 'error', 'th']
False
RequestFactory._base_environ
(self, **request)
The base environment for a request.
The base environment for a request.
def _base_environ(self, **request): """ The base environment for a request. """ # This is a minimal valid WSGI environ dictionary, plus: # - HTTP_COOKIE: for cookie support, # - REMOTE_ADDR: often useful, see #8551. # See https://www.python.org/dev/peps/pep-3333/#...
[ "def", "_base_environ", "(", "self", ",", "*", "*", "request", ")", ":", "# This is a minimal valid WSGI environ dictionary, plus:", "# - HTTP_COOKIE: for cookie support,", "# - REMOTE_ADDR: often useful, see #8551.", "# See https://www.python.org/dev/peps/pep-3333/#environ-variables", "...
[ 274, 4 ]
[ 303, 9 ]
python
en
['en', 'error', 'th']
False
RequestFactory.request
(self, **request)
Construct a generic request object.
Construct a generic request object.
def request(self, **request): "Construct a generic request object." return WSGIRequest(self._base_environ(**request))
[ "def", "request", "(", "self", ",", "*", "*", "request", ")", ":", "return", "WSGIRequest", "(", "self", ".", "_base_environ", "(", "*", "*", "request", ")", ")" ]
[ 305, 4 ]
[ 307, 57 ]
python
en
['en', 'en', 'en']
True
RequestFactory._encode_json
(self, data, content_type)
Return encoded JSON if data is a dict, list, or tuple and content_type is application/json.
Return encoded JSON if data is a dict, list, or tuple and content_type is application/json.
def _encode_json(self, data, content_type): """ Return encoded JSON if data is a dict, list, or tuple and content_type is application/json. """ should_encode = JSON_CONTENT_TYPE_RE.match(content_type) and isinstance(data, (dict, list, tuple)) return json.dumps(data, cls=s...
[ "def", "_encode_json", "(", "self", ",", "data", ",", "content_type", ")", ":", "should_encode", "=", "JSON_CONTENT_TYPE_RE", ".", "match", "(", "content_type", ")", "and", "isinstance", "(", "data", ",", "(", "dict", ",", "list", ",", "tuple", ")", ")", ...
[ 321, 4 ]
[ 327, 81 ]
python
en
['en', 'error', 'th']
False
RequestFactory.get
(self, path, data=None, secure=False, **extra)
Construct a GET request.
Construct a GET request.
def get(self, path, data=None, secure=False, **extra): """Construct a GET request.""" data = {} if data is None else data return self.generic('GET', path, secure=secure, **{ 'QUERY_STRING': urlencode(data, doseq=True), **extra, })
[ "def", "get", "(", "self", ",", "path", ",", "data", "=", "None", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "{", "}", "if", "data", "is", "None", "else", "data", "return", "self", ".", "generic", "(", "'GET'", ...
[ 340, 4 ]
[ 346, 10 ]
python
en
['en', 'en', 'en']
True
RequestFactory.post
(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False, **extra)
Construct a POST request.
Construct a POST request.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False, **extra): """Construct a POST request.""" data = self._encode_json({} if data is None else data, content_type) post_data = self._encode_data(data, content_type) return self.generic('POST', path, p...
[ "def", "post", "(", "self", ",", "path", ",", "data", "=", "None", ",", "content_type", "=", "MULTIPART_CONTENT", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "self", ".", "_encode_json", "(", "{", "}", "if", "data", ...
[ 348, 4 ]
[ 355, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.head
(self, path, data=None, secure=False, **extra)
Construct a HEAD request.
Construct a HEAD request.
def head(self, path, data=None, secure=False, **extra): """Construct a HEAD request.""" data = {} if data is None else data return self.generic('HEAD', path, secure=secure, **{ 'QUERY_STRING': urlencode(data, doseq=True), **extra, })
[ "def", "head", "(", "self", ",", "path", ",", "data", "=", "None", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "{", "}", "if", "data", "is", "None", "else", "data", "return", "self", ".", "generic", "(", "'HEAD'", ...
[ 357, 4 ]
[ 363, 10 ]
python
en
['en', 'en', 'en']
True
RequestFactory.trace
(self, path, secure=False, **extra)
Construct a TRACE request.
Construct a TRACE request.
def trace(self, path, secure=False, **extra): """Construct a TRACE request.""" return self.generic('TRACE', path, secure=secure, **extra)
[ "def", "trace", "(", "self", ",", "path", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'TRACE'", ",", "path", ",", "secure", "=", "secure", ",", "*", "*", "extra", ")" ]
[ 365, 4 ]
[ 367, 66 ]
python
en
['en', 'en', 'en']
True
RequestFactory.options
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct an OPTIONS request.
Construct an OPTIONS request.
def options(self, path, data='', content_type='application/octet-stream', secure=False, **extra): "Construct an OPTIONS request." return self.generic('OPTIONS', path, data, content_type, secure=secure, **extra)
[ "def", "options", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'OPTIONS'", ",", "path", ...
[ 369, 4 ]
[ 373, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.put
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct a PUT request.
Construct a PUT request.
def put(self, path, data='', content_type='application/octet-stream', secure=False, **extra): """Construct a PUT request.""" data = self._encode_json(data, content_type) return self.generic('PUT', path, data, content_type, secure=secure, **extra)
[ "def", "put", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "self", ".", "_encode_json", "(", "data", ",", "content_...
[ 375, 4 ]
[ 380, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.patch
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct a PATCH request.
Construct a PATCH request.
def patch(self, path, data='', content_type='application/octet-stream', secure=False, **extra): """Construct a PATCH request.""" data = self._encode_json(data, content_type) return self.generic('PATCH', path, data, content_type, secure=secure, **extra)
[ "def", "patch", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "self", ".", "_encode_json", "(", "data", ",", "conten...
[ 382, 4 ]
[ 387, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.delete
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct a DELETE request.
Construct a DELETE request.
def delete(self, path, data='', content_type='application/octet-stream', secure=False, **extra): """Construct a DELETE request.""" data = self._encode_json(data, content_type) return self.generic('DELETE', path, data, content_type, secure=secure, **extr...
[ "def", "delete", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "self", ".", "_encode_json", "(", "data", ",", "conte...
[ 389, 4 ]
[ 394, 51 ]
python
en
['en', 'it', 'en']
True
RequestFactory.generic
(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct an arbitrary HTTP request.
Construct an arbitrary HTTP request.
def generic(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra): """Construct an arbitrary HTTP request.""" parsed = urlparse(str(path)) # path can be lazy data = force_bytes(data, settings.DEFAULT_CHARSET) r = { ...
[ "def", "generic", "(", "self", ",", "method", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "parsed", "=", "urlparse", "(", "str", "(", "path"...
[ 396, 4 ]
[ 420, 32 ]
python
en
['en', 'en', 'en']
True
Client.store_exc_info
(self, **kwargs)
Store exceptions when they are generated by a view.
Store exceptions when they are generated by a view.
def store_exc_info(self, **kwargs): """Store exceptions when they are generated by a view.""" self.exc_info = sys.exc_info()
[ "def", "store_exc_info", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "exc_info", "=", "sys", ".", "exc_info", "(", ")" ]
[ 447, 4 ]
[ 449, 38 ]
python
en
['en', 'en', 'en']
True
Client.session
(self)
Return the current session variables.
Return the current session variables.
def session(self): """Return the current session variables.""" engine = import_module(settings.SESSION_ENGINE) cookie = self.cookies.get(settings.SESSION_COOKIE_NAME) if cookie: return engine.SessionStore(cookie.value) session = engine.SessionStore() session....
[ "def", "session", "(", "self", ")", ":", "engine", "=", "import_module", "(", "settings", ".", "SESSION_ENGINE", ")", "cookie", "=", "self", ".", "cookies", ".", "get", "(", "settings", ".", "SESSION_COOKIE_NAME", ")", "if", "cookie", ":", "return", "engin...
[ 452, 4 ]
[ 462, 22 ]
python
en
['en', 'en', 'en']
True
Client.request
(self, **request)
The master request method. Compose the environment dictionary and pass to the handler, return the result of the handler. Assume defaults for the query environment, which can be overridden using the arguments to the request.
The master request method. Compose the environment dictionary and pass to the handler, return the result of the handler. Assume defaults for the query environment, which can be overridden using the arguments to the request.
def request(self, **request): """ The master request method. Compose the environment dictionary and pass to the handler, return the result of the handler. Assume defaults for the query environment, which can be overridden using the arguments to the request. """ en...
[ "def", "request", "(", "self", ",", "*", "*", "request", ")", ":", "environ", "=", "self", ".", "_base_environ", "(", "*", "*", "request", ")", "# Curry a data dictionary into an instance of the template renderer", "# callback function.", "data", "=", "{", "}", "o...
[ 464, 4 ]
[ 513, 23 ]
python
en
['en', 'error', 'th']
False
Client.get
(self, path, data=None, follow=False, secure=False, **extra)
Request a response from the server using GET.
Request a response from the server using GET.
def get(self, path, data=None, follow=False, secure=False, **extra): """Request a response from the server using GET.""" response = super().get(path, data=data, secure=secure, **extra) if follow: response = self._handle_redirects(response, data=data, **extra) return response
[ "def", "get", "(", "self", ",", "path", ",", "data", "=", "None", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ".", "get", "(", "path", ",", "data", "=", "data",...
[ 515, 4 ]
[ 520, 23 ]
python
en
['en', 'en', 'en']
True
Client.post
(self, path, data=None, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra)
Request a response from the server using POST.
Request a response from the server using POST.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra): """Request a response from the server using POST.""" response = super().post(path, data=data, content_type=content_type, secure=secure, **extra) if follow: response = se...
[ "def", "post", "(", "self", ",", "path", ",", "data", "=", "None", ",", "content_type", "=", "MULTIPART_CONTENT", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ".", "...
[ 522, 4 ]
[ 528, 23 ]
python
en
['en', 'en', 'en']
True
Client.head
(self, path, data=None, follow=False, secure=False, **extra)
Request a response from the server using HEAD.
Request a response from the server using HEAD.
def head(self, path, data=None, follow=False, secure=False, **extra): """Request a response from the server using HEAD.""" response = super().head(path, data=data, secure=secure, **extra) if follow: response = self._handle_redirects(response, data=data, **extra) return respon...
[ "def", "head", "(", "self", ",", "path", ",", "data", "=", "None", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ".", "head", "(", "path", ",", "data", "=", "data...
[ 530, 4 ]
[ 535, 23 ]
python
en
['en', 'en', 'en']
True
Client.options
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Request a response from the server using OPTIONS.
Request a response from the server using OPTIONS.
def options(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """Request a response from the server using OPTIONS.""" response = super().options(path, data=data, content_type=content_type, secure=secure, **extra) if follow: ...
[ "def", "options", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ...
[ 537, 4 ]
[ 543, 23 ]
python
en
['en', 'en', 'en']
True
Client.put
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Send a resource to the server using PUT.
Send a resource to the server using PUT.
def put(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """Send a resource to the server using PUT.""" response = super().put(path, data=data, content_type=content_type, secure=secure, **extra) if follow: response = self...
[ "def", "put", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", "....
[ 545, 4 ]
[ 551, 23 ]
python
en
['en', 'en', 'en']
True
Client.patch
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Send a resource to the server using PATCH.
Send a resource to the server using PATCH.
def patch(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """Send a resource to the server using PATCH.""" response = super().patch(path, data=data, content_type=content_type, secure=secure, **extra) if follow: respons...
[ "def", "patch", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ...
[ 553, 4 ]
[ 559, 23 ]
python
en
['en', 'en', 'en']
True
Client.delete
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Send a DELETE request to the server.
Send a DELETE request to the server.
def delete(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """Send a DELETE request to the server.""" response = super().delete(path, data=data, content_type=content_type, secure=secure, **extra) if follow: response =...
[ "def", "delete", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ...
[ 561, 4 ]
[ 567, 23 ]
python
en
['en', 'it', 'en']
True
Client.trace
(self, path, data='', follow=False, secure=False, **extra)
Send a TRACE request to the server.
Send a TRACE request to the server.
def trace(self, path, data='', follow=False, secure=False, **extra): """Send a TRACE request to the server.""" response = super().trace(path, data=data, secure=secure, **extra) if follow: response = self._handle_redirects(response, data=data, **extra) return response
[ "def", "trace", "(", "self", ",", "path", ",", "data", "=", "''", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", ")", ".", "trace", "(", "path", ",", "data", "=", "data...
[ 569, 4 ]
[ 574, 23 ]
python
en
['en', 'en', 'en']
True
Client.login
(self, **credentials)
Set the Factory to appear as if it has successfully logged into a site. Return True if login is possible; False if the provided credentials are incorrect.
Set the Factory to appear as if it has successfully logged into a site.
def login(self, **credentials): """ Set the Factory to appear as if it has successfully logged into a site. Return True if login is possible; False if the provided credentials are incorrect. """ from django.contrib.auth import authenticate user = authenticate(**c...
[ "def", "login", "(", "self", ",", "*", "*", "credentials", ")", ":", "from", "django", ".", "contrib", ".", "auth", "import", "authenticate", "user", "=", "authenticate", "(", "*", "*", "credentials", ")", "if", "user", ":", "self", ".", "_login", "(",...
[ 576, 4 ]
[ 589, 24 ]
python
en
['en', 'error', 'th']
False
Client.logout
(self)
Log out the user by removing the cookies and session object.
Log out the user by removing the cookies and session object.
def logout(self): """Log out the user by removing the cookies and session object.""" from django.contrib.auth import get_user, logout request = HttpRequest() engine = import_module(settings.SESSION_ENGINE) if self.session: request.session = self.session r...
[ "def", "logout", "(", "self", ")", ":", "from", "django", ".", "contrib", ".", "auth", "import", "get_user", ",", "logout", "request", "=", "HttpRequest", "(", ")", "engine", "=", "import_module", "(", "settings", ".", "SESSION_ENGINE", ")", "if", "self", ...
[ 631, 4 ]
[ 643, 37 ]
python
en
['en', 'en', 'en']
True
Client._handle_redirects
(self, response, data='', content_type='', **extra)
Follow any redirects by requesting responses from the server using GET.
Follow any redirects by requesting responses from the server using GET.
def _handle_redirects(self, response, data='', content_type='', **extra): """ Follow any redirects by requesting responses from the server using GET. """ response.redirect_chain = [] redirect_status_codes = ( HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.FOUND,...
[ "def", "_handle_redirects", "(", "self", ",", "response", ",", "data", "=", "''", ",", "content_type", "=", "''", ",", "*", "*", "extra", ")", ":", "response", ".", "redirect_chain", "=", "[", "]", "redirect_status_codes", "=", "(", "HTTPStatus", ".", "M...
[ 655, 4 ]
[ 706, 23 ]
python
en
['en', 'error', 'th']
False
_get_related_models
(m)
Return all models that have a direct relationship to the given model.
Return all models that have a direct relationship to the given model.
def _get_related_models(m): """Return all models that have a direct relationship to the given model.""" related_models = [ subclass for subclass in m.__subclasses__() if issubclass(subclass, models.Model) ] related_fields_models = set() for f in m._meta.get_fields(include_parents=Tru...
[ "def", "_get_related_models", "(", "m", ")", ":", "related_models", "=", "[", "subclass", "for", "subclass", "in", "m", ".", "__subclasses__", "(", ")", "if", "issubclass", "(", "subclass", ",", "models", ".", "Model", ")", "]", "related_fields_models", "=",...
[ 26, 0 ]
[ 42, 25 ]
python
en
['en', 'en', 'en']
True
get_related_models_tuples
(model)
Return a list of typical (app_label, model_name) tuples for all related models for the given model.
Return a list of typical (app_label, model_name) tuples for all related models for the given model.
def get_related_models_tuples(model): """ Return a list of typical (app_label, model_name) tuples for all related models for the given model. """ return { (rel_mod._meta.app_label, rel_mod._meta.model_name) for rel_mod in _get_related_models(model) }
[ "def", "get_related_models_tuples", "(", "model", ")", ":", "return", "{", "(", "rel_mod", ".", "_meta", ".", "app_label", ",", "rel_mod", ".", "_meta", ".", "model_name", ")", "for", "rel_mod", "in", "_get_related_models", "(", "model", ")", "}" ]
[ 45, 0 ]
[ 53, 5 ]
python
en
['en', 'error', 'th']
False
get_related_models_recursive
(model)
Return all models that have a direct or indirect relationship to the given model. Relationships are either defined by explicit relational fields, like ForeignKey, ManyToManyField or OneToOneField, or by inheriting from another model (a superclass is related to its subclasses, but not vice versa). ...
Return all models that have a direct or indirect relationship to the given model.
def get_related_models_recursive(model): """ Return all models that have a direct or indirect relationship to the given model. Relationships are either defined by explicit relational fields, like ForeignKey, ManyToManyField or OneToOneField, or by inheriting from another model (a superclass is ...
[ "def", "get_related_models_recursive", "(", "model", ")", ":", "seen", "=", "set", "(", ")", "queue", "=", "_get_related_models", "(", "model", ")", "for", "rel_mod", "in", "queue", ":", "rel_app_label", ",", "rel_model_name", "=", "rel_mod", ".", "_meta", "...
[ 56, 0 ]
[ 75, 67 ]
python
en
['en', 'error', 'th']
False
ProjectState.clone
(self)
Return an exact copy of this ProjectState.
Return an exact copy of this ProjectState.
def clone(self): """Return an exact copy of this ProjectState.""" new_state = ProjectState( models={k: v.clone() for k, v in self.models.items()}, real_apps=self.real_apps, ) if 'apps' in self.__dict__: new_state.apps = self.apps.clone() new_st...
[ "def", "clone", "(", "self", ")", ":", "new_state", "=", "ProjectState", "(", "models", "=", "{", "k", ":", "v", ".", "clone", "(", ")", "for", "k", ",", "v", "in", "self", ".", "models", ".", "items", "(", ")", "}", ",", "real_apps", "=", "sel...
[ 191, 4 ]
[ 200, 24 ]
python
en
['en', 'en', 'en']
True
ProjectState.from_apps
(cls, apps)
Take an Apps and return a ProjectState matching it.
Take an Apps and return a ProjectState matching it.
def from_apps(cls, apps): """Take an Apps and return a ProjectState matching it.""" app_models = {} for model in apps.get_models(include_swapped=True): model_state = ModelState.from_model(model) app_models[(model_state.app_label, model_state.name_lower)] = model_state ...
[ "def", "from_apps", "(", "cls", ",", "apps", ")", ":", "app_models", "=", "{", "}", "for", "model", "in", "apps", ".", "get_models", "(", "include_swapped", "=", "True", ")", ":", "model_state", "=", "ModelState", ".", "from_model", "(", "model", ")", ...
[ 216, 4 ]
[ 222, 30 ]
python
en
['en', 'en', 'en']
True
StateApps.clone
(self)
Return a clone of this registry.
Return a clone of this registry.
def clone(self): """Return a clone of this registry.""" clone = StateApps([], {}) clone.all_models = copy.deepcopy(self.all_models) clone.app_configs = copy.deepcopy(self.app_configs) # Set the pointer to the correct app registry. for app_config in clone.app_configs.value...
[ "def", "clone", "(", "self", ")", ":", "clone", "=", "StateApps", "(", "[", "]", ",", "{", "}", ")", "clone", ".", "all_models", "=", "copy", ".", "deepcopy", "(", "self", ".", "all_models", ")", "clone", ".", "app_configs", "=", "copy", ".", "deep...
[ 318, 4 ]
[ 328, 20 ]
python
en
['en', 'en', 'en']
True