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
LazySettings.__delattr__
(self, name)
Delete a setting and clear it from cache if needed.
Delete a setting and clear it from cache if needed.
def __delattr__(self, name): """Delete a setting and clear it from cache if needed.""" super().__delattr__(name) self.__dict__.pop(name, None)
[ "def", "__delattr__", "(", "self", ",", "name", ")", ":", "super", "(", ")", ".", "__delattr__", "(", "name", ")", "self", ".", "__dict__", ".", "pop", "(", "name", ",", "None", ")" ]
[ 91, 4 ]
[ 94, 37 ]
python
en
['en', 'en', 'en']
True
LazySettings.configure
(self, default_settings=global_settings, **options)
Called to manually configure the settings. The 'default_settings' parameter sets where to retrieve any unspecified values from (its argument must support attribute access (__getattr__)).
Called to manually configure the settings. The 'default_settings' parameter sets where to retrieve any unspecified values from (its argument must support attribute access (__getattr__)).
def configure(self, default_settings=global_settings, **options): """ Called to manually configure the settings. The 'default_settings' parameter sets where to retrieve any unspecified values from (its argument must support attribute access (__getattr__)). """ if self._wr...
[ "def", "configure", "(", "self", ",", "default_settings", "=", "global_settings", ",", "*", "*", "options", ")", ":", "if", "self", ".", "_wrapped", "is", "not", "empty", ":", "raise", "RuntimeError", "(", "'Settings already configured.'", ")", "holder", "=", ...
[ 96, 4 ]
[ 109, 30 ]
python
en
['en', 'error', 'th']
False
LazySettings.configured
(self)
Return True if the settings have already been configured.
Return True if the settings have already been configured.
def configured(self): """Return True if the settings have already been configured.""" return self._wrapped is not empty
[ "def", "configured", "(", "self", ")", ":", "return", "self", ".", "_wrapped", "is", "not", "empty" ]
[ 112, 4 ]
[ 114, 41 ]
python
en
['en', 'en', 'en']
True
UserSettingsHolder.__init__
(self, default_settings)
Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible).
Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible).
def __init__(self, default_settings): """ Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible). """ self.__dict__['_deleted'] = set() self.default_settings = default_settings
[ "def", "__init__", "(", "self", ",", "default_settings", ")", ":", "self", ".", "__dict__", "[", "'_deleted'", "]", "=", "set", "(", ")", "self", ".", "default_settings", "=", "default_settings" ]
[ 193, 4 ]
[ 199, 48 ]
python
en
['en', 'error', 'th']
False
Command.write_migration_files
(self, changes)
Take a changes dict and write them out as migration files.
Take a changes dict and write them out as migration files.
def write_migration_files(self, changes): """ Take a changes dict and write them out as migration files. """ directory_created = {} for app_label, app_migrations in changes.items(): if self.verbosity >= 1: self.stdout.write(self.style.MIGRATE_HEADING("...
[ "def", "write_migration_files", "(", "self", ",", "changes", ")", ":", "directory_created", "=", "{", "}", "for", "app_label", ",", "app_migrations", "in", "changes", ".", "items", "(", ")", ":", "if", "self", ".", "verbosity", ">=", "1", ":", "self", "....
[ 185, 4 ]
[ 228, 66 ]
python
en
['en', 'error', 'th']
False
Command.handle_merge
(self, loader, conflicts)
Handles merging together conflicted migrations interactively, if it's safe; otherwise, advises on how to fix it.
Handles merging together conflicted migrations interactively, if it's safe; otherwise, advises on how to fix it.
def handle_merge(self, loader, conflicts): """ Handles merging together conflicted migrations interactively, if it's safe; otherwise, advises on how to fix it. """ if self.interactive: questioner = InteractiveMigrationQuestioner() else: questioner ...
[ "def", "handle_merge", "(", "self", ",", "loader", ",", "conflicts", ")", ":", "if", "self", ".", "interactive", ":", "questioner", "=", "InteractiveMigrationQuestioner", "(", ")", "else", ":", "questioner", "=", "MigrationQuestioner", "(", "defaults", "=", "{...
[ 230, 4 ]
[ 309, 66 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTests.test_get_or_create_redundant_instance
(self)
If we execute the exact same statement twice, the second time, it won't create a Person.
If we execute the exact same statement twice, the second time, it won't create a Person.
def test_get_or_create_redundant_instance(self): """ If we execute the exact same statement twice, the second time, it won't create a Person. """ Person.objects.get_or_create( first_name='George', last_name='Harrison', defaults={ 'birthday': date(1943,...
[ "def", "test_get_or_create_redundant_instance", "(", "self", ")", ":", "Person", ".", "objects", ".", "get_or_create", "(", "first_name", "=", "'George'", ",", "last_name", "=", "'Harrison'", ",", "defaults", "=", "{", "'birthday'", ":", "date", "(", "1943", "...
[ 39, 4 ]
[ 56, 51 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTests.test_get_or_create_invalid_params
(self)
If you don't specify a value or default value for all required fields, you will get an error.
If you don't specify a value or default value for all required fields, you will get an error.
def test_get_or_create_invalid_params(self): """ If you don't specify a value or default value for all required fields, you will get an error. """ self.assertRaises( IntegrityError, Person.objects.get_or_create, first_name="Tom", last_name="Smith" ...
[ "def", "test_get_or_create_invalid_params", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "IntegrityError", ",", "Person", ".", "objects", ".", "get_or_create", ",", "first_name", "=", "\"Tom\"", ",", "last_name", "=", "\"Smith\"", ")" ]
[ 58, 4 ]
[ 66, 9 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTestsWithManualPKs.test_create_with_duplicate_primary_key
(self)
If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated.
If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated.
def test_create_with_duplicate_primary_key(self): """ If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated. """ self.assertRaises( IntegrityError, ManualPrimaryKeyTest.objects.get_or_cr...
[ "def", "test_create_with_duplicate_primary_key", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "IntegrityError", ",", "ManualPrimaryKeyTest", ".", "objects", ".", "get_or_create", ",", "id", "=", "1", ",", "data", "=", "\"Different\"", ")", "self", "....
[ 133, 4 ]
[ 142, 81 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTestsWithManualPKs.test_get_or_create_raises_IntegrityError_plus_traceback
(self)
get_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises here because we need to inspect the actual traceback. Refs #16340.
get_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises here because we need to inspect the actual traceback. Refs #16340.
def test_get_or_create_raises_IntegrityError_plus_traceback(self): """ get_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises here because we need to inspect the actua...
[ "def", "test_get_or_create_raises_IntegrityError_plus_traceback", "(", "self", ")", ":", "try", ":", "ManualPrimaryKeyTest", ".", "objects", ".", "get_or_create", "(", "id", "=", "1", ",", "data", "=", "\"Different\"", ")", "except", "IntegrityError", ":", "formatte...
[ 144, 4 ]
[ 155, 63 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTestsWithManualPKs.test_savepoint_rollback
(self)
Regression test for #20463: the database connection should still be usable after a DataError or ProgrammingError in .get_or_create().
Regression test for #20463: the database connection should still be usable after a DataError or ProgrammingError in .get_or_create().
def test_savepoint_rollback(self): """ Regression test for #20463: the database connection should still be usable after a DataError or ProgrammingError in .get_or_create(). """ try: # Hide warnings when broken data is saved with a warning (MySQL). with war...
[ "def", "test_savepoint_rollback", "(", "self", ")", ":", "try", ":", "# Hide warnings when broken data is saved with a warning (MySQL).", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "'ignore'", ")", "Person", ".", "o...
[ 157, 4 ]
[ 173, 63 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTestsWithManualPKs.test_get_or_create_empty
(self)
Regression test for #16137: get_or_create does not require kwargs.
Regression test for #16137: get_or_create does not require kwargs.
def test_get_or_create_empty(self): """ Regression test for #16137: get_or_create does not require kwargs. """ try: DefaultPerson.objects.get_or_create() except AssertionError: self.fail("If all the attributes on a model have defaults, we " ...
[ "def", "test_get_or_create_empty", "(", "self", ")", ":", "try", ":", "DefaultPerson", ".", "objects", ".", "get_or_create", "(", ")", "except", "AssertionError", ":", "self", ".", "fail", "(", "\"If all the attributes on a model have defaults, we \"", "\"shouldn't need...
[ 175, 4 ]
[ 183, 62 ]
python
en
['en', 'error', 'th']
False
GetOrCreateTransactionTests.test_get_or_create_integrityerror
(self)
Regression test for #15117. Requires a TransactionTestCase on databases that delay integrity checks until the end of transactions, otherwise the exception is never raised.
Regression test for #15117. Requires a TransactionTestCase on databases that delay integrity checks until the end of transactions, otherwise the exception is never raised.
def test_get_or_create_integrityerror(self): """ Regression test for #15117. Requires a TransactionTestCase on databases that delay integrity checks until the end of transactions, otherwise the exception is never raised. """ try: Profile.objects.get_or_create(...
[ "def", "test_get_or_create_integrityerror", "(", "self", ")", ":", "try", ":", "Profile", ".", "objects", ".", "get_or_create", "(", "person", "=", "Person", "(", "id", "=", "1", ")", ")", "except", "IntegrityError", ":", "pass", "else", ":", "self", ".", ...
[ 190, 4 ]
[ 201, 76 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_integrity
(self)
If you don't specify a value or default value for all required fields, you will get an error.
If you don't specify a value or default value for all required fields, you will get an error.
def test_integrity(self): """ If you don't specify a value or default value for all required fields, you will get an error. """ self.assertRaises(IntegrityError, Person.objects.update_or_create, first_name="Tom", last_name="Smith")
[ "def", "test_integrity", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "IntegrityError", ",", "Person", ".", "objects", ".", "update_or_create", ",", "first_name", "=", "\"Tom\"", ",", "last_name", "=", "\"Smith\"", ")" ]
[ 267, 4 ]
[ 273, 81 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_manual_primary_key_test
(self)
If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated.
If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated.
def test_manual_primary_key_test(self): """ If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated. """ ManualPrimaryKeyTest.objects.create(id=1, data="Original") self.assertRaises( Integrity...
[ "def", "test_manual_primary_key_test", "(", "self", ")", ":", "ManualPrimaryKeyTest", ".", "objects", ".", "create", "(", "id", "=", "1", ",", "data", "=", "\"Original\"", ")", "self", ".", "assertRaises", "(", "IntegrityError", ",", "ManualPrimaryKeyTest", ".",...
[ 275, 4 ]
[ 285, 81 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_error_contains_full_traceback
(self)
update_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises/assertRaises here because we need to inspect the actual traceback. Refs #16340.
update_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises/assertRaises here because we need to inspect the actual traceback. Refs #16340.
def test_error_contains_full_traceback(self): """ update_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises/assertRaises here because we need to inspect the actual tra...
[ "def", "test_error_contains_full_traceback", "(", "self", ")", ":", "try", ":", "ManualPrimaryKeyTest", ".", "objects", ".", "update_or_create", "(", "id", "=", "1", ",", "data", "=", "\"Different\"", ")", "except", "IntegrityError", ":", "formatted_traceback", "=...
[ 287, 4 ]
[ 298, 58 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_create_with_related_manager
(self)
Should be able to use update_or_create from the related manager to create a book. Refs #23611.
Should be able to use update_or_create from the related manager to create a book. Refs #23611.
def test_create_with_related_manager(self): """ Should be able to use update_or_create from the related manager to create a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") book, created = p.books.update_or_create(name="The Book of Ed & Fred") ...
[ "def", "test_create_with_related_manager", "(", "self", ")", ":", "p", "=", "Publisher", ".", "objects", ".", "create", "(", "name", "=", "\"Acme Publishing\"", ")", "book", ",", "created", "=", "p", ".", "books", ".", "update_or_create", "(", "name", "=", ...
[ 300, 4 ]
[ 308, 44 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_update_with_related_manager
(self)
Should be able to use update_or_create from the related manager to update a book. Refs #23611.
Should be able to use update_or_create from the related manager to update a book. Refs #23611.
def test_update_with_related_manager(self): """ Should be able to use update_or_create from the related manager to update a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") book = Book.objects.create(name="The Book of Ed & Fred", publisher=p) ...
[ "def", "test_update_with_related_manager", "(", "self", ")", ":", "p", "=", "Publisher", ".", "objects", ".", "create", "(", "name", "=", "\"Acme Publishing\"", ")", "book", "=", "Book", ".", "objects", ".", "create", "(", "name", "=", "\"The Book of Ed & Fred...
[ 310, 4 ]
[ 322, 44 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_create_with_many
(self)
Should be able to use update_or_create from the m2m related manager to create a book. Refs #23611.
Should be able to use update_or_create from the m2m related manager to create a book. Refs #23611.
def test_create_with_many(self): """ Should be able to use update_or_create from the m2m related manager to create a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") author = Author.objects.create(name="Ted") book, created = author.books...
[ "def", "test_create_with_many", "(", "self", ")", ":", "p", "=", "Publisher", ".", "objects", ".", "create", "(", "name", "=", "\"Acme Publishing\"", ")", "author", "=", "Author", ".", "objects", ".", "create", "(", "name", "=", "\"Ted\"", ")", "book", "...
[ 324, 4 ]
[ 333, 49 ]
python
en
['en', 'error', 'th']
False
UpdateOrCreateTests.test_update_with_many
(self)
Should be able to use update_or_create from the m2m related manager to update a book. Refs #23611.
Should be able to use update_or_create from the m2m related manager to update a book. Refs #23611.
def test_update_with_many(self): """ Should be able to use update_or_create from the m2m related manager to update a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") author = Author.objects.create(name="Ted") book = Book.objects.create(n...
[ "def", "test_update_with_many", "(", "self", ")", ":", "p", "=", "Publisher", ".", "objects", ".", "create", "(", "name", "=", "\"Acme Publishing\"", ")", "author", "=", "Author", ".", "objects", ".", "create", "(", "name", "=", "\"Ted\"", ")", "book", "...
[ 335, 4 ]
[ 349, 49 ]
python
en
['en', 'error', 'th']
False
HashedFilesMixin.file_hash
(self, name, content=None)
Return a hash of the file with the given name and optional content.
Return a hash of the file with the given name and optional content.
def file_hash(self, name, content=None): """ Return a hash of the file with the given name and optional content. """ if content is None: return None md5 = hashlib.md5() for chunk in content.chunks(): md5.update(chunk) return md5.hexdigest()...
[ "def", "file_hash", "(", "self", ",", "name", ",", "content", "=", "None", ")", ":", "if", "content", "is", "None", ":", "return", "None", "md5", "=", "hashlib", ".", "md5", "(", ")", "for", "chunk", "in", "content", ".", "chunks", "(", ")", ":", ...
[ 72, 4 ]
[ 81, 35 ]
python
en
['en', 'error', 'th']
False
HashedFilesMixin._url
(self, hashed_name_func, name, force=False, hashed_files=None)
Return the non-hashed URL in DEBUG mode.
Return the non-hashed URL in DEBUG mode.
def _url(self, hashed_name_func, name, force=False, hashed_files=None): """ Return the non-hashed URL in DEBUG mode. """ if settings.DEBUG and not force: hashed_name, fragment = name, '' else: clean_name, fragment = urldefrag(name) if urlsplit(...
[ "def", "_url", "(", "self", ",", "hashed_name_func", ",", "name", ",", "force", "=", "False", ",", "hashed_files", "=", "None", ")", ":", "if", "settings", ".", "DEBUG", "and", "not", "force", ":", "hashed_name", ",", "fragment", "=", "name", ",", "''"...
[ 117, 4 ]
[ 146, 33 ]
python
en
['en', 'error', 'th']
False
HashedFilesMixin.url
(self, name, force=False)
Return the non-hashed URL in DEBUG mode.
Return the non-hashed URL in DEBUG mode.
def url(self, name, force=False): """ Return the non-hashed URL in DEBUG mode. """ return self._url(self.stored_name, name, force)
[ "def", "url", "(", "self", ",", "name", ",", "force", "=", "False", ")", ":", "return", "self", ".", "_url", "(", "self", ".", "stored_name", ",", "name", ",", "force", ")" ]
[ 148, 4 ]
[ 152, 55 ]
python
en
['en', 'error', 'th']
False
HashedFilesMixin.url_converter
(self, name, hashed_files, template=None)
Return the custom URL converter for the given file name.
Return the custom URL converter for the given file name.
def url_converter(self, name, hashed_files, template=None): """ Return the custom URL converter for the given file name. """ if template is None: template = self.default_template def converter(matchobj): """ Convert the matched URL to a normal...
[ "def", "url_converter", "(", "self", ",", "name", ",", "hashed_files", ",", "template", "=", "None", ")", ":", "if", "template", "is", "None", ":", "template", "=", "self", ".", "default_template", "def", "converter", "(", "matchobj", ")", ":", "\"\"\"\n ...
[ 154, 4 ]
[ 206, 24 ]
python
en
['en', 'error', 'th']
False
HashedFilesMixin.post_process
(self, paths, dry_run=False, **options)
Post process the given dictionary of files (called from collectstatic). Processing is actually two separate operations: 1. renaming files to include a hash of their content for cache-busting, and copying those files to the target storage. 2. adjusting files which contain re...
Post process the given dictionary of files (called from collectstatic).
def post_process(self, paths, dry_run=False, **options): """ Post process the given dictionary of files (called from collectstatic). Processing is actually two separate operations: 1. renaming files to include a hash of their content for cache-busting, and copying those file...
[ "def", "post_process", "(", "self", ",", "paths", ",", "dry_run", "=", "False", ",", "*", "*", "options", ")", ":", "# don't even dare to process the files if we're in dry run mode", "if", "dry_run", ":", "return", "# where to store the new paths", "hashed_files", "=", ...
[ 208, 4 ]
[ 254, 46 ]
python
en
['en', 'error', 'th']
False
TestSerialization.test_different_types_and_shapes
(self)
Exhaustive noop serialization-->deserialization test over all supported datatypes and several distrinct shapes
Exhaustive noop serialization-->deserialization test over all supported datatypes and several distrinct shapes
def test_different_types_and_shapes(self): """ Exhaustive noop serialization-->deserialization test over all supported datatypes and several distrinct shapes """ _TESTED_DTYPES = [ np.float32, np.float64, np.int8, np.uint8, ...
[ "def", "test_different_types_and_shapes", "(", "self", ")", ":", "_TESTED_DTYPES", "=", "[", "np", ".", "float32", ",", "np", ".", "float64", ",", "np", ".", "int8", ",", "np", ".", "uint8", ",", "np", ".", "int16", ",", "np", ".", "uint16", ",", "np...
[ 21, 4 ]
[ 78, 59 ]
python
en
['en', 'error', 'th']
False
kml
(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS)
This view generates KML for the given app label, model, and field name. The field name must be that of a geographic field.
This view generates KML for the given app label, model, and field name.
def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS): """ This view generates KML for the given app label, model, and field name. The field name must be that of a geographic field. """ placemarks = [] try: klass = apps.get_model(label, model) excep...
[ "def", "kml", "(", "request", ",", "label", ",", "model", ",", "field_name", "=", "None", ",", "compress", "=", "False", ",", "using", "=", "DEFAULT_DB_ALIAS", ")", ":", "placemarks", "=", "[", "]", "try", ":", "klass", "=", "apps", ".", "get_model", ...
[ 9, 0 ]
[ 53, 67 ]
python
en
['en', 'error', 'th']
False
kmz
(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS)
Return KMZ for the given app label, model, and field name.
Return KMZ for the given app label, model, and field name.
def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS): """ Return KMZ for the given app label, model, and field name. """ return kml(request, label, model, field_name, compress=True, using=using)
[ "def", "kmz", "(", "request", ",", "label", ",", "model", ",", "field_name", "=", "None", ",", "using", "=", "DEFAULT_DB_ALIAS", ")", ":", "return", "kml", "(", "request", ",", "label", ",", "model", ",", "field_name", ",", "compress", "=", "True", ","...
[ 56, 0 ]
[ 60, 77 ]
python
en
['en', 'error', 'th']
False
Layer.__init__
(self, layer_ptr, ds)
Initializes on an OGR C pointer to the Layer and the `DataSource` object that owns this layer. The `DataSource` object is required so that a reference to it is kept with this Layer. This prevents garbage collection of the `DataSource` while this Layer is still active.
Initializes on an OGR C pointer to the Layer and the `DataSource` object that owns this layer. The `DataSource` object is required so that a reference to it is kept with this Layer. This prevents garbage collection of the `DataSource` while this Layer is still active.
def __init__(self, layer_ptr, ds): """ Initializes on an OGR C pointer to the Layer and the `DataSource` object that owns this layer. The `DataSource` object is required so that a reference to it is kept with this Layer. This prevents garbage collection of the `DataSource` whil...
[ "def", "__init__", "(", "self", ",", "layer_ptr", ",", "ds", ")", ":", "if", "not", "layer_ptr", ":", "raise", "OGRException", "(", "'Cannot create Layer, invalid pointer given'", ")", "self", ".", "ptr", "=", "layer_ptr", "self", ".", "_ds", "=", "ds", "sel...
[ 29, 4 ]
[ 42, 63 ]
python
en
['en', 'error', 'th']
False
Layer.__getitem__
(self, index)
Gets the Feature at the specified index.
Gets the Feature at the specified index.
def __getitem__(self, index): "Gets the Feature at the specified index." if isinstance(index, six.integer_types): # An integer index was given -- we cannot do a check based on the # number of features because the beginning and ending feature IDs # are not guaranteed t...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "six", ".", "integer_types", ")", ":", "# An integer index was given -- we cannot do a check based on the", "# number of features because the beginning and ending feature IDs", "...
[ 44, 4 ]
[ 58, 93 ]
python
en
['en', 'en', 'en']
True
Layer.__iter__
(self)
Iterates over each Feature in the Layer.
Iterates over each Feature in the Layer.
def __iter__(self): "Iterates over each Feature in the Layer." # ResetReading() must be called before iteration is to begin. capi.reset_reading(self._ptr) for i in xrange(self.num_feat): yield Feature(capi.get_next_feature(self._ptr), self)
[ "def", "__iter__", "(", "self", ")", ":", "# ResetReading() must be called before iteration is to begin.", "capi", ".", "reset_reading", "(", "self", ".", "_ptr", ")", "for", "i", "in", "xrange", "(", "self", ".", "num_feat", ")", ":", "yield", "Feature", "(", ...
[ 60, 4 ]
[ 65, 65 ]
python
en
['en', 'en', 'en']
True
Layer.__len__
(self)
The length is the number of features.
The length is the number of features.
def __len__(self): "The length is the number of features." return self.num_feat
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "num_feat" ]
[ 67, 4 ]
[ 69, 28 ]
python
en
['en', 'en', 'en']
True
Layer.__str__
(self)
The string name of the layer.
The string name of the layer.
def __str__(self): "The string name of the layer." return self.name
[ "def", "__str__", "(", "self", ")", ":", "return", "self", ".", "name" ]
[ 71, 4 ]
[ 73, 24 ]
python
en
['en', 'en', 'en']
True
Layer._make_feature
(self, feat_id)
Helper routine for __getitem__ that constructs a Feature from the given Feature ID. If the OGR Layer does not support random-access reading, then each feature of the layer will be incremented through until the a Feature is found matching the given feature ID.
Helper routine for __getitem__ that constructs a Feature from the given Feature ID. If the OGR Layer does not support random-access reading, then each feature of the layer will be incremented through until the a Feature is found matching the given feature ID.
def _make_feature(self, feat_id): """ Helper routine for __getitem__ that constructs a Feature from the given Feature ID. If the OGR Layer does not support random-access reading, then each feature of the layer will be incremented through until the a Feature is found matching the...
[ "def", "_make_feature", "(", "self", ",", "feat_id", ")", ":", "if", "self", ".", "_random_read", ":", "# If the Layer supports random reading, return.", "try", ":", "return", "Feature", "(", "capi", ".", "get_feature", "(", "self", ".", "ptr", ",", "feat_id", ...
[ 75, 4 ]
[ 95, 64 ]
python
en
['en', 'error', 'th']
False
Layer.extent
(self)
Returns the extent (an Envelope) of this layer.
Returns the extent (an Envelope) of this layer.
def extent(self): "Returns the extent (an Envelope) of this layer." env = OGREnvelope() capi.get_extent(self.ptr, byref(env), 1) return Envelope(env)
[ "def", "extent", "(", "self", ")", ":", "env", "=", "OGREnvelope", "(", ")", "capi", ".", "get_extent", "(", "self", ".", "ptr", ",", "byref", "(", "env", ")", ",", "1", ")", "return", "Envelope", "(", "env", ")" ]
[ 99, 4 ]
[ 103, 28 ]
python
en
['en', 'en', 'en']
True
Layer.name
(self)
Returns the name of this layer in the Data Source.
Returns the name of this layer in the Data Source.
def name(self): "Returns the name of this layer in the Data Source." name = capi.get_fd_name(self._ldefn) return force_text(name, self._ds.encoding, strings_only=True)
[ "def", "name", "(", "self", ")", ":", "name", "=", "capi", ".", "get_fd_name", "(", "self", ".", "_ldefn", ")", "return", "force_text", "(", "name", ",", "self", ".", "_ds", ".", "encoding", ",", "strings_only", "=", "True", ")" ]
[ 106, 4 ]
[ 109, 69 ]
python
en
['en', 'en', 'en']
True
Layer.num_feat
(self, force=1)
Returns the number of features in the Layer.
Returns the number of features in the Layer.
def num_feat(self, force=1): "Returns the number of features in the Layer." return capi.get_feature_count(self.ptr, force)
[ "def", "num_feat", "(", "self", ",", "force", "=", "1", ")", ":", "return", "capi", ".", "get_feature_count", "(", "self", ".", "ptr", ",", "force", ")" ]
[ 112, 4 ]
[ 114, 54 ]
python
en
['en', 'en', 'en']
True
Layer.num_fields
(self)
Returns the number of fields in the Layer.
Returns the number of fields in the Layer.
def num_fields(self): "Returns the number of fields in the Layer." return capi.get_field_count(self._ldefn)
[ "def", "num_fields", "(", "self", ")", ":", "return", "capi", ".", "get_field_count", "(", "self", ".", "_ldefn", ")" ]
[ 117, 4 ]
[ 119, 48 ]
python
en
['en', 'en', 'en']
True
Layer.geom_type
(self)
Returns the geometry type (OGRGeomType) of the Layer.
Returns the geometry type (OGRGeomType) of the Layer.
def geom_type(self): "Returns the geometry type (OGRGeomType) of the Layer." return OGRGeomType(capi.get_fd_geom_type(self._ldefn))
[ "def", "geom_type", "(", "self", ")", ":", "return", "OGRGeomType", "(", "capi", ".", "get_fd_geom_type", "(", "self", ".", "_ldefn", ")", ")" ]
[ 122, 4 ]
[ 124, 62 ]
python
en
['en', 'en', 'en']
True
Layer.srs
(self)
Returns the Spatial Reference used in this Layer.
Returns the Spatial Reference used in this Layer.
def srs(self): "Returns the Spatial Reference used in this Layer." try: ptr = capi.get_layer_srs(self.ptr) return SpatialReference(srs_api.clone_srs(ptr)) except SRSException: return None
[ "def", "srs", "(", "self", ")", ":", "try", ":", "ptr", "=", "capi", ".", "get_layer_srs", "(", "self", ".", "ptr", ")", "return", "SpatialReference", "(", "srs_api", ".", "clone_srs", "(", "ptr", ")", ")", "except", "SRSException", ":", "return", "Non...
[ 127, 4 ]
[ 133, 23 ]
python
en
['en', 'en', 'en']
True
Layer.fields
(self)
Returns a list of string names corresponding to each of the Fields available in this Layer.
Returns a list of string names corresponding to each of the Fields available in this Layer.
def fields(self): """ Returns a list of string names corresponding to each of the Fields available in this Layer. """ return [force_text(capi.get_field_name(capi.get_field_defn(self._ldefn, i)), self._ds.encoding, strings_only=True) for ...
[ "def", "fields", "(", "self", ")", ":", "return", "[", "force_text", "(", "capi", ".", "get_field_name", "(", "capi", ".", "get_field_defn", "(", "self", ".", "_ldefn", ",", "i", ")", ")", ",", "self", ".", "_ds", ".", "encoding", ",", "strings_only", ...
[ 136, 4 ]
[ 143, 49 ]
python
en
['en', 'error', 'th']
False
Layer.field_types
(self)
Returns a list of the types of fields in this Layer. For example, the list [OFTInteger, OFTReal, OFTString] would be returned for an OGR layer that had an integer, a floating-point, and string fields.
Returns a list of the types of fields in this Layer. For example, the list [OFTInteger, OFTReal, OFTString] would be returned for an OGR layer that had an integer, a floating-point, and string fields.
def field_types(self): """ Returns a list of the types of fields in this Layer. For example, the list [OFTInteger, OFTReal, OFTString] would be returned for an OGR layer that had an integer, a floating-point, and string fields. """ return [OGRFieldTypes[capi.get_...
[ "def", "field_types", "(", "self", ")", ":", "return", "[", "OGRFieldTypes", "[", "capi", ".", "get_field_type", "(", "capi", ".", "get_field_defn", "(", "self", ".", "_ldefn", ",", "i", ")", ")", "]", "for", "i", "in", "xrange", "(", "self", ".", "n...
[ 146, 4 ]
[ 154, 49 ]
python
en
['en', 'error', 'th']
False
Layer.field_widths
(self)
Returns a list of the maximum field widths for the features.
Returns a list of the maximum field widths for the features.
def field_widths(self): "Returns a list of the maximum field widths for the features." return [capi.get_field_width(capi.get_field_defn(self._ldefn, i)) for i in xrange(self.num_fields)]
[ "def", "field_widths", "(", "self", ")", ":", "return", "[", "capi", ".", "get_field_width", "(", "capi", ".", "get_field_defn", "(", "self", ".", "_ldefn", ",", "i", ")", ")", "for", "i", "in", "xrange", "(", "self", ".", "num_fields", ")", "]" ]
[ 157, 4 ]
[ 160, 49 ]
python
en
['en', 'en', 'en']
True
Layer.field_precisions
(self)
Returns the field precisions for the features.
Returns the field precisions for the features.
def field_precisions(self): "Returns the field precisions for the features." return [capi.get_field_precision(capi.get_field_defn(self._ldefn, i)) for i in xrange(self.num_fields)]
[ "def", "field_precisions", "(", "self", ")", ":", "return", "[", "capi", ".", "get_field_precision", "(", "capi", ".", "get_field_defn", "(", "self", ".", "_ldefn", ",", "i", ")", ")", "for", "i", "in", "xrange", "(", "self", ".", "num_fields", ")", "]...
[ 163, 4 ]
[ 166, 49 ]
python
en
['en', 'en', 'en']
True
Layer.get_fields
(self, field_name)
Returns a list containing the given field name for every Feature in the Layer.
Returns a list containing the given field name for every Feature in the Layer.
def get_fields(self, field_name): """ Returns a list containing the given field name for every Feature in the Layer. """ if field_name not in self.fields: raise OGRException('invalid field name: %s' % field_name) return [feat.get(field_name) for feat in self]
[ "def", "get_fields", "(", "self", ",", "field_name", ")", ":", "if", "field_name", "not", "in", "self", ".", "fields", ":", "raise", "OGRException", "(", "'invalid field name: %s'", "%", "field_name", ")", "return", "[", "feat", ".", "get", "(", "field_name"...
[ 192, 4 ]
[ 199, 54 ]
python
en
['en', 'error', 'th']
False
Layer.get_geoms
(self, geos=False)
Returns a list containing the OGRGeometry for every Feature in the Layer.
Returns a list containing the OGRGeometry for every Feature in the Layer.
def get_geoms(self, geos=False): """ Returns a list containing the OGRGeometry for every Feature in the Layer. """ if geos: from django.contrib.gis.geos import GEOSGeometry return [GEOSGeometry(feat.geom.wkb) for feat in self] else: ret...
[ "def", "get_geoms", "(", "self", ",", "geos", "=", "False", ")", ":", "if", "geos", ":", "from", "django", ".", "contrib", ".", "gis", ".", "geos", "import", "GEOSGeometry", "return", "[", "GEOSGeometry", "(", "feat", ".", "geom", ".", "wkb", ")", "f...
[ 201, 4 ]
[ 210, 47 ]
python
en
['en', 'error', 'th']
False
Layer.test_capability
(self, capability)
Returns a bool indicating whether the this Layer supports the given capability (a string). Valid capability strings include: 'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter', 'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions', 'DeleteFea...
Returns a bool indicating whether the this Layer supports the given capability (a string). Valid capability strings include: 'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter', 'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions', 'DeleteFea...
def test_capability(self, capability): """ Returns a bool indicating whether the this Layer supports the given capability (a string). Valid capability strings include: 'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter', 'FastFeatureCount', 'FastGetExtent', '...
[ "def", "test_capability", "(", "self", ",", "capability", ")", ":", "return", "bool", "(", "capi", ".", "test_capability", "(", "self", ".", "ptr", ",", "force_bytes", "(", "capability", ")", ")", ")" ]
[ 212, 4 ]
[ 220, 76 ]
python
en
['en', 'error', 'th']
False
cursor_iter
(cursor, sentinel)
Yields blocks of rows from a cursor and ensures the cursor is closed when done.
Yields blocks of rows from a cursor and ensures the cursor is closed when done.
def cursor_iter(cursor, sentinel): """ Yields blocks of rows from a cursor and ensures the cursor is closed when done. """ try: for rows in iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), sentinel): yield rows finally: cursor.close()
[ "def", "cursor_iter", "(", "cursor", ",", "sentinel", ")", ":", "try", ":", "for", "rows", "in", "iter", "(", "(", "lambda", ":", "cursor", ".", "fetchmany", "(", "GET_ITERATOR_CHUNK_SIZE", ")", ")", ",", "sentinel", ")", ":", "yield", "rows", "finally",...
[ 1158, 0 ]
[ 1168, 22 ]
python
en
['en', 'error', 'th']
False
order_modified_iter
(cursor, trim, sentinel)
Yields blocks of rows from a cursor. We use this iterator in the special case when extra output columns have been added to support ordering requirements. We must trim those extra columns before anything else can use the results, since they're only needed to make the SQL valid.
Yields blocks of rows from a cursor. We use this iterator in the special case when extra output columns have been added to support ordering requirements. We must trim those extra columns before anything else can use the results, since they're only needed to make the SQL valid.
def order_modified_iter(cursor, trim, sentinel): """ Yields blocks of rows from a cursor. We use this iterator in the special case when extra output columns have been added to support ordering requirements. We must trim those extra columns before anything else can use the results, since they're only...
[ "def", "order_modified_iter", "(", "cursor", ",", "trim", ",", "sentinel", ")", ":", "try", ":", "for", "rows", "in", "iter", "(", "(", "lambda", ":", "cursor", ".", "fetchmany", "(", "GET_ITERATOR_CHUNK_SIZE", ")", ")", ",", "sentinel", ")", ":", "yield...
[ 1171, 0 ]
[ 1183, 22 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.pre_sql_setup
(self)
Does any necessary class setup immediately prior to producing SQL. This is for things that can't necessarily be done in __init__ because we might not have all the pieces in place at that time. # TODO: after the query has been executed, the altered state should be # cleaned. We a...
Does any necessary class setup immediately prior to producing SQL. This is for things that can't necessarily be done in __init__ because we might not have all the pieces in place at that time. # TODO: after the query has been executed, the altered state should be # cleaned. We a...
def pre_sql_setup(self): """ Does any necessary class setup immediately prior to producing SQL. This is for things that can't necessarily be done in __init__ because we might not have all the pieces in place at that time. # TODO: after the query has been executed, the altered sta...
[ "def", "pre_sql_setup", "(", "self", ")", ":", "if", "not", "self", ".", "query", ".", "tables", ":", "self", ".", "query", ".", "join", "(", "(", "None", ",", "self", ".", "query", ".", "get_meta", "(", ")", ".", "db_table", ",", "None", ")", ")...
[ 33, 4 ]
[ 47, 42 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.__call__
(self, name)
A wrapper around connection.ops.quote_name that doesn't quote aliases for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL).
A wrapper around connection.ops.quote_name that doesn't quote aliases for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL).
def __call__(self, name): """ A wrapper around connection.ops.quote_name that doesn't quote aliases for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL). """ if name in self.quote_cache: return self...
[ "def", "__call__", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "quote_cache", ":", "return", "self", ".", "quote_cache", "[", "name", "]", "if", "(", "(", "name", "in", "self", ".", "query", ".", "alias_map", "and", "name", ...
[ 49, 4 ]
[ 63, 16 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.quote_name_unless_alias
(self, name)
A wrapper around connection.ops.quote_name that doesn't quote aliases for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL).
A wrapper around connection.ops.quote_name that doesn't quote aliases for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL).
def quote_name_unless_alias(self, name): """ A wrapper around connection.ops.quote_name that doesn't quote aliases for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL). """ return self(name)
[ "def", "quote_name_unless_alias", "(", "self", ",", "name", ")", ":", "return", "self", "(", "name", ")" ]
[ 65, 4 ]
[ 71, 25 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.as_sql
(self, with_limits=True, with_col_aliases=False)
Creates the SQL for this query. Returns the SQL string and list of parameters. If 'with_limits' is False, any limit/offset information is not included in the query.
Creates the SQL for this query. Returns the SQL string and list of parameters.
def as_sql(self, with_limits=True, with_col_aliases=False): """ Creates the SQL for this query. Returns the SQL string and list of parameters. If 'with_limits' is False, any limit/offset information is not included in the query. """ if with_limits and self.query....
[ "def", "as_sql", "(", "self", ",", "with_limits", "=", "True", ",", "with_col_aliases", "=", "False", ")", ":", "if", "with_limits", "and", "self", ".", "query", ".", "low_mark", "==", "self", ".", "query", ".", "high_mark", ":", "return", "''", ",", "...
[ 81, 4 ]
[ 174, 46 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.as_nested_sql
(self)
Perform the same functionality as the as_sql() method, returning an SQL string and parameters. However, the alias prefixes are bumped beforehand (in a copy -- the current query isn't changed), and any ordering is removed if the query is unsliced. Used when nesting this query in...
Perform the same functionality as the as_sql() method, returning an SQL string and parameters. However, the alias prefixes are bumped beforehand (in a copy -- the current query isn't changed), and any ordering is removed if the query is unsliced.
def as_nested_sql(self): """ Perform the same functionality as the as_sql() method, returning an SQL string and parameters. However, the alias prefixes are bumped beforehand (in a copy -- the current query isn't changed), and any ordering is removed if the query is unsliced. ...
[ "def", "as_nested_sql", "(", "self", ")", ":", "obj", "=", "self", ".", "query", ".", "clone", "(", ")", "if", "obj", ".", "low_mark", "==", "0", "and", "obj", ".", "high_mark", "is", "None", "and", "not", "self", ".", "query", ".", "distinct_fields"...
[ 176, 4 ]
[ 189, 68 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.get_columns
(self, with_aliases=False)
Returns the list of columns to use in the select statement, as well as a list any extra parameters that need to be included. If no columns have been specified, returns all columns relating to fields in the model. If 'with_aliases' is true, any column names that are duplicated ...
Returns the list of columns to use in the select statement, as well as a list any extra parameters that need to be included. If no columns have been specified, returns all columns relating to fields in the model.
def get_columns(self, with_aliases=False): """ Returns the list of columns to use in the select statement, as well as a list any extra parameters that need to be included. If no columns have been specified, returns all columns relating to fields in the model. If 'with_al...
[ "def", "get_columns", "(", "self", ",", "with_aliases", "=", "False", ")", ":", "qn", "=", "self", "qn2", "=", "self", ".", "connection", ".", "ops", ".", "quote_name", "result", "=", "[", "'(%s) AS %s'", "%", "(", "col", "[", "0", "]", ",", "qn2", ...
[ 191, 4 ]
[ 271, 29 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.get_default_columns
(self, with_aliases=False, col_aliases=None, start_alias=None, opts=None, as_pairs=False, from_parent=None)
Computes the default columns for selecting every field in the base model. Will sometimes be called to pull in related models (e.g. via select_related), in which case "opts" and "start_alias" will be given to provide a starting point for the traversal. Returns a list of strings,...
Computes the default columns for selecting every field in the base model. Will sometimes be called to pull in related models (e.g. via select_related), in which case "opts" and "start_alias" will be given to provide a starting point for the traversal.
def get_default_columns(self, with_aliases=False, col_aliases=None, start_alias=None, opts=None, as_pairs=False, from_parent=None): """ Computes the default columns for selecting every field in the base model. Will sometimes be called to pull in related models (e.g. via selec...
[ "def", "get_default_columns", "(", "self", ",", "with_aliases", "=", "False", ",", "col_aliases", "=", "None", ",", "start_alias", "=", "None", ",", "opts", "=", "None", ",", "as_pairs", "=", "False", ",", "from_parent", "=", "None", ")", ":", "result", ...
[ 273, 4 ]
[ 332, 30 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.get_distinct
(self)
Returns a quoted list of fields to use in DISTINCT ON part of the query. Note that this method can alter the tables in the query, and thus it must be called before get_from_clause().
Returns a quoted list of fields to use in DISTINCT ON part of the query.
def get_distinct(self): """ Returns a quoted list of fields to use in DISTINCT ON part of the query. Note that this method can alter the tables in the query, and thus it must be called before get_from_clause(). """ qn = self qn2 = self.connection.ops.quote_name ...
[ "def", "get_distinct", "(", "self", ")", ":", "qn", "=", "self", "qn2", "=", "self", ".", "connection", ".", "ops", ".", "quote_name", "result", "=", "[", "]", "opts", "=", "self", ".", "query", ".", "get_meta", "(", ")", "for", "name", "in", "self...
[ 334, 4 ]
[ 352, 21 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.get_ordering
(self)
Returns a tuple containing a list representing the SQL elements in the "order by" clause, and the list of SQL elements that need to be added to the GROUP BY clause as a result of the ordering. Also sets the ordering_aliases attribute on this instance to a list of extra aliases ...
Returns a tuple containing a list representing the SQL elements in the "order by" clause, and the list of SQL elements that need to be added to the GROUP BY clause as a result of the ordering.
def get_ordering(self): """ Returns a tuple containing a list representing the SQL elements in the "order by" clause, and the list of SQL elements that need to be added to the GROUP BY clause as a result of the ordering. Also sets the ordering_aliases attribute on this instance ...
[ "def", "get_ordering", "(", "self", ")", ":", "if", "self", ".", "query", ".", "extra_order_by", ":", "ordering", "=", "self", ".", "query", ".", "extra_order_by", "elif", "not", "self", ".", "query", ".", "default_ordering", ":", "ordering", "=", "self", ...
[ 354, 4 ]
[ 453, 39 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.find_ordering_name
(self, name, opts, alias=None, default_order='ASC', already_seen=None)
Returns the table alias (the name might be ambiguous, the alias will not be) and column name for ordering by the given 'name' parameter. The 'name' is of the form 'field1__field2__...__fieldN'.
Returns the table alias (the name might be ambiguous, the alias will not be) and column name for ordering by the given 'name' parameter. The 'name' is of the form 'field1__field2__...__fieldN'.
def find_ordering_name(self, name, opts, alias=None, default_order='ASC', already_seen=None): """ Returns the table alias (the name might be ambiguous, the alias will not be) and column name for ordering by the given 'name' parameter. The 'name' is of the form ...
[ "def", "find_ordering_name", "(", "self", ",", "name", ",", "opts", ",", "alias", "=", "None", ",", "default_order", "=", "'ASC'", ",", "already_seen", "=", "None", ")", ":", "name", ",", "order", "=", "get_order_dir", "(", "name", ",", "default_order", ...
[ 455, 4 ]
[ 484, 60 ]
python
en
['en', 'error', 'th']
False
SQLCompiler._setup_joins
(self, pieces, opts, alias)
A helper method for get_ordering and get_distinct. Note that get_ordering and get_distinct must produce same target columns on same input, as the prefixes of get_ordering and get_distinct must match. Executing SQL where this is not true is an error.
A helper method for get_ordering and get_distinct.
def _setup_joins(self, pieces, opts, alias): """ A helper method for get_ordering and get_distinct. Note that get_ordering and get_distinct must produce same target columns on same input, as the prefixes of get_ordering and get_distinct must match. Executing SQL where this is no...
[ "def", "_setup_joins", "(", "self", ",", "pieces", ",", "opts", ",", "alias", ")", ":", "if", "not", "alias", ":", "alias", "=", "self", ".", "query", ".", "get_initial_alias", "(", ")", "field", ",", "targets", ",", "opts", ",", "joins", ",", "path"...
[ 486, 4 ]
[ 499, 55 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.get_from_clause
(self)
Returns a list of strings that are joined together to go after the "FROM" part of the query, as well as a list any extra parameters that need to be included. Sub-classes, can override this to create a from-clause via a "select". This should only be called after any SQL construc...
Returns a list of strings that are joined together to go after the "FROM" part of the query, as well as a list any extra parameters that need to be included. Sub-classes, can override this to create a from-clause via a "select".
def get_from_clause(self): """ Returns a list of strings that are joined together to go after the "FROM" part of the query, as well as a list any extra parameters that need to be included. Sub-classes, can override this to create a from-clause via a "select". This should...
[ "def", "get_from_clause", "(", "self", ")", ":", "result", "=", "[", "]", "qn", "=", "self", "qn2", "=", "self", ".", "connection", ".", "ops", ".", "quote_name", "first", "=", "True", "from_params", "=", "[", "]", "for", "alias", "in", "self", ".", ...
[ 501, 4 ]
[ 557, 34 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.get_grouping
(self, having_group_by, ordering_group_by)
Returns a tuple representing the SQL elements in the "group by" clause.
Returns a tuple representing the SQL elements in the "group by" clause.
def get_grouping(self, having_group_by, ordering_group_by): """ Returns a tuple representing the SQL elements in the "group by" clause. """ qn = self result, params = [], [] if self.query.group_by is not None: select_cols = self.query.select + self.query.relat...
[ "def", "get_grouping", "(", "self", ",", "having_group_by", ",", "ordering_group_by", ")", ":", "qn", "=", "self", "result", ",", "params", "=", "[", "]", ",", "[", "]", "if", "self", ".", "query", ".", "group_by", "is", "not", "None", ":", "select_col...
[ 559, 4 ]
[ 607, 29 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.fill_related_selections
(self, opts=None, root_alias=None, cur_depth=1, requested=None, restricted=None)
Fill in the information needed for a select_related query. The current depth is measured as the number of connections away from the root model (for example, cur_depth=1 means we are looking at models with direct connections to the root model).
Fill in the information needed for a select_related query. The current depth is measured as the number of connections away from the root model (for example, cur_depth=1 means we are looking at models with direct connections to the root model).
def fill_related_selections(self, opts=None, root_alias=None, cur_depth=1, requested=None, restricted=None): """ Fill in the information needed for a select_related query. The current depth is measured as the number of connections away from the root model (for example, cur_de...
[ "def", "fill_related_selections", "(", "self", ",", "opts", "=", "None", ",", "root_alias", "=", "None", ",", "cur_depth", "=", "1", ",", "requested", "=", "None", ",", "restricted", "=", "None", ")", ":", "if", "not", "restricted", "and", "self", ".", ...
[ 609, 4 ]
[ 680, 62 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.deferred_to_columns
(self)
Converts the self.deferred_loading data structure to mapping of table names to sets of column names which are to be loaded. Returns the dictionary.
Converts the self.deferred_loading data structure to mapping of table names to sets of column names which are to be loaded. Returns the dictionary.
def deferred_to_columns(self): """ Converts the self.deferred_loading data structure to mapping of table names to sets of column names which are to be loaded. Returns the dictionary. """ columns = {} self.query.deferred_to_data(columns, self.query.deferred_to_colu...
[ "def", "deferred_to_columns", "(", "self", ")", ":", "columns", "=", "{", "}", "self", ".", "query", ".", "deferred_to_data", "(", "columns", ",", "self", ".", "query", ".", "deferred_to_columns_cb", ")", "return", "columns" ]
[ 682, 4 ]
[ 690, 22 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.results_iter
(self)
Returns an iterator over the results from executing this query.
Returns an iterator over the results from executing this query.
def results_iter(self): """ Returns an iterator over the results from executing this query. """ fields = None converters = None has_aggregate_select = bool(self.query.aggregate_select) for rows in self.execute_sql(MULTI): for row in rows: ...
[ "def", "results_iter", "(", "self", ")", ":", "fields", "=", "None", "converters", "=", "None", "has_aggregate_select", "=", "bool", "(", "self", ".", "query", ".", "aggregate_select", ")", "for", "rows", "in", "self", ".", "execute_sql", "(", "MULTI", ")"...
[ 714, 4 ]
[ 772, 25 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.has_results
(self)
Backends (e.g. NoSQL) can override this in order to use optimized versions of "query has any results."
Backends (e.g. NoSQL) can override this in order to use optimized versions of "query has any results."
def has_results(self): """ Backends (e.g. NoSQL) can override this in order to use optimized versions of "query has any results." """ # This is always executed on a query clone, so we can modify self.query self.query.add_extra({'a': 1}, None, None, None, None, None) ...
[ "def", "has_results", "(", "self", ")", ":", "# This is always executed on a query clone, so we can modify self.query", "self", ".", "query", ".", "add_extra", "(", "{", "'a'", ":", "1", "}", ",", "None", ",", "None", ",", "None", ",", "None", ",", "None", ")"...
[ 774, 4 ]
[ 782, 45 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.execute_sql
(self, result_type=MULTI)
Run the query against the database and returns the result(s). The return value is a single data item if result_type is SINGLE, or an iterator over the results if the result_type is MULTI. result_type is either MULTI (use fetchmany() to retrieve all rows), SINGLE (only retrieve ...
Run the query against the database and returns the result(s). The return value is a single data item if result_type is SINGLE, or an iterator over the results if the result_type is MULTI.
def execute_sql(self, result_type=MULTI): """ Run the query against the database and returns the result(s). The return value is a single data item if result_type is SINGLE, or an iterator over the results if the result_type is MULTI. result_type is either MULTI (use fetchmany() ...
[ "def", "execute_sql", "(", "self", ",", "result_type", "=", "MULTI", ")", ":", "if", "not", "result_type", ":", "result_type", "=", "NO_RESULTS", "try", ":", "sql", ",", "params", "=", "self", ".", "as_sql", "(", ")", "if", "not", "sql", ":", "raise", ...
[ 784, 4 ]
[ 848, 21 ]
python
en
['en', 'error', 'th']
False
SQLDeleteCompiler.as_sql
(self)
Creates the SQL for this query. Returns the SQL string and list of parameters.
Creates the SQL for this query. Returns the SQL string and list of parameters.
def as_sql(self): """ Creates the SQL for this query. Returns the SQL string and list of parameters. """ assert len(self.query.tables) == 1, \ "Can only delete from one table at a time." qn = self result = ['DELETE FROM %s' % qn(self.query.tables[0])] ...
[ "def", "as_sql", "(", "self", ")", ":", "assert", "len", "(", "self", ".", "query", ".", "tables", ")", "==", "1", ",", "\"Can only delete from one table at a time.\"", "qn", "=", "self", "result", "=", "[", "'DELETE FROM %s'", "%", "qn", "(", "self", ".",...
[ 957, 4 ]
[ 969, 46 ]
python
en
['en', 'error', 'th']
False
SQLUpdateCompiler.as_sql
(self)
Creates the SQL for this query. Returns the SQL string and list of parameters.
Creates the SQL for this query. Returns the SQL string and list of parameters.
def as_sql(self): """ Creates the SQL for this query. Returns the SQL string and list of parameters. """ self.pre_sql_setup() if not self.query.values: return '', () table = self.query.tables[0] qn = self result = ['UPDATE %s' % qn(tabl...
[ "def", "as_sql", "(", "self", ")", ":", "self", ".", "pre_sql_setup", "(", ")", "if", "not", "self", ".", "query", ".", "values", ":", "return", "''", ",", "(", ")", "table", "=", "self", ".", "query", ".", "tables", "[", "0", "]", "qn", "=", "...
[ 973, 4 ]
[ 1022, 62 ]
python
en
['en', 'error', 'th']
False
SQLUpdateCompiler.execute_sql
(self, result_type)
Execute the specified update. Returns the number of rows affected by the primary update query. The "primary update query" is the first non-empty query that is executed. Row counts for any subsequent, related queries are not available.
Execute the specified update. Returns the number of rows affected by the primary update query. The "primary update query" is the first non-empty query that is executed. Row counts for any subsequent, related queries are not available.
def execute_sql(self, result_type): """ Execute the specified update. Returns the number of rows affected by the primary update query. The "primary update query" is the first non-empty query that is executed. Row counts for any subsequent, related queries are not available. ...
[ "def", "execute_sql", "(", "self", ",", "result_type", ")", ":", "cursor", "=", "super", "(", "SQLUpdateCompiler", ",", "self", ")", ".", "execute_sql", "(", "result_type", ")", "try", ":", "rows", "=", "cursor", ".", "rowcount", "if", "cursor", "else", ...
[ 1024, 4 ]
[ 1043, 19 ]
python
en
['en', 'error', 'th']
False
SQLUpdateCompiler.pre_sql_setup
(self)
If the update depends on results from other tables, we need to do some munging of the "where" conditions to match the format required for (portable) SQL updates. That is done here. Further, if we are going to be running multiple updates, we pull out the id values to update at t...
If the update depends on results from other tables, we need to do some munging of the "where" conditions to match the format required for (portable) SQL updates. That is done here.
def pre_sql_setup(self): """ If the update depends on results from other tables, we need to do some munging of the "where" conditions to match the format required for (portable) SQL updates. That is done here. Further, if we are going to be running multiple updates, we pull out ...
[ "def", "pre_sql_setup", "(", "self", ")", ":", "self", ".", "query", ".", "select_related", "=", "False", "self", ".", "query", ".", "clear_ordering", "(", "True", ")", "super", "(", "SQLUpdateCompiler", ",", "self", ")", ".", "pre_sql_setup", "(", ")", ...
[ 1045, 4 ]
[ 1092, 48 ]
python
en
['en', 'error', 'th']
False
SQLAggregateCompiler.as_sql
(self, qn=None)
Creates the SQL for this query. Returns the SQL string and list of parameters.
Creates the SQL for this query. Returns the SQL string and list of parameters.
def as_sql(self, qn=None): """ Creates the SQL for this query. Returns the SQL string and list of parameters. """ if qn is None: qn = self sql, params = [], [] for aggregate in self.query.aggregate_select.values(): agg_sql, agg_params = se...
[ "def", "as_sql", "(", "self", ",", "qn", "=", "None", ")", ":", "if", "qn", "is", "None", ":", "qn", "=", "self", "sql", ",", "params", "=", "[", "]", ",", "[", "]", "for", "aggregate", "in", "self", ".", "query", ".", "aggregate_select", ".", ...
[ 1096, 4 ]
[ 1114, 26 ]
python
en
['en', 'error', 'th']
False
SQLDateCompiler.results_iter
(self)
Returns an iterator over the results from executing this query.
Returns an iterator over the results from executing this query.
def results_iter(self): """ Returns an iterator over the results from executing this query. """ from django.db.models.fields import DateField converters = self.get_converters([DateField()]) offset = len(self.query.extra_select) for rows in self.execute_sql(MULTI)...
[ "def", "results_iter", "(", "self", ")", ":", "from", "django", ".", "db", ".", "models", ".", "fields", "import", "DateField", "converters", "=", "self", ".", "get_converters", "(", "[", "DateField", "(", ")", "]", ")", "offset", "=", "len", "(", "sel...
[ 1118, 4 ]
[ 1131, 26 ]
python
en
['en', 'error', 'th']
False
SQLDateTimeCompiler.results_iter
(self)
Returns an iterator over the results from executing this query.
Returns an iterator over the results from executing this query.
def results_iter(self): """ Returns an iterator over the results from executing this query. """ from django.db.models.fields import DateTimeField converters = self.get_converters([DateTimeField()]) offset = len(self.query.extra_select) for rows in self.execute_sq...
[ "def", "results_iter", "(", "self", ")", ":", "from", "django", ".", "db", ".", "models", ".", "fields", "import", "DateTimeField", "converters", "=", "self", ".", "get_converters", "(", "[", "DateTimeField", "(", ")", "]", ")", "offset", "=", "len", "("...
[ 1135, 4 ]
[ 1155, 30 ]
python
en
['en', 'error', 'th']
False
Finder.score_one
(self, x)
Calculate a change score. Parameters ---------- x : float The sample you want to calculate the change score. Returns ------- score : float Change score of the sample.
Calculate a change score.
def score_one(self, x): """Calculate a change score. Parameters ---------- x : float The sample you want to calculate the change score. Returns ------- score : float Change score of the sample. """ self._first_score_queue....
[ "def", "score_one", "(", "self", ",", "x", ")", ":", "self", ".", "_first_score_queue", ".", "pop", "(", "0", ")", "self", ".", "_first_score_queue", ".", "append", "(", "self", ".", "first_code_length", ".", "length", "(", "x", ")", ")", "first_smoothed...
[ 22, 4 ]
[ 42, 20 ]
python
co
['it', 'co', 'en']
False
Finder.score
(self, X)
Calculate change scores. Parameters ---------- X : array-like, shape (1, n_samples) Sequence of the samples. Returns ------- scores : iterator shale(n_samples) Change scores of the individuale samples.
Calculate change scores.
def score(self, X): """Calculate change scores. Parameters ---------- X : array-like, shape (1, n_samples) Sequence of the samples. Returns ------- scores : iterator shale(n_samples) Change scores of the individuale samples. """ ...
[ "def", "score", "(", "self", ",", "X", ")", ":", "for", "x", "in", "X", ":", "yield", "self", ".", "score_one", "(", "x", ")" ]
[ 44, 4 ]
[ 58, 35 ]
python
en
['es', 'en', 'en']
True
Bazaar.export
(self, location, url)
Export the Bazaar repository at the url to the destination location
Export the Bazaar repository at the url to the destination location
def export(self, location, url): # type: (str, HiddenText) -> None """ Export the Bazaar repository at the url to the destination location """ # Remove the location to make sure Bazaar can export it correctly if os.path.exists(location): rmtree(location) ...
[ "def", "export", "(", "self", ",", "location", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "# Remove the location to make sure Bazaar can export it correctly", "if", "os", ".", "path", ".", "exists", "(", "location", ")", ":", "rmtree", "(", "location",...
[ 45, 4 ]
[ 58, 9 ]
python
en
['en', 'error', 'th']
False
Bazaar.is_commit_id_equal
(cls, dest, name)
Always assume the versions don't match
Always assume the versions don't match
def is_commit_id_equal(cls, dest, name): """Always assume the versions don't match""" return False
[ "def", "is_commit_id_equal", "(", "cls", ",", "dest", ",", "name", ")", ":", "return", "False" ]
[ 114, 4 ]
[ 116, 20 ]
python
en
['en', 'en', 'en']
True
swappable_dependency
(value)
Turns a setting value into a dependency.
Turns a setting value into a dependency.
def swappable_dependency(value): """ Turns a setting value into a dependency. """ return SwappableTuple((value.split(".", 1)[0], "__first__"), value)
[ "def", "swappable_dependency", "(", "value", ")", ":", "return", "SwappableTuple", "(", "(", "value", ".", "split", "(", "\".\"", ",", "1", ")", "[", "0", "]", ",", "\"__first__\"", ")", ",", "value", ")" ]
[ 160, 0 ]
[ 164, 71 ]
python
en
['en', 'error', 'th']
False
Migration.mutate_state
(self, project_state)
Takes a ProjectState and returns a new one with the migration's operations applied to it.
Takes a ProjectState and returns a new one with the migration's operations applied to it.
def mutate_state(self, project_state): """ Takes a ProjectState and returns a new one with the migration's operations applied to it. """ new_state = project_state.clone() for operation in self.operations: operation.state_forwards(self.app_label, new_state) ...
[ "def", "mutate_state", "(", "self", ",", "project_state", ")", ":", "new_state", "=", "project_state", ".", "clone", "(", ")", "for", "operation", "in", "self", ".", "operations", ":", "operation", ".", "state_forwards", "(", "self", ".", "app_label", ",", ...
[ 68, 4 ]
[ 76, 24 ]
python
en
['en', 'error', 'th']
False
Migration.apply
(self, project_state, schema_editor, collect_sql=False)
Takes a project_state representing all migrations prior to this one and a schema_editor for a live database and applies the migration in a forwards order. Returns the resulting project state for efficient re-use by following Migrations.
Takes a project_state representing all migrations prior to this one and a schema_editor for a live database and applies the migration in a forwards order.
def apply(self, project_state, schema_editor, collect_sql=False): """ Takes a project_state representing all migrations prior to this one and a schema_editor for a live database and applies the migration in a forwards order. Returns the resulting project state for efficient re-u...
[ "def", "apply", "(", "self", ",", "project_state", ",", "schema_editor", ",", "collect_sql", "=", "False", ")", ":", "for", "operation", "in", "self", ".", "operations", ":", "# If this operation cannot be represented as SQL, place a comment", "# there instead", "if", ...
[ 78, 4 ]
[ 109, 28 ]
python
en
['en', 'error', 'th']
False
Migration.unapply
(self, project_state, schema_editor, collect_sql=False)
Takes a project_state representing all migrations prior to this one and a schema_editor for a live database and applies the migration in a reverse order.
Takes a project_state representing all migrations prior to this one and a schema_editor for a live database and applies the migration in a reverse order.
def unapply(self, project_state, schema_editor, collect_sql=False): """ Takes a project_state representing all migrations prior to this one and a schema_editor for a live database and applies the migration in a reverse order. """ # We need to pre-calculate the stack of pr...
[ "def", "unapply", "(", "self", ",", "project_state", ",", "schema_editor", ",", "collect_sql", "=", "False", ")", ":", "# We need to pre-calculate the stack of project states", "to_run", "=", "[", "]", "for", "operation", "in", "self", ".", "operations", ":", "# I...
[ 111, 4 ]
[ 145, 28 ]
python
en
['en', 'error', 'th']
False
decoder
(conv_func)
The Python sqlite3 interface returns always byte strings. This function converts the received value to a regular string before passing it to the receiver function.
The Python sqlite3 interface returns always byte strings. This function converts the received value to a regular string before passing it to the receiver function.
def decoder(conv_func): """ The Python sqlite3 interface returns always byte strings. This function converts the received value to a regular string before passing it to the receiver function. """ return lambda s: conv_func(s.decode('utf-8'))
[ "def", "decoder", "(", "conv_func", ")", ":", "return", "lambda", "s", ":", "conv_func", "(", "s", ".", "decode", "(", "'utf-8'", ")", ")" ]
[ 70, 0 ]
[ 75, 49 ]
python
en
['en', 'en', 'en']
True
DatabaseFeatures.supports_stddev
(self)
Confirm support for STDDEV and related stats functions SQLite supports STDDEV as an extension package; so connection.ops.check_aggregate_support() can't unilaterally rule out support for STDDEV. We need to manually check whether the call works.
Confirm support for STDDEV and related stats functions
def supports_stddev(self): """Confirm support for STDDEV and related stats functions SQLite supports STDDEV as an extension package; so connection.ops.check_aggregate_support() can't unilaterally rule out support for STDDEV. We need to manually check whether the call works. ...
[ "def", "supports_stddev", "(", "self", ")", ":", "with", "self", ".", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'CREATE TABLE STDDEV_TEST (X INT)'", ")", "try", ":", "cursor", ".", "execute", "(", "'SELECT ST...
[ 126, 4 ]
[ 142, 26 ]
python
en
['en', 'en', 'en']
True
DatabaseOperations.bulk_batch_size
(self, fields, objs)
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of 999 variables per query. If there is just single field to insert, then we can hit another limit, SQLITE_MAX_COMPOUND_SELECT which defaults to 500.
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of 999 variables per query.
def bulk_batch_size(self, fields, objs): """ SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of 999 variables per query. If there is just single field to insert, then we can hit another limit, SQLITE_MAX_COMPOUND_SELECT which defaults to 500. """ ...
[ "def", "bulk_batch_size", "(", "self", ",", "fields", ",", "objs", ")", ":", "limit", "=", "999", "if", "len", "(", "fields", ")", ">", "1", "else", "500", "return", "(", "limit", "//", "len", "(", "fields", ")", ")", "if", "len", "(", "fields", ...
[ 150, 4 ]
[ 159, 71 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper.check_constraints
(self, table_names=None)
Checks each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint ...
Checks each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint ...
def check_constraints(self, table_names=None): """ Checks each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows...
[ "def", "check_constraints", "(", "self", ",", "table_names", "=", "None", ")", ":", "cursor", "=", "self", ".", "cursor", "(", ")", "if", "table_names", "is", "None", ":", "table_names", "=", "self", ".", "introspection", ".", "table_names", "(", "cursor",...
[ 443, 4 ]
[ 478, 71 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper._start_transaction_under_autocommit
(self)
Start a transaction explicitly in autocommit mode. Staying in autocommit mode works around a bug of sqlite3 that breaks savepoints when autocommit is disabled.
Start a transaction explicitly in autocommit mode.
def _start_transaction_under_autocommit(self): """ Start a transaction explicitly in autocommit mode. Staying in autocommit mode works around a bug of sqlite3 that breaks savepoints when autocommit is disabled. """ self.cursor().execute("BEGIN")
[ "def", "_start_transaction_under_autocommit", "(", "self", ")", ":", "self", ".", "cursor", "(", ")", ".", "execute", "(", "\"BEGIN\"", ")" ]
[ 483, 4 ]
[ 490, 38 ]
python
en
['en', 'error', 'th']
False
_WKBReader.read
(self, wkb)
Returns a _pointer_ to C GEOS Geometry object from the given WKB.
Returns a _pointer_ to C GEOS Geometry object from the given WKB.
def read(self, wkb): "Returns a _pointer_ to C GEOS Geometry object from the given WKB." if isinstance(wkb, six.memoryview): wkb_s = bytes(wkb) return wkb_reader_read(self.ptr, wkb_s, len(wkb_s)) elif isinstance(wkb, (bytes, six.string_types)): return wkb_read...
[ "def", "read", "(", "self", ",", "wkb", ")", ":", "if", "isinstance", "(", "wkb", ",", "six", ".", "memoryview", ")", ":", "wkb_s", "=", "bytes", "(", "wkb", ")", "return", "wkb_reader_read", "(", "self", ".", "ptr", ",", "wkb_s", ",", "len", "(", ...
[ 163, 4 ]
[ 171, 27 ]
python
en
['en', 'en', 'en']
True
WKTWriter.write
(self, geom)
Returns the WKT representation of the given geometry.
Returns the WKT representation of the given geometry.
def write(self, geom): "Returns the WKT representation of the given geometry." return wkt_writer_write(self.ptr, geom.ptr)
[ "def", "write", "(", "self", ",", "geom", ")", ":", "return", "wkt_writer_write", "(", "self", ".", "ptr", ",", "geom", ".", "ptr", ")" ]
[ 180, 4 ]
[ 182, 51 ]
python
en
['en', 'en', 'en']
True
WKBWriter.write
(self, geom)
Returns the WKB representation of the given geometry.
Returns the WKB representation of the given geometry.
def write(self, geom): "Returns the WKB representation of the given geometry." return six.memoryview(wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t())))
[ "def", "write", "(", "self", ",", "geom", ")", ":", "return", "six", ".", "memoryview", "(", "wkb_writer_write", "(", "self", ".", "ptr", ",", "geom", ".", "ptr", ",", "byref", "(", "c_size_t", "(", ")", ")", ")", ")" ]
[ 200, 4 ]
[ 202, 86 ]
python
en
['en', 'en', 'en']
True
WKBWriter.write_hex
(self, geom)
Returns the HEXEWKB representation of the given geometry.
Returns the HEXEWKB representation of the given geometry.
def write_hex(self, geom): "Returns the HEXEWKB representation of the given geometry." return wkb_writer_write_hex(self.ptr, geom.ptr, byref(c_size_t()))
[ "def", "write_hex", "(", "self", ",", "geom", ")", ":", "return", "wkb_writer_write_hex", "(", "self", ".", "ptr", ",", "geom", ".", "ptr", ",", "byref", "(", "c_size_t", "(", ")", ")", ")" ]
[ 204, 4 ]
[ 206, 74 ]
python
en
['en', 'en', 'en']
True
is_password_usable
(encoded)
Return True if this password wasn't generated by User.set_unusable_password(), i.e. make_password(None).
Return True if this password wasn't generated by User.set_unusable_password(), i.e. make_password(None).
def is_password_usable(encoded): """ Return True if this password wasn't generated by User.set_unusable_password(), i.e. make_password(None). """ return encoded is None or not encoded.startswith(UNUSABLE_PASSWORD_PREFIX)
[ "def", "is_password_usable", "(", "encoded", ")", ":", "return", "encoded", "is", "None", "or", "not", "encoded", ".", "startswith", "(", "UNUSABLE_PASSWORD_PREFIX", ")" ]
[ 21, 0 ]
[ 26, 78 ]
python
en
['en', 'error', 'th']
False
check_password
(password, encoded, setter=None, preferred='default')
Return a boolean of whether the raw password matches the three part encoded digest. If setter is specified, it'll be called when you need to regenerate the password.
Return a boolean of whether the raw password matches the three part encoded digest.
def check_password(password, encoded, setter=None, preferred='default'): """ Return a boolean of whether the raw password matches the three part encoded digest. If setter is specified, it'll be called when you need to regenerate the password. """ if password is None or not is_password_usabl...
[ "def", "check_password", "(", "password", ",", "encoded", ",", "setter", "=", "None", ",", "preferred", "=", "'default'", ")", ":", "if", "password", "is", "None", "or", "not", "is_password_usable", "(", "encoded", ")", ":", "return", "False", "preferred", ...
[ 29, 0 ]
[ 60, 21 ]
python
en
['en', 'error', 'th']
False
make_password
(password, salt=None, hasher='default')
Turn a plain-text password into a hash for database storage Same as encode() but generate a new random salt. If password is None then return a concatenation of UNUSABLE_PASSWORD_PREFIX and a random string, which disallows logins. Additional random string reduces chances of gaining access to staff ...
Turn a plain-text password into a hash for database storage
def make_password(password, salt=None, hasher='default'): """ Turn a plain-text password into a hash for database storage Same as encode() but generate a new random salt. If password is None then return a concatenation of UNUSABLE_PASSWORD_PREFIX and a random string, which disallows logins. Additio...
[ "def", "make_password", "(", "password", ",", "salt", "=", "None", ",", "hasher", "=", "'default'", ")", ":", "if", "password", "is", "None", ":", "return", "UNUSABLE_PASSWORD_PREFIX", "+", "get_random_string", "(", "UNUSABLE_PASSWORD_SUFFIX_LENGTH", ")", "hasher"...
[ 63, 0 ]
[ 76, 40 ]
python
en
['en', 'error', 'th']
False
get_hasher
(algorithm='default')
Return an instance of a loaded password hasher. If algorithm is 'default', return the default hasher. Lazily import hashers specified in the project's settings file if needed.
Return an instance of a loaded password hasher.
def get_hasher(algorithm='default'): """ Return an instance of a loaded password hasher. If algorithm is 'default', return the default hasher. Lazily import hashers specified in the project's settings file if needed. """ if hasattr(algorithm, 'algorithm'): return algorithm elif alg...
[ "def", "get_hasher", "(", "algorithm", "=", "'default'", ")", ":", "if", "hasattr", "(", "algorithm", ",", "'algorithm'", ")", ":", "return", "algorithm", "elif", "algorithm", "==", "'default'", ":", "return", "get_hashers", "(", ")", "[", "0", "]", "else"...
[ 104, 0 ]
[ 124, 52 ]
python
en
['en', 'error', 'th']
False
identify_hasher
(encoded)
Return an instance of a loaded password hasher. Identify hasher algorithm by examining encoded hash, and call get_hasher() to return hasher. Raise ValueError if algorithm cannot be identified, or if hasher is not loaded.
Return an instance of a loaded password hasher.
def identify_hasher(encoded): """ Return an instance of a loaded password hasher. Identify hasher algorithm by examining encoded hash, and call get_hasher() to return hasher. Raise ValueError if algorithm cannot be identified, or if hasher is not loaded. """ # Ancient versions of Django cre...
[ "def", "identify_hasher", "(", "encoded", ")", ":", "# Ancient versions of Django created plain MD5 passwords and accepted", "# MD5 passwords with an empty salt.", "if", "(", "(", "len", "(", "encoded", ")", "==", "32", "and", "'$'", "not", "in", "encoded", ")", "or", ...
[ 127, 0 ]
[ 145, 32 ]
python
en
['en', 'error', 'th']
False
mask_hash
(hash, show=6, char="*")
Return the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons.
Return the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons.
def mask_hash(hash, show=6, char="*"): """ Return the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons. """ masked = hash[:show] masked += char * len(hash[show:]) return masked
[ "def", "mask_hash", "(", "hash", ",", "show", "=", "6", ",", "char", "=", "\"*\"", ")", ":", "masked", "=", "hash", "[", ":", "show", "]", "masked", "+=", "char", "*", "len", "(", "hash", "[", "show", ":", "]", ")", "return", "masked" ]
[ 148, 0 ]
[ 155, 17 ]
python
en
['en', 'error', 'th']
False
BasePasswordHasher.salt
(self)
Generate a cryptographically secure nonce salt in ASCII.
Generate a cryptographically secure nonce salt in ASCII.
def salt(self): """Generate a cryptographically secure nonce salt in ASCII.""" return get_random_string()
[ "def", "salt", "(", "self", ")", ":", "return", "get_random_string", "(", ")" ]
[ 185, 4 ]
[ 187, 34 ]
python
en
['en', 'en', 'en']
True
BasePasswordHasher.verify
(self, password, encoded)
Check if the given password is correct.
Check if the given password is correct.
def verify(self, password, encoded): """Check if the given password is correct.""" raise NotImplementedError('subclasses of BasePasswordHasher must provide a verify() method')
[ "def", "verify", "(", "self", ",", "password", ",", "encoded", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BasePasswordHasher must provide a verify() method'", ")" ]
[ 189, 4 ]
[ 191, 100 ]
python
en
['en', 'en', 'en']
True
BasePasswordHasher.encode
(self, password, salt)
Create an encoded database value. The result is normally formatted as "algorithm$salt$hash" and must be fewer than 128 characters.
Create an encoded database value.
def encode(self, password, salt): """ Create an encoded database value. The result is normally formatted as "algorithm$salt$hash" and must be fewer than 128 characters. """ raise NotImplementedError('subclasses of BasePasswordHasher must provide an encode() method')
[ "def", "encode", "(", "self", ",", "password", ",", "salt", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BasePasswordHasher must provide an encode() method'", ")" ]
[ 193, 4 ]
[ 200, 101 ]
python
en
['en', 'error', 'th']
False