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
RequestsCookieJar.__setitem__
(self, name, value)
Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead.
Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead.
def __setitem__(self, name, value): """Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead. """ self.set(name, value)
[ "def", "__setitem__", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "set", "(", "name", ",", "value", ")" ]
[ 329, 4 ]
[ 334, 29 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__delitem__
(self, name)
Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``.
Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``.
def __delitem__(self, name): """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``. """ remove_cookie_by_name(self, name)
[ "def", "__delitem__", "(", "self", ",", "name", ")", ":", "remove_cookie_by_name", "(", "self", ",", "name", ")" ]
[ 336, 4 ]
[ 340, 41 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.update
(self, other)
Updates this jar with cookies from another CookieJar or dict-like
Updates this jar with cookies from another CookieJar or dict-like
def update(self, other): """Updates this jar with cookies from another CookieJar or dict-like""" if isinstance(other, cookielib.CookieJar): for cookie in other: self.set_cookie(copy.copy(cookie)) else: super(RequestsCookieJar, self).update(other)
[ "def", "update", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "cookielib", ".", "CookieJar", ")", ":", "for", "cookie", "in", "other", ":", "self", ".", "set_cookie", "(", "copy", ".", "copy", "(", "cookie", ")", ")", ...
[ 347, 4 ]
[ 353, 56 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar._find
(self, name, domain=None, path=None)
Requests uses this method internally to get cookie values. If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies. :param name: a string containing name of cookie :param domain: (...
Requests uses this method internally to get cookie values.
def _find(self, name, domain=None, path=None): """Requests uses this method internally to get cookie values. If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies. :param name: a...
[ "def", "_find", "(", "self", ",", "name", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "name", "==", "name", ":", "if", "domain", "is", "None", "or", ...
[ 355, 4 ]
[ 373, 76 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar._find_no_duplicates
(self, name, domain=None, path=None)
Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie :raises KeyError: if...
Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests.
def _find_no_duplicates(self, name, domain=None, path=None): """Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: ...
[ "def", "_find_no_duplicates", "(", "self", ",", "name", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "toReturn", "=", "None", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "name", "==", "name", ":", "...
[ 375, 4 ]
[ 398, 76 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__getstate__
(self)
Unlike a normal CookieJar, this class is pickleable.
Unlike a normal CookieJar, this class is pickleable.
def __getstate__(self): """Unlike a normal CookieJar, this class is pickleable.""" state = self.__dict__.copy() # remove the unpickleable RLock object state.pop('_cookies_lock') return state
[ "def", "__getstate__", "(", "self", ")", ":", "state", "=", "self", ".", "__dict__", ".", "copy", "(", ")", "# remove the unpickleable RLock object", "state", ".", "pop", "(", "'_cookies_lock'", ")", "return", "state" ]
[ 400, 4 ]
[ 405, 20 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__setstate__
(self, state)
Unlike a normal CookieJar, this class is pickleable.
Unlike a normal CookieJar, this class is pickleable.
def __setstate__(self, state): """Unlike a normal CookieJar, this class is pickleable.""" self.__dict__.update(state) if '_cookies_lock' not in self.__dict__: self._cookies_lock = threading.RLock()
[ "def", "__setstate__", "(", "self", ",", "state", ")", ":", "self", ".", "__dict__", ".", "update", "(", "state", ")", "if", "'_cookies_lock'", "not", "in", "self", ".", "__dict__", ":", "self", ".", "_cookies_lock", "=", "threading", ".", "RLock", "(", ...
[ 407, 4 ]
[ 411, 50 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.copy
(self)
Return a copy of this RequestsCookieJar.
Return a copy of this RequestsCookieJar.
def copy(self): """Return a copy of this RequestsCookieJar.""" new_cj = RequestsCookieJar() new_cj.set_policy(self.get_policy()) new_cj.update(self) return new_cj
[ "def", "copy", "(", "self", ")", ":", "new_cj", "=", "RequestsCookieJar", "(", ")", "new_cj", ".", "set_policy", "(", "self", ".", "get_policy", "(", ")", ")", "new_cj", ".", "update", "(", "self", ")", "return", "new_cj" ]
[ 413, 4 ]
[ 418, 21 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.get_policy
(self)
Return the CookiePolicy instance used.
Return the CookiePolicy instance used.
def get_policy(self): """Return the CookiePolicy instance used.""" return self._policy
[ "def", "get_policy", "(", "self", ")", ":", "return", "self", ".", "_policy" ]
[ 420, 4 ]
[ 422, 27 ]
python
en
['en', 'en', 'en']
True
supports_color
()
Return True if the running system's terminal supports color, and False otherwise.
Return True if the running system's terminal supports color, and False otherwise.
def supports_color(): """ Return True if the running system's terminal supports color, and False otherwise. """ plat = sys.platform supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ) # isatty is not always implemented, #6223. is_a_tty = hasattr(sys...
[ "def", "supports_color", "(", ")", ":", "plat", "=", "sys", ".", "platform", "supported_platform", "=", "plat", "!=", "'Pocket PC'", "and", "(", "plat", "!=", "'win32'", "or", "'ANSICON'", "in", "os", ".", "environ", ")", "# isatty is not always implemented, #62...
[ 11, 0 ]
[ 21, 42 ]
python
en
['en', 'error', 'th']
False
make_style
(config_string='')
Create a Style object from the given config_string. If config_string is empty django.utils.termcolors.DEFAULT_PALETTE is used.
Create a Style object from the given config_string.
def make_style(config_string=''): """ Create a Style object from the given config_string. If config_string is empty django.utils.termcolors.DEFAULT_PALETTE is used. """ style = Style() color_settings = termcolors.parse_color_setting(config_string) # The nocolor palette has all available ...
[ "def", "make_style", "(", "config_string", "=", "''", ")", ":", "style", "=", "Style", "(", ")", "color_settings", "=", "termcolors", ".", "parse_color_setting", "(", "config_string", ")", "# The nocolor palette has all available roles.", "# Use that palette as the basis ...
[ 28, 0 ]
[ 55, 16 ]
python
en
['en', 'error', 'th']
False
no_style
()
Return a Style object with no color scheme.
Return a Style object with no color scheme.
def no_style(): """ Return a Style object with no color scheme. """ return make_style('nocolor')
[ "def", "no_style", "(", ")", ":", "return", "make_style", "(", "'nocolor'", ")" ]
[ 59, 0 ]
[ 63, 32 ]
python
en
['en', 'error', 'th']
False
color_style
(force_color=False)
Return a Style object from the Django color scheme.
Return a Style object from the Django color scheme.
def color_style(force_color=False): """ Return a Style object from the Django color scheme. """ if not force_color and not supports_color(): return no_style() return make_style(os.environ.get('DJANGO_COLORS', ''))
[ "def", "color_style", "(", "force_color", "=", "False", ")", ":", "if", "not", "force_color", "and", "not", "supports_color", "(", ")", ":", "return", "no_style", "(", ")", "return", "make_style", "(", "os", ".", "environ", ".", "get", "(", "'DJANGO_COLORS...
[ 66, 0 ]
[ 72, 58 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor.skip_default
(self, field)
MySQL doesn't accept default values for longtext and longblob and implicitly treats these columns as nullable.
MySQL doesn't accept default values for longtext and longblob and implicitly treats these columns as nullable.
def skip_default(self, field): """ MySQL doesn't accept default values for longtext and longblob and implicitly treats these columns as nullable. """ return field.db_type(self.connection) in {'longtext', 'longblob'}
[ "def", "skip_default", "(", "self", ",", "field", ")", ":", "return", "field", ".", "db_type", "(", "self", ".", "connection", ")", "in", "{", "'longtext'", ",", "'longblob'", "}" ]
[ 36, 4 ]
[ 41, 73 ]
python
en
['en', 'error', 'th']
False
MpoImageFile.adopt
(jpeg_instance, mpheader=None)
Transform the instance of JpegImageFile into an instance of MpoImageFile. After the call, the JpegImageFile is extended to be an MpoImageFile. This is essentially useful when opening a JPEG file that reveals itself as an MPO, to avoid double call to _open. ...
Transform the instance of JpegImageFile into an instance of MpoImageFile. After the call, the JpegImageFile is extended to be an MpoImageFile.
def adopt(jpeg_instance, mpheader=None): """ Transform the instance of JpegImageFile into an instance of MpoImageFile. After the call, the JpegImageFile is extended to be an MpoImageFile. This is essentially useful when opening a JPEG file that reveals itself as ...
[ "def", "adopt", "(", "jpeg_instance", ",", "mpheader", "=", "None", ")", ":", "jpeg_instance", ".", "__class__", "=", "MpoImageFile", "jpeg_instance", ".", "_after_jpeg_open", "(", "mpheader", ")", "return", "jpeg_instance" ]
[ 106, 4 ]
[ 119, 28 ]
python
en
['en', 'error', 'th']
False
SpatialiteGeometryColumns.table_name_col
(cls)
Return the name of the metadata column used to store the feature table name.
Return the name of the metadata column used to store the feature table name.
def table_name_col(cls): """ Return the name of the metadata column used to store the feature table name. """ return 'f_table_name'
[ "def", "table_name_col", "(", "cls", ")", ":", "return", "'f_table_name'" ]
[ 33, 4 ]
[ 38, 29 ]
python
en
['en', 'error', 'th']
False
SpatialiteGeometryColumns.geom_col_name
(cls)
Return the name of the metadata column used to store the feature geometry column.
Return the name of the metadata column used to store the feature geometry column.
def geom_col_name(cls): """ Return the name of the metadata column used to store the feature geometry column. """ return 'f_geometry_column'
[ "def", "geom_col_name", "(", "cls", ")", ":", "return", "'f_geometry_column'" ]
[ 41, 4 ]
[ 46, 34 ]
python
en
['en', 'error', 'th']
False
get_image_dimensions
(file_or_path, close=False)
Return the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state.
Return the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state.
def get_image_dimensions(file_or_path, close=False): """ Return the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state. """ from PIL import ImageFile as PillowImageFile p = PillowImageFile.Parser()...
[ "def", "get_image_dimensions", "(", "file_or_path", ",", "close", "=", "False", ")", ":", "from", "PIL", "import", "ImageFile", "as", "PillowImageFile", "p", "=", "PillowImageFile", ".", "Parser", "(", ")", "if", "hasattr", "(", "file_or_path", ",", "'read'", ...
[ 32, 0 ]
[ 83, 31 ]
python
en
['en', 'error', 'th']
False
Apps.populate
(self, installed_apps=None)
Loads application configurations and models. This method imports each application module and then each model module. It is thread safe and idempotent, but not reentrant.
Loads application configurations and models.
def populate(self, installed_apps=None): """ Loads application configurations and models. This method imports each application module and then each model module. It is thread safe and idempotent, but not reentrant. """ if self.ready: return # popula...
[ "def", "populate", "(", "self", ",", "installed_apps", "=", "None", ")", ":", "if", "self", ".", "ready", ":", "return", "# populate() might be called by two threads in parallel on servers", "# that create threads before initializing the WSGI callable.", "with", "self", ".", ...
[ 57, 4 ]
[ 116, 29 ]
python
en
['en', 'error', 'th']
False
Apps.check_apps_ready
(self)
Raises an exception if all apps haven't been imported yet.
Raises an exception if all apps haven't been imported yet.
def check_apps_ready(self): """ Raises an exception if all apps haven't been imported yet. """ if not self.apps_ready: raise AppRegistryNotReady("Apps aren't loaded yet.")
[ "def", "check_apps_ready", "(", "self", ")", ":", "if", "not", "self", ".", "apps_ready", ":", "raise", "AppRegistryNotReady", "(", "\"Apps aren't loaded yet.\"", ")" ]
[ 118, 4 ]
[ 123, 64 ]
python
en
['en', 'error', 'th']
False
Apps.check_models_ready
(self)
Raises an exception if all models haven't been imported yet.
Raises an exception if all models haven't been imported yet.
def check_models_ready(self): """ Raises an exception if all models haven't been imported yet. """ if not self.models_ready: raise AppRegistryNotReady("Models aren't loaded yet.")
[ "def", "check_models_ready", "(", "self", ")", ":", "if", "not", "self", ".", "models_ready", ":", "raise", "AppRegistryNotReady", "(", "\"Models aren't loaded yet.\"", ")" ]
[ 125, 4 ]
[ 130, 66 ]
python
en
['en', 'error', 'th']
False
Apps.get_app_configs
(self)
Imports applications and returns an iterable of app configs.
Imports applications and returns an iterable of app configs.
def get_app_configs(self): """ Imports applications and returns an iterable of app configs. """ self.check_apps_ready() return self.app_configs.values()
[ "def", "get_app_configs", "(", "self", ")", ":", "self", ".", "check_apps_ready", "(", ")", "return", "self", ".", "app_configs", ".", "values", "(", ")" ]
[ 132, 4 ]
[ 137, 40 ]
python
en
['en', 'error', 'th']
False
Apps.get_app_config
(self, app_label)
Imports applications and returns an app config for the given label. Raises LookupError if no application exists with this label.
Imports applications and returns an app config for the given label.
def get_app_config(self, app_label): """ Imports applications and returns an app config for the given label. Raises LookupError if no application exists with this label. """ self.check_apps_ready() try: return self.app_configs[app_label] except KeyErr...
[ "def", "get_app_config", "(", "self", ",", "app_label", ")", ":", "self", ".", "check_apps_ready", "(", ")", "try", ":", "return", "self", ".", "app_configs", "[", "app_label", "]", "except", "KeyError", ":", "raise", "LookupError", "(", "\"No installed app wi...
[ 139, 4 ]
[ 149, 78 ]
python
en
['en', 'error', 'th']
False
Apps.get_models
(self, app_mod=None, include_auto_created=False, include_deferred=False, include_swapped=False)
Returns a list of all installed models. By default, the following models aren't included: - auto-created models for many-to-many relations without an explicit intermediate table, - models created to satisfy deferred attribute queries, - models that have been swapped ...
Returns a list of all installed models.
def get_models(self, app_mod=None, include_auto_created=False, include_deferred=False, include_swapped=False): """ Returns a list of all installed models. By default, the following models aren't included: - auto-created models for many-to-many relations without ...
[ "def", "get_models", "(", "self", ",", "app_mod", "=", "None", ",", "include_auto_created", "=", "False", ",", "include_deferred", "=", "False", ",", "include_swapped", "=", "False", ")", ":", "self", ".", "check_models_ready", "(", ")", "if", "app_mod", ":"...
[ 153, 4 ]
[ 183, 21 ]
python
en
['en', 'error', 'th']
False
Apps.get_model
(self, app_label, model_name=None)
Returns the model matching the given app_label and model_name. As a shortcut, this function also accepts a single argument in the form <app_label>.<model_name>. model_name is case-insensitive. Raises LookupError if no application exists with this label, or no model ex...
Returns the model matching the given app_label and model_name.
def get_model(self, app_label, model_name=None): """ Returns the model matching the given app_label and model_name. As a shortcut, this function also accepts a single argument in the form <app_label>.<model_name>. model_name is case-insensitive. Raises LookupError if n...
[ "def", "get_model", "(", "self", ",", "app_label", ",", "model_name", "=", "None", ")", ":", "self", ".", "check_models_ready", "(", ")", "if", "model_name", "is", "None", ":", "app_label", ",", "model_name", "=", "app_label", ".", "split", "(", "'.'", "...
[ 185, 4 ]
[ 201, 75 ]
python
en
['en', 'error', 'th']
False
Apps.is_installed
(self, app_name)
Checks whether an application with this name exists in the registry. app_name is the full name of the app eg. 'django.contrib.admin'.
Checks whether an application with this name exists in the registry.
def is_installed(self, app_name): """ Checks whether an application with this name exists in the registry. app_name is the full name of the app eg. 'django.contrib.admin'. """ self.check_apps_ready() return any(ac.name == app_name for ac in self.app_configs.values())
[ "def", "is_installed", "(", "self", ",", "app_name", ")", ":", "self", ".", "check_apps_ready", "(", ")", "return", "any", "(", "ac", ".", "name", "==", "app_name", "for", "ac", "in", "self", ".", "app_configs", ".", "values", "(", ")", ")" ]
[ 216, 4 ]
[ 223, 75 ]
python
en
['en', 'error', 'th']
False
Apps.get_containing_app_config
(self, object_name)
Look for an app config containing a given object. object_name is the dotted Python path to the object. Returns the app config for the inner application in case of nesting. Returns None if the object isn't in any registered app config.
Look for an app config containing a given object.
def get_containing_app_config(self, object_name): """ Look for an app config containing a given object. object_name is the dotted Python path to the object. Returns the app config for the inner application in case of nesting. Returns None if the object isn't in any registered a...
[ "def", "get_containing_app_config", "(", "self", ",", "object_name", ")", ":", "# In Django 1.7 and 1.8, it's allowed to call this method at import", "# time, even while the registry is being populated. In Django 1.9 and", "# later, that should be forbidden with `self.check_apps_ready()`.", "c...
[ 225, 4 ]
[ 244, 70 ]
python
en
['en', 'error', 'th']
False
Apps.get_registered_model
(self, app_label, model_name)
Similar to get_model(), but doesn't require that an app exists with the given app_label. It's safe to call this method at import time, even while the registry is being populated.
Similar to get_model(), but doesn't require that an app exists with the given app_label.
def get_registered_model(self, app_label, model_name): """ Similar to get_model(), but doesn't require that an app exists with the given app_label. It's safe to call this method at import time, even while the registry is being populated. """ model = self.all_mode...
[ "def", "get_registered_model", "(", "self", ",", "app_label", ",", "model_name", ")", ":", "model", "=", "self", ".", "all_models", "[", "app_label", "]", ".", "get", "(", "model_name", ".", "lower", "(", ")", ")", "if", "model", "is", "None", ":", "ra...
[ 246, 4 ]
[ 258, 20 ]
python
en
['en', 'error', 'th']
False
Apps.set_available_apps
(self, available)
Restricts the set of installed apps used by get_app_config[s]. available must be an iterable of application names. set_available_apps() must be balanced with unset_available_apps(). Primarily used for performance optimization in TransactionTestCase. This method is safe is th...
Restricts the set of installed apps used by get_app_config[s].
def set_available_apps(self, available): """ Restricts the set of installed apps used by get_app_config[s]. available must be an iterable of application names. set_available_apps() must be balanced with unset_available_apps(). Primarily used for performance optimization in Tra...
[ "def", "set_available_apps", "(", "self", ",", "available", ")", ":", "available", "=", "set", "(", "available", ")", "installed", "=", "set", "(", "app_config", ".", "name", "for", "app_config", "in", "self", ".", "get_app_configs", "(", ")", ")", "if", ...
[ 260, 4 ]
[ 283, 26 ]
python
en
['en', 'error', 'th']
False
Apps.unset_available_apps
(self)
Cancels a previous call to set_available_apps().
Cancels a previous call to set_available_apps().
def unset_available_apps(self): """ Cancels a previous call to set_available_apps(). """ self.app_configs = self.stored_app_configs.pop() self.clear_cache()
[ "def", "unset_available_apps", "(", "self", ")", ":", "self", ".", "app_configs", "=", "self", ".", "stored_app_configs", ".", "pop", "(", ")", "self", ".", "clear_cache", "(", ")" ]
[ 285, 4 ]
[ 290, 26 ]
python
en
['en', 'error', 'th']
False
Apps.set_installed_apps
(self, installed)
Enables a different set of installed apps for get_app_config[s]. installed must be an iterable in the same format as INSTALLED_APPS. set_installed_apps() must be balanced with unset_installed_apps(), even if it exits with an exception. Primarily used as a receiver of the sett...
Enables a different set of installed apps for get_app_config[s].
def set_installed_apps(self, installed): """ Enables a different set of installed apps for get_app_config[s]. installed must be an iterable in the same format as INSTALLED_APPS. set_installed_apps() must be balanced with unset_installed_apps(), even if it exits with an exceptio...
[ "def", "set_installed_apps", "(", "self", ",", "installed", ")", ":", "if", "not", "self", ".", "ready", ":", "raise", "AppRegistryNotReady", "(", "\"App registry isn't ready yet.\"", ")", "self", ".", "stored_app_configs", ".", "append", "(", "self", ".", "app_...
[ 292, 4 ]
[ 315, 32 ]
python
en
['en', 'error', 'th']
False
Apps.unset_installed_apps
(self)
Cancels a previous call to set_installed_apps().
Cancels a previous call to set_installed_apps().
def unset_installed_apps(self): """ Cancels a previous call to set_installed_apps(). """ self.app_configs = self.stored_app_configs.pop() self.apps_ready = self.models_ready = self.ready = True self.clear_cache()
[ "def", "unset_installed_apps", "(", "self", ")", ":", "self", ".", "app_configs", "=", "self", ".", "stored_app_configs", ".", "pop", "(", ")", "self", ".", "apps_ready", "=", "self", ".", "models_ready", "=", "self", ".", "ready", "=", "True", "self", "...
[ 317, 4 ]
[ 323, 26 ]
python
en
['en', 'error', 'th']
False
Apps.clear_cache
(self)
Clears all internal caches, for methods that alter the app registry. This is mostly used in tests.
Clears all internal caches, for methods that alter the app registry.
def clear_cache(self): """ Clears all internal caches, for methods that alter the app registry. This is mostly used in tests. """ self.get_models.cache_clear()
[ "def", "clear_cache", "(", "self", ")", ":", "self", ".", "get_models", ".", "cache_clear", "(", ")" ]
[ 325, 4 ]
[ 331, 37 ]
python
en
['en', 'error', 'th']
False
Apps.load_app
(self, app_name)
Loads the app with the provided fully qualified name, and returns the model module.
Loads the app with the provided fully qualified name, and returns the model module.
def load_app(self, app_name): """ Loads the app with the provided fully qualified name, and returns the model module. """ warnings.warn( "load_app(app_name) is deprecated.", RemovedInDjango19Warning, stacklevel=2) app_config = AppConfig.create(app_...
[ "def", "load_app", "(", "self", ",", "app_name", ")", ":", "warnings", ".", "warn", "(", "\"load_app(app_name) is deprecated.\"", ",", "RemovedInDjango19Warning", ",", "stacklevel", "=", "2", ")", "app_config", "=", "AppConfig", ".", "create", "(", "app_name", "...
[ 335, 4 ]
[ 347, 39 ]
python
en
['en', 'error', 'th']
False
Apps.get_app
(self, app_label)
Returns the module containing the models for the given app_label.
Returns the module containing the models for the given app_label.
def get_app(self, app_label): """ Returns the module containing the models for the given app_label. """ warnings.warn( "get_app_config(app_label).models_module supersedes get_app(app_label).", RemovedInDjango19Warning, stacklevel=2) try: models...
[ "def", "get_app", "(", "self", ",", "app_label", ")", ":", "warnings", ".", "warn", "(", "\"get_app_config(app_label).models_module supersedes get_app(app_label).\"", ",", "RemovedInDjango19Warning", ",", "stacklevel", "=", "2", ")", "try", ":", "models_module", "=", ...
[ 355, 4 ]
[ 370, 28 ]
python
en
['en', 'error', 'th']
False
Apps.get_apps
(self)
Returns a list of all installed modules that contain models.
Returns a list of all installed modules that contain models.
def get_apps(self): """ Returns a list of all installed modules that contain models. """ warnings.warn( "[a.models_module for a in get_app_configs()] supersedes get_apps().", RemovedInDjango19Warning, stacklevel=2) app_configs = self.get_app_configs() ...
[ "def", "get_apps", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"[a.models_module for a in get_app_configs()] supersedes get_apps().\"", ",", "RemovedInDjango19Warning", ",", "stacklevel", "=", "2", ")", "app_configs", "=", "self", ".", "get_app_configs", "(",...
[ 372, 4 ]
[ 381, 56 ]
python
en
['en', 'error', 'th']
False
Apps.get_app_paths
(self)
Returns a list of paths to all installed apps. Useful for discovering files at conventional locations inside apps (static files, templates, etc.)
Returns a list of paths to all installed apps.
def get_app_paths(self): """ Returns a list of paths to all installed apps. Useful for discovering files at conventional locations inside apps (static files, templates, etc.) """ warnings.warn( "[a.path for a in get_app_configs()] supersedes get_app_paths()."...
[ "def", "get_app_paths", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"[a.path for a in get_app_configs()] supersedes get_app_paths().\"", ",", "RemovedInDjango19Warning", ",", "stacklevel", "=", "2", ")", "self", ".", "check_apps_ready", "(", ")", "app_paths",...
[ 405, 4 ]
[ 419, 24 ]
python
en
['en', 'error', 'th']
False
Apps.register_models
(self, app_label, *models)
Register a set of models as belonging to an app.
Register a set of models as belonging to an app.
def register_models(self, app_label, *models): """ Register a set of models as belonging to an app. """ warnings.warn( "register_models(app_label, *models) is deprecated.", RemovedInDjango19Warning, stacklevel=2) for model in models: self.regis...
[ "def", "register_models", "(", "self", ",", "app_label", ",", "*", "models", ")", ":", "warnings", ".", "warn", "(", "\"register_models(app_label, *models) is deprecated.\"", ",", "RemovedInDjango19Warning", ",", "stacklevel", "=", "2", ")", "for", "model", "in", ...
[ 421, 4 ]
[ 429, 49 ]
python
en
['en', 'error', 'th']
False
split_identifier
(identifier)
Split an SQL identifier into a two element tuple of (namespace, name). The identifier could be a table, column, or sequence name might be prefixed by a namespace.
Split an SQL identifier into a two element tuple of (namespace, name).
def split_identifier(identifier): """ Split an SQL identifier into a two element tuple of (namespace, name). The identifier could be a table, column, or sequence name might be prefixed by a namespace. """ try: namespace, name = identifier.split('"."') except ValueError: name...
[ "def", "split_identifier", "(", "identifier", ")", ":", "try", ":", "namespace", ",", "name", "=", "identifier", ".", "split", "(", "'\".\"'", ")", "except", "ValueError", ":", "namespace", ",", "name", "=", "''", ",", "identifier", "return", "namespace", ...
[ 184, 0 ]
[ 195, 48 ]
python
en
['en', 'error', 'th']
False
truncate_name
(identifier, length=None, hash_len=4)
Shorten an SQL identifier to a repeatable mangled version with the given length. If a quote stripped name contains a namespace, e.g. USERNAME"."TABLE, truncate the table portion only.
Shorten an SQL identifier to a repeatable mangled version with the given length.
def truncate_name(identifier, length=None, hash_len=4): """ Shorten an SQL identifier to a repeatable mangled version with the given length. If a quote stripped name contains a namespace, e.g. USERNAME"."TABLE, truncate the table portion only. """ namespace, name = split_identifier(identifi...
[ "def", "truncate_name", "(", "identifier", ",", "length", "=", "None", ",", "hash_len", "=", "4", ")", ":", "namespace", ",", "name", "=", "split_identifier", "(", "identifier", ")", "if", "length", "is", "None", "or", "len", "(", "name", ")", "<=", "l...
[ 198, 0 ]
[ 212, 98 ]
python
en
['en', 'error', 'th']
False
names_digest
(*args, length)
Generate a 32-bit digest of a set of arguments that can be used to shorten identifying names.
Generate a 32-bit digest of a set of arguments that can be used to shorten identifying names.
def names_digest(*args, length): """ Generate a 32-bit digest of a set of arguments that can be used to shorten identifying names. """ h = hashlib.md5() for arg in args: h.update(arg.encode()) return h.hexdigest()[:length]
[ "def", "names_digest", "(", "*", "args", ",", "length", ")", ":", "h", "=", "hashlib", ".", "md5", "(", ")", "for", "arg", "in", "args", ":", "h", ".", "update", "(", "arg", ".", "encode", "(", ")", ")", "return", "h", ".", "hexdigest", "(", ")...
[ 215, 0 ]
[ 223, 33 ]
python
en
['en', 'error', 'th']
False
format_number
(value, max_digits, decimal_places)
Format a number into a string with the requisite number of digits and decimal places.
Format a number into a string with the requisite number of digits and decimal places.
def format_number(value, max_digits, decimal_places): """ Format a number into a string with the requisite number of digits and decimal places. """ if value is None: return None context = decimal.getcontext().copy() if max_digits is not None: context.prec = max_digits if ...
[ "def", "format_number", "(", "value", ",", "max_digits", ",", "decimal_places", ")", ":", "if", "value", "is", "None", ":", "return", "None", "context", "=", "decimal", ".", "getcontext", "(", ")", ".", "copy", "(", ")", "if", "max_digits", "is", "not", ...
[ 226, 0 ]
[ 241, 31 ]
python
en
['en', 'error', 'th']
False
strip_quotes
(table_name)
Strip quotes off of quoted table names to make them safe for use in index names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming scheme) becomes 'USER"."TABLE'.
Strip quotes off of quoted table names to make them safe for use in index names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming scheme) becomes 'USER"."TABLE'.
def strip_quotes(table_name): """ Strip quotes off of quoted table names to make them safe for use in index names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming scheme) becomes 'USER"."TABLE'. """ has_quotes = table_name.startswith('"') and table_name.endswith('"') retu...
[ "def", "strip_quotes", "(", "table_name", ")", ":", "has_quotes", "=", "table_name", ".", "startswith", "(", "'\"'", ")", "and", "table_name", ".", "endswith", "(", "'\"'", ")", "return", "table_name", "[", "1", ":", "-", "1", "]", "if", "has_quotes", "e...
[ 244, 0 ]
[ 251, 57 ]
python
en
['en', 'error', 'th']
False
Command.get_handler
(self, *args, **options)
Returns the default WSGI handler for the runner.
Returns the default WSGI handler for the runner.
def get_handler(self, *args, **options): """ Returns the default WSGI handler for the runner. """ return get_internal_wsgi_application()
[ "def", "get_handler", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "return", "get_internal_wsgi_application", "(", ")" ]
[ 43, 4 ]
[ 47, 46 ]
python
en
['en', 'error', 'th']
False
Command.run
(self, **options)
Runs the server, using the autoreloader if needed
Runs the server, using the autoreloader if needed
def run(self, **options): """ Runs the server, using the autoreloader if needed """ use_reloader = options.get('use_reloader') if use_reloader: autoreload.main(self.inner_run, None, options) else: self.inner_run(None, **options)
[ "def", "run", "(", "self", ",", "*", "*", "options", ")", ":", "use_reloader", "=", "options", ".", "get", "(", "'use_reloader'", ")", "if", "use_reloader", ":", "autoreload", ".", "main", "(", "self", ".", "inner_run", ",", "None", ",", "options", ")"...
[ 82, 4 ]
[ 91, 43 ]
python
en
['en', 'error', 'th']
False
Command.check_migrations
(self)
Checks to see if the set of migrations on disk matches the migrations in the database. Prints a warning if they don't match.
Checks to see if the set of migrations on disk matches the migrations in the database. Prints a warning if they don't match.
def check_migrations(self): """ Checks to see if the set of migrations on disk matches the migrations in the database. Prints a warning if they don't match. """ executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) plan = executor.migration_plan(executor.loader.grap...
[ "def", "check_migrations", "(", "self", ")", ":", "executor", "=", "MigrationExecutor", "(", "connections", "[", "DEFAULT_DB_ALIAS", "]", ")", "plan", "=", "executor", ".", "migration_plan", "(", "executor", ".", "loader", ".", "graph", ".", "leaf_nodes", "(",...
[ 151, 4 ]
[ 162, 99 ]
python
en
['en', 'error', 'th']
False
_dnsname_match
(dn, hostname, max_wildcards=1)
Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3
Matching according to RFC 6125, section 6.4.3
def _dnsname_match(dn, hostname, max_wildcards=1): """Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 """ pats = [] if not dn: return False # Ported from python3-syntax: # leftmost, *remainder = dn.split(r'.') parts = dn.split(r"."...
[ "def", "_dnsname_match", "(", "dn", ",", "hostname", ",", "max_wildcards", "=", "1", ")", ":", "pats", "=", "[", "]", "if", "not", "dn", ":", "return", "False", "# Ported from python3-syntax:", "# leftmost, *remainder = dn.split(r'.')", "parts", "=", "dn", ".", ...
[ 24, 0 ]
[ 75, 30 ]
python
en
['en', 'en', 'en']
True
_ipaddress_match
(ipname, host_ip)
Exact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope").
Exact matching of IP addresses.
def _ipaddress_match(ipname, host_ip): """Exact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope"). """ # OpenSSL may add a trailing newline to a subjectAltName's IP address # Divergence from upstream: ipaddress can't handle byte ...
[ "def", "_ipaddress_match", "(", "ipname", ",", "host_ip", ")", ":", "# OpenSSL may add a trailing newline to a subjectAltName's IP address", "# Divergence from upstream: ipaddress can't handle byte str", "ip", "=", "ipaddress", ".", "ip_address", "(", "_to_unicode", "(", "ipname"...
[ 84, 0 ]
[ 93, 24 ]
python
en
['en', 'sn', 'en']
True
match_hostname
(cert, hostname)
Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing.
Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*.
def match_hostname(cert, hostname): """Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function r...
[ "def", "match_hostname", "(", "cert", ",", "hostname", ")", ":", "if", "not", "cert", ":", "raise", "ValueError", "(", "\"empty or no certificate, match_hostname needs a \"", "\"SSL socket or SSL context with either \"", "\"CERT_OPTIONAL or CERT_REQUIRED\"", ")", "try", ":", ...
[ 96, 0 ]
[ 159, 9 ]
python
en
['en', 'en', 'en']
True
load_network_from_checkpoint
(checkpoint, model_json, input_shape=None)
Function to read the weights from checkpoint based on json description. Args: checkpoint: tensorflow checkpoint with trained model to verify model_json: path of json file with model description of the network list of dictionary items for each layer containing 'type', 'weight_var...
Function to read the weights from checkpoint based on json description.
def load_network_from_checkpoint(checkpoint, model_json, input_shape=None): """Function to read the weights from checkpoint based on json description. Args: checkpoint: tensorflow checkpoint with trained model to verify model_json: path of json file with model description of the net...
[ "def", "load_network_from_checkpoint", "(", "checkpoint", ",", "model_json", ",", "input_shape", "=", "None", ")", ":", "# Load checkpoint", "reader", "=", "tf", ".", "train", ".", "load_checkpoint", "(", "checkpoint", ")", "variable_map", "=", "reader", ".", "g...
[ 194, 0 ]
[ 268, 5 ]
python
en
['en', 'en', 'en']
True
NeuralNetwork.__init__
( self, net_weights, net_biases, net_layer_types, input_shape=None, cnn_params=None, )
Function to initialize NeuralNetParams class. Args: net_weights: list of numpy matrices of weights of each layer [convention: x[i+1] = W[i] x[i] net_biases: list of numpy arrays of biases of each layer net_layer_types: type of each layer ['ff' or 'ff_relu' or 'ff_conv' ...
Function to initialize NeuralNetParams class.
def __init__( self, net_weights, net_biases, net_layer_types, input_shape=None, cnn_params=None, ): """Function to initialize NeuralNetParams class. Args: net_weights: list of numpy matrices of weights of each layer [convention: x...
[ "def", "__init__", "(", "self", ",", "net_weights", ",", "net_biases", ",", "net_layer_types", ",", "input_shape", "=", "None", ",", "cnn_params", "=", "None", ",", ")", ":", "if", "(", "len", "(", "net_weights", ")", "!=", "len", "(", "net_biases", ")",...
[ 19, 4 ]
[ 129, 9 ]
python
en
['en', 'en', 'en']
True
NeuralNetwork.forward_pass
(self, vector, layer_index, is_transpose=False, is_abs=False)
Performs forward pass through the layer weights at layer_index. Args: vector: vector that has to be passed through in forward pass layer_index: index of the layer is_transpose: whether the weights of the layer have to be transposed is_abs: whether to take the absolute va...
Performs forward pass through the layer weights at layer_index.
def forward_pass(self, vector, layer_index, is_transpose=False, is_abs=False): """Performs forward pass through the layer weights at layer_index. Args: vector: vector that has to be passed through in forward pass layer_index: index of the layer is_transpose: whether the we...
[ "def", "forward_pass", "(", "self", ",", "vector", ",", "layer_index", ",", "is_transpose", "=", "False", ",", "is_abs", "=", "False", ")", ":", "if", "layer_index", "<", "0", "or", "layer_index", ">", "self", ".", "num_hidden_layers", ":", "raise", "Value...
[ 131, 4 ]
[ 191, 74 ]
python
en
['en', 'en', 'en']
True
register
(*models, **kwargs)
Registers the given model(s) classes and wrapped ModelAdmin class with admin site: @register(Author) class AuthorAdmin(admin.ModelAdmin): pass A kwarg of `site` can be passed as the admin site, otherwise the default admin site will be used.
Registers the given model(s) classes and wrapped ModelAdmin class with admin site:
def register(*models, **kwargs): """ Registers the given model(s) classes and wrapped ModelAdmin class with admin site: @register(Author) class AuthorAdmin(admin.ModelAdmin): pass A kwarg of `site` can be passed as the admin site, otherwise the default admin site will be used. ...
[ "def", "register", "(", "*", "models", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "contrib", ".", "admin", "import", "ModelAdmin", "from", "django", ".", "contrib", ".", "admin", ".", "sites", "import", "site", ",", "AdminSite", "def", "...
[ 0, 0 ]
[ 27, 31 ]
python
en
['en', 'error', 'th']
False
ContentTypeManager.get_for_model
(self, model, for_concrete_model=True)
Returns the ContentType object for a given model, creating the ContentType if necessary. Lookups are cached so that subsequent lookups for the same model don't hit the database.
Returns the ContentType object for a given model, creating the ContentType if necessary. Lookups are cached so that subsequent lookups for the same model don't hit the database.
def get_for_model(self, model, for_concrete_model=True): """ Returns the ContentType object for a given model, creating the ContentType if necessary. Lookups are cached so that subsequent lookups for the same model don't hit the database. """ opts = self._get_opts(model, ...
[ "def", "get_for_model", "(", "self", ",", "model", ",", "for_concrete_model", "=", "True", ")", ":", "opts", "=", "self", ".", "_get_opts", "(", "model", ",", "for_concrete_model", ")", "try", ":", "return", "self", ".", "_get_from_cache", "(", "opts", ")"...
[ 35, 4 ]
[ 69, 17 ]
python
en
['en', 'error', 'th']
False
ContentTypeManager.get_for_models
(self, *models, **kwargs)
Given *models, returns a dictionary mapping {model: content_type}.
Given *models, returns a dictionary mapping {model: content_type}.
def get_for_models(self, *models, **kwargs): """ Given *models, returns a dictionary mapping {model: content_type}. """ for_concrete_models = kwargs.pop('for_concrete_models', True) # Final results results = {} # models that aren't already in the cache nee...
[ "def", "get_for_models", "(", "self", ",", "*", "models", ",", "*", "*", "kwargs", ")", ":", "for_concrete_models", "=", "kwargs", ".", "pop", "(", "'for_concrete_models'", ",", "True", ")", "# Final results", "results", "=", "{", "}", "# models that aren't al...
[ 71, 4 ]
[ 112, 22 ]
python
en
['en', 'error', 'th']
False
ContentTypeManager.get_for_id
(self, id)
Lookup a ContentType by ID. Uses the same shared cache as get_for_model (though ContentTypes are obviously not created on-the-fly by get_by_id).
Lookup a ContentType by ID. Uses the same shared cache as get_for_model (though ContentTypes are obviously not created on-the-fly by get_by_id).
def get_for_id(self, id): """ Lookup a ContentType by ID. Uses the same shared cache as get_for_model (though ContentTypes are obviously not created on-the-fly by get_by_id). """ try: ct = self.__class__._cache[self.db][id] except KeyError: # This ...
[ "def", "get_for_id", "(", "self", ",", "id", ")", ":", "try", ":", "ct", "=", "self", ".", "__class__", ".", "_cache", "[", "self", ".", "db", "]", "[", "id", "]", "except", "KeyError", ":", "# This could raise a DoesNotExist; that's correct behavior and will"...
[ 114, 4 ]
[ 126, 17 ]
python
en
['en', 'error', 'th']
False
ContentTypeManager.clear_cache
(self)
Clear out the content-type cache. This needs to happen during database flushes to prevent caching of "stale" content type IDs (see django.contrib.contenttypes.management.update_contenttypes for where this gets called).
Clear out the content-type cache. This needs to happen during database flushes to prevent caching of "stale" content type IDs (see django.contrib.contenttypes.management.update_contenttypes for where this gets called).
def clear_cache(self): """ Clear out the content-type cache. This needs to happen during database flushes to prevent caching of "stale" content type IDs (see django.contrib.contenttypes.management.update_contenttypes for where this gets called). """ self.__class__...
[ "def", "clear_cache", "(", "self", ")", ":", "self", ".", "__class__", ".", "_cache", ".", "clear", "(", ")" ]
[ 128, 4 ]
[ 135, 37 ]
python
en
['en', 'error', 'th']
False
ContentTypeManager._add_to_cache
(self, using, ct)
Insert a ContentType into the cache.
Insert a ContentType into the cache.
def _add_to_cache(self, using, ct): """Insert a ContentType into the cache.""" # Note it's possible for ContentType objects to be stale; model_class() will return None. # Hence, there is no reliance on model._meta.app_label here, just using the model fields instead. key = (ct.app_label, ...
[ "def", "_add_to_cache", "(", "self", ",", "using", ",", "ct", ")", ":", "# Note it's possible for ContentType objects to be stale; model_class() will return None.", "# Hence, there is no reliance on model._meta.app_label here, just using the model fields instead.", "key", "=", "(", "ct...
[ 137, 4 ]
[ 143, 63 ]
python
en
['en', 'en', 'en']
True
tempdir
()
Create a temporary directory in a context manager.
Create a temporary directory in a context manager.
def tempdir(): """Create a temporary directory in a context manager.""" td = tempfile.mkdtemp() try: yield td finally: shutil.rmtree(td)
[ "def", "tempdir", "(", ")", ":", "td", "=", "tempfile", ".", "mkdtemp", "(", ")", "try", ":", "yield", "td", "finally", ":", "shutil", ".", "rmtree", "(", "td", ")" ]
[ 10, 0 ]
[ 16, 25 ]
python
en
['en', 'en', 'en']
True
mkdir_p
(*args, **kwargs)
Like `mkdir`, but does not raise an exception if the directory already exists.
Like `mkdir`, but does not raise an exception if the directory already exists.
def mkdir_p(*args, **kwargs): """Like `mkdir`, but does not raise an exception if the directory already exists. """ try: return os.mkdir(*args, **kwargs) except OSError as exc: if exc.errno != errno.EEXIST: raise
[ "def", "mkdir_p", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "os", ".", "mkdir", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "OSError", "as", "exc", ":", "if", "exc", ".", "errno", "!=", "errno", "....
[ 19, 0 ]
[ 27, 17 ]
python
en
['en', 'en', 'en']
True
dir_to_zipfile
(root)
Construct an in-memory zip file for a directory.
Construct an in-memory zip file for a directory.
def dir_to_zipfile(root): """Construct an in-memory zip file for a directory.""" buffer = io.BytesIO() zip_file = zipfile.ZipFile(buffer, 'w') for root, dirs, files in os.walk(root): for path in dirs: fs_path = os.path.join(root, path) rel_path = os.path.relpath(fs_path, ...
[ "def", "dir_to_zipfile", "(", "root", ")", ":", "buffer", "=", "io", ".", "BytesIO", "(", ")", "zip_file", "=", "zipfile", ".", "ZipFile", "(", "buffer", ",", "'w'", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "root...
[ 30, 0 ]
[ 43, 19 ]
python
en
['br', 'en', 'en']
True
DeletionTests.test_add_form_deletion_when_invalid
(self)
Make sure that an add form that is filled out, but marked for deletion doesn't cause validation errors.
Make sure that an add form that is filled out, but marked for deletion doesn't cause validation errors.
def test_add_form_deletion_when_invalid(self): """ Make sure that an add form that is filled out, but marked for deletion doesn't cause validation errors. """ PoetFormSet = modelformset_factory(Poet, fields="__all__", can_delete=True) poet = Poet.objects.create(name='test...
[ "def", "test_add_form_deletion_when_invalid", "(", "self", ")", ":", "PoetFormSet", "=", "modelformset_factory", "(", "Poet", ",", "fields", "=", "\"__all__\"", ",", "can_delete", "=", "True", ")", "poet", "=", "Poet", ".", "objects", ".", "create", "(", "name...
[ 42, 4 ]
[ 74, 49 ]
python
en
['en', 'error', 'th']
False
DeletionTests.test_change_form_deletion_when_invalid
(self)
Make sure that a change form that is filled out, but marked for deletion doesn't cause validation errors.
Make sure that a change form that is filled out, but marked for deletion doesn't cause validation errors.
def test_change_form_deletion_when_invalid(self): """ Make sure that a change form that is filled out, but marked for deletion doesn't cause validation errors. """ PoetFormSet = modelformset_factory(Poet, fields="__all__", can_delete=True) poet = Poet.objects.create(name=...
[ "def", "test_change_form_deletion_when_invalid", "(", "self", ")", ":", "PoetFormSet", "=", "modelformset_factory", "(", "Poet", ",", "fields", "=", "\"__all__\"", ",", "can_delete", "=", "True", ")", "poet", "=", "Poet", ".", "objects", ".", "create", "(", "n...
[ 76, 4 ]
[ 101, 49 ]
python
en
['en', 'error', 'th']
False
ModelFormsetTest.test_modelformset_factory_without_fields
(self)
Regression for #19733
Regression for #19733
def test_modelformset_factory_without_fields(self): """ Regression for #19733 """ message = ( "Calling modelformset_factory without defining 'fields' or 'exclude' " "explicitly is prohibited." ) with self.assertRaisesMessage(ImproperlyConfigured, message): ...
[ "def", "test_modelformset_factory_without_fields", "(", "self", ")", ":", "message", "=", "(", "\"Calling modelformset_factory without defining 'fields' or 'exclude' \"", "\"explicitly is prohibited.\"", ")", "with", "self", ".", "assertRaisesMessage", "(", "ImproperlyConfigured", ...
[ 134, 4 ]
[ 141, 40 ]
python
en
['en', 'en', 'en']
True
ModelFormsetTest.test_custom_form
(self)
Test that model_formset respects fields and exclude parameters of custom form
Test that model_formset respects fields and exclude parameters of custom form
def test_custom_form(self): """ Test that model_formset respects fields and exclude parameters of custom form """ class PostForm1(forms.ModelForm): class Meta: model = Post fields = ('title', 'posted') class PostForm2(forms.ModelFo...
[ "def", "test_custom_form", "(", "self", ")", ":", "class", "PostForm1", "(", "forms", ".", "ModelForm", ")", ":", "class", "Meta", ":", "model", "=", "Post", "fields", "=", "(", "'title'", ",", "'posted'", ")", "class", "PostForm2", "(", "forms", ".", ...
[ 435, 4 ]
[ 455, 63 ]
python
en
['en', 'en', 'en']
True
ModelFormsetTest.test_custom_queryset_init
(self)
Test that a queryset can be overridden in the __init__ method. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-the-queryset
Test that a queryset can be overridden in the __init__ method. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-the-queryset
def test_custom_queryset_init(self): """ Test that a queryset can be overridden in the __init__ method. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-the-queryset """ Author.objects.create(name='Charles Baudelaire') Author.objects.create(name='Pa...
[ "def", "test_custom_queryset_init", "(", "self", ")", ":", "Author", ".", "objects", ".", "create", "(", "name", "=", "'Charles Baudelaire'", ")", "Author", ".", "objects", ".", "create", "(", "name", "=", "'Paul Verlaine'", ")", "class", "BaseAuthorFormSet", ...
[ 457, 4 ]
[ 472, 56 ]
python
en
['en', 'error', 'th']
False
ModelFormsetTest.test_inline_formsets_with_wrong_fk_name
(self)
Regression for #23451
Regression for #23451
def test_inline_formsets_with_wrong_fk_name(self): """ Regression for #23451 """ message = "fk_name 'title' is not a ForeignKey to 'model_formsets.Author'." with self.assertRaisesMessage(ValueError, message): inlineformset_factory(Author, Book, fields="__all__", fk_name='title')
[ "def", "test_inline_formsets_with_wrong_fk_name", "(", "self", ")", ":", "message", "=", "\"fk_name 'title' is not a ForeignKey to 'model_formsets.Author'.\"", "with", "self", ".", "assertRaisesMessage", "(", "ValueError", ",", "message", ")", ":", "inlineformset_factory", "(...
[ 817, 4 ]
[ 821, 82 ]
python
en
['en', 'en', 'en']
True
to_list
(value)
Puts value into a list if it's not already one. Returns an empty list if value is None.
Puts value into a list if it's not already one. Returns an empty list if value is None.
def to_list(value): """ Puts value into a list if it's not already one. Returns an empty list if value is None. """ if value is None: value = [] elif not isinstance(value, list): value = [value] return value
[ "def", "to_list", "(", "value", ")", ":", "if", "value", "is", "None", ":", "value", "=", "[", "]", "elif", "not", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[", "value", "]", "return", "value" ]
[ 49, 0 ]
[ 58, 16 ]
python
en
['en', 'error', 'th']
False
connections_support_transactions
()
Returns True if all connections support transactions.
Returns True if all connections support transactions.
def connections_support_transactions(): """ Returns True if all connections support transactions. """ return all(conn.features.supports_transactions for conn in connections.all())
[ "def", "connections_support_transactions", "(", ")", ":", "return", "all", "(", "conn", ".", "features", ".", "supports_transactions", "for", "conn", "in", "connections", ".", "all", "(", ")", ")" ]
[ 895, 0 ]
[ 900, 45 ]
python
en
['en', 'error', 'th']
False
skipIfDBFeature
(*features)
Skip a test if a database has at least one of the named features.
Skip a test if a database has at least one of the named features.
def skipIfDBFeature(*features): """ Skip a test if a database has at least one of the named features. """ return _deferredSkip( lambda: any(getattr(connection.features, feature, False) for feature in features), "Database has feature(s) %s" % ", ".join(features) )
[ "def", "skipIfDBFeature", "(", "*", "features", ")", ":", "return", "_deferredSkip", "(", "lambda", ":", "any", "(", "getattr", "(", "connection", ".", "features", ",", "feature", ",", "False", ")", "for", "feature", "in", "features", ")", ",", "\"Database...
[ 979, 0 ]
[ 986, 5 ]
python
en
['en', 'error', 'th']
False
skipUnlessDBFeature
(*features)
Skip a test unless a database has all the named features.
Skip a test unless a database has all the named features.
def skipUnlessDBFeature(*features): """ Skip a test unless a database has all the named features. """ return _deferredSkip( lambda: not all(getattr(connection.features, feature, False) for feature in features), "Database doesn't support feature(s): %s" % ", ".join(features) )
[ "def", "skipUnlessDBFeature", "(", "*", "features", ")", ":", "return", "_deferredSkip", "(", "lambda", ":", "not", "all", "(", "getattr", "(", "connection", ".", "features", ",", "feature", ",", "False", ")", "for", "feature", "in", "features", ")", ",", ...
[ 989, 0 ]
[ 996, 5 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.__call__
(self, result=None)
Wrapper around default __call__ method to perform common Django test set up. This means that user-defined Test Cases aren't required to include a call to super().setUp().
Wrapper around default __call__ method to perform common Django test set up. This means that user-defined Test Cases aren't required to include a call to super().setUp().
def __call__(self, result=None): """ Wrapper around default __call__ method to perform common Django test set up. This means that user-defined Test Cases aren't required to include a call to super().setUp(). """ testMethod = getattr(self, self._testMethodName) ski...
[ "def", "__call__", "(", "self", ",", "result", "=", "None", ")", ":", "testMethod", "=", "getattr", "(", "self", ",", "self", ".", "_testMethodName", ")", "skipped", "=", "(", "getattr", "(", "self", ".", "__class__", ",", "\"__unittest_skip__\"", ",", "...
[ 163, 4 ]
[ 185, 22 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase._pre_setup
(self)
Performs any pre-test setup. This includes: * Creating a test client. * If the class has a 'urls' attribute, replace ROOT_URLCONF with it. * Clearing the mail test outbox.
Performs any pre-test setup. This includes:
def _pre_setup(self): """Performs any pre-test setup. This includes: * Creating a test client. * If the class has a 'urls' attribute, replace ROOT_URLCONF with it. * Clearing the mail test outbox. """ if self._overridden_settings: self._overridden_context = o...
[ "def", "_pre_setup", "(", "self", ")", ":", "if", "self", ".", "_overridden_settings", ":", "self", ".", "_overridden_context", "=", "override_settings", "(", "*", "*", "self", ".", "_overridden_settings", ")", "self", ".", "_overridden_context", ".", "enable", ...
[ 187, 4 ]
[ 202, 24 ]
python
en
['en', 'en', 'en']
True
SimpleTestCase._post_teardown
(self)
Performs any post-test things. This includes: * Putting back the original ROOT_URLCONF if it was changed.
Performs any post-test things. This includes:
def _post_teardown(self): """Performs any post-test things. This includes: * Putting back the original ROOT_URLCONF if it was changed. """ self._urlconf_teardown() if self._modified_settings: self._modified_context.disable() if self._overridden_settings: ...
[ "def", "_post_teardown", "(", "self", ")", ":", "self", ".", "_urlconf_teardown", "(", ")", "if", "self", ".", "_modified_settings", ":", "self", ".", "_modified_context", ".", "disable", "(", ")", "if", "self", ".", "_overridden_settings", ":", "self", ".",...
[ 216, 4 ]
[ 225, 46 ]
python
en
['en', 'en', 'en']
True
SimpleTestCase.settings
(self, **kwargs)
A context manager that temporarily sets a setting and reverts to the original value when exiting the context.
A context manager that temporarily sets a setting and reverts to the original value when exiting the context.
def settings(self, **kwargs): """ A context manager that temporarily sets a setting and reverts to the original value when exiting the context. """ return override_settings(**kwargs)
[ "def", "settings", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "override_settings", "(", "*", "*", "kwargs", ")" ]
[ 233, 4 ]
[ 237, 42 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.modify_settings
(self, **kwargs)
A context manager that temporarily applies changes a list setting and reverts back to the original value when exiting the context.
A context manager that temporarily applies changes a list setting and reverts back to the original value when exiting the context.
def modify_settings(self, **kwargs): """ A context manager that temporarily applies changes a list setting and reverts back to the original value when exiting the context. """ return modify_settings(**kwargs)
[ "def", "modify_settings", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "modify_settings", "(", "*", "*", "kwargs", ")" ]
[ 239, 4 ]
[ 244, 40 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertRedirects
(self, response, expected_url, status_code=302, target_status_code=200, host=None, msg_prefix='', fetch_redirect_response=True)
Asserts that a response redirected to a specific URL, and that the redirect URL can be loaded. Note that assertRedirects won't work for external links since it uses TestClient to do a request (use fetch_redirect_response=False to check such links without fetching them).
Asserts that a response redirected to a specific URL, and that the redirect URL can be loaded.
def assertRedirects(self, response, expected_url, status_code=302, target_status_code=200, host=None, msg_prefix='', fetch_redirect_response=True): """Asserts that a response redirected to a specific URL, and that the redirect URL can be loaded. N...
[ "def", "assertRedirects", "(", "self", ",", "response", ",", "expected_url", ",", "status_code", "=", "302", ",", "target_status_code", "=", "200", ",", "host", "=", "None", ",", "msg_prefix", "=", "''", ",", "fetch_redirect_response", "=", "True", ")", ":",...
[ 246, 4 ]
[ 309, 36 ]
python
en
['en', 'en', 'en']
True
SimpleTestCase.assertContains
(self, response, text, count=None, status_code=200, msg_prefix='', html=False)
Asserts that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected), and that ``text`` occurs ``count`` times in the content of the response. If ``count`` is None, the count doesn't matter - the assertion is true if the te...
Asserts that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected), and that ``text`` occurs ``count`` times in the content of the response. If ``count`` is None, the count doesn't matter - the assertion is true if the te...
def assertContains(self, response, text, count=None, status_code=200, msg_prefix='', html=False): """ Asserts that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected), and that ``text`` occurs ``count`` ti...
[ "def", "assertContains", "(", "self", ",", "response", ",", "text", ",", "count", "=", "None", ",", "status_code", "=", "200", ",", "msg_prefix", "=", "''", ",", "html", "=", "False", ")", ":", "text_repr", ",", "real_count", ",", "msg_prefix", "=", "s...
[ 343, 4 ]
[ 361, 72 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertNotContains
(self, response, text, status_code=200, msg_prefix='', html=False)
Asserts that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected), and that ``text`` doesn't occurs in the content of the response.
Asserts that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected), and that ``text`` doesn't occurs in the content of the response.
def assertNotContains(self, response, text, status_code=200, msg_prefix='', html=False): """ Asserts that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected), and that ``text`` doesn't occurs in the con...
[ "def", "assertNotContains", "(", "self", ",", "response", ",", "text", ",", "status_code", "=", "200", ",", "msg_prefix", "=", "''", ",", "html", "=", "False", ")", ":", "text_repr", ",", "real_count", ",", "msg_prefix", "=", "self", ".", "_assert_contains...
[ 363, 4 ]
[ 374, 74 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertFormError
(self, response, form, field, errors, msg_prefix='')
Asserts that a form used to render the response has a specific field error.
Asserts that a form used to render the response has a specific field error.
def assertFormError(self, response, form, field, errors, msg_prefix=''): """ Asserts that a form used to render the response has a specific field error. """ if msg_prefix: msg_prefix += ": " # Put context(s) into a list to simplify processing. context...
[ "def", "assertFormError", "(", "self", ",", "response", ",", "form", ",", "field", ",", "errors", ",", "msg_prefix", "=", "''", ")", ":", "if", "msg_prefix", ":", "msg_prefix", "+=", "\": \"", "# Put context(s) into a list to simplify processing.", "contexts", "="...
[ 376, 4 ]
[ 425, 41 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertFormsetError
(self, response, formset, form_index, field, errors, msg_prefix='')
Asserts that a formset used to render the response has a specific error. For field errors, specify the ``form_index`` and the ``field``. For non-field errors, specify the ``form_index`` and the ``field`` as None. For non-form errors, specify ``form_index`` as None and the ``fie...
Asserts that a formset used to render the response has a specific error.
def assertFormsetError(self, response, formset, form_index, field, errors, msg_prefix=''): """ Asserts that a formset used to render the response has a specific error. For field errors, specify the ``form_index`` and the ``field``. For non-field errors, specif...
[ "def", "assertFormsetError", "(", "self", ",", "response", ",", "formset", ",", "form_index", ",", "field", ",", "errors", ",", "msg_prefix", "=", "''", ")", ":", "# Add punctuation to msg_prefix", "if", "msg_prefix", ":", "msg_prefix", "+=", "\": \"", "# Put co...
[ 427, 4 ]
[ 502, 47 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertTemplateUsed
(self, response=None, template_name=None, msg_prefix='', count=None)
Asserts that the template with the provided name was used in rendering the response. Also usable as context manager.
Asserts that the template with the provided name was used in rendering the response. Also usable as context manager.
def assertTemplateUsed(self, response=None, template_name=None, msg_prefix='', count=None): """ Asserts that the template with the provided name was used in rendering the response. Also usable as context manager. """ context_mgr_template, template_names, msg_prefix = self._assert...
[ "def", "assertTemplateUsed", "(", "self", ",", "response", "=", "None", ",", "template_name", "=", "None", ",", "msg_prefix", "=", "''", ",", "count", "=", "None", ")", ":", "context_mgr_template", ",", "template_names", ",", "msg_prefix", "=", "self", ".", ...
[ 523, 4 ]
[ 546, 80 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertTemplateNotUsed
(self, response=None, template_name=None, msg_prefix='')
Asserts that the template with the provided name was NOT used in rendering the response. Also usable as context manager.
Asserts that the template with the provided name was NOT used in rendering the response. Also usable as context manager.
def assertTemplateNotUsed(self, response=None, template_name=None, msg_prefix=''): """ Asserts that the template with the provided name was NOT used in rendering the response. Also usable as context manager. """ context_mgr_template, template_names, msg_prefix = self._assert_tem...
[ "def", "assertTemplateNotUsed", "(", "self", ",", "response", "=", "None", ",", "template_name", "=", "None", ",", "msg_prefix", "=", "''", ")", ":", "context_mgr_template", ",", "template_names", ",", "msg_prefix", "=", "self", ".", "_assert_template_used", "("...
[ 548, 4 ]
[ 563, 44 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertRaisesMessage
(self, expected_exception, expected_message, callable_obj=None, *args, **kwargs)
Asserts that the message in a raised exception matches the passed value. Args: expected_exception: Exception class expected to be raised. expected_message: expected error message string value. callable_obj: Function to be called. args: Extra args...
Asserts that the message in a raised exception matches the passed value.
def assertRaisesMessage(self, expected_exception, expected_message, callable_obj=None, *args, **kwargs): """ Asserts that the message in a raised exception matches the passed value. Args: expected_exception: Exception class expected to be raised. ...
[ "def", "assertRaisesMessage", "(", "self", ",", "expected_exception", ",", "expected_message", ",", "callable_obj", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "six", ".", "assertRaisesRegex", "(", "self", ",", "expected_excepti...
[ 565, 4 ]
[ 579, 75 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertFieldOutput
(self, fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value='')
Asserts that a form field behaves correctly with various inputs. Args: fieldclass: the class of the field to be tested. valid: a dictionary mapping valid inputs to their expected cleaned values. invalid: a dictionary mapping invalid inputs to one...
Asserts that a form field behaves correctly with various inputs.
def assertFieldOutput(self, fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value=''): """ Asserts that a form field behaves correctly with various inputs. Args: fieldclass: the class of the field to be tested. valid: a dictionary mappin...
[ "def", "assertFieldOutput", "(", "self", ",", "fieldclass", ",", "valid", ",", "invalid", ",", "field_args", "=", "None", ",", "field_kwargs", "=", "None", ",", "empty_value", "=", "''", ")", ":", "if", "field_args", "is", "None", ":", "field_args", "=", ...
[ 581, 4 ]
[ 629, 45 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertHTMLEqual
(self, html1, html2, msg=None)
Asserts that two HTML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid HTML.
Asserts that two HTML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid HTML.
def assertHTMLEqual(self, html1, html2, msg=None): """ Asserts that two HTML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid HTML. """ dom1 = assert_and_parse_html(se...
[ "def", "assertHTMLEqual", "(", "self", ",", "html1", ",", "html2", ",", "msg", "=", "None", ")", ":", "dom1", "=", "assert_and_parse_html", "(", "self", ",", "html1", ",", "msg", ",", "'First argument is not valid HTML:'", ")", "dom2", "=", "assert_and_parse_h...
[ 631, 4 ]
[ 649, 60 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertHTMLNotEqual
(self, html1, html2, msg=None)
Asserts that two HTML snippets are not semantically equivalent.
Asserts that two HTML snippets are not semantically equivalent.
def assertHTMLNotEqual(self, html1, html2, msg=None): """Asserts that two HTML snippets are not semantically equivalent.""" dom1 = assert_and_parse_html(self, html1, msg, 'First argument is not valid HTML:') dom2 = assert_and_parse_html(self, html2, msg, 'Second argument ...
[ "def", "assertHTMLNotEqual", "(", "self", ",", "html1", ",", "html2", ",", "msg", "=", "None", ")", ":", "dom1", "=", "assert_and_parse_html", "(", "self", ",", "html1", ",", "msg", ",", "'First argument is not valid HTML:'", ")", "dom2", "=", "assert_and_pars...
[ 651, 4 ]
[ 661, 60 ]
python
en
['en', 'en', 'en']
True
SimpleTestCase.assertJSONEqual
(self, raw, expected_data, msg=None)
Asserts that the JSON fragments raw and expected_data are equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library.
Asserts that the JSON fragments raw and expected_data are equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library.
def assertJSONEqual(self, raw, expected_data, msg=None): """ Asserts that the JSON fragments raw and expected_data are equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library. """ try: data = json.loads(raw)...
[ "def", "assertJSONEqual", "(", "self", ",", "raw", ",", "expected_data", ",", "msg", "=", "None", ")", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "raw", ")", "except", "ValueError", ":", "self", ".", "fail", "(", "\"First argument is not va...
[ 677, 4 ]
[ 692, 54 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertJSONNotEqual
(self, raw, expected_data, msg=None)
Asserts that the JSON fragments raw and expected_data are not equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library.
Asserts that the JSON fragments raw and expected_data are not equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library.
def assertJSONNotEqual(self, raw, expected_data, msg=None): """ Asserts that the JSON fragments raw and expected_data are not equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library. """ try: data = json.loa...
[ "def", "assertJSONNotEqual", "(", "self", ",", "raw", ",", "expected_data", ",", "msg", "=", "None", ")", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "raw", ")", "except", "ValueError", ":", "self", ".", "fail", "(", "\"First argument is not...
[ 694, 4 ]
[ 709, 57 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertXMLEqual
(self, xml1, xml2, msg=None)
Asserts that two XML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid XML.
Asserts that two XML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid XML.
def assertXMLEqual(self, xml1, xml2, msg=None): """ Asserts that two XML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid XML. """ try: result = compare_xm...
[ "def", "assertXMLEqual", "(", "self", ",", "xml1", ",", "xml2", ",", "msg", "=", "None", ")", ":", "try", ":", "result", "=", "compare_xml", "(", "xml1", ",", "xml2", ")", "except", "Exception", "as", "e", ":", "standardMsg", "=", "'First or second argum...
[ 711, 4 ]
[ 725, 64 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertXMLNotEqual
(self, xml1, xml2, msg=None)
Asserts that two XML snippets are not semantically equivalent. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid XML.
Asserts that two XML snippets are not semantically equivalent. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid XML.
def assertXMLNotEqual(self, xml1, xml2, msg=None): """ Asserts that two XML snippets are not semantically equivalent. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid XML. """ try: result = c...
[ "def", "assertXMLNotEqual", "(", "self", ",", "xml1", ",", "xml2", ",", "msg", "=", "None", ")", ":", "try", ":", "result", "=", "compare_xml", "(", "xml1", ",", "xml2", ")", "except", "Exception", "as", "e", ":", "standardMsg", "=", "'First or second ar...
[ 727, 4 ]
[ 741, 64 ]
python
en
['en', 'error', 'th']
False
TransactionTestCase._pre_setup
(self)
Performs any pre-test setup. This includes: * If the class has an 'available_apps' attribute, restricting the app registry to these applications, then firing post_migrate -- it must run with the correct set of applications for the test case. * If the class has a 'fixtures' attribute...
Performs any pre-test setup. This includes:
def _pre_setup(self): """Performs any pre-test setup. This includes: * If the class has an 'available_apps' attribute, restricting the app registry to these applications, then firing post_migrate -- it must run with the correct set of applications for the test case. * If the...
[ "def", "_pre_setup", "(", "self", ")", ":", "super", "(", "TransactionTestCase", ",", "self", ")", ".", "_pre_setup", "(", ")", "if", "self", ".", "available_apps", "is", "not", "None", ":", "apps", ".", "set_available_apps", "(", "self", ".", "available_a...
[ 762, 4 ]
[ 789, 17 ]
python
en
['en', 'en', 'en']
True
TransactionTestCase._post_teardown
(self)
Performs any post-test things. This includes: * Flushing the contents of the database, to leave a clean slate. If the class has an 'available_apps' attribute, post_migrate isn't fired. * Force-closing the connection, so the next test gets a clean cursor.
Performs any post-test things. This includes:
def _post_teardown(self): """Performs any post-test things. This includes: * Flushing the contents of the database, to leave a clean slate. If the class has an 'available_apps' attribute, post_migrate isn't fired. * Force-closing the connection, so the next test gets a clean cursor. ...
[ "def", "_post_teardown", "(", "self", ")", ":", "try", ":", "self", ".", "_fixture_teardown", "(", ")", "super", "(", "TransactionTestCase", ",", "self", ")", ".", "_post_teardown", "(", ")", "# Some DB cursors include SQL statements as part of cursor", "# creation. I...
[ 834, 4 ]
[ 858, 49 ]
python
en
['en', 'en', 'en']
True
FSFilesHandler._should_handle
(self, path)
Checks if the path should be handled. Ignores the path if: * the host is provided as part of the base_url * the request's path isn't under the media path (or equal)
Checks if the path should be handled. Ignores the path if:
def _should_handle(self, path): """ Checks if the path should be handled. Ignores the path if: * the host is provided as part of the base_url * the request's path isn't under the media path (or equal) """ return path.startswith(self.base_url[2]) and not self.base_url[1]
[ "def", "_should_handle", "(", "self", ",", "path", ")", ":", "return", "path", ".", "startswith", "(", "self", ".", "base_url", "[", "2", "]", ")", "and", "not", "self", ".", "base_url", "[", "1", "]" ]
[ 1020, 4 ]
[ 1027, 73 ]
python
en
['en', 'error', 'th']
False
FSFilesHandler.file_path
(self, url)
Returns the relative path to the file on disk for the given URL.
Returns the relative path to the file on disk for the given URL.
def file_path(self, url): """ Returns the relative path to the file on disk for the given URL. """ relative_url = url[len(self.base_url[2]):] return url2pathname(relative_url)
[ "def", "file_path", "(", "self", ",", "url", ")", ":", "relative_url", "=", "url", "[", "len", "(", "self", ".", "base_url", "[", "2", "]", ")", ":", "]", "return", "url2pathname", "(", "relative_url", ")" ]
[ 1029, 4 ]
[ 1034, 41 ]
python
en
['en', 'error', 'th']
False
LiveServerThread.run
(self)
Sets up the live server and databases, and then loops over handling http requests.
Sets up the live server and databases, and then loops over handling http requests.
def run(self): """ Sets up the live server and databases, and then loops over handling http requests. """ if self.connections_override: # Override this thread's database connections with the ones # provided by the main thread. for alias, conn i...
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "connections_override", ":", "# Override this thread's database connections with the ones", "# provided by the main thread.", "for", "alias", ",", "conn", "in", "self", ".", "connections_override", ".", "items", "(...
[ 1102, 4 ]
[ 1143, 31 ]
python
en
['en', 'error', 'th']
False
Driver.__init__
(self, dr_input)
Initializes an OGR driver on either a string or integer input.
Initializes an OGR driver on either a string or integer input.
def __init__(self, dr_input): "Initializes an OGR driver on either a string or integer input." if isinstance(dr_input, six.string_types): # If a string name of the driver was passed in self._register() # Checking the alias dictionary (case-insensitive) to see if an ...
[ "def", "__init__", "(", "self", ",", "dr_input", ")", ":", "if", "isinstance", "(", "dr_input", ",", "six", ".", "string_types", ")", ":", "# If a string name of the driver was passed in", "self", ".", "_register", "(", ")", "# Checking the alias dictionary (case-inse...
[ 25, 4 ]
[ 52, 21 ]
python
en
['en', 'en', 'en']
True
Driver.__str__
(self)
Returns the string name of the OGR Driver.
Returns the string name of the OGR Driver.
def __str__(self): "Returns the string name of the OGR Driver." return capi.get_driver_name(self.ptr)
[ "def", "__str__", "(", "self", ")", ":", "return", "capi", ".", "get_driver_name", "(", "self", ".", "ptr", ")" ]
[ 54, 4 ]
[ 56, 45 ]
python
en
['en', 'en', 'en']
True
Driver._register
(self)
Attempts to register all the data source drivers.
Attempts to register all the data source drivers.
def _register(self): "Attempts to register all the data source drivers." # Only register all if the driver count is 0 (or else all drivers # will be registered over and over again) if not self.driver_count: capi.register_all()
[ "def", "_register", "(", "self", ")", ":", "# Only register all if the driver count is 0 (or else all drivers", "# will be registered over and over again)", "if", "not", "self", ".", "driver_count", ":", "capi", ".", "register_all", "(", ")" ]
[ 58, 4 ]
[ 63, 31 ]
python
en
['en', 'en', 'en']
True
Driver.driver_count
(self)
Returns the number of OGR data source drivers registered.
Returns the number of OGR data source drivers registered.
def driver_count(self): "Returns the number of OGR data source drivers registered." return capi.get_driver_count()
[ "def", "driver_count", "(", "self", ")", ":", "return", "capi", ".", "get_driver_count", "(", ")" ]
[ 67, 4 ]
[ 69, 38 ]
python
en
['en', 'da', 'en']
True