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
IndexView.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", ".", "get_default_ordering", "(", "request", ")", ")", "if", "self", ".", "ORDER_VAR", "in", "param...
[ 463, 4 ]
[ 505, 23 ]
python
en
['en', 'error', 'th']
False
IndexView.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...
[ 507, 4 ]
[ 538, 30 ]
python
en
['en', 'error', 'th']
False
InspectView.get_field_label
(self, field_name, field=None)
Return a label to display for a field
Return a label to display for a field
def get_field_label(self, field_name, field=None): """ Return a label to display for a field """ return label_for_field(field_name, model=self.model)
[ "def", "get_field_label", "(", "self", ",", "field_name", ",", "field", "=", "None", ")", ":", "return", "label_for_field", "(", "field_name", ",", "model", "=", "self", ".", "model", ")" ]
[ 839, 4 ]
[ 841, 60 ]
python
en
['en', 'en', 'en']
True
InspectView.get_field_display_value
(self, field_name, field=None)
Return a display value for a field/attribute
Return a display value for a field/attribute
def get_field_display_value(self, field_name, field=None): """ Return a display value for a field/attribute """ # First we check for a 'get_fieldname_display' property/method on # the model, and return the value of that, if present. val_funct = getattr(self.instance, 'get_%s_display' % ...
[ "def", "get_field_display_value", "(", "self", ",", "field_name", ",", "field", "=", "None", ")", ":", "# First we check for a 'get_fieldname_display' property/method on", "# the model, and return the value of that, if present.", "val_funct", "=", "getattr", "(", "self", ".", ...
[ 843, 4 ]
[ 887, 67 ]
python
en
['en', 'en', 'en']
True
InspectView.get_image_field_display
(self, field_name, field)
Render an image
Render an image
def get_image_field_display(self, field_name, field): """ Render an image """ from wagtail.images.shortcuts import get_rendition_or_not_found image = getattr(self.instance, field_name) if image: return get_rendition_or_not_found(image, 'max-400x400').img_tag return se...
[ "def", "get_image_field_display", "(", "self", ",", "field_name", ",", "field", ")", ":", "from", "wagtail", ".", "images", ".", "shortcuts", "import", "get_rendition_or_not_found", "image", "=", "getattr", "(", "self", ".", "instance", ",", "field_name", ")", ...
[ 889, 4 ]
[ 895, 67 ]
python
en
['en', 'en', 'en']
True
InspectView.get_document_field_display
(self, field_name, field)
Render a link to a document
Render a link to a document
def get_document_field_display(self, field_name, field): """ Render a link to a document """ document = getattr(self.instance, field_name) if document: return mark_safe( '<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % ( document.url, ...
[ "def", "get_document_field_display", "(", "self", ",", "field_name", ",", "field", ")", ":", "document", "=", "getattr", "(", "self", ".", "instance", ",", "field_name", ")", "if", "document", ":", "return", "mark_safe", "(", "'<a href=\"%s\">%s <span class=\"meta...
[ 897, 4 ]
[ 909, 67 ]
python
en
['en', 'en', 'en']
True
InspectView.get_dict_for_field
(self, field_name)
Return a dictionary containing `label` and `value` values to display for a field.
Return a dictionary containing `label` and `value` values to display for a field.
def get_dict_for_field(self, field_name): """ Return a dictionary containing `label` and `value` values to display for a field. """ try: field = self.model._meta.get_field(field_name) except FieldDoesNotExist: field = None return { ...
[ "def", "get_dict_for_field", "(", "self", ",", "field_name", ")", ":", "try", ":", "field", "=", "self", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "field", "=", "None", "return", "{", "'label'...
[ 911, 4 ]
[ 923, 9 ]
python
en
['en', 'error', 'th']
False
InspectView.get_fields_dict
(self)
Return a list of `label`/`value` dictionaries to represent the fields named by the model_admin class's `get_inspect_view_fields` method
Return a list of `label`/`value` dictionaries to represent the fields named by the model_admin class's `get_inspect_view_fields` method
def get_fields_dict(self): """ Return a list of `label`/`value` dictionaries to represent the fields named by the model_admin class's `get_inspect_view_fields` method """ fields = [] for field_name in self.model_admin.get_inspect_view_fields(): fields.append(s...
[ "def", "get_fields_dict", "(", "self", ")", ":", "fields", "=", "[", "]", "for", "field_name", "in", "self", ".", "model_admin", ".", "get_inspect_view_fields", "(", ")", ":", "fields", ".", "append", "(", "self", ".", "get_dict_for_field", "(", "field_name"...
[ 925, 4 ]
[ 933, 21 ]
python
en
['en', 'error', 'th']
False
parse_bdist_wininst
(name)
Return (base,pyversion) or (None,None) for possible .exe name
Return (base,pyversion) or (None,None) for possible .exe name
def parse_bdist_wininst(name): """Return (base,pyversion) or (None,None) for possible .exe name""" lower = name.lower() base, py_ver, plat = None, None, None if lower.endswith('.exe'): if lower.endswith('.win32.exe'): base = name[:-10] plat = 'win32' elif lower....
[ "def", "parse_bdist_wininst", "(", "name", ")", ":", "lower", "=", "name", ".", "lower", "(", ")", "base", ",", "py_ver", ",", "plat", "=", "None", ",", "None", ",", "None", "if", "lower", ".", "endswith", "(", "'.exe'", ")", ":", "if", "lower", "....
[ 61, 0 ]
[ 82, 29 ]
python
en
['en', 'en', 'en']
True
distros_for_url
(url, metadata=None)
Yield egg or source distribution objects that might be found at a URL
Yield egg or source distribution objects that might be found at a URL
def distros_for_url(url, metadata=None): """Yield egg or source distribution objects that might be found at a URL""" base, fragment = egg_info_for_url(url) for dist in distros_for_location(url, base, metadata): yield dist if fragment: match = EGG_FRAGMENT.match(fragment) if match...
[ "def", "distros_for_url", "(", "url", ",", "metadata", "=", "None", ")", ":", "base", ",", "fragment", "=", "egg_info_for_url", "(", "url", ")", "for", "dist", "in", "distros_for_location", "(", "url", ",", "base", ",", "metadata", ")", ":", "yield", "di...
[ 96, 0 ]
[ 107, 26 ]
python
en
['en', 'en', 'en']
True
distros_for_location
(location, basename, metadata=None)
Yield egg or source distribution objects based on basename
Yield egg or source distribution objects based on basename
def distros_for_location(location, basename, metadata=None): """Yield egg or source distribution objects based on basename""" if basename.endswith('.egg.zip'): basename = basename[:-4] # strip the .zip if basename.endswith('.egg') and '-' in basename: # only one, unambiguous interpretation ...
[ "def", "distros_for_location", "(", "location", ",", "basename", ",", "metadata", "=", "None", ")", ":", "if", "basename", ".", "endswith", "(", "'.egg.zip'", ")", ":", "basename", "=", "basename", "[", ":", "-", "4", "]", "# strip the .zip", "if", "basena...
[ 110, 0 ]
[ 140, 13 ]
python
en
['en', 'en', 'en']
True
distros_for_filename
(filename, metadata=None)
Yield possible egg or source distribution objects based on a filename
Yield possible egg or source distribution objects based on a filename
def distros_for_filename(filename, metadata=None): """Yield possible egg or source distribution objects based on a filename""" return distros_for_location( normalize_path(filename), os.path.basename(filename), metadata )
[ "def", "distros_for_filename", "(", "filename", ",", "metadata", "=", "None", ")", ":", "return", "distros_for_location", "(", "normalize_path", "(", "filename", ")", ",", "os", ".", "path", ".", "basename", "(", "filename", ")", ",", "metadata", ")" ]
[ 143, 0 ]
[ 147, 5 ]
python
en
['en', 'en', 'en']
True
interpret_distro_name
( location, basename, metadata, py_version=None, precedence=SOURCE_DIST, platform=None )
Generate alternative interpretations of a source distro name Note: if `location` is a filesystem filename, you should call ``pkg_resources.normalize_path()`` on it before passing it to this routine!
Generate alternative interpretations of a source distro name
def interpret_distro_name( location, basename, metadata, py_version=None, precedence=SOURCE_DIST, platform=None ): """Generate alternative interpretations of a source distro name Note: if `location` is a filesystem filename, you should call ``pkg_resources.normalize_path()`` on it before pa...
[ "def", "interpret_distro_name", "(", "location", ",", "basename", ",", "metadata", ",", "py_version", "=", "None", ",", "precedence", "=", "SOURCE_DIST", ",", "platform", "=", "None", ")", ":", "# Generate alternative interpretations of a source distro name", "# Because...
[ 150, 0 ]
[ 182, 9 ]
python
en
['en', 'it', 'en']
True
unique_everseen
(iterable, key=None)
List unique elements, preserving order. Remember all elements ever seen.
List unique elements, preserving order. Remember all elements ever seen.
def unique_everseen(iterable, key=None): "List unique elements, preserving order. Remember all elements ever seen." # unique_everseen('AAAABBBCCDAABBB') --> A B C D # unique_everseen('ABBCcAD', str.lower) --> A B C D seen = set() seen_add = seen.add if key is None: for element in itertoo...
[ "def", "unique_everseen", "(", "iterable", ",", "key", "=", "None", ")", ":", "# unique_everseen('AAAABBBCCDAABBB') --> A B C D", "# unique_everseen('ABBCcAD', str.lower) --> A B C D", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "if", "key", "is...
[ 186, 0 ]
[ 201, 29 ]
python
ca
['ca', 'ca', 'en']
True
unique_values
(func)
Wrap a function returning an iterable such that the resulting iterable only ever yields unique items.
Wrap a function returning an iterable such that the resulting iterable only ever yields unique items.
def unique_values(func): """ Wrap a function returning an iterable such that the resulting iterable only ever yields unique items. """ @wraps(func) def wrapper(*args, **kwargs): return unique_everseen(func(*args, **kwargs)) return wrapper
[ "def", "unique_values", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "unique_everseen", "(", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "...
[ 204, 0 ]
[ 214, 18 ]
python
en
['en', 'error', 'th']
False
find_external_links
(url, page)
Find rel="homepage" and rel="download" links in `page`, yielding URLs
Find rel="homepage" and rel="download" links in `page`, yielding URLs
def find_external_links(url, page): """Find rel="homepage" and rel="download" links in `page`, yielding URLs""" for match in REL.finditer(page): tag, rel = match.groups() rels = set(map(str.strip, rel.lower().split(','))) if 'homepage' in rels or 'download' in rels: for matc...
[ "def", "find_external_links", "(", "url", ",", "page", ")", ":", "for", "match", "in", "REL", ".", "finditer", "(", "page", ")", ":", "tag", ",", "rel", "=", "match", ".", "groups", "(", ")", "rels", "=", "set", "(", "map", "(", "str", ".", "stri...
[ 222, 0 ]
[ 237, 75 ]
python
en
['en', 'en', 'en']
True
htmldecode
(text)
Decode HTML entities in the given text. >>> htmldecode( ... 'https://../package_name-0.1.2.tar.gz' ... '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz') 'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
Decode HTML entities in the given text.
def htmldecode(text): """ Decode HTML entities in the given text. >>> htmldecode( ... 'https://../package_name-0.1.2.tar.gz' ... '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz') 'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz' """ return en...
[ "def", "htmldecode", "(", "text", ")", ":", "return", "entity_sub", "(", "decode_entity", ",", "text", ")" ]
[ 945, 0 ]
[ 954, 42 ]
python
en
['en', 'error', 'th']
False
_encode_auth
(auth)
Encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ=' Long auth strings should not cause a newline to be inserted. >>> long_auth = 'username:' + 'password'*10 >>> chr(10) in str(_encode_auth(long_auth)) False
Encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ='
def _encode_auth(auth): """ Encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ=' Long auth strings should not cause a newline to be inserted. >>> long_auth = 'username:' + 'password'*10 >>> chr(10) in str(_encode_auth(lo...
[ "def", "_encode_auth", "(", "auth", ")", ":", "auth_s", "=", "urllib", ".", "parse", ".", "unquote", "(", "auth", ")", "# convert to bytes", "auth_bytes", "=", "auth_s", ".", "encode", "(", ")", "encoded_bytes", "=", "base64", ".", "b64encode", "(", "auth_...
[ 972, 0 ]
[ 990, 36 ]
python
en
['en', 'error', 'th']
False
open_with_auth
(url, opener=urllib.request.urlopen)
Open a urllib2 request, handling HTTP authentication
Open a urllib2 request, handling HTTP authentication
def open_with_auth(url, opener=urllib.request.urlopen): """Open a urllib2 request, handling HTTP authentication""" parsed = urllib.parse.urlparse(url) scheme, netloc, path, params, query, frag = parsed # Double scheme does not raise on macOS as revealed by a # failing test. We would expect "nonnum...
[ "def", "open_with_auth", "(", "url", ",", "opener", "=", "urllib", ".", "request", ".", "urlopen", ")", ":", "parsed", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", "...
[ 1048, 0 ]
[ 1091, 13 ]
python
en
['en', 'lb', 'en']
True
_splituser
(host)
splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.
splituser('user[:passwd]
def _splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" user, delim, host = host.rpartition('@') return (user if delim else None), host
[ "def", "_splituser", "(", "host", ")", ":", "user", ",", "delim", ",", "host", "=", "host", ".", "rpartition", "(", "'@'", ")", "return", "(", "user", "if", "delim", "else", "None", ")", ",", "host" ]
[ 1095, 0 ]
[ 1099, 42 ]
python
en
['en', 'no', 'sw']
False
local_open
(url)
Read a local path, with special support for directories
Read a local path, with special support for directories
def local_open(url): """Read a local path, with special support for directories""" scheme, server, path, param, query, frag = urllib.parse.urlparse(url) filename = urllib.request.url2pathname(path) if os.path.isfile(filename): return urllib.request.urlopen(url) elif path.endswith('/') and os...
[ "def", "local_open", "(", "url", ")", ":", "scheme", ",", "server", ",", "path", ",", "param", ",", "query", ",", "frag", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "filename", "=", "urllib", ".", "request", ".", "url2pathname", "...
[ 1110, 0 ]
[ 1138, 77 ]
python
en
['en', 'en', 'en']
True
ContentChecker.feed
(self, block)
Feed a block of data to the hash.
Feed a block of data to the hash.
def feed(self, block): """ Feed a block of data to the hash. """ return
[ "def", "feed", "(", "self", ",", "block", ")", ":", "return" ]
[ 245, 4 ]
[ 249, 14 ]
python
en
['en', 'error', 'th']
False
ContentChecker.is_valid
(self)
Check the hash. Return False if validation fails.
Check the hash. Return False if validation fails.
def is_valid(self): """ Check the hash. Return False if validation fails. """ return True
[ "def", "is_valid", "(", "self", ")", ":", "return", "True" ]
[ 251, 4 ]
[ 255, 19 ]
python
en
['en', 'error', 'th']
False
ContentChecker.report
(self, reporter, template)
Call reporter with information about the checker (hash name) substituted into the template.
Call reporter with information about the checker (hash name) substituted into the template.
def report(self, reporter, template): """ Call reporter with information about the checker (hash name) substituted into the template. """ return
[ "def", "report", "(", "self", ",", "reporter", ",", "template", ")", ":", "return" ]
[ 257, 4 ]
[ 262, 14 ]
python
en
['en', 'error', 'th']
False
HashChecker.from_url
(cls, url)
Construct a (possibly null) ContentChecker from a URL
Construct a (possibly null) ContentChecker from a URL
def from_url(cls, url): "Construct a (possibly null) ContentChecker from a URL" fragment = urllib.parse.urlparse(url)[-1] if not fragment: return ContentChecker() match = cls.pattern.search(fragment) if not match: return ContentChecker() return cls...
[ "def", "from_url", "(", "cls", ",", "url", ")", ":", "fragment", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "[", "-", "1", "]", "if", "not", "fragment", ":", "return", "ContentChecker", "(", ")", "match", "=", "cls", ".", "patte...
[ 277, 4 ]
[ 285, 39 ]
python
en
['en', 'en', 'en']
True
PackageIndex.process_url
(self, url, retrieve=False)
Evaluate a URL as a possible download, and maybe retrieve it
Evaluate a URL as a possible download, and maybe retrieve it
def process_url(self, url, retrieve=False): """Evaluate a URL as a possible download, and maybe retrieve it""" if url in self.scanned_urls and not retrieve: return self.scanned_urls[url] = True if not URL_SCHEME(url): self.process_filename(url) return ...
[ "def", "process_url", "(", "self", ",", "url", ",", "retrieve", "=", "False", ")", ":", "if", "url", "in", "self", ".", "scanned_urls", "and", "not", "retrieve", ":", "return", "self", ".", "scanned_urls", "[", "url", "]", "=", "True", "if", "not", "...
[ 322, 4 ]
[ 373, 48 ]
python
en
['en', 'en', 'en']
True
PackageIndex.process_index
(self, url, page)
Process the contents of a PyPI page
Process the contents of a PyPI page
def process_index(self, url, page): """Process the contents of a PyPI page""" def scan(link): # Process a URL to see if it's for a package page if link.startswith(self.index_url): parts = list(map( urllib.parse.unquote, link[len(self.index_url...
[ "def", "process_index", "(", "self", ",", "url", ",", "page", ")", ":", "def", "scan", "(", "link", ")", ":", "# Process a URL to see if it's for a package page", "if", "link", ".", "startswith", "(", "self", ".", "index_url", ")", ":", "parts", "=", "list",...
[ 430, 4 ]
[ 471, 21 ]
python
en
['en', 'en', 'en']
True
PackageIndex.check_hash
(self, checker, filename, tfp)
checker is a ContentChecker
checker is a ContentChecker
def check_hash(self, checker, filename, tfp): """ checker is a ContentChecker """ checker.report( self.debug, "Validating %%s checksum for %s" % filename) if not checker.is_valid(): tfp.close() os.unlink(filename) raise ...
[ "def", "check_hash", "(", "self", ",", "checker", ",", "filename", ",", "tfp", ")", ":", "checker", ".", "report", "(", "self", ".", "debug", ",", "\"Validating %%s checksum for %s\"", "%", "filename", ")", "if", "not", "checker", ".", "is_valid", "(", ")"...
[ 512, 4 ]
[ 526, 13 ]
python
en
['en', 'error', 'th']
False
PackageIndex.add_find_links
(self, urls)
Add `urls` to the list that will be prescanned for searches
Add `urls` to the list that will be prescanned for searches
def add_find_links(self, urls): """Add `urls` to the list that will be prescanned for searches""" for url in urls: if ( self.to_scan is None # if we have already "gone online" or not URL_SCHEME(url) # or it's a local file/directory or url.sta...
[ "def", "add_find_links", "(", "self", ",", "urls", ")", ":", "for", "url", "in", "urls", ":", "if", "(", "self", ".", "to_scan", "is", "None", "# if we have already \"gone online\"", "or", "not", "URL_SCHEME", "(", "url", ")", "# or it's a local file/directory",...
[ 528, 4 ]
[ 541, 40 ]
python
en
['en', 'en', 'en']
True
PackageIndex.prescan
(self)
Scan urls scheduled for prescanning (e.g. --find-links)
Scan urls scheduled for prescanning (e.g. --find-links)
def prescan(self): """Scan urls scheduled for prescanning (e.g. --find-links)""" if self.to_scan: list(map(self.scan_url, self.to_scan)) self.to_scan = None
[ "def", "prescan", "(", "self", ")", ":", "if", "self", ".", "to_scan", ":", "list", "(", "map", "(", "self", ".", "scan_url", ",", "self", ".", "to_scan", ")", ")", "self", ".", "to_scan", "=", "None" ]
[ 543, 4 ]
[ 547, 27 ]
python
en
['en', 'de', 'en']
True
PackageIndex.download
(self, spec, tmpdir)
Locate and/or download `spec` to `tmpdir`, returning a local path `spec` may be a ``Requirement`` object, or a string containing a URL, an existing local filename, or a project/version requirement spec (i.e. the string form of a ``Requirement`` object). If it is the URL of a .py file w...
Locate and/or download `spec` to `tmpdir`, returning a local path
def download(self, spec, tmpdir): """Locate and/or download `spec` to `tmpdir`, returning a local path `spec` may be a ``Requirement`` object, or a string containing a URL, an existing local filename, or a project/version requirement spec (i.e. the string form of a ``Requirement`` objec...
[ "def", "download", "(", "self", ",", "spec", ",", "tmpdir", ")", ":", "if", "not", "isinstance", "(", "spec", ",", "Requirement", ")", ":", "scheme", "=", "URL_SCHEME", "(", "spec", ")", "if", "scheme", ":", "# It's a url, download it to tmpdir", "found", ...
[ 559, 4 ]
[ 591, 79 ]
python
en
['en', 'en', 'en']
True
PackageIndex.fetch_distribution
( self, requirement, tmpdir, force_scan=False, source=False, develop_ok=False, local_index=None)
Obtain a distribution suitable for fulfilling `requirement` `requirement` must be a ``pkg_resources.Requirement`` instance. If necessary, or if the `force_scan` flag is set, the requirement is searched for in the (online) package index as well as the locally installed packages. If a di...
Obtain a distribution suitable for fulfilling `requirement`
def fetch_distribution( self, requirement, tmpdir, force_scan=False, source=False, develop_ok=False, local_index=None): """Obtain a distribution suitable for fulfilling `requirement` `requirement` must be a ``pkg_resources.Requirement`` instance. If necessary, or if the ...
[ "def", "fetch_distribution", "(", "self", ",", "requirement", ",", "tmpdir", ",", "force_scan", "=", "False", ",", "source", "=", "False", ",", "develop_ok", "=", "False", ",", "local_index", "=", "None", ")", ":", "# process a Requirement", "self", ".", "in...
[ 593, 4 ]
[ 667, 62 ]
python
en
['en', 'en', 'en']
True
PackageIndex.fetch
(self, requirement, tmpdir, force_scan=False, source=False)
Obtain a file suitable for fulfilling `requirement` DEPRECATED; use the ``fetch_distribution()`` method now instead. For backward compatibility, this routine is identical but returns the ``location`` of the downloaded distribution instead of a distribution object.
Obtain a file suitable for fulfilling `requirement`
def fetch(self, requirement, tmpdir, force_scan=False, source=False): """Obtain a file suitable for fulfilling `requirement` DEPRECATED; use the ``fetch_distribution()`` method now instead. For backward compatibility, this routine is identical but returns the ``location`` of the downlo...
[ "def", "fetch", "(", "self", ",", "requirement", ",", "tmpdir", ",", "force_scan", "=", "False", ",", "source", "=", "False", ")", ":", "dist", "=", "self", ".", "fetch_distribution", "(", "requirement", ",", "tmpdir", ",", "force_scan", ",", "source", "...
[ 669, 4 ]
[ 680, 19 ]
python
en
['en', 'en', 'en']
True
PyPIConfig.__init__
(self)
Load from ~/.pypirc
Load from ~/.pypirc
def __init__(self): """ Load from ~/.pypirc """ defaults = dict.fromkeys(['username', 'password', 'repository'], '') configparser.RawConfigParser.__init__(self, defaults) rc = os.path.join(os.path.expanduser('~'), '.pypirc') if os.path.exists(rc): sel...
[ "def", "__init__", "(", "self", ")", ":", "defaults", "=", "dict", ".", "fromkeys", "(", "[", "'username'", ",", "'password'", ",", "'repository'", "]", ",", "''", ")", "configparser", ".", "RawConfigParser", ".", "__init__", "(", "self", ",", "defaults", ...
[ 1011, 4 ]
[ 1020, 25 ]
python
en
['en', 'error', 'th']
False
PyPIConfig.find_credential
(self, url)
If the URL indicated appears to be a repository defined in this config, return the credential for that repository.
If the URL indicated appears to be a repository defined in this config, return the credential for that repository.
def find_credential(self, url): """ If the URL indicated appears to be a repository defined in this config, return the credential for that repository. """ for repository, cred in self.creds_by_repository.items(): if url.startswith(repository): return c...
[ "def", "find_credential", "(", "self", ",", "url", ")", ":", "for", "repository", ",", "cred", "in", "self", ".", "creds_by_repository", ".", "items", "(", ")", ":", "if", "url", ".", "startswith", "(", "repository", ")", ":", "return", "cred" ]
[ 1038, 4 ]
[ 1045, 27 ]
python
en
['en', 'error', 'th']
False
RequestMethods.request
(self, method, url, fields=None, headers=None, **urlopen_kw)
Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used. This is a convenience method that requires the least amount of manual effort. It can be used in most situations, while still having the option to drop down to more spe...
Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used.
def request(self, method, url, fields=None, headers=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used. This is a convenience method that requires the least amount of manual effort. It can be use...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "headers", "=", "None", ",", "*", "*", "urlopen_kw", ")", ":", "method", "=", "method", ".", "upper", "(", ")", "urlopen_kw", "[", "\"request_url\"", "]", "=",...
[ 57, 4 ]
[ 79, 13 ]
python
en
['en', 'error', 'th']
False
RequestMethods.request_encode_url
(self, method, url, fields=None, headers=None, **urlopen_kw)
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
def request_encode_url(self, method, url, fields=None, headers=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. """ if headers is None: headers = self....
[ "def", "request_encode_url", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "headers", "=", "None", ",", "*", "*", "urlopen_kw", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "self", ".", "headers", "extra_kw",...
[ 81, 4 ]
[ 95, 52 ]
python
en
['en', 'error', 'th']
False
RequestMethods.request_encode_body
( self, method, url, fields=None, headers=None, encode_multipart=True, multipart_boundary=None, **urlopen_kw )
Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc. When ``encode_multipart=True`` (default), then :func:`urllib3.encode_multipart_formdata` is used to encode the payload with the appropria...
Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc.
def request_encode_body( self, method, url, fields=None, headers=None, encode_multipart=True, multipart_boundary=None, **urlopen_kw ): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is use...
[ "def", "request_encode_body", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "headers", "=", "None", ",", "encode_multipart", "=", "True", ",", "multipart_boundary", "=", "None", ",", "*", "*", "urlopen_kw", ")", ":", "if", "hea...
[ 97, 4 ]
[ 169, 52 ]
python
en
['en', 'error', 'th']
False
MediaEmbedHandler.expand_db_attributes
(attrs)
Given a dict of attributes from the <embed> tag, return the real HTML representation for use on the front-end.
Given a dict of attributes from the <embed> tag, return the real HTML representation for use on the front-end.
def expand_db_attributes(attrs): """ Given a dict of attributes from the <embed> tag, return the real HTML representation for use on the front-end. """ return format.embed_to_frontend_html(attrs['url'])
[ "def", "expand_db_attributes", "(", "attrs", ")", ":", "return", "format", ".", "embed_to_frontend_html", "(", "attrs", "[", "'url'", "]", ")" ]
[ 20, 4 ]
[ 25, 58 ]
python
en
['en', 'error', 'th']
False
AdHocCommand.relaunch
(self, payload={})
Relaunch the command using the related->relaunch endpoint
Relaunch the command using the related->relaunch endpoint
def relaunch(self, payload={}): """Relaunch the command using the related->relaunch endpoint""" # navigate to relaunch_pg relaunch_pg = self.get_related('relaunch') # relaunch the command result = relaunch_pg.post(payload) # return the corresponding command_pg r...
[ "def", "relaunch", "(", "self", ",", "payload", "=", "{", "}", ")", ":", "# navigate to relaunch_pg", "relaunch_pg", "=", "self", ".", "get_related", "(", "'relaunch'", ")", "# relaunch the command", "result", "=", "relaunch_pg", ".", "post", "(", "payload", "...
[ 14, 4 ]
[ 23, 36 ]
python
en
['en', 'en', 'en']
True
ProjectFinder._find_project
(self, proj_name)
:rtype: bzt.bza.Project
:rtype: bzt.bza.Project
def _find_project(self, proj_name): """ :rtype: bzt.bza.Project """ if isinstance(proj_name, (int, float)): # project id proj_id = int(proj_name) self.log.debug("Treating project name as ID: %s", proj_id) project = self.workspaces.projects(ident=proj_...
[ "def", "_find_project", "(", "self", ",", "proj_name", ")", ":", "if", "isinstance", "(", "proj_name", ",", "(", "int", ",", "float", ")", ")", ":", "# project id", "proj_id", "=", "int", "(", "proj_name", ")", "self", ".", "log", ".", "debug", "(", ...
[ 35, 4 ]
[ 50, 22 ]
python
en
['en', 'error', 'th']
False
extract_timestamp
(hdulist)
args: hdulist (astropy.io.fits.HDUList): fits header to extract timestamp from returns: datetime.datetime: extracted timestamp
args: hdulist (astropy.io.fits.HDUList): fits header to extract timestamp from
def extract_timestamp(hdulist): """ args: hdulist (astropy.io.fits.HDUList): fits header to extract timestamp from returns: datetime.datetime: extracted timestamp """ return dateutil.parser.parse(hdulist[0].header['date-obs'])
[ "def", "extract_timestamp", "(", "hdulist", ")", ":", "return", "dateutil", ".", "parser", ".", "parse", "(", "hdulist", "[", "0", "]", ".", "header", "[", "'date-obs'", "]", ")" ]
[ 33, 0 ]
[ 42, 63 ]
python
en
['en', 'error', 'th']
False
getbytes
(socket_, bytes_)
Read an amount of bytes from the socket args: socket_ (socket.socket): socket to use for reading bytes_ (int): amount of bytes to read returns: str: raw bytes from socket
Read an amount of bytes from the socket
def getbytes(socket_, bytes_): """ Read an amount of bytes from the socket args: socket_ (socket.socket): socket to use for reading bytes_ (int): amount of bytes to read returns: str: raw bytes from socket """ result = StringIO.StringIO() count = bytes_ while cou...
[ "def", "getbytes", "(", "socket_", ",", "bytes_", ")", ":", "result", "=", "StringIO", ".", "StringIO", "(", ")", "count", "=", "bytes_", "while", "count", ">", "0", ":", "recv", "=", "socket_", ".", "recv", "(", "count", ")", "if", "len", "(", "re...
[ 45, 0 ]
[ 63, 28 ]
python
en
['en', 'error', 'th']
False
read_window
(socket_)
read raw aarfaac protocol window args: socket_ (socket.socket): socket to read from returns: fits_bytes, image_bytes
read raw aarfaac protocol window
def read_window(socket_): """ read raw aarfaac protocol window args: socket_ (socket.socket): socket to read from returns: fits_bytes, image_bytes """ header_bytes = getbytes(socket_, 512) magic = struct.unpack('Q', header_bytes[:8])[0] fits_length = struct.unpack('=L', ...
[ "def", "read_window", "(", "socket_", ")", ":", "header_bytes", "=", "getbytes", "(", "socket_", ",", "512", ")", "magic", "=", "struct", ".", "unpack", "(", "'Q'", ",", "header_bytes", "[", ":", "8", "]", ")", "[", "0", "]", "fits_length", "=", "str...
[ 66, 0 ]
[ 82, 34 ]
python
en
['en', 'error', 'th']
False
reconstruct_fits
(fits_bytes, image_bytes)
reconstruct a fits object from serialised fits header and data. args: fits_bytes (str): a string with serialized fits bytes image_bytes (str): a string with serialized image data returns: astropy.io.fits.HDUList: the fits object
reconstruct a fits object from serialised fits header and data.
def reconstruct_fits(fits_bytes, image_bytes): """ reconstruct a fits object from serialised fits header and data. args: fits_bytes (str): a string with serialized fits bytes image_bytes (str): a string with serialized image data returns: astropy.io.fits.HDUList: the fits object...
[ "def", "reconstruct_fits", "(", "fits_bytes", ",", "image_bytes", ")", ":", "hdu_header", "=", "astropy", ".", "io", ".", "fits", ".", "header", ".", "Header", ".", "fromstring", "(", "fits_bytes", ")", "width", "=", "hdu_header", "[", "\"NAXIS1\"", "]", "...
[ 85, 0 ]
[ 104, 18 ]
python
en
['en', 'error', 'th']
False
connection_handler
(socket_, image_queue)
Handles the connection, waits until a windows is returned and puts it in the queue. Daemon thread, will loop forever. args: socket_ (socket.socket): socket used for reading image_queue (Queue.Queue): used for putting images in
Handles the connection, waits until a windows is returned and puts it in the queue.
def connection_handler(socket_, image_queue): """ Handles the connection, waits until a windows is returned and puts it in the queue. Daemon thread, will loop forever. args: socket_ (socket.socket): socket used for reading image_queue (Queue.Queue): used for putting images in "...
[ "def", "connection_handler", "(", "socket_", ",", "image_queue", ")", ":", "while", "True", ":", "try", ":", "fits_bytes", ",", "image_bytes", "=", "read_window", "(", "socket_", ")", "except", "Exception", "as", "e", ":", "logger", ".", "error", "(", "\"e...
[ 107, 0 ]
[ 128, 36 ]
python
en
['en', 'error', 'th']
False
connector
(host, port, image_queue)
Tries to connect to a specific host and port, if succesfull will call connection_handler() with the connection. args: host (str): host to connect to port (int): port to connect to image_queue (Queue.Queue): Will be used for putting the images in
Tries to connect to a specific host and port, if succesfull will call connection_handler() with the connection.
def connector(host, port, image_queue): """ Tries to connect to a specific host and port, if succesfull will call connection_handler() with the connection. args: host (str): host to connect to port (int): port to connect to image_queue (Queue.Queue): Will be used for putting the...
[ "def", "connector", "(", "host", ",", "port", ",", "image_queue", ")", ":", "while", "True", ":", "logger", ".", "info", "(", "\"connecting to {}:{}\"", ".", "format", "(", "host", ",", "port", ")", ")", "try", ":", "socket_", "=", "socket", ".", "sock...
[ 131, 0 ]
[ 154, 52 ]
python
en
['en', 'error', 'th']
False
merger
(image_queue, grouped_queue)
Will monitor image_queue for images and group them by timestamp. When an image with an successive timestamp is received the group is put on the grouped queue. args: image_queue (Queue): the incoming image queue grouped_queue (Queue): the outgoing grouped image queue
Will monitor image_queue for images and group them by timestamp. When an image with an successive timestamp is received the group is put on the grouped queue.
def merger(image_queue, grouped_queue): """ Will monitor image_queue for images and group them by timestamp. When an image with an successive timestamp is received the group is put on the grouped queue. args: image_queue (Queue): the incoming image queue grouped_queue (Queue): the o...
[ "def", "merger", "(", "image_queue", ",", "grouped_queue", ")", ":", "logger", ".", "info", "(", "\"merger thread started\"", ")", "first_image", "=", "image_queue", ".", "get", "(", ")", "logger", ".", "info", "(", "\"merger received first image\"", ")", "image...
[ 157, 0 ]
[ 191, 32 ]
python
en
['en', 'error', 'th']
False
stream_generator
(hosts, ports)
Connects to all hosts on port in ports. Returns a generator yielding sets of images with the same timestamp. args: hosts (tuple): list of hosts to connect to ports (tuple): list of ports to connect to
Connects to all hosts on port in ports. Returns a generator yielding sets of images with the same timestamp.
def stream_generator(hosts, ports): """ Connects to all hosts on port in ports. Returns a generator yielding sets of images with the same timestamp. args: hosts (tuple): list of hosts to connect to ports (tuple): list of ports to connect to """ if THREADED: import threa...
[ "def", "stream_generator", "(", "hosts", ",", "ports", ")", ":", "if", "THREADED", ":", "import", "threading", "from", "queue", "import", "Queue", "method", "=", "threading", ".", "Thread", "image_queue", "=", "Queue", "(", ")", "grouped_queue", "=", "Queue"...
[ 194, 0 ]
[ 231, 33 ]
python
en
['en', 'error', 'th']
False
matches_patterns
(path, patterns=None)
Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``).
Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``).
def matches_patterns(path, patterns=None): """ Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``). """ if patterns is None: patterns = [] for pattern in patterns: if fnmatch.fnmatchcase(path, pattern): ...
[ "def", "matches_patterns", "(", "path", ",", "patterns", "=", "None", ")", ":", "if", "patterns", "is", "None", ":", "patterns", "=", "[", "]", "for", "pattern", "in", "patterns", ":", "if", "fnmatch", ".", "fnmatchcase", "(", "path", ",", "pattern", "...
[ 7, 0 ]
[ 17, 16 ]
python
en
['en', 'error', 'th']
False
get_files
(storage, ignore_patterns=None, location='')
Recursively walk the storage directories yielding the paths of all files that should be copied.
Recursively walk the storage directories yielding the paths of all files that should be copied.
def get_files(storage, ignore_patterns=None, location=''): """ Recursively walk the storage directories yielding the paths of all files that should be copied. """ if ignore_patterns is None: ignore_patterns = [] directories, files = storage.listdir(location) for fn in files: ...
[ "def", "get_files", "(", "storage", ",", "ignore_patterns", "=", "None", ",", "location", "=", "''", ")", ":", "if", "ignore_patterns", "is", "None", ":", "ignore_patterns", "=", "[", "]", "directories", ",", "files", "=", "storage", ".", "listdir", "(", ...
[ 20, 0 ]
[ 40, 20 ]
python
en
['en', 'error', 'th']
False
check_settings
(base_url=None)
Checks if the staticfiles settings have sane values.
Checks if the staticfiles settings have sane values.
def check_settings(base_url=None): """ Checks if the staticfiles settings have sane values. """ if base_url is None: base_url = settings.STATIC_URL if not base_url: raise ImproperlyConfigured( "You're using the staticfiles app " "without having set the require...
[ "def", "check_settings", "(", "base_url", "=", "None", ")", ":", "if", "base_url", "is", "None", ":", "base_url", "=", "settings", ".", "STATIC_URL", "if", "not", "base_url", ":", "raise", "ImproperlyConfigured", "(", "\"You're using the staticfiles app \"", "\"wi...
[ 43, 0 ]
[ 59, 73 ]
python
en
['en', 'error', 'th']
False
_default_key_normalizer
(key_class, request_context)
Create a pool key out of a request context dictionary. According to RFC 3986, both the scheme and host are case-insensitive. Therefore, this function normalizes both before constructing the pool key for an HTTPS request. If you wish to change this behaviour, provide alternate callables to ``key_fn...
Create a pool key out of a request context dictionary.
def _default_key_normalizer(key_class, request_context): """ Create a pool key out of a request context dictionary. According to RFC 3986, both the scheme and host are case-insensitive. Therefore, this function normalizes both before constructing the pool key for an HTTPS request. If you wish to ch...
[ "def", "_default_key_normalizer", "(", "key_class", ",", "request_context", ")", ":", "# Since we mutate the dictionary, make a copy first", "context", "=", "request_context", ".", "copy", "(", ")", "context", "[", "\"scheme\"", "]", "=", "context", "[", "\"scheme\"", ...
[ 77, 0 ]
[ 123, 31 ]
python
en
['en', 'error', 'th']
False
PoolManager._new_pool
(self, scheme, host, port, request_context=None)
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. This method is used to actually create the connect...
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments.
def _new_pool(self, scheme, host, port, request_context=None): """ Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the p...
[ "def", "_new_pool", "(", "self", ",", "scheme", ",", "host", ",", "port", ",", "request_context", "=", "None", ")", ":", "pool_cls", "=", "self", ".", "pool_classes_by_scheme", "[", "scheme", "]", "if", "request_context", "is", "None", ":", "request_context"...
[ 187, 4 ]
[ 212, 54 ]
python
en
['en', 'error', 'th']
False
PoolManager.clear
(self)
Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion.
Empty our store of pools and direct them all to close.
def clear(self): """ Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion. """ self.pools.clear()
[ "def", "clear", "(", "self", ")", ":", "self", ".", "pools", ".", "clear", "(", ")" ]
[ 214, 4 ]
[ 221, 26 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_host
(self, host, port=None, scheme="http", pool_kwargs=None)
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_...
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme.
def connection_from_host(self, host, port=None, scheme="http", pool_kwargs=None): """ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``...
[ "def", "connection_from_host", "(", "self", ",", "host", ",", "port", "=", "None", ",", "scheme", "=", "\"http\"", ",", "pool_kwargs", "=", "None", ")", ":", "if", "not", "host", ":", "raise", "LocationValueError", "(", "\"No host specified.\"", ")", "reques...
[ 223, 4 ]
[ 244, 60 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_context
(self, request_context)
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable.
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context.
def connection_from_context(self, request_context): """ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable. """ ...
[ "def", "connection_from_context", "(", "self", ",", "request_context", ")", ":", "scheme", "=", "request_context", "[", "\"scheme\"", "]", ".", "lower", "(", ")", "pool_key_constructor", "=", "self", ".", "key_fn_by_scheme", ".", "get", "(", "scheme", ")", "if...
[ 246, 4 ]
[ 259, 87 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_pool_key
(self, pool_key, request_context=None)
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ``port`` fields.
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key.
def connection_from_pool_key(self, pool_key, request_context=None): """ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ...
[ "def", "connection_from_pool_key", "(", "self", ",", "pool_key", ",", "request_context", "=", "None", ")", ":", "with", "self", ".", "pools", ".", "lock", ":", "# If the scheme, host, or port doesn't match existing open", "# connections, open a new ConnectionPool.", "pool",...
[ 261, 4 ]
[ 283, 19 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_url
(self, url, pool_kwargs=None)
Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` is provided, it is ...
Similar to :func:`urllib3.connectionpool.connection_from_url`.
def connection_from_url(self, url, pool_kwargs=None): """ Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpoo...
[ "def", "connection_from_url", "(", "self", ",", "url", ",", "pool_kwargs", "=", "None", ")", ":", "u", "=", "parse_url", "(", "url", ")", "return", "self", ".", "connection_from_host", "(", "u", ".", "host", ",", "port", "=", "u", ".", "port", ",", "...
[ 285, 4 ]
[ 299, 9 ]
python
en
['en', 'error', 'th']
False
PoolManager._merge_pool_kwargs
(self, override)
Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary.
Merge a dictionary of override values for self.connection_pool_kw.
def _merge_pool_kwargs(self, override): """ Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary...
[ "def", "_merge_pool_kwargs", "(", "self", ",", "override", ")", ":", "base_pool_kwargs", "=", "self", ".", "connection_pool_kw", ".", "copy", "(", ")", "if", "override", ":", "for", "key", ",", "value", "in", "override", ".", "items", "(", ")", ":", "if"...
[ 301, 4 ]
[ 319, 31 ]
python
en
['en', 'error', 'th']
False
PoolManager._proxy_requires_url_absolute_form
(self, parsed_url)
Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel.
Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel.
def _proxy_requires_url_absolute_form(self, parsed_url): """ Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel. """ if self.proxy is None: return False retu...
[ "def", "_proxy_requires_url_absolute_form", "(", "self", ",", "parsed_url", ")", ":", "if", "self", ".", "proxy", "is", "None", ":", "return", "False", "return", "not", "connection_requires_http_tunnel", "(", "self", ".", "proxy", ",", "self", ".", "proxy_config...
[ 321, 4 ]
[ 332, 9 ]
python
en
['en', 'error', 'th']
False
PoolManager._validate_proxy_scheme_url_selection
(self, url_scheme)
Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations.
Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations.
def _validate_proxy_scheme_url_selection(self, url_scheme): """ Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations. """ if self.proxy is None or url_scheme != "https": return if self.proxy.scheme...
[ "def", "_validate_proxy_scheme_url_selection", "(", "self", ",", "url_scheme", ")", ":", "if", "self", ".", "proxy", "is", "None", "or", "url_scheme", "!=", "\"https\"", ":", "return", "if", "self", ".", "proxy", ".", "scheme", "!=", "\"https\"", ":", "retur...
[ 334, 4 ]
[ 349, 13 ]
python
en
['en', 'error', 'th']
False
PoolManager.urlopen
(self, method, url, redirect=True, **kw)
Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate :class:`urllib3.connectionpool.ConnectionPool` can be chosen fo...
Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``.
def urlopen(self, method, url, redirect=True, **kw): """ Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate ...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "redirect", "=", "True", ",", "*", "*", "kw", ")", ":", "u", "=", "parse_url", "(", "url", ")", "self", ".", "_validate_proxy_scheme_url_selection", "(", "u", ".", "scheme", ")", "conn", ...
[ 351, 4 ]
[ 416, 60 ]
python
en
['en', 'error', 'th']
False
ProxyManager._set_proxy_headers
(self, url, headers=None)
Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.
Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.
def _set_proxy_headers(self, url, headers=None): """ Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user. """ headers_ = {"Accept": "*/*"} netloc = parse_url(url).netloc if netloc: head...
[ "def", "_set_proxy_headers", "(", "self", ",", "url", ",", "headers", "=", "None", ")", ":", "headers_", "=", "{", "\"Accept\"", ":", "\"*/*\"", "}", "netloc", "=", "parse_url", "(", "url", ")", ".", "netloc", "if", "netloc", ":", "headers_", "[", "\"H...
[ 506, 4 ]
[ 519, 23 ]
python
en
['en', 'error', 'th']
False
ProxyManager.urlopen
(self, method, url, redirect=True, **kw)
Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.
Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.
def urlopen(self, method, url, redirect=True, **kw): "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute." u = parse_url(url) if not connection_requires_http_tunnel(self.proxy, self.proxy_config, u.scheme): # For connections using HTTP CONNECT, httplib sets the necessary...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "redirect", "=", "True", ",", "*", "*", "kw", ")", ":", "u", "=", "parse_url", "(", "url", ")", "if", "not", "connection_requires_http_tunnel", "(", "self", ".", "proxy", ",", "self", "."...
[ 521, 4 ]
[ 531, 86 ]
python
en
['en', 'en', 'nl']
True
filter_by_expression
(counts, median_threshold, min_threshold)
Filter the counts matrix by median expression of replicates with a condition, and a minimum expression level across all samples
Filter the counts matrix by median expression of replicates with a condition, and a minimum expression level across all samples
def filter_by_expression(counts, median_threshold, min_threshold): ''' Filter the counts matrix by median expression of replicates with a condition, and a minimum expression level across all samples ''' if counts.empty: return counts # If all reps are 100% matches we don't need to do any...
[ "def", "filter_by_expression", "(", "counts", ",", "median_threshold", ",", "min_threshold", ")", ":", "if", "counts", ".", "empty", ":", "return", "counts", "# If all reps are 100% matches we don't need to do any tests", "is_variable", "=", "counts", ".", "groupby", "(...
[ 23, 0 ]
[ 41, 49 ]
python
en
['en', 'error', 'th']
False
run_differr_analysis
(kd_bam_fns, cntrl_bam_fns, fasta_fn, res_hdf5_fn=None, batch_size=1_000_000, median_expr_threshold=10, min_expr_threshold=0, fdr_threshold=0.05, processes=6, ...
run the whole analysis on a set of bam files. Returns a dataframe filtered by fdr.
run the whole analysis on a set of bam files. Returns a dataframe filtered by fdr.
def run_differr_analysis(kd_bam_fns, cntrl_bam_fns, fasta_fn, res_hdf5_fn=None, batch_size=1_000_000, median_expr_threshold=10, min_expr_threshold=0, fdr_threshold=0.05, ...
[ "def", "run_differr_analysis", "(", "kd_bam_fns", ",", "cntrl_bam_fns", ",", "fasta_fn", ",", "res_hdf5_fn", "=", "None", ",", "batch_size", "=", "1_000_000", ",", "median_expr_threshold", "=", "10", ",", "min_expr_threshold", "=", "0", ",", "fdr_threshold", "=", ...
[ 44, 0 ]
[ 104, 18 ]
python
en
['en', 'error', 'th']
False
differr
(cond_a_bams, cond_b_bams, reference_fasta, output_bed, raw_counts_hdf, fdr_threshold, processes, max_depth, normalise, median_expr_threshold, min_expr_threshold)
A script for detecting differential error rates in aligned Nanopore data
A script for detecting differential error rates in aligned Nanopore data
def differr(cond_a_bams, cond_b_bams, reference_fasta, output_bed, raw_counts_hdf, fdr_threshold, processes, max_depth, normalise, median_expr_threshold, min_expr_threshold): ''' A script for detecting differential error rates in aligned Na...
[ "def", "differr", "(", "cond_a_bams", ",", "cond_b_bams", ",", "reference_fasta", ",", "output_bed", ",", "raw_counts_hdf", ",", "fdr_threshold", ",", "processes", ",", "max_depth", ",", "normalise", ",", "median_expr_threshold", ",", "min_expr_threshold", ")", ":",...
[ 140, 0 ]
[ 165, 43 ]
python
en
['en', 'error', 'th']
False
TestServiceBotBasics.test_service_events_for_private_mentions
(self)
Service bots should not get access to mentions if they aren't a direct recipient.
Service bots should not get access to mentions if they aren't a direct recipient.
def test_service_events_for_private_mentions(self) -> None: """Service bots should not get access to mentions if they aren't a direct recipient.""" sender = self.example_user("hamlet") assert not sender.is_bot outgoing_bot = self._get_outgoing_bot() assert outgoing_bot.b...
[ "def", "test_service_events_for_private_mentions", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "assert", "not", "sender", ".", "is_bot", "outgoing_bot", "=", "self", ".", "_get_outgoing_bot", "(", ")",...
[ 119, 4 ]
[ 138, 41 ]
python
en
['en', 'en', 'en']
True
TestFrontendServeView.test_get
(self)
Test a valid GET request to the view
Test a valid GET request to the view
def test_get(self): """ Test a valid GET request to the view """ # Generate signature signature = generate_signature(self.image.id, 'fill-800x600') # Get the image response = self.client.get(reverse('wagtailimages_serve', args=(signature, self.image.id, 'fill-800...
[ "def", "test_get", "(", "self", ")", ":", "# Generate signature", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", ",", "'fill-800x600'", ")", "# Get the image", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", ...
[ 303, 4 ]
[ 316, 63 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_with_extra_component
(self)
Test that a filename can be optionally added to the end of the URL.
Test that a filename can be optionally added to the end of the URL.
def test_get_with_extra_component(self): """ Test that a filename can be optionally added to the end of the URL. """ # Generate signature signature = generate_signature(self.image.id, 'fill-800x600') # Get the image response = self.client.get(reverse('wagtailimag...
[ "def", "test_get_with_extra_component", "(", "self", ")", ":", "# Generate signature", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", ",", "'fill-800x600'", ")", "# Get the image", "response", "=", "self", ".", "client", ".", "get", ...
[ 318, 4 ]
[ 331, 63 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_with_too_many_extra_components
(self)
A filename can be appended to the end of the URL, but it must not contain a '/'
A filename can be appended to the end of the URL, but it must not contain a '/'
def test_get_with_too_many_extra_components(self): """ A filename can be appended to the end of the URL, but it must not contain a '/' """ # Generate signature signature = generate_signature(self.image.id, 'fill-800x600') # Get the image response = self.client.ge...
[ "def", "test_get_with_too_many_extra_components", "(", "self", ")", ":", "# Generate signature", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", ",", "'fill-800x600'", ")", "# Get the image", "response", "=", "self", ".", "client", ".",...
[ 333, 4 ]
[ 344, 51 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_with_custom_key
(self)
Test that that the key can be changed on the view
Test that that the key can be changed on the view
def test_get_with_custom_key(self): """ Test that that the key can be changed on the view """ # Generate signature signature = generate_signature(self.image.id, 'fill-800x600', key='custom') # Get the image response = self.client.get(reverse('wagtailimages_serve_...
[ "def", "test_get_with_custom_key", "(", "self", ")", ":", "# Generate signature", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", ",", "'fill-800x600'", ",", "key", "=", "'custom'", ")", "# Get the image", "response", "=", "self", "...
[ 368, 4 ]
[ 379, 51 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_with_custom_key_using_default_key
(self)
Test that that the key can be changed on the view This tests that the default key no longer works when the key is changed on the view
Test that that the key can be changed on the view
def test_get_with_custom_key_using_default_key(self): """ Test that that the key can be changed on the view This tests that the default key no longer works when the key is changed on the view """ # Generate signature signature = generate_signature(self.image.id, 'fill-80...
[ "def", "test_get_with_custom_key_using_default_key", "(", "self", ")", ":", "# Generate signature", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", ",", "'fill-800x600'", ")", "# Get the image", "response", "=", "self", ".", "client", "...
[ 381, 4 ]
[ 394, 51 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_invalid_signature
(self)
Test that an invalid signature returns a 403 response
Test that an invalid signature returns a 403 response
def test_get_invalid_signature(self): """ Test that an invalid signature returns a 403 response """ # Generate a signature for the incorrect image id signature = generate_signature(self.image.id + 1, 'fill-800x600') # Get the image response = self.client.get(reve...
[ "def", "test_get_invalid_signature", "(", "self", ")", ":", "# Generate a signature for the incorrect image id", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", "+", "1", ",", "'fill-800x600'", ")", "# Get the image", "response", "=", "se...
[ 396, 4 ]
[ 407, 51 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_invalid_filter_spec
(self)
Test that an invalid filter spec returns a 400 response This is very unlikely to happen in reality. A user would have to create signature for the invalid filter spec which can't be done with Wagtails built in URL generator. We should test it anyway though.
Test that an invalid filter spec returns a 400 response
def test_get_invalid_filter_spec(self): """ Test that an invalid filter spec returns a 400 response This is very unlikely to happen in reality. A user would have to create signature for the invalid filter spec which can't be done with Wagtails built in URL generator. We should t...
[ "def", "test_get_invalid_filter_spec", "(", "self", ")", ":", "# Generate a signature with the invalid filterspec", "signature", "=", "generate_signature", "(", "self", ".", "image", ".", "id", ",", "'bad-filter-spec'", ")", "# Get the image", "response", "=", "self", "...
[ 409, 4 ]
[ 425, 51 ]
python
en
['en', 'error', 'th']
False
TestFrontendServeView.test_get_missing_source_image_file
(self)
Test that a missing image file gives a 410 response When the source image file is missing, it is presumed deleted so we return a 410 "Gone" response.
Test that a missing image file gives a 410 response
def test_get_missing_source_image_file(self): """ Test that a missing image file gives a 410 response When the source image file is missing, it is presumed deleted so we return a 410 "Gone" response. """ # Delete the image file os.remove(self.image.file.path) ...
[ "def", "test_get_missing_source_image_file", "(", "self", ")", ":", "# Delete the image file", "os", ".", "remove", "(", "self", ".", "image", ".", "file", ".", "path", ")", "# Get the image", "signature", "=", "generate_signature", "(", "self", ".", "image", "....
[ 427, 4 ]
[ 442, 51 ]
python
en
['en', 'error', 'th']
False
TestGetImageModel.test_custom_get_image_model
(self)
Test get_image_model with a custom image model
Test get_image_model with a custom image model
def test_custom_get_image_model(self): """Test get_image_model with a custom image model""" self.assertIs(get_image_model(), CustomImage)
[ "def", "test_custom_get_image_model", "(", "self", ")", ":", "self", ".", "assertIs", "(", "get_image_model", "(", ")", ",", "CustomImage", ")" ]
[ 669, 4 ]
[ 671, 53 ]
python
en
['en', 'en', 'en']
True
TestGetImageModel.test_custom_get_image_model_string
(self)
Test get_image_model_string with a custom image model
Test get_image_model_string with a custom image model
def test_custom_get_image_model_string(self): """Test get_image_model_string with a custom image model""" self.assertEqual(get_image_model_string(), 'tests.CustomImage')
[ "def", "test_custom_get_image_model_string", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "get_image_model_string", "(", ")", ",", "'tests.CustomImage'", ")" ]
[ 674, 4 ]
[ 676, 71 ]
python
en
['en', 'en', 'en']
True
TestGetImageModel.test_standard_get_image_model
(self)
Test get_image_model with no WAGTAILIMAGES_IMAGE_MODEL
Test get_image_model with no WAGTAILIMAGES_IMAGE_MODEL
def test_standard_get_image_model(self): """Test get_image_model with no WAGTAILIMAGES_IMAGE_MODEL""" del settings.WAGTAILIMAGES_IMAGE_MODEL from wagtail.images.models import Image self.assertIs(get_image_model(), Image)
[ "def", "test_standard_get_image_model", "(", "self", ")", ":", "del", "settings", ".", "WAGTAILIMAGES_IMAGE_MODEL", "from", "wagtail", ".", "images", ".", "models", "import", "Image", "self", ".", "assertIs", "(", "get_image_model", "(", ")", ",", "Image", ")" ]
[ 679, 4 ]
[ 683, 47 ]
python
en
['en', 'en', 'sw']
True
TestGetImageModel.test_standard_get_image_model_string
(self)
Test get_image_model_STRING with no WAGTAILIMAGES_IMAGE_MODEL
Test get_image_model_STRING with no WAGTAILIMAGES_IMAGE_MODEL
def test_standard_get_image_model_string(self): """Test get_image_model_STRING with no WAGTAILIMAGES_IMAGE_MODEL""" del settings.WAGTAILIMAGES_IMAGE_MODEL self.assertEqual(get_image_model_string(), 'wagtailimages.Image')
[ "def", "test_standard_get_image_model_string", "(", "self", ")", ":", "del", "settings", ".", "WAGTAILIMAGES_IMAGE_MODEL", "self", ".", "assertEqual", "(", "get_image_model_string", "(", ")", ",", "'wagtailimages.Image'", ")" ]
[ 686, 4 ]
[ 689, 73 ]
python
en
['en', 'en', 'sw']
True
TestGetImageModel.test_unknown_get_image_model
(self)
Test get_image_model with an unknown model
Test get_image_model with an unknown model
def test_unknown_get_image_model(self): """Test get_image_model with an unknown model""" with self.assertRaises(ImproperlyConfigured): get_image_model()
[ "def", "test_unknown_get_image_model", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "get_image_model", "(", ")" ]
[ 692, 4 ]
[ 695, 29 ]
python
en
['en', 'en', 'en']
True
TestGetImageModel.test_invalid_get_image_model
(self)
Test get_image_model with an invalid model string
Test get_image_model with an invalid model string
def test_invalid_get_image_model(self): """Test get_image_model with an invalid model string""" with self.assertRaises(ImproperlyConfigured): get_image_model()
[ "def", "test_invalid_get_image_model", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "get_image_model", "(", ")" ]
[ 698, 4 ]
[ 701, 29 ]
python
en
['en', 'en', 'en']
True
get_chooser_context
()
construct context variables needed by the chooser JS
construct context variables needed by the chooser JS
def get_chooser_context(): """construct context variables needed by the chooser JS""" return { 'step': 'chooser', 'error_label': _("Server Error"), 'error_message': _("Report this error to your webmaster with the following information:"), 'tag_autocomplete_url': reverse('wagtaila...
[ "def", "get_chooser_context", "(", ")", ":", "return", "{", "'step'", ":", "'chooser'", ",", "'error_label'", ":", "_", "(", "\"Server Error\"", ")", ",", "'error_message'", ":", "_", "(", "\"Report this error to your webmaster with the following information:\"", ")", ...
[ 19, 0 ]
[ 26, 5 ]
python
en
['en', 'en', 'en']
True
get_document_result_data
(document)
helper function: given a document, return the json data to pass back to the chooser panel
helper function: given a document, return the json data to pass back to the chooser panel
def get_document_result_data(document): """ helper function: given a document, return the json data to pass back to the chooser panel """ return { 'id': document.id, 'title': document.title, 'url': document.url, 'filename': document.filename, 'edit_link': rev...
[ "def", "get_document_result_data", "(", "document", ")", ":", "return", "{", "'id'", ":", "document", ".", "id", ",", "'title'", ":", "document", ".", "title", ",", "'url'", ":", "document", ".", "url", ",", "'filename'", ":", "document", ".", "filename", ...
[ 29, 0 ]
[ 41, 5 ]
python
en
['en', 'error', 'th']
False
module_to_dict
(module, omittable=lambda k: k.startswith('_'))
Converts a module namespace to a Python dictionary.
Converts a module namespace to a Python dictionary.
def module_to_dict(module, omittable=lambda k: k.startswith('_')): """Converts a module namespace to a Python dictionary.""" return {k: repr(v) for k, v in module.__dict__.items() if not omittable(k)}
[ "def", "module_to_dict", "(", "module", ",", "omittable", "=", "lambda", "k", ":", "k", ".", "startswith", "(", "'_'", ")", ")", ":", "return", "{", "k", ":", "repr", "(", "v", ")", "for", "k", ",", "v", "in", "module", ".", "__dict__", ".", "ite...
[ 3, 0 ]
[ 5, 79 ]
python
en
['en', 'en', 'en']
True
multidim_t_pdf
(x, mu, sigma, dof)
Multidimensional t-student density: Args: x: points where to calculate the pdf - array of shape (batch_size, ndim_x) mu: mean - array of shape (ndim_x, ) sigma: scale - array of shape (ndim_x, ) dof = degrees of freedom d: dimension Returns: p: probability...
Multidimensional t-student density:
def multidim_t_pdf(x, mu, sigma, dof): ''' Multidimensional t-student density: Args: x: points where to calculate the pdf - array of shape (batch_size, ndim_x) mu: mean - array of shape (ndim_x, ) sigma: scale - array of shape (ndim_x, ) dof = degrees of freedom d: ...
[ "def", "multidim_t_pdf", "(", "x", ",", "mu", ",", "sigma", ",", "dof", ")", ":", "d", "=", "mu", ".", "shape", "[", "0", "]", "num", "=", "gamma", "(", "(", "d", "+", "dof", ")", "/", "2.0", ")", "denom", "=", "gamma", "(", "dof", "/", "2....
[ 28, 0 ]
[ 48, 12 ]
python
en
['en', 'error', 'th']
False
multidim_t_rvs
(mu, sigma, dof, N=1, random_state=None)
generates random variables of multidmensional (diagonal covariance matrix) t distribution Args: mu = mean - array of shape (ndim_x, )ble sigma: scale - array of shape (ndim_x, ) dof: (numeric) degrees of freedom N: (int) number of observations, return random array will be ...
generates random variables of multidmensional (diagonal covariance matrix) t distribution
def multidim_t_rvs(mu, sigma, dof, N=1, random_state=None): ''' generates random variables of multidmensional (diagonal covariance matrix) t distribution Args: mu = mean - array of shape (ndim_x, )ble sigma: scale - array of shape (ndim_x, ) dof: (numeric) degrees of freedom ...
[ "def", "multidim_t_rvs", "(", "mu", ",", "sigma", ",", "dof", ",", "N", "=", "1", ",", "random_state", "=", "None", ")", ":", "return", "multivariate_t_rvs", "(", "mu", ",", "np", ".", "diag", "(", "sigma", ")", ",", "dof", ",", "N", ",", "random_s...
[ 51, 0 ]
[ 68, 84 ]
python
en
['en', 'ca', 'en']
True
multivariate_t_rvs
(loc, cov, dof=np.inf, n=1, random_state=None)
generates random variables of multivariate t distribution Parameters Args: loc: (array_like) mean of random variable, length determines dimension of random variable cov: (array_like) square array of covariance matrix dof: (numeric) degrees of freedom n: (int) number of ob...
generates random variables of multivariate t distribution Parameters
def multivariate_t_rvs(loc, cov, dof=np.inf, n=1, random_state=None): ''' generates random variables of multivariate t distribution Parameters Args: loc: (array_like) mean of random variable, length determines dimension of random variable cov: (array_like) square array of covariance m...
[ "def", "multivariate_t_rvs", "(", "loc", ",", "cov", ",", "dof", "=", "np", ".", "inf", ",", "n", "=", "1", ",", "random_state", "=", "None", ")", ":", "if", "random_state", "is", "None", ":", "random_state", "=", "np", ".", "random", ".", "RandomSta...
[ 70, 0 ]
[ 95, 40 ]
python
en
['en', 'sv', 'en']
True
contextmanager
(func)
@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <b...
@contextmanager decorator.
def contextmanager(func): """@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<argument...
[ "def", "contextmanager", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "helper", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "return", "_GeneratorContextManager", "(", "func", ",", "args", ",", "kwds", ")", "return", "helper" ]
[ 184, 0 ]
[ 215, 17 ]
python
da
['da', 'su', 'it']
False
AbstractContextManager.__enter__
(self)
Return `self` upon entering the runtime context.
Return `self` upon entering the runtime context.
def __enter__(self): """Return `self` upon entering the runtime context.""" return self
[ "def", "__enter__", "(", "self", ")", ":", "return", "self" ]
[ 55, 4 ]
[ 57, 19 ]
python
en
['en', 'en', 'en']
True
AbstractContextManager.__exit__
(self, exc_type, exc_value, traceback)
Raise any exception triggered within the runtime context.
Raise any exception triggered within the runtime context.
def __exit__(self, exc_type, exc_value, traceback): """Raise any exception triggered within the runtime context.""" return None
[ "def", "__exit__", "(", "self", ",", "exc_type", ",", "exc_value", ",", "traceback", ")", ":", "return", "None" ]
[ 60, 4 ]
[ 62, 19 ]
python
en
['en', 'en', 'en']
True
AbstractContextManager.__subclasshook__
(cls, C)
Check whether subclass is considered a subclass of this ABC.
Check whether subclass is considered a subclass of this ABC.
def __subclasshook__(cls, C): """Check whether subclass is considered a subclass of this ABC.""" if cls is AbstractContextManager: return _check_methods(C, "__enter__", "__exit__") return NotImplemented
[ "def", "__subclasshook__", "(", "cls", ",", "C", ")", ":", "if", "cls", "is", "AbstractContextManager", ":", "return", "_check_methods", "(", "C", ",", "\"__enter__\"", ",", "\"__exit__\"", ")", "return", "NotImplemented" ]
[ 65, 4 ]
[ 69, 29 ]
python
en
['en', 'en', 'en']
True
ContextDecorator.refresh_cm
(self)
Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decorators via implicit recrea...
Returns the context manager used to actually wrap the call to the decorated function.
def refresh_cm(self): """Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decor...
[ "def", "refresh_cm", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"refresh_cm was never added to the standard library\"", ",", "DeprecationWarning", ")", "return", "self", ".", "_recreate_cm", "(", ")" ]
[ 75, 4 ]
[ 90, 34 ]
python
en
['en', 'en', 'en']
True
ContextDecorator._recreate_cm
(self)
Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11647 for details.
Return a recreated instance of self.
def _recreate_cm(self): """Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11...
[ "def", "_recreate_cm", "(", "self", ")", ":", "return", "self" ]
[ 92, 4 ]
[ 102, 19 ]
python
en
['en', 'en', 'en']
True
ExitStack.pop_all
(self)
Preserve the context stack by transferring it to a new instance
Preserve the context stack by transferring it to a new instance
def pop_all(self): """Preserve the context stack by transferring it to a new instance""" new_stack = type(self)() new_stack._exit_callbacks = self._exit_callbacks self._exit_callbacks = deque() return new_stack
[ "def", "pop_all", "(", "self", ")", ":", "new_stack", "=", "type", "(", "self", ")", "(", ")", "new_stack", ".", "_exit_callbacks", "=", "self", ".", "_exit_callbacks", "self", ".", "_exit_callbacks", "=", "deque", "(", ")", "return", "new_stack" ]
[ 385, 4 ]
[ 390, 24 ]
python
en
['en', 'en', 'en']
True
ExitStack._push_cm_exit
(self, cm, cm_exit)
Helper to correctly register callbacks to __exit__ methods
Helper to correctly register callbacks to __exit__ methods
def _push_cm_exit(self, cm, cm_exit): """Helper to correctly register callbacks to __exit__ methods""" def _exit_wrapper(*exc_details): return cm_exit(cm, *exc_details) _exit_wrapper.__self__ = cm self.push(_exit_wrapper)
[ "def", "_push_cm_exit", "(", "self", ",", "cm", ",", "cm_exit", ")", ":", "def", "_exit_wrapper", "(", "*", "exc_details", ")", ":", "return", "cm_exit", "(", "cm", ",", "*", "exc_details", ")", "_exit_wrapper", ".", "__self__", "=", "cm", "self", ".", ...
[ 392, 4 ]
[ 397, 32 ]
python
en
['en', 'en', 'en']
True
ExitStack.push
(self, exit)
Registers a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself)
Registers a callback with the standard __exit__ method signature
def push(self, exit): """Registers a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself) """ # We ...
[ "def", "push", "(", "self", ",", "exit", ")", ":", "# We use an unbound method rather than a bound method to follow", "# the standard lookup behaviour for special methods", "_cb_type", "=", "_get_type", "(", "exit", ")", "try", ":", "exit_method", "=", "_cb_type", ".", "_...
[ 399, 4 ]
[ 417, 19 ]
python
en
['en', 'en', 'en']
True
ExitStack.callback
(self, callback, *args, **kwds)
Registers an arbitrary callback and arguments. Cannot suppress exceptions.
Registers an arbitrary callback and arguments.
def callback(self, callback, *args, **kwds): """Registers an arbitrary callback and arguments. Cannot suppress exceptions. """ def _exit_wrapper(exc_type, exc, tb): callback(*args, **kwds) # We changed the signature, so using @wraps is not appropriate, but # ...
[ "def", "callback", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "def", "_exit_wrapper", "(", "exc_type", ",", "exc", ",", "tb", ")", ":", "callback", "(", "*", "args", ",", "*", "*", "kwds", ")", "# We changed th...
[ 419, 4 ]
[ 430, 23 ]
python
en
['en', 'en', 'en']
True
ExitStack.enter_context
(self, cm)
Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method.
Enters the supplied context manager
def enter_context(self, cm): """Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method. """ # We look up the special methods on the type to match the with statement _cm_type = _get_t...
[ "def", "enter_context", "(", "self", ",", "cm", ")", ":", "# We look up the special methods on the type to match the with statement", "_cm_type", "=", "_get_type", "(", "cm", ")", "_exit", "=", "_cm_type", ".", "__exit__", "result", "=", "_cm_type", ".", "__enter__", ...
[ 432, 4 ]
[ 443, 21 ]
python
en
['en', 'en', 'en']
True