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
BaseDatabaseSchemaEditor.remove_field
(self, model, field)
Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
def remove_field(self, model, field): """ Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table. """ # Special-case implicit M2M tables if field.many_to_many and field.remote_field.through._meta.auto_created: ...
[ "def", "remove_field", "(", "self", ",", "model", ",", "field", ")", ":", "# Special-case implicit M2M tables", "if", "field", ".", "many_to_many", "and", "field", ".", "remote_field", ".", "through", ".", "_meta", ".", "auto_created", ":", "return", "self", "...
[ 497, 4 ]
[ 525, 45 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.alter_field
(self, model, old_field, new_field, strict=False)
Allow a field's type, uniqueness, nullability, default, column, constraints, etc. to be modified. `old_field` is required to compute the necessary changes. If `strict` is True, raise errors if the old column does not match `old_field` precisely.
Allow a field's type, uniqueness, nullability, default, column, constraints, etc. to be modified. `old_field` is required to compute the necessary changes. If `strict` is True, raise errors if the old column does not match `old_field` precisely.
def alter_field(self, model, old_field, new_field, strict=False): """ Allow a field's type, uniqueness, nullability, default, column, constraints, etc. to be modified. `old_field` is required to compute the necessary changes. If `strict` is True, raise errors if the old column do...
[ "def", "alter_field", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "strict", "=", "False", ")", ":", "# Ensure this field is even column-based", "old_db_params", "=", "old_field", ".", "db_parameters", "(", "connection", "=", "self", ".", ...
[ 527, 4 ]
[ 566, 63 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._alter_field
(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False)
Perform a "physical" (non-ManyToMany) field update.
Perform a "physical" (non-ManyToMany) field update.
def _alter_field(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False): """Perform a "physical" (non-ManyToMany) field update.""" # Drop any FK constraints, we'll remake them later fks_dropped = set() if old_field.remote_f...
[ "def", "_alter_field", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "old_type", ",", "new_type", ",", "old_db_params", ",", "new_db_params", ",", "strict", "=", "False", ")", ":", "# Drop any FK constraints, we'll remake them later", "fks_drop...
[ 568, 4 ]
[ 810, 35 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseSchemaEditor._alter_column_null_sql
(self, model, old_field, new_field)
Hook to specialize column null alteration. Return a (sql, params) fragment to set a column to null or non-null as required by new_field, or None if no changes are required.
Hook to specialize column null alteration.
def _alter_column_null_sql(self, model, old_field, new_field): """ Hook to specialize column null alteration. Return a (sql, params) fragment to set a column to null or non-null as required by new_field, or None if no changes are required. """ if (self.connection.feature...
[ "def", "_alter_column_null_sql", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ")", ":", "if", "(", "self", ".", "connection", ".", "features", ".", "interprets_empty_strings_as_nulls", "and", "new_field", ".", "get_internal_type", "(", ")", "in...
[ 812, 4 ]
[ 832, 13 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._alter_column_default_sql
(self, model, old_field, new_field, drop=False)
Hook to specialize column default alteration. Return a (sql, params) fragment to add or drop (depending on the drop argument) a default to new_field's column.
Hook to specialize column default alteration.
def _alter_column_default_sql(self, model, old_field, new_field, drop=False): """ Hook to specialize column default alteration. Return a (sql, params) fragment to add or drop (depending on the drop argument) a default to new_field's column. """ new_default = self.effecti...
[ "def", "_alter_column_default_sql", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "drop", "=", "False", ")", ":", "new_default", "=", "self", ".", "effective_default", "(", "new_field", ")", "default", "=", "self", ".", "_column_default_s...
[ 834, 4 ]
[ 863, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._alter_column_type_sql
(self, model, old_field, new_field, new_type)
Hook to specialize column type alteration for different backends, for cases when a creation type is different to an alteration type (e.g. SERIAL in PostgreSQL, PostGIS fields). Return a two-tuple of: an SQL fragment of (sql, params) to insert into an ALTER TABLE statement and a...
Hook to specialize column type alteration for different backends, for cases when a creation type is different to an alteration type (e.g. SERIAL in PostgreSQL, PostGIS fields).
def _alter_column_type_sql(self, model, old_field, new_field, new_type): """ Hook to specialize column type alteration for different backends, for cases when a creation type is different to an alteration type (e.g. SERIAL in PostgreSQL, PostGIS fields). Return a two-tuple of: an...
[ "def", "_alter_column_type_sql", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "new_type", ")", ":", "return", "(", "(", "self", ".", "sql_alter_column_type", "%", "{", "\"column\"", ":", "self", ".", "quote_name", "(", "new_field", "."...
[ 865, 4 ]
[ 884, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._alter_many_to_many
(self, model, old_field, new_field, strict)
Alter M2Ms to repoint their to= endpoints.
Alter M2Ms to repoint their to= endpoints.
def _alter_many_to_many(self, model, old_field, new_field, strict): """Alter M2Ms to repoint their to= endpoints.""" # Rename the through table if old_field.remote_field.through._meta.db_table != new_field.remote_field.through._meta.db_table: self.alter_db_table(old_field.remote_fiel...
[ "def", "_alter_many_to_many", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "strict", ")", ":", "# Rename the through table", "if", "old_field", ".", "remote_field", ".", "through", ".", "_meta", ".", "db_table", "!=", "new_field", ".", "...
[ 886, 4 ]
[ 905, 9 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseSchemaEditor._create_index_name
(self, table_name, column_names, suffix="")
Generate a unique name for an index/unique constraint. The name is divided into 3 parts: the table name, the column names, and a unique digest and suffix.
Generate a unique name for an index/unique constraint.
def _create_index_name(self, table_name, column_names, suffix=""): """ Generate a unique name for an index/unique constraint. The name is divided into 3 parts: the table name, the column names, and a unique digest and suffix. """ _, table_name = split_identifier(table_na...
[ "def", "_create_index_name", "(", "self", ",", "table_name", ",", "column_names", ",", "suffix", "=", "\"\"", ")", ":", "_", ",", "table_name", "=", "split_identifier", "(", "table_name", ")", "hash_suffix_part", "=", "'%s%s'", "%", "(", "names_digest", "(", ...
[ 907, 4 ]
[ 934, 25 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._create_index_sql
(self, model, fields, *, name=None, suffix='', using='', db_tablespace=None, col_suffixes=(), sql=None, opclasses=(), condition=None)
Return the SQL statement to create the index for one or several fields. `sql` can be specified if the syntax differs from the standard (GIS indexes, ...).
Return the SQL statement to create the index for one or several fields. `sql` can be specified if the syntax differs from the standard (GIS indexes, ...).
def _create_index_sql(self, model, fields, *, name=None, suffix='', using='', db_tablespace=None, col_suffixes=(), sql=None, opclasses=(), condition=None): """ Return the SQL statement to create the index for one or several fields. `sql` can be...
[ "def", "_create_index_sql", "(", "self", ",", "model", ",", "fields", ",", "*", ",", "name", "=", "None", ",", "suffix", "=", "''", ",", "using", "=", "''", ",", "db_tablespace", "=", "None", ",", "col_suffixes", "=", "(", ")", ",", "sql", "=", "No...
[ 946, 4 ]
[ 973, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._model_indexes_sql
(self, model)
Return a list of all index SQL statements (field indexes, index_together, Meta.indexes) for the specified model.
Return a list of all index SQL statements (field indexes, index_together, Meta.indexes) for the specified model.
def _model_indexes_sql(self, model): """ Return a list of all index SQL statements (field indexes, index_together, Meta.indexes) for the specified model. """ if not model._meta.managed or model._meta.proxy or model._meta.swapped: return [] output = [] ...
[ "def", "_model_indexes_sql", "(", "self", ",", "model", ")", ":", "if", "not", "model", ".", "_meta", ".", "managed", "or", "model", ".", "_meta", ".", "proxy", "or", "model", ".", "_meta", ".", "swapped", ":", "return", "[", "]", "output", "=", "[",...
[ 985, 4 ]
[ 1002, 21 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._field_indexes_sql
(self, model, field)
Return a list of all index SQL statements for the specified field.
Return a list of all index SQL statements for the specified field.
def _field_indexes_sql(self, model, field): """ Return a list of all index SQL statements for the specified field. """ output = [] if self._field_should_be_indexed(model, field): output.append(self._create_index_sql(model, [field])) return output
[ "def", "_field_indexes_sql", "(", "self", ",", "model", ",", "field", ")", ":", "output", "=", "[", "]", "if", "self", ".", "_field_should_be_indexed", "(", "model", ",", "field", ")", ":", "output", ".", "append", "(", "self", ".", "_create_index_sql", ...
[ 1004, 4 ]
[ 1011, 21 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._constraint_names
(self, model, column_names=None, unique=None, primary_key=None, index=None, foreign_key=None, check=None, type_=None, exclude=None)
Return all constraint names matching the columns and conditions.
Return all constraint names matching the columns and conditions.
def _constraint_names(self, model, column_names=None, unique=None, primary_key=None, index=None, foreign_key=None, check=None, type_=None, exclude=None): """Return all constraint names matching the columns and conditions.""" if column_names is not None...
[ "def", "_constraint_names", "(", "self", ",", "model", ",", "column_names", "=", "None", ",", "unique", "=", "None", ",", "primary_key", "=", "None", ",", "index", "=", "None", ",", "foreign_key", "=", "None", ",", "check", "=", "None", ",", "type_", "...
[ 1139, 4 ]
[ 1167, 21 ]
python
en
['en', 'en', 'en']
True
OrderingTests.test_default_ordering
(self)
By default, Article.objects.all() orders by pub_date descending, then headline ascending.
By default, Article.objects.all() orders by pub_date descending, then headline ascending.
def test_default_ordering(self): """ By default, Article.objects.all() orders by pub_date descending, then headline ascending. """ self.assertQuerysetEqual( Article.objects.all(), [ "Article 4", "Article 2", "Article 3",...
[ "def", "test_default_ordering", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "all", "(", ")", ",", "[", "\"Article 4\"", ",", "\"Article 2\"", ",", "\"Article 3\"", ",", "\"Article 1\"", ",", "]", ",", "attr...
[ 25, 4 ]
[ 41, 59 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_default_ordering_override
(self)
Override ordering with order_by, which is in the same format as the ordering attribute in models.
Override ordering with order_by, which is in the same format as the ordering attribute in models.
def test_default_ordering_override(self): """ Override ordering with order_by, which is in the same format as the ordering attribute in models. """ self.assertQuerysetEqual( Article.objects.order_by("headline"), [ "Article 1", "Article ...
[ "def", "test_default_ordering_override", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "order_by", "(", "\"headline\"", ")", ",", "[", "\"Article 1\"", ",", "\"Article 2\"", ",", "\"Article 3\"", ",", "\"Article 4\...
[ 43, 4 ]
[ 65, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_order_by_override
(self)
Only the last order_by has any effect (since they each override any previous ordering).
Only the last order_by has any effect (since they each override any previous ordering).
def test_order_by_override(self): """ Only the last order_by has any effect (since they each override any previous ordering). """ self.assertQuerysetEqual( Article.objects.order_by("id"), [ "Article 1", "Article 2", "Art...
[ "def", "test_order_by_override", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "order_by", "(", "\"id\"", ")", ",", "[", "\"Article 1\"", ",", "\"Article 2\"", ",", "\"Article 3\"", ",", "\"Article 4\"", ",", "...
[ 67, 4 ]
[ 89, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_stop_slicing
(self)
Use the 'stop' part of slicing notation to limit the results.
Use the 'stop' part of slicing notation to limit the results.
def test_stop_slicing(self): """ Use the 'stop' part of slicing notation to limit the results. """ self.assertQuerysetEqual( Article.objects.order_by("headline")[:2], [ "Article 1", "Article 2", ], attrgetter("headline")...
[ "def", "test_stop_slicing", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "order_by", "(", "\"headline\"", ")", "[", ":", "2", "]", ",", "[", "\"Article 1\"", ",", "\"Article 2\"", ",", "]", ",", "attrgette...
[ 91, 4 ]
[ 101, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_stop_start_slicing
(self)
Use the 'stop' and 'start' parts of slicing notation to offset the result list.
Use the 'stop' and 'start' parts of slicing notation to offset the result list.
def test_stop_start_slicing(self): """ Use the 'stop' and 'start' parts of slicing notation to offset the result list. """ self.assertQuerysetEqual( Article.objects.order_by("headline")[1:3], [ "Article 2", "Article 3", ], ...
[ "def", "test_stop_start_slicing", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "order_by", "(", "\"headline\"", ")", "[", "1", ":", "3", "]", ",", "[", "\"Article 2\"", ",", "\"Article 3\"", ",", "]", ",",...
[ 103, 4 ]
[ 114, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_random_ordering
(self)
Use '?' to order randomly.
Use '?' to order randomly.
def test_random_ordering(self): """ Use '?' to order randomly. """ self.assertEqual( len(list(Article.objects.order_by("?"))), 4 )
[ "def", "test_random_ordering", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "len", "(", "list", "(", "Article", ".", "objects", ".", "order_by", "(", "\"?\"", ")", ")", ")", ",", "4", ")" ]
[ 116, 4 ]
[ 122, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_reversed_ordering
(self)
Ordering can be reversed using the reverse() method on a queryset. This allows you to extract things like "the last two items" (reverse and then take the first two).
Ordering can be reversed using the reverse() method on a queryset. This allows you to extract things like "the last two items" (reverse and then take the first two).
def test_reversed_ordering(self): """ Ordering can be reversed using the reverse() method on a queryset. This allows you to extract things like "the last two items" (reverse and then take the first two). """ self.assertQuerysetEqual( Article.objects.all().reve...
[ "def", "test_reversed_ordering", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "all", "(", ")", ".", "reverse", "(", ")", "[", ":", "2", "]", ",", "[", "\"Article 1\"", ",", "\"Article 3\"", ",", "]", "...
[ 124, 4 ]
[ 136, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_extra_ordering
(self)
Ordering can be based on fields included from an 'extra' clause
Ordering can be based on fields included from an 'extra' clause
def test_extra_ordering(self): """ Ordering can be based on fields included from an 'extra' clause """ self.assertQuerysetEqual( Article.objects.extra(select={"foo": "pub_date"}, order_by=["foo", "headline"]), [ "Article 1", "Article 2", ...
[ "def", "test_extra_ordering", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "extra", "(", "select", "=", "{", "\"foo\"", ":", "\"pub_date\"", "}", ",", "order_by", "=", "[", "\"foo\"", ",", "\"headline\"", ...
[ 138, 4 ]
[ 150, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_extra_ordering_quoting
(self)
If the extra clause uses an SQL keyword for a name, it will be protected by quoting.
If the extra clause uses an SQL keyword for a name, it will be protected by quoting.
def test_extra_ordering_quoting(self): """ If the extra clause uses an SQL keyword for a name, it will be protected by quoting. """ self.assertQuerysetEqual( Article.objects.extra(select={"order": "pub_date"}, order_by=["order", "headline"]), [ "Articl...
[ "def", "test_extra_ordering_quoting", "(", "self", ")", ":", "self", ".", "assertQuerysetEqual", "(", "Article", ".", "objects", ".", "extra", "(", "select", "=", "{", "\"order\"", ":", "\"pub_date\"", "}", ",", "order_by", "=", "[", "\"order\"", ",", "\"hea...
[ 152, 4 ]
[ 165, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_order_by_pk
(self)
Ensure that 'pk' works as an ordering option in Meta. Refs #8291.
Ensure that 'pk' works as an ordering option in Meta. Refs #8291.
def test_order_by_pk(self): """ Ensure that 'pk' works as an ordering option in Meta. Refs #8291. """ Author.objects.create(pk=1) Author.objects.create(pk=2) Author.objects.create(pk=3) Author.objects.create(pk=4) self.assertQuerysetEqual( ...
[ "def", "test_order_by_pk", "(", "self", ")", ":", "Author", ".", "objects", ".", "create", "(", "pk", "=", "1", ")", "Author", ".", "objects", ".", "create", "(", "pk", "=", "2", ")", "Author", ".", "objects", ".", "create", "(", "pk", "=", "3", ...
[ 167, 4 ]
[ 182, 9 ]
python
en
['en', 'error', 'th']
False
OrderingTests.test_order_by_fk_attname
(self)
Ensure that ordering by a foreign key by its attribute name prevents the query from inheriting it's related model ordering option. Refs #19195.
Ensure that ordering by a foreign key by its attribute name prevents the query from inheriting it's related model ordering option. Refs #19195.
def test_order_by_fk_attname(self): """ Ensure that ordering by a foreign key by its attribute name prevents the query from inheriting it's related model ordering option. Refs #19195. """ for i in range(1, 5): author = Author.objects.create(pk=i) a...
[ "def", "test_order_by_fk_attname", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "5", ")", ":", "author", "=", "Author", ".", "objects", ".", "create", "(", "pk", "=", "i", ")", "article", "=", "getattr", "(", "self", ",", "\"a%d...
[ 184, 4 ]
[ 204, 9 ]
python
en
['en', 'error', 'th']
False
Deserializer
(stream_or_string, **options)
Deserialize a stream or string of JSON data.
Deserialize a stream or string of JSON data.
def Deserializer(stream_or_string, **options): """Deserialize a stream or string of JSON data.""" if not isinstance(stream_or_string, (bytes, str)): stream_or_string = stream_or_string.read() if isinstance(stream_or_string, bytes): stream_or_string = stream_or_string.decode() try: ...
[ "def", "Deserializer", "(", "stream_or_string", ",", "*", "*", "options", ")", ":", "if", "not", "isinstance", "(", "stream_or_string", ",", "(", "bytes", ",", "str", ")", ")", ":", "stream_or_string", "=", "stream_or_string", ".", "read", "(", ")", "if", ...
[ 60, 0 ]
[ 72, 45 ]
python
en
['en', 'en', 'en']
True
ImagePalette.getdata
(self)
Get palette contents in format suitable for the low-level ``im.putpalette`` primitive. .. warning:: This method is experimental.
Get palette contents in format suitable for the low-level ``im.putpalette`` primitive.
def getdata(self): """ Get palette contents in format suitable for the low-level ``im.putpalette`` primitive. .. warning:: This method is experimental. """ if self.rawmode: return self.rawmode, self.palette return self.mode + ";L", self.tobytes()
[ "def", "getdata", "(", "self", ")", ":", "if", "self", ".", "rawmode", ":", "return", "self", ".", "rawmode", ",", "self", ".", "palette", "return", "self", ".", "mode", "+", "\";L\"", ",", "self", ".", "tobytes", "(", ")" ]
[ 61, 4 ]
[ 70, 47 ]
python
en
['en', 'error', 'th']
False
ImagePalette.tobytes
(self)
Convert palette to bytes. .. warning:: This method is experimental.
Convert palette to bytes.
def tobytes(self): """Convert palette to bytes. .. warning:: This method is experimental. """ if self.rawmode: raise ValueError("palette contains raw palette data") if isinstance(self.palette, bytes): return self.palette arr = array.array("B", sel...
[ "def", "tobytes", "(", "self", ")", ":", "if", "self", ".", "rawmode", ":", "raise", "ValueError", "(", "\"palette contains raw palette data\"", ")", "if", "isinstance", "(", "self", ".", "palette", ",", "bytes", ")", ":", "return", "self", ".", "palette", ...
[ 72, 4 ]
[ 84, 29 ]
python
en
['en', 'en', 'en']
True
ImagePalette.getcolor
(self, color)
Given an rgb tuple, allocate palette entry. .. warning:: This method is experimental.
Given an rgb tuple, allocate palette entry.
def getcolor(self, color): """Given an rgb tuple, allocate palette entry. .. warning:: This method is experimental. """ if self.rawmode: raise ValueError("palette contains raw palette data") if isinstance(color, tuple): try: return self.co...
[ "def", "getcolor", "(", "self", ",", "color", ")", ":", "if", "self", ".", "rawmode", ":", "raise", "ValueError", "(", "\"palette contains raw palette data\"", ")", "if", "isinstance", "(", "color", ",", "tuple", ")", ":", "try", ":", "return", "self", "."...
[ 89, 4 ]
[ 113, 67 ]
python
en
['en', 'en', 'it']
True
ImagePalette.save
(self, fp)
Save palette to text file. .. warning:: This method is experimental.
Save palette to text file.
def save(self, fp): """Save palette to text file. .. warning:: This method is experimental. """ if self.rawmode: raise ValueError("palette contains raw palette data") if isinstance(fp, str): fp = open(fp, "w") fp.write("# Palette\n") fp.wr...
[ "def", "save", "(", "self", ",", "fp", ")", ":", "if", "self", ".", "rawmode", ":", "raise", "ValueError", "(", "\"palette contains raw palette data\"", ")", "if", "isinstance", "(", "fp", ",", "str", ")", ":", "fp", "=", "open", "(", "fp", ",", "\"w\"...
[ 115, 4 ]
[ 134, 18 ]
python
en
['en', 'en', 'en']
True
fix_location_header
(request, response)
Ensures that we always use an absolute URI in any location header in the response. This is required by RFC 2616, section 14.30. Code constructing response objects is free to insert relative paths, as this function converts them to absolute paths.
Ensures that we always use an absolute URI in any location header in the response. This is required by RFC 2616, section 14.30.
def fix_location_header(request, response): """ Ensures that we always use an absolute URI in any location header in the response. This is required by RFC 2616, section 14.30. Code constructing response objects is free to insert relative paths, as this function converts them to absolute paths. ...
[ "def", "fix_location_header", "(", "request", ",", "response", ")", ":", "if", "'Location'", "in", "response", ":", "response", "[", "'Location'", "]", "=", "request", ".", "build_absolute_uri", "(", "response", "[", "'Location'", "]", ")", "return", "response...
[ 11, 0 ]
[ 21, 19 ]
python
en
['en', 'error', 'th']
False
conditional_content_removal
(request, response)
Removes the content of responses for HEAD requests, 1xx, 204 and 304 responses. Ensures compliance with RFC 2616, section 4.3.
Removes the content of responses for HEAD requests, 1xx, 204 and 304 responses. Ensures compliance with RFC 2616, section 4.3.
def conditional_content_removal(request, response): """ Removes the content of responses for HEAD requests, 1xx, 204 and 304 responses. Ensures compliance with RFC 2616, section 4.3. """ if 100 <= response.status_code < 200 or response.status_code in (204, 304): if response.streaming: ...
[ "def", "conditional_content_removal", "(", "request", ",", "response", ")", ":", "if", "100", "<=", "response", ".", "status_code", "<", "200", "or", "response", ".", "status_code", "in", "(", "204", ",", "304", ")", ":", "if", "response", ".", "streaming"...
[ 24, 0 ]
[ 40, 19 ]
python
en
['en', 'error', 'th']
False
test_anonymize_user_data
(api_client, resource_in_unit, user)
Test anonymization of user data.
Test anonymization of user data.
def test_anonymize_user_data(api_client, resource_in_unit, user): """ Test anonymization of user data. """ user.first_name = 'testi_ukkeli' user.save() original_uuid = user.uuid original_email = user.email user_pk = user.pk SocialAccount.objects.create(user=user, uid=original_uuid, ...
[ "def", "test_anonymize_user_data", "(", "api_client", ",", "resource_in_unit", ",", "user", ")", ":", "user", ".", "first_name", "=", "'testi_ukkeli'", "user", ".", "save", "(", ")", "original_uuid", "=", "user", ".", "uuid", "original_email", "=", "user", "."...
[ 10, 0 ]
[ 42, 84 ]
python
en
['en', 'error', 'th']
False
Scheduler.process_cron_expression
(self, expression, tz=None)
Return an UTC cron expression based on local timezone supplied one.
Return an UTC cron expression based on local timezone supplied one.
def process_cron_expression(self, expression, tz=None): """ Return an UTC cron expression based on local timezone supplied one. """ m = re.search("localcron\((.*)\)", expression) if not m: log.debug(f"Not a local timezone CRON specification: {expression}.") retur...
[ "def", "process_cron_expression", "(", "self", ",", "expression", ",", "tz", "=", "None", ")", ":", "m", "=", "re", ".", "search", "(", "\"localcron\\((.*)\\)\"", ",", "expression", ")", "if", "not", "m", ":", "log", ".", "debug", "(", "f\"Not a local time...
[ 142, 4 ]
[ 180, 85 ]
python
en
['en', 'en', 'en']
True
get_field_size
(name)
Extract the size number from a "varchar(11)" type name
Extract the size number from a "varchar(11)" type name
def get_field_size(name): """ Extract the size number from a "varchar(11)" type name """ m = field_size_re.search(name) return int(m.group(1)) if m else None
[ "def", "get_field_size", "(", "name", ")", ":", "m", "=", "field_size_re", ".", "search", "(", "name", ")", "return", "int", "(", "m", ".", "group", "(", "1", ")", ")", "if", "m", "else", "None" ]
[ 15, 0 ]
[ 18, 41 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_table_list
(self, cursor)
Return a list of table and view names in the current database.
Return a list of table and view names in the current database.
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" # Skip the sqlite_sequence system table used for autoincrement key # generation. cursor.execute(""" SELECT name, type FROM sqlite_master WHERE type in ('table', ...
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "# Skip the sqlite_sequence system table used for autoincrement key", "# generation.", "cursor", ".", "execute", "(", "\"\"\"\n SELECT name, type FROM sqlite_master\n WHERE type in ('table', 'view') AND ...
[ 65, 4 ]
[ 73, 74 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_table_description
(self, cursor, table_name)
Return a description of the table with the DB-API cursor.description interface.
Return a description of the table with the DB-API cursor.description interface.
def get_table_description(self, cursor, table_name): """ Return a description of the table with the DB-API cursor.description interface. """ cursor.execute('PRAGMA table_info(%s)' % self.connection.ops.quote_name(table_name)) return [ FieldInfo( ...
[ "def", "get_table_description", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "cursor", ".", "execute", "(", "'PRAGMA table_info(%s)'", "%", "self", ".", "connection", ".", "ops", ".", "quote_name", "(", "table_name", ")", ")", "return", "[", "Fie...
[ 75, 4 ]
[ 87, 9 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_relations
(self, cursor, table_name)
Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table.
Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table.
def get_relations(self, cursor, table_name): """ Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table. """ # Dictionary of relations to return relations = {} # Schema for this table c...
[ "def", "get_relations", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "# Dictionary of relations to return", "relations", "=", "{", "}", "# Schema for this table", "cursor", ".", "execute", "(", "\"SELECT sql, type FROM sqlite_master \"", "\"WHERE tbl_name = %s A...
[ 93, 4 ]
[ 149, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_key_columns
(self, cursor, table_name)
Return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
Return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
def get_key_columns(self, cursor, table_name): """ Return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table. """ key_columns = [] # Schema for this table cursor.execute("SELECT sql FROM sqlite_master WHERE t...
[ "def", "get_key_columns", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "key_columns", "=", "[", "]", "# Schema for this table", "cursor", ".", "execute", "(", "\"SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s\"", ",", "[", "table_name", ",",...
[ 151, 4 ]
[ 178, 26 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_primary_key_column
(self, cursor, table_name)
Return the column name of the primary key for the given table.
Return the column name of the primary key for the given table.
def get_primary_key_column(self, cursor, table_name): """Return the column name of the primary key for the given table.""" # Don't use PRAGMA because that causes issues with some transactions cursor.execute( "SELECT sql, type FROM sqlite_master " "WHERE tbl_name = %s AND ...
[ "def", "get_primary_key_column", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "# Don't use PRAGMA because that causes issues with some transactions", "cursor", ".", "execute", "(", "\"SELECT sql, type FROM sqlite_master \"", "\"WHERE tbl_name = %s AND type IN ('table', 'v...
[ 180, 4 ]
[ 201, 19 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns.
Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns.
def get_constraints(self, cursor, table_name): """ Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns. """ constraints = {} # Find inline check constraints. try: table_schema = cursor.execute( "SE...
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "{", "}", "# Find inline check constraints.", "try", ":", "table_schema", "=", "cursor", ".", "execute", "(", "\"SELECT sql FROM sqlite_master WHERE type='table' and n...
[ 339, 4 ]
[ 416, 26 ]
python
en
['en', 'error', 'th']
False
test_cli_micropy
(runner, mocker, mock_cwd)
should execute
should execute
def test_cli_micropy(runner, mocker, mock_cwd): """should execute""" if (mock_cwd / ".micropy").exists(): (mock_cwd / ".micropy").unlink() result = runner.invoke(cli.cli) assert result.exit_code == 0 expected = "CLI Application for creating/managing" " Micropython Projects." assert expec...
[ "def", "test_cli_micropy", "(", "runner", ",", "mocker", ",", "mock_cwd", ")", ":", "if", "(", "mock_cwd", "/", "\".micropy\"", ")", ".", "exists", "(", ")", ":", "(", "mock_cwd", "/", "\".micropy\"", ")", ".", "unlink", "(", ")", "result", "=", "runne...
[ 24, 0 ]
[ 36, 57 ]
python
en
['en', 'en', 'en']
False
test_stub_list
(mock_mpy, mocker, runner)
should list stubs
should list stubs
def test_stub_list(mock_mpy, mocker, runner): """should list stubs""" mock_mpy.log.title = print mock_mpy.log.info = print m_data = [("FakeFirmware", ["dev1", "dev2"])] mock_project = mocker.patch.object(cli, "Project") mock_mpy.resolve_project.return_value = mock_project.return_value mock_m...
[ "def", "test_stub_list", "(", "mock_mpy", ",", "mocker", ",", "runner", ")", ":", "mock_mpy", ".", "log", ".", "title", "=", "print", "mock_mpy", ".", "log", ".", "info", "=", "print", "m_data", "=", "[", "(", "\"FakeFirmware\"", ",", "[", "\"dev1\"", ...
[ 39, 0 ]
[ 52, 33 ]
python
en
['en', 'da', 'en']
True
test_stub_create
(runner, mock_mpy, mocker)
should call create_stubs
should call create_stubs
def test_stub_create(runner, mock_mpy, mocker): """should call create_stubs""" result = runner.invoke(cli.create, ["/dev/PORT"], obj=mock_mpy) mock_mpy.create_stubs.assert_called_once_with("/dev/PORT", verbose=False) assert result.exit_code == 0 mocker.patch.object(cli.utils, "CREATE_STUBS_INSTALLED...
[ "def", "test_stub_create", "(", "runner", ",", "mock_mpy", ",", "mocker", ")", ":", "result", "=", "runner", ".", "invoke", "(", "cli", ".", "create", ",", "[", "\"/dev/PORT\"", "]", ",", "obj", "=", "mock_mpy", ")", "mock_mpy", ".", "create_stubs", ".",...
[ 55, 0 ]
[ 62, 32 ]
python
en
['en', 'en', 'en']
True
test_cli_init
(mocker, mock_mpy, shared_datadir, mock_prompt, runner, cliargs, expargs)
should create project
should create project
def test_cli_init(mocker, mock_mpy, shared_datadir, mock_prompt, runner, cliargs, expargs): """should create project""" # Mock Project mock_project = mocker.patch.object(cli, "Project") mock_modules = mocker.patch.object(cli, "modules") # Mock Text Prompt ptext_mock = mocker.patch.object(cli.pro...
[ "def", "test_cli_init", "(", "mocker", ",", "mock_mpy", ",", "shared_datadir", ",", "mock_prompt", ",", "runner", ",", "cliargs", ",", "expargs", ")", ":", "# Mock Project", "mock_project", "=", "mocker", ".", "patch", ".", "object", "(", "cli", ",", "\"Proj...
[ 84, 0 ]
[ 113, 32 ]
python
en
['en', 'en', 'en']
True
test_cli_stubs_add
(mocker, mock_mpy, shared_datadir, runner, tmp_path, mock_checks)
should add stub
should add stub
def test_cli_stubs_add(mocker, mock_mpy, shared_datadir, runner, tmp_path, mock_checks): """should add stub""" mock_proj = mocker.patch.object(cli, "Project").return_value mock_proj.exists.return_value = True mock_mpy.project = mock_proj mock_mpy.stubs.add.side_effect = [cli.exc.StubError, cli.exc.S...
[ "def", "test_cli_stubs_add", "(", "mocker", ",", "mock_mpy", ",", "shared_datadir", ",", "runner", ",", "tmp_path", ",", "mock_checks", ")", ":", "mock_proj", "=", "mocker", ".", "patch", ".", "object", "(", "cli", ",", "\"Project\"", ")", ".", "return_value...
[ 116, 0 ]
[ 138, 32 ]
python
en
['en', 'cy', 'en']
True
test_cli_stubs_search
(mock_mpy, runner)
should search stubs
should search stubs
def test_cli_stubs_search(mock_mpy, runner): """should search stubs""" mock_mpy.stubs.search_remote.return_value = [ ( "esp8266-micropython-1.11.0", True, ), ( "esp8266-micropython-1.10.0", False, ), ] result = runner.invoke...
[ "def", "test_cli_stubs_search", "(", "mock_mpy", ",", "runner", ")", ":", "mock_mpy", ".", "stubs", ".", "search_remote", ".", "return_value", "=", "[", "(", "\"esp8266-micropython-1.11.0\"", ",", "True", ",", ")", ",", "(", "\"esp8266-micropython-1.10.0\"", ",", ...
[ 141, 0 ]
[ 154, 32 ]
python
en
['en', 'en', 'en']
True
read_CIFAR10
(data_folder)
Reads and parses examples from CIFAR10 data files
Reads and parses examples from CIFAR10 data files
def read_CIFAR10(data_folder): """ Reads and parses examples from CIFAR10 data files """ train_img = [] train_label = [] test_img = [] test_label = [] train_file_list = [ "data_batch_1", "data_batch_2", "data_batch_3", "data_batch_4", "data_batch_5", ...
[ "def", "read_CIFAR10", "(", "data_folder", ")", ":", "train_img", "=", "[", "]", "train_label", "=", "[", "]", "test_img", "=", "[", "]", "test_label", "=", "[", "]", "train_file_list", "=", "[", "\"data_batch_1\"", ",", "\"data_batch_2\"", ",", "\"data_batc...
[ 51, 0 ]
[ 115, 55 ]
python
en
['en', 'en', 'en']
True
read_CIFAR100
(data_folder)
Reads and parses examples from CIFAR100 python data files
Reads and parses examples from CIFAR100 python data files
def read_CIFAR100(data_folder): """ Reads and parses examples from CIFAR100 python data files """ train_img = [] train_label = [] test_img = [] test_label = [] train_file_list = ["cifar-100-python/train"] test_file_list = ["cifar-100-python/test"] tmp_dict = unpickle(os.path.join(data...
[ "def", "read_CIFAR100", "(", "data_folder", ")", ":", "train_img", "=", "[", "]", "train_label", "=", "[", "]", "test_img", "=", "[", "]", "test_label", "=", "[", "]", "train_file_list", "=", "[", "\"cifar-100-python/train\"", "]", "test_file_list", "=", "["...
[ 118, 0 ]
[ 160, 24 ]
python
en
['en', 'en', 'en']
True
View.__init__
(self, **kwargs)
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
def __init__(self, **kwargs): """ Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things. """ # Go through keyword arguments, and either save their values to our # instance, or raise an error. for key, value in kwargs.ite...
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Go through keyword arguments, and either save their values to our", "# instance, or raise an error.", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "self...
[ 37, 4 ]
[ 45, 37 ]
python
en
['en', 'error', 'th']
False
View.as_view
(cls, **initkwargs)
Main entry point for a request-response process.
Main entry point for a request-response process.
def as_view(cls, **initkwargs): """Main entry point for a request-response process.""" for key in initkwargs: if key in cls.http_method_names: raise TypeError("You tried to pass in the %s method name as a " "keyword argument to %s(). Don't do t...
[ "def", "as_view", "(", "cls", ",", "*", "*", "initkwargs", ")", ":", "for", "key", "in", "initkwargs", ":", "if", "key", "in", "cls", ".", "http_method_names", ":", "raise", "TypeError", "(", "\"You tried to pass in the %s method name as a \"", "\"keyword argument...
[ 48, 4 ]
[ 80, 19 ]
python
en
['en', 'en', 'en']
True
View.setup
(self, request, *args, **kwargs)
Initialize attributes shared by all view methods.
Initialize attributes shared by all view methods.
def setup(self, request, *args, **kwargs): """Initialize attributes shared by all view methods.""" self.request = request self.args = args self.kwargs = kwargs
[ "def", "setup", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "request", "=", "request", "self", ".", "args", "=", "args", "self", ".", "kwargs", "=", "kwargs" ]
[ 82, 4 ]
[ 86, 28 ]
python
en
['en', 'en', 'en']
True
View.options
(self, request, *args, **kwargs)
Handle responding to requests for the OPTIONS HTTP verb.
Handle responding to requests for the OPTIONS HTTP verb.
def options(self, request, *args, **kwargs): """Handle responding to requests for the OPTIONS HTTP verb.""" response = HttpResponse() response['Allow'] = ', '.join(self._allowed_methods()) response['Content-Length'] = '0' return response
[ "def", "options", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "HttpResponse", "(", ")", "response", "[", "'Allow'", "]", "=", "', '", ".", "join", "(", "self", ".", "_allowed_methods", "(", ")", ...
[ 105, 4 ]
[ 110, 23 ]
python
en
['en', 'en', 'en']
True
TemplateResponseMixin.render_to_response
(self, context, **response_kwargs)
Return a response, using the `response_class` for this view, with a template rendered with the given context. Pass response_kwargs to the constructor of the response class.
Return a response, using the `response_class` for this view, with a template rendered with the given context.
def render_to_response(self, context, **response_kwargs): """ Return a response, using the `response_class` for this view, with a template rendered with the given context. Pass response_kwargs to the constructor of the response class. """ response_kwargs.setdefault('cont...
[ "def", "render_to_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "response_kwargs", ".", "setdefault", "(", "'content_type'", ",", "self", ".", "content_type", ")", "return", "self", ".", "response_class", "(", "request", "...
[ 123, 4 ]
[ 137, 9 ]
python
en
['en', 'error', 'th']
False
TemplateResponseMixin.get_template_names
(self)
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
def get_template_names(self): """ Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden. """ if self.template_name is None: raise ImproperlyConfigured( "TemplateResponseM...
[ "def", "get_template_names", "(", "self", ")", ":", "if", "self", ".", "template_name", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "\"TemplateResponseMixin requires either a definition of \"", "\"'template_name' or an implementation of 'get_template_names()'\"", ")"...
[ 139, 4 ]
[ 149, 39 ]
python
en
['en', 'error', 'th']
False
RedirectView.get_redirect_url
(self, *args, **kwargs)
Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.
Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.
def get_redirect_url(self, *args, **kwargs): """ Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method. """ if self.url: url = self.url % kwargs elif self.pattern_...
[ "def", "get_redirect_url", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "url", ":", "url", "=", "self", ".", "url", "%", "kwargs", "elif", "self", ".", "pattern_name", ":", "url", "=", "reverse", "(", "self",...
[ 168, 4 ]
[ 184, 18 ]
python
en
['en', 'error', 'th']
False
connection_from_url
(url, **kw)
Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must include the scheme. Port is optional. ...
Given a url, return an :class:`.ConnectionPool` instance of its host.
def connection_from_url(url, **kw): """ Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must...
[ "def", "connection_from_url", "(", "url", ",", "*", "*", "kw", ")", ":", "scheme", ",", "host", ",", "port", "=", "get_host", "(", "url", ")", "port", "=", "port", "or", "port_by_scheme", ".", "get", "(", "scheme", ",", "80", ")", "if", "scheme", "...
[ 989, 0 ]
[ 1014, 56 ]
python
en
['en', 'error', 'th']
False
_normalize_host
(host, scheme)
Normalize hosts for comparisons and use with sockets.
Normalize hosts for comparisons and use with sockets.
def _normalize_host(host, scheme): """ Normalize hosts for comparisons and use with sockets. """ host = normalize_host(host, scheme) # httplib doesn't like it when we include brackets in IPv6 addresses # Specifically, if we include brackets but also pass the port then # httplib crazily dou...
[ "def", "_normalize_host", "(", "host", ",", "scheme", ")", ":", "host", "=", "normalize_host", "(", "host", ",", "scheme", ")", "# httplib doesn't like it when we include brackets in IPv6 addresses", "# Specifically, if we include brackets but also pass the port then", "# httplib...
[ 1017, 0 ]
[ 1032, 15 ]
python
en
['en', 'error', 'th']
False
ConnectionPool.close
(self)
Close all pooled connections and disable the pool.
Close all pooled connections and disable the pool.
def close(self): """ Close all pooled connections and disable the pool. """ pass
[ "def", "close", "(", "self", ")", ":", "pass" ]
[ 96, 4 ]
[ 100, 12 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._new_conn
(self)
Return a fresh :class:`HTTPConnection`.
Return a fresh :class:`HTTPConnection`.
def _new_conn(self): """ Return a fresh :class:`HTTPConnection`. """ self.num_connections += 1 log.debug( "Starting new HTTP connection (%d): %s:%s", self.num_connections, self.host, self.port or "80", ) conn = self...
[ "def", "_new_conn", "(", "self", ")", ":", "self", ".", "num_connections", "+=", "1", "log", ".", "debug", "(", "\"Starting new HTTP connection (%d): %s:%s\"", ",", "self", ".", "num_connections", ",", "self", ".", "host", ",", "self", ".", "port", "or", "\"...
[ 220, 4 ]
[ 239, 19 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._get_conn
(self, timeout=None)
Get a connection. Will return a pooled connection if one is available. If no connections are available and :prop:`.block` is ``False``, then a fresh connection is returned. :param timeout: Seconds to wait before giving up and raising :class:`urllib3.exceptions....
Get a connection. Will return a pooled connection if one is available.
def _get_conn(self, timeout=None): """ Get a connection. Will return a pooled connection if one is available. If no connections are available and :prop:`.block` is ``False``, then a fresh connection is returned. :param timeout: Seconds to wait before giving up and r...
[ "def", "_get_conn", "(", "self", ",", "timeout", "=", "None", ")", ":", "conn", "=", "None", "try", ":", "conn", "=", "self", ".", "pool", ".", "get", "(", "block", "=", "self", ".", "block", ",", "timeout", "=", "timeout", ")", "except", "Attribut...
[ 241, 4 ]
[ 278, 39 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._put_conn
(self, conn)
Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded because we exceeded maxsize. If connec...
Put a connection back into the pool.
def _put_conn(self, conn): """ Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded ...
[ "def", "_put_conn", "(", "self", ",", "conn", ")", ":", "try", ":", "self", ".", "pool", ".", "put", "(", "conn", ",", "block", "=", "False", ")", "return", "# Everything is dandy, done.", "except", "AttributeError", ":", "# self.pool is None.", "pass", "exc...
[ 280, 4 ]
[ 306, 24 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._validate_conn
(self, conn)
Called right before a request is made, after the socket is created.
Called right before a request is made, after the socket is created.
def _validate_conn(self, conn): """ Called right before a request is made, after the socket is created. """ pass
[ "def", "_validate_conn", "(", "self", ",", "conn", ")", ":", "pass" ]
[ 308, 4 ]
[ 312, 12 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._get_timeout
(self, timeout)
Helper that always returns a :class:`urllib3.util.Timeout`
Helper that always returns a :class:`urllib3.util.Timeout`
def _get_timeout(self, timeout): """ Helper that always returns a :class:`urllib3.util.Timeout` """ if timeout is _Default: return self.timeout.clone() if isinstance(timeout, Timeout): return timeout.clone() else: # User passed us an int/float. This i...
[ "def", "_get_timeout", "(", "self", ",", "timeout", ")", ":", "if", "timeout", "is", "_Default", ":", "return", "self", ".", "timeout", ".", "clone", "(", ")", "if", "isinstance", "(", "timeout", ",", "Timeout", ")", ":", "return", "timeout", ".", "clo...
[ 318, 4 ]
[ 328, 46 ]
python
en
['en', 'lb', 'en']
True
HTTPConnectionPool._raise_timeout
(self, err, url, timeout_value)
Is the error actually a timeout? Will raise a ReadTimeout or pass
Is the error actually a timeout? Will raise a ReadTimeout or pass
def _raise_timeout(self, err, url, timeout_value): """Is the error actually a timeout? Will raise a ReadTimeout or pass""" if isinstance(err, SocketTimeout): raise ReadTimeoutError( self, url, "Read timed out. (read timeout=%s)" % timeout_value ) # See t...
[ "def", "_raise_timeout", "(", "self", ",", "err", ",", "url", ",", "timeout_value", ")", ":", "if", "isinstance", "(", "err", ",", "SocketTimeout", ")", ":", "raise", "ReadTimeoutError", "(", "self", ",", "url", ",", "\"Read timed out. (read timeout=%s)\"", "%...
[ 330, 4 ]
[ 353, 13 ]
python
en
['en', 'en', 'en']
True
HTTPConnectionPool._make_request
( self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw )
Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: Socket timeout in seconds for the request. This can be a float or integer, which will set the same ...
Perform a request on a given urllib connection object taken from our pool.
def _make_request( self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw ): """ Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout:...
[ "def", "_make_request", "(", "self", ",", "conn", ",", "method", ",", "url", ",", "timeout", "=", "_Default", ",", "chunked", "=", "False", ",", "*", "*", "httplib_request_kw", ")", ":", "self", ".", "num_requests", "+=", "1", "timeout_obj", "=", "self",...
[ 355, 4 ]
[ 454, 31 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool.close
(self)
Close all pooled connections and disable the pool.
Close all pooled connections and disable the pool.
def close(self): """ Close all pooled connections and disable the pool. """ if self.pool is None: return # Disable access to the pool old_pool, self.pool = self.pool, None try: while True: conn = old_pool.get(block=False) ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "pool", "is", "None", ":", "return", "# Disable access to the pool", "old_pool", ",", "self", ".", "pool", "=", "self", ".", "pool", ",", "None", "try", ":", "while", "True", ":", "conn", "=", ...
[ 459, 4 ]
[ 475, 16 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool.is_same_host
(self, url)
Check if the given ``url`` is a member of the same host as this connection pool.
Check if the given ``url`` is a member of the same host as this connection pool.
def is_same_host(self, url): """ Check if the given ``url`` is a member of the same host as this connection pool. """ if url.startswith("/"): return True # TODO: Add optional support for socket.gethostbyname checking. scheme, host, port = get_host(url...
[ "def", "is_same_host", "(", "self", ",", "url", ")", ":", "if", "url", ".", "startswith", "(", "\"/\"", ")", ":", "return", "True", "# TODO: Add optional support for socket.gethostbyname checking.", "scheme", ",", "host", ",", "port", "=", "get_host", "(", "url"...
[ 477, 4 ]
[ 496, 74 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool.urlopen
( self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, chunked=False, body_pos=None, **response_kw )
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details. .. note:: More commonly, it's appropriate to use a convenience method provided by :class:`.RequestMethod...
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details.
def urlopen( self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, chunked=False, body_pos=None, **response_kw...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "retries", "=", "None", ",", "redirect", "=", "True", ",", "assert_same_host", "=", "True", ",", "timeout", "=", "_Default", ",", "p...
[ 498, 4 ]
[ 830, 23 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._prepare_conn
(self, conn)
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used.
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used.
def _prepare_conn(self, conn): """ Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used. """ if isinstance(conn, VerifiedHTTPSConnection): conn.set_cert( key_file=self.key_file, ...
[ "def", "_prepare_conn", "(", "self", ",", "conn", ")", ":", "if", "isinstance", "(", "conn", ",", "VerifiedHTTPSConnection", ")", ":", "conn", ".", "set_cert", "(", "key_file", "=", "self", ".", "key_file", ",", "key_password", "=", "self", ".", "key_passw...
[ 903, 4 ]
[ 921, 19 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._prepare_proxy
(self, conn)
Establish tunnel connection early, because otherwise httplib would improperly set Host: header to proxy's IP:port.
Establish tunnel connection early, because otherwise httplib would improperly set Host: header to proxy's IP:port.
def _prepare_proxy(self, conn): """ Establish tunnel connection early, because otherwise httplib would improperly set Host: header to proxy's IP:port. """ conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers) conn.connect()
[ "def", "_prepare_proxy", "(", "self", ",", "conn", ")", ":", "conn", ".", "set_tunnel", "(", "self", ".", "_proxy_host", ",", "self", ".", "port", ",", "self", ".", "proxy_headers", ")", "conn", ".", "connect", "(", ")" ]
[ 923, 4 ]
[ 929, 22 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._new_conn
(self)
Return a fresh :class:`httplib.HTTPSConnection`.
Return a fresh :class:`httplib.HTTPSConnection`.
def _new_conn(self): """ Return a fresh :class:`httplib.HTTPSConnection`. """ self.num_connections += 1 log.debug( "Starting new HTTPS connection (%d): %s:%s", self.num_connections, self.host, self.port or "443", ) ...
[ "def", "_new_conn", "(", "self", ")", ":", "self", ".", "num_connections", "+=", "1", "log", ".", "debug", "(", "\"Starting new HTTPS connection (%d): %s:%s\"", ",", "self", ".", "num_connections", ",", "self", ".", "host", ",", "self", ".", "port", "or", "\...
[ 931, 4 ]
[ 965, 39 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._validate_conn
(self, conn)
Called right before a request is made, after the socket is created.
Called right before a request is made, after the socket is created.
def _validate_conn(self, conn): """ Called right before a request is made, after the socket is created. """ super(HTTPSConnectionPool, self)._validate_conn(conn) # Force connect early to allow us to validate the connection. if not getattr(conn, "sock", None): # AppEngin...
[ "def", "_validate_conn", "(", "self", ",", "conn", ")", ":", "super", "(", "HTTPSConnectionPool", ",", "self", ")", ".", "_validate_conn", "(", "conn", ")", "# Force connect early to allow us to validate the connection.", "if", "not", "getattr", "(", "conn", ",", ...
[ 967, 4 ]
[ 986, 13 ]
python
en
['en', 'error', 'th']
False
staticfiles_urlpatterns
(prefix=None)
Helper function to return a URL pattern for serving static files.
Helper function to return a URL pattern for serving static files.
def staticfiles_urlpatterns(prefix=None): """ Helper function to return a URL pattern for serving static files. """ if prefix is None: prefix = settings.STATIC_URL return static(prefix, view=serve)
[ "def", "staticfiles_urlpatterns", "(", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "None", ":", "prefix", "=", "settings", ".", "STATIC_URL", "return", "static", "(", "prefix", ",", "view", "=", "serve", ")" ]
[ 7, 0 ]
[ 13, 37 ]
python
en
['en', 'error', 'th']
False
Installer._get_all_ns_packages
(self)
Return sorted list of all package namespaces
Return sorted list of all package namespaces
def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" pkgs = self.distribution.namespace_packages or [] return sorted(flatten(map(self._pkg_names, pkgs)))
[ "def", "_get_all_ns_packages", "(", "self", ")", ":", "pkgs", "=", "self", ".", "distribution", ".", "namespace_packages", "or", "[", "]", "return", "sorted", "(", "flatten", "(", "map", "(", "self", ".", "_pkg_names", ",", "pkgs", ")", ")", ")" ]
[ 84, 4 ]
[ 87, 58 ]
python
en
['en', 'en', 'en']
True
Installer._pkg_names
(pkg)
Given a namespace package, yield the components of that package. >>> names = Installer._pkg_names('a.b.c') >>> set(names) == set(['a', 'a.b', 'a.b.c']) True
Given a namespace package, yield the components of that package.
def _pkg_names(pkg): """ Given a namespace package, yield the components of that package. >>> names = Installer._pkg_names('a.b.c') >>> set(names) == set(['a', 'a.b', 'a.b.c']) True """ parts = pkg.split('.') while parts: yield '.'.joi...
[ "def", "_pkg_names", "(", "pkg", ")", ":", "parts", "=", "pkg", ".", "split", "(", "'.'", ")", "while", "parts", ":", "yield", "'.'", ".", "join", "(", "parts", ")", "parts", ".", "pop", "(", ")" ]
[ 90, 4 ]
[ 102, 23 ]
python
en
['en', 'error', 'th']
False
split_first
(s, delims)
.. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz',...
.. deprecated:: 1.25
def split_first(s, delims): """ .. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz'...
[ "def", "split_first", "(", "s", ",", "delims", ")", ":", "min_idx", "=", "None", "min_delim", "=", "None", "for", "d", "in", "delims", ":", "idx", "=", "s", ".", "find", "(", "d", ")", "if", "idx", "<", "0", ":", "continue", "if", "min_idx", "is"...
[ 174, 0 ]
[ 206, 51 ]
python
en
['en', 'error', 'th']
False
_encode_invalid_chars
(component, allowed_chars, encoding="utf-8")
Percent-encodes a URI component without reapplying onto an already percent-encoded component.
Percent-encodes a URI component without reapplying onto an already percent-encoded component.
def _encode_invalid_chars(component, allowed_chars, encoding="utf-8"): """Percent-encodes a URI component without reapplying onto an already percent-encoded component. """ if component is None: return component component = six.ensure_text(component) # Normalize existing percent-encoded...
[ "def", "_encode_invalid_chars", "(", "component", ",", "allowed_chars", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "component", "is", "None", ":", "return", "component", "component", "=", "six", ".", "ensure_text", "(", "component", ")", "# Normalize exi...
[ 209, 0 ]
[ 240, 45 ]
python
en
['en', 'en', 'en']
True
_encode_target
(target)
Percent-encodes a request target so that there are no invalid characters
Percent-encodes a request target so that there are no invalid characters
def _encode_target(target): """Percent-encodes a request target so that there are no invalid characters""" path, query = TARGET_RE.match(target).groups() target = _encode_invalid_chars(path, PATH_CHARS) query = _encode_invalid_chars(query, QUERY_CHARS) if query is not None: target += "?" + q...
[ "def", "_encode_target", "(", "target", ")", ":", "path", ",", "query", "=", "TARGET_RE", ".", "match", "(", "target", ")", ".", "groups", "(", ")", "target", "=", "_encode_invalid_chars", "(", "path", ",", "PATH_CHARS", ")", "query", "=", "_encode_invalid...
[ 319, 0 ]
[ 326, 17 ]
python
en
['en', 'en', 'en']
True
parse_url
(url)
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. :param str url: URL to...
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant.
def parse_url(url): """ Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. ...
[ "def", "parse_url", "(", "url", ")", ":", "if", "not", "url", ":", "# Empty", "return", "Url", "(", ")", "source_url", "=", "url", "if", "not", "SCHEME_RE", ".", "search", "(", "url", ")", ":", "url", "=", "\"//\"", "+", "url", "try", ":", "scheme"...
[ 329, 0 ]
[ 421, 5 ]
python
en
['en', 'error', 'th']
False
get_host
(url)
Deprecated. Use :func:`parse_url` instead.
Deprecated. Use :func:`parse_url` instead.
def get_host(url): """ Deprecated. Use :func:`parse_url` instead. """ p = parse_url(url) return p.scheme or "http", p.hostname, p.port
[ "def", "get_host", "(", "url", ")", ":", "p", "=", "parse_url", "(", "url", ")", "return", "p", ".", "scheme", "or", "\"http\"", ",", "p", ".", "hostname", ",", "p", ".", "port" ]
[ 424, 0 ]
[ 429, 49 ]
python
en
['en', 'error', 'th']
False
Url.hostname
(self)
For backwards-compatibility with urlparse. We're nice like that.
For backwards-compatibility with urlparse. We're nice like that.
def hostname(self): """For backwards-compatibility with urlparse. We're nice like that.""" return self.host
[ "def", "hostname", "(", "self", ")", ":", "return", "self", ".", "host" ]
[ 109, 4 ]
[ 111, 24 ]
python
en
['en', 'en', 'en']
True
Url.request_uri
(self)
Absolute path including the query string.
Absolute path including the query string.
def request_uri(self): """Absolute path including the query string.""" uri = self.path or "/" if self.query is not None: uri += "?" + self.query return uri
[ "def", "request_uri", "(", "self", ")", ":", "uri", "=", "self", ".", "path", "or", "\"/\"", "if", "self", ".", "query", "is", "not", "None", ":", "uri", "+=", "\"?\"", "+", "self", ".", "query", "return", "uri" ]
[ 114, 4 ]
[ 121, 18 ]
python
en
['en', 'en', 'en']
True
Url.netloc
(self)
Network location including host and port
Network location including host and port
def netloc(self): """Network location including host and port""" if self.port: return "%s:%d" % (self.host, self.port) return self.host
[ "def", "netloc", "(", "self", ")", ":", "if", "self", ".", "port", ":", "return", "\"%s:%d\"", "%", "(", "self", ".", "host", ",", "self", ".", "port", ")", "return", "self", ".", "host" ]
[ 124, 4 ]
[ 128, 24 ]
python
en
['en', 'en', 'en']
True
Url.url
(self)
Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). ...
Convert self into a url
def url(self): """ Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port w...
[ "def", "url", "(", "self", ")", ":", "scheme", ",", "auth", ",", "host", ",", "port", ",", "path", ",", "query", ",", "fragment", "=", "self", "url", "=", "u\"\"", "# We use \"is not None\" we want things to happen with empty strings (or 0 port)", "if", "scheme", ...
[ 131, 4 ]
[ 168, 18 ]
python
en
['en', 'error', 'th']
False
Point.__init__
(self, x, y=None, z=None, srid=None)
The Point object may be initialized with either a tuple, or individual parameters. For Example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individual parameters
The Point object may be initialized with either a tuple, or individual parameters.
def __init__(self, x, y=None, z=None, srid=None): """ The Point object may be initialized with either a tuple, or individual parameters. For Example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individual par...
[ "def", "__init__", "(", "self", ",", "x", ",", "y", "=", "None", ",", "z", "=", "None", ",", "srid", "=", "None", ")", ":", "if", "isinstance", "(", "x", ",", "(", "tuple", ",", "list", ")", ")", ":", "# Here a tuple or list was passed in under the `x`...
[ 12, 4 ]
[ 40, 53 ]
python
en
['en', 'error', 'th']
False
Point._create_point
(self, ndim, coords)
Create a coordinate sequence, set X, Y, [Z], and create point
Create a coordinate sequence, set X, Y, [Z], and create point
def _create_point(self, ndim, coords): """ Create a coordinate sequence, set X, Y, [Z], and create point """ if ndim < 2 or ndim > 3: raise TypeError('Invalid point dimension: %s' % str(ndim)) cs = capi.create_cs(c_uint(1), c_uint(ndim)) i = iter(coords) ...
[ "def", "_create_point", "(", "self", ",", "ndim", ",", "coords", ")", ":", "if", "ndim", "<", "2", "or", "ndim", ">", "3", ":", "raise", "TypeError", "(", "'Invalid point dimension: %s'", "%", "str", "(", "ndim", ")", ")", "cs", "=", "capi", ".", "cr...
[ 42, 4 ]
[ 56, 36 ]
python
en
['en', 'error', 'th']
False
Point.__iter__
(self)
Allows iteration over coordinates of this Point.
Allows iteration over coordinates of this Point.
def __iter__(self): "Allows iteration over coordinates of this Point." for i in xrange(len(self)): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "len", "(", "self", ")", ")", ":", "yield", "self", "[", "i", "]" ]
[ 71, 4 ]
[ 74, 25 ]
python
en
['en', 'en', 'en']
True
Point.__len__
(self)
Returns the number of dimensions for this Point (either 0, 2 or 3).
Returns the number of dimensions for this Point (either 0, 2 or 3).
def __len__(self): "Returns the number of dimensions for this Point (either 0, 2 or 3)." if self.empty: return 0 if self.hasz: return 3 else: return 2
[ "def", "__len__", "(", "self", ")", ":", "if", "self", ".", "empty", ":", "return", "0", "if", "self", ".", "hasz", ":", "return", "3", "else", ":", "return", "2" ]
[ 76, 4 ]
[ 83, 20 ]
python
en
['en', 'en', 'en']
True
Point.get_x
(self)
Returns the X component of the Point.
Returns the X component of the Point.
def get_x(self): "Returns the X component of the Point." return self._cs.getOrdinate(0, 0)
[ "def", "get_x", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "0", ",", "0", ")" ]
[ 95, 4 ]
[ 97, 41 ]
python
en
['en', 'en', 'en']
True
Point.set_x
(self, value)
Sets the X component of the Point.
Sets the X component of the Point.
def set_x(self, value): "Sets the X component of the Point." self._cs.setOrdinate(0, 0, value)
[ "def", "set_x", "(", "self", ",", "value", ")", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "0", ",", "0", ",", "value", ")" ]
[ 99, 4 ]
[ 101, 41 ]
python
en
['en', 'en', 'en']
True
Point.get_y
(self)
Returns the Y component of the Point.
Returns the Y component of the Point.
def get_y(self): "Returns the Y component of the Point." return self._cs.getOrdinate(1, 0)
[ "def", "get_y", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "1", ",", "0", ")" ]
[ 103, 4 ]
[ 105, 41 ]
python
en
['en', 'en', 'en']
True
Point.set_y
(self, value)
Sets the Y component of the Point.
Sets the Y component of the Point.
def set_y(self, value): "Sets the Y component of the Point." self._cs.setOrdinate(1, 0, value)
[ "def", "set_y", "(", "self", ",", "value", ")", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "1", ",", "0", ",", "value", ")" ]
[ 107, 4 ]
[ 109, 41 ]
python
en
['en', 'en', 'en']
True
Point.get_z
(self)
Returns the Z component of the Point.
Returns the Z component of the Point.
def get_z(self): "Returns the Z component of the Point." if self.hasz: return self._cs.getOrdinate(2, 0) else: return None
[ "def", "get_z", "(", "self", ")", ":", "if", "self", ".", "hasz", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "2", ",", "0", ")", "else", ":", "return", "None" ]
[ 111, 4 ]
[ 116, 23 ]
python
en
['en', 'en', 'en']
True
Point.set_z
(self, value)
Sets the Z component of the Point.
Sets the Z component of the Point.
def set_z(self, value): "Sets the Z component of the Point." if self.hasz: self._cs.setOrdinate(2, 0, value) else: raise GEOSException('Cannot set Z on 2D Point.')
[ "def", "set_z", "(", "self", ",", "value", ")", ":", "if", "self", ".", "hasz", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "2", ",", "0", ",", "value", ")", "else", ":", "raise", "GEOSException", "(", "'Cannot set Z on 2D Point.'", ")" ]
[ 118, 4 ]
[ 123, 60 ]
python
en
['en', 'en', 'en']
True
Point.get_coords
(self)
Returns a tuple of the point.
Returns a tuple of the point.
def get_coords(self): "Returns a tuple of the point." return self._cs.tuple
[ "def", "get_coords", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "tuple" ]
[ 131, 4 ]
[ 133, 29 ]
python
en
['en', 'en', 'en']
True
Point.set_coords
(self, tup)
Sets the coordinates of the point with the given tuple.
Sets the coordinates of the point with the given tuple.
def set_coords(self, tup): "Sets the coordinates of the point with the given tuple." self._cs[0] = tup
[ "def", "set_coords", "(", "self", ",", "tup", ")", ":", "self", ".", "_cs", "[", "0", "]", "=", "tup" ]
[ 135, 4 ]
[ 137, 25 ]
python
en
['en', 'en', 'en']
True
_add_doc
(func, doc)
Add documentation to a function.
Add documentation to a function.
def _add_doc(func, doc): """Add documentation to a function.""" func.__doc__ = doc
[ "def", "_add_doc", "(", "func", ",", "doc", ")", ":", "func", ".", "__doc__", "=", "doc" ]
[ 74, 0 ]
[ 76, 22 ]
python
en
['en', 'en', 'en']
True
_import_module
(name)
Import module, returning the module after the last dot.
Import module, returning the module after the last dot.
def _import_module(name): """Import module, returning the module after the last dot.""" __import__(name) return sys.modules[name]
[ "def", "_import_module", "(", "name", ")", ":", "__import__", "(", "name", ")", "return", "sys", ".", "modules", "[", "name", "]" ]
[ 79, 0 ]
[ 82, 28 ]
python
en
['en', 'en', 'en']
True
add_move
(move)
Add an item to six.moves.
Add an item to six.moves.
def add_move(move): """Add an item to six.moves.""" setattr(_MovedItems, move.name, move)
[ "def", "add_move", "(", "move", ")", ":", "setattr", "(", "_MovedItems", ",", "move", ".", "name", ",", "move", ")" ]
[ 493, 0 ]
[ 495, 41 ]
python
en
['en', 'en', 'en']
True
remove_move
(name)
Remove item from six.moves.
Remove item from six.moves.
def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,))
[ "def", "remove_move", "(", "name", ")", ":", "try", ":", "delattr", "(", "_MovedItems", ",", "name", ")", "except", "AttributeError", ":", "try", ":", "del", "moves", ".", "__dict__", "[", "name", "]", "except", "KeyError", ":", "raise", "AttributeError", ...
[ 498, 0 ]
[ 506, 62 ]
python
en
['en', 'en', 'en']
True
with_metaclass
(meta, *bases)
Create a base class with a metaclass.
Create a base class with a metaclass.
def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(type): def __new__(cls, na...
[ "def", "with_metaclass", "(", "meta", ",", "*", "bases", ")", ":", "# This requires a bit of explanation: the basic idea is to make a dummy", "# metaclass for one level of class instantiation that replaces itself with", "# the actual metaclass.", "class", "metaclass", "(", "type", ")...
[ 839, 0 ]
[ 860, 61 ]
python
en
['en', 'en', 'en']
True