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
ResourceManager.resource_string
(self, package_or_requirement, resource_name)
Return specified resource as a string
Return specified resource as a string
def resource_string(self, package_or_requirement, resource_name): """Return specified resource as a string""" return get_provider(package_or_requirement).get_resource_string( self, resource_name )
[ "def", "resource_string", "(", "self", ",", "package_or_requirement", ",", "resource_name", ")", ":", "return", "get_provider", "(", "package_or_requirement", ")", ".", "get_resource_string", "(", "self", ",", "resource_name", ")" ]
[ 1153, 4 ]
[ 1157, 9 ]
python
en
['en', 'en', 'en']
True
ResourceManager.resource_listdir
(self, package_or_requirement, resource_name)
List the contents of the named resource directory
List the contents of the named resource directory
def resource_listdir(self, package_or_requirement, resource_name): """List the contents of the named resource directory""" return get_provider(package_or_requirement).resource_listdir( resource_name )
[ "def", "resource_listdir", "(", "self", ",", "package_or_requirement", ",", "resource_name", ")", ":", "return", "get_provider", "(", "package_or_requirement", ")", ".", "resource_listdir", "(", "resource_name", ")" ]
[ 1159, 4 ]
[ 1163, 9 ]
python
en
['en', 'en', 'en']
True
ResourceManager.extraction_error
(self)
Give an error message for problems extracting file(s)
Give an error message for problems extracting file(s)
def extraction_error(self): """Give an error message for problems extracting file(s)""" old_exc = sys.exc_info()[1] cache_path = self.extraction_path or get_default_cache() tmpl = textwrap.dedent(""" Can't extract file(s) to egg cache The following error occurr...
[ "def", "extraction_error", "(", "self", ")", ":", "old_exc", "=", "sys", ".", "exc_info", "(", ")", "[", "1", "]", "cache_path", "=", "self", ".", "extraction_path", "or", "get_default_cache", "(", ")", "tmpl", "=", "textwrap", ".", "dedent", "(", "\"\"\...
[ 1165, 4 ]
[ 1191, 17 ]
python
en
['en', 'en', 'en']
True
ResourceManager.get_cache_path
(self, archive_name, names=())
Return absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not be the name of the enclosing zipfile!), including its...
Return absolute location in cache for `archive_name` and `names`
def get_cache_path(self, archive_name, names=()): """Return absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not ...
[ "def", "get_cache_path", "(", "self", ",", "archive_name", ",", "names", "=", "(", ")", ")", ":", "extract_path", "=", "self", ".", "extraction_path", "or", "get_default_cache", "(", ")", "target_path", "=", "os", ".", "path", ".", "join", "(", "extract_pa...
[ 1193, 4 ]
[ 1216, 26 ]
python
en
['en', 'en', 'en']
True
ResourceManager._warn_unsafe_extraction_path
(path)
If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location is used. See Distribute #375 for more det...
If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location is used.
def _warn_unsafe_extraction_path(path): """ If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location...
[ "def", "_warn_unsafe_extraction_path", "(", "path", ")", ":", "if", "os", ".", "name", "==", "'nt'", "and", "not", "path", ".", "startswith", "(", "os", ".", "environ", "[", "'windir'", "]", ")", ":", "# On Windows, permissions are generally restrictive by default...
[ 1219, 4 ]
[ 1242, 43 ]
python
en
['en', 'error', 'th']
False
ResourceManager.postprocess
(self, tempname, filename)
Perform any platform-specific postprocessing of `tempname` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method ONLY after successfully extracting a compressed resource. They must NOT c...
Perform any platform-specific postprocessing of `tempname`
def postprocess(self, tempname, filename): """Perform any platform-specific postprocessing of `tempname` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method ONLY after successfully ...
[ "def", "postprocess", "(", "self", ",", "tempname", ",", "filename", ")", ":", "if", "os", ".", "name", "==", "'posix'", ":", "# Make the resource executable", "mode", "=", "(", "(", "os", ".", "stat", "(", "tempname", ")", ".", "st_mode", ")", "|", "0...
[ 1244, 4 ]
[ 1262, 36 ]
python
en
['en', 'en', 'en']
True
ResourceManager.set_extraction_path
(self, path)
Set the base path where resources will be extracted to, if needed. If you do not call this routine before any extractions take place, the path defaults to the return value of ``get_default_cache()``. (Which is based on the ``PYTHON_EGG_CACHE`` environment variable, with various platfor...
Set the base path where resources will be extracted to, if needed.
def set_extraction_path(self, path): """Set the base path where resources will be extracted to, if needed. If you do not call this routine before any extractions take place, the path defaults to the return value of ``get_default_cache()``. (Which is based on the ``PYTHON_EGG_CACHE`` en...
[ "def", "set_extraction_path", "(", "self", ",", "path", ")", ":", "if", "self", ".", "cached_files", ":", "raise", "ValueError", "(", "\"Can't change extraction path, files already extracted\"", ")", "self", ".", "extraction_path", "=", "path" ]
[ 1264, 4 ]
[ 1288, 35 ]
python
en
['en', 'en', 'en']
True
ResourceManager.cleanup_resources
(self, force=False)
Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary dir...
Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary dir...
def cleanup_resources(self, force=False): """ Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be calle...
[ "def", "cleanup_resources", "(", "self", ",", "force", "=", "False", ")", ":" ]
[ 1290, 4 ]
[ 1300, 11 ]
python
en
['en', 'error', 'th']
False
NullProvider._validate_resource_path
(path)
Validate the resource paths according to the docs. https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access >>> warned = getfixture('recwarn') >>> warnings.simplefilter('always') >>> vrp = NullProvider._validate_resource_path >>> vrp('foo/bar...
Validate the resource paths according to the docs. https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access
def _validate_resource_path(path): """ Validate the resource paths according to the docs. https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access >>> warned = getfixture('recwarn') >>> warnings.simplefilter('always') >>> vrp = NullProvider._v...
[ "def", "_validate_resource_path", "(", "path", ")", ":", "invalid", "=", "(", "os", ".", "path", ".", "pardir", "in", "path", ".", "split", "(", "posixpath", ".", "sep", ")", "or", "posixpath", ".", "isabs", "(", "path", ")", "or", "ntpath", ".", "is...
[ 1492, 4 ]
[ 1564, 9 ]
python
en
['en', 'error', 'th']
False
ZipManifests.build
(cls, path)
Build a dictionary similar to the zipimport directory caches, except instead of tuples, store ZipInfo objects. Use a platform-specific path separator (os.sep) for the path keys for compatibility with pypy on Windows.
Build a dictionary similar to the zipimport directory caches, except instead of tuples, store ZipInfo objects.
def build(cls, path): """ Build a dictionary similar to the zipimport directory caches, except instead of tuples, store ZipInfo objects. Use a platform-specific path separator (os.sep) for the path keys for compatibility with pypy on Windows. """ with zipfile.Zip...
[ "def", "build", "(", "cls", ",", "path", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "path", ")", "as", "zfile", ":", "items", "=", "(", "(", "name", ".", "replace", "(", "'/'", ",", "os", ".", "sep", ")", ",", "zfile", ".", "getinfo", "(...
[ 1655, 4 ]
[ 1671, 30 ]
python
en
['en', 'error', 'th']
False
MemoizedZipManifests.load
(self, path)
Load a manifest at path or return a suitable manifest already loaded.
Load a manifest at path or return a suitable manifest already loaded.
def load(self, path): """ Load a manifest at path or return a suitable manifest already loaded. """ path = os.path.normpath(path) mtime = os.stat(path).st_mtime if path not in self or self[path].mtime != mtime: manifest = self.build(path) self[pat...
[ "def", "load", "(", "self", ",", "path", ")", ":", "path", "=", "os", ".", "path", ".", "normpath", "(", "path", ")", "mtime", "=", "os", ".", "stat", "(", "path", ")", ".", "st_mtime", "if", "path", "not", "in", "self", "or", "self", "[", "pat...
[ 1682, 4 ]
[ 1693, 34 ]
python
en
['en', 'error', 'th']
False
ZipProvider._is_current
(self, file_path, zip_path)
Return True if the file_path is current for this zip_path
Return True if the file_path is current for this zip_path
def _is_current(self, file_path, zip_path): """ Return True if the file_path is current for this zip_path """ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path]) if not os.path.isfile(file_path): return False stat = os.stat(file_path) if ...
[ "def", "_is_current", "(", "self", ",", "file_path", ",", "zip_path", ")", ":", "timestamp", ",", "size", "=", "self", ".", "_get_date_and_size", "(", "self", ".", "zipinfo", "[", "zip_path", "]", ")", "if", "not", "os", ".", "path", ".", "isfile", "("...
[ 1809, 4 ]
[ 1823, 44 ]
python
en
['en', 'error', 'th']
False
EggMetadata.__init__
(self, importer)
Create a metadata provider from a zipimporter
Create a metadata provider from a zipimporter
def __init__(self, importer): """Create a metadata provider from a zipimporter""" self.zip_pre = importer.archive + os.sep self.loader = importer if importer.prefix: self.module_path = os.path.join(importer.archive, importer.prefix) else: self.module_path...
[ "def", "__init__", "(", "self", ",", "importer", ")", ":", "self", ".", "zip_pre", "=", "importer", ".", "archive", "+", "os", ".", "sep", "self", ".", "loader", "=", "importer", "if", "importer", ".", "prefix", ":", "self", ".", "module_path", "=", ...
[ 1941, 4 ]
[ 1950, 28 ]
python
en
['en', 'en', 'en']
True
EntryPoint.load
(self, require=True, *args, **kwargs)
Require packages for this EntryPoint, then resolve it.
Require packages for this EntryPoint, then resolve it.
def load(self, require=True, *args, **kwargs): """ Require packages for this EntryPoint, then resolve it. """ if not require or args or kwargs: warnings.warn( "Parameters to load are deprecated. Call .resolve and " ".require separately.", ...
[ "def", "load", "(", "self", ",", "require", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "require", "or", "args", "or", "kwargs", ":", "warnings", ".", "warn", "(", "\"Parameters to load are deprecated. Call .resolve and \"...
[ 2429, 4 ]
[ 2442, 29 ]
python
en
['en', 'error', 'th']
False
EntryPoint.resolve
(self)
Resolve the entry point from its module and attrs.
Resolve the entry point from its module and attrs.
def resolve(self): """ Resolve the entry point from its module and attrs. """ module = __import__(self.module_name, fromlist=['__name__'], level=0) try: return functools.reduce(getattr, self.attrs, module) except AttributeError as exc: raise Import...
[ "def", "resolve", "(", "self", ")", ":", "module", "=", "__import__", "(", "self", ".", "module_name", ",", "fromlist", "=", "[", "'__name__'", "]", ",", "level", "=", "0", ")", "try", ":", "return", "functools", ".", "reduce", "(", "getattr", ",", "...
[ 2444, 4 ]
[ 2452, 39 ]
python
en
['en', 'error', 'th']
False
EntryPoint.parse
(cls, src, dist=None)
Parse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional
Parse a single entry point from string `src`
def parse(cls, src, dist=None): """Parse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional "...
[ "def", "parse", "(", "cls", ",", "src", ",", "dist", "=", "None", ")", ":", "m", "=", "cls", ".", "pattern", ".", "match", "(", "src", ")", "if", "not", "m", ":", "msg", "=", "\"EntryPoint must be in 'name=module:attrs [extras]' format\"", "raise", "ValueE...
[ 2477, 4 ]
[ 2494, 67 ]
python
en
['en', 'en', 'en']
True
EntryPoint.parse_group
(cls, group, lines, dist=None)
Parse an entry point group
Parse an entry point group
def parse_group(cls, group, lines, dist=None): """Parse an entry point group""" if not MODULE(group): raise ValueError("Invalid group name", group) this = {} for line in yield_lines(lines): ep = cls.parse(line, dist) if ep.name in this: ...
[ "def", "parse_group", "(", "cls", ",", "group", ",", "lines", ",", "dist", "=", "None", ")", ":", "if", "not", "MODULE", "(", "group", ")", ":", "raise", "ValueError", "(", "\"Invalid group name\"", ",", "group", ")", "this", "=", "{", "}", "for", "l...
[ 2506, 4 ]
[ 2516, 19 ]
python
en
['en', 'en', 'en']
True
EntryPoint.parse_map
(cls, data, dist=None)
Parse a map of entry point groups
Parse a map of entry point groups
def parse_map(cls, data, dist=None): """Parse a map of entry point groups""" if isinstance(data, dict): data = data.items() else: data = split_sections(data) maps = {} for group, lines in data: if group is None: if not lines: ...
[ "def", "parse_map", "(", "cls", ",", "data", ",", "dist", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "data", "=", "data", ".", "items", "(", ")", "else", ":", "data", "=", "split_sections", "(", "data", ")", "m...
[ 2519, 4 ]
[ 2535, 19 ]
python
en
['en', 'en', 'en']
True
Distribution._dep_map
(self)
A map of extra to its list of (direct) requirements for this distribution, including the null extra.
A map of extra to its list of (direct) requirements for this distribution, including the null extra.
def _dep_map(self): """ A map of extra to its list of (direct) requirements for this distribution, including the null extra. """ try: return self.__dep_map except AttributeError: self.__dep_map = self._filter_extras(self._build_dep_map()) r...
[ "def", "_dep_map", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dep_map", "except", "AttributeError", ":", "self", ".", "__dep_map", "=", "self", ".", "_filter_extras", "(", "self", ".", "_build_dep_map", "(", ")", ")", "return", "self", ...
[ 2693, 4 ]
[ 2702, 29 ]
python
en
['en', 'error', 'th']
False
Distribution._filter_extras
(dm)
Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers.
Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers.
def _filter_extras(dm): """ Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers. """ for extra in list(filter(None, dm)): new_extra = extra reqs = dm.pop(extra) ...
[ "def", "_filter_extras", "(", "dm", ")", ":", "for", "extra", "in", "list", "(", "filter", "(", "None", ",", "dm", ")", ")", ":", "new_extra", "=", "extra", "reqs", "=", "dm", ".", "pop", "(", "extra", ")", "new_extra", ",", "_", ",", "marker", "...
[ 2705, 4 ]
[ 2724, 17 ]
python
en
['en', 'error', 'th']
False
Distribution.requires
(self, extras=())
List of Requirements needed for this distro if `extras` are used
List of Requirements needed for this distro if `extras` are used
def requires(self, extras=()): """List of Requirements needed for this distro if `extras` are used""" dm = self._dep_map deps = [] deps.extend(dm.get(None, ())) for ext in extras: try: deps.extend(dm[safe_extra(ext)]) except KeyError: ...
[ "def", "requires", "(", "self", ",", "extras", "=", "(", ")", ")", ":", "dm", "=", "self", ".", "_dep_map", "deps", "=", "[", "]", "deps", ".", "extend", "(", "dm", ".", "get", "(", "None", ",", "(", ")", ")", ")", "for", "ext", "in", "extras...
[ 2733, 4 ]
[ 2745, 19 ]
python
en
['en', 'en', 'en']
True
Distribution._get_metadata_path_for_display
(self, name)
Return the path to the given metadata file, if available.
Return the path to the given metadata file, if available.
def _get_metadata_path_for_display(self, name): """ Return the path to the given metadata file, if available. """ try: # We need to access _get_metadata_path() on the provider object # directly rather than through this class's __getattr__() # since _ge...
[ "def", "_get_metadata_path_for_display", "(", "self", ",", "name", ")", ":", "try", ":", "# We need to access _get_metadata_path() on the provider object", "# directly rather than through this class's __getattr__()", "# since _get_metadata_path() is marked private.", "path", "=", "self...
[ 2747, 4 ]
[ 2762, 19 ]
python
en
['en', 'error', 'th']
False
Distribution.activate
(self, path=None, replace=False)
Ensure distribution is importable on `path` (default=sys.path)
Ensure distribution is importable on `path` (default=sys.path)
def activate(self, path=None, replace=False): """Ensure distribution is importable on `path` (default=sys.path)""" if path is None: path = sys.path self.insert_on(path, replace=replace) if path is sys.path: fixup_namespace_packages(self.location) for p...
[ "def", "activate", "(", "self", ",", "path", "=", "None", ",", "replace", "=", "False", ")", ":", "if", "path", "is", "None", ":", "path", "=", "sys", ".", "path", "self", ".", "insert_on", "(", "path", ",", "replace", "=", "replace", ")", "if", ...
[ 2775, 4 ]
[ 2784, 42 ]
python
en
['en', 'en', 'en']
True
Distribution.egg_name
(self)
Return what this distribution's standard .egg filename should be
Return what this distribution's standard .egg filename should be
def egg_name(self): """Return what this distribution's standard .egg filename should be""" filename = "%s-%s-py%s" % ( to_filename(self.project_name), to_filename(self.version), self.py_version or PY_MAJOR ) if self.platform: filename += '-' + self.pl...
[ "def", "egg_name", "(", "self", ")", ":", "filename", "=", "\"%s-%s-py%s\"", "%", "(", "to_filename", "(", "self", ".", "project_name", ")", ",", "to_filename", "(", "self", ".", "version", ")", ",", "self", ".", "py_version", "or", "PY_MAJOR", ")", "if"...
[ 2786, 4 ]
[ 2795, 23 ]
python
en
['en', 'en', 'en']
True
Distribution.__getattr__
(self, attr)
Delegate all unrecognized public attributes to .metadata provider
Delegate all unrecognized public attributes to .metadata provider
def __getattr__(self, attr): """Delegate all unrecognized public attributes to .metadata provider""" if attr.startswith('_'): raise AttributeError(attr) return getattr(self._provider, attr)
[ "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "if", "attr", ".", "startswith", "(", "'_'", ")", ":", "raise", "AttributeError", "(", "attr", ")", "return", "getattr", "(", "self", ".", "_provider", ",", "attr", ")" ]
[ 2811, 4 ]
[ 2815, 44 ]
python
en
['en', 'it', 'en']
True
Distribution.as_requirement
(self)
Return a ``Requirement`` that matches this distribution exactly
Return a ``Requirement`` that matches this distribution exactly
def as_requirement(self): """Return a ``Requirement`` that matches this distribution exactly""" if isinstance(self.parsed_version, packaging.version.Version): spec = "%s==%s" % (self.project_name, self.parsed_version) else: spec = "%s===%s" % (self.project_name, self.pars...
[ "def", "as_requirement", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "parsed_version", ",", "packaging", ".", "version", ".", "Version", ")", ":", "spec", "=", "\"%s==%s\"", "%", "(", "self", ".", "project_name", ",", "self", ".", "parse...
[ 2837, 4 ]
[ 2844, 38 ]
python
en
['en', 'en', 'en']
True
Distribution.load_entry_point
(self, group, name)
Return the `name` entry point of `group` or raise ImportError
Return the `name` entry point of `group` or raise ImportError
def load_entry_point(self, group, name): """Return the `name` entry point of `group` or raise ImportError""" ep = self.get_entry_info(group, name) if ep is None: raise ImportError("Entry point %r not found" % ((group, name),)) return ep.load()
[ "def", "load_entry_point", "(", "self", ",", "group", ",", "name", ")", ":", "ep", "=", "self", ".", "get_entry_info", "(", "group", ",", "name", ")", "if", "ep", "is", "None", ":", "raise", "ImportError", "(", "\"Entry point %r not found\"", "%", "(", "...
[ 2846, 4 ]
[ 2851, 24 ]
python
en
['en', 'en', 'en']
True
Distribution.get_entry_map
(self, group=None)
Return the entry point map for `group`, or the full entry map
Return the entry point map for `group`, or the full entry map
def get_entry_map(self, group=None): """Return the entry point map for `group`, or the full entry map""" try: ep_map = self._ep_map except AttributeError: ep_map = self._ep_map = EntryPoint.parse_map( self._get_metadata('entry_points.txt'), self ...
[ "def", "get_entry_map", "(", "self", ",", "group", "=", "None", ")", ":", "try", ":", "ep_map", "=", "self", ".", "_ep_map", "except", "AttributeError", ":", "ep_map", "=", "self", ".", "_ep_map", "=", "EntryPoint", ".", "parse_map", "(", "self", ".", ...
[ 2853, 4 ]
[ 2863, 21 ]
python
en
['en', 'en', 'en']
True
Distribution.get_entry_info
(self, group, name)
Return the EntryPoint object for `group`+`name`, or ``None``
Return the EntryPoint object for `group`+`name`, or ``None``
def get_entry_info(self, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return self.get_entry_map(group).get(name)
[ "def", "get_entry_info", "(", "self", ",", "group", ",", "name", ")", ":", "return", "self", ".", "get_entry_map", "(", "group", ")", ".", "get", "(", "name", ")" ]
[ 2865, 4 ]
[ 2867, 50 ]
python
en
['en', 'en', 'en']
True
Distribution.insert_on
(self, path, loc=None, replace=False)
Ensure self.location is on path If replace=False (default): - If location is already in path anywhere, do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead of the parent. - Else: add to the end of path. ...
Ensure self.location is on path
def insert_on(self, path, loc=None, replace=False): """Ensure self.location is on path If replace=False (default): - If location is already in path anywhere, do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead...
[ "def", "insert_on", "(", "self", ",", "path", ",", "loc", "=", "None", ",", "replace", "=", "False", ")", ":", "loc", "=", "loc", "or", "self", ".", "location", "if", "not", "loc", ":", "return", "nloc", "=", "_normalize_cached", "(", "loc", ")", "...
[ 2869, 4 ]
[ 2935, 14 ]
python
en
['en', 'en', 'en']
True
Distribution.clone
(self, **kw)
Copy this distribution, substituting in any changed keyword args
Copy this distribution, substituting in any changed keyword args
def clone(self, **kw): """Copy this distribution, substituting in any changed keyword args""" names = 'project_name version py_version platform location precedence' for attr in names.split(): kw.setdefault(attr, getattr(self, attr, None)) kw.setdefault('metadata', self._provi...
[ "def", "clone", "(", "self", ",", "*", "*", "kw", ")", ":", "names", "=", "'project_name version py_version platform location precedence'", "for", "attr", "in", "names", ".", "split", "(", ")", ":", "kw", ".", "setdefault", "(", "attr", ",", "getattr", "(", ...
[ 2967, 4 ]
[ 2973, 35 ]
python
en
['en', 'en', 'en']
True
EggInfoDistribution._reload_version
(self)
Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not be parsed properly dow...
Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not be parsed properly dow...
def _reload_version(self): """ Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not ...
[ "def", "_reload_version", "(", "self", ")", ":", "md_version", "=", "self", ".", "_get_version", "(", ")", "if", "md_version", ":", "self", ".", "_version", "=", "md_version", "return", "self" ]
[ 2981, 4 ]
[ 2996, 19 ]
python
en
['en', 'error', 'th']
False
StreamBookmark.save
(self, resume_token: str)
Save resume_token to DynamoDB
Save resume_token to DynamoDB
def save(self, resume_token: str) -> None: """Save resume_token to DynamoDB""" try: self.dynamo.insert_item(data=resume_token) except: print("error saving bookmark")
[ "def", "save", "(", "self", ",", "resume_token", ":", "str", ")", "->", "None", ":", "try", ":", "self", ".", "dynamo", ".", "insert_item", "(", "data", "=", "resume_token", ")", "except", ":", "print", "(", "\"error saving bookmark\"", ")" ]
[ 8, 4 ]
[ 13, 42 ]
python
en
['en', 'jv', 'en']
True
lpf
(current, new, alpha: float)
:param alpha: Filter constant. 0 ==> current. 1 ==> new.
:param alpha: Filter constant. 0 ==> current. 1 ==> new.
def lpf(current, new, alpha: float) -> float: """ :param alpha: Filter constant. 0 ==> current. 1 ==> new. """ return (1 - alpha) * current + alpha * new
[ "def", "lpf", "(", "current", ",", "new", ",", "alpha", ":", "float", ")", "->", "float", ":", "return", "(", "1", "-", "alpha", ")", "*", "current", "+", "alpha", "*", "new" ]
[ 455, 0 ]
[ 459, 46 ]
python
en
['en', 'error', 'th']
False
Point.angle
(self, other: 'Point')
:return: The angle [degrees] of the line drawn from this point to the other point.
:return: The angle [degrees] of the line drawn from this point to the other point.
def angle(self, other: 'Point') -> float: """:return: The angle [degrees] of the line drawn from this point to the other point.""" angle = atan2(other.y - self.y, other.x - self.x) * 180 / pi return normalize_angle_degrees(angle)
[ "def", "angle", "(", "self", ",", "other", ":", "'Point'", ")", "->", "float", ":", "angle", "=", "atan2", "(", "other", ".", "y", "-", "self", ".", "y", ",", "other", ".", "x", "-", "self", ".", "x", ")", "*", "180", "/", "pi", "return", "no...
[ 445, 4 ]
[ 448, 45 ]
python
en
['en', 'en', 'en']
True
Point.distance
(self, other: 'Point')
:return: The distance [no units] of this point from the other point.
:return: The distance [no units] of this point from the other point.
def distance(self, other: 'Point') -> float: """:return: The distance [no units] of this point from the other point.""" return sqrt((other.x - self.x) ** 2 + (other.y - self.y) ** 2)
[ "def", "distance", "(", "self", ",", "other", ":", "'Point'", ")", "->", "float", ":", "return", "sqrt", "(", "(", "other", ".", "x", "-", "self", ".", "x", ")", "**", "2", "+", "(", "other", ".", "y", "-", "self", ".", "y", ")", "**", "2", ...
[ 450, 4 ]
[ 452, 70 ]
python
en
['en', 'en', 'en']
True
test_model_finder_dummy_multiclass
( model_finder_multiclass, split_dataset_multiclass, seed, multiclass_scorings, test_input )
Testing if DummyModel (for multiclass) is created correctly.
Testing if DummyModel (for multiclass) is created correctly.
def test_model_finder_dummy_multiclass( model_finder_multiclass, split_dataset_multiclass, seed, multiclass_scorings, test_input ): """Testing if DummyModel (for multiclass) is created correctly.""" X_train = split_dataset_multiclass[0] y_train = split_dataset_multiclass[2] expected_model = Dumm...
[ "def", "test_model_finder_dummy_multiclass", "(", "model_finder_multiclass", ",", "split_dataset_multiclass", ",", "seed", ",", "multiclass_scorings", ",", "test_input", ")", ":", "X_train", "=", "split_dataset_multiclass", "[", "0", "]", "y_train", "=", "split_dataset_mu...
[ 18, 0 ]
[ 36, 55 ]
python
en
['en', 'en', 'en']
True
test_model_finder_multiclass_dummy_model_results
(model_finder_multiclass, seed)
Testing if dummy_model_results() function returns correct DataFrame (multiclass).
Testing if dummy_model_results() function returns correct DataFrame (multiclass).
def test_model_finder_multiclass_dummy_model_results(model_finder_multiclass, seed): """Testing if dummy_model_results() function returns correct DataFrame (multiclass).""" _ = { "model": "DummyClassifier", "fit_time": np.nan, "params": "{{'constant': None, 'random_state': {seed}, 'strat...
[ "def", "test_model_finder_multiclass_dummy_model_results", "(", "model_finder_multiclass", ",", "seed", ")", ":", "_", "=", "{", "\"model\"", ":", "\"DummyClassifier\"", ",", "\"fit_time\"", ":", "np", ".", "nan", ",", "\"params\"", ":", "\"{{'constant': None, 'random_s...
[ 39, 0 ]
[ 55, 59 ]
python
en
['fr', 'en', 'en']
True
test_model_finder_multiclass_search
(model_finder_multiclass, multiclass_scorings, mode, expected_model, seed)
Testing if search() function returns expected Model (for multiclass).
Testing if search() function returns expected Model (for multiclass).
def test_model_finder_multiclass_search(model_finder_multiclass, multiclass_scorings, mode, expected_model, seed): """Testing if search() function returns expected Model (for multiclass).""" model_finder_multiclass._quicksearch_limit = 1 actual_model = model_finder_multiclass.search(models=None, scoring=mul...
[ "def", "test_model_finder_multiclass_search", "(", "model_finder_multiclass", ",", "multiclass_scorings", ",", "mode", ",", "expected_model", ",", "seed", ")", ":", "model_finder_multiclass", ".", "_quicksearch_limit", "=", "1", "actual_model", "=", "model_finder_multiclass...
[ 65, 0 ]
[ 70, 51 ]
python
en
['es', 'en', 'en']
True
test_model_finder_multiclass_search_defined_models
( model_finder_multiclass, multiclass_scorings, models, expected_model )
Testing if models provided explicitly are being scored and chosen properly in multiclass (including models not present in default models collection).
Testing if models provided explicitly are being scored and chosen properly in multiclass (including models not present in default models collection).
def test_model_finder_multiclass_search_defined_models( model_finder_multiclass, multiclass_scorings, models, expected_model ): """Testing if models provided explicitly are being scored and chosen properly in multiclass (including models not present in default models collection).""" actual_model = m...
[ "def", "test_model_finder_multiclass_search_defined_models", "(", "model_finder_multiclass", ",", "multiclass_scorings", ",", "models", ",", "expected_model", ")", ":", "actual_model", "=", "model_finder_multiclass", ".", "search", "(", "models", "=", "models", ",", "scor...
[ 90, 0 ]
[ 96, 51 ]
python
en
['en', 'en', 'en']
True
test_model_finder_perform_gridsearch_multiclass
( model_finder_multiclass, multiclass_scorings, chosen_classifiers_grid, seed )
Testing if gridsearch works and returns correct Models and result dict (in multiclass).
Testing if gridsearch works and returns correct Models and result dict (in multiclass).
def test_model_finder_perform_gridsearch_multiclass( model_finder_multiclass, multiclass_scorings, chosen_classifiers_grid, seed ): """Testing if gridsearch works and returns correct Models and result dict (in multiclass).""" expected_models = [ (DecisionTreeClassifier, {"max_depth": 10, "criter...
[ "def", "test_model_finder_perform_gridsearch_multiclass", "(", "model_finder_multiclass", ",", "multiclass_scorings", ",", "chosen_classifiers_grid", ",", "seed", ")", ":", "expected_models", "=", "[", "(", "DecisionTreeClassifier", ",", "{", "\"max_depth\"", ":", "10", "...
[ 99, 0 ]
[ 129, 43 ]
python
en
['en', 'en', 'en']
True
test_model_finder_perform_quicksearch_multiclass
( model_finder_multiclass, multiclass_scorings, chosen_classifiers_grid, seed )
Testing if quicksearch works and returns correct Models and result dict (in multiclass).
Testing if quicksearch works and returns correct Models and result dict (in multiclass).
def test_model_finder_perform_quicksearch_multiclass( model_finder_multiclass, multiclass_scorings, chosen_classifiers_grid, seed ): """Testing if quicksearch works and returns correct Models and result dict (in multiclass).""" expected_models = [ (DecisionTreeClassifier, 0.948507632718159), ...
[ "def", "test_model_finder_perform_quicksearch_multiclass", "(", "model_finder_multiclass", ",", "multiclass_scorings", ",", "chosen_classifiers_grid", ",", "seed", ")", ":", "expected_models", "=", "[", "(", "DecisionTreeClassifier", ",", "0.948507632718159", ")", ",", "(",...
[ 132, 0 ]
[ 153, 43 ]
python
en
['en', 'en', 'en']
True
test_model_finder_quicksearch_multiclass
( model_finder_multiclass, chosen_classifiers_grid, multiclass_scorings, limit, expected_models )
Testing if quicksearch correctly chooses only a limited number of found Models based on the limit (in multiclass).
Testing if quicksearch correctly chooses only a limited number of found Models based on the limit (in multiclass).
def test_model_finder_quicksearch_multiclass( model_finder_multiclass, chosen_classifiers_grid, multiclass_scorings, limit, expected_models ): """Testing if quicksearch correctly chooses only a limited number of found Models based on the limit (in multiclass).""" model_finder_multiclass._quicksearch...
[ "def", "test_model_finder_quicksearch_multiclass", "(", "model_finder_multiclass", ",", "chosen_classifiers_grid", ",", "multiclass_scorings", ",", "limit", ",", "expected_models", ")", ":", "model_finder_multiclass", ".", "_quicksearch_limit", "=", "limit", "actual_models", ...
[ 163, 0 ]
[ 171, 43 ]
python
en
['en', 'en', 'en']
True
test_model_finder_assess_models_multiclass
(model_finder_multiclass, multiclass_scorings, seed)
Testing if assess_model function returns correct Models and result dict (in multiclass).
Testing if assess_model function returns correct Models and result dict (in multiclass).
def test_model_finder_assess_models_multiclass(model_finder_multiclass, multiclass_scorings, seed): """Testing if assess_model function returns correct Models and result dict (in multiclass).""" models = [ DecisionTreeClassifier(**{"max_depth": 10, "criterion": "entropy", "random_state": seed}), ...
[ "def", "test_model_finder_assess_models_multiclass", "(", "model_finder_multiclass", ",", "multiclass_scorings", ",", "seed", ")", ":", "models", "=", "[", "DecisionTreeClassifier", "(", "*", "*", "{", "\"max_depth\"", ":", "10", ",", "\"criterion\"", ":", "\"entropy\...
[ 174, 0 ]
[ 192, 70 ]
python
en
['en', 'en', 'en']
True
test_model_finder_multiclass_search_results_dataframe
(model_finder_multiclass_fitted, limit, seed)
Testing if search_results_dataframe is being correctly filtered out to a provided model_limit (in multiclass)
Testing if search_results_dataframe is being correctly filtered out to a provided model_limit (in multiclass)
def test_model_finder_multiclass_search_results_dataframe(model_finder_multiclass_fitted, limit, seed): """Testing if search_results_dataframe is being correctly filtered out to a provided model_limit (in multiclass)""" models = ["DecisionTreeClassifier", "LogisticRegression", "SVC"] dummy = ["DummyClas...
[ "def", "test_model_finder_multiclass_search_results_dataframe", "(", "model_finder_multiclass_fitted", ",", "limit", ",", "seed", ")", ":", "models", "=", "[", "\"DecisionTreeClassifier\"", ",", "\"LogisticRegression\"", ",", "\"SVC\"", "]", "dummy", "=", "[", "\"DummyCla...
[ 202, 0 ]
[ 214, 55 ]
python
en
['en', 'en', 'en']
True
test_model_finder_multiclass_create_scoring_multiclass
( model_finder_multiclass, input_func, expected_results )
Testing if creating closures (and adding them to regular scorings) for multiclass scorings works correctly.
Testing if creating closures (and adding them to regular scorings) for multiclass scorings works correctly.
def test_model_finder_multiclass_create_scoring_multiclass( model_finder_multiclass, input_func, expected_results ): """Testing if creating closures (and adding them to regular scorings) for multiclass scorings works correctly.""" y_actual = 1 y_predicted = 2 def plus_one(y_true, y_score): ...
[ "def", "test_model_finder_multiclass_create_scoring_multiclass", "(", "model_finder_multiclass", ",", "input_func", ",", "expected_results", ")", ":", "y_actual", "=", "1", "y_predicted", "=", "2", "def", "plus_one", "(", "y_true", ",", "y_score", ")", ":", "return", ...
[ 231, 0 ]
[ 252, 45 ]
python
en
['en', 'en', 'en']
True
test_model_finder_multiclass_confusion_matrices
(model_finder_multiclass_fitted, limit)
Testing if confusion matrices are being correctly calculated and returned (in multiclass).
Testing if confusion matrices are being correctly calculated and returned (in multiclass).
def test_model_finder_multiclass_confusion_matrices(model_finder_multiclass_fitted, limit): """Testing if confusion matrices are being correctly calculated and returned (in multiclass).""" results = [ ("DecisionTreeClassifier", [11, 0, 0, 0, 6, 0, 0, 0, 8]), ("LogisticRegression", [11, 0, 0, 0, ...
[ "def", "test_model_finder_multiclass_confusion_matrices", "(", "model_finder_multiclass_fitted", ",", "limit", ")", ":", "results", "=", "[", "(", "\"DecisionTreeClassifier\"", ",", "[", "11", ",", "0", ",", "0", ",", "0", ",", "6", ",", "0", ",", "0", ",", ...
[ 263, 0 ]
[ 276, 70 ]
python
en
['en', 'en', 'en']
True
test_model_finder_predict_X_test_multiclass
(model_finder_multiclass_fitted, split_dataset_multiclass, limit, seed)
Testing if predictions of X_test split from found models are correct (in multiclass).
Testing if predictions of X_test split from found models are correct (in multiclass).
def test_model_finder_predict_X_test_multiclass(model_finder_multiclass_fitted, split_dataset_multiclass, limit, seed): """Testing if predictions of X_test split from found models are correct (in multiclass).""" models = [ DecisionTreeClassifier(**{"max_depth": 10, "random_state": seed}), Logist...
[ "def", "test_model_finder_predict_X_test_multiclass", "(", "model_finder_multiclass_fitted", ",", "split_dataset_multiclass", ",", "limit", ",", "seed", ")", ":", "models", "=", "[", "DecisionTreeClassifier", "(", "*", "*", "{", "\"max_depth\"", ":", "10", ",", "\"ran...
[ 287, 0 ]
[ 306, 67 ]
python
en
['en', 'en', 'en']
True
test_model_finder_calculate_model_score_multiclass_regular_scoring
( model_finder_multiclass, split_dataset_multiclass, model )
Testing if calculating model score works correctly in multiclass with scoring != roc_auc_score.
Testing if calculating model score works correctly in multiclass with scoring != roc_auc_score.
def test_model_finder_calculate_model_score_multiclass_regular_scoring( model_finder_multiclass, split_dataset_multiclass, model ): """Testing if calculating model score works correctly in multiclass with scoring != roc_auc_score.""" scoring = accuracy_score X_train = split_dataset_multiclass[0] ...
[ "def", "test_model_finder_calculate_model_score_multiclass_regular_scoring", "(", "model_finder_multiclass", ",", "split_dataset_multiclass", ",", "model", ")", ":", "scoring", "=", "accuracy_score", "X_train", "=", "split_dataset_multiclass", "[", "0", "]", "X_test", "=", ...
[ 317, 0 ]
[ 332, 43 ]
python
en
['en', 'en', 'en']
True
contained_in
(filename, directory)
Test if a file is located within the given directory.
Test if a file is located within the given directory.
def contained_in(filename, directory): """Test if a file is located within the given directory.""" filename = os.path.normcase(os.path.abspath(filename)) directory = os.path.normcase(os.path.abspath(directory)) return os.path.commonprefix([filename, directory]) == directory
[ "def", "contained_in", "(", "filename", ",", "directory", ")", ":", "filename", "=", "os", ".", "path", ".", "normcase", "(", "os", ".", "path", ".", "abspath", "(", "filename", ")", ")", "directory", "=", "os", ".", "path", ".", "normcase", "(", "os...
[ 67, 0 ]
[ 71, 67 ]
python
en
['en', 'en', 'en']
True
_build_backend
()
Find and load the build backend
Find and load the build backend
def _build_backend(): """Find and load the build backend""" # Add in-tree backend directories to the front of sys.path. backend_path = os.environ.get('PEP517_BACKEND_PATH') if backend_path: extra_pathitems = backend_path.split(os.pathsep) sys.path[:0] = extra_pathitems ep = os.envir...
[ "def", "_build_backend", "(", ")", ":", "# Add in-tree backend directories to the front of sys.path.", "backend_path", "=", "os", ".", "environ", ".", "get", "(", "'PEP517_BACKEND_PATH'", ")", "if", "backend_path", ":", "extra_pathitems", "=", "backend_path", ".", "spli...
[ 74, 0 ]
[ 99, 14 ]
python
en
['en', 'en', 'en']
True
get_requires_for_build_wheel
(config_settings)
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
Invoke the optional get_requires_for_build_wheel hook
def get_requires_for_build_wheel(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_wheel except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_wheel", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_wheel", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
[ 102, 0 ]
[ 113, 36 ]
python
en
['en', 'en', 'en']
True
prepare_metadata_for_build_wheel
( metadata_directory, config_settings, _allow_fallback)
Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined, unless _allow_fallback is False in which case HookMissing is raised.
Invoke optional prepare_metadata_for_build_wheel
def prepare_metadata_for_build_wheel( metadata_directory, config_settings, _allow_fallback): """Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined, unless _allow_fallback is False in which case HookMissing is raised. """ back...
[ "def", "prepare_metadata_for_build_wheel", "(", "metadata_directory", ",", "config_settings", ",", "_allow_fallback", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "prepare_metadata_for_build_wheel", "except", "AttributeE...
[ 116, 0 ]
[ 132, 56 ]
python
en
['en', 'no', 'en']
True
_dist_info_files
(whl_zip)
Identify the .dist-info folder inside a wheel ZipFile.
Identify the .dist-info folder inside a wheel ZipFile.
def _dist_info_files(whl_zip): """Identify the .dist-info folder inside a wheel ZipFile.""" res = [] for path in whl_zip.namelist(): m = re.match(r'[^/\\]+-[^/\\]+\.dist-info/', path) if m: res.append(path) if res: return res raise Exception("No .dist-info folder ...
[ "def", "_dist_info_files", "(", "whl_zip", ")", ":", "res", "=", "[", "]", "for", "path", "in", "whl_zip", ".", "namelist", "(", ")", ":", "m", "=", "re", ".", "match", "(", "r'[^/\\\\]+-[^/\\\\]+\\.dist-info/'", ",", "path", ")", "if", "m", ":", "res"...
[ 138, 0 ]
[ 147, 58 ]
python
en
['en', 'fy', 'en']
True
_get_wheel_metadata_from_wheel
( backend, metadata_directory, config_settings)
Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook.
Build a wheel and extract the metadata from it.
def _get_wheel_metadata_from_wheel( backend, metadata_directory, config_settings): """Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook. """ from zipfile import ZipFile whl_basename = backend.build_wheel(met...
[ "def", "_get_wheel_metadata_from_wheel", "(", "backend", ",", "metadata_directory", ",", "config_settings", ")", ":", "from", "zipfile", "import", "ZipFile", "whl_basename", "=", "backend", ".", "build_wheel", "(", "metadata_directory", ",", "config_settings", ")", "w...
[ 150, 0 ]
[ 166, 37 ]
python
en
['en', 'en', 'en']
True
_find_already_built_wheel
(metadata_directory)
Check for a wheel already built during the get_wheel_metadata hook.
Check for a wheel already built during the get_wheel_metadata hook.
def _find_already_built_wheel(metadata_directory): """Check for a wheel already built during the get_wheel_metadata hook. """ if not metadata_directory: return None metadata_parent = os.path.dirname(metadata_directory) if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)): ...
[ "def", "_find_already_built_wheel", "(", "metadata_directory", ")", ":", "if", "not", "metadata_directory", ":", "return", "None", "metadata_parent", "=", "os", ".", "path", ".", "dirname", "(", "metadata_directory", ")", "if", "not", "os", ".", "path", ".", "...
[ 169, 0 ]
[ 188, 23 ]
python
en
['en', 'en', 'en']
True
build_wheel
(wheel_directory, config_settings, metadata_directory=None)
Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel.
Invoke the mandatory build_wheel hook.
def build_wheel(wheel_directory, config_settings, metadata_directory=None): """Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel. """ prebuilt_whl = _find_already_built_wheel(m...
[ "def", "build_wheel", "(", "wheel_directory", ",", "config_settings", ",", "metadata_directory", "=", "None", ")", ":", "prebuilt_whl", "=", "_find_already_built_wheel", "(", "metadata_directory", ")", "if", "prebuilt_whl", ":", "shutil", ".", "copy2", "(", "prebuil...
[ 191, 0 ]
[ 204, 59 ]
python
en
['en', 'st', 'en']
True
get_requires_for_build_sdist
(config_settings)
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
Invoke the optional get_requires_for_build_wheel hook
def get_requires_for_build_sdist(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_sdist except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_sdist", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_sdist", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
[ 207, 0 ]
[ 218, 36 ]
python
en
['en', 'en', 'en']
True
build_sdist
(sdist_directory, config_settings)
Invoke the mandatory build_sdist hook.
Invoke the mandatory build_sdist hook.
def build_sdist(sdist_directory, config_settings): """Invoke the mandatory build_sdist hook.""" backend = _build_backend() try: return backend.build_sdist(sdist_directory, config_settings) except getattr(backend, 'UnsupportedOperation', _DummyException): raise GotUnsupportedOperation(tra...
[ "def", "build_sdist", "(", "sdist_directory", ",", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "return", "backend", ".", "build_sdist", "(", "sdist_directory", ",", "config_settings", ")", "except", "getattr", "(", "backe...
[ 231, 0 ]
[ 237, 61 ]
python
en
['en', 'st', '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: (...) -> AbstractDistribution """Prepare a distribution for installation. """ abstract_dist = ...
[ "def", "_get_prepared_distribution", "(", "req", ",", "# type: InstallRequirement", "req_tracker", ",", "# type: RequirementTracker", "finder", ",", "# type: PackageFinder", "build_isolation", "# type: bool", ")", ":", "# type: (...) -> AbstractDistribution", "abstract_dist", "="...
[ 79, 0 ]
[ 91, 24 ]
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...
[ 135, 0 ]
[ 153, 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...
[ 188, 0 ]
[ 218, 40 ]
python
en
['en', 'en', 'en']
True
unpack_url
( link, # type: Link location, # type: str downloader, # 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 downloader, # 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 o...
[ "def", "unpack_url", "(", "link", ",", "# type: Link", "location", ",", "# type: str", "downloader", ",", "# type: Downloader", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) ...
[ 221, 0 ]
[ 266, 15 ]
python
en
['it', 'en', 'en']
True
_download_http_url
( link, # type: Link downloader, # type: Downloader temp_dir, # type: str hashes, # type: Optional[Hashes] )
Download link url into temp_dir using provided session
Download link url into temp_dir using provided session
def _download_http_url( link, # type: Link downloader, # type: Downloader temp_dir, # type: str hashes, # type: Optional[Hashes] ): # type: (...) -> Tuple[str, str] """Download link url into temp_dir using provided session""" download = downloader(link) file_path = os.path.join(temp...
[ "def", "_download_http_url", "(", "link", ",", "# type: Link", "downloader", ",", "# type: Downloader", "temp_dir", ",", "# type: str", "hashes", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> Tuple[str, str]", "download", "=", "downloader", "(", "link", "...
[ 269, 0 ]
[ 287, 71 ]
python
en
['en', '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", "...
[ 290, 0 ]
[ 313, 24 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._log_preparing_link
(self, req)
Log the way the link prepared.
Log the way the link prepared.
def _log_preparing_link(self, req): # type: (InstallRequirement) -> None """Log the way the link prepared.""" if req.link.is_file: path = req.link.file_path logger.info('Processing %s', display_path(path)) else: logger.info('Collecting %s', req.req or ...
[ "def", "_log_preparing_link", "(", "self", ",", "req", ")", ":", "# type: (InstallRequirement) -> None", "if", "req", ".", "link", ".", "is_file", ":", "path", "=", "req", ".", "link", ".", "file_path", "logger", ".", "info", "(", "'Processing %s'", ",", "di...
[ 379, 4 ]
[ 386, 56 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._ensure_link_req_src_dir
(self, req, download_dir, parallel_builds)
Ensure source_dir of a linked InstallRequirement.
Ensure source_dir of a linked InstallRequirement.
def _ensure_link_req_src_dir(self, req, download_dir, parallel_builds): # type: (InstallRequirement, Optional[str], 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...
[ "def", "_ensure_link_req_src_dir", "(", "self", ",", "req", ",", "download_dir", ",", "parallel_builds", ")", ":", "# type: (InstallRequirement, Optional[str], bool) -> None", "# Since source_dir is only set for editable requirements.", "if", "req", ".", "link", ".", "is_wheel"...
[ 388, 4 ]
[ 416, 13 ]
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) -> AbstractDistribution """Prepare a requirement to be obtained from req.link.""" assert req.link link = req.link self._log_preparing_link(req) if link.is_wheel and self.w...
[ "def", "prepare_linked_requirement", "(", "self", ",", "req", ",", "parallel_builds", "=", "False", ")", ":", "# type: (InstallRequirement, bool) -> AbstractDistribution", "assert", "req", ".", "link", "link", "=", "req", ".", "link", "self", ".", "_log_preparing_link...
[ 451, 4 ]
[ 501, 28 ]
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: (...) -> AbstractDistribution """Prepare an editable requirement """ assert req.editable, "cannot prepare a non-editable req as editable" logger.info('Obtaining %s', req) ...
[ "def", "prepare_editable_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", ")", ":", "# type: (...) -> AbstractDistribution", "assert", "req", ".", "editable", ",", "\"cannot prepare a non-editable req as editable\"", "logger", ".", "info", "(", "'Ob...
[ 503, 4 ]
[ 532, 28 ]
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: (...) -> AbstractDistribution """Prepare an already-installed requirement """ assert req.satisfied_by, "req should have been satisfied but isn't" ...
[ "def", "prepare_installed_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", "skip_reason", "# type: str", ")", ":", "# type: (...) -> AbstractDistribution", "assert", "req", ".", "satisfied_by", ",", "\"req should have been satisfied but isn't\"", "asser...
[ 534, 4 ]
[ 561, 28 ]
python
en
['en', 'en', 'en']
True
TabView.get_tabs
(self, request, **kwargs)
Returns the initialized tab group for this view.
Returns the initialized tab group for this view.
def get_tabs(self, request, **kwargs): """Returns the initialized tab group for this view.""" if self._tab_group is None: self._tab_group = self.tab_group_class(request, **kwargs) return self._tab_group
[ "def", "get_tabs", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_tab_group", "is", "None", ":", "self", ".", "_tab_group", "=", "self", ".", "tab_group_class", "(", "request", ",", "*", "*", "kwargs", ")", "retu...
[ 39, 4 ]
[ 43, 30 ]
python
en
['en', 'en', 'en']
True
TabView.get_context_data
(self, **kwargs)
Adds the ``tab_group`` variable to the context data.
Adds the ``tab_group`` variable to the context data.
def get_context_data(self, **kwargs): """Adds the ``tab_group`` variable to the context data.""" context = super(TabView, self).get_context_data(**kwargs) try: tab_group = self.get_tabs(self.request, **kwargs) context["tab_group"] = tab_group # Make sure our d...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "TabView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "try", ":", "tab_group", "=", "self", ".", "get_tabs", "(", "...
[ 45, 4 ]
[ 55, 22 ]
python
en
['en', 'en', 'en']
True
TabView.handle_tabbed_response
(self, tab_group, context)
Sends back an AJAX-appropriate response for the tab group if needed. Otherwise renders the response as normal.
Sends back an AJAX-appropriate response for the tab group if needed.
def handle_tabbed_response(self, tab_group, context): """Sends back an AJAX-appropriate response for the tab group if needed. Otherwise renders the response as normal. """ if self.request.is_ajax(): if tab_group.selected: return http.HttpResponse(tab_group.se...
[ "def", "handle_tabbed_response", "(", "self", ",", "tab_group", ",", "context", ")", ":", "if", "self", ".", "request", ".", "is_ajax", "(", ")", ":", "if", "tab_group", ".", "selected", ":", "return", "http", ".", "HttpResponse", "(", "tab_group", ".", ...
[ 57, 4 ]
[ 67, 47 ]
python
en
['en', 'en', 'en']
True
TabbedTableView.load_tabs
(self)
Loads the tab group. It compiles the table instances for each table attached to any :class:`horizon.tabs.TableTab` instances on the tab group. This step is necessary before processing any tab or table actions.
Loads the tab group.
def load_tabs(self): """Loads the tab group. It compiles the table instances for each table attached to any :class:`horizon.tabs.TableTab` instances on the tab group. This step is necessary before processing any tab or table actions. """ tab_group = self.get_tabs(self.re...
[ "def", "load_tabs", "(", "self", ")", ":", "tab_group", "=", "self", ".", "get_tabs", "(", "self", ".", "request", ",", "*", "*", "self", ".", "kwargs", ")", "tabs", "=", "tab_group", ".", "get_tabs", "(", ")", "for", "tab", "in", "[", "t", "for", ...
[ 80, 4 ]
[ 93, 65 ]
python
en
['en', 'en', 'en']
True
TabbedTableView.get_tables
(self)
A no-op on this class. Tables are handled at the tab level.
A no-op on this class. Tables are handled at the tab level.
def get_tables(self): """A no-op on this class. Tables are handled at the tab level.""" # Override the base class implementation so that the MultiTableMixin # doesn't freak out. We do the processing at the TableTab level. return {}
[ "def", "get_tables", "(", "self", ")", ":", "# Override the base class implementation so that the MultiTableMixin", "# doesn't freak out. We do the processing at the TableTab level.", "return", "{", "}" ]
[ 95, 4 ]
[ 99, 17 ]
python
en
['en', 'en', 'en']
True
TabbedTableView.handle_table
(self, table_dict)
Loads the table data based on a given table_dict and handles them. For the given dict containing a ``DataTable`` and a ``TableTab`` instance, it loads the table data for that tab and calls the table's :meth:`~horizon.tables.DataTable.maybe_handle` method. The return value will be the re...
Loads the table data based on a given table_dict and handles them.
def handle_table(self, table_dict): """Loads the table data based on a given table_dict and handles them. For the given dict containing a ``DataTable`` and a ``TableTab`` instance, it loads the table data for that tab and calls the table's :meth:`~horizon.tables.DataTable.maybe_handle` ...
[ "def", "handle_table", "(", "self", ",", "table_dict", ")", ":", "table", "=", "table_dict", "[", "'table'", "]", "tab", "=", "table_dict", "[", "'tab'", "]", "tab", ".", "load_table_data", "(", ")", "table_name", "=", "table", ".", "_meta", ".", "name",...
[ 101, 4 ]
[ 116, 22 ]
python
en
['en', 'en', 'en']
True
normcase
(s)
Normalize case of pathname. Makes all characters lowercase and all slashes into backslashes.
Normalize case of pathname.
def normcase(s): """Normalize case of pathname. Makes all characters lowercase and all slashes into backslashes.""" s = os.fspath(s) try: if isinstance(s, bytes): return s.replace(b'/', b'\\').lower() else: return s.replace('/', '\\').lower() except (TypeErro...
[ "def", "normcase", "(", "s", ")", ":", "s", "=", "os", ".", "fspath", "(", "s", ")", "try", ":", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "return", "s", ".", "replace", "(", "b'/'", ",", "b'\\\\'", ")", ".", "lower", "(", ")", "e...
[ 43, 0 ]
[ 57, 13 ]
python
en
['en', 'en', 'en']
True
isabs
(s)
Test whether a path is absolute
Test whether a path is absolute
def isabs(s): """Test whether a path is absolute""" s = os.fspath(s) s = splitdrive(s)[1] return len(s) > 0 and s[0] in _get_bothseps(s)
[ "def", "isabs", "(", "s", ")", ":", "s", "=", "os", ".", "fspath", "(", "s", ")", "s", "=", "splitdrive", "(", "s", ")", "[", "1", "]", "return", "len", "(", "s", ")", ">", "0", "and", "s", "[", "0", "]", "in", "_get_bothseps", "(", "s", ...
[ 66, 0 ]
[ 70, 50 ]
python
en
['en', 'en', 'en']
True
splitdrive
(p)
Split a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty. If you assign result = splitdrive(p) It is always true that: result[0] + result[1] == p If the path contained a drive letter, drive_or_unc will con...
Split a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty.
def splitdrive(p): """Split a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty. If you assign result = splitdrive(p) It is always true that: result[0] + result[1] == p If the path contained a drive let...
[ "def", "splitdrive", "(", "p", ")", ":", "p", "=", "os", ".", "fspath", "(", "p", ")", "if", "len", "(", "p", ")", ">=", "2", ":", "if", "isinstance", "(", "p", ",", "bytes", ")", ":", "sep", "=", "b'\\\\'", "altsep", "=", "b'/'", "colon", "=...
[ 121, 0 ]
[ 169, 19 ]
python
en
['en', 'en', 'en']
True
splitunc
(p)
Deprecated since Python 3.1. Please use splitdrive() instead; it now handles UNC paths. Split a pathname into UNC mount point and relative path specifiers. Return a 2-tuple (unc, rest); either part may be empty. If unc is not empty, it has the form '//host/mount' (or similar using backslashes). ...
Deprecated since Python 3.1. Please use splitdrive() instead; it now handles UNC paths.
def splitunc(p): """Deprecated since Python 3.1. Please use splitdrive() instead; it now handles UNC paths. Split a pathname into UNC mount point and relative path specifiers. Return a 2-tuple (unc, rest); either part may be empty. If unc is not empty, it has the form '//host/mount' (or similar ...
[ "def", "splitunc", "(", "p", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"ntpath.splitunc is deprecated, use ntpath.splitdrive instead\"", ",", "DeprecationWarning", ",", "2", ")", "drive", ",", "path", "=", "splitdrive", "(", "p", ")", "if", ...
[ 173, 0 ]
[ 191, 22 ]
python
en
['en', 'en', 'en']
True
split
(p)
Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.
Split a pathname.
def split(p): """Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.""" p = os.fspath(p) seps = _get_bothseps(p) d, p = splitdrive(p) # set i to index beyond p's last slash i = len(p) while i and p[i-1] not in seps: ...
[ "def", "split", "(", "p", ")", ":", "p", "=", "os", ".", "fspath", "(", "p", ")", "seps", "=", "_get_bothseps", "(", "p", ")", "d", ",", "p", "=", "splitdrive", "(", "p", ")", "# set i to index beyond p's last slash", "i", "=", "len", "(", "p", ")"...
[ 199, 0 ]
[ 214, 25 ]
python
en
['en', 'ht', 'en']
True
basename
(p)
Returns the final component of a pathname
Returns the final component of a pathname
def basename(p): """Returns the final component of a pathname""" return split(p)[1]
[ "def", "basename", "(", "p", ")", ":", "return", "split", "(", "p", ")", "[", "1", "]" ]
[ 233, 0 ]
[ 235, 22 ]
python
en
['en', 'en', 'en']
True
dirname
(p)
Returns the directory component of a pathname
Returns the directory component of a pathname
def dirname(p): """Returns the directory component of a pathname""" return split(p)[0]
[ "def", "dirname", "(", "p", ")", ":", "return", "split", "(", "p", ")", "[", "0", "]" ]
[ 240, 0 ]
[ 242, 22 ]
python
en
['en', 'en', 'en']
True
islink
(path)
Test whether a path is a symbolic link. This will always return false for Windows prior to 6.0.
Test whether a path is a symbolic link. This will always return false for Windows prior to 6.0.
def islink(path): """Test whether a path is a symbolic link. This will always return false for Windows prior to 6.0. """ try: st = os.lstat(path) except (OSError, AttributeError): return False return stat.S_ISLNK(st.st_mode)
[ "def", "islink", "(", "path", ")", ":", "try", ":", "st", "=", "os", ".", "lstat", "(", "path", ")", "except", "(", "OSError", ",", "AttributeError", ")", ":", "return", "False", "return", "stat", ".", "S_ISLNK", "(", "st", ".", "st_mode", ")" ]
[ 247, 0 ]
[ 255, 35 ]
python
en
['en', 'en', 'en']
True
lexists
(path)
Test whether a path exists. Returns True for broken symbolic links
Test whether a path exists. Returns True for broken symbolic links
def lexists(path): """Test whether a path exists. Returns True for broken symbolic links""" try: st = os.lstat(path) except OSError: return False return True
[ "def", "lexists", "(", "path", ")", ":", "try", ":", "st", "=", "os", ".", "lstat", "(", "path", ")", "except", "OSError", ":", "return", "False", "return", "True" ]
[ 259, 0 ]
[ 265, 15 ]
python
en
['en', 'en', 'en']
True
ismount
(path)
Test whether a path is a mount point (a drive root, the root of a share, or a mounted volume)
Test whether a path is a mount point (a drive root, the root of a share, or a mounted volume)
def ismount(path): """Test whether a path is a mount point (a drive root, the root of a share, or a mounted volume)""" path = os.fspath(path) seps = _get_bothseps(path) path = abspath(path) root, rest = splitdrive(path) if root and root[0] in seps: return (not rest) or (rest in seps)...
[ "def", "ismount", "(", "path", ")", ":", "path", "=", "os", ".", "fspath", "(", "path", ")", "seps", "=", "_get_bothseps", "(", "path", ")", "path", "=", "abspath", "(", "path", ")", "root", ",", "rest", "=", "splitdrive", "(", "path", ")", "if", ...
[ 281, 0 ]
[ 296, 20 ]
python
en
['en', 'en', 'en']
True
expanduser
(path)
Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.
Expand ~ and ~user constructs.
def expanduser(path): """Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.""" path = os.fspath(path) if isinstance(path, bytes): tilde = b'~' else: tilde = '~' if not path.startswith(tilde): return path i, n = 1, len(path) while i < n and pa...
[ "def", "expanduser", "(", "path", ")", ":", "path", "=", "os", ".", "fspath", "(", "path", ")", "if", "isinstance", "(", "path", ",", "bytes", ")", ":", "tilde", "=", "b'~'", "else", ":", "tilde", "=", "'~'", "if", "not", "path", ".", "startswith",...
[ 308, 0 ]
[ 342, 30 ]
python
en
['en', 'en', 'en']
True
expandvars
(path)
Expand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.
Expand shell variables of the forms $var, ${var} and %var%.
def expandvars(path): """Expand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.""" path = os.fspath(path) if isinstance(path, bytes): if b'$' not in path and b'%' not in path: return path import string varchars = bytes(strin...
[ "def", "expandvars", "(", "path", ")", ":", "path", "=", "os", ".", "fspath", "(", "path", ")", "if", "isinstance", "(", "path", ",", "bytes", ")", ":", "if", "b'$'", "not", "in", "path", "and", "b'%'", "not", "in", "path", ":", "return", "path", ...
[ 358, 0 ]
[ 464, 14 ]
python
en
['en', 'en', 'en']
True
normpath
(path)
Normalize path, eliminating double slashes, etc.
Normalize path, eliminating double slashes, etc.
def normpath(path): """Normalize path, eliminating double slashes, etc.""" path = os.fspath(path) if isinstance(path, bytes): sep = b'\\' altsep = b'/' curdir = b'.' pardir = b'..' special_prefixes = (b'\\\\.\\', b'\\\\?\\') else: sep = '\\' altsep...
[ "def", "normpath", "(", "path", ")", ":", "path", "=", "os", ".", "fspath", "(", "path", ")", "if", "isinstance", "(", "path", ",", "bytes", ")", ":", "sep", "=", "b'\\\\'", "altsep", "=", "b'/'", "curdir", "=", "b'.'", "pardir", "=", "b'..'", "spe...
[ 471, 0 ]
[ 518, 35 ]
python
en
['fr', 'zu', 'en']
False
relpath
(path, start=None)
Return a relative version of a path
Return a relative version of a path
def relpath(path, start=None): """Return a relative version of a path""" path = os.fspath(path) if isinstance(path, bytes): sep = b'\\' curdir = b'.' pardir = b'..' else: sep = '\\' curdir = '.' pardir = '..' if start is None: start = curdir ...
[ "def", "relpath", "(", "path", ",", "start", "=", "None", ")", ":", "path", "=", "os", ".", "fspath", "(", "path", ")", "if", "isinstance", "(", "path", ",", "bytes", ")", ":", "sep", "=", "b'\\\\'", "curdir", "=", "b'.'", "pardir", "=", "b'..'", ...
[ 559, 0 ]
[ 602, 13 ]
python
en
['en', 'co', 'en']
True
commonpath
(paths)
Given a sequence of path names, returns the longest common sub-path.
Given a sequence of path names, returns the longest common sub-path.
def commonpath(paths): """Given a sequence of path names, returns the longest common sub-path.""" if not paths: raise ValueError('commonpath() arg is an empty sequence') paths = tuple(map(os.fspath, paths)) if isinstance(paths[0], bytes): sep = b'\\' altsep = b'/' curdi...
[ "def", "commonpath", "(", "paths", ")", ":", "if", "not", "paths", ":", "raise", "ValueError", "(", "'commonpath() arg is an empty sequence'", ")", "paths", "=", "tuple", "(", "map", "(", "os", ".", "fspath", ",", "paths", ")", ")", "if", "isinstance", "("...
[ 615, 0 ]
[ 664, 13 ]
python
en
['en', 'en', 'en']
True
VolumesnapshotsTable.delete_volume_snapshots
(self, delete_button)
Batch Delete table action.
Batch Delete table action.
def delete_volume_snapshots(self, delete_button): """Batch Delete table action.""" delete_button.click() return forms.BaseFormRegion(self.driver, self.conf)
[ "def", "delete_volume_snapshots", "(", "self", ",", "delete_button", ")", ":", "delete_button", ".", "click", "(", ")", "return", "forms", ".", "BaseFormRegion", "(", "self", ".", "driver", ",", "self", ".", "conf", ")" ]
[ 32, 4 ]
[ 35, 59 ]
python
en
['en', 'fr', 'en']
True
VolumesnapshotsTable.delete_volume_snapshot
(self, delete_button, row)
Per-entity delete row action.
Per-entity delete row action.
def delete_volume_snapshot(self, delete_button, row): """Per-entity delete row action.""" delete_button.click() return forms.BaseFormRegion(self.driver, self.conf)
[ "def", "delete_volume_snapshot", "(", "self", ",", "delete_button", ",", "row", ")", ":", "delete_button", ".", "click", "(", ")", "return", "forms", ".", "BaseFormRegion", "(", "self", ".", "driver", ",", "self", ".", "conf", ")" ]
[ 38, 4 ]
[ 41, 59 ]
python
en
['en', 'es', 'it']
False
clear_scheduled_invitation_emails
(email: str)
Unlike most scheduled emails, invitation emails don't have an existing user object to key off of, so we filter by address here.
Unlike most scheduled emails, invitation emails don't have an existing user object to key off of, so we filter by address here.
def clear_scheduled_invitation_emails(email: str) -> None: """Unlike most scheduled emails, invitation emails don't have an existing user object to key off of, so we filter by address here.""" items = ScheduledEmail.objects.filter( address__iexact=email, type=ScheduledEmail.INVITATION_REMINDER )...
[ "def", "clear_scheduled_invitation_emails", "(", "email", ":", "str", ")", "->", "None", ":", "items", "=", "ScheduledEmail", ".", "objects", ".", "filter", "(", "address__iexact", "=", "email", ",", "type", "=", "ScheduledEmail", ".", "INVITATION_REMINDER", ")"...
[ 382, 0 ]
[ 388, 18 ]
python
en
['en', 'en', 'en']
True
send_custom_email
(users: List[UserProfile], options: Dict[str, Any])
Can be used directly with from a management shell with send_custom_email(user_profile_list, dict( markdown_template_path="/path/to/markdown/file.md", subject="Email subject", from_name="Sender Name") )
Can be used directly with from a management shell with send_custom_email(user_profile_list, dict( markdown_template_path="/path/to/markdown/file.md", subject="Email subject", from_name="Sender Name") )
def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None: """ Can be used directly with from a management shell with send_custom_email(user_profile_list, dict( markdown_template_path="/path/to/markdown/file.md", subject="Email subject", from_name="Sender Name"...
[ "def", "send_custom_email", "(", "users", ":", "List", "[", "UserProfile", "]", ",", "options", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "with", "open", "(", "options", "[", "\"markdown_template_path\"", "]", ")", "as", "f", ":...
[ 456, 0 ]
[ 523, 17 ]
python
en
['en', 'error', 'th']
False
modernize_apns_payload
(data: Dict[str, Any])
Take a payload in an unknown Zulip version's format, and return in current format.
Take a payload in an unknown Zulip version's format, and return in current format.
def modernize_apns_payload(data: Dict[str, Any]) -> Dict[str, Any]: """Take a payload in an unknown Zulip version's format, and return in current format.""" # TODO this isn't super robust as is -- if a buggy remote server # sends a malformed payload, we are likely to raise an exception. if "message_ids"...
[ "def", "modernize_apns_payload", "(", "data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "# TODO this isn't super robust as is -- if a buggy remote server", "# sends a malformed payload, we are likely to raise an exception...
[ 86, 0 ]
[ 109, 19 ]
python
en
['en', 'en', 'en']
True
parse_gcm_options
(options: Dict[str, Any], data: Dict[str, Any])
Parse GCM options, supplying defaults, and raising an error if invalid. The options permitted here form part of the Zulip notification bouncer's API. They are: `priority`: Passed through to GCM; see upstream doc linked below. Zulip servers should always set this; when unset, we guess a value...
Parse GCM options, supplying defaults, and raising an error if invalid.
def parse_gcm_options(options: Dict[str, Any], data: Dict[str, Any]) -> str: """ Parse GCM options, supplying defaults, and raising an error if invalid. The options permitted here form part of the Zulip notification bouncer's API. They are: `priority`: Passed through to GCM; see upstream doc link...
[ "def", "parse_gcm_options", "(", "options", ":", "Dict", "[", "str", ",", "Any", "]", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "priority", "=", "options", ".", "pop", "(", "\"priority\"", ",", "None", ")", "if",...
[ 245, 0 ]
[ 287, 19 ]
python
en
['en', 'error', 'th']
False
send_android_push_notification
( devices: List[DeviceToken], data: Dict[str, Any], options: Dict[str, Any], remote: bool = False )
Send a GCM message to the given devices. See https://firebase.google.com/docs/cloud-messaging/http-server-ref for the GCM upstream API which this talks to. data: The JSON object (decoded) to send as the 'data' parameter of the GCM message. options: Additional options to control the GCM me...
Send a GCM message to the given devices.
def send_android_push_notification( devices: List[DeviceToken], data: Dict[str, Any], options: Dict[str, Any], remote: bool = False ) -> None: """ Send a GCM message to the given devices. See https://firebase.google.com/docs/cloud-messaging/http-server-ref for the GCM upstream API which this talks ...
[ "def", "send_android_push_notification", "(", "devices", ":", "List", "[", "DeviceToken", "]", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", ",", "options", ":", "Dict", "[", "str", ",", "Any", "]", ",", "remote", ":", "bool", "=", "False", ...
[ 291, 0 ]
[ 378, 83 ]
python
en
['en', 'error', 'th']
False
push_notifications_enabled
()
True just if this server has configured a way to send push notifications.
True just if this server has configured a way to send push notifications.
def push_notifications_enabled() -> bool: """True just if this server has configured a way to send push notifications.""" if ( uses_notification_bouncer() and settings.ZULIP_ORG_KEY is not None and settings.ZULIP_ORG_ID is not None ): # nocoverage # We have the needed config...
[ "def", "push_notifications_enabled", "(", ")", "->", "bool", ":", "if", "(", "uses_notification_bouncer", "(", ")", "and", "settings", ".", "ZULIP_ORG_KEY", "is", "not", "None", "and", "settings", ".", "ZULIP_ORG_ID", "is", "not", "None", ")", ":", "# nocovera...
[ 517, 0 ]
[ 538, 16 ]
python
en
['en', 'en', 'en']
True
get_gcm_alert
(message: Message)
Determine what alert string to display based on the missed messages.
Determine what alert string to display based on the missed messages.
def get_gcm_alert(message: Message) -> str: """ Determine what alert string to display based on the missed messages. """ sender_str = message.sender.full_name if message.recipient.type == Recipient.HUDDLE and message.trigger == "private_message": return f"New private group message from {send...
[ "def", "get_gcm_alert", "(", "message", ":", "Message", ")", "->", "str", ":", "sender_str", "=", "message", ".", "sender", ".", "full_name", "if", "message", ".", "recipient", ".", "type", "==", "Recipient", ".", "HUDDLE", "and", "message", ".", "trigger"...
[ 553, 0 ]
[ 567, 100 ]
python
en
['en', 'error', 'th']
False