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
get_all_distribution_names
(url=None)
Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names.
Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names.
def get_all_distribution_names(url=None): """ Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. """ if url is None: url = DEFAULT_INDEX client = ServerProxy(url, timeout=3.0) try: return cli...
[ "def", "get_all_distribution_names", "(", "url", "=", "None", ")", ":", "if", "url", "is", "None", ":", "url", "=", "DEFAULT_INDEX", "client", "=", "ServerProxy", "(", "url", ",", "timeout", "=", "3.0", ")", "try", ":", "return", "client", ".", "list_pac...
[ 40, 0 ]
[ 52, 25 ]
python
en
['en', 'error', 'th']
False
Locator.__init__
(self, scheme='default')
Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing d...
Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing d...
def __init__(self, scheme='default'): """ Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` ...
[ "def", "__init__", "(", "self", ",", "scheme", "=", "'default'", ")", ":", "self", ".", "_cache", "=", "{", "}", "self", ".", "scheme", "=", "scheme", "# Because of bugs in some of the handlers on some of the platforms,", "# we use our own opener rather than just using ur...
[ 101, 4 ]
[ 118, 35 ]
python
en
['en', 'error', 'th']
False
Locator.get_errors
(self)
Return any errors which have occurred.
Return any errors which have occurred.
def get_errors(self): """ Return any errors which have occurred. """ result = [] while not self.errors.empty(): # pragma: no cover try: e = self.errors.get(False) result.append(e) except self.errors.Empty: c...
[ "def", "get_errors", "(", "self", ")", ":", "result", "=", "[", "]", "while", "not", "self", ".", "errors", ".", "empty", "(", ")", ":", "# pragma: no cover", "try", ":", "e", "=", "self", ".", "errors", ".", "get", "(", "False", ")", "result", "."...
[ 120, 4 ]
[ 132, 21 ]
python
en
['en', 'error', 'th']
False
Locator.clear_errors
(self)
Clear any errors which may have been logged.
Clear any errors which may have been logged.
def clear_errors(self): """ Clear any errors which may have been logged. """ # Just get the errors and throw them away self.get_errors()
[ "def", "clear_errors", "(", "self", ")", ":", "# Just get the errors and throw them away", "self", ".", "get_errors", "(", ")" ]
[ 134, 4 ]
[ 139, 25 ]
python
en
['en', 'error', 'th']
False
Locator._get_project
(self, name)
For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisfy, otherwise it will be None.
For a given project, get a dictionary mapping available versions to Distribution instances.
def _get_project(self, name): """ For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisf...
[ "def", "_get_project", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'Please implement in the subclass'", ")" ]
[ 152, 4 ]
[ 162, 69 ]
python
en
['en', 'error', 'th']
False
Locator.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('Please implement in the subclass')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Please implement in the subclass'", ")" ]
[ 164, 4 ]
[ 168, 69 ]
python
en
['en', 'error', 'th']
False
Locator.get_project
(self, name)
For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top.
For a given project, get a dictionary mapping available versions to Distribution instances.
def get_project(self, name): """ For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top. """ if self._cache is None: # pragma: no cover ...
[ "def", "get_project", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_cache", "is", "None", ":", "# pragma: no cover", "result", "=", "self", ".", "_get_project", "(", "name", ")", "elif", "name", "in", "self", ".", "_cache", ":", "result", "=...
[ 170, 4 ]
[ 185, 21 ]
python
en
['en', 'error', 'th']
False
Locator.score_url
(self, url)
Give an url a score which can be used to choose preferred URLs for a given project release.
Give an url a score which can be used to choose preferred URLs for a given project release.
def score_url(self, url): """ Give an url a score which can be used to choose preferred URLs for a given project release. """ t = urlparse(url) basename = posixpath.basename(t.path) compatible = True is_wheel = basename.endswith('.whl') is_download...
[ "def", "score_url", "(", "self", ",", "url", ")", ":", "t", "=", "urlparse", "(", "url", ")", "basename", "=", "posixpath", ".", "basename", "(", "t", ".", "path", ")", "compatible", "=", "True", "is_wheel", "=", "basename", ".", "endswith", "(", "'....
[ 187, 4 ]
[ 200, 64 ]
python
en
['en', 'error', 'th']
False
Locator.prefer_url
(self, url1, url2)
Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over those from other locations, wheel compatibili...
Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip).
def prefer_url(self, url1, url2): """ Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over ...
[ "def", "prefer_url", "(", "self", ",", "url1", ",", "url2", ")", ":", "result", "=", "url2", "if", "url1", ":", "s1", "=", "self", ".", "score_url", "(", "url1", ")", "s2", "=", "self", ".", "score_url", "(", "url2", ")", "if", "s1", ">", "s2", ...
[ 202, 4 ]
[ 222, 21 ]
python
en
['en', 'error', 'th']
False
Locator.split_filename
(self, filename, project_name)
Attempt to split a filename in project name, version and Python version.
Attempt to split a filename in project name, version and Python version.
def split_filename(self, filename, project_name): """ Attempt to split a filename in project name, version and Python version. """ return split_filename(filename, project_name)
[ "def", "split_filename", "(", "self", ",", "filename", ",", "project_name", ")", ":", "return", "split_filename", "(", "filename", ",", "project_name", ")" ]
[ 224, 4 ]
[ 228, 53 ]
python
en
['en', 'error', 'th']
False
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", ")" ]
[ 1070, 4 ]
[ 1076, 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", ...
[ 1078, 4 ]
[ 1091, 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...
[ 1093, 4 ]
[ 1109, 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", "...
[ 1111, 4 ]
[ 1125, 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",...
[ 1127, 4 ]
[ 1149, 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", ".", "...
[ 1151, 4 ]
[ 1189, 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", "=", "{", "}", "...
[ 1191, 4 ]
[ 1299, 30 ]
python
en
['en', 'error', 'th']
False
update_or_create_token
(token, vegetariano, notificacao_almoco="11:00", notificacao_jantar="17:00")
Registra device token ou atualiza os seus parametros "last_used" e/ou "vegetariano". Acho que tenho que deixas os valores default do almoco e janta como os originais, para manter as notificacoes dos usuarios que nao atualizarem o app. :param token: token a ser registrado ou atualizado. :param vegetar...
Registra device token ou atualiza os seus parametros "last_used" e/ou "vegetariano".
def update_or_create_token(token, vegetariano, notificacao_almoco="11:00", notificacao_jantar="17:00"): """ Registra device token ou atualiza os seus parametros "last_used" e/ou "vegetariano". Acho que tenho que deixas os valores default do almoco e janta como os originais, para manter as notificacoes dos ...
[ "def", "update_or_create_token", "(", "token", ",", "vegetariano", ",", "notificacao_almoco", "=", "\"11:00\"", ",", "notificacao_jantar", "=", "\"17:00\"", ")", ":", "new_dict", "=", "{", "\"last_used\"", ":", "date", ".", "today", "(", ")", ".", "strftime", ...
[ 74, 0 ]
[ 102, 15 ]
python
en
['en', 'error', 'th']
False
delete_token
(token)
Remove device token do BD (firebase). :param token: token a ser removido. :return: True caso nao haja erros durante o processo.
Remove device token do BD (firebase).
def delete_token(token): """ Remove device token do BD (firebase). :param token: token a ser removido. :return: True caso nao haja erros durante o processo. """ db = setup_firebase() db.child('tokens').child(token).remove() print("Device token {} removido com sucesso.".format(token)) ...
[ "def", "delete_token", "(", "token", ")", ":", "db", "=", "setup_firebase", "(", ")", "db", ".", "child", "(", "'tokens'", ")", ".", "child", "(", "token", ")", ".", "remove", "(", ")", "print", "(", "\"Device token {} removido com sucesso.\"", ".", "forma...
[ 107, 0 ]
[ 119, 15 ]
python
en
['en', 'error', 'th']
False
same_time_with_margin
(hora)
Compara um horario fornecido com o horario atual para decidir se uma notificacao deve ser enviada para o token correspondente a esse horario. Ele leva em consideracao um possivel atraso de ate 3min no heroku scheduler. :param hora: horario a ser verificado :return: booleano dizendo esta proximo o suficien...
Compara um horario fornecido com o horario atual para decidir se uma notificacao deve ser enviada para o token correspondente a esse horario. Ele leva em consideracao um possivel atraso de ate 3min no heroku scheduler.
def same_time_with_margin(hora): """ Compara um horario fornecido com o horario atual para decidir se uma notificacao deve ser enviada para o token correspondente a esse horario. Ele leva em consideracao um possivel atraso de ate 3min no heroku scheduler. :param hora: horario a ser verificado :return: ...
[ "def", "same_time_with_margin", "(", "hora", ")", ":", "if", "hora", "is", "None", ":", "return", "False", "tz", "=", "pytz", ".", "timezone", "(", "'America/Sao_Paulo'", ")", "today", "=", "datetime", ".", "now", "(", "tz", ")", "minutes_today", "=", "i...
[ 126, 0 ]
[ 147, 57 ]
python
en
['en', 'error', 'th']
False
get_device_tokens
(refeicao)
Pega os device tokens no firebase, separa os tradicionais dos vegetarianos e filtra os tokens que devem receber notificacao no momento. Lembrando que o heroku scheduler vai rodar o script de notificacao a cada 10min. :return: uma tupla (toks_trad, toks_veg) contendo os tokens tradicionais e vegetarianos. ...
Pega os device tokens no firebase, separa os tradicionais dos vegetarianos e filtra os tokens que devem receber notificacao no momento. Lembrando que o heroku scheduler vai rodar o script de notificacao a cada 10min.
def get_device_tokens(refeicao): """ Pega os device tokens no firebase, separa os tradicionais dos vegetarianos e filtra os tokens que devem receber notificacao no momento. Lembrando que o heroku scheduler vai rodar o script de notificacao a cada 10min. :return: uma tupla (toks_trad, toks_veg) contendo os...
[ "def", "get_device_tokens", "(", "refeicao", ")", ":", "# obtems device tokens dos usuarios registrados", "db", "=", "setup_firebase", "(", ")", "tokens", "=", "db", ".", "child", "(", "'tokens'", ")", ".", "get", "(", ")", ".", "val", "(", ")", "# pprint(\"Al...
[ 151, 0 ]
[ 187, 49 ]
python
en
['en', 'error', 'th']
False
get_notification_objects
(msg_tradicional, msg_vegetariano, tokens_tradicional, tokens_vegetariano)
Instancia os objetos de notificacao utilizados pelo modulo apns2. Para entender mais, olhar a documentacao dessa biblioteca. :param msg_tradicional: mensagem da notificacao do cardapio tradicional. :param msg_vegetariano: mensagem da notificacao do cardapio vegetariano. :return: objetos de notificaca...
def get_notification_objects(msg_tradicional, msg_vegetariano, tokens_tradicional, tokens_vegetariano): """ Instancia os objetos de notificacao utilizados pelo modulo apns2. Para entender mais, olhar a documentacao dessa biblioteca. :param msg_tradicional: mensagem da notificacao do cardapio tradicional. ...
[ "def", "get_notification_objects", "(", "msg_tradicional", ",", "msg_vegetariano", ",", "tokens_tradicional", ",", "tokens_vegetariano", ")", ":", "# cria 2 payloads diferentes para tradicional e vegetariano", "payload_tradicional", "=", "Payload", "(", "alert", "=", "msg_tradi...
[ 191, 0 ]
[ 215, 24 ]
python
en
['en', 'error', 'th']
False
setup_apns_client
(use_sandbox)
Configura um cliente do servico apns2. Para mais informacoes, olhar a documentacao e o codigo dessa biblioteca. :param use_sandbox: :return: um objeto do tipo APNsClient para enviar push notifications.
Configura um cliente do servico apns2. Para mais informacoes, olhar a documentacao e o codigo dessa biblioteca. :param use_sandbox: :return: um objeto do tipo APNsClient para enviar push notifications.
def setup_apns_client(use_sandbox): """ Configura um cliente do servico apns2. Para mais informacoes, olhar a documentacao e o codigo dessa biblioteca. :param use_sandbox: :return: um objeto do tipo APNsClient para enviar push notifications. """ try: apns_key = environment_vars.APNS_PROD...
[ "def", "setup_apns_client", "(", "use_sandbox", ")", ":", "try", ":", "apns_key", "=", "environment_vars", ".", "APNS_PROD_KEY_CONTENT", "f", "=", "open", "(", "'./apns_key.pem'", ",", "'w'", ")", "f", ".", "write", "(", "apns_key", ")", "f", ".", "close", ...
[ 218, 0 ]
[ 242, 17 ]
python
en
['en', 'error', 'th']
False
push_next_notification
(msg_tradicional, msg_vegetariano, refeicao)
Utiliza a biblioteca apns2 para enviar push notifications para os usuarios registrados. :param msg_tradicional: string de notificacao para o cardapio tradicional. :param msg_vegetariano: string de notificacao para o cardapio vegetariano. :return: None
Utiliza a biblioteca apns2 para enviar push notifications para os usuarios registrados.
def push_next_notification(msg_tradicional, msg_vegetariano, refeicao): """ Utiliza a biblioteca apns2 para enviar push notifications para os usuarios registrados. :param msg_tradicional: string de notificacao para o cardapio tradicional. :param msg_vegetariano: string de notificacao para o cardapio v...
[ "def", "push_next_notification", "(", "msg_tradicional", ",", "msg_vegetariano", ",", "refeicao", ")", ":", "# separa tradicional e vegetariano e filtra tokens que querem receber notificacao agora para a refeicao fornecida.", "tokens_tradicional", ",", "tokens_vegetariano", "=", "get_d...
[ 244, 0 ]
[ 285, 66 ]
python
en
['en', 'error', 'th']
False
cardapio_valido
()
Pega o proximo cardapio disponivel e confere se é do dia de hoje. Retorna None quando nao há cardapio disponivel ou quando for fim de semana ou feriado. :return: o proximo cardapio, se for valido, ou None caso contrário.
Pega o proximo cardapio disponivel e confere se é do dia de hoje. Retorna None quando nao há cardapio disponivel ou quando for fim de semana ou feriado.
def cardapio_valido(): """ Pega o proximo cardapio disponivel e confere se é do dia de hoje. Retorna None quando nao há cardapio disponivel ou quando for fim de semana ou feriado. :return: o proximo cardapio, se for valido, ou None caso contrário. """ cardapios = get_all_cardapios() if le...
[ "def", "cardapio_valido", "(", ")", ":", "cardapios", "=", "get_all_cardapios", "(", ")", "if", "len", "(", "cardapios", ")", "==", "0", ":", "return", "None", "prox", "=", "cardapios", "[", "0", "]", "today", "=", "date", ".", "today", "(", ")", "."...
[ 290, 0 ]
[ 311, 19 ]
python
en
['en', 'error', 'th']
False
mandar_proxima_refeicao
(refeicao)
Recebendo a refeicao (almoço ou jantar) a ser enviada, esse metodo cria a string da notificação e chama o método para envia-la caso exista um cardapio valido (dia útil). :param refeicao: string com valor "almoço" ou "jantar", indicando qual a refeicao a ser informada.
Recebendo a refeicao (almoço ou jantar) a ser enviada, esse metodo cria a string da notificação e chama o método para envia-la caso exista um cardapio valido (dia útil).
def mandar_proxima_refeicao(refeicao): """ Recebendo a refeicao (almoço ou jantar) a ser enviada, esse metodo cria a string da notificação e chama o método para envia-la caso exista um cardapio valido (dia útil). :param refeicao: string com valor "almoço" ou "jantar", indicando qual a refeicao a ser i...
[ "def", "mandar_proxima_refeicao", "(", "refeicao", ")", ":", "if", "not", "segunda_a_sexta", "(", ")", ":", "print", "(", "\"Nao deve haver notificação no sábado ou domingo.\")", "", "return", "None", "cardapio", "=", "cardapio_valido", "(", ")", "template", "=", "\...
[ 314, 0 ]
[ 345, 53 ]
python
en
['en', 'error', 'th']
False
testar_notificacao
()
Funcao para testar o envio de notificacoes. TODO: refatorar isso para mandar notificacoes para todos os tokens em development, independente do horario da notificacao.
Funcao para testar o envio de notificacoes.
def testar_notificacao(): """ Funcao para testar o envio de notificacoes. TODO: refatorar isso para mandar notificacoes para todos os tokens em development, independente do horario da notificacao. """ template = "Hoje tem {} no {}." cardapios = get_all_cardapios() cardapio = cardapios[0]...
[ "def", "testar_notificacao", "(", ")", ":", "template", "=", "\"Hoje tem {} no {}.\"", "cardapios", "=", "get_all_cardapios", "(", ")", "cardapio", "=", "cardapios", "[", "0", "]", "tradicional", "=", "template", ".", "format", "(", "cardapio", ".", "almoco", ...
[ 349, 0 ]
[ 374, 62 ]
python
en
['en', 'error', 'th']
False
PostGISGeometryColumns.table_name_col
(cls)
Return the name of the metadata column used to store the feature table name.
Return the name of the metadata column used to store the feature table name.
def table_name_col(cls): """ Return the name of the metadata column used to store the feature table name. """ return 'f_table_name'
[ "def", "table_name_col", "(", "cls", ")", ":", "return", "'f_table_name'" ]
[ 35, 4 ]
[ 40, 29 ]
python
en
['en', 'error', 'th']
False
PostGISGeometryColumns.geom_col_name
(cls)
Return the name of the metadata column used to store the feature geometry column.
Return the name of the metadata column used to store the feature geometry column.
def geom_col_name(cls): """ Return the name of the metadata column used to store the feature geometry column. """ return 'f_geometry_column'
[ "def", "geom_col_name", "(", "cls", ")", ":", "return", "'f_geometry_column'" ]
[ 43, 4 ]
[ 48, 34 ]
python
en
['en', 'error', 'th']
False
Deserializer
(object_list, *, using=DEFAULT_DB_ALIAS, ignorenonexistent=False, **options)
Deserialize simple Python objects back into Django ORM instances. It's expected that you pass the Python objects themselves (instead of a stream or a string) to the constructor
Deserialize simple Python objects back into Django ORM instances.
def Deserializer(object_list, *, using=DEFAULT_DB_ALIAS, ignorenonexistent=False, **options): """ Deserialize simple Python objects back into Django ORM instances. It's expected that you pass the Python objects themselves (instead of a stream or a string) to the constructor """ handle_forward_r...
[ "def", "Deserializer", "(", "object_list", ",", "*", ",", "using", "=", "DEFAULT_DB_ALIAS", ",", "ignorenonexistent", "=", "False", ",", "*", "*", "options", ")", ":", "handle_forward_references", "=", "options", ".", "pop", "(", "'handle_forward_references'", "...
[ 79, 0 ]
[ 148, 69 ]
python
en
['en', 'error', 'th']
False
_get_model
(model_identifier)
Look up a model from an "app_label.model_name" string.
Look up a model from an "app_label.model_name" string.
def _get_model(model_identifier): """Look up a model from an "app_label.model_name" string.""" try: return apps.get_model(model_identifier) except (LookupError, TypeError): raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier)
[ "def", "_get_model", "(", "model_identifier", ")", ":", "try", ":", "return", "apps", ".", "get_model", "(", "model_identifier", ")", "except", "(", "LookupError", ",", "TypeError", ")", ":", "raise", "base", ".", "DeserializationError", "(", "\"Invalid model id...
[ 151, 0 ]
[ 156, 92 ]
python
en
['en', 'en', 'en']
True
Kernel.pred_bias
(self)
閾値の枚数からの推定 :return: 閾値の百分率
閾値の枚数からの推定 :return: 閾値の百分率
def pred_bias(self): """ 閾値の枚数からの推定 :return: 閾値の百分率 """ default = 90 bias = 0.0 IMG_NUM = adjuster = self.params['crawler']['target_num'] if IMG_NUM >= 100: bias += 2.0 adjuster -= IMG_NUM while True: if ...
[ "def", "pred_bias", "(", "self", ")", ":", "default", "=", "90", "bias", "=", "0.0", "IMG_NUM", "=", "adjuster", "=", "self", ".", "params", "[", "'crawler'", "]", "[", "'target_num'", "]", "if", "IMG_NUM", ">=", "100", ":", "bias", "+=", "2.0", "adj...
[ 96, 4 ]
[ 121, 22 ]
python
en
['en', 'error', 'th']
False
Highmap.__init__
(self, **kwargs)
This is the base class for all the charts. The following keywords are accepted: :keyword: **display_container** - default: ``True``
This is the base class for all the charts. The following keywords are accepted: :keyword: **display_container** - default: ``True``
def __init__(self, **kwargs): """ This is the base class for all the charts. The following keywords are accepted: :keyword: **display_container** - default: ``True`` """ # Set the model self.model = self.__class__.__name__ #: The chart model, self.div_nam...
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Set the model", "self", ".", "model", "=", "self", ".", "__class__", ".", "__name__", "#: The chart model,", "self", ".", "div_name", "=", "kwargs", ".", "get", "(", "\"renderTo\"", ",",...
[ 51, 4 ]
[ 169, 41 ]
python
en
['en', 'error', 'th']
False
Highmap.add_JSsource
(self, new_src)
add additional js script source(s)
add additional js script source(s)
def add_JSsource(self, new_src): """add additional js script source(s)""" if isinstance(new_src, list): for h in new_src: self.JSsource.append(h) elif isinstance(new_src, basestring): self.JSsource.append(new_src) else: raise OptionType...
[ "def", "add_JSsource", "(", "self", ",", "new_src", ")", ":", "if", "isinstance", "(", "new_src", ",", "list", ")", ":", "for", "h", "in", "new_src", ":", "self", ".", "JSsource", ".", "append", "(", "h", ")", "elif", "isinstance", "(", "new_src", ",...
[ 178, 4 ]
[ 186, 95 ]
python
en
['en', 'co', 'en']
True
Highmap.add_CSSsource
(self, new_src)
add additional css source(s)
add additional css source(s)
def add_CSSsource(self, new_src): """add additional css source(s)""" if isinstance(new_src, list): for h in new_src: self.CSSsource.append(h) elif isinstance(new_src, basestring): self.CSSsource.append(new_src) else: raise OptionTypeErr...
[ "def", "add_CSSsource", "(", "self", ",", "new_src", ")", ":", "if", "isinstance", "(", "new_src", ",", "list", ")", ":", "for", "h", "in", "new_src", ":", "self", ".", "CSSsource", ".", "append", "(", "h", ")", "elif", "isinstance", "(", "new_src", ...
[ 189, 4 ]
[ 197, 95 ]
python
en
['en', 'en', 'en']
True
Highmap.add_data_set
(self, data, series_type="map", name=None, is_coordinate = False, **kwargs)
set data for series option in highmaps
set data for series option in highmaps
def add_data_set(self, data, series_type="map", name=None, is_coordinate = False, **kwargs): """set data for series option in highmaps """ self.data_set_count += 1 if not name: name = "Series %d" % self.data_set_count kwargs.update({'name':name}) if is_coord...
[ "def", "add_data_set", "(", "self", ",", "data", ",", "series_type", "=", "\"map\"", ",", "name", "=", "None", ",", "is_coordinate", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "data_set_count", "+=", "1", "if", "not", "name", ":", ...
[ 200, 4 ]
[ 222, 42 ]
python
en
['en', 'en', 'en']
True
Highmap.add_drilldown_data_set
(self, data, series_type, id, **kwargs)
set data for drilldown option in highmaps id must be input and corresponding to drilldown arguments in data series
set data for drilldown option in highmaps id must be input and corresponding to drilldown arguments in data series
def add_drilldown_data_set(self, data, series_type, id, **kwargs): """set data for drilldown option in highmaps id must be input and corresponding to drilldown arguments in data series """ self.drilldown_data_set_count += 1 if self.drilldown_flag == False: self.dril...
[ "def", "add_drilldown_data_set", "(", "self", ",", "data", ",", "series_type", ",", "id", ",", "*", "*", "kwargs", ")", ":", "self", ".", "drilldown_data_set_count", "+=", "1", "if", "self", ".", "drilldown_flag", "==", "False", ":", "self", ".", "drilldow...
[ 225, 4 ]
[ 236, 52 ]
python
en
['en', 'en', 'en']
True
Highmap.add_data_from_jsonp
(self, data_src, data_name = 'json_data', series_type="map", name=None, **kwargs)
add data directly from a https source the data_src is the https link for data using jsonp
add data directly from a https source the data_src is the https link for data using jsonp
def add_data_from_jsonp(self, data_src, data_name = 'json_data', series_type="map", name=None, **kwargs): """add data directly from a https source the data_src is the https link for data using jsonp """ self.jsonp_data_flag = True self.jsonp_data_url = json.dumps(data_src) ...
[ "def", "add_data_from_jsonp", "(", "self", ",", "data_src", ",", "data_name", "=", "'json_data'", ",", "series_type", "=", "\"map\"", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "jsonp_data_flag", "=", "True", "self", ".", "...
[ 239, 4 ]
[ 248, 89 ]
python
en
['en', 'en', 'en']
True
Highmap.add_JSscript
(self, js_script, js_loc)
add (highcharts) javascript in the beginning or at the end of script use only if necessary
add (highcharts) javascript in the beginning or at the end of script use only if necessary
def add_JSscript(self, js_script, js_loc): """add (highcharts) javascript in the beginning or at the end of script use only if necessary """ if js_loc == 'head': self.jscript_head_flag = True if self.jscript_head: self.jscript_head = self.jscript_h...
[ "def", "add_JSscript", "(", "self", ",", "js_script", ",", "js_loc", ")", ":", "if", "js_loc", "==", "'head'", ":", "self", ".", "jscript_head_flag", "=", "True", "if", "self", ".", "jscript_head", ":", "self", ".", "jscript_head", "=", "self", ".", "jsc...
[ 251, 4 ]
[ 269, 41 ]
python
en
['en', 'en', 'en']
True
Highmap.set_map_source
(self, map_src, jsonp_map = False)
set map data use if the mapData is loaded directly from a https source the map_src is the https link for the mapData geojson (from jsonp) or .js formates are acceptable default is js script from highcharts' map collection: https://code.highcharts.com/mapdata/
set map data use if the mapData is loaded directly from a https source the map_src is the https link for the mapData geojson (from jsonp) or .js formates are acceptable default is js script from highcharts' map collection: https://code.highcharts.com/mapdata/
def set_map_source(self, map_src, jsonp_map = False): """set map data use if the mapData is loaded directly from a https source the map_src is the https link for the mapData geojson (from jsonp) or .js formates are acceptable default is js script from highcharts' map collection:...
[ "def", "set_map_source", "(", "self", ",", "map_src", ",", "jsonp_map", "=", "False", ")", ":", "if", "not", "map_src", ":", "raise", "OptionTypeError", "(", "\"No map source input, please refer to: https://code.highcharts.com/mapdata/\"", ")", "if", "jsonp_map", ":", ...
[ 291, 4 ]
[ 314, 84 ]
python
en
['nl', 'jv', 'en']
False
Highmap.set_options
(self, option_type, option_dict, force_options=False)
set plot options
set plot options
def set_options(self, option_type, option_dict, force_options=False): """set plot options""" if force_options: # not to use unless it is really needed self.options[option_type].update(option_dict) elif (option_type == 'yAxis' or option_type == 'xAxis') and isinstance(option_dict, li...
[ "def", "set_options", "(", "self", ",", "option_type", ",", "option_dict", ",", "force_options", "=", "False", ")", ":", "if", "force_options", ":", "# not to use unless it is really needed", "self", ".", "options", "[", "option_type", "]", ".", "update", "(", "...
[ 316, 4 ]
[ 333, 64 ]
python
en
['en', 'bg', 'en']
True
Highmap.set_dict_options
(self, options)
for dictionary-like inputs (as object in Javascript) options must be in python dictionary format
for dictionary-like inputs (as object in Javascript) options must be in python dictionary format
def set_dict_options(self, options): """for dictionary-like inputs (as object in Javascript) options must be in python dictionary format """ if isinstance(options, dict): for key, option_data in options.items(): self.set_options(key, option_data) else:...
[ "def", "set_dict_options", "(", "self", ",", "options", ")", ":", "if", "isinstance", "(", "options", ",", "dict", ")", ":", "for", "key", ",", "option_data", "in", "options", ".", "items", "(", ")", ":", "self", ".", "set_options", "(", "key", ",", ...
[ 335, 4 ]
[ 343, 104 ]
python
en
['en', 'en', 'en']
True
Highmap._get_jsmap_name
(self, url)
return 'name' of the map in .js format
return 'name' of the map in .js format
def _get_jsmap_name(self, url): """return 'name' of the map in .js format""" ret = urlopen(url) return ret.read().decode('utf-8').split('=')[0].replace(" ", "")
[ "def", "_get_jsmap_name", "(", "self", ",", "url", ")", ":", "ret", "=", "urlopen", "(", "url", ")", "return", "ret", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", ".", "split", "(", "'='", ")", "[", "0", "]", ".", "replace", "(", ...
[ 346, 4 ]
[ 350, 72 ]
python
en
['en', 'en', 'en']
True
Highmap.buildcontent
(self)
build HTML content only, no header or body tags
build HTML content only, no header or body tags
def buildcontent(self): """build HTML content only, no header or body tags""" self.buildcontainer() self.option = json.dumps(self.options, cls = HighchartsEncoder) self.setoption = json.dumps(self.setOptions, cls = HighchartsEncoder) self.data = json.dumps(self.data_temp, cls =...
[ "def", "buildcontent", "(", "self", ")", ":", "self", ".", "buildcontainer", "(", ")", "self", ".", "option", "=", "json", ".", "dumps", "(", "self", ".", "options", ",", "cls", "=", "HighchartsEncoder", ")", "self", ".", "setoption", "=", "json", ".",...
[ 353, 4 ]
[ 363, 95 ]
python
en
['en', 'en', 'en']
True
Highmap.buildhtml
(self)
Build the HTML page Create the htmlheader with css / js Create html page
Build the HTML page Create the htmlheader with css / js Create html page
def buildhtml(self): """Build the HTML page Create the htmlheader with css / js Create html page """ self.buildcontent() self.buildhtmlheader() self.content = self._htmlcontent.decode('utf-8') # need to ensure unicode self._htmlcontent = self.template_page...
[ "def", "buildhtml", "(", "self", ")", ":", "self", ".", "buildcontent", "(", ")", "self", ".", "buildhtmlheader", "(", ")", "self", ".", "content", "=", "self", ".", "_htmlcontent", ".", "decode", "(", "'utf-8'", ")", "# need to ensure unicode", "self", "....
[ 366, 4 ]
[ 375, 32 ]
python
en
['en', 'en', 'en']
True
Highmap.buildhtmlheader
(self)
generate HTML header content
generate HTML header content
def buildhtmlheader(self): """generate HTML header content""" #Highcharts lib/ needs to make sure it's up to date if self.drilldown_flag: self.add_JSsource('https://code.highcharts.com/maps/modules/drilldown.js') self.header_css = [ '<link href="%s" rel=...
[ "def", "buildhtmlheader", "(", "self", ")", ":", "#Highcharts lib/ needs to make sure it's up to date", "if", "self", ".", "drilldown_flag", ":", "self", ".", "add_JSsource", "(", "'https://code.highcharts.com/maps/modules/drilldown.js'", ")", "self", ".", "header_css", "="...
[ 377, 4 ]
[ 396, 33 ]
python
en
['en', 'en', 'en']
True
Highmap.buildcontainer
(self)
generate HTML div
generate HTML div
def buildcontainer(self): """generate HTML div""" if self.container: return # Create HTML div with style if self.options['chart'].width: if str(self.options['chart'].width)[-1] != '%': self.div_style += 'width:%spx;' % self.options['chart'].width ...
[ "def", "buildcontainer", "(", "self", ")", ":", "if", "self", ".", "container", ":", "return", "# Create HTML div with style", "if", "self", ".", "options", "[", "'chart'", "]", ".", "width", ":", "if", "str", "(", "self", ".", "options", "[", "'chart'", ...
[ 399, 4 ]
[ 417, 96 ]
python
en
['en', 'en', 'en']
True
Highmap.__str__
(self)
return htmlcontent
return htmlcontent
def __str__(self): """return htmlcontent""" #self.buildhtml() return self.htmlcontent
[ "def", "__str__", "(", "self", ")", ":", "#self.buildhtml()", "return", "self", ".", "htmlcontent" ]
[ 440, 4 ]
[ 443, 31 ]
python
en
['en', 'no', 'en']
False
Highmap.save_file
(self, filename = 'Map')
save htmlcontent as .html file
save htmlcontent as .html file
def save_file(self, filename = 'Map'): """ save htmlcontent as .html file """ filename = filename + '.html' with open(filename, 'w') as f: #self.buildhtml() f.write(self.htmlcontent) f.closed
[ "def", "save_file", "(", "self", ",", "filename", "=", "'Map'", ")", ":", "filename", "=", "filename", "+", "'.html'", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "#self.buildhtml()", "f", ".", "write", "(", "self", ".", "htmlcont...
[ 445, 4 ]
[ 453, 16 ]
python
en
['en', 'en', 'en']
True
get_asgi_application
()
The public interface to Django's ASGI support. Return an ASGI 3 callable. Avoids making django.core.handlers.ASGIHandler a public API, in case the internal implementation changes or moves in the future.
The public interface to Django's ASGI support. Return an ASGI 3 callable.
def get_asgi_application(): """ The public interface to Django's ASGI support. Return an ASGI 3 callable. Avoids making django.core.handlers.ASGIHandler a public API, in case the internal implementation changes or moves in the future. """ django.setup(set_prefix=False) return ASGIHandler()
[ "def", "get_asgi_application", "(", ")", ":", "django", ".", "setup", "(", "set_prefix", "=", "False", ")", "return", "ASGIHandler", "(", ")" ]
[ 4, 0 ]
[ 12, 24 ]
python
en
['en', 'error', 'th']
False
AsyncToSync._run_event_loop
(self, loop, coro)
Runs the given event loop (designed to be called in a thread).
Runs the given event loop (designed to be called in a thread).
def _run_event_loop(self, loop, coro): """ Runs the given event loop (designed to be called in a thread). """ asyncio.set_event_loop(loop) try: loop.run_until_complete(coro) finally: try: # mimic asyncio.run() behavior ...
[ "def", "_run_event_loop", "(", "self", ",", "loop", ",", "coro", ")", ":", "asyncio", ".", "set_event_loop", "(", "loop", ")", "try", ":", "loop", ".", "run_until_complete", "(", "coro", ")", "finally", ":", "try", ":", "# mimic asyncio.run() behavior", "# c...
[ 224, 4 ]
[ 261, 60 ]
python
en
['en', 'error', 'th']
False
AsyncToSync.__get__
(self, parent, objtype)
Include self for methods
Include self for methods
def __get__(self, parent, objtype): """ Include self for methods """ func = functools.partial(self.__call__, parent) return functools.update_wrapper(func, self.awaitable)
[ "def", "__get__", "(", "self", ",", "parent", ",", "objtype", ")", ":", "func", "=", "functools", ".", "partial", "(", "self", ".", "__call__", ",", "parent", ")", "return", "functools", ".", "update_wrapper", "(", "func", ",", "self", ".", "awaitable", ...
[ 263, 4 ]
[ 268, 61 ]
python
en
['en', 'error', 'th']
False
AsyncToSync.main_wrap
( self, args, kwargs, call_result, source_thread, exc_info, context )
Wraps the awaitable with something that puts the result into the result/exception future.
Wraps the awaitable with something that puts the result into the result/exception future.
async def main_wrap( self, args, kwargs, call_result, source_thread, exc_info, context ): """ Wraps the awaitable with something that puts the result into the result/exception future. """ if context is not None: _restore_context(context[0]) curren...
[ "async", "def", "main_wrap", "(", "self", ",", "args", ",", "kwargs", ",", "call_result", ",", "source_thread", ",", "exc_info", ",", "context", ")", ":", "if", "context", "is", "not", "None", ":", "_restore_context", "(", "context", "[", "0", "]", ")", ...
[ 270, 4 ]
[ 300, 55 ]
python
en
['en', 'error', 'th']
False
SyncToAsync.__get__
(self, parent, objtype)
Include self for methods
Include self for methods
def __get__(self, parent, objtype): """ Include self for methods """ return functools.partial(self.__call__, parent)
[ "def", "__get__", "(", "self", ",", "parent", ",", "objtype", ")", ":", "return", "functools", ".", "partial", "(", "self", ".", "__call__", ",", "parent", ")" ]
[ 453, 4 ]
[ 457, 55 ]
python
en
['en', 'error', 'th']
False
SyncToAsync.thread_handler
(self, loop, source_task, exc_info, func, *args, **kwargs)
Wraps the sync application with exception handling.
Wraps the sync application with exception handling.
def thread_handler(self, loop, source_task, exc_info, func, *args, **kwargs): """ Wraps the sync application with exception handling. """ # Set the threadlocal for AsyncToSync self.threadlocal.main_event_loop = loop self.threadlocal.main_event_loop_pid = os.getpid() ...
[ "def", "thread_handler", "(", "self", ",", "loop", ",", "source_task", ",", "exc_info", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Set the threadlocal for AsyncToSync", "self", ".", "threadlocal", ".", "main_event_loop", "=", "loop", ...
[ 459, 4 ]
[ 490, 51 ]
python
en
['en', 'error', 'th']
False
SyncToAsync.get_current_task
()
Cross-version implementation of asyncio.current_task() Returns None if there is no task.
Cross-version implementation of asyncio.current_task()
def get_current_task(): """ Cross-version implementation of asyncio.current_task() Returns None if there is no task. """ try: if hasattr(asyncio, "current_task"): # Python 3.7 and up return asyncio.current_task() else: ...
[ "def", "get_current_task", "(", ")", ":", "try", ":", "if", "hasattr", "(", "asyncio", ",", "\"current_task\"", ")", ":", "# Python 3.7 and up", "return", "asyncio", ".", "current_task", "(", ")", "else", ":", "# Python 3.6", "return", "asyncio", ".", "Task", ...
[ 493, 4 ]
[ 507, 23 ]
python
en
['en', 'error', 'th']
False
ugettext_noop
(message)
A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext_noop() since Django 2.0.
A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext_noop() since Django 2.0.
def ugettext_noop(message): """ A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext_noop() since Django 2.0. """ warnings.warn( 'django.utils.translation.ugettext_noop() is deprecated in favor of ' 'django.utils.translation.gettext_noop().', Remo...
[ "def", "ugettext_noop", "(", "message", ")", ":", "warnings", ".", "warn", "(", "'django.utils.translation.ugettext_noop() is deprecated in favor of '", "'django.utils.translation.gettext_noop().'", ",", "RemovedInDjango40Warning", ",", "stacklevel", "=", "2", ",", ")", "retu...
[ 79, 0 ]
[ 89, 32 ]
python
en
['en', 'error', 'th']
False
ugettext
(message)
A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext() since Django 2.0.
A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext() since Django 2.0.
def ugettext(message): """ A legacy compatibility wrapper for Unicode handling on Python 2. Alias of gettext() since Django 2.0. """ warnings.warn( 'django.utils.translation.ugettext() is deprecated in favor of ' 'django.utils.translation.gettext().', RemovedInDjango40Warning...
[ "def", "ugettext", "(", "message", ")", ":", "warnings", ".", "warn", "(", "'django.utils.translation.ugettext() is deprecated in favor of '", "'django.utils.translation.gettext().'", ",", "RemovedInDjango40Warning", ",", "stacklevel", "=", "2", ",", ")", "return", "gettext...
[ 96, 0 ]
[ 106, 27 ]
python
en
['en', 'error', 'th']
False
ungettext
(singular, plural, number)
A legacy compatibility wrapper for Unicode handling on Python 2. Alias of ngettext() since Django 2.0.
A legacy compatibility wrapper for Unicode handling on Python 2. Alias of ngettext() since Django 2.0.
def ungettext(singular, plural, number): """ A legacy compatibility wrapper for Unicode handling on Python 2. Alias of ngettext() since Django 2.0. """ warnings.warn( 'django.utils.translation.ungettext() is deprecated in favor of ' 'django.utils.translation.ngettext().', Rem...
[ "def", "ungettext", "(", "singular", ",", "plural", ",", "number", ")", ":", "warnings", ".", "warn", "(", "'django.utils.translation.ungettext() is deprecated in favor of '", "'django.utils.translation.ngettext().'", ",", "RemovedInDjango40Warning", ",", "stacklevel", "=", ...
[ 113, 0 ]
[ 123, 45 ]
python
en
['en', 'error', 'th']
False
ugettext_lazy
(message)
A legacy compatibility wrapper for Unicode handling on Python 2. Has been Alias of gettext_lazy since Django 2.0.
A legacy compatibility wrapper for Unicode handling on Python 2. Has been Alias of gettext_lazy since Django 2.0.
def ugettext_lazy(message): """ A legacy compatibility wrapper for Unicode handling on Python 2. Has been Alias of gettext_lazy since Django 2.0. """ warnings.warn( 'django.utils.translation.ugettext_lazy() is deprecated in favor of ' 'django.utils.translation.gettext_lazy().', ...
[ "def", "ugettext_lazy", "(", "message", ")", ":", "warnings", ".", "warn", "(", "'django.utils.translation.ugettext_lazy() is deprecated in favor of '", "'django.utils.translation.gettext_lazy().'", ",", "RemovedInDjango40Warning", ",", "stacklevel", "=", "2", ",", ")", "retu...
[ 138, 0 ]
[ 148, 32 ]
python
en
['en', 'error', 'th']
False
ungettext_lazy
(singular, plural, number=None)
A legacy compatibility wrapper for Unicode handling on Python 2. An alias of ungettext_lazy() since Django 2.0.
A legacy compatibility wrapper for Unicode handling on Python 2. An alias of ungettext_lazy() since Django 2.0.
def ungettext_lazy(singular, plural, number=None): """ A legacy compatibility wrapper for Unicode handling on Python 2. An alias of ungettext_lazy() since Django 2.0. """ warnings.warn( 'django.utils.translation.ungettext_lazy() is deprecated in favor of ' 'django.utils.translation.n...
[ "def", "ungettext_lazy", "(", "singular", ",", "plural", ",", "number", "=", "None", ")", ":", "warnings", ".", "warn", "(", "'django.utils.translation.ungettext_lazy() is deprecated in favor of '", "'django.utils.translation.ngettext_lazy().'", ",", "RemovedInDjango40Warning",...
[ 206, 0 ]
[ 216, 50 ]
python
en
['en', 'error', 'th']
False
to_language
(locale)
Turn a locale name (en_US) into a language name (en-us).
Turn a locale name (en_US) into a language name (en-us).
def to_language(locale): """Turn a locale name (en_US) into a language name (en-us).""" p = locale.find('_') if p >= 0: return locale[:p].lower() + '-' + locale[p + 1:].lower() else: return locale.lower()
[ "def", "to_language", "(", "locale", ")", ":", "p", "=", "locale", ".", "find", "(", "'_'", ")", "if", "p", ">=", "0", ":", "return", "locale", "[", ":", "p", "]", ".", "lower", "(", ")", "+", "'-'", "+", "locale", "[", "p", "+", "1", ":", ...
[ 264, 0 ]
[ 270, 29 ]
python
en
['es', 'en', 'en']
True
to_locale
(language)
Turn a language name (en-us) into a locale name (en_US).
Turn a language name (en-us) into a locale name (en_US).
def to_locale(language): """Turn a language name (en-us) into a locale name (en_US).""" language, _, country = language.lower().partition('-') if not country: return language # A language with > 2 characters after the dash only has its first # character after the dash capitalized; e.g. sr-la...
[ "def", "to_locale", "(", "language", ")", ":", "language", ",", "_", ",", "country", "=", "language", ".", "lower", "(", ")", ".", "partition", "(", "'-'", ")", "if", "not", "country", ":", "return", "language", "# A language with > 2 characters after the dash...
[ 273, 0 ]
[ 286, 35 ]
python
en
['es', 'en', 'en']
True
recommendation
()
Given a user id, return a list of recommended item ids.
Given a user id, return a list of recommended item ids.
def recommendation(): """Given a user id, return a list of recommended item ids.""" user_id = request.args.get('userId') num_recs = request.args.get('numRecs') # validate args if user_id is None: return 'No User Id provided.', 400 if num_recs is None: num_recs = DEFAULT_RECS try: uid_int = in...
[ "def", "recommendation", "(", ")", ":", "user_id", "=", "request", ".", "args", ".", "get", "(", "'userId'", ")", "num_recs", "=", "request", ".", "args", ".", "get", "(", "'numRecs'", ")", "# validate args", "if", "user_id", "is", "None", ":", "return",...
[ 28, 0 ]
[ 51, 27 ]
python
en
['en', 'en', 'en']
True
CSSFeatures.fit
(self, blocks, y=None)
This method returns the current instance unchanged, since no fitting is required for this ``Feature``. It's here only for API consistency.
This method returns the current instance unchanged, since no fitting is required for this ``Feature``. It's here only for API consistency.
def fit(self, blocks, y=None): """ This method returns the current instance unchanged, since no fitting is required for this ``Feature``. It's here only for API consistency. """ return self
[ "def", "fit", "(", "self", ",", "blocks", ",", "y", "=", "None", ")", ":", "return", "self" ]
[ 30, 4 ]
[ 35, 19 ]
python
en
['en', 'error', 'th']
False
CSSFeatures.transform
(self, blocks, y=None)
Transform an ordered sequence of blocks into a 2D features matrix with shape (num blocks, num features). Args: blocks (List[Block]): as output by :class:`Blockifier.blockify` y (None): This isn't used, it's only here for API consistency. Returns: `n...
Transform an ordered sequence of blocks into a 2D features matrix with shape (num blocks, num features).
def transform(self, blocks, y=None): """ Transform an ordered sequence of blocks into a 2D features matrix with shape (num blocks, num features). Args: blocks (List[Block]): as output by :class:`Blockifier.blockify` y (None): This isn't used, it's only here for A...
[ "def", "transform", "(", "self", ",", "blocks", ",", "y", "=", "None", ")", ":", "feature_vecs", "=", "(", "tuple", "(", "re", ".", "search", "(", "token", ",", "block", ".", "css", "[", "attrib", "]", ")", "is", "not", "None", "for", "block", "i...
[ 37, 4 ]
[ 57, 63 ]
python
en
['en', 'error', 'th']
False
Dataset.scheduler
(self, epoch: int)
Epoch lr rate scheduler for your dataset
Epoch lr rate scheduler for your dataset
def scheduler(self, epoch: int) -> float: """ Epoch lr rate scheduler for your dataset """ raise NotImplementedError
[ "def", "scheduler", "(", "self", ",", "epoch", ":", "int", ")", "->", "float", ":", "raise", "NotImplementedError" ]
[ 14, 4 ]
[ 18, 33 ]
python
en
['en', 'error', 'th']
False
Dataset.classes
(self)
:return: number of classes in this dataset
:return: number of classes in this dataset
def classes(self) -> int: """ :return: number of classes in this dataset """ return self._classes
[ "def", "classes", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_classes" ]
[ 21, 4 ]
[ 25, 28 ]
python
en
['en', 'error', 'th']
False
Dataset.load_train_datasets
(self)
:return: training dataset(tf.data.Dataset), size
:return: training dataset(tf.data.Dataset), size
def load_train_datasets(self) -> (tf.data.Dataset, float): """ :return: training dataset(tf.data.Dataset), size """ pass
[ "def", "load_train_datasets", "(", "self", ")", "->", "(", "tf", ".", "data", ".", "Dataset", ",", "float", ")", ":", "pass" ]
[ 28, 4 ]
[ 32, 12 ]
python
en
['en', 'error', 'th']
False
Dataset.load_validation_datasets
(self)
:return: validation dataset (tf.data.Dataset), size
:return: validation dataset (tf.data.Dataset), size
def load_validation_datasets(self) -> (tf.data.Dataset, float): """ :return: validation dataset (tf.data.Dataset), size """ pass
[ "def", "load_validation_datasets", "(", "self", ")", "->", "(", "tf", ".", "data", ".", "Dataset", ",", "float", ")", ":", "pass" ]
[ 35, 4 ]
[ 39, 12 ]
python
en
['en', 'error', 'th']
False
Dataset.decode
(self, *args, **kwargs)
:return: (image, labels, bboxes) where
:return: (image, labels, bboxes) where
def decode(self, *args, **kwargs): """ :return: (image, labels, bboxes) where """ pass
[ "def", "decode", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 42, 4 ]
[ 46, 12 ]
python
en
['en', 'error', 'th']
False
test_content_and_content_comments_extractor_blocks
(html)
The content and content/comments extractor should return proper blocks
The content and content/comments extractor should return proper blocks
def test_content_and_content_comments_extractor_blocks(html): """ The content and content/comments extractor should return proper blocks """ content = extract_content(html, as_blocks=True) content_comments = extract_comments(html, as_blocks=True) passed_content = False passed_content_commen...
[ "def", "test_content_and_content_comments_extractor_blocks", "(", "html", ")", ":", "content", "=", "extract_content", "(", "html", ",", "as_blocks", "=", "True", ")", "content_comments", "=", "extract_comments", "(", "html", ",", "as_blocks", "=", "True", ")", "p...
[ 59, 0 ]
[ 86, 34 ]
python
en
['en', 'error', 'th']
False
SSLTransport._validate_ssl_context_for_tls_in_tls
(ssl_context)
Raises a ProxySchemeUnsupported if the provided ssl_context can't be used for TLS in TLS. The only requirement is that the ssl_context provides the 'wrap_bio' methods.
Raises a ProxySchemeUnsupported if the provided ssl_context can't be used for TLS in TLS.
def _validate_ssl_context_for_tls_in_tls(ssl_context): """ Raises a ProxySchemeUnsupported if the provided ssl_context can't be used for TLS in TLS. The only requirement is that the ssl_context provides the 'wrap_bio' methods. """ if not hasattr(ssl_context, "wr...
[ "def", "_validate_ssl_context_for_tls_in_tls", "(", "ssl_context", ")", ":", "if", "not", "hasattr", "(", "ssl_context", ",", "\"wrap_bio\"", ")", ":", "if", "six", ".", "PY2", ":", "raise", "ProxySchemeUnsupported", "(", "\"TLS in TLS requires SSLContext.wrap_bio() whi...
[ 22, 4 ]
[ 41, 17 ]
python
en
['en', 'error', 'th']
False
SSLTransport.__init__
( self, socket, ssl_context, server_hostname=None, suppress_ragged_eofs=True )
Create an SSLTransport around socket using the provided ssl_context.
Create an SSLTransport around socket using the provided ssl_context.
def __init__( self, socket, ssl_context, server_hostname=None, suppress_ragged_eofs=True ): """ Create an SSLTransport around socket using the provided ssl_context. """ self.incoming = ssl.MemoryBIO() self.outgoing = ssl.MemoryBIO() self.suppress_ragged_eofs ...
[ "def", "__init__", "(", "self", ",", "socket", ",", "ssl_context", ",", "server_hostname", "=", "None", ",", "suppress_ragged_eofs", "=", "True", ")", ":", "self", ".", "incoming", "=", "ssl", ".", "MemoryBIO", "(", ")", "self", ".", "outgoing", "=", "ss...
[ 43, 4 ]
[ 60, 51 ]
python
en
['en', 'error', 'th']
False
SSLTransport.makefile
( self, mode="r", buffering=None, encoding=None, errors=None, newline=None )
Python's httpclient uses makefile and buffered io when reading HTTP messages and we need to support it. This is unfortunately a copy and paste of socket.py makefile with small changes to point to the socket directly.
Python's httpclient uses makefile and buffered io when reading HTTP messages and we need to support it.
def makefile( self, mode="r", buffering=None, encoding=None, errors=None, newline=None ): """ Python's httpclient uses makefile and buffered io when reading HTTP messages and we need to support it. This is unfortunately a copy and paste of socket.py makefile with small ...
[ "def", "makefile", "(", "self", ",", "mode", "=", "\"r\"", ",", "buffering", "=", "None", ",", "encoding", "=", "None", ",", "errors", "=", "None", ",", "newline", "=", "None", ")", ":", "if", "not", "set", "(", "mode", ")", "<=", "{", "\"r\"", "...
[ 104, 4 ]
[ 147, 19 ]
python
en
['en', 'error', 'th']
False