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
fits_detect
(filename)
Detect which telescope produced FITS data, return corresponding accessor. Checks for known FITS image types where we expect additional metadata. If the telescope is unknown we default to a regular FitsImage.
Detect which telescope produced FITS data, return corresponding accessor.
def fits_detect(filename): """ Detect which telescope produced FITS data, return corresponding accessor. Checks for known FITS image types where we expect additional metadata. If the telescope is unknown we default to a regular FitsImage. """ with pyfits.open(filename) as hdulist: hdr =...
[ "def", "fits_detect", "(", "filename", ")", ":", "with", "pyfits", ".", "open", "(", "filename", ")", "as", "hdulist", ":", "hdr", "=", "hdulist", "[", "0", "]", ".", "header", "for", "fits_test", "in", "fits_type_mapping", ":", "if", "fits_test", ".", ...
[ 84, 0 ]
[ 96, 20 ]
python
en
['en', 'error', 'th']
False
casa_detect
(filename)
Detect which telescope produced CASA data, return corresponding accessor. Checks for known CASA table types where we expect additional metadata. If the telescope is unknown we return nothing.
Detect which telescope produced CASA data, return corresponding accessor.
def casa_detect(filename): """ Detect which telescope produced CASA data, return corresponding accessor. Checks for known CASA table types where we expect additional metadata. If the telescope is unknown we return nothing. """ table = casacore_table(filename.encode(), ack=False) telescope =...
[ "def", "casa_detect", "(", "filename", ")", ":", "table", "=", "casacore_table", "(", "filename", ".", "encode", "(", ")", ",", "ack", "=", "False", ")", "telescope", "=", "table", ".", "getkeyword", "(", "'coords'", ")", "[", "'telescope'", "]", "return...
[ 99, 0 ]
[ 108, 62 ]
python
en
['en', 'error', 'th']
False
detect
(filename)
returns the accessor class that should be used to process filename
returns the accessor class that should be used to process filename
def detect(filename): """returns the accessor class that should be used to process filename""" if isfits(filename): return fits_detect(filename) elif iscasa(filename): return casa_detect(filename) elif islofarhdf5(filename): return LofarHdf5Image else: raise IOError("...
[ "def", "detect", "(", "filename", ")", ":", "if", "isfits", "(", "filename", ")", ":", "return", "fits_detect", "(", "filename", ")", "elif", "iscasa", "(", "filename", ")", ":", "return", "casa_detect", "(", "filename", ")", "elif", "islofarhdf5", "(", ...
[ 111, 0 ]
[ 120, 58 ]
python
en
['en', 'en', 'en']
True
CacheControlAdapter.send
(self, request, cacheable_methods=None, **kw)
Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can.
Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can.
def send(self, request, cacheable_methods=None, **kw): """ Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can. """ cacheable = cacheable_methods or self.cacheable_methods if request.method in cacheable...
[ "def", "send", "(", "self", ",", "request", ",", "cacheable_methods", "=", "None", ",", "*", "*", "kw", ")", ":", "cacheable", "=", "cacheable_methods", "or", "self", ".", "cacheable_methods", "if", "request", ".", "method", "in", "cacheable", ":", "try", ...
[ 35, 4 ]
[ 54, 19 ]
python
en
['en', 'error', 'th']
False
CacheControlAdapter.build_response
( self, request, response, from_cache=False, cacheable_methods=None )
Build a response by making a request or using the cache. This will end up calling send and returning a potentially cached response
Build a response by making a request or using the cache.
def build_response( self, request, response, from_cache=False, cacheable_methods=None ): """ Build a response by making a request or using the cache. This will end up calling send and returning a potentially cached response """ cacheable = cacheable_methods o...
[ "def", "build_response", "(", "self", ",", "request", ",", "response", ",", "from_cache", "=", "False", ",", "cacheable_methods", "=", "None", ")", ":", "cacheable", "=", "cacheable_methods", "or", "self", ".", "cacheable_methods", "if", "not", "from_cache", "...
[ 56, 4 ]
[ 128, 19 ]
python
en
['en', 'error', 'th']
False
RedfishOptions.__init__
( self, urlbase='redfish/v1', authentication = AuthenticationType.Basic, port = 443, connection_timeout = 20, read_timeout = 30, max_retries = 1, verify_ssl = False, cacheTimeout=180 )
:param authentication: HTTP Authentication type 'Basic', 'Digest' :param port: https Port number for Redfish communication :param connection_timeout: time in seconds to wait for the server to connect before giving up :param read_timeout: time in secon...
:param authentication: HTTP Authentication type 'Basic', 'Digest' :param port: https Port number for Redfish communication :param connection_timeout: time in seconds to wait for the server to connect before giving up :param read_timeout: time in secon...
def __init__( self, urlbase='redfish/v1', authentication = AuthenticationType.Basic, port = 443, connection_timeout = 20, read_timeout = 30, max_retries = 1, verify_ssl = False, cacheTimeout=180 ): """ :param authentication: HTTP Authentica...
[ "def", "__init__", "(", "self", ",", "urlbase", "=", "'redfish/v1'", ",", "authentication", "=", "AuthenticationType", ".", "Basic", ",", "port", "=", "443", ",", "connection_timeout", "=", "20", ",", "read_timeout", "=", "30", ",", "max_retries", "=", "1", ...
[ 47, 4 ]
[ 76, 40 ]
python
en
['en', 'ja', 'th']
False
RedfishProtocolBase.identify
(self)
Identifies the target product Curently _communicate has hardcoded data
Identifies the target product Curently _communicate has hardcoded data
def identify(self): """ Identifies the target product Curently _communicate has hardcoded data """ return None
[ "def", "identify", "(", "self", ")", ":", "return", "None" ]
[ 108, 4 ]
[ 113, 19 ]
python
en
['en', 'ja', 'th']
False
MachineDiscoveryRepository._delete_all_attached
(session: Session, machine: Machine)
Delete all resources attached to a machine As we don't need performance we can avoid heuristics by dropping and re-creating theses needed resources The discovery data is the reference of the reality :param session: a DB session :param machine: :return:
Delete all resources attached to a machine As we don't need performance we can avoid heuristics by dropping and re-creating theses needed resources The discovery data is the reference of the reality :param session: a DB session :param machine: :return:
def _delete_all_attached(session: Session, machine: Machine): """ Delete all resources attached to a machine As we don't need performance we can avoid heuristics by dropping and re-creating theses needed resources The discovery data is the reference of the reality :param session:...
[ "def", "_delete_all_attached", "(", "session", ":", "Session", ",", "machine", ":", "Machine", ")", ":", "session", ".", "query", "(", "MachineDisk", ")", ".", "filter", "(", "MachineDisk", ".", "machine_id", "==", "machine", ".", "id", ")", ".", "delete",...
[ 33, 4 ]
[ 54, 23 ]
python
en
['en', 'error', 'th']
False
MachineDiscoveryRepository.fetch_all_discovery
(self)
Get discovery data of interfaces, disks and the boot-info :return:
Get discovery data of interfaces, disks and the boot-info :return:
def fetch_all_discovery(self): """ Get discovery data of interfaces, disks and the boot-info :return: """ machines = [] with session_commit(sess_maker=self.__sess_maker) as session: for m in session.query(Machine) \ .options(joinedload("int...
[ "def", "fetch_all_discovery", "(", "self", ")", ":", "machines", "=", "[", "]", "with", "session_commit", "(", "sess_maker", "=", "self", ".", "__sess_maker", ")", "as", "session", ":", "for", "m", "in", "session", ".", "query", "(", "Machine", ")", ".",...
[ 131, 4 ]
[ 169, 27 ]
python
en
['en', 'error', 'th']
False
loadImageSeries
(filelist=None)
create a list of :py:class:`~PIL.Image.Image` objects for use in a montage
create a list of :py:class:`~PIL.Image.Image` objects for use in a montage
def loadImageSeries(filelist=None): """create a list of :py:class:`~PIL.Image.Image` objects for use in a montage""" if filelist is None or len(filelist) < 1: return imglist = [] for img in filelist: if not os.path.exists(img): print(f"unable to find {img}") cont...
[ "def", "loadImageSeries", "(", "filelist", "=", "None", ")", ":", "if", "filelist", "is", "None", "or", "len", "(", "filelist", ")", "<", "1", ":", "return", "imglist", "=", "[", "]", "for", "img", "in", "filelist", ":", "if", "not", "os", ".", "pa...
[ 207, 0 ]
[ 226, 18 ]
python
en
['en', 'en', 'en']
True
find
(path, all=False)
Find a static file with the given path using all enabled finders. If ``all`` is ``False`` (default), return the first matching absolute path (or ``None`` if no match). Otherwise return a list.
Find a static file with the given path using all enabled finders.
def find(path, all=False): """ Find a static file with the given path using all enabled finders. If ``all`` is ``False`` (default), return the first matching absolute path (or ``None`` if no match). Otherwise return a list. """ searched_locations[:] = [] matches = [] for finder in get_f...
[ "def", "find", "(", "path", ",", "all", "=", "False", ")", ":", "searched_locations", "[", ":", "]", "=", "[", "]", "matches", "=", "[", "]", "for", "finder", "in", "get_finders", "(", ")", ":", "result", "=", "finder", ".", "find", "(", "path", ...
[ 239, 0 ]
[ 258, 30 ]
python
en
['en', 'error', 'th']
False
get_finder
(import_path)
Imports the staticfiles finder class described by import_path, where import_path is the full Python path to the class.
Imports the staticfiles finder class described by import_path, where import_path is the full Python path to the class.
def get_finder(import_path): """ Imports the staticfiles finder class described by import_path, where import_path is the full Python path to the class. """ Finder = import_string(import_path) if not issubclass(Finder, BaseFinder): raise ImproperlyConfigured('Finder "%s" is not a subclass...
[ "def", "get_finder", "(", "import_path", ")", ":", "Finder", "=", "import_string", "(", "import_path", ")", "if", "not", "issubclass", "(", "Finder", ",", "BaseFinder", ")", ":", "raise", "ImproperlyConfigured", "(", "'Finder \"%s\" is not a subclass of \"%s\"'", "%...
[ 267, 0 ]
[ 276, 19 ]
python
en
['en', 'error', 'th']
False
BaseFinder.find
(self, path, all=False)
Given a relative file path this ought to find an absolute file path. If the ``all`` parameter is ``False`` (default) only the first found file path will be returned; if set to ``True`` a list of all found files paths is returned.
Given a relative file path this ought to find an absolute file path.
def find(self, path, all=False): """ Given a relative file path this ought to find an absolute file path. If the ``all`` parameter is ``False`` (default) only the first found file path will be returned; if set to ``True`` a list of all found files paths is returned. ...
[ "def", "find", "(", "self", ",", "path", ",", "all", "=", "False", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseFinder must provide a find() method'", ")" ]
[ 24, 4 ]
[ 33, 90 ]
python
en
['en', 'error', 'th']
False
BaseFinder.list
(self, ignore_patterns)
Given an optional list of paths to ignore, this should return a two item iterable consisting of the relative path and storage instance.
Given an optional list of paths to ignore, this should return a two item iterable consisting of the relative path and storage instance.
def list(self, ignore_patterns): """ Given an optional list of paths to ignore, this should return a two item iterable consisting of the relative path and storage instance. """ raise NotImplementedError('subclasses of BaseFinder must provide a list() method')
[ "def", "list", "(", "self", ",", "ignore_patterns", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseFinder must provide a list() method'", ")" ]
[ 35, 4 ]
[ 41, 90 ]
python
en
['en', 'error', 'th']
False
FileSystemFinder.find
(self, path, all=False)
Looks for files in the extra locations as defined in ``STATICFILES_DIRS``.
Looks for files in the extra locations as defined in ``STATICFILES_DIRS``.
def find(self, path, all=False): """ Looks for files in the extra locations as defined in ``STATICFILES_DIRS``. """ matches = [] for prefix, root in self.locations: if root not in searched_locations: searched_locations.append(root) ...
[ "def", "find", "(", "self", ",", "path", ",", "all", "=", "False", ")", ":", "matches", "=", "[", "]", "for", "prefix", ",", "root", "in", "self", ".", "locations", ":", "if", "root", "not", "in", "searched_locations", ":", "searched_locations", ".", ...
[ 75, 4 ]
[ 89, 22 ]
python
en
['en', 'error', 'th']
False
FileSystemFinder.find_location
(self, root, path, prefix=None)
Finds a requested static file in a location, returning the found absolute path (or ``None`` if no match).
Finds a requested static file in a location, returning the found absolute path (or ``None`` if no match).
def find_location(self, root, path, prefix=None): """ Finds a requested static file in a location, returning the found absolute path (or ``None`` if no match). """ if prefix: prefix = '%s%s' % (prefix, os.sep) if not path.startswith(prefix): ...
[ "def", "find_location", "(", "self", ",", "root", ",", "path", ",", "prefix", "=", "None", ")", ":", "if", "prefix", ":", "prefix", "=", "'%s%s'", "%", "(", "prefix", ",", "os", ".", "sep", ")", "if", "not", "path", ".", "startswith", "(", "prefix"...
[ 91, 4 ]
[ 103, 23 ]
python
en
['en', 'error', 'th']
False
FileSystemFinder.list
(self, ignore_patterns)
List all files in all locations.
List all files in all locations.
def list(self, ignore_patterns): """ List all files in all locations. """ for prefix, root in self.locations: storage = self.storages[root] for path in utils.get_files(storage, ignore_patterns): yield path, storage
[ "def", "list", "(", "self", ",", "ignore_patterns", ")", ":", "for", "prefix", ",", "root", "in", "self", ".", "locations", ":", "storage", "=", "self", ".", "storages", "[", "root", "]", "for", "path", "in", "utils", ".", "get_files", "(", "storage", ...
[ 105, 4 ]
[ 112, 35 ]
python
en
['en', 'error', 'th']
False
AppDirectoriesFinder.list
(self, ignore_patterns)
List all files in all app storages.
List all files in all app storages.
def list(self, ignore_patterns): """ List all files in all app storages. """ for storage in six.itervalues(self.storages): if storage.exists(''): # check if storage location exists for path in utils.get_files(storage, ignore_patterns): yie...
[ "def", "list", "(", "self", ",", "ignore_patterns", ")", ":", "for", "storage", "in", "six", ".", "itervalues", "(", "self", ".", "storages", ")", ":", "if", "storage", ".", "exists", "(", "''", ")", ":", "# check if storage location exists", "for", "path"...
[ 141, 4 ]
[ 148, 39 ]
python
en
['en', 'error', 'th']
False
AppDirectoriesFinder.find
(self, path, all=False)
Looks for files in the app directories.
Looks for files in the app directories.
def find(self, path, all=False): """ Looks for files in the app directories. """ matches = [] for app in self.apps: app_location = self.storages[app].location if app_location not in searched_locations: searched_locations.append(app_location...
[ "def", "find", "(", "self", ",", "path", ",", "all", "=", "False", ")", ":", "matches", "=", "[", "]", "for", "app", "in", "self", ".", "apps", ":", "app_location", "=", "self", ".", "storages", "[", "app", "]", ".", "location", "if", "app_location...
[ 150, 4 ]
[ 164, 22 ]
python
en
['en', 'error', 'th']
False
AppDirectoriesFinder.find_in_app
(self, app, path)
Find a requested static file in an app's static locations.
Find a requested static file in an app's static locations.
def find_in_app(self, app, path): """ Find a requested static file in an app's static locations. """ storage = self.storages.get(app) if storage: # only try to find a file if the source dir actually exists if storage.exists(path): matched_p...
[ "def", "find_in_app", "(", "self", ",", "app", ",", "path", ")", ":", "storage", "=", "self", ".", "storages", ".", "get", "(", "app", ")", "if", "storage", ":", "# only try to find a file if the source dir actually exists", "if", "storage", ".", "exists", "("...
[ 166, 4 ]
[ 176, 39 ]
python
en
['en', 'error', 'th']
False
BaseStorageFinder.find
(self, path, all=False)
Looks for files in the default file storage, if it's local.
Looks for files in the default file storage, if it's local.
def find(self, path, all=False): """ Looks for files in the default file storage, if it's local. """ try: self.storage.path('') except NotImplementedError: pass else: if self.storage.location not in searched_locations: s...
[ "def", "find", "(", "self", ",", "path", ",", "all", "=", "False", ")", ":", "try", ":", "self", ".", "storage", ".", "path", "(", "''", ")", "except", "NotImplementedError", ":", "pass", "else", ":", "if", "self", ".", "storage", ".", "location", ...
[ 198, 4 ]
[ 214, 17 ]
python
en
['en', 'error', 'th']
False
BaseStorageFinder.list
(self, ignore_patterns)
List all files of the storage.
List all files of the storage.
def list(self, ignore_patterns): """ List all files of the storage. """ for path in utils.get_files(self.storage, ignore_patterns): yield path, self.storage
[ "def", "list", "(", "self", ",", "ignore_patterns", ")", ":", "for", "path", "in", "utils", ".", "get_files", "(", "self", ".", "storage", ",", "ignore_patterns", ")", ":", "yield", "path", ",", "self", ".", "storage" ]
[ 216, 4 ]
[ 221, 36 ]
python
en
['en', 'error', 'th']
False
ChangeList.get_filters_params
(self, params=None)
Returns all params except IGNORED_PARAMS
Returns all params except IGNORED_PARAMS
def get_filters_params(self, params=None): """ Returns all params except IGNORED_PARAMS """ if not params: params = self.params lookup_params = params.copy() # a dictionary of the query string # Remove all the parameters that are globally and systematically ...
[ "def", "get_filters_params", "(", "self", ",", "params", "=", "None", ")", ":", "if", "not", "params", ":", "params", "=", "self", ".", "params", "lookup_params", "=", "params", ".", "copy", "(", ")", "# a dictionary of the query string", "# Remove all the param...
[ 86, 4 ]
[ 98, 28 ]
python
en
['en', 'error', 'th']
False
ChangeList.get_ordering_field
(self, field_name)
Returns the proper model field name corresponding to the given field_name to use for ordering. field_name may either be the name of a proper model field or the name of a method (on the admin or model) or a callable with the 'admin_order_field' attribute. Returns None if no prope...
Returns the proper model field name corresponding to the given field_name to use for ordering. field_name may either be the name of a proper model field or the name of a method (on the admin or model) or a callable with the 'admin_order_field' attribute. Returns None if no prope...
def get_ordering_field(self, field_name): """ Returns the proper model field name corresponding to the given field_name to use for ordering. field_name may either be the name of a proper model field or the name of a method (on the admin or model) or a callable with the 'admin_ord...
[ "def", "get_ordering_field", "(", "self", ",", "field_name", ")", ":", "try", ":", "field", "=", "self", ".", "lookup_opts", ".", "get_field", "(", "field_name", ")", "return", "field", ".", "name", "except", "FieldDoesNotExist", ":", "# See whether field_name i...
[ 214, 4 ]
[ 234, 59 ]
python
en
['en', 'error', 'th']
False
ChangeList.get_ordering
(self, request, queryset)
Returns the list of ordering fields for the change list. First we check the get_ordering() method in model admin, then we check the object's default ordering. Then, any manually-specified ordering from the query string overrides anything. Finally, a deterministic order is guaran...
Returns the list of ordering fields for the change list. First we check the get_ordering() method in model admin, then we check the object's default ordering. Then, any manually-specified ordering from the query string overrides anything. Finally, a deterministic order is guaran...
def get_ordering(self, request, queryset): """ Returns the list of ordering fields for the change list. First we check the get_ordering() method in model admin, then we check the object's default ordering. Then, any manually-specified ordering from the query string overrides anyt...
[ "def", "get_ordering", "(", "self", ",", "request", ",", "queryset", ")", ":", "params", "=", "self", ".", "params", "ordering", "=", "list", "(", "self", ".", "model_admin", ".", "get_ordering", "(", "request", ")", "or", "self", ".", "_get_default_orderi...
[ 236, 4 ]
[ 278, 23 ]
python
en
['en', 'error', 'th']
False
ChangeList.get_ordering_field_columns
(self)
Returns an OrderedDict of ordering field column numbers and asc/desc
Returns an OrderedDict of ordering field column numbers and asc/desc
def get_ordering_field_columns(self): """ Returns an OrderedDict of ordering field column numbers and asc/desc """ # We must cope with more than one column having the same underlying sort # field, so we base things on column numbers. ordering = self._get_default_ordering...
[ "def", "get_ordering_field_columns", "(", "self", ")", ":", "# We must cope with more than one column having the same underlying sort", "# field, so we base things on column numbers.", "ordering", "=", "self", ".", "_get_default_ordering", "(", ")", "ordering_fields", "=", "Ordered...
[ 280, 4 ]
[ 311, 30 ]
python
en
['en', 'error', 'th']
False
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" ]
[ 50, 0 ]
[ 59, 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", "(", ")", ")" ]
[ 985, 0 ]
[ 990, 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...
[ 1136, 0 ]
[ 1143, 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", ")", ",", ...
[ 1146, 0 ]
[ 1153, 5 ]
python
en
['en', 'error', 'th']
False
skipUnlessAnyDBFeature
(*features)
Skip a test unless a database has any of the named features.
Skip a test unless a database has any of the named features.
def skipUnlessAnyDBFeature(*features): """ Skip a test unless a database has any of the named features. """ return _deferredSkip( lambda: not any(getattr(connection.features, feature, False) for feature in features), "Database doesn't support any of the feature(s): %s" % ", ".join(featur...
[ "def", "skipUnlessAnyDBFeature", "(", "*", "features", ")", ":", "return", "_deferredSkip", "(", "lambda", ":", "not", "any", "(", "getattr", "(", "connection", ".", "features", ",", "feature", ",", "False", ")", "for", "feature", "in", "features", ")", ",...
[ 1156, 0 ]
[ 1163, 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__\"", ",", "...
[ 194, 4 ]
[ 218, 22 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase._pre_setup
(self)
Performs any pre-test setup. This includes: * Creating a test client. * 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. * Clearing the mail test outbox. """ self.client = self.client_class() mail.outbox = []
[ "def", "_pre_setup", "(", "self", ")", ":", "self", ".", "client", "=", "self", ".", "client_class", "(", ")", "mail", ".", "outbox", "=", "[", "]" ]
[ 220, 4 ]
[ 227, 24 ]
python
en
['en', 'en', 'en']
True
SimpleTestCase._post_teardown
(self)
Perform any post-test things.
Perform any post-test things.
def _post_teardown(self): """Perform any post-test things.""" pass
[ "def", "_post_teardown", "(", "self", ")", ":", "pass" ]
[ 229, 4 ]
[ 231, 12 ]
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 ]
[ 342, 9 ]
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`` times in the content of t...
[ "def", "assertContains", "(", "self", ",", "response", ",", "text", ",", "count", "=", "None", ",", "status_code", "=", "200", ",", "msg_prefix", "=", "''", ",", "html", "=", "False", ")", ":", "text_repr", ",", "real_count", ",", "msg_prefix", "=", "s...
[ 375, 4 ]
[ 392, 101 ]
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 content of the response. ...
[ "def", "assertNotContains", "(", "self", ",", "response", ",", "text", ",", "status_code", "=", "200", ",", "msg_prefix", "=", "''", ",", "html", "=", "False", ")", ":", "text_repr", ",", "real_count", ",", "msg_prefix", "=", "self", ".", "_assert_contains...
[ 394, 4 ]
[ 403, 98 ]
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", "="...
[ 405, 4 ]
[ 458, 94 ]
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...
[ 460, 4 ]
[ 538, 100 ]
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", ".", ...
[ 564, 4 ]
[ 591, 13 ]
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_temp...
[ "def", "assertTemplateNotUsed", "(", "self", ",", "response", "=", "None", ",", "template_name", "=", "None", ",", "msg_prefix", "=", "''", ")", ":", "context_mgr_template", ",", "template_names", ",", "msg_prefix", "=", "self", ".", "_assert_template_used", "("...
[ 593, 4 ]
[ 608, 9 ]
python
en
['en', 'error', 'th']
False
SimpleTestCase.assertRaisesMessage
(self, expected_exception, expected_message, *args, **kwargs)
Asserts that expected_message is found in the the message of a raised exception. Args: expected_exception: Exception class expected to be raised. expected_message: expected error message string value. args: Function to be called and extra positional args. ...
Asserts that expected_message is found in the the message of a raised exception.
def assertRaisesMessage(self, expected_exception, expected_message, *args, **kwargs): """ Asserts that expected_message is found in the the message of a raised exception. Args: expected_exception: Exception class expected to be raised. expected_message: expected ...
[ "def", "assertRaisesMessage", "(", "self", ",", "expected_exception", ",", "expected_message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# callable_obj was a documented kwarg in Django 1.8 and older.", "callable_obj", "=", "kwargs", ".", "pop", "(", "'call...
[ 616, 4 ]
[ 644, 41 ]
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 dic...
[ "def", "assertFieldOutput", "(", "self", ",", "fieldclass", ",", "valid", ",", "invalid", ",", "field_args", "=", "None", ",", "field_kwargs", "=", "None", ",", "empty_value", "=", "''", ")", ":", "if", "field_args", "is", "None", ":", "field_args", "=", ...
[ 646, 4 ]
[ 690, 86 ]
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...
[ 692, 4 ]
[ 709, 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 is not valid HTML:') ...
[ "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...
[ 711, 4 ]
[ 719, 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...
[ 733, 4 ]
[ 748, 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...
[ 750, 4 ]
[ 765, 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...
[ 767, 4 ]
[ 788, 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...
[ 790, 4 ]
[ 804, 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...
[ 835, 4 ]
[ 865, 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", "(", ")", "if", "self", ".", "_should_reload_connections", "(", ")", ":", ...
[ 916, 4 ]
[ 941, 49 ]
python
en
['en', 'en', 'en']
True
TestCase._enter_atomics
(cls)
Helper method to open atomic blocks for multiple databases
Helper method to open atomic blocks for multiple databases
def _enter_atomics(cls): """Helper method to open atomic blocks for multiple databases""" atomics = {} for db_name in cls._databases_names(): atomics[db_name] = transaction.atomic(using=db_name) atomics[db_name].__enter__() return atomics
[ "def", "_enter_atomics", "(", "cls", ")", ":", "atomics", "=", "{", "}", "for", "db_name", "in", "cls", ".", "_databases_names", "(", ")", ":", "atomics", "[", "db_name", "]", "=", "transaction", ".", "atomic", "(", "using", "=", "db_name", ")", "atomi...
[ 1007, 4 ]
[ 1013, 22 ]
python
en
['en', 'no', 'en']
True
TestCase._rollback_atomics
(cls, atomics)
Rollback atomic blocks opened through the previous method
Rollback atomic blocks opened through the previous method
def _rollback_atomics(cls, atomics): """Rollback atomic blocks opened through the previous method""" for db_name in reversed(cls._databases_names()): transaction.set_rollback(True, using=db_name) atomics[db_name].__exit__(None, None, None)
[ "def", "_rollback_atomics", "(", "cls", ",", "atomics", ")", ":", "for", "db_name", "in", "reversed", "(", "cls", ".", "_databases_names", "(", ")", ")", ":", "transaction", ".", "set_rollback", "(", "True", ",", "using", "=", "db_name", ")", "atomics", ...
[ 1016, 4 ]
[ 1020, 55 ]
python
en
['en', 'en', 'en']
True
TestCase.setUpTestData
(cls)
Load initial data for the TestCase
Load initial data for the TestCase
def setUpTestData(cls): """Load initial data for the TestCase""" pass
[ "def", "setUpTestData", "(", "cls", ")", ":", "pass" ]
[ 1055, 4 ]
[ 1057, 12 ]
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", "]" ]
[ 1187, 4 ]
[ 1194, 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", ")" ]
[ 1196, 4 ]
[ 1201, 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", "(...
[ 1268, 4 ]
[ 1290, 35 ]
python
en
['en', 'error', 'th']
False
ScriptHelpersTest.generate_replay
(self)
Generates replay of an episode.
Generates replay of an episode.
def generate_replay(self): """Generates replay of an episode.""" cfg = config.Config() left_players = 2 cfg.update({ 'action_set': 'full', 'level': 'tests.corner_test', 'dump_full_episodes': True, 'players': ['agent:left_players={}'.format(left_players), ...
[ "def", "generate_replay", "(", "self", ")", ":", "cfg", "=", "config", ".", "Config", "(", ")", "left_players", "=", "2", "cfg", ".", "update", "(", "{", "'action_set'", ":", "'full'", ",", "'level'", ":", "'tests.corner_test'", ",", "'dump_full_episodes'", ...
[ 36, 2 ]
[ 57, 15 ]
python
en
['en', 'en', 'en']
True
ScriptHelpersTest.test__replay
(self)
Has to run first, as it generates dumps for other tests.
Has to run first, as it generates dumps for other tests.
def test__replay(self): """Has to run first, as it generates dumps for other tests.""" dumps_before = self.current_dumps() self.generate_replay() dumps_after = self.current_dumps() dump1 = dumps_after - dumps_before assert len(dump1) == 1, dump1 hash1 = self.compute_hash(list(dump1)[0]) ...
[ "def", "test__replay", "(", "self", ")", ":", "dumps_before", "=", "self", ".", "current_dumps", "(", ")", "self", ".", "generate_replay", "(", ")", "dumps_after", "=", "self", ".", "current_dumps", "(", ")", "dump1", "=", "dumps_after", "-", "dumps_before",...
[ 72, 2 ]
[ 90, 34 ]
python
en
['en', 'en', 'en']
True
SimpleQueueClient.ensure_queue
(self, queue_name: str, callback: Callable[[BlockingChannel], None])
Ensure that a given queue has been declared, and then call the callback with no arguments.
Ensure that a given queue has been declared, and then call the callback with no arguments.
def ensure_queue(self, queue_name: str, callback: Callable[[BlockingChannel], None]) -> None: """Ensure that a given queue has been declared, and then call the callback with no arguments.""" if self.connection is None or not self.connection.is_open: self._connect() assert se...
[ "def", "ensure_queue", "(", "self", ",", "queue_name", ":", "str", ",", "callback", ":", "Callable", "[", "[", "BlockingChannel", "]", ",", "None", "]", ")", "->", "None", ":", "if", "self", ".", "connection", "is", "None", "or", "not", "self", ".", ...
[ 106, 4 ]
[ 116, 30 ]
python
en
['en', 'en', 'en']
True
AffineFlow.get_param_size
(n_dims)
:param n_dims: The dimension of the distribution to be transformed by the flow. :return: (int) The dimension of the parameter space for the flow. Here it's n_dims + n_dims
:param n_dims: The dimension of the distribution to be transformed by the flow. :return: (int) The dimension of the parameter space for the flow. Here it's n_dims + n_dims
def get_param_size(n_dims): """ :param n_dims: The dimension of the distribution to be transformed by the flow. :return: (int) The dimension of the parameter space for the flow. Here it's n_dims + n_dims """ return 2 * n_dims
[ "def", "get_param_size", "(", "n_dims", ")", ":", "return", "2", "*", "n_dims" ]
[ 27, 4 ]
[ 32, 25 ]
python
en
['en', 'error', 'th']
False
AffineFlow._forward
(self, x)
Forward pass through the bijector. a*x + b
Forward pass through the bijector. a*x + b
def _forward(self, x): """ Forward pass through the bijector. a*x + b """ return tf.exp(self._a) * x + self._b
[ "def", "_forward", "(", "self", ",", "x", ")", ":", "return", "tf", ".", "exp", "(", "self", ".", "_a", ")", "*", "x", "+", "self", ".", "_b" ]
[ 34, 4 ]
[ 38, 44 ]
python
en
['en', 'error', 'th']
False
AffineFlow._inverse
(self, y)
Backward pass through the bijector. (y-b) / a
Backward pass through the bijector. (y-b) / a
def _inverse(self, y): """ Backward pass through the bijector. (y-b) / a """ return (y - self._b) * tf.exp(-self._a)
[ "def", "_inverse", "(", "self", ",", "y", ")", ":", "return", "(", "y", "-", "self", ".", "_b", ")", "*", "tf", ".", "exp", "(", "-", "self", ".", "_a", ")" ]
[ 40, 4 ]
[ 44, 47 ]
python
en
['en', 'error', 'th']
False
implicit_namespace_packages
( directory: str, ignored_dirnames: Optional[List[str]] = None )
Discovers namespace packages implemented using the 'native namespace packages' method. AKA 'implicit namespace packages', which has been supported since Python 3.3. See: https://packaging.python.org/guides/packaging-namespace-packages/#native-namespace-packages Args: directory: The root directory ...
Discovers namespace packages implemented using the 'native namespace packages' method.
def implicit_namespace_packages( directory: str, ignored_dirnames: Optional[List[str]] = None ) -> Set[str]: """Discovers namespace packages implemented using the 'native namespace packages' method. AKA 'implicit namespace packages', which has been supported since Python 3.3. See: https://packaging.pyt...
[ "def", "implicit_namespace_packages", "(", "directory", ":", "str", ",", "ignored_dirnames", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ")", "->", "Set", "[", "str", "]", ":", "namespace_pkg_dirs", "=", "set", "(", ")", "for", "dirp...
[ 8, 0 ]
[ 43, 29 ]
python
en
['en', 'en', 'en']
True
add_pkgutil_style_namespace_pkg_init
(dir_path: str)
Adds 'pkgutil-style namespace packages' init file to the given directory See: https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages Args: dir_path: The directory to create an __init__.py for. Raises: ValueError: If the directory already contain...
Adds 'pkgutil-style namespace packages' init file to the given directory
def add_pkgutil_style_namespace_pkg_init(dir_path: str) -> None: """Adds 'pkgutil-style namespace packages' init file to the given directory See: https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages Args: dir_path: The directory to create an __init__.p...
[ "def", "add_pkgutil_style_namespace_pkg_init", "(", "dir_path", ":", "str", ")", "->", "None", ":", "ns_pkg_init_filepath", "=", "os", ".", "path", ".", "join", "(", "dir_path", ",", "\"__init__.py\"", ")", "if", "os", ".", "path", ".", "isfile", "(", "ns_pk...
[ 46, 0 ]
[ 71, 9 ]
python
en
['en', 'en', 'en']
True
register_uuid
(oids=None, conn_or_curs=None)
Create the UUID type and an uuid.UUID adapter. :param oids: oid for the PostgreSQL :sql:`uuid` type, or 2-items sequence with oids of the type and the array. If not specified, use PostgreSQL standard oids. :param conn_or_curs: where to register the typecaster. If not specified, register...
Create the UUID type and an uuid.UUID adapter.
def register_uuid(oids=None, conn_or_curs=None): """Create the UUID type and an uuid.UUID adapter. :param oids: oid for the PostgreSQL :sql:`uuid` type, or 2-items sequence with oids of the type and the array. If not specified, use PostgreSQL standard oids. :param conn_or_curs: where to reg...
[ "def", "register_uuid", "(", "oids", "=", "None", ",", "conn_or_curs", "=", "None", ")", ":", "import", "uuid", "if", "not", "oids", ":", "oid1", "=", "2950", "oid2", "=", "2951", "elif", "isinstance", "(", "oids", ",", "(", "list", ",", "tuple", ")"...
[ 642, 0 ]
[ 671, 20 ]
python
en
['en', 'tg', 'en']
True
register_inet
(oid=None, conn_or_curs=None)
Create the INET type and an Inet adapter. :param oid: oid for the PostgreSQL :sql:`inet` type, or 2-items sequence with oids of the type and the array. If not specified, use PostgreSQL standard oids. :param conn_or_curs: where to register the typecaster. If not specified, register it gl...
Create the INET type and an Inet adapter.
def register_inet(oid=None, conn_or_curs=None): """Create the INET type and an Inet adapter. :param oid: oid for the PostgreSQL :sql:`inet` type, or 2-items sequence with oids of the type and the array. If not specified, use PostgreSQL standard oids. :param conn_or_curs: where to register t...
[ "def", "register_inet", "(", "oid", "=", "None", ",", "conn_or_curs", "=", "None", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"the inet adapter is deprecated, it's not very useful\"", ",", "DeprecationWarning", ")", "if", "not", "oid", ":", "o...
[ 707, 0 ]
[ 737, 20 ]
python
en
['en', 'en', 'en']
True
register_tstz_w_secs
(oids=None, conn_or_curs=None)
The function used to register an alternate type caster for :sql:`TIMESTAMP WITH TIME ZONE` to deal with historical time zones with seconds in the UTC offset. These are now correctly handled by the default type caster, so currently the function doesn't do anything.
The function used to register an alternate type caster for :sql:`TIMESTAMP WITH TIME ZONE` to deal with historical time zones with seconds in the UTC offset.
def register_tstz_w_secs(oids=None, conn_or_curs=None): """The function used to register an alternate type caster for :sql:`TIMESTAMP WITH TIME ZONE` to deal with historical time zones with seconds in the UTC offset. These are now correctly handled by the default type caster, so currently the funct...
[ "def", "register_tstz_w_secs", "(", "oids", "=", "None", ",", "conn_or_curs", "=", "None", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"deprecated\"", ",", "DeprecationWarning", ")" ]
[ 740, 0 ]
[ 749, 51 ]
python
en
['en', 'en', 'en']
True
wait_select
(conn)
Wait until a connection or cursor has data available. The function is an example of a wait callback to be registered with `~psycopg2.extensions.set_wait_callback()`. This function uses :py:func:`~select.select()` to wait for data available.
Wait until a connection or cursor has data available.
def wait_select(conn): """Wait until a connection or cursor has data available. The function is an example of a wait callback to be registered with `~psycopg2.extensions.set_wait_callback()`. This function uses :py:func:`~select.select()` to wait for data available. """ import select from ...
[ "def", "wait_select", "(", "conn", ")", ":", "import", "select", "from", "psycopg2", ".", "extensions", "import", "POLL_OK", ",", "POLL_READ", ",", "POLL_WRITE", "while", "1", ":", "try", ":", "state", "=", "conn", ".", "poll", "(", ")", "if", "state", ...
[ 752, 0 ]
[ 777, 20 ]
python
en
['en', 'en', 'en']
True
_solve_conn_curs
(conn_or_curs)
Return the connection and a DBAPI cursor from a connection or cursor.
Return the connection and a DBAPI cursor from a connection or cursor.
def _solve_conn_curs(conn_or_curs): """Return the connection and a DBAPI cursor from a connection or cursor.""" if conn_or_curs is None: raise psycopg2.ProgrammingError("no connection or cursor provided") if hasattr(conn_or_curs, 'execute'): conn = conn_or_curs.connection curs = con...
[ "def", "_solve_conn_curs", "(", "conn_or_curs", ")", ":", "if", "conn_or_curs", "is", "None", ":", "raise", "psycopg2", ".", "ProgrammingError", "(", "\"no connection or cursor provided\"", ")", "if", "hasattr", "(", "conn_or_curs", ",", "'execute'", ")", ":", "co...
[ 780, 0 ]
[ 792, 21 ]
python
en
['en', 'en', 'en']
True
register_hstore
(conn_or_curs, globally=False, str=False, oid=None, array_oid=None)
r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions. :param conn_or_curs: a connection or cursor: the typecaster will be registered only on this object unless *globally* is set to `!True` :param globally: register the adapter globally, not only on *conn_or_curs* :param unicode: ...
r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions.
def register_hstore(conn_or_curs, globally=False, str=False, oid=None, array_oid=None): r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions. :param conn_or_curs: a connection or cursor: the typecaster will be registered only on this object unless *globally* is se...
[ "def", "register_hstore", "(", "conn_or_curs", ",", "globally", "=", "False", ",", "str", "=", "False", ",", "oid", "=", "None", ",", "array_oid", "=", "None", ")", ":", "if", "oid", "is", "None", ":", "oid", "=", "HstoreAdapter", ".", "get_oids", "(",...
[ 932, 0 ]
[ 994, 78 ]
python
en
['en', 'en', 'en']
True
register_composite
(name, conn_or_curs, globally=False, factory=None)
Register a typecaster to convert a composite type into a tuple. :param name: the name of a PostgreSQL composite type, e.g. created using the |CREATE TYPE|_ command :param conn_or_curs: a connection or cursor used to find the type oid and components; the typecaster is registered in a scope limit...
Register a typecaster to convert a composite type into a tuple.
def register_composite(name, conn_or_curs, globally=False, factory=None): """Register a typecaster to convert a composite type into a tuple. :param name: the name of a PostgreSQL composite type, e.g. created using the |CREATE TYPE|_ command :param conn_or_curs: a connection or cursor used to find t...
[ "def", "register_composite", "(", "name", ",", "conn_or_curs", ",", "globally", "=", "False", ",", "factory", "=", "None", ")", ":", "if", "factory", "is", "None", ":", "factory", "=", "CompositeCaster", "caster", "=", "factory", ".", "_from_db", "(", "nam...
[ 1133, 0 ]
[ 1158, 17 ]
python
en
['en', 'en', 'en']
True
_paginate
(seq, page_size)
Consume an iterable and return it in chunks. Every chunk is at most `page_size`. Never return an empty chunk.
Consume an iterable and return it in chunks.
def _paginate(seq, page_size): """Consume an iterable and return it in chunks. Every chunk is at most `page_size`. Never return an empty chunk. """ page = [] it = iter(seq) while 1: try: for i in range(page_size): page.append(next(it)) yield page ...
[ "def", "_paginate", "(", "seq", ",", "page_size", ")", ":", "page", "=", "[", "]", "it", "=", "iter", "(", "seq", ")", "while", "1", ":", "try", ":", "for", "i", "in", "range", "(", "page_size", ")", ":", "page", ".", "append", "(", "next", "("...
[ 1161, 0 ]
[ 1177, 18 ]
python
en
['en', 'en', 'en']
True
execute_batch
(cur, sql, argslist, page_size=100)
r"""Execute groups of statements in fewer server roundtrips. Execute *sql* several times, against all parameters set (sequences or mappings) found in *argslist*. The function is semantically similar to .. parsed-literal:: *cur*\.\ `~cursor.executemany`\ (\ *sql*\ , *argslist*\ ) but has...
r"""Execute groups of statements in fewer server roundtrips.
def execute_batch(cur, sql, argslist, page_size=100): r"""Execute groups of statements in fewer server roundtrips. Execute *sql* several times, against all parameters set (sequences or mappings) found in *argslist*. The function is semantically similar to .. parsed-literal:: *cur*\.\ `~c...
[ "def", "execute_batch", "(", "cur", ",", "sql", ",", "argslist", ",", "page_size", "=", "100", ")", ":", "for", "page", "in", "_paginate", "(", "argslist", ",", "page_size", "=", "page_size", ")", ":", "sqls", "=", "[", "cur", ".", "mogrify", "(", "s...
[ 1180, 0 ]
[ 1202, 36 ]
python
en
['en', 'en', 'en']
True
execute_values
(cur, sql, argslist, template=None, page_size=100)
Execute a statement using :sql:`VALUES` with a sequence of parameters. :param cur: the cursor to use to execute the query. :param sql: the query to execute. It must contain a single ``%s`` placeholder, which will be replaced by a `VALUES list`__. Example: ``"INSERT INTO mytable (id, f1, f2) VA...
Execute a statement using :sql:`VALUES` with a sequence of parameters.
def execute_values(cur, sql, argslist, template=None, page_size=100): '''Execute a statement using :sql:`VALUES` with a sequence of parameters. :param cur: the cursor to use to execute the query. :param sql: the query to execute. It must contain a single ``%s`` placeholder, which will be replaced ...
[ "def", "execute_values", "(", "cur", ",", "sql", ",", "argslist", ",", "template", "=", "None", ",", "page_size", "=", "100", ")", ":", "# we can't just use sql % vals because vals is bytes: if sql is bytes", "# there will be some decoding error because of stupid codec used, an...
[ 1205, 0 ]
[ 1276, 36 ]
python
en
['en', 'en', 'en']
True
_split_sql
(sql)
Split *sql* on a single ``%s`` placeholder. Split on the %s, perform %% replacement and return pre, post lists of snippets.
Split *sql* on a single ``%s`` placeholder.
def _split_sql(sql): """Split *sql* on a single ``%s`` placeholder. Split on the %s, perform %% replacement and return pre, post lists of snippets. """ curr = pre = [] post = [] tokens = _re.split(br'(%.)', sql) for token in tokens: if len(token) != 2 or token[:1] != b'%': ...
[ "def", "_split_sql", "(", "sql", ")", ":", "curr", "=", "pre", "=", "[", "]", "post", "=", "[", "]", "tokens", "=", "_re", ".", "split", "(", "br'(%.)'", ",", "sql", ")", "for", "token", "in", "tokens", ":", "if", "len", "(", "token", ")", "!="...
[ 1279, 0 ]
[ 1308, 20 ]
python
en
['en', 'da', 'en']
True
LoggingConnection.initialize
(self, logobj)
Initialize the connection to log to `!logobj`. The `!logobj` parameter can be an open file object or a Logger instance from the standard logging module.
Initialize the connection to log to `!logobj`.
def initialize(self, logobj): """Initialize the connection to log to `!logobj`. The `!logobj` parameter can be an open file object or a Logger instance from the standard logging module. """ self._logobj = logobj if _logging and isinstance(logobj, _logging.Logger): ...
[ "def", "initialize", "(", "self", ",", "logobj", ")", ":", "self", ".", "_logobj", "=", "logobj", "if", "_logging", "and", "isinstance", "(", "logobj", ",", "_logging", ".", "Logger", ")", ":", "self", ".", "log", "=", "self", ".", "_logtologger", "els...
[ 393, 4 ]
[ 403, 38 ]
python
en
['en', 'en', 'en']
True
LoggingConnection.filter
(self, msg, curs)
Filter the query before logging it. This is the method to overwrite to filter unwanted queries out of the log or to add some extra data to the output. The default implementation just does nothing.
Filter the query before logging it.
def filter(self, msg, curs): """Filter the query before logging it. This is the method to overwrite to filter unwanted queries out of the log or to add some extra data to the output. The default implementation just does nothing. """ return msg
[ "def", "filter", "(", "self", ",", "msg", ",", "curs", ")", ":", "return", "msg" ]
[ 405, 4 ]
[ 412, 18 ]
python
en
['en', 'en', 'en']
True
ReplicationCursor.create_replication_slot
(self, slot_name, slot_type=None, output_plugin=None)
Create streaming replication slot.
Create streaming replication slot.
def create_replication_slot(self, slot_name, slot_type=None, output_plugin=None): """Create streaming replication slot.""" command = "CREATE_REPLICATION_SLOT %s " % quote_ident(slot_name, self) if slot_type is None: slot_type = self.connection.replication_type if slot_type...
[ "def", "create_replication_slot", "(", "self", ",", "slot_name", ",", "slot_type", "=", "None", ",", "output_plugin", "=", "None", ")", ":", "command", "=", "\"CREATE_REPLICATION_SLOT %s \"", "%", "quote_ident", "(", "slot_name", ",", "self", ")", "if", "slot_ty...
[ 521, 4 ]
[ 549, 29 ]
python
en
['en', 'en', 'en']
True
ReplicationCursor.drop_replication_slot
(self, slot_name)
Drop streaming replication slot.
Drop streaming replication slot.
def drop_replication_slot(self, slot_name): """Drop streaming replication slot.""" command = "DROP_REPLICATION_SLOT %s" % quote_ident(slot_name, self) self.execute(command)
[ "def", "drop_replication_slot", "(", "self", ",", "slot_name", ")", ":", "command", "=", "\"DROP_REPLICATION_SLOT %s\"", "%", "quote_ident", "(", "slot_name", ",", "self", ")", "self", ".", "execute", "(", "command", ")" ]
[ 551, 4 ]
[ 555, 29 ]
python
en
['en', 'fil', 'en']
True
ReplicationCursor.start_replication
(self, slot_name=None, slot_type=None, start_lsn=0, timeline=0, options=None, decode=False)
Start replication stream.
Start replication stream.
def start_replication(self, slot_name=None, slot_type=None, start_lsn=0, timeline=0, options=None, decode=False): """Start replication stream.""" command = "START_REPLICATION " if slot_type is None: slot_type = self.connection.replication_type if ...
[ "def", "start_replication", "(", "self", ",", "slot_name", "=", "None", ",", "slot_type", "=", "None", ",", "start_lsn", "=", "0", ",", "timeline", "=", "0", ",", "options", "=", "None", ",", "decode", "=", "False", ")", ":", "command", "=", "\"START_R...
[ 557, 4 ]
[ 612, 61 ]
python
en
['en', 'sn', 'en']
True
HstoreAdapter._getquoted_8
(self)
Use the operators available in PG pre-9.0.
Use the operators available in PG pre-9.0.
def _getquoted_8(self): """Use the operators available in PG pre-9.0.""" if not self.wrapped: return b"''::hstore" adapt = _ext.adapt rv = [] for k, v in self.wrapped.items(): k = adapt(k) k.prepare(self.conn) k = k.getquoted() ...
[ "def", "_getquoted_8", "(", "self", ")", ":", "if", "not", "self", ".", "wrapped", ":", "return", "b\"''::hstore\"", "adapt", "=", "_ext", ".", "adapt", "rv", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "wrapped", ".", "items", "(", ")"...
[ 807, 4 ]
[ 829, 43 ]
python
en
['en', 'en', 'en']
True
HstoreAdapter._getquoted_9
(self)
Use the hstore(text[], text[]) function.
Use the hstore(text[], text[]) function.
def _getquoted_9(self): """Use the hstore(text[], text[]) function.""" if not self.wrapped: return b"''::hstore" k = _ext.adapt(list(self.wrapped.keys())) k.prepare(self.conn) v = _ext.adapt(list(self.wrapped.values())) v.prepare(self.conn) return b"h...
[ "def", "_getquoted_9", "(", "self", ")", ":", "if", "not", "self", ".", "wrapped", ":", "return", "b\"''::hstore\"", "k", "=", "_ext", ".", "adapt", "(", "list", "(", "self", ".", "wrapped", ".", "keys", "(", ")", ")", ")", "k", ".", "prepare", "("...
[ 831, 4 ]
[ 840, 72 ]
python
en
['en', 'en', 'en']
True
HstoreAdapter.parse
(self, s, cur, _bsdec=_re.compile(r"\\(.)"))
Parse an hstore representation in a Python string. The hstore is represented as something like:: "a"=>"1", "b"=>"2" with backslash-escaped strings.
Parse an hstore representation in a Python string.
def parse(self, s, cur, _bsdec=_re.compile(r"\\(.)")): """Parse an hstore representation in a Python string. The hstore is represented as something like:: "a"=>"1", "b"=>"2" with backslash-escaped strings. """ if s is None: return None rv = {} ...
[ "def", "parse", "(", "self", ",", "s", ",", "cur", ",", "_bsdec", "=", "_re", ".", "compile", "(", "r\"\\\\(.)\"", ")", ")", ":", "if", "s", "is", "None", ":", "return", "None", "rv", "=", "{", "}", "start", "=", "0", "for", "m", "in", "self", ...
[ 858, 4 ]
[ 888, 17 ]
python
en
['en', 'en', 'en']
True
HstoreAdapter.parse_unicode
(self, s, cur)
Parse an hstore returning unicode keys and values.
Parse an hstore returning unicode keys and values.
def parse_unicode(self, s, cur): """Parse an hstore returning unicode keys and values.""" if s is None: return None s = s.decode(_ext.encodings[cur.connection.encoding]) return self.parse(s, cur)
[ "def", "parse_unicode", "(", "self", ",", "s", ",", "cur", ")", ":", "if", "s", "is", "None", ":", "return", "None", "s", "=", "s", ".", "decode", "(", "_ext", ".", "encodings", "[", "cur", ".", "connection", ".", "encoding", "]", ")", "return", ...
[ 891, 4 ]
[ 897, 33 ]
python
en
['en', 'en', 'en']
True
HstoreAdapter.get_oids
(self, conn_or_curs)
Return the lists of OID of the hstore and hstore[] types.
Return the lists of OID of the hstore and hstore[] types.
def get_oids(self, conn_or_curs): """Return the lists of OID of the hstore and hstore[] types. """ conn, curs = _solve_conn_curs(conn_or_curs) # Store the transaction status of the connection to revert it after use conn_status = conn.status # column typarray not availab...
[ "def", "get_oids", "(", "self", ",", "conn_or_curs", ")", ":", "conn", ",", "curs", "=", "_solve_conn_curs", "(", "conn_or_curs", ")", "# Store the transaction status of the connection to revert it after use", "conn_status", "=", "conn", ".", "status", "# column typarray ...
[ 900, 4 ]
[ 929, 37 ]
python
en
['en', 'en', 'en']
True
CompositeCaster.make
(self, values)
Return a new Python object representing the data being casted. *values* is the list of attributes, already casted into their Python representation. You can subclass this method to :ref:`customize the composite cast <custom-composite>`.
Return a new Python object representing the data being casted.
def make(self, values): """Return a new Python object representing the data being casted. *values* is the list of attributes, already casted into their Python representation. You can subclass this method to :ref:`customize the composite cast <custom-composite>`. """ ...
[ "def", "make", "(", "self", ",", "values", ")", ":", "return", "self", ".", "_ctor", "(", "values", ")" ]
[ 1037, 4 ]
[ 1047, 33 ]
python
en
['en', 'en', 'en']
True
CompositeCaster._from_db
(self, name, conn_or_curs)
Return a `CompositeCaster` instance for the type *name*. Raise `ProgrammingError` if the type is not found.
Return a `CompositeCaster` instance for the type *name*.
def _from_db(self, name, conn_or_curs): """Return a `CompositeCaster` instance for the type *name*. Raise `ProgrammingError` if the type is not found. """ conn, curs = _solve_conn_curs(conn_or_curs) # Store the transaction status of the connection to revert it after use ...
[ "def", "_from_db", "(", "self", ",", "name", ",", "conn_or_curs", ")", ":", "conn", ",", "curs", "=", "_solve_conn_curs", "(", "conn_or_curs", ")", "# Store the transaction status of the connection to revert it after use", "conn_status", "=", "conn", ".", "status", "#...
[ 1083, 4 ]
[ 1130, 47 ]
python
en
['en', 'en', 'en']
True
A2GradUni.step
(self, closure: OptLossClosure = None)
r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
r"""Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for group...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_gr...
[ 57, 4 ]
[ 107, 19 ]
python
en
['en', 'en', 'en']
True
A2GradInc.step
(self, closure: OptLossClosure = None)
r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
r"""Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for group...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_gr...
[ 151, 4 ]
[ 202, 19 ]
python
en
['en', 'en', 'en']
True
A2GradExp.step
(self, closure: OptLossClosure = None)
r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
r"""Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for group...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_gr...
[ 251, 4 ]
[ 310, 19 ]
python
en
['en', 'en', 'en']
True
get_internal_wsgi_application
()
Loads and returns the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``. This function, and the ``WSGI_APPLICATION`` setting itself, are only useful for Django's ...
Loads and returns the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``.
def get_internal_wsgi_application(): """ Loads and returns the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``. This function, and the ``WSGI_APPLICATION`` setti...
[ "def", "get_internal_wsgi_application", "(", ")", ":", "from", "django", ".", "conf", "import", "settings", "app_path", "=", "getattr", "(", "settings", ",", "'WSGI_APPLICATION'", ")", "if", "app_path", "is", "None", ":", "return", "get_wsgi_application", "(", "...
[ 27, 0 ]
[ 56, 38 ]
python
en
['en', 'error', 'th']
False
WSGIRequestHandler.handle
(self)
Copy of WSGIRequestHandler, but with different ServerHandler
Copy of WSGIRequestHandler, but with different ServerHandler
def handle(self): """Copy of WSGIRequestHandler, but with different ServerHandler""" self.raw_requestline = self.rfile.readline(65537) if len(self.raw_requestline) > 65536: self.requestline = '' self.request_version = '' self.command = '' self.sen...
[ "def", "handle", "(", "self", ")", ":", "self", ".", "raw_requestline", "=", "self", ".", "rfile", ".", "readline", "(", "65537", ")", "if", "len", "(", "self", ".", "raw_requestline", ")", ">", "65536", ":", "self", ".", "requestline", "=", "''", "s...
[ 136, 4 ]
[ 154, 42 ]
python
en
['en', 'en', 'en']
True
SelectionPreferences.__init__
( self, allow_yanked, # type: bool allow_all_prereleases=False, # type: bool format_control=None, # type: Optional[FormatControl] prefer_binary=False, # type: bool ignore_requires_python=None, # type: Optional[bool] )
Create a SelectionPreferences object. :param allow_yanked: Whether files marked as yanked (in the sense of PEP 592) are permitted to be candidates for install. :param format_control: A FormatControl object or None. Used to control the selection of source packages / binary packag...
Create a SelectionPreferences object.
def __init__( self, allow_yanked, # type: bool allow_all_prereleases=False, # type: bool format_control=None, # type: Optional[FormatControl] prefer_binary=False, # type: bool ignore_requires_python=None, # type: Optional[bool] ): # type: ...
[ "def", "__init__", "(", "self", ",", "allow_yanked", ",", "# type: bool", "allow_all_prereleases", "=", "False", ",", "# type: bool", "format_control", "=", "None", ",", "# type: Optional[FormatControl]", "prefer_binary", "=", "False", ",", "# type: bool", "ignore_requi...
[ 21, 4 ]
[ 49, 60 ]
python
en
['en', 'en', 'en']
True
netstorge_async
(rpc_port: int, delta_block_height: str, start: str)
Calculates the estimated space on the network given two block header hashes.
Calculates the estimated space on the network given two block header hashes.
async def netstorge_async(rpc_port: int, delta_block_height: str, start: str) -> None: """ Calculates the estimated space on the network given two block header hashes. """ try: config = load_config(DEFAULT_ROOT_PATH, "config.yaml") self_hostname = config["self_hostname"] if rpc_p...
[ "async", "def", "netstorge_async", "(", "rpc_port", ":", "int", ",", "delta_block_height", ":", "str", ",", "start", ":", "str", ")", "->", "None", ":", "try", ":", "config", "=", "load_config", "(", "DEFAULT_ROOT_PATH", ",", "\"config.yaml\"", ")", "self_ho...
[ 9, 0 ]
[ 79, 31 ]
python
en
['en', 'error', 'th']
False
test_dependency_graph_single_page
()
confirms that `dependency_graph(Base)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any)
confirms that `dependency_graph(Base)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any)
def test_dependency_graph_single_page(): """confirms that `dependency_graph(Base)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) """ desired = {} desired[G] = set([D]) desired[D] = set([A]) desired[A] = set() assert has_create.de...
[ "def", "test_dependency_graph_single_page", "(", ")", ":", "desired", "=", "{", "}", "desired", "[", "G", "]", "=", "set", "(", "[", "D", "]", ")", "desired", "[", "D", "]", "=", "set", "(", "[", "A", "]", ")", "desired", "[", "A", "]", "=", "s...
[ 107, 0 ]
[ 115, 52 ]
python
en
['en', 'en', 'en']
True
test_dependency_graph_page_with_optional
()
confirms that `dependency_graph(Base, OptionalBase)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) with the exception that the OptionalBase and its dependencies are included as well.
confirms that `dependency_graph(Base, OptionalBase)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) with the exception that the OptionalBase and its dependencies are included as well.
def test_dependency_graph_page_with_optional(): """confirms that `dependency_graph(Base, OptionalBase)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) with the exception that the OptionalBase and its dependencies are included as well. """ des...
[ "def", "test_dependency_graph_page_with_optional", "(", ")", ":", "desired", "=", "{", "}", "desired", "[", "G", "]", "=", "set", "(", "[", "D", "]", ")", "desired", "[", "E", "]", "=", "set", "(", "[", "D", ",", "C", "]", ")", "desired", "[", "C...
[ 118, 0 ]
[ 130, 55 ]
python
en
['en', 'en', 'en']
True
test_dependency_graph_page_with_additionals
()
confirms that `dependency_graph(Base, AdditionalBaseOne, AdditionalBaseTwo)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) with the exception that the AdditionalBases are treated as a dependencies of Base (when they aren't) and their dependencies ...
confirms that `dependency_graph(Base, AdditionalBaseOne, AdditionalBaseTwo)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) with the exception that the AdditionalBases are treated as a dependencies of Base (when they aren't) and their dependencies ...
def test_dependency_graph_page_with_additionals(): """confirms that `dependency_graph(Base, AdditionalBaseOne, AdditionalBaseTwo)` will return a dependency graph consisting of only dependencies and dependencies of dependencies (if any) with the exception that the AdditionalBases are treated as a depende...
[ "def", "test_dependency_graph_page_with_additionals", "(", ")", ":", "desired", "=", "{", "}", "desired", "[", "E", "]", "=", "set", "(", "[", "D", ",", "C", "]", ")", "desired", "[", "D", "]", "=", "set", "(", "[", "A", "]", ")", "desired", "[", ...
[ 133, 0 ]
[ 148, 58 ]
python
en
['en', 'en', 'en']
True