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
DatabaseSchemaEditor._set_field_new_type_null_status
(self, field, new_type)
Keep the null property of the old field. If it has changed, it will be handled separately.
Keep the null property of the old field. If it has changed, it will be handled separately.
def _set_field_new_type_null_status(self, field, new_type): """ Keep the null property of the old field. If it has changed, it will be handled separately. """ if field.null: new_type += " NULL" else: new_type += " NOT NULL" return new_type
[ "def", "_set_field_new_type_null_status", "(", "self", ",", "field", ",", "new_type", ")", ":", "if", "field", ".", "null", ":", "new_type", "+=", "\" NULL\"", "else", ":", "new_type", "+=", "\" NOT NULL\"", "return", "new_type" ]
[ 121, 4 ]
[ 130, 23 ]
python
en
['en', 'error', 'th']
False
Operation.deconstruct
(self)
Returns a 3-tuple of class import path (or just name if it lives under django.db.migrations), positional arguments, and keyword arguments.
Returns a 3-tuple of class import path (or just name if it lives under django.db.migrations), positional arguments, and keyword arguments.
def deconstruct(self): """ Returns a 3-tuple of class import path (or just name if it lives under django.db.migrations), positional arguments, and keyword arguments. """ return ( self.__class__.__name__, self._constructor_args[0], self....
[ "def", "deconstruct", "(", "self", ")", ":", "return", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "_constructor_args", "[", "0", "]", ",", "self", ".", "_constructor_args", "[", "1", "]", ",", ")" ]
[ 39, 4 ]
[ 49, 9 ]
python
en
['en', 'error', 'th']
False
Operation.state_forwards
(self, app_label, state)
Takes the state from the previous migration, and mutates it so that it matches what this migration would perform.
Takes the state from the previous migration, and mutates it so that it matches what this migration would perform.
def state_forwards(self, app_label, state): """ Takes the state from the previous migration, and mutates it so that it matches what this migration would perform. """ raise NotImplementedError('subclasses of Operation must provide a state_forwards() method')
[ "def", "state_forwards", "(", "self", ",", "app_label", ",", "state", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Operation must provide a state_forwards() method'", ")" ]
[ 51, 4 ]
[ 56, 99 ]
python
en
['en', 'error', 'th']
False
Operation.database_forwards
(self, app_label, schema_editor, from_state, to_state)
Performs the mutation on the database schema in the normal (forwards) direction.
Performs the mutation on the database schema in the normal (forwards) direction.
def database_forwards(self, app_label, schema_editor, from_state, to_state): """ Performs the mutation on the database schema in the normal (forwards) direction. """ raise NotImplementedError('subclasses of Operation must provide a database_forwards() method')
[ "def", "database_forwards", "(", "self", ",", "app_label", ",", "schema_editor", ",", "from_state", ",", "to_state", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Operation must provide a database_forwards() method'", ")" ]
[ 58, 4 ]
[ 63, 102 ]
python
en
['en', 'error', 'th']
False
Operation.database_backwards
(self, app_label, schema_editor, from_state, to_state)
Performs the mutation on the database schema in the reverse direction - e.g. if this were CreateModel, it would in fact drop the model's table.
Performs the mutation on the database schema in the reverse direction - e.g. if this were CreateModel, it would in fact drop the model's table.
def database_backwards(self, app_label, schema_editor, from_state, to_state): """ Performs the mutation on the database schema in the reverse direction - e.g. if this were CreateModel, it would in fact drop the model's table. """ raise NotImplementedError('subclasses of O...
[ "def", "database_backwards", "(", "self", ",", "app_label", ",", "schema_editor", ",", "from_state", ",", "to_state", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Operation must provide a database_backwards() method'", ")" ]
[ 65, 4 ]
[ 71, 103 ]
python
en
['en', 'error', 'th']
False
Operation.describe
(self)
Outputs a brief summary of what the action does.
Outputs a brief summary of what the action does.
def describe(self): """ Outputs a brief summary of what the action does. """ return "%s: %s" % (self.__class__.__name__, self._constructor_args)
[ "def", "describe", "(", "self", ")", ":", "return", "\"%s: %s\"", "%", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "_constructor_args", ")" ]
[ 73, 4 ]
[ 77, 75 ]
python
en
['en', 'error', 'th']
False
Operation.references_model
(self, name, app_label=None)
Returns True if there is a chance this operation references the given model name (as a string), with an optional app label for accuracy. Used for optimization. If in doubt, return True; returning a false positive will merely make the optimizer a little less efficient, while ret...
Returns True if there is a chance this operation references the given model name (as a string), with an optional app label for accuracy.
def references_model(self, name, app_label=None): """ Returns True if there is a chance this operation references the given model name (as a string), with an optional app label for accuracy. Used for optimization. If in doubt, return True; returning a false positive will merely ...
[ "def", "references_model", "(", "self", ",", "name", ",", "app_label", "=", "None", ")", ":", "return", "True" ]
[ 79, 4 ]
[ 89, 19 ]
python
en
['en', 'error', 'th']
False
Operation.references_field
(self, model_name, name, app_label=None)
Returns True if there is a chance this operation references the given field name, with an optional app label for accuracy. Used for optimization. If in doubt, return True.
Returns True if there is a chance this operation references the given field name, with an optional app label for accuracy.
def references_field(self, model_name, name, app_label=None): """ Returns True if there is a chance this operation references the given field name, with an optional app label for accuracy. Used for optimization. If in doubt, return True. """ return self.references_model(...
[ "def", "references_field", "(", "self", ",", "model_name", ",", "name", ",", "app_label", "=", "None", ")", ":", "return", "self", ".", "references_model", "(", "model_name", ",", "app_label", ")" ]
[ 91, 4 ]
[ 98, 59 ]
python
en
['en', 'error', 'th']
False
Operation.allowed_to_migrate
(self, connection_alias, model)
Returns if we're allowed to migrate the model. Checks the router, if it's a proxy, if it's managed, and if it's swapped out.
Returns if we're allowed to migrate the model. Checks the router, if it's a proxy, if it's managed, and if it's swapped out.
def allowed_to_migrate(self, connection_alias, model): """ Returns if we're allowed to migrate the model. Checks the router, if it's a proxy, if it's managed, and if it's swapped out. """ return ( router.allow_migrate(connection_alias, model) and not model...
[ "def", "allowed_to_migrate", "(", "self", ",", "connection_alias", ",", "model", ")", ":", "return", "(", "router", ".", "allow_migrate", "(", "connection_alias", ",", "model", ")", "and", "not", "model", ".", "_meta", ".", "proxy", "and", "not", "model", ...
[ 100, 4 ]
[ 110, 9 ]
python
en
['en', 'error', 'th']
False
GISLookup._check_geo_field
(cls, opts, lookup)
Utility for checking the given lookup with the given model options. The lookup is a string either specifying the geographic field, e.g. 'point, 'the_geom', or a related lookup on a geographic field like 'address__point'. If a GeometryField exists according to the given lookup o...
Utility for checking the given lookup with the given model options. The lookup is a string either specifying the geographic field, e.g. 'point, 'the_geom', or a related lookup on a geographic field like 'address__point'.
def _check_geo_field(cls, opts, lookup): """ Utility for checking the given lookup with the given model options. The lookup is a string either specifying the geographic field, e.g. 'point, 'the_geom', or a related lookup on a geographic field like 'address__point'. If a ...
[ "def", "_check_geo_field", "(", "cls", ",", "opts", ",", "lookup", ")", ":", "from", "django", ".", "contrib", ".", "gis", ".", "db", ".", "models", ".", "fields", "import", "GeometryField", "# This takes into account the situation where the lookup is a", "# lookup ...
[ 18, 4 ]
[ 55, 24 ]
python
en
['en', 'error', 'th']
False
unique_test
(fname, idx_class, num_images)
[o = open, c = closed, y = yes, n = no] example dataset of size 10 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 c, o, c, o, c, o, c, o, c, o n, y, n, y, n, n, y, n, y, n num_images = 4 n, y, n, n, n, n, y, n, n, n num_images = 2 example dataset of size 12 1, 2, 3, 4, 5, 6, 7...
[o = open, c = closed, y = yes, n = no] example dataset of size 10 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 c, o, c, o, c, o, c, o, c, o n, y, n, y, n, n, y, n, y, n num_images = 4 n, y, n, n, n, n, y, n, n, n num_images = 2
def unique_test(fname, idx_class, num_images): ''' [o = open, c = closed, y = yes, n = no] example dataset of size 10 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 c, o, c, o, c, o, c, o, c, o n, y, n, y, n, n, y, n, y, n num_images = 4 n, y, n, n, n, n, y, n, n, n num_images = 2 ...
[ "def", "unique_test", "(", "fname", ",", "idx_class", ",", "num_images", ")", ":", "if", "fname", "[", "0", "]", "==", "'v'", ":", "# val", "sample", "=", "int", "(", "fname", "[", "3", ":", "-", "4", "]", ")", "size", "=", "2800", "elif", "fname...
[ 33, 0 ]
[ 71, 35 ]
python
en
['en', 'error', 'th']
False
pair_test
(fname, idx_class, num_images)
[o = open, c = closed, y = yes, n = no] example dataset of size 10 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 c, o, c, o, c, o, c, o, c, o y, y, y, y, n, n, n, n, n, n num_images = 4 y, y, n, n, n, n, n, n, n, n num_images = 2
[o = open, c = closed, y = yes, n = no] example dataset of size 10 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 c, o, c, o, c, o, c, o, c, o y, y, y, y, n, n, n, n, n, n num_images = 4 y, y, n, n, n, n, n, n, n, n num_images = 2
def pair_test(fname, idx_class, num_images): ''' [o = open, c = closed, y = yes, n = no] example dataset of size 10 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 c, o, c, o, c, o, c, o, c, o y, y, y, y, n, n, n, n, n, n num_images = 4 y, y, n, n, n, n, n, n, n, n num_images = 2 '''...
[ "def", "pair_test", "(", "fname", ",", "idx_class", ",", "num_images", ")", ":", "if", "fname", "[", "0", "]", "==", "'v'", ":", "# val", "sample", "=", "int", "(", "fname", "[", "3", ":", "-", "4", "]", ")", "size", "=", "2800", "elif", "fname",...
[ 74, 0 ]
[ 99, 31 ]
python
en
['en', 'error', 'th']
False
make_dataset
(dir, class_to_idx, extensions, test_fun, num_images)
necessary for class CustomImageFolder
necessary for class CustomImageFolder
def make_dataset(dir, class_to_idx, extensions, test_fun, num_images): ''' necessary for class CustomImageFolder ''' images = [] dir = os.path.expanduser(dir) c0 = 0 c1 = 0 for target in sorted(os.listdir(dir)): d = os.path.join(dir, target) if not os.path.isdir(d): ...
[ "def", "make_dataset", "(", "dir", ",", "class_to_idx", ",", "extensions", ",", "test_fun", ",", "num_images", ")", ":", "images", "=", "[", "]", "dir", "=", "os", ".", "path", ".", "expanduser", "(", "dir", ")", "c0", "=", "0", "c1", "=", "0", "fo...
[ 102, 0 ]
[ 129, 17 ]
python
en
['en', 'error', 'th']
False
load_dataset_cc
( set_num, contrast, batch_size, split, prep_method='imagenet', regularization=0, num_trainimages=None, dat_augment=0, unique='pairs', return_dataset=0, crop_margin=0)
load data set for closed contours.
load data set for closed contours.
def load_dataset_cc( set_num, contrast, batch_size, split, prep_method='imagenet', regularization=0, num_trainimages=None, dat_augment=0, unique='pairs', return_dataset=0, crop_margin=0): """ load data set for closed contours. ...
[ "def", "load_dataset_cc", "(", "set_num", ",", "contrast", ",", "batch_size", ",", "split", ",", "prep_method", "=", "'imagenet'", ",", "regularization", "=", "0", ",", "num_trainimages", "=", "None", ",", "dat_augment", "=", "0", ",", "unique", "=", "'pairs...
[ 179, 0 ]
[ 252, 25 ]
python
en
['en', 'en', 'en']
True
get_a_pair2
(set_num, contrast, idx, crop_margin=0)
Get an image pair (closed and open version). This function is used for the heatmaps.
Get an image pair (closed and open version). This function is used for the heatmaps.
def get_a_pair2(set_num, contrast, idx, crop_margin=0): ''' Get an image pair (closed and open version). This function is used for the heatmaps. ''' assert idx < 1000 dat_dir = 'stimuli_for_heatmap' img_open = plt.imread(dat_dir + '/test28.png') # even numbers img_closed = plt.imread(dat_d...
[ "def", "get_a_pair2", "(", "set_num", ",", "contrast", ",", "idx", ",", "crop_margin", "=", "0", ")", ":", "assert", "idx", "<", "1000", "dat_dir", "=", "'stimuli_for_heatmap'", "img_open", "=", "plt", ".", "imread", "(", "dat_dir", "+", "'/test28.png'", "...
[ 297, 0 ]
[ 322, 73 ]
python
en
['en', 'en', 'en']
True
Dataset_OTF.__init__
(self, epoch_len, crop_margin)
Initialization
Initialization
def __init__(self, epoch_len, crop_margin): 'Initialization' self.len = epoch_len self.crop_margin = crop_margin
[ "def", "__init__", "(", "self", ",", "epoch_len", ",", "crop_margin", ")", ":", "self", ".", "len", "=", "epoch_len", "self", ".", "crop_margin", "=", "crop_margin" ]
[ 259, 4 ]
[ 262, 38 ]
python
co
['es', 'co', 'en']
False
Dataset_OTF.__getitem__
(self, idx)
Generates one sample of data
Generates one sample of data
def __getitem__(self, idx): 'Generates one sample of data' # set seed # random seed: use idx because of num_workers = 8, and time because of # multiple epochs np.random.seed((idx + 1) * int(time.time()) % (2**32 - 1)) # np.random.seed(torch.initial_seed() % (2**32 - 1)) ...
[ "def", "__getitem__", "(", "self", ",", "idx", ")", ":", "# set seed", "# random seed: use idx because of num_workers = 8, and time because of", "# multiple epochs", "np", ".", "random", ".", "seed", "(", "(", "idx", "+", "1", ")", "*", "int", "(", "time", ".", ...
[ 267, 4 ]
[ 294, 30 ]
python
en
['en', 'en', 'en']
True
subclass_exception
(name, parents, module, attached_to=None)
Create exception subclass. Used by ModelBase below. If 'attached_to' is supplied, the exception will be created in a way that allows it to be pickled, assuming the returned exception class will be added as an attribute to the 'attached_to' class.
Create exception subclass. Used by ModelBase below.
def subclass_exception(name, parents, module, attached_to=None): """ Create exception subclass. Used by ModelBase below. If 'attached_to' is supplied, the exception will be created in a way that allows it to be pickled, assuming the returned exception class will be added as an attribute to the 'att...
[ "def", "subclass_exception", "(", "name", ",", "parents", ",", "module", ",", "attached_to", "=", "None", ")", ":", "class_dict", "=", "{", "'__module__'", ":", "module", "}", "if", "attached_to", "is", "not", "None", ":", "def", "__reduce__", "(", "self",...
[ 34, 0 ]
[ 55, 42 ]
python
en
['en', 'error', 'th']
False
simple_class_factory
(model, attrs)
Needed for dynamic classes.
Needed for dynamic classes.
def simple_class_factory(model, attrs): """ Needed for dynamic classes. """ return model
[ "def", "simple_class_factory", "(", "model", ",", "attrs", ")", ":", "return", "model" ]
[ 1579, 0 ]
[ 1583, 16 ]
python
en
['en', 'error', 'th']
False
model_unpickle
(model_id, attrs, factory)
Used to unpickle Model subclasses with deferred fields.
Used to unpickle Model subclasses with deferred fields.
def model_unpickle(model_id, attrs, factory): """ Used to unpickle Model subclasses with deferred fields. """ if isinstance(model_id, tuple): model = apps.get_model(*model_id) else: # Backwards compat - the model was cached directly in earlier versions. model = model_id c...
[ "def", "model_unpickle", "(", "model_id", ",", "attrs", ",", "factory", ")", ":", "if", "isinstance", "(", "model_id", ",", "tuple", ")", ":", "model", "=", "apps", ".", "get_model", "(", "*", "model_id", ")", "else", ":", "# Backwards compat - the model was...
[ 1586, 0 ]
[ 1596, 27 ]
python
en
['en', 'error', 'th']
False
ModelBase._prepare
(cls)
Creates some methods once self._meta has been populated.
Creates some methods once self._meta has been populated.
def _prepare(cls): """ Creates some methods once self._meta has been populated. """ opts = cls._meta opts._prepare(cls) if opts.order_with_respect_to: cls.get_next_in_order = curry(cls._get_next_or_previous_in_order, is_next=True) cls.get_previous...
[ "def", "_prepare", "(", "cls", ")", ":", "opts", "=", "cls", ".", "_meta", "opts", ".", "_prepare", "(", "cls", ")", "if", "opts", ".", "order_with_respect_to", ":", "cls", ".", "get_next_in_order", "=", "curry", "(", "cls", ".", "_get_next_or_previous_in_...
[ 312, 4 ]
[ 354, 47 ]
python
en
['en', 'error', 'th']
False
Model.__reduce__
(self)
Provides pickling support. Normally, this just dispatches to Python's standard handling. However, for models with deferred field loading, we need to do things manually, as they're dynamically created classes and only module-level classes can be pickled by the default path.
Provides pickling support. Normally, this just dispatches to Python's standard handling. However, for models with deferred field loading, we need to do things manually, as they're dynamically created classes and only module-level classes can be pickled by the default path.
def __reduce__(self): """ Provides pickling support. Normally, this just dispatches to Python's standard handling. However, for models with deferred field loading, we need to do things manually, as they're dynamically created classes and only module-level classes can be pickled b...
[ "def", "__reduce__", "(", "self", ")", ":", "data", "=", "self", ".", "__dict__", "data", "[", "DJANGO_VERSION_PICKLE_KEY", "]", "=", "get_version", "(", ")", "if", "not", "self", ".", "_deferred", ":", "class_id", "=", "self", ".", "_meta", ".", "app_la...
[ 508, 4 ]
[ 527, 81 ]
python
en
['en', 'error', 'th']
False
Model.serializable_value
(self, field_name)
Returns the value of the field name for this instance. If the field is a foreign key, returns the id value, instead of the object. If there's no Field object with this name on the model, the model attribute's value is returned directly. Used to serialize a field's value (in the...
Returns the value of the field name for this instance. If the field is a foreign key, returns the id value, instead of the object. If there's no Field object with this name on the model, the model attribute's value is returned directly.
def serializable_value(self, field_name): """ Returns the value of the field name for this instance. If the field is a foreign key, returns the id value, instead of the object. If there's no Field object with this name on the model, the model attribute's value is returned directl...
[ "def", "serializable_value", "(", "self", ",", "field_name", ")", ":", "try", ":", "field", "=", "self", ".", "_meta", ".", "get_field_by_name", "(", "field_name", ")", "[", "0", "]", "except", "FieldDoesNotExist", ":", "return", "getattr", "(", "self", ",...
[ 556, 4 ]
[ 571, 43 ]
python
en
['en', 'error', 'th']
False
Model.save
(self, force_insert=False, force_update=False, using=None, update_fields=None)
Saves the current instance. Override this in a subclass if you want to control the saving process. The 'force_insert' and 'force_update' parameters can be used to insist that the "save" must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally...
Saves the current instance. Override this in a subclass if you want to control the saving process.
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): """ Saves the current instance. Override this in a subclass if you want to control the saving process. The 'force_insert' and 'force_update' parameters can be used to insist that...
[ "def", "save", "(", "self", ",", "force_insert", "=", "False", ",", "force_update", "=", "False", ",", "using", "=", "None", ",", "update_fields", "=", "None", ")", ":", "using", "=", "using", "or", "router", ".", "db_for_write", "(", "self", ".", "__c...
[ 573, 4 ]
[ 629, 78 ]
python
en
['en', 'error', 'th']
False
Model.save_base
(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None)
Handles the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending. The 'raw' argument is telling save_base not to save any parent models and not to do any changes to the values before ...
Handles the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
def save_base(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None): """ Handles the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending. ...
[ "def", "save_base", "(", "self", ",", "raw", "=", "False", ",", "force_insert", "=", "False", ",", "force_update", "=", "False", ",", "using", "=", "None", ",", "update_fields", "=", "None", ")", ":", "using", "=", "using", "or", "router", ".", "db_for...
[ 632, 4 ]
[ 666, 85 ]
python
en
['en', 'error', 'th']
False
Model._save_parents
(self, cls, using, update_fields)
Saves all the parents of cls using values from self.
Saves all the parents of cls using values from self.
def _save_parents(self, cls, using, update_fields): """ Saves all the parents of cls using values from self. """ meta = cls._meta for parent, field in meta.parents.items(): # Make sure the link fields are synced between parent and self. if (field and getat...
[ "def", "_save_parents", "(", "self", ",", "cls", ",", "using", ",", "update_fields", ")", ":", "meta", "=", "cls", ".", "_meta", "for", "parent", ",", "field", "in", "meta", ".", "parents", ".", "items", "(", ")", ":", "# Make sure the link fields are sync...
[ 670, 4 ]
[ 692, 45 ]
python
en
['en', 'error', 'th']
False
Model._save_table
(self, raw=False, cls=None, force_insert=False, force_update=False, using=None, update_fields=None)
Does the heavy-lifting involved in saving. Updates or inserts the data for a single table.
Does the heavy-lifting involved in saving. Updates or inserts the data for a single table.
def _save_table(self, raw=False, cls=None, force_insert=False, force_update=False, using=None, update_fields=None): """ Does the heavy-lifting involved in saving. Updates or inserts the data for a single table. """ meta = cls._meta non_pks = [f for f i...
[ "def", "_save_table", "(", "self", ",", "raw", "=", "False", ",", "cls", "=", "None", ",", "force_insert", "=", "False", ",", "force_update", "=", "False", ",", "using", "=", "None", ",", "update_fields", "=", "None", ")", ":", "meta", "=", "cls", "....
[ 694, 4 ]
[ 741, 22 ]
python
en
['en', 'error', 'th']
False
Model._do_update
(self, base_qs, using, pk_val, values, update_fields, forced_update)
This method will try to update the model. If the model was updated (in the sense that an update query was done and a matching row was found from the DB) the method will return True.
This method will try to update the model. If the model was updated (in the sense that an update query was done and a matching row was found from the DB) the method will return True.
def _do_update(self, base_qs, using, pk_val, values, update_fields, forced_update): """ This method will try to update the model. If the model was updated (in the sense that an update query was done and a matching row was found from the DB) the method will return True. """ ...
[ "def", "_do_update", "(", "self", ",", "base_qs", ",", "using", ",", "pk_val", ",", "values", ",", "update_fields", ",", "forced_update", ")", ":", "filtered", "=", "base_qs", ".", "filter", "(", "pk", "=", "pk_val", ")", "if", "not", "values", ":", "#...
[ 743, 4 ]
[ 763, 43 ]
python
en
['en', 'error', 'th']
False
Model._do_insert
(self, manager, using, fields, update_pk, raw)
Do an INSERT. If update_pk is defined then this method should return the new pk for the model.
Do an INSERT. If update_pk is defined then this method should return the new pk for the model.
def _do_insert(self, manager, using, fields, update_pk, raw): """ Do an INSERT. If update_pk is defined then this method should return the new pk for the model. """ return manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=...
[ "def", "_do_insert", "(", "self", ",", "manager", ",", "using", ",", "fields", ",", "update_pk", ",", "raw", ")", ":", "return", "manager", ".", "_insert", "(", "[", "self", "]", ",", "fields", "=", "fields", ",", "return_id", "=", "update_pk", ",", ...
[ 765, 4 ]
[ 771, 52 ]
python
en
['en', 'error', 'th']
False
Model.clean
(self)
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS....
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS....
def clean(self): """ Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field ...
[ "def", "clean", "(", "self", ")", ":", "pass" ]
[ 827, 4 ]
[ 834, 12 ]
python
en
['en', 'error', 'th']
False
Model.validate_unique
(self, exclude=None)
Checks unique constraints on the model and raises ``ValidationError`` if any failed.
Checks unique constraints on the model and raises ``ValidationError`` if any failed.
def validate_unique(self, exclude=None): """ Checks unique constraints on the model and raises ``ValidationError`` if any failed. """ unique_checks, date_checks = self._get_unique_checks(exclude=exclude) errors = self._perform_unique_checks(unique_checks) date_er...
[ "def", "validate_unique", "(", "self", ",", "exclude", "=", "None", ")", ":", "unique_checks", ",", "date_checks", "=", "self", ".", "_get_unique_checks", "(", "exclude", "=", "exclude", ")", "errors", "=", "self", ".", "_perform_unique_checks", "(", "unique_c...
[ 836, 4 ]
[ 850, 41 ]
python
en
['en', 'error', 'th']
False
Model._get_unique_checks
(self, exclude=None)
Gather a list of checks to perform. Since validate_unique could be called from a ModelForm, some fields may have been excluded; we can't perform a unique check on a model that is missing fields involved in that check. Fields that did not validate should also be excluded, but the...
Gather a list of checks to perform. Since validate_unique could be called from a ModelForm, some fields may have been excluded; we can't perform a unique check on a model that is missing fields involved in that check. Fields that did not validate should also be excluded, but the...
def _get_unique_checks(self, exclude=None): """ Gather a list of checks to perform. Since validate_unique could be called from a ModelForm, some fields may have been excluded; we can't perform a unique check on a model that is missing fields involved in that check. Fields...
[ "def", "_get_unique_checks", "(", "self", ",", "exclude", "=", "None", ")", ":", "if", "exclude", "is", "None", ":", "exclude", "=", "[", "]", "unique_checks", "=", "[", "]", "unique_togethers", "=", "[", "(", "self", ".", "__class__", ",", "self", "."...
[ 852, 4 ]
[ 902, 41 ]
python
en
['en', 'error', 'th']
False
Model.full_clean
(self, exclude=None, validate_unique=True)
Calls clean_fields, clean, and validate_unique, on the model, and raises a ``ValidationError`` for any errors that occurred.
Calls clean_fields, clean, and validate_unique, on the model, and raises a ``ValidationError`` for any errors that occurred.
def full_clean(self, exclude=None, validate_unique=True): """ Calls clean_fields, clean, and validate_unique, on the model, and raises a ``ValidationError`` for any errors that occurred. """ errors = {} if exclude is None: exclude = [] else: ...
[ "def", "full_clean", "(", "self", ",", "exclude", "=", "None", ",", "validate_unique", "=", "True", ")", ":", "errors", "=", "{", "}", "if", "exclude", "is", "None", ":", "exclude", "=", "[", "]", "else", ":", "exclude", "=", "list", "(", "exclude", ...
[ 1023, 4 ]
[ 1057, 41 ]
python
en
['en', 'error', 'th']
False
Model.clean_fields
(self, exclude=None)
Cleans all fields and raises a ValidationError containing a dict of all validation errors if any occur.
Cleans all fields and raises a ValidationError containing a dict of all validation errors if any occur.
def clean_fields(self, exclude=None): """ Cleans all fields and raises a ValidationError containing a dict of all validation errors if any occur. """ if exclude is None: exclude = [] errors = {} for f in self._meta.fields: if f.name in exc...
[ "def", "clean_fields", "(", "self", ",", "exclude", "=", "None", ")", ":", "if", "exclude", "is", "None", ":", "exclude", "=", "[", "]", "errors", "=", "{", "}", "for", "f", "in", "self", ".", "_meta", ".", "fields", ":", "if", "f", ".", "name", ...
[ 1059, 4 ]
[ 1082, 41 ]
python
en
['en', 'error', 'th']
False
Model._check_swappable
(cls)
Check if the swapped model exists.
Check if the swapped model exists.
def _check_swappable(cls): """ Check if the swapped model exists. """ errors = [] if cls._meta.swapped: try: apps.get_model(cls._meta.swapped) except ValueError: errors.append( checks.Error( "'%s...
[ "def", "_check_swappable", "(", "cls", ")", ":", "errors", "=", "[", "]", "if", "cls", ".", "_meta", ".", "swapped", ":", "try", ":", "apps", ".", "get_model", "(", "cls", ".", "_meta", ".", "swapped", ")", "except", "ValueError", ":", "errors", ".",...
[ 1107, 4 ]
[ 1135, 21 ]
python
en
['en', 'en', 'en']
True
Model._check_managers
(cls, **kwargs)
Perform all manager checks.
Perform all manager checks.
def _check_managers(cls, **kwargs): """ Perform all manager checks. """ errors = [] managers = cls._meta.concrete_managers + cls._meta.abstract_managers for __, __, manager in managers: errors.extend(manager.check(**kwargs)) return errors
[ "def", "_check_managers", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "errors", "=", "[", "]", "managers", "=", "cls", ".", "_meta", ".", "concrete_managers", "+", "cls", ".", "_meta", ".", "abstract_managers", "for", "__", ",", "__", ",", "manager"...
[ 1153, 4 ]
[ 1160, 21 ]
python
en
['en', 'en', 'en']
True
Model._check_fields
(cls, **kwargs)
Perform all field checks.
Perform all field checks.
def _check_fields(cls, **kwargs): """ Perform all field checks. """ errors = [] for field in cls._meta.local_fields: errors.extend(field.check(**kwargs)) for field in cls._meta.local_many_to_many: errors.extend(field.check(from_model=cls, **kwargs)) retur...
[ "def", "_check_fields", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "errors", "=", "[", "]", "for", "field", "in", "cls", ".", "_meta", ".", "local_fields", ":", "errors", ".", "extend", "(", "field", ".", "check", "(", "*", "*", "kwargs", ")", ...
[ 1163, 4 ]
[ 1171, 21 ]
python
en
['en', 'sk', 'en']
True
Model._check_m2m_through_same_relationship
(cls)
Check if no relationship model is used by more than one m2m field.
Check if no relationship model is used by more than one m2m field.
def _check_m2m_through_same_relationship(cls): """ Check if no relationship model is used by more than one m2m field. """ errors = [] seen_intermediary_signatures = [] fields = cls._meta.local_many_to_many # Skip when the target model wasn't found. fields = (f ...
[ "def", "_check_m2m_through_same_relationship", "(", "cls", ")", ":", "errors", "=", "[", "]", "seen_intermediary_signatures", "=", "[", "]", "fields", "=", "cls", ".", "_meta", ".", "local_many_to_many", "# Skip when the target model wasn't found.", "fields", "=", "("...
[ 1174, 4 ]
[ 1206, 21 ]
python
en
['en', 'en', 'en']
True
Model._check_id_field
(cls)
Check if `id` field is a primary key.
Check if `id` field is a primary key.
def _check_id_field(cls): """ Check if `id` field is a primary key. """ fields = list(f for f in cls._meta.local_fields if f.name == 'id' and f != cls._meta.pk) # fields is empty or consists of the invalid "id" field if fields and not fields[0].primary_key and cls._meta.pk.n...
[ "def", "_check_id_field", "(", "cls", ")", ":", "fields", "=", "list", "(", "f", "for", "f", "in", "cls", ".", "_meta", ".", "local_fields", "if", "f", ".", "name", "==", "'id'", "and", "f", "!=", "cls", ".", "_meta", ".", "pk", ")", "# fields is e...
[ 1209, 4 ]
[ 1226, 21 ]
python
en
['en', 'en', 'en']
True
Model._check_field_name_clashes
(cls)
Ref #17673.
Ref #17673.
def _check_field_name_clashes(cls): """ Ref #17673. """ errors = [] used_fields = {} # name or attname -> field # Check that multi-inheritance doesn't cause field name shadowing. for parent in cls._meta.parents: for f in parent._meta.local_fields: c...
[ "def", "_check_field_name_clashes", "(", "cls", ")", ":", "errors", "=", "[", "]", "used_fields", "=", "{", "}", "# name or attname -> field", "# Check that multi-inheritance doesn't cause field name shadowing.", "for", "parent", "in", "cls", ".", "_meta", ".", "parents...
[ 1229, 4 ]
[ 1281, 21 ]
python
en
['en', 'kk', 'ur']
False
Model._check_index_together
(cls)
Check the value of "index_together" option.
Check the value of "index_together" option.
def _check_index_together(cls): """ Check the value of "index_together" option. """ if not isinstance(cls._meta.index_together, (tuple, list)): return [ checks.Error( "'index_together' must be a list or tuple.", hint=None, ...
[ "def", "_check_index_together", "(", "cls", ")", ":", "if", "not", "isinstance", "(", "cls", ".", "_meta", ".", "index_together", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "[", "checks", ".", "Error", "(", "\"'index_together' must be a list or...
[ 1308, 4 ]
[ 1335, 25 ]
python
en
['en', 'en', 'en']
True
Model._check_unique_together
(cls)
Check the value of "unique_together" option.
Check the value of "unique_together" option.
def _check_unique_together(cls): """ Check the value of "unique_together" option. """ if not isinstance(cls._meta.unique_together, (tuple, list)): return [ checks.Error( "'unique_together' must be a list or tuple.", hint=None, ...
[ "def", "_check_unique_together", "(", "cls", ")", ":", "if", "not", "isinstance", "(", "cls", ".", "_meta", ".", "unique_together", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "[", "checks", ".", "Error", "(", "\"'unique_together' must be a list...
[ 1338, 4 ]
[ 1365, 25 ]
python
en
['en', 'en', 'en']
True
Model._check_ordering
(cls)
Check "ordering" option -- is it a list of strings and do all fields exist?
Check "ordering" option -- is it a list of strings and do all fields exist?
def _check_ordering(cls): """ Check "ordering" option -- is it a list of strings and do all fields exist? """ from django.db.models import FieldDoesNotExist if not cls._meta.ordering: return [] if not isinstance(cls._meta.ordering, (list, tuple)): retur...
[ "def", "_check_ordering", "(", "cls", ")", ":", "from", "django", ".", "db", ".", "models", "import", "FieldDoesNotExist", "if", "not", "cls", ".", "_meta", ".", "ordering", ":", "return", "[", "]", "if", "not", "isinstance", "(", "cls", ".", "_meta", ...
[ 1414, 4 ]
[ 1475, 21 ]
python
en
['en', 'en', 'en']
True
Model._check_long_column_names
(cls)
Check that any auto-generated column names are shorter than the limits for each database in which the model will be created.
Check that any auto-generated column names are shorter than the limits for each database in which the model will be created.
def _check_long_column_names(cls): """ Check that any auto-generated column names are shorter than the limits for each database in which the model will be created. """ errors = [] allowed_len = None db_alias = None # Find the minimum max allowed length am...
[ "def", "_check_long_column_names", "(", "cls", ")", ":", "errors", "=", "[", "]", "allowed_len", "=", "None", "db_alias", "=", "None", "# Find the minimum max allowed length among all specified db_aliases.", "for", "db", "in", "settings", ".", "DATABASES", ".", "keys"...
[ 1478, 4 ]
[ 1545, 21 ]
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", "...
[ 1007, 0 ]
[ 1032, 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...
[ 1035, 0 ]
[ 1050, 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" ]
[ 91, 4 ]
[ 95, 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", "\"...
[ 215, 4 ]
[ 234, 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...
[ 236, 4 ]
[ 273, 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...
[ 275, 4 ]
[ 301, 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" ]
[ 303, 4 ]
[ 307, 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...
[ 313, 4 ]
[ 323, 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)\"", "%...
[ 325, 4 ]
[ 348, 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",...
[ 350, 4 ]
[ 449, 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", "=", ...
[ 454, 4 ]
[ 470, 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"...
[ 472, 4 ]
[ 491, 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...
[ 493, 4 ]
[ 848, 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...
[ 921, 4 ]
[ 939, 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", "(", ")" ]
[ 941, 4 ]
[ 947, 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", "\...
[ 949, 4 ]
[ 983, 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", ",", ...
[ 985, 4 ]
[ 1004, 13 ]
python
en
['en', 'error', 'th']
False
getTreeBuilder
(treeType, implementation=None, **kwargs)
Get a TreeBuilder class for various types of trees with built-in support :arg treeType: the name of the tree type required (case-insensitive). Supported values are: * "dom" - A generic builder for DOM implementations, defaulting to a xml.dom.minidom based implementation. * "etree...
Get a TreeBuilder class for various types of trees with built-in support
def getTreeBuilder(treeType, implementation=None, **kwargs): """Get a TreeBuilder class for various types of trees with built-in support :arg treeType: the name of the tree type required (case-insensitive). Supported values are: * "dom" - A generic builder for DOM implementations, defaulting t...
[ "def", "getTreeBuilder", "(", "treeType", ",", "implementation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "treeType", "=", "treeType", ".", "lower", "(", ")", "if", "treeType", "not", "in", "treeBuilderCache", ":", "if", "treeType", "==", "\"dom\"",...
[ 38, 0 ]
[ 87, 41 ]
python
en
['en', 'en', 'en']
True
OracleOperations.geo_db_type
(self, f)
Returns the geometry database type for Oracle. Unlike other spatial backends, no stored procedure is necessary and it's the same for all geometry types.
Returns the geometry database type for Oracle. Unlike other spatial backends, no stored procedure is necessary and it's the same for all geometry types.
def geo_db_type(self, f): """ Returns the geometry database type for Oracle. Unlike other spatial backends, no stored procedure is necessary and it's the same for all geometry types. """ return 'MDSYS.SDO_GEOMETRY'
[ "def", "geo_db_type", "(", "self", ",", "f", ")", ":", "return", "'MDSYS.SDO_GEOMETRY'" ]
[ 153, 4 ]
[ 159, 35 ]
python
en
['en', 'error', 'th']
False
OracleOperations.get_distance
(self, f, value, lookup_type)
Returns the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave implicitly like a geography column, and thus meters will be used as the distance parameter on them.
Returns the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave implicitly like a geography column, and thus meters will be used as the distance parameter on them.
def get_distance(self, f, value, lookup_type): """ Returns the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave implicitly like a geography column, and thus meters will be used as the distance parameter ...
[ "def", "get_distance", "(", "self", ",", "f", ",", "value", ",", "lookup_type", ")", ":", "if", "not", "value", ":", "return", "[", "]", "value", "=", "value", "[", "0", "]", "if", "isinstance", "(", "value", ",", "Distance", ")", ":", "if", "f", ...
[ 161, 4 ]
[ 184, 27 ]
python
en
['en', 'error', 'th']
False
OracleOperations.get_geom_placeholder
(self, f, value)
Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the SDO_CS.TRANSFORM() function call.
Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the SDO_CS.TRANSFORM() function call.
def get_geom_placeholder(self, f, value): """ Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the SDO_CS.TRANSFORM() function call. """ if value is None: return 'NULL' ...
[ "def", "get_geom_placeholder", "(", "self", ",", "f", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "'NULL'", "def", "transform_value", "(", "val", ",", "srid", ")", ":", "return", "val", ".", "srid", "!=", "srid", "if", "hasattr"...
[ 186, 4 ]
[ 210, 55 ]
python
en
['en', 'error', 'th']
False
OracleOperations.spatial_aggregate_sql
(self, agg)
Returns the spatial aggregate SQL template and function for the given Aggregate instance.
Returns the spatial aggregate SQL template and function for the given Aggregate instance.
def spatial_aggregate_sql(self, agg): """ Returns the spatial aggregate SQL template and function for the given Aggregate instance. """ agg_name = agg.__class__.__name__.lower() if agg_name == 'union': agg_name += 'agg' if agg.is_extent: sq...
[ "def", "spatial_aggregate_sql", "(", "self", ",", "agg", ")", ":", "agg_name", "=", "agg", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", "if", "agg_name", "==", "'union'", ":", "agg_name", "+=", "'agg'", "if", "agg", ".", "is_extent", ":", ...
[ 212, 4 ]
[ 225, 55 ]
python
en
['en', 'error', 'th']
False
OracleOperations.modify_insert_params
(self, placeholders, params)
Drop out insert parameters for NULL placeholder. Needed for Oracle Spatial backend due to #10888
Drop out insert parameters for NULL placeholder. Needed for Oracle Spatial backend due to #10888
def modify_insert_params(self, placeholders, params): """Drop out insert parameters for NULL placeholder. Needed for Oracle Spatial backend due to #10888 """ # This code doesn't work for bulk insert cases. assert len(placeholders) == 1 return [[param for pholder, param ...
[ "def", "modify_insert_params", "(", "self", ",", "placeholders", ",", "params", ")", ":", "# This code doesn't work for bulk insert cases.", "assert", "len", "(", "placeholders", ")", "==", "1", "return", "[", "[", "param", "for", "pholder", ",", "param", "in", ...
[ 236, 4 ]
[ 243, 86 ]
python
en
['en', 'en', 'en']
True
BaseResource._bootstrap
(self)
Bootstraps the model object based on configured values.
Bootstraps the model object based on configured values.
def _bootstrap(self): """Bootstraps the model object based on configured values.""" for attr in self._keys(): setattr(self, attr, None)
[ "def", "_bootstrap", "(", "self", ")", ":", "for", "attr", "in", "self", ".", "_keys", "(", ")", ":", "setattr", "(", "self", ",", "attr", ",", "None", ")" ]
[ 35, 4 ]
[ 39, 37 ]
python
en
['en', 'en', 'en']
True
BaseResource._ids
(self)
The list of primary keys to validate against.
The list of primary keys to validate against.
def _ids(self): """The list of primary keys to validate against.""" for pk in self._pks: yield getattr(self, pk) for pk in self._pks: try: yield str(getattr(self, pk)) except ValueError: pass
[ "def", "_ids", "(", "self", ")", ":", "for", "pk", "in", "self", ".", "_pks", ":", "yield", "getattr", "(", "self", ",", "pk", ")", "for", "pk", "in", "self", ".", "_pks", ":", "try", ":", "yield", "str", "(", "getattr", "(", "self", ",", "pk",...
[ 52, 4 ]
[ 62, 20 ]
python
en
['en', 'en', 'en']
True
Addon.upgrade
(self, name, params=None)
Upgrades an addon to the given tier.
Upgrades an addon to the given tier.
def upgrade(self, name, params=None): """Upgrades an addon to the given tier.""" # Allow non-namespaced upgrades. (e.g. advanced vs logging:advanced) if ':' not in name: name = '{0}:{1}'.format(self.type, name) r = self._h._http_resource( method='PUT', ...
[ "def", "upgrade", "(", "self", ",", "name", ",", "params", "=", "None", ")", ":", "# Allow non-namespaced upgrades. (e.g. advanced vs logging:advanced)", "if", "':'", "not", "in", "name", ":", "name", "=", "'{0}:{1}'", ".", "format", "(", "self", ".", "type", ...
[ 137, 4 ]
[ 150, 36 ]
python
en
['en', 'en', 'en']
True
App.new
(self, name=None, stack='cedar')
Creates a new app.
Creates a new app.
def new(self, name=None, stack='cedar'): """Creates a new app.""" payload = {} if name: payload['app[name]'] = name if stack: payload['app[stack]'] = stack r = self._h._http_resource( method='POST', resource=('apps',), ...
[ "def", "new", "(", "self", ",", "name", "=", "None", ",", "stack", "=", "'cedar'", ")", ":", "payload", "=", "{", "}", "if", "name", ":", "payload", "[", "'app[name]'", "]", "=", "name", "if", "stack", ":", "payload", "[", "'app[stack]'", "]", "=",...
[ 167, 4 ]
[ 185, 37 ]
python
en
['en', 'ga', 'en']
True
App.collaborators
(self)
The collaborators for this app.
The collaborators for this app.
def collaborators(self): """The collaborators for this app.""" return self._h._get_resources( resource=('apps', self.name, 'collaborators'), obj=Collaborator, app=self )
[ "def", "collaborators", "(", "self", ")", ":", "return", "self", ".", "_h", ".", "_get_resources", "(", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'collaborators'", ")", ",", "obj", "=", "Collaborator", ",", "app", "=", "self", ")"...
[ 195, 4 ]
[ 200, 9 ]
python
en
['en', 'en', 'en']
True
App.domains
(self)
The domains for this app.
The domains for this app.
def domains(self): """The domains for this app.""" return self._h._get_resources( resource=('apps', self.name, 'domains'), obj=Domain, app=self )
[ "def", "domains", "(", "self", ")", ":", "return", "self", ".", "_h", ".", "_get_resources", "(", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'domains'", ")", ",", "obj", "=", "Domain", ",", "app", "=", "self", ")" ]
[ 203, 4 ]
[ 208, 9 ]
python
en
['en', 'en', 'en']
True
App.releases
(self)
The releases for this app.
The releases for this app.
def releases(self): """The releases for this app.""" return self._h._get_resources( resource=('apps', self.name, 'releases'), obj=Release, app=self )
[ "def", "releases", "(", "self", ")", ":", "return", "self", ".", "_h", ".", "_get_resources", "(", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'releases'", ")", ",", "obj", "=", "Release", ",", "app", "=", "self", ")" ]
[ 211, 4 ]
[ 216, 9 ]
python
en
['en', 'en', 'en']
True
App.processes
(self)
The proccesses for this app.
The proccesses for this app.
def processes(self): """The proccesses for this app.""" return self._h._get_resources( resource=('apps', self.name, 'ps'), obj=Process, app=self, map=ProcessListResource )
[ "def", "processes", "(", "self", ")", ":", "return", "self", ".", "_h", ".", "_get_resources", "(", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'ps'", ")", ",", "obj", "=", "Process", ",", "app", "=", "self", ",", "map", "=", ...
[ 219, 4 ]
[ 224, 9 ]
python
en
['en', 'en', 'en']
True
App.config
(self)
The envs for this app.
The envs for this app.
def config(self): """The envs for this app.""" return self._h._get_resource( resource=('apps', self.name, 'config_vars'), obj=ConfigVars, app=self )
[ "def", "config", "(", "self", ")", ":", "return", "self", ".", "_h", ".", "_get_resource", "(", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'config_vars'", ")", ",", "obj", "=", "ConfigVars", ",", "app", "=", "self", ")" ]
[ 227, 4 ]
[ 233, 9 ]
python
en
['en', 'en', 'en']
True
App.info
(self)
Returns current info for this app.
Returns current info for this app.
def info(self): """Returns current info for this app.""" return self._h._get_resource( resource=('apps', self.name), obj=App, )
[ "def", "info", "(", "self", ")", ":", "return", "self", ".", "_h", ".", "_get_resource", "(", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ")", ",", "obj", "=", "App", ",", ")" ]
[ 236, 4 ]
[ 242, 9 ]
python
en
['en', 'en', 'en']
True
App.rollback
(self, release)
Rolls back the release to the given version.
Rolls back the release to the given version.
def rollback(self, release): """Rolls back the release to the given version.""" r = self._h._http_resource( method='POST', resource=('apps', self.name, 'releases'), data={'rollback': release} ) return self.releases[-1]
[ "def", "rollback", "(", "self", ",", "release", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'POST'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'releases'", ")", ",", "data", "=", "{"...
[ 251, 4 ]
[ 258, 32 ]
python
en
['en', 'en', 'en']
True
App.rename
(self, name)
Renames app to given name.
Renames app to given name.
def rename(self, name): """Renames app to given name.""" r = self._h._http_resource( method='PUT', resource=('apps', self.name), data={'app[name]': name} ) return r.ok
[ "def", "rename", "(", "self", ",", "name", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'PUT'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ")", ",", "data", "=", "{", "'app[name]'", ":", "...
[ 261, 4 ]
[ 269, 19 ]
python
en
['en', 'en', 'en']
True
App.transfer
(self, user)
Transfers app to given username's account.
Transfers app to given username's account.
def transfer(self, user): """Transfers app to given username's account.""" r = self._h._http_resource( method='PUT', resource=('apps', self.name), data={'app[transfer_owner]': user} ) return r.ok
[ "def", "transfer", "(", "self", ",", "user", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'PUT'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ")", ",", "data", "=", "{", "'app[transfer_owner]'"...
[ 271, 4 ]
[ 279, 19 ]
python
en
['en', 'en', 'en']
True
App.maintenance
(self, on=True)
Toggles maintenance mode.
Toggles maintenance mode.
def maintenance(self, on=True): """Toggles maintenance mode.""" r = self._h._http_resource( method='POST', resource=('apps', self.name, 'server', 'maintenance'), data={'maintenance_mode': int(on)} ) return r.ok
[ "def", "maintenance", "(", "self", ",", "on", "=", "True", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'POST'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ",", "'server'", ",", "'maintenance'...
[ 281, 4 ]
[ 289, 19 ]
python
en
['fr', 'en', 'en']
True
App.destroy
(self)
Destoys the app. Do be careful.
Destoys the app. Do be careful.
def destroy(self): """Destoys the app. Do be careful.""" r = self._h._http_resource( method='DELETE', resource=('apps', self.name) ) return r.ok
[ "def", "destroy", "(", "self", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'DELETE'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "name", ")", ")", "return", "r", ".", "ok" ]
[ 291, 4 ]
[ 298, 19 ]
python
en
['en', 'ga', 'en']
True
App.logs
(self, num=None, source=None, ps=None, tail=False)
Returns the requested log.
Returns the requested log.
def logs(self, num=None, source=None, ps=None, tail=False): """Returns the requested log.""" # Bootstrap payload package. payload = {'logplex': 'true'} if num: payload['num'] = num if source: payload['source'] = source if ps: payloa...
[ "def", "logs", "(", "self", ",", "num", "=", "None", ",", "source", "=", "None", ",", "ps", "=", "None", ",", "tail", "=", "False", ")", ":", "# Bootstrap payload package.", "payload", "=", "{", "'logplex'", ":", "'true'", "}", "if", "num", ":", "pay...
[ 300, 4 ]
[ 332, 33 ]
python
en
['en', 'en', 'en']
True
Key.id
(self)
Returns the username@hostname description field of the key.
Returns the username
def id(self): """Returns the username@hostname description field of the key.""" return self.contents.split()[-1]
[ "def", "id", "(", "self", ")", ":", "return", "self", ".", "contents", ".", "split", "(", ")", "[", "-", "1", "]" ]
[ 459, 4 ]
[ 462, 40 ]
python
en
['en', 'no', 'en']
True
Key.delete
(self)
Deletes the key.
Deletes the key.
def delete(self): """Deletes the key.""" r = self._h._http_resource( method='DELETE', resource=('user', 'keys', self.id) ) r.raise_for_status()
[ "def", "delete", "(", "self", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'DELETE'", ",", "resource", "=", "(", "'user'", ",", "'keys'", ",", "self", ".", "id", ")", ")", "r", ".", "raise_for_status", "(", ")"...
[ 473, 4 ]
[ 480, 28 ]
python
en
['en', 'sq', 'en']
True
Process.new
(self, command, attach="")
Creates a new Process Attach: If attach=True it will return a rendezvous connection point, for streaming stdout/stderr Command: The actual command it will run
Creates a new Process Attach: If attach=True it will return a rendezvous connection point, for streaming stdout/stderr Command: The actual command it will run
def new(self, command, attach=""): """ Creates a new Process Attach: If attach=True it will return a rendezvous connection point, for streaming stdout/stderr Command: The actual command it will run """ r = self._h._http_resource( method='POST', res...
[ "def", "new", "(", "self", ",", "command", ",", "attach", "=", "\"\"", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'POST'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "app", ".", "name", ",", "'p...
[ 509, 4 ]
[ 522, 52 ]
python
en
['en', 'error', 'th']
False
Process.restart
(self, all=False)
Restarts the given process.
Restarts the given process.
def restart(self, all=False): """Restarts the given process.""" if all: data = {'type': self.type} else: data = {'ps': self.process} r = self._h._http_resource( method='POST', resource=('apps', self.app.name, 'ps', 'restart'), ...
[ "def", "restart", "(", "self", ",", "all", "=", "False", ")", ":", "if", "all", ":", "data", "=", "{", "'type'", ":", "self", ".", "type", "}", "else", ":", "data", "=", "{", "'ps'", ":", "self", ".", "process", "}", "r", "=", "self", ".", "_...
[ 528, 4 ]
[ 543, 28 ]
python
en
['en', 'en', 'en']
True
Process.stop
(self, all=False)
Stops the given process.
Stops the given process.
def stop(self, all=False): """Stops the given process.""" if all: data = {'type': self.type} else: data = {'ps': self.process} r = self._h._http_resource( method='POST', resource=('apps', self.app.name, 'ps', 'stop'), data=da...
[ "def", "stop", "(", "self", ",", "all", "=", "False", ")", ":", "if", "all", ":", "data", "=", "{", "'type'", ":", "self", ".", "type", "}", "else", ":", "data", "=", "{", "'ps'", ":", "self", ".", "process", "}", "r", "=", "self", ".", "_h",...
[ 545, 4 ]
[ 560, 28 ]
python
en
['en', 'en', 'en']
True
Process.scale
(self, quantity)
Scales the given process to the given number of dynos.
Scales the given process to the given number of dynos.
def scale(self, quantity): """Scales the given process to the given number of dynos.""" r = self._h._http_resource( method='POST', resource=('apps', self.app.name, 'ps', 'scale'), data={'type': self.type, 'qty': quantity} ) r.raise_for_status() ...
[ "def", "scale", "(", "self", ",", "quantity", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'POST'", ",", "resource", "=", "(", "'apps'", ",", "self", ".", "app", ".", "name", ",", "'ps'", ",", "'scale'", ")", ...
[ 562, 4 ]
[ 576, 40 ]
python
en
['en', 'en', 'en']
True
Release.rollback
(self)
Rolls back the application to this release.
Rolls back the application to this release.
def rollback(self): """Rolls back the application to this release.""" return self.app.rollback(self.name)
[ "def", "rollback", "(", "self", ")", ":", "return", "self", ".", "app", ".", "rollback", "(", "self", ".", "name", ")" ]
[ 593, 4 ]
[ 596, 43 ]
python
en
['en', 'en', 'en']
True
TemplateCommand.handle_template
(self, template, subdir)
Determines where the app or project templates are. Use django.__path__[0] as the default because we don't know into which directory Django has been installed.
Determines where the app or project templates are. Use django.__path__[0] as the default because we don't know into which directory Django has been installed.
def handle_template(self, template, subdir): """ Determines where the app or project templates are. Use django.__path__[0] as the default because we don't know into which directory Django has been installed. """ if template is None: return path.join(django.__p...
[ "def", "handle_template", "(", "self", ",", "template", ",", "subdir", ")", ":", "if", "template", "is", "None", ":", "return", "path", ".", "join", "(", "django", ".", "__path__", "[", "0", "]", ",", "'conf'", ",", "subdir", ")", "else", ":", "if", ...
[ 182, 4 ]
[ 206, 59 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.download
(self, url)
Downloads the given URL and returns the file name.
Downloads the given URL and returns the file name.
def download(self, url): """ Downloads the given URL and returns the file name. """ def cleanup_url(url): tmp = url.rstrip('/') filename = tmp.split('/')[-1] if url.endswith('/'): display_url = tmp + '/' else: ...
[ "def", "download", "(", "self", ",", "url", ")", ":", "def", "cleanup_url", "(", "url", ")", ":", "tmp", "=", "url", ".", "rstrip", "(", "'/'", ")", "filename", "=", "tmp", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "if", "url", ".", ...
[ 222, 4 ]
[ 274, 23 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.splitext
(self, the_path)
Like os.path.splitext, but takes off .tar, too
Like os.path.splitext, but takes off .tar, too
def splitext(self, the_path): """ Like os.path.splitext, but takes off .tar, too """ base, ext = posixpath.splitext(the_path) if base.lower().endswith('.tar'): ext = base[-4:] + ext base = base[:-4] return base, ext
[ "def", "splitext", "(", "self", ",", "the_path", ")", ":", "base", ",", "ext", "=", "posixpath", ".", "splitext", "(", "the_path", ")", "if", "base", ".", "lower", "(", ")", ".", "endswith", "(", "'.tar'", ")", ":", "ext", "=", "base", "[", "-", ...
[ 276, 4 ]
[ 284, 24 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.extract
(self, filename)
Extracts the given file to a temporarily and returns the path of the directory with the extracted content.
Extracts the given file to a temporarily and returns the path of the directory with the extracted content.
def extract(self, filename): """ Extracts the given file to a temporarily and returns the path of the directory with the extracted content. """ prefix = 'django_%s_template_' % self.app_or_project tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_extract') self.p...
[ "def", "extract", "(", "self", ",", "filename", ")", ":", "prefix", "=", "'django_%s_template_'", "%", "self", ".", "app_or_project", "tempdir", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "prefix", ",", "suffix", "=", "'_extract'", ")", "self", "...
[ 286, 4 ]
[ 301, 54 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.is_url
(self, template)
Returns True if the name looks like a URL
Returns True if the name looks like a URL
def is_url(self, template): """ Returns True if the name looks like a URL """ if ':' not in template: return False scheme = template.split(':', 1)[0].lower() return scheme in self.url_schemes
[ "def", "is_url", "(", "self", ",", "template", ")", ":", "if", "':'", "not", "in", "template", ":", "return", "False", "scheme", "=", "template", ".", "split", "(", "':'", ",", "1", ")", "[", "0", "]", ".", "lower", "(", ")", "return", "scheme", ...
[ 303, 4 ]
[ 310, 41 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.make_writeable
(self, filename)
Make sure that the file is writeable. Useful if our source is read-only.
Make sure that the file is writeable. Useful if our source is read-only.
def make_writeable(self, filename): """ Make sure that the file is writeable. Useful if our source is read-only. """ if sys.platform.startswith('java'): # On Jython there is no os.access() return if not os.access(filename, os.W_OK): st ...
[ "def", "make_writeable", "(", "self", ",", "filename", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'java'", ")", ":", "# On Jython there is no os.access()", "return", "if", "not", "os", ".", "access", "(", "filename", ",", "os", ".", "...
[ 312, 4 ]
[ 323, 47 ]
python
en
['en', 'error', 'th']
False
load
(root)
Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package.
Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package.
def load(root): """ Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package. """ root = os.path.expanduser(root) system = compat_system(root) builder = functools.partial(build, source_dir=root, system=system) ...
[ "def", "load", "(", "root", ")", ":", "root", "=", "os", ".", "path", ".", "expanduser", "(", "root", ")", "system", "=", "compat_system", "(", "root", ")", "builder", "=", "functools", ".", "partial", "(", "build", ",", "source_dir", "=", "root", ",...
[ 61, 0 ]
[ 71, 42 ]
python
en
['en', 'error', 'th']
False
ensure_echo_on
()
Ensure that echo mode is enabled. Some tools such as PDB disable it which causes usability issues after reload.
Ensure that echo mode is enabled. Some tools such as PDB disable it which causes usability issues after reload.
def ensure_echo_on(): """ Ensure that echo mode is enabled. Some tools such as PDB disable it which causes usability issues after reload. """ if not termios or not sys.stdin.isatty(): return attr_list = termios.tcgetattr(sys.stdin) if not attr_list[3] & termios.ECHO: attr_lis...
[ "def", "ensure_echo_on", "(", ")", ":", "if", "not", "termios", "or", "not", "sys", ".", "stdin", ".", "isatty", "(", ")", ":", "return", "attr_list", "=", "termios", ".", "tcgetattr", "(", "sys", ".", "stdin", ")", "if", "not", "attr_list", "[", "3"...
[ 78, 0 ]
[ 94, 54 ]
python
en
['en', 'error', 'th']
False
iter_modules_and_files
(modules, extra_files)
Iterate through all modules needed to be watched.
Iterate through all modules needed to be watched.
def iter_modules_and_files(modules, extra_files): """Iterate through all modules needed to be watched.""" sys_file_paths = [] for module in modules: # During debugging (with PyDev) the 'typing.io' and 'typing.re' objects # are added to sys.modules, however they are types not modules and so ...
[ "def", "iter_modules_and_files", "(", "modules", ",", "extra_files", ")", ":", "sys_file_paths", "=", "[", "]", "for", "module", "in", "modules", ":", "# During debugging (with PyDev) the 'typing.io' and 'typing.re' objects", "# are added to sys.modules, however they are types no...
[ 108, 0 ]
[ 150, 29 ]
python
en
['en', 'en', 'en']
True
common_roots
(paths)
Return a tuple of common roots that are shared between the given paths. File system watchers operate on directories and aren't cheap to create. Try to find the minimum set of directories to watch that encompass all of the files that need to be watched.
Return a tuple of common roots that are shared between the given paths. File system watchers operate on directories and aren't cheap to create. Try to find the minimum set of directories to watch that encompass all of the files that need to be watched.
def common_roots(paths): """ Return a tuple of common roots that are shared between the given paths. File system watchers operate on directories and aren't cheap to create. Try to find the minimum set of directories to watch that encompass all of the files that need to be watched. """ # Insp...
[ "def", "common_roots", "(", "paths", ")", ":", "# Inspired from Werkzeug:", "# https://github.com/pallets/werkzeug/blob/7477be2853df70a022d9613e765581b9411c3c39/werkzeug/_reloader.py", "# Create a sorted list of the path components, longest first.", "path_parts", "=", "sorted", "(", "[", ...
[ 154, 0 ]
[ 181, 33 ]
python
en
['en', 'error', 'th']
False