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
Locator.convert_url_to_download_info
(self, url, project_name)
See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page). If it is, a dictionary is returned with keys "name", "version", "filename" and "url"; otherwise, None is returned.
See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page).
def convert_url_to_download_info(self, url, project_name): """ See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page). If it is, a dictionary is returned with keys "name", "version", "filename" and "url"; otherwise, No...
[ "def", "convert_url_to_download_info", "(", "self", ",", "url", ",", "project_name", ")", ":", "def", "same_project", "(", "name1", ",", "name2", ")", ":", "return", "normalize_name", "(", "name1", ")", "==", "normalize_name", "(", "name2", ")", "result", "=...
[ 230, 4 ]
[ 302, 21 ]
python
en
['en', 'error', 'th']
False
Locator._get_digest
(self, info)
Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5.
Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'.
def _get_digest(self, info): """ Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5. """ result = None if '...
[ "def", "_get_digest", "(", "self", ",", "info", ")", ":", "result", "=", "None", "if", "'digests'", "in", "info", ":", "digests", "=", "info", "[", "'digests'", "]", "for", "algo", "in", "(", "'sha256'", ",", "'md5'", ")", ":", "if", "algo", "in", ...
[ 304, 4 ]
[ 325, 21 ]
python
en
['en', 'error', 'th']
False
Locator._update_version_data
(self, result, info)
Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution.
Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution.
def _update_version_data(self, result, info): """ Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution. """ name = inf...
[ "def", "_update_version_data", "(", "self", ",", "result", ",", "info", ")", ":", "name", "=", "info", ".", "pop", "(", "'name'", ")", "version", "=", "info", ".", "pop", "(", "'version'", ")", "if", "version", "in", "result", ":", "dist", "=", "resu...
[ 327, 4 ]
[ 348, 30 ]
python
en
['en', 'error', 'th']
False
Locator.locate
(self, requirement, prereleases=False)
Find the most recent distribution which matches the given requirement. :param requirement: A requirement of the form 'foo (1.0)' or perhaps 'foo (>= 1.0, < 2.0, != 1.3)' :param prereleases: If ``True``, allow pre-release versions ...
Find the most recent distribution which matches the given requirement.
def locate(self, requirement, prereleases=False): """ Find the most recent distribution which matches the given requirement. :param requirement: A requirement of the form 'foo (1.0)' or perhaps 'foo (>= 1.0, < 2.0, != 1.3)' :param prereleases: If ``Tr...
[ "def", "locate", "(", "self", ",", "requirement", ",", "prereleases", "=", "False", ")", ":", "result", "=", "None", "r", "=", "parse_requirement", "(", "requirement", ")", "if", "r", "is", "None", ":", "# pragma: no cover", "raise", "DistlibException", "(",...
[ 350, 4 ]
[ 407, 21 ]
python
en
['en', 'error', 'th']
False
PyPIRPCLocator.__init__
(self, url, **kwargs)
Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor.
Initialise an instance.
def __init__(self, url, **kwargs): """ Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor. """ super(PyPIRPCLocator, self).__init__(**kwargs) self.base_url = url self.client = ServerProxy(ur...
[ "def", "__init__", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "super", "(", "PyPIRPCLocator", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self", ".", "base_url", "=", "url", "self", ".", "client", "=", "Server...
[ 415, 4 ]
[ 424, 51 ]
python
en
['en', 'error', 'th']
False
PyPIRPCLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ return set(self.client.list_packages())
[ "def", "get_distribution_names", "(", "self", ")", ":", "return", "set", "(", "self", ".", "client", ".", "list_packages", "(", ")", ")" ]
[ 426, 4 ]
[ 430, 47 ]
python
en
['en', 'error', 'th']
False
PyPIJSONLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ raise NotImplementedError('Not available from this locator')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Not available from this locator'", ")" ]
[ 467, 4 ]
[ 471, 68 ]
python
en
['en', 'error', 'th']
False
Page.__init__
(self, data, url)
Initialise an instance with the Unicode page contents and the URL they came from.
Initialise an instance with the Unicode page contents and the URL they came from.
def __init__(self, data, url): """ Initialise an instance with the Unicode page contents and the URL they came from. """ self.data = data self.base_url = self.url = url m = self._base.search(self.data) if m: self.base_url = m.group(1)
[ "def", "__init__", "(", "self", ",", "data", ",", "url", ")", ":", "self", ".", "data", "=", "data", "self", ".", "base_url", "=", "self", ".", "url", "=", "url", "m", "=", "self", ".", "_base", ".", "search", "(", "self", ".", "data", ")", "if...
[ 543, 4 ]
[ 552, 38 ]
python
en
['en', 'error', 'th']
False
Page.links
(self)
Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping.
Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping.
def links(self): """ Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping. """ def clean(url): "Tidy up an URL." ...
[ "def", "links", "(", "self", ")", ":", "def", "clean", "(", "url", ")", ":", "\"Tidy up an URL.\"", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "frag", "=", "urlparse", "(", "url", ")", "return", "urlunparse", "(", "(", "s...
[ 557, 4 ]
[ 582, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator.__init__
(self, url, timeout=None, num_workers=10, **kwargs)
Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, ...
Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, ...
def __init__(self, url, timeout=None, num_workers=10, **kwargs): """ Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). ...
[ "def", "__init__", "(", "self", ",", "url", ",", "timeout", "=", "None", ",", "num_workers", "=", "10", ",", "*", "*", "kwargs", ")", ":", "super", "(", "SimpleScrapingLocator", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self",...
[ 599, 4 ]
[ 624, 35 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._prepare_threads
(self)
Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages).
Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages).
def _prepare_threads(self): """ Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages). """ self._threads = [] for i in range(self.num_workers): t = th...
[ "def", "_prepare_threads", "(", "self", ")", ":", "self", ".", "_threads", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "num_workers", ")", ":", "t", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_fetch", ")", "t...
[ 626, 4 ]
[ 637, 35 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._wait_threads
(self)
Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so.
Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so.
def _wait_threads(self): """ Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so. """ # Note that you need two loops, since you can't say which # thread will get each sentinel for t in self._threads: self._to_fetc...
[ "def", "_wait_threads", "(", "self", ")", ":", "# Note that you need two loops, since you can't say which", "# thread will get each sentinel", "for", "t", "in", "self", ".", "_threads", ":", "self", ".", "_to_fetch", ".", "put", "(", "None", ")", "# sentinel", "for", ...
[ 639, 4 ]
[ 650, 26 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._is_platform_dependent
(self, url)
Does an URL refer to a platform-specific download?
Does an URL refer to a platform-specific download?
def _is_platform_dependent(self, url): """ Does an URL refer to a platform-specific download? """ return self.platform_dependent.search(url)
[ "def", "_is_platform_dependent", "(", "self", ",", "url", ")", ":", "return", "self", ".", "platform_dependent", ".", "search", "(", "url", ")" ]
[ 673, 4 ]
[ 677, 50 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._process_download
(self, url)
See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean value.
See if an URL is a suitable download for a project.
def _process_download(self, url): """ See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean ...
[ "def", "_process_download", "(", "self", ",", "url", ")", ":", "if", "self", ".", "platform_check", "and", "self", ".", "_is_platform_dependent", "(", "url", ")", ":", "info", "=", "None", "else", ":", "info", "=", "self", ".", "convert_url_to_download_info"...
[ 679, 4 ]
[ 697, 19 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._should_queue
(self, link, referrer, rel)
Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping.
Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping.
def _should_queue(self, link, referrer, rel): """ Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping. """ scheme, netloc, path, _, _, _ = urlparse(link) if path.endswith(self.source_extensions + self.bina...
[ "def", "_should_queue", "(", "self", ",", "link", ",", "referrer", ",", "rel", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "_", ",", "_", ",", "_", "=", "urlparse", "(", "link", ")", "if", "path", ".", "endswith", "(", "self", ".", "sour...
[ 699, 4 ]
[ 726, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._fetch
(self)
Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread.
Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping.
def _fetch(self): """ Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread. """ while True: url = self._to_fetch.get() t...
[ "def", "_fetch", "(", "self", ")", ":", "while", "True", ":", "url", "=", "self", ".", "_to_fetch", ".", "get", "(", ")", "try", ":", "if", "url", ":", "page", "=", "self", ".", "get_page", "(", "url", ")", "if", "page", "is", "None", ":", "# e...
[ 728, 4 ]
[ 759, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator.get_page
(self, url)
Get the HTML for an URL, possibly from an in-memory cache. XXX TODO Note: this cache is never actually cleared. It's assumed that the data won't get stale over the lifetime of a locator instance (not necessarily true for the default_locator).
Get the HTML for an URL, possibly from an in-memory cache.
def get_page(self, url): """ Get the HTML for an URL, possibly from an in-memory cache. XXX TODO Note: this cache is never actually cleared. It's assumed that the data won't get stale over the lifetime of a locator instance (not necessarily true for the default_locator). ...
[ "def", "get_page", "(", "self", ",", "url", ")", ":", "# http://peak.telecommunity.com/DevCenter/EasyInstall#package-index-api", "scheme", ",", "netloc", ",", "path", ",", "_", ",", "_", ",", "_", "=", "urlparse", "(", "url", ")", "if", "scheme", "==", "'file'...
[ 761, 4 ]
[ 818, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ result = set() page = self.get_page(self.base_url) if not page: raise DistlibException('Unable to get %s' % self.base_url) for match in self._distname_re...
[ "def", "get_distribution_names", "(", "self", ")", ":", "result", "=", "set", "(", ")", "page", "=", "self", ".", "get_page", "(", "self", ".", "base_url", ")", "if", "not", "page", ":", "raise", "DistlibException", "(", "'Unable to get %s'", "%", "self", ...
[ 822, 4 ]
[ 832, 21 ]
python
en
['en', 'error', 'th']
False
DirectoryLocator.__init__
(self, path, **kwargs)
Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are recursed into. If False,...
Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are recursed into. If False,...
def __init__(self, path, **kwargs): """ Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are ...
[ "def", "__init__", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "self", ".", "recursive", "=", "kwargs", ".", "pop", "(", "'recursive'", ",", "True", ")", "super", "(", "DirectoryLocator", ",", "self", ")", ".", "__init__", "(", "*", ...
[ 839, 4 ]
[ 854, 28 ]
python
en
['en', 'error', 'th']
False
DirectoryLocator.should_include
(self, filename, parent)
Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation.
Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation.
def should_include(self, filename, parent): """ Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation. """ return filename.endswith(sel...
[ "def", "should_include", "(", "self", ",", "filename", ",", "parent", ")", ":", "return", "filename", ".", "endswith", "(", "self", ".", "downloadable_extensions", ")" ]
[ 856, 4 ]
[ 862, 62 ]
python
en
['en', 'error', 'th']
False
DirectoryLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ result = set() for root, dirs, files in os.walk(self.base_dir): for fn in files: if self.should_include(fn, root): fn = os.path.join(...
[ "def", "get_distribution_names", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "base_dir", ")", ":", "for", "fn", "in", "files", ":", "if", "self", ".", ...
[ 880, 4 ]
[ 897, 21 ]
python
en
['en', 'error', 'th']
False
JSONLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ raise NotImplementedError('Not available from this locator')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Not available from this locator'", ")" ]
[ 906, 4 ]
[ 910, 68 ]
python
en
['en', 'error', 'th']
False
DistPathLocator.__init__
(self, distpath, **kwargs)
Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search.
Initialise an instance.
def __init__(self, distpath, **kwargs): """ Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search. """ super(DistPathLocator, self).__init__(**kwargs) assert isinstance(distpath, DistributionPath) self.distpath = distpath
[ "def", "__init__", "(", "self", ",", "distpath", ",", "*", "*", "kwargs", ")", ":", "super", "(", "DistPathLocator", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "assert", "isinstance", "(", "distpath", ",", "DistributionPath", ")", ...
[ 942, 4 ]
[ 950, 32 ]
python
en
['en', 'error', 'th']
False
AggregatingLocator.__init__
(self, *locators, **kwargs)
Initialise an instance. :param locators: The list of locators to search. :param kwargs: Passed to the superclass constructor, except for: * merge - if False (the default), the first successful search from any of the locator...
Initialise an instance.
def __init__(self, *locators, **kwargs): """ Initialise an instance. :param locators: The list of locators to search. :param kwargs: Passed to the superclass constructor, except for: * merge - if False (the default), the first successful ...
[ "def", "__init__", "(", "self", ",", "*", "locators", ",", "*", "*", "kwargs", ")", ":", "self", ".", "merge", "=", "kwargs", ".", "pop", "(", "'merge'", ",", "False", ")", "self", ".", "locators", "=", "locators", "super", "(", "AggregatingLocator", ...
[ 969, 4 ]
[ 983, 58 ]
python
en
['en', 'error', 'th']
False
AggregatingLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ result = set() for locator in self.locators: try: result |= locator.get_distribution_names() except NotImplementedError: pass...
[ "def", "get_distribution_names", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "locator", "in", "self", ".", "locators", ":", "try", ":", "result", "|=", "locator", ".", "get_distribution_names", "(", ")", "except", "NotImplementedError", ":"...
[ 1041, 4 ]
[ 1051, 21 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.__init__
(self, locator=None)
Initialise an instance, using the specified locator to locate distributions.
Initialise an instance, using the specified locator to locate distributions.
def __init__(self, locator=None): """ Initialise an instance, using the specified locator to locate distributions. """ self.locator = locator or default_locator self.scheme = get_scheme(self.locator.scheme)
[ "def", "__init__", "(", "self", ",", "locator", "=", "None", ")", ":", "self", ".", "locator", "=", "locator", "or", "default_locator", "self", ".", "scheme", "=", "get_scheme", "(", "self", ".", "locator", ".", "scheme", ")" ]
[ 1072, 4 ]
[ 1078, 53 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.add_distribution
(self, dist)
Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add.
Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add.
def add_distribution(self, dist): """ Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add. """ logger.debug('adding distribution %s', dist) name = dist.key self.dists_by_name...
[ "def", "add_distribution", "(", "self", ",", "dist", ")", ":", "logger", ".", "debug", "(", "'adding distribution %s'", ",", "dist", ")", "name", "=", "dist", ".", "key", "self", ".", "dists_by_name", "[", "name", "]", "=", "dist", "self", ".", "dists", ...
[ 1080, 4 ]
[ 1093, 70 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.remove_distribution
(self, dist)
Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove.
Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove.
def remove_distribution(self, dist): """ Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove. """ logger.debug('removing distribution %s', dist) name = dist.key del s...
[ "def", "remove_distribution", "(", "self", ",", "dist", ")", ":", "logger", ".", "debug", "(", "'removing distribution %s'", ",", "dist", ")", "name", "=", "dist", ".", "key", "del", "self", ".", "dists_by_name", "[", "name", "]", "del", "self", ".", "di...
[ 1095, 4 ]
[ 1111, 39 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.get_matcher
(self, reqt)
Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`).
Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`).
def get_matcher(self, reqt): """ Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`). """ try: matcher = self.scheme.matcher...
[ "def", "get_matcher", "(", "self", ",", "reqt", ")", ":", "try", ":", "matcher", "=", "self", ".", "scheme", ".", "matcher", "(", "reqt", ")", "except", "UnsupportedVersionError", ":", "# pragma: no cover", "# XXX compat-mode if cannot read the version", "name", "...
[ 1113, 4 ]
[ 1127, 22 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.find_providers
(self, reqt)
Find the distributions which can fulfill a requirement. :param reqt: The requirement. :type reqt: str :return: A set of distribution which can fulfill the requirement.
Find the distributions which can fulfill a requirement.
def find_providers(self, reqt): """ Find the distributions which can fulfill a requirement. :param reqt: The requirement. :type reqt: str :return: A set of distribution which can fulfill the requirement. """ matcher = self.get_matcher(reqt) name = matche...
[ "def", "find_providers", "(", "self", ",", "reqt", ")", ":", "matcher", "=", "self", ".", "get_matcher", "(", "reqt", ")", "name", "=", "matcher", ".", "key", "# case-insensitive", "result", "=", "set", "(", ")", "provided", "=", "self", ".", "provided",...
[ 1129, 4 ]
[ 1151, 21 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.try_to_replace
(self, provider, other, problems)
Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must meet all the requirements which ``other`` fulfills. ...
Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1).
def try_to_replace(self, provider, other, problems): """ Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must ...
[ "def", "try_to_replace", "(", "self", ",", "provider", ",", "other", ",", "problems", ")", ":", "rlist", "=", "self", ".", "reqts", "[", "other", "]", "unmatched", "=", "set", "(", ")", "for", "s", "in", "rlist", ":", "matcher", "=", "self", ".", "...
[ 1153, 4 ]
[ 1191, 21 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.find
(self, requirement, meta_extras=None, prereleases=False)
Find a distribution and all distributions it depends on. :param requirement: The requirement specifying the distribution to find, or a Distribution instance. :param meta_extras: A list of meta extras such as :test:, :build: and so on. ...
Find a distribution and all distributions it depends on.
def find(self, requirement, meta_extras=None, prereleases=False): """ Find a distribution and all distributions it depends on. :param requirement: The requirement specifying the distribution to find, or a Distribution instance. :param meta_extras: A list of m...
[ "def", "find", "(", "self", ",", "requirement", ",", "meta_extras", "=", "None", ",", "prereleases", "=", "False", ")", ":", "self", ".", "provided", "=", "{", "}", "self", ".", "dists", "=", "{", "}", "self", ".", "dists_by_name", "=", "{", "}", "...
[ 1193, 4 ]
[ 1301, 30 ]
python
en
['en', 'error', 'th']
False
parse_tag
(tag)
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances. Returning a set is required due to the possibility that the tag is a compressed tag set.
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
def parse_tag(tag): # type: (str) -> FrozenSet[Tag] """ Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances. Returning a set is required due to the possibility that the tag is a compressed tag set. """ tags = set() interpreters, abis, platforms = tag.split("-...
[ "def", "parse_tag", "(", "tag", ")", ":", "# type: (str) -> FrozenSet[Tag]", "tags", "=", "set", "(", ")", "interpreters", ",", "abis", ",", "platforms", "=", "tag", ".", "split", "(", "\"-\"", ")", "for", "interpreter", "in", "interpreters", ".", "split", ...
[ 139, 0 ]
[ 153, 26 ]
python
en
['en', 'error', 'th']
False
_warn_keyword_parameter
(func_name, kwargs)
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
def _warn_keyword_parameter(func_name, kwargs): # type: (str, Dict[str, bool]) -> bool """ Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only. """ if not kwargs: return False elif len(kwargs) > 1 or "warn" not in kwargs: kwargs.pop("warn", None) ...
[ "def", "_warn_keyword_parameter", "(", "func_name", ",", "kwargs", ")", ":", "# type: (str, Dict[str, bool]) -> bool", "if", "not", "kwargs", ":", "return", "False", "elif", "len", "(", "kwargs", ")", ">", "1", "or", "\"warn\"", "not", "in", "kwargs", ":", "kw...
[ 156, 0 ]
[ 169, 25 ]
python
en
['en', 'error', 'th']
False
_abi3_applies
(python_version)
Determine if the Python version supports abi3. PEP 384 was first implemented in Python 3.2.
Determine if the Python version supports abi3.
def _abi3_applies(python_version): # type: (PythonVersion) -> bool """ Determine if the Python version supports abi3. PEP 384 was first implemented in Python 3.2. """ return len(python_version) > 1 and tuple(python_version) >= (3, 2)
[ "def", "_abi3_applies", "(", "python_version", ")", ":", "# type: (PythonVersion) -> bool", "return", "len", "(", "python_version", ")", ">", "1", "and", "tuple", "(", "python_version", ")", ">=", "(", "3", ",", "2", ")" ]
[ 187, 0 ]
[ 194, 70 ]
python
en
['en', 'error', 'th']
False
cpython_tags
( python_version=None, # type: Optional[PythonVersion] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool )
Yields the tags for a CPython interpreter. The tags consist of: - cp<python_version>-<abi>-<platform> - cp<python_version>-abi3-<platform> - cp<python_version>-none-<platform> - cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2. If python_version only speci...
Yields the tags for a CPython interpreter.
def cpython_tags( python_version=None, # type: Optional[PythonVersion] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool ): # type: (...) -> Iterator[Tag] """ Yields the tags for a CPython interpreter. The tags consist o...
[ "def", "cpython_tags", "(", "python_version", "=", "None", ",", "# type: Optional[PythonVersion]", "abis", "=", "None", ",", "# type: Optional[Iterable[str]]", "platforms", "=", "None", ",", "# type: Optional[Iterable[str]]", "*", "*", "kwargs", "# type: bool", ")", ":"...
[ 234, 0 ]
[ 291, 57 ]
python
en
['en', 'error', 'th']
False
generic_tags
( interpreter=None, # type: Optional[str] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool )
Yields the tags for a generic interpreter. The tags consist of: - <interpreter>-<abi>-<platform> The "none" ABI will be added if it was not explicitly provided.
Yields the tags for a generic interpreter.
def generic_tags( interpreter=None, # type: Optional[str] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool ): # type: (...) -> Iterator[Tag] """ Yields the tags for a generic interpreter. The tags consist of: - <int...
[ "def", "generic_tags", "(", "interpreter", "=", "None", ",", "# type: Optional[str]", "abis", "=", "None", ",", "# type: Optional[Iterable[str]]", "platforms", "=", "None", ",", "# type: Optional[Iterable[str]]", "*", "*", "kwargs", "# type: bool", ")", ":", "# type: ...
[ 301, 0 ]
[ 329, 50 ]
python
en
['en', 'error', 'th']
False
_py_interpreter_range
(py_version)
Yields Python versions in descending order. After the latest version, the major-only version will be yielded, and then all previous versions of that major version.
Yields Python versions in descending order.
def _py_interpreter_range(py_version): # type: (PythonVersion) -> Iterator[str] """ Yields Python versions in descending order. After the latest version, the major-only version will be yielded, and then all previous versions of that major version. """ if len(py_version) > 1: yield "...
[ "def", "_py_interpreter_range", "(", "py_version", ")", ":", "# type: (PythonVersion) -> Iterator[str]", "if", "len", "(", "py_version", ")", ">", "1", ":", "yield", "\"py{version}\"", ".", "format", "(", "version", "=", "_version_nodot", "(", "py_version", "[", "...
[ 332, 0 ]
[ 345, 86 ]
python
en
['en', 'error', 'th']
False
compatible_tags
( python_version=None, # type: Optional[PythonVersion] interpreter=None, # type: Optional[str] platforms=None, # type: Optional[Iterable[str]] )
Yields the sequence of tags that are compatible with a specific version of Python. The tags consist of: - py*-none-<platform> - <interpreter>-none-any # ... if `interpreter` is provided. - py*-none-any
Yields the sequence of tags that are compatible with a specific version of Python.
def compatible_tags( python_version=None, # type: Optional[PythonVersion] interpreter=None, # type: Optional[str] platforms=None, # type: Optional[Iterable[str]] ): # type: (...) -> Iterator[Tag] """ Yields the sequence of tags that are compatible with a specific version of Python. The t...
[ "def", "compatible_tags", "(", "python_version", "=", "None", ",", "# type: Optional[PythonVersion]", "interpreter", "=", "None", ",", "# type: Optional[str]", "platforms", "=", "None", ",", "# type: Optional[Iterable[str]]", ")", ":", "# type: (...) -> Iterator[Tag]", "if"...
[ 348, 0 ]
[ 371, 41 ]
python
en
['en', 'error', 'th']
False
mac_platforms
(version=None, arch=None)
Yields the platform tags for a macOS system. The `version` parameter is a two-item tuple specifying the macOS version to generate platform tags for. The `arch` parameter is the CPU architecture to generate platform tags for. Both parameters default to the appropriate value for the current system. ...
Yields the platform tags for a macOS system.
def mac_platforms(version=None, arch=None): # type: (Optional[MacVersion], Optional[str]) -> Iterator[str] """ Yields the platform tags for a macOS system. The `version` parameter is a two-item tuple specifying the macOS version to generate platform tags for. The `arch` parameter is the CPU archite...
[ "def", "mac_platforms", "(", "version", "=", "None", ",", "arch", "=", "None", ")", ":", "# type: (Optional[MacVersion], Optional[str]) -> Iterator[str]", "version_str", ",", "_", ",", "cpu_arch", "=", "platform", ".", "mac_ver", "(", ")", "# type: ignore", "if", ...
[ 418, 0 ]
[ 472, 17 ]
python
en
['en', 'error', 'th']
False
_glibc_version_string_confstr
()
Primary implementation of glibc_version_string using os.confstr.
Primary implementation of glibc_version_string using os.confstr.
def _glibc_version_string_confstr(): # type: () -> Optional[str] """ Primary implementation of glibc_version_string using os.confstr. """ # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely # to be broken or missing. This strategy is used in the standard library # platf...
[ "def", "_glibc_version_string_confstr", "(", ")", ":", "# type: () -> Optional[str]", "# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely", "# to be broken or missing. This strategy is used in the standard library", "# platform module.", "# https://github.com/python/cpython/...
[ 512, 0 ]
[ 531, 18 ]
python
en
['en', 'error', 'th']
False
_glibc_version_string_ctypes
()
Fallback implementation of glibc_version_string using ctypes.
Fallback implementation of glibc_version_string using ctypes.
def _glibc_version_string_ctypes(): # type: () -> Optional[str] """ Fallback implementation of glibc_version_string using ctypes. """ try: import ctypes except ImportError: return None # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "...
[ "def", "_glibc_version_string_ctypes", "(", ")", ":", "# type: () -> Optional[str]", "try", ":", "import", "ctypes", "except", "ImportError", ":", "return", "None", "# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen", "# manpage says, \"If filename is NULL, then th...
[ 534, 0 ]
[ 577, 22 ]
python
en
['en', 'error', 'th']
False
_platform_tags
()
Provides the platform tags for this installation.
Provides the platform tags for this installation.
def _platform_tags(): # type: () -> Iterator[str] """ Provides the platform tags for this installation. """ if platform.system() == "Darwin": return mac_platforms() elif platform.system() == "Linux": return _linux_platforms() else: return _generic_platforms()
[ "def", "_platform_tags", "(", ")", ":", "# type: () -> Iterator[str]", "if", "platform", ".", "system", "(", ")", "==", "\"Darwin\"", ":", "return", "mac_platforms", "(", ")", "elif", "platform", ".", "system", "(", ")", "==", "\"Linux\"", ":", "return", "_l...
[ 787, 0 ]
[ 797, 35 ]
python
en
['en', 'error', 'th']
False
interpreter_name
()
Returns the name of the running interpreter.
Returns the name of the running interpreter.
def interpreter_name(): # type: () -> str """ Returns the name of the running interpreter. """ try: name = sys.implementation.name # type: ignore except AttributeError: # pragma: no cover # Python 2.7 compatibility. name = platform.python_implementation().lower() re...
[ "def", "interpreter_name", "(", ")", ":", "# type: () -> str", "try", ":", "name", "=", "sys", ".", "implementation", ".", "name", "# type: ignore", "except", "AttributeError", ":", "# pragma: no cover", "# Python 2.7 compatibility.", "name", "=", "platform", ".", "...
[ 800, 0 ]
[ 810, 52 ]
python
en
['en', 'error', 'th']
False
interpreter_version
(**kwargs)
Returns the version of the running interpreter.
Returns the version of the running interpreter.
def interpreter_version(**kwargs): # type: (bool) -> str """ Returns the version of the running interpreter. """ warn = _warn_keyword_parameter("interpreter_version", kwargs) version = _get_config_var("py_version_nodot", warn=warn) if version: version = str(version) else: ...
[ "def", "interpreter_version", "(", "*", "*", "kwargs", ")", ":", "# type: (bool) -> str", "warn", "=", "_warn_keyword_parameter", "(", "\"interpreter_version\"", ",", "kwargs", ")", "version", "=", "_get_config_var", "(", "\"py_version_nodot\"", ",", "warn", "=", "w...
[ 813, 0 ]
[ 824, 18 ]
python
en
['en', 'error', 'th']
False
sys_tags
(**kwargs)
Returns the sequence of tag triples for the running interpreter. The order of the sequence corresponds to priority order for the interpreter, from most to least important.
Returns the sequence of tag triples for the running interpreter.
def sys_tags(**kwargs): # type: (bool) -> Iterator[Tag] """ Returns the sequence of tag triples for the running interpreter. The order of the sequence corresponds to priority order for the interpreter, from most to least important. """ warn = _warn_keyword_parameter("sys_tags", kwargs) ...
[ "def", "sys_tags", "(", "*", "*", "kwargs", ")", ":", "# type: (bool) -> Iterator[Tag]", "warn", "=", "_warn_keyword_parameter", "(", "\"sys_tags\"", ",", "kwargs", ")", "interp_name", "=", "interpreter_name", "(", ")", "if", "interp_name", "==", "\"cp\"", ":", ...
[ 832, 0 ]
[ 851, 17 ]
python
en
['en', 'error', 'th']
False
WalletActionStore.get_wallet_action
(self, id: int)
Return a wallet action by id
Return a wallet action by id
async def get_wallet_action(self, id: int) -> Optional[WalletAction]: """ Return a wallet action by id """ cursor = await self.db_connection.execute("SELECT * from action_queue WHERE id=?", (id,)) row = await cursor.fetchone() await cursor.close() if row is None...
[ "async", "def", "get_wallet_action", "(", "self", ",", "id", ":", "int", ")", "->", "Optional", "[", "WalletAction", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from action_queue WHERE id=?\"", ",", "(", "id...
[ 53, 4 ]
[ 65, 101 ]
python
en
['en', 'error', 'th']
False
WalletActionStore.create_action
( self, name: str, wallet_id: int, type: int, callback: str, done: bool, data: str, in_transaction: bool )
Creates Wallet Action
Creates Wallet Action
async def create_action( self, name: str, wallet_id: int, type: int, callback: str, done: bool, data: str, in_transaction: bool ): """ Creates Wallet Action """ if not in_transaction: await self.db_wrapper.lock.acquire() try: cursor = await sel...
[ "async", "def", "create_action", "(", "self", ",", "name", ":", "str", ",", "wallet_id", ":", "int", ",", "type", ":", "int", ",", "callback", ":", "str", ",", "done", ":", "bool", ",", "data", ":", "str", ",", "in_transaction", ":", "bool", ")", "...
[ 67, 4 ]
[ 84, 46 ]
python
en
['en', 'error', 'th']
False
WalletActionStore.action_done
(self, action_id: int)
Marks action as done
Marks action as done
async def action_done(self, action_id: int): """ Marks action as done """ action: Optional[WalletAction] = await self.get_wallet_action(action_id) assert action is not None async with self.db_wrapper.lock: cursor = await self.db_connection.execute( ...
[ "async", "def", "action_done", "(", "self", ",", "action_id", ":", "int", ")", ":", "action", ":", "Optional", "[", "WalletAction", "]", "=", "await", "self", ".", "get_wallet_action", "(", "action_id", ")", "assert", "action", "is", "not", "None", "async"...
[ 86, 4 ]
[ 107, 45 ]
python
en
['en', 'error', 'th']
False
WalletActionStore.get_all_pending_actions
(self)
Returns list of all pending action
Returns list of all pending action
async def get_all_pending_actions(self) -> List[WalletAction]: """ Returns list of all pending action """ result: List[WalletAction] = [] cursor = await self.db_connection.execute("SELECT * from action_queue WHERE done=?", (0,)) rows = await cursor.fetchall() awai...
[ "async", "def", "get_all_pending_actions", "(", "self", ")", "->", "List", "[", "WalletAction", "]", ":", "result", ":", "List", "[", "WalletAction", "]", "=", "[", "]", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT *...
[ 109, 4 ]
[ 125, 21 ]
python
en
['en', 'error', 'th']
False
WalletActionStore.get_action_by_id
(self, id)
Return a wallet action by id
Return a wallet action by id
async def get_action_by_id(self, id) -> Optional[WalletAction]: """ Return a wallet action by id """ cursor = await self.db_connection.execute("SELECT * from action_queue WHERE id=?", (id,)) row = await cursor.fetchone() await cursor.close() if row is None: ...
[ "async", "def", "get_action_by_id", "(", "self", ",", "id", ")", "->", "Optional", "[", "WalletAction", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from action_queue WHERE id=?\"", ",", "(", "id", ",", ")", ...
[ 127, 4 ]
[ 139, 101 ]
python
en
['en', 'error', 'th']
False
get_fields_from_path
(model, path)
Given a Django ORM lookup path (possibly over multiple models) Returns the fields in the line, and also the revised lookup path ex., given model=Organization path='project__timeout' returns tuple of fields traversed as well and a corrected path, for special cases we do substitutions...
Given a Django ORM lookup path (possibly over multiple models) Returns the fields in the line, and also the revised lookup path ex., given model=Organization path='project__timeout' returns tuple of fields traversed as well and a corrected path, for special cases we do substitutions...
def get_fields_from_path(model, path): """ Given a Django ORM lookup path (possibly over multiple models) Returns the fields in the line, and also the revised lookup path ex., given model=Organization path='project__timeout' returns tuple of fields traversed as well and a corrected p...
[ "def", "get_fields_from_path", "(", "model", ",", "path", ")", ":", "# Store of all the fields used to detect repeats", "field_list", "=", "[", "]", "new_parts", "=", "[", "]", "for", "name", "in", "path", ".", "split", "(", "'__'", ")", ":", "if", "model", ...
[ 65, 0 ]
[ 116, 43 ]
python
en
['en', 'error', 'th']
False
get_field_from_path
(model, path)
Given a Django ORM lookup path (possibly over multiple models) Returns the last field in the line, and the revised lookup path ex. (<IntegerField for timeout>, 'project__timeout')
Given a Django ORM lookup path (possibly over multiple models) Returns the last field in the line, and the revised lookup path ex. (<IntegerField for timeout>, 'project__timeout')
def get_field_from_path(model, path): """ Given a Django ORM lookup path (possibly over multiple models) Returns the last field in the line, and the revised lookup path ex. (<IntegerField for timeout>, 'project__timeout') """ field_list, new_path = get_fields_from_path(model, path) r...
[ "def", "get_field_from_path", "(", "model", ",", "path", ")", ":", "field_list", ",", "new_path", "=", "get_fields_from_path", "(", "model", ",", "path", ")", "return", "(", "field_list", "[", "-", "1", "]", ",", "new_path", ")" ]
[ 119, 0 ]
[ 127, 37 ]
python
en
['en', 'error', 'th']
False
FieldLookupBackend.get_field_from_lookup
(self, model, lookup)
Method to match return type of single field, if needed.
Method to match return type of single field, if needed.
def get_field_from_lookup(self, model, lookup): '''Method to match return type of single field, if needed.''' field_list, new_lookup = self.get_fields_from_lookup(model, lookup) return (field_list[-1], new_lookup)
[ "def", "get_field_from_lookup", "(", "self", ",", "model", ",", "lookup", ")", ":", "field_list", ",", "new_lookup", "=", "self", ".", "get_fields_from_lookup", "(", "model", ",", "lookup", ")", "return", "(", "field_list", "[", "-", "1", "]", ",", "new_lo...
[ 181, 4 ]
[ 184, 43 ]
python
en
['en', 'en', 'en']
True
_get_prepared_distribution
( req, # type: InstallRequirement req_tracker, # type: RequirementTracker finder, # type: PackageFinder build_isolation, # type: bool )
Prepare a distribution for installation.
Prepare a distribution for installation.
def _get_prepared_distribution( req, # type: InstallRequirement req_tracker, # type: RequirementTracker finder, # type: PackageFinder build_isolation, # type: bool ): # type: (...) -> Distribution """Prepare a distribution for installation.""" abstract_dist = make_distribution_for_instal...
[ "def", "_get_prepared_distribution", "(", "req", ",", "# type: InstallRequirement", "req_tracker", ",", "# type: RequirementTracker", "finder", ",", "# type: PackageFinder", "build_isolation", ",", "# type: bool", ")", ":", "# type: (...) -> Distribution", "abstract_dist", "=",...
[ 77, 0 ]
[ 88, 57 ]
python
it
['it', 'it', 'en']
True
_copy2_ignoring_special_files
(src, dest)
Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory.
Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory.
def _copy2_ignoring_special_files(src, dest): # type: (str, str) -> None """Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory. """ try: copy2_fixed(src, ...
[ "def", "_copy2_ignoring_special_files", "(", "src", ",", "dest", ")", ":", "# type: (str, str) -> None", "try", ":", "copy2_fixed", "(", "src", ",", "dest", ")", "except", "shutil", ".", "SpecialFileError", "as", "e", ":", "# SpecialFileError may be raised due to eith...
[ 136, 0 ]
[ 154, 9 ]
python
en
['en', 'en', 'en']
True
get_file_url
( link, # type: Link download_dir=None, # type: Optional[str] hashes=None # type: Optional[Hashes] )
Get file and optionally check its hash.
Get file and optionally check its hash.
def get_file_url( link, # type: Link download_dir=None, # type: Optional[str] hashes=None # type: Optional[Hashes] ): # type: (...) -> File """Get file and optionally check its hash. """ # If a download dir is specified, is the file already there and valid? already_downloaded_path = N...
[ "def", "get_file_url", "(", "link", ",", "# type: Link", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> File", "# If a download dir is specified, is the file already there and valid?", "a...
[ 189, 0 ]
[ 216, 32 ]
python
en
['en', 'en', 'en']
True
unpack_url
( link, # type: Link location, # type: str download, # type: Downloader download_dir=None, # type: Optional[str] hashes=None, # type: Optional[Hashes] )
Unpack link into location, downloading if required. :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise Has...
Unpack link into location, downloading if required.
def unpack_url( link, # type: Link location, # type: str download, # type: Downloader download_dir=None, # type: Optional[str] hashes=None, # type: Optional[Hashes] ): # type: (...) -> Optional[File] """Unpack link into location, downloading if required. :param hashes: A Hashes obj...
[ "def", "unpack_url", "(", "link", ",", "# type: Link", "location", ",", "# type: str", "download", ",", "# type: Downloader", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) ->...
[ 219, 0 ]
[ 264, 15 ]
python
en
['it', 'en', 'en']
True
_check_download_dir
(link, download_dir, hashes)
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
def _check_download_dir(link, download_dir, hashes): # type: (Link, str, Optional[Hashes]) -> Optional[str] """ Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None """ download_path = os.path.join(download_dir, link.filename) ...
[ "def", "_check_download_dir", "(", "link", ",", "download_dir", ",", "hashes", ")", ":", "# type: (Link, str, Optional[Hashes]) -> Optional[str]", "download_path", "=", "os", ".", "path", ".", "join", "(", "download_dir", ",", "link", ".", "filename", ")", "if", "...
[ 267, 0 ]
[ 290, 24 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._log_preparing_link
(self, req)
Provide context for the requirement being prepared.
Provide context for the requirement being prepared.
def _log_preparing_link(self, req): # type: (InstallRequirement) -> None """Provide context for the requirement being prepared.""" if req.link.is_file and not req.original_link_is_in_wheel_cache: message = "Processing %s" information = str(display_path(req.link.file_path)...
[ "def", "_log_preparing_link", "(", "self", ",", "req", ")", ":", "# type: (InstallRequirement) -> None", "if", "req", ".", "link", ".", "is_file", "and", "not", "req", ".", "original_link_is_in_wheel_cache", ":", "message", "=", "\"Processing %s\"", "information", "...
[ 344, 4 ]
[ 360, 65 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._ensure_link_req_src_dir
(self, req, parallel_builds)
Ensure source_dir of a linked InstallRequirement.
Ensure source_dir of a linked InstallRequirement.
def _ensure_link_req_src_dir(self, req, parallel_builds): # type: (InstallRequirement, bool) -> None """Ensure source_dir of a linked InstallRequirement.""" # Since source_dir is only set for editable requirements. if req.link.is_wheel: # We don't need to unpack wheels, so no...
[ "def", "_ensure_link_req_src_dir", "(", "self", ",", "req", ",", "parallel_builds", ")", ":", "# type: (InstallRequirement, bool) -> None", "# Since source_dir is only set for editable requirements.", "if", "req", ".", "link", ".", "is_wheel", ":", "# We don't need to unpack wh...
[ 362, 4 ]
[ 390, 13 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._fetch_metadata_using_lazy_wheel
(self, link)
Fetch metadata using lazy wheel, if possible.
Fetch metadata using lazy wheel, if possible.
def _fetch_metadata_using_lazy_wheel(self, link): # type: (Link) -> Optional[Distribution] """Fetch metadata using lazy wheel, if possible.""" if not self.use_lazy_wheel: return None if self.require_hashes: logger.debug('Lazy wheel is not used as hash checking is ...
[ "def", "_fetch_metadata_using_lazy_wheel", "(", "self", ",", "link", ")", ":", "# type: (Link) -> Optional[Distribution]", "if", "not", "self", ".", "use_lazy_wheel", ":", "return", "None", "if", "self", ".", "require_hashes", ":", "logger", ".", "debug", "(", "'L...
[ 425, 4 ]
[ 452, 23 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_linked_requirement
(self, req, parallel_builds=False)
Prepare a requirement to be obtained from req.link.
Prepare a requirement to be obtained from req.link.
def prepare_linked_requirement(self, req, parallel_builds=False): # type: (InstallRequirement, bool) -> Distribution """Prepare a requirement to be obtained from req.link.""" assert req.link link = req.link self._log_preparing_link(req) with indent_log(): # Ch...
[ "def", "prepare_linked_requirement", "(", "self", ",", "req", ",", "parallel_builds", "=", "False", ")", ":", "# type: (InstallRequirement, bool) -> Distribution", "assert", "req", ".", "link", "link", "=", "req", ".", "link", "self", ".", "_log_preparing_link", "("...
[ 454, 4 ]
[ 479, 73 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_linked_requirements_more
(self, reqs, parallel_builds=False)
Prepare a linked requirement more, if needed.
Prepare a linked requirement more, if needed.
def prepare_linked_requirements_more(self, reqs, parallel_builds=False): # type: (Iterable[InstallRequirement], bool) -> None """Prepare a linked requirement more, if needed.""" reqs = [req for req in reqs if req.needs_more_preparation] links = [req.link for req in reqs] # Let's...
[ "def", "prepare_linked_requirements_more", "(", "self", ",", "reqs", ",", "parallel_builds", "=", "False", ")", ":", "# type: (Iterable[InstallRequirement], bool) -> None", "reqs", "=", "[", "req", "for", "req", "in", "reqs", "if", "req", ".", "needs_more_preparation"...
[ 481, 4 ]
[ 491, 66 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_editable_requirement
( self, req, # type: InstallRequirement )
Prepare an editable requirement
Prepare an editable requirement
def prepare_editable_requirement( self, req, # type: InstallRequirement ): # type: (...) -> Distribution """Prepare an editable requirement """ assert req.editable, "cannot prepare a non-editable req as editable" logger.info('Obtaining %s', req) wit...
[ "def", "prepare_editable_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", ")", ":", "# type: (...) -> Distribution", "assert", "req", ".", "editable", ",", "\"cannot prepare a non-editable req as editable\"", "logger", ".", "info", "(", "'Obtaining ...
[ 553, 4 ]
[ 580, 19 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_installed_requirement
( self, req, # type: InstallRequirement skip_reason # type: str )
Prepare an already-installed requirement
Prepare an already-installed requirement
def prepare_installed_requirement( self, req, # type: InstallRequirement skip_reason # type: str ): # type: (...) -> Distribution """Prepare an already-installed requirement """ assert req.satisfied_by, "req should have been satisfied but isn't" asse...
[ "def", "prepare_installed_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", "skip_reason", "# type: str", ")", ":", "# type: (...) -> Distribution", "assert", "req", ".", "satisfied_by", ",", "\"req should have been satisfied but isn't\"", "assert", "s...
[ 582, 4 ]
[ 607, 78 ]
python
en
['en', 'en', 'en']
True
FixedRecycleView.on_scrollable_distance
(self, *args)
This method maintains the position in scroll, by using the saved distance_to_top property to adjust the scroll_y property. Only if we are currently scrolled back.
This method maintains the position in scroll, by using the saved distance_to_top property to adjust the scroll_y property. Only if we are currently scrolled back.
def on_scrollable_distance(self, *args): """This method maintains the position in scroll, by using the saved distance_to_top property to adjust the scroll_y property. Only if we are currently scrolled back. """ if self.scroll_y > 0: self.scroll_y = ( (...
[ "def", "on_scrollable_distance", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "scroll_y", ">", "0", ":", "self", ".", "scroll_y", "=", "(", "(", "self", ".", "scrollable_distance", "-", "self", ".", "distance_to_top", ")", "/", "self", "...
[ 96, 4 ]
[ 105, 13 ]
python
en
['en', 'en', 'en']
True
FixedRecycleView.on_scroll_y
(self, *args)
Save the distance_to_top everytime we scroll.
Save the distance_to_top everytime we scroll.
def on_scroll_y(self, *args): """Save the distance_to_top everytime we scroll. """ self.distance_to_top = (1 - self.scroll_y) * self.scrollable_distance
[ "def", "on_scroll_y", "(", "self", ",", "*", "args", ")", ":", "self", ".", "distance_to_top", "=", "(", "1", "-", "self", ".", "scroll_y", ")", "*", "self", ".", "scrollable_distance" ]
[ 107, 4 ]
[ 110, 77 ]
python
en
['en', 'en', 'en']
True
Application.add_log
(self, dt)
Produce random text to append in the log, with the date, we don't want to forget when we babbled incoherently.
Produce random text to append in the log, with the date, we don't want to forget when we babbled incoherently.
def add_log(self, dt): """Produce random text to append in the log, with the date, we don't want to forget when we babbled incoherently. """ self.data.append({ 'index': len(self.data), 'text': f"[{asctime()}]: {''.join(sample(printable, 50))}", 'cached...
[ "def", "add_log", "(", "self", ",", "dt", ")", ":", "self", ".", "data", ".", "append", "(", "{", "'index'", ":", "len", "(", "self", ".", "data", ")", ",", "'text'", ":", "f\"[{asctime()}]: {''.join(sample(printable, 50))}\"", ",", "'cached_size'", ":", "...
[ 120, 4 ]
[ 128, 10 ]
python
en
['en', 'en', 'en']
True
Application.update_size
(self, index, size)
Maintain the size data for a log entry, so recycleview can adjust the size computation. As a log entry needs to be displayed to compute its size, it's by default considered to be (0, 0) which is a good enough approximation for such a small widget, but you might want do give a better defa...
Maintain the size data for a log entry, so recycleview can adjust the size computation. As a log entry needs to be displayed to compute its size, it's by default considered to be (0, 0) which is a good enough approximation for such a small widget, but you might want do give a better defa...
def update_size(self, index, size): """Maintain the size data for a log entry, so recycleview can adjust the size computation. As a log entry needs to be displayed to compute its size, it's by default considered to be (0, 0) which is a good enough approximation for such a small w...
[ "def", "update_size", "(", "self", ",", "index", ",", "size", ")", ":", "self", ".", "data", "[", "index", "]", "[", "'cached_size'", "]", "=", "size" ]
[ 130, 4 ]
[ 138, 46 ]
python
en
['en', 'en', 'en']
True
default
(request)
Called whenever a request comes in with the correct prefix (eg /admin/) but doesn't actually correspond to a Wagtail view. For authenticated users, it'll raise a 404 error. Anonymous users will be redirected to the login page.
Called whenever a request comes in with the correct prefix (eg /admin/) but doesn't actually correspond to a Wagtail view.
def default(request): """ Called whenever a request comes in with the correct prefix (eg /admin/) but doesn't actually correspond to a Wagtail view. For authenticated users, it'll raise a 404 error. Anonymous users will be redirected to the login page. """ raise Http404
[ "def", "default", "(", "request", ")", ":", "raise", "Http404" ]
[ 193, 0 ]
[ 201, 17 ]
python
en
['en', 'error', 'th']
False
versioned_static
(path)
Wrapper for Django's static file finder to append a cache-busting query parameter that updates on each Wagtail version
Wrapper for Django's static file finder to append a cache-busting query parameter that updates on each Wagtail version
def versioned_static(path): """ Wrapper for Django's static file finder to append a cache-busting query parameter that updates on each Wagtail version """ # An absolute path is returned unchanged (either a full URL, or processed already) if path.startswith(('http://', 'https://', '/')): ...
[ "def", "versioned_static", "(", "path", ")", ":", "# An absolute path is returned unchanged (either a full URL, or processed already)", "if", "path", ".", "startswith", "(", "(", "'http://'", ",", "'https://'", ",", "'/'", ")", ")", ":", "return", "path", "base_url", ...
[ 38, 0 ]
[ 54, 46 ]
python
en
['en', 'error', 'th']
False
install.initialize_options
(self)
Initializes options.
Initializes options.
def initialize_options(self): """Initializes options.""" # High-level options: these select both an installation base # and scheme. self.prefix = None self.exec_prefix = None self.home = None self.user = 0 # These select only the installation base; it's u...
[ "def", "initialize_options", "(", "self", ")", ":", "# High-level options: these select both an installation base", "# and scheme.", "self", ".", "prefix", "=", "None", "self", ".", "exec_prefix", "=", "None", "self", ".", "home", "=", "None", "self", ".", "user", ...
[ 159, 4 ]
[ 228, 26 ]
python
en
['en', 'en', 'en']
False
install.finalize_options
(self)
Finalizes options.
Finalizes options.
def finalize_options(self): """Finalizes options.""" # This method (and its helpers, like 'finalize_unix()', # 'finalize_other()', and 'select_scheme()') is where the default # installation directories for modules, extension modules, and # anything else we care to install from a ...
[ "def", "finalize_options", "(", "self", ")", ":", "# This method (and its helpers, like 'finalize_unix()',", "# 'finalize_other()', and 'select_scheme()') is where the default", "# installation directories for modules, extension modules, and", "# anything else we care to install from a Python modu...
[ 237, 4 ]
[ 382, 62 ]
python
en
['en', 'en', 'en']
False
install.dump_dirs
(self, msg)
Dumps the list of user options.
Dumps the list of user options.
def dump_dirs(self, msg): """Dumps the list of user options.""" if not DEBUG: return from distutils.fancy_getopt import longopt_xlate log.debug(msg + ":") for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": o...
[ "def", "dump_dirs", "(", "self", ",", "msg", ")", ":", "if", "not", "DEBUG", ":", "return", "from", "distutils", ".", "fancy_getopt", "import", "longopt_xlate", "log", ".", "debug", "(", "msg", "+", "\":\"", ")", "for", "opt", "in", "self", ".", "user_...
[ 387, 4 ]
[ 404, 48 ]
python
en
['en', 'en', 'en']
True
install.finalize_unix
(self)
Finalizes options for posix platforms.
Finalizes options for posix platforms.
def finalize_unix(self): """Finalizes options for posix platforms.""" if self.install_base is not None or self.install_platbase is not None: if ((self.install_lib is None and self.install_purelib is None and self.install_platlib is None) or s...
[ "def", "finalize_unix", "(", "self", ")", ":", "if", "self", ".", "install_base", "is", "not", "None", "or", "self", ".", "install_platbase", "is", "not", "None", ":", "if", "(", "(", "self", ".", "install_lib", "is", "None", "and", "self", ".", "insta...
[ 406, 4 ]
[ 444, 45 ]
python
en
['en', 'en', 'en']
True
install.finalize_other
(self)
Finalizes options for non-posix platforms
Finalizes options for non-posix platforms
def finalize_other(self): """Finalizes options for non-posix platforms""" if self.user: if self.install_userbase is None: raise DistutilsPlatformError( "User base directory is not specified") self.install_base = self.install_platbase = self.ins...
[ "def", "finalize_other", "(", "self", ")", ":", "if", "self", ".", "user", ":", "if", "self", ".", "install_userbase", "is", "None", ":", "raise", "DistutilsPlatformError", "(", "\"User base directory is not specified\"", ")", "self", ".", "install_base", "=", "...
[ 446, 4 ]
[ 466, 76 ]
python
en
['en', 'en', 'en']
True
install.select_scheme
(self, name)
Sets the install directories by applying the install schemes.
Sets the install directories by applying the install schemes.
def select_scheme(self, name): """Sets the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! if (hasattr(sys, 'pypy_version_info') and not name.endswith(('_user', '_home'))): if os.name == 'nt': ...
[ "def", "select_scheme", "(", "self", ",", "name", ")", ":", "# it's the caller's problem if they supply a bad name!", "if", "(", "hasattr", "(", "sys", ",", "'pypy_version_info'", ")", "and", "not", "name", ".", "endswith", "(", "(", "'_user'", ",", "'_home'", "...
[ 468, 4 ]
[ 481, 52 ]
python
en
['en', 'en', 'en']
True
install.expand_basedirs
(self)
Calls `os.path.expanduser` on install_base, install_platbase and root.
Calls `os.path.expanduser` on install_base, install_platbase and root.
def expand_basedirs(self): """Calls `os.path.expanduser` on install_base, install_platbase and root.""" self._expand_attrs(['install_base', 'install_platbase', 'root'])
[ "def", "expand_basedirs", "(", "self", ")", ":", "self", ".", "_expand_attrs", "(", "[", "'install_base'", ",", "'install_platbase'", ",", "'root'", "]", ")" ]
[ 492, 4 ]
[ 495, 72 ]
python
en
['en', 'en', 'en']
True
install.expand_dirs
(self)
Calls `os.path.expanduser` on install dirs.
Calls `os.path.expanduser` on install dirs.
def expand_dirs(self): """Calls `os.path.expanduser` on install dirs.""" self._expand_attrs(['install_purelib', 'install_platlib', 'install_lib', 'install_headers', 'install_scripts', 'install_data',])
[ "def", "expand_dirs", "(", "self", ")", ":", "self", ".", "_expand_attrs", "(", "[", "'install_purelib'", ",", "'install_platlib'", ",", "'install_lib'", ",", "'install_headers'", ",", "'install_scripts'", ",", "'install_data'", ",", "]", ")" ]
[ 497, 4 ]
[ 501, 64 ]
python
en
['en', 'en', 'en']
True
install.convert_paths
(self, *names)
Call `convert_path` over `names`.
Call `convert_path` over `names`.
def convert_paths(self, *names): """Call `convert_path` over `names`.""" for name in names: attr = "install_" + name setattr(self, attr, convert_path(getattr(self, attr)))
[ "def", "convert_paths", "(", "self", ",", "*", "names", ")", ":", "for", "name", "in", "names", ":", "attr", "=", "\"install_\"", "+", "name", "setattr", "(", "self", ",", "attr", ",", "convert_path", "(", "getattr", "(", "self", ",", "attr", ")", ")...
[ 503, 4 ]
[ 507, 66 ]
python
en
['en', 'en', 'en']
True
install.handle_extra_path
(self)
Set `path_file` and `extra_dirs` using `extra_path`.
Set `path_file` and `extra_dirs` using `extra_path`.
def handle_extra_path(self): """Set `path_file` and `extra_dirs` using `extra_path`.""" if self.extra_path is None: self.extra_path = self.distribution.extra_path if self.extra_path is not None: log.warn( "Distribution option extra_path is deprecated. " ...
[ "def", "handle_extra_path", "(", "self", ")", ":", "if", "self", ".", "extra_path", "is", "None", ":", "self", ".", "extra_path", "=", "self", ".", "distribution", ".", "extra_path", "if", "self", ".", "extra_path", "is", "not", "None", ":", "log", ".", ...
[ 509, 4 ]
[ 541, 36 ]
python
en
['en', 'en', 'en']
True
install.change_roots
(self, *names)
Change the install directories pointed by name using root.
Change the install directories pointed by name using root.
def change_roots(self, *names): """Change the install directories pointed by name using root.""" for name in names: attr = "install_" + name setattr(self, attr, change_root(self.root, getattr(self, attr)))
[ "def", "change_roots", "(", "self", ",", "*", "names", ")", ":", "for", "name", "in", "names", ":", "attr", "=", "\"install_\"", "+", "name", "setattr", "(", "self", ",", "attr", ",", "change_root", "(", "self", ".", "root", ",", "getattr", "(", "sel...
[ 543, 4 ]
[ 547, 76 ]
python
en
['en', 'en', 'en']
True
install.create_home_path
(self)
Create directories under ~.
Create directories under ~.
def create_home_path(self): """Create directories under ~.""" if not self.user: return home = convert_path(os.path.expanduser("~")) for name, path in self.config_vars.items(): if path.startswith(home) and not os.path.isdir(path): self.debug_print("...
[ "def", "create_home_path", "(", "self", ")", ":", "if", "not", "self", ".", "user", ":", "return", "home", "=", "convert_path", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ")", "for", "name", ",", "path", "in", "self", ".", "config_...
[ 549, 4 ]
[ 557, 40 ]
python
de
['de', 'de', 'en']
True
install.run
(self)
Runs the command.
Runs the command.
def run(self): """Runs the command.""" # Obviously have to build before we can install if not self.skip_build: self.run_command('build') # If we built for any other platform, we can't install. build_plat = self.distribution.get_command_obj('build').plat_name ...
[ "def", "run", "(", "self", ")", ":", "# Obviously have to build before we can install", "if", "not", "self", ".", "skip_build", ":", "self", ".", "run_command", "(", "'build'", ")", "# If we built for any other platform, we can't install.", "build_plat", "=", "self", "....
[ 561, 4 ]
[ 603, 40 ]
python
en
['en', 'it', 'en']
True
install.create_path_file
(self)
Creates the .pth file
Creates the .pth file
def create_path_file(self): """Creates the .pth file""" filename = os.path.join(self.install_libbase, self.path_file + ".pth") if self.install_path_file: self.execute(write_file, (filename, [self.extra_dirs]), ...
[ "def", "create_path_file", "(", "self", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "install_libbase", ",", "self", ".", "path_file", "+", "\".pth\"", ")", "if", "self", ".", "install_path_file", ":", "self", ".", "execut...
[ 605, 4 ]
[ 614, 62 ]
python
en
['en', 'sm', 'en']
True
install.get_outputs
(self)
Assembles the outputs of all the sub-commands.
Assembles the outputs of all the sub-commands.
def get_outputs(self): """Assembles the outputs of all the sub-commands.""" outputs = [] for cmd_name in self.get_sub_commands(): cmd = self.get_finalized_command(cmd_name) # Add the contents of cmd.get_outputs(), ensuring # that outputs doesn't contain duplic...
[ "def", "get_outputs", "(", "self", ")", ":", "outputs", "=", "[", "]", "for", "cmd_name", "in", "self", ".", "get_sub_commands", "(", ")", ":", "cmd", "=", "self", ".", "get_finalized_command", "(", "cmd_name", ")", "# Add the contents of cmd.get_outputs(), ensu...
[ 619, 4 ]
[ 634, 22 ]
python
en
['en', 'en', 'en']
True
install.get_inputs
(self)
Returns the inputs of all the sub-commands
Returns the inputs of all the sub-commands
def get_inputs(self): """Returns the inputs of all the sub-commands""" # XXX gee, this looks familiar ;-( inputs = [] for cmd_name in self.get_sub_commands(): cmd = self.get_finalized_command(cmd_name) inputs.extend(cmd.get_inputs()) return inputs
[ "def", "get_inputs", "(", "self", ")", ":", "# XXX gee, this looks familiar ;-(", "inputs", "=", "[", "]", "for", "cmd_name", "in", "self", ".", "get_sub_commands", "(", ")", ":", "cmd", "=", "self", ".", "get_finalized_command", "(", "cmd_name", ")", "inputs"...
[ 636, 4 ]
[ 644, 21 ]
python
en
['en', 'en', 'en']
True
install.has_lib
(self)
Returns true if the current distribution has any Python modules to install.
Returns true if the current distribution has any Python modules to install.
def has_lib(self): """Returns true if the current distribution has any Python modules to install.""" return (self.distribution.has_pure_modules() or self.distribution.has_ext_modules())
[ "def", "has_lib", "(", "self", ")", ":", "return", "(", "self", ".", "distribution", ".", "has_pure_modules", "(", ")", "or", "self", ".", "distribution", ".", "has_ext_modules", "(", ")", ")" ]
[ 648, 4 ]
[ 652, 52 ]
python
en
['en', 'en', 'en']
True
install.has_headers
(self)
Returns true if the current distribution has any headers to install.
Returns true if the current distribution has any headers to install.
def has_headers(self): """Returns true if the current distribution has any headers to install.""" return self.distribution.has_headers()
[ "def", "has_headers", "(", "self", ")", ":", "return", "self", ".", "distribution", ".", "has_headers", "(", ")" ]
[ 654, 4 ]
[ 657, 46 ]
python
en
['en', 'en', 'en']
True
install.has_scripts
(self)
Returns true if the current distribution has any scripts to. install.
Returns true if the current distribution has any scripts to. install.
def has_scripts(self): """Returns true if the current distribution has any scripts to. install.""" return self.distribution.has_scripts()
[ "def", "has_scripts", "(", "self", ")", ":", "return", "self", ".", "distribution", ".", "has_scripts", "(", ")" ]
[ 659, 4 ]
[ 662, 46 ]
python
en
['en', 'en', 'en']
True
install.has_data
(self)
Returns true if the current distribution has any data to. install.
Returns true if the current distribution has any data to. install.
def has_data(self): """Returns true if the current distribution has any data to. install.""" return self.distribution.has_data_files()
[ "def", "has_data", "(", "self", ")", ":", "return", "self", ".", "distribution", ".", "has_data_files", "(", ")" ]
[ 664, 4 ]
[ 667, 49 ]
python
en
['en', 'en', 'en']
True
escape
(string)
Escape a string such that it can be embedded into a Ninja file without further interpretation.
Escape a string such that it can be embedded into a Ninja file without further interpretation.
def escape(string): """Escape a string such that it can be embedded into a Ninja file without further interpretation.""" assert "\n" not in string, "Ninja syntax does not allow newlines" # We only have one special metacharacter: '$'. return string.replace("$", "$$")
[ "def", "escape", "(", "string", ")", ":", "assert", "\"\\n\"", "not", "in", "string", ",", "\"Ninja syntax does not allow newlines\"", "# We only have one special metacharacter: '$'.", "return", "string", ".", "replace", "(", "\"$\"", ",", "\"$$\"", ")" ]
[ 168, 0 ]
[ 173, 36 ]
python
en
['en', 'en', 'en']
True
Writer._count_dollars_before_index
(self, s, i)
Returns the number of '$' characters right in front of s[i].
Returns the number of '$' characters right in front of s[i].
def _count_dollars_before_index(self, s, i): """Returns the number of '$' characters right in front of s[i].""" dollar_count = 0 dollar_index = i - 1 while dollar_index > 0 and s[dollar_index] == "$": dollar_count += 1 dollar_index -= 1 return dollar_count
[ "def", "_count_dollars_before_index", "(", "self", ",", "s", ",", "i", ")", ":", "dollar_count", "=", "0", "dollar_index", "=", "i", "-", "1", "while", "dollar_index", ">", "0", "and", "s", "[", "dollar_index", "]", "==", "\"$\"", ":", "dollar_count", "+...
[ 114, 4 ]
[ 121, 27 ]
python
en
['en', 'en', 'en']
True
Writer._line
(self, text, indent=0)
Write 'text' word-wrapped at self.width characters.
Write 'text' word-wrapped at self.width characters.
def _line(self, text, indent=0): """Write 'text' word-wrapped at self.width characters.""" leading_space = " " * indent while len(leading_space) + len(text) > self.width: # The text is too wide; wrap if possible. # Find the rightmost space that would obey our width cons...
[ "def", "_line", "(", "self", ",", "text", ",", "indent", "=", "0", ")", ":", "leading_space", "=", "\" \"", "*", "indent", "while", "len", "(", "leading_space", ")", "+", "len", "(", "text", ")", ">", "self", ".", "width", ":", "# The text is too wide...
[ 123, 4 ]
[ 158, 54 ]
python
en
['en', 'en', 'en']
True
items_for_result
(view, result, request)
Generates the actual list of data.
Generates the actual list of data.
def items_for_result(view, result, request): """ Generates the actual list of data. """ modeladmin = view.model_admin for field_name in view.list_display: empty_value_display = modeladmin.get_empty_value_display(field_name) row_classes = ['field-%s' % field_name, 'title'] try...
[ "def", "items_for_result", "(", "view", ",", "result", ",", "request", ")", ":", "modeladmin", "=", "view", ".", "model_admin", "for", "field_name", "in", "view", ".", "list_display", ":", "empty_value_display", "=", "modeladmin", ".", "get_empty_value_display", ...
[ 19, 0 ]
[ 81, 75 ]
python
en
['en', 'error', 'th']
False
result_list
(context)
Displays the headers and data list together
Displays the headers and data list together
def result_list(context): """ Displays the headers and data list together """ view = context['view'] object_list = context['object_list'] headers = list(result_headers(view)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields +...
[ "def", "result_list", "(", "context", ")", ":", "view", "=", "context", "[", "'view'", "]", "object_list", "=", "context", "[", "'object_list'", "]", "headers", "=", "list", "(", "result_headers", "(", "view", ")", ")", "num_sorted_fields", "=", "0", "for"...
[ 91, 0 ]
[ 106, 18 ]
python
en
['en', 'error', 'th']
False
prepopulated_slugs
(context)
Create a list of prepopulated_fields that should render Javascript for the prepopulated fields for modeladmin forms.
Create a list of prepopulated_fields that should render Javascript for the prepopulated fields for modeladmin forms.
def prepopulated_slugs(context): """ Create a list of prepopulated_fields that should render Javascript for the prepopulated fields for modeladmin forms. """ prepopulated_fields = [] if "prepopulated_fields" in context: prepopulated_fields.extend(context["prepopulated_fields"]) prep...
[ "def", "prepopulated_slugs", "(", "context", ")", ":", "prepopulated_fields", "=", "[", "]", "if", "\"prepopulated_fields\"", "in", "context", ":", "prepopulated_fields", ".", "extend", "(", "context", "[", "\"prepopulated_fields\"", "]", ")", "prepopulated_fields_jso...
[ 206, 0 ]
[ 238, 18 ]
python
en
['en', 'error', 'th']
False
autocontrast
(image, cutoff=0, ignore=None, mask=None)
Maximize (normalize) image contrast. This function calculates a histogram of the input image (or mask region), removes ``cutoff`` percent of the lightest and darkest pixels from the histogram, and remaps the image so that the darkest pixel becomes black (0), and the lightest becomes white (255). ...
Maximize (normalize) image contrast. This function calculates a histogram of the input image (or mask region), removes ``cutoff`` percent of the lightest and darkest pixels from the histogram, and remaps the image so that the darkest pixel becomes black (0), and the lightest becomes white (255).
def autocontrast(image, cutoff=0, ignore=None, mask=None): """ Maximize (normalize) image contrast. This function calculates a histogram of the input image (or mask region), removes ``cutoff`` percent of the lightest and darkest pixels from the histogram, and remaps the image so that the darkest pix...
[ "def", "autocontrast", "(", "image", ",", "cutoff", "=", "0", ",", "ignore", "=", "None", ",", "mask", "=", "None", ")", ":", "histogram", "=", "image", ".", "histogram", "(", "mask", ")", "lut", "=", "[", "]", "for", "layer", "in", "range", "(", ...
[ 63, 0 ]
[ 143, 27 ]
python
en
['en', 'error', 'th']
False
colorize
(image, black, white, mid=None, blackpoint=0, whitepoint=255, midpoint=127)
Colorize grayscale image. This function calculates a color wedge which maps all black pixels in the source image to the first color and all white pixels to the second color. If ``mid`` is specified, it uses three-color mapping. The ``black`` and ``white`` arguments should be RGB tuples or color nam...
Colorize grayscale image. This function calculates a color wedge which maps all black pixels in the source image to the first color and all white pixels to the second color. If ``mid`` is specified, it uses three-color mapping. The ``black`` and ``white`` arguments should be RGB tuples or color nam...
def colorize(image, black, white, mid=None, blackpoint=0, whitepoint=255, midpoint=127): """ Colorize grayscale image. This function calculates a color wedge which maps all black pixels in the source image to the first color and all white pixels to the second color. If ``mid`` is specified, it uses ...
[ "def", "colorize", "(", "image", ",", "black", ",", "white", ",", "mid", "=", "None", ",", "blackpoint", "=", "0", ",", "whitepoint", "=", "255", ",", "midpoint", "=", "127", ")", ":", "# Initial asserts", "assert", "image", ".", "mode", "==", "\"L\"",...
[ 146, 0 ]
[ 227, 42 ]
python
en
['en', 'error', 'th']
False