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
TarInfo._block
(self, count)
Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024.
Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024.
def _block(self, count): """Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. """ blocks, remainder = divmod(count, BLOCKSIZE) if remainder: blocks += 1 return blocks * BLOCKSIZE
[ "def", "_block", "(", "self", ",", "count", ")", ":", "blocks", ",", "remainder", "=", "divmod", "(", "count", ",", "BLOCKSIZE", ")", "if", "remainder", ":", "blocks", "+=", "1", "return", "blocks", "*", "BLOCKSIZE" ]
[ 1351, 4 ]
[ 1358, 33 ]
python
en
['en', 'en', 'en']
True
TarFile.__init__
(self, name=None, mode="r", fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None, copybufsize=None)
Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing d...
Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing d...
def __init__(self, name=None, mode="r", fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None, copybufsize=None): """Open an (uncompressed) tar archive `name'. `mode...
[ "def", "__init__", "(", "self", ",", "name", "=", "None", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "format", "=", "None", ",", "tarinfo", "=", "None", ",", "dereference", "=", "None", ",", "ignore_zeros", "=", "None", ",", "encodi...
[ 1408, 4 ]
[ 1506, 17 ]
python
en
['en', 'en', 'en']
True
TarFile.open
(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs)
Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. mode: 'r' or 'r:*' open for reading with transparent compression 'r:' open for reading exclusively uncompressed 'r:gz' open for reading with gzip compression ...
Open a tar archive for reading, writing or appending. Return an appropriate TarFile class.
def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. mode: 'r' or 'r:*' open for reading with transparent compression 'r:' open for readin...
[ "def", "open", "(", "cls", ",", "name", "=", "None", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "bufsize", "=", "RECORDSIZE", ",", "*", "*", "kwargs", ")", ":", "if", "not", "name", "and", "not", "fileobj", ":", "raise", "ValueErr...
[ 1520, 4 ]
[ 1608, 46 ]
python
en
['en', 'en', 'en']
True
TarFile.taropen
(cls, name, mode="r", fileobj=None, **kwargs)
Open uncompressed tar archive name for reading or writing.
Open uncompressed tar archive name for reading or writing.
def taropen(cls, name, mode="r", fileobj=None, **kwargs): """Open uncompressed tar archive name for reading or writing. """ if mode not in ("r", "a", "w", "x"): raise ValueError("mode must be 'r', 'a', 'w' or 'x'") return cls(name, mode, fileobj, **kwargs)
[ "def", "taropen", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "not", "in", "(", "\"r\"", ",", "\"a\"", ",", "\"w\"", ",", "\"x\"", ")", ":", "raise", "ValueErro...
[ 1611, 4 ]
[ 1616, 49 ]
python
en
['en', 'en', 'en']
True
TarFile.gzopen
(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs)
Open gzip compressed tar archive name for reading or writing. Appending is not allowed.
Open gzip compressed tar archive name for reading or writing. Appending is not allowed.
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if mode not in ("r", "w", "x"): raise ValueError("mode must be 'r', 'w' or 'x'") try: ...
[ "def", "gzopen", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "compresslevel", "=", "9", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "not", "in", "(", "\"r\"", ",", "\"w\"", ",", "\"x\"", ")", ":", ...
[ 1619, 4 ]
[ 1650, 16 ]
python
en
['en', 'en', 'en']
True
TarFile.bz2open
(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs)
Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed.
Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed.
def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if mode not in ("r", "w", "x"): raise ValueError("mode must be 'r', 'w' or 'x'") try: ...
[ "def", "bz2open", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "compresslevel", "=", "9", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "not", "in", "(", "\"r\"", ",", "\"w\"", ",", "\"x\"", ")", ":", ...
[ 1653, 4 ]
[ 1679, 16 ]
python
en
['en', 'en', 'en']
True
TarFile.xzopen
(cls, name, mode="r", fileobj=None, preset=None, **kwargs)
Open lzma compressed tar archive name for reading or writing. Appending is not allowed.
Open lzma compressed tar archive name for reading or writing. Appending is not allowed.
def xzopen(cls, name, mode="r", fileobj=None, preset=None, **kwargs): """Open lzma compressed tar archive name for reading or writing. Appending is not allowed. """ if mode not in ("r", "w", "x"): raise ValueError("mode must be 'r', 'w' or 'x'") try: i...
[ "def", "xzopen", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "preset", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "not", "in", "(", "\"r\"", ",", "\"w\"", ",", "\"x\"", ")", ":", "rai...
[ 1682, 4 ]
[ 1707, 16 ]
python
en
['en', 'en', 'en']
True
TarFile.close
(self)
Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive.
Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive.
def close(self): """Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive. """ if self.closed: return self.closed = True try: if self.mode in ("a", "w", "x"): self.fileobj.write(NUL * (BLOCKSIZE...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "return", "self", ".", "closed", "=", "True", "try", ":", "if", "self", ".", "mode", "in", "(", "\"a\"", ",", "\"w\"", ",", "\"x\"", ")", ":", "self", ".", "fileobj", ".", ...
[ 1720, 4 ]
[ 1739, 36 ]
python
en
['en', 'it', 'en']
True
TarFile.getmember
(self, name)
Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurrence is assumed to be the most up-to-date version.
Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurrence is assumed to be the most up-to-date version.
def getmember(self, name): """Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurrence is assumed to be the most up-to-date version. """ tarinfo...
[ "def", "getmember", "(", "self", ",", "name", ")", ":", "tarinfo", "=", "self", ".", "_getmember", "(", "name", ")", "if", "tarinfo", "is", "None", ":", "raise", "KeyError", "(", "\"filename %r not found\"", "%", "name", ")", "return", "tarinfo" ]
[ 1741, 4 ]
[ 1750, 22 ]
python
en
['en', 'en', 'en']
True
TarFile.getmembers
(self)
Return the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive.
Return the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive.
def getmembers(self): """Return the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive. """ self._check() if not self._loaded: # if we want to obtain a list of self._load() # all members, we firs...
[ "def", "getmembers", "(", "self", ")", ":", "self", ".", "_check", "(", ")", "if", "not", "self", ".", "_loaded", ":", "# if we want to obtain a list of", "self", ".", "_load", "(", ")", "# all members, we first have to", "# scan the whole archive.", "return", "se...
[ 1752, 4 ]
[ 1760, 27 ]
python
en
['en', 'en', 'en']
True
TarFile.getnames
(self)
Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers().
Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers().
def getnames(self): """Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). """ return [tarinfo.name for tarinfo in self.getmembers()]
[ "def", "getnames", "(", "self", ")", ":", "return", "[", "tarinfo", ".", "name", "for", "tarinfo", "in", "self", ".", "getmembers", "(", ")", "]" ]
[ 1762, 4 ]
[ 1766, 62 ]
python
en
['en', 'en', 'en']
True
TarFile.gettarinfo
(self, name=None, arcname=None, fileobj=None)
Create a TarInfo object from the result of os.stat or equivalent on an existing file. The file is either named by `name', or specified as a file object `fileobj' with a file descriptor. If given, `arcname' specifies an alternative name for the file in the archive, otherwise, ...
Create a TarInfo object from the result of os.stat or equivalent on an existing file. The file is either named by `name', or specified as a file object `fileobj' with a file descriptor. If given, `arcname' specifies an alternative name for the file in the archive, otherwise, ...
def gettarinfo(self, name=None, arcname=None, fileobj=None): """Create a TarInfo object from the result of os.stat or equivalent on an existing file. The file is either named by `name', or specified as a file object `fileobj' with a file descriptor. If given, `arcname' specifies...
[ "def", "gettarinfo", "(", "self", ",", "name", "=", "None", ",", "arcname", "=", "None", ",", "fileobj", "=", "None", ")", ":", "self", ".", "_check", "(", "\"awx\"", ")", "# When fileobj is given, replace name by", "# fileobj's real name.", "if", "fileobj", "...
[ 1768, 4 ]
[ 1866, 22 ]
python
en
['en', 'en', 'en']
True
TarFile.list
(self, verbose=True, *, members=None)
Print a table of contents to sys.stdout. If `verbose' is False, only the names of the members are printed. If it is True, an `ls -l'-like output is produced. `members' is optional and must be a subset of the list returned by getmembers().
Print a table of contents to sys.stdout. If `verbose' is False, only the names of the members are printed. If it is True, an `ls -l'-like output is produced. `members' is optional and must be a subset of the list returned by getmembers().
def list(self, verbose=True, *, members=None): """Print a table of contents to sys.stdout. If `verbose' is False, only the names of the members are printed. If it is True, an `ls -l'-like output is produced. `members' is optional and must be a subset of the list returned by getm...
[ "def", "list", "(", "self", ",", "verbose", "=", "True", ",", "*", ",", "members", "=", "None", ")", ":", "self", ".", "_check", "(", ")", "if", "members", "is", "None", ":", "members", "=", "self", "for", "tarinfo", "in", "members", ":", "if", "...
[ 1868, 4 ]
[ 1898, 19 ]
python
en
['en', 'en', 'en']
True
TarFile.add
(self, name, arcname=None, recursive=True, exclude=None, *, filter=None)
Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' t...
Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' t...
def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directori...
[ "def", "add", "(", "self", ",", "name", ",", "arcname", "=", "None", ",", "recursive", "=", "True", ",", "exclude", "=", "None", ",", "*", ",", "filter", "=", "None", ")", ":", "self", ".", "_check", "(", "\"awx\"", ")", "if", "arcname", "is", "N...
[ 1900, 4 ]
[ 1959, 33 ]
python
en
['en', 'en', 'en']
True
TarFile.addfile
(self, tarinfo, fileobj=None)
Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, it should be a binary file, and tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects directly, or by using gettarinfo().
Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, it should be a binary file, and tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects directly, or by using gettarinfo().
def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, it should be a binary file, and tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects directly, or by using gettarinfo(). ...
[ "def", "addfile", "(", "self", ",", "tarinfo", ",", "fileobj", "=", "None", ")", ":", "self", ".", "_check", "(", "\"awx\"", ")", "tarinfo", "=", "copy", ".", "copy", "(", "tarinfo", ")", "buf", "=", "tarinfo", ".", "tobuf", "(", "self", ".", "form...
[ 1961, 4 ]
[ 1984, 36 ]
python
en
['en', 'en', 'en']
True
TarFile.extractall
(self, path=".", members=None, *, numeric_owner=False)
Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmember...
Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmember...
def extractall(self, path=".", members=None, *, numeric_owner=False): """Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `membe...
[ "def", "extractall", "(", "self", ",", "path", "=", "\".\"", ",", "members", "=", "None", ",", "*", ",", "numeric_owner", "=", "False", ")", ":", "directories", "=", "[", "]", "if", "members", "is", "None", ":", "members", "=", "self", "for", "tarinf...
[ 1986, 4 ]
[ 2024, 51 ]
python
en
['en', 'en', 'en']
True
TarFile.extract
(self, member, path="", set_attrs=True, *, numeric_owner=False)
Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible. `member' may be a filename or a TarInfo object. You can specify a different directory using `path'. File attributes (owner, mt...
Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible. `member' may be a filename or a TarInfo object. You can specify a different directory using `path'. File attributes (owner, mt...
def extract(self, member, path="", set_attrs=True, *, numeric_owner=False): """Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible. `member' may be a filename or a TarInfo object. You can ...
[ "def", "extract", "(", "self", ",", "member", ",", "path", "=", "\"\"", ",", "set_attrs", "=", "True", ",", "*", ",", "numeric_owner", "=", "False", ")", ":", "self", ".", "_check", "(", "\"r\"", ")", "if", "isinstance", "(", "member", ",", "str", ...
[ 2026, 4 ]
[ 2062, 47 ]
python
en
['en', 'en', 'en']
True
TarFile.extractfile
(self, member)
Extract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file or a link, an io.BufferedReader object is returned. Otherwise, None is returned.
Extract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file or a link, an io.BufferedReader object is returned. Otherwise, None is returned.
def extractfile(self, member): """Extract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file or a link, an io.BufferedReader object is returned. Otherwise, None is returned. """ self._check("r...
[ "def", "extractfile", "(", "self", ",", "member", ")", ":", "self", ".", "_check", "(", "\"r\"", ")", "if", "isinstance", "(", "member", ",", "str", ")", ":", "tarinfo", "=", "self", ".", "getmember", "(", "member", ")", "else", ":", "tarinfo", "=", ...
[ 2064, 4 ]
[ 2093, 23 ]
python
en
['en', 'en', 'en']
True
TarFile._extract_member
(self, tarinfo, targetpath, set_attrs=True, numeric_owner=False)
Extract the TarInfo object tarinfo to a physical file called targetpath.
Extract the TarInfo object tarinfo to a physical file called targetpath.
def _extract_member(self, tarinfo, targetpath, set_attrs=True, numeric_owner=False): """Extract the TarInfo object tarinfo to a physical file called targetpath. """ # Fetch the TarInfo object for the given name # and build the destination pathname, repl...
[ "def", "_extract_member", "(", "self", ",", "tarinfo", ",", "targetpath", ",", "set_attrs", "=", "True", ",", "numeric_owner", "=", "False", ")", ":", "# Fetch the TarInfo object for the given name", "# and build the destination pathname, replacing", "# forward slashes to pla...
[ 2095, 4 ]
[ 2137, 47 ]
python
en
['en', 'en', 'en']
True
TarFile.makedir
(self, tarinfo, targetpath)
Make a directory called targetpath.
Make a directory called targetpath.
def makedir(self, tarinfo, targetpath): """Make a directory called targetpath. """ try: # Use a safe mode for the directory, the real mode is set # later in _extract_member(). os.mkdir(targetpath, 0o700) except FileExistsError: pass
[ "def", "makedir", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "try", ":", "# Use a safe mode for the directory, the real mode is set", "# later in _extract_member().", "os", ".", "mkdir", "(", "targetpath", ",", "0o700", ")", "except", "FileExistsError", ...
[ 2144, 4 ]
[ 2152, 16 ]
python
en
['en', 'en', 'en']
True
TarFile.makefile
(self, tarinfo, targetpath)
Make a file called targetpath.
Make a file called targetpath.
def makefile(self, tarinfo, targetpath): """Make a file called targetpath. """ source = self.fileobj source.seek(tarinfo.offset_data) bufsize = self.copybufsize with bltn_open(targetpath, "wb") as target: if tarinfo.sparse is not None: for offs...
[ "def", "makefile", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "source", "=", "self", ".", "fileobj", "source", ".", "seek", "(", "tarinfo", ".", "offset_data", ")", "bufsize", "=", "self", ".", "copybufsize", "with", "bltn_open", "(", "tar...
[ 2154, 4 ]
[ 2168, 77 ]
python
en
['en', 'ig', 'en']
True
TarFile.makeunknown
(self, tarinfo, targetpath)
Make a file from a TarInfo object with an unknown type at targetpath.
Make a file from a TarInfo object with an unknown type at targetpath.
def makeunknown(self, tarinfo, targetpath): """Make a file from a TarInfo object with an unknown type at targetpath. """ self.makefile(tarinfo, targetpath) self._dbg(1, "tarfile: Unknown file type %r, " \ "extracted as regular file." % tarinfo.type)
[ "def", "makeunknown", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "self", ".", "makefile", "(", "tarinfo", ",", "targetpath", ")", "self", ".", "_dbg", "(", "1", ",", "\"tarfile: Unknown file type %r, \"", "\"extracted as regular file.\"", "%", "ta...
[ 2170, 4 ]
[ 2176, 65 ]
python
en
['en', 'en', 'en']
True
TarFile.makefifo
(self, tarinfo, targetpath)
Make a fifo called targetpath.
Make a fifo called targetpath.
def makefifo(self, tarinfo, targetpath): """Make a fifo called targetpath. """ if hasattr(os, "mkfifo"): os.mkfifo(targetpath) else: raise ExtractError("fifo not supported by system")
[ "def", "makefifo", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "if", "hasattr", "(", "os", ",", "\"mkfifo\"", ")", ":", "os", ".", "mkfifo", "(", "targetpath", ")", "else", ":", "raise", "ExtractError", "(", "\"fifo not supported by system\"", ...
[ 2178, 4 ]
[ 2184, 62 ]
python
en
['en', 'ig', 'en']
True
TarFile.makedev
(self, tarinfo, targetpath)
Make a character or block device called targetpath.
Make a character or block device called targetpath.
def makedev(self, tarinfo, targetpath): """Make a character or block device called targetpath. """ if not hasattr(os, "mknod") or not hasattr(os, "makedev"): raise ExtractError("special devices not supported by system") mode = tarinfo.mode if tarinfo.isblk(): ...
[ "def", "makedev", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "if", "not", "hasattr", "(", "os", ",", "\"mknod\"", ")", "or", "not", "hasattr", "(", "os", ",", "\"makedev\"", ")", ":", "raise", "ExtractError", "(", "\"special devices not supp...
[ 2186, 4 ]
[ 2199, 64 ]
python
en
['en', 'en', 'en']
True
TarFile.makelink
(self, tarinfo, targetpath)
Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link.
Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link.
def makelink(self, tarinfo, targetpath): """Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link. """ try: # For systems that support symbolic and hard links. ...
[ "def", "makelink", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "try", ":", "# For systems that support symbolic and hard links.", "if", "tarinfo", ".", "issym", "(", ")", ":", "os", ".", "symlink", "(", "tarinfo", ".", "linkname", ",", "targetpat...
[ 2201, 4 ]
[ 2222, 75 ]
python
en
['en', 'en', 'en']
True
TarFile.chown
(self, tarinfo, targetpath, numeric_owner)
Set owner of targetpath according to tarinfo. If numeric_owner is True, use .gid/.uid instead of .gname/.uname. If numeric_owner is False, fall back to .gid/.uid when the search based on name fails.
Set owner of targetpath according to tarinfo. If numeric_owner is True, use .gid/.uid instead of .gname/.uname. If numeric_owner is False, fall back to .gid/.uid when the search based on name fails.
def chown(self, tarinfo, targetpath, numeric_owner): """Set owner of targetpath according to tarinfo. If numeric_owner is True, use .gid/.uid instead of .gname/.uname. If numeric_owner is False, fall back to .gid/.uid when the search based on name fails. """ if h...
[ "def", "chown", "(", "self", ",", "tarinfo", ",", "targetpath", ",", "numeric_owner", ")", ":", "if", "hasattr", "(", "os", ",", "\"geteuid\"", ")", "and", "os", ".", "geteuid", "(", ")", "==", "0", ":", "# We have to be root to do so.", "g", "=", "tarin...
[ 2224, 4 ]
[ 2251, 60 ]
python
en
['en', 'en', 'en']
True
TarFile.chmod
(self, tarinfo, targetpath)
Set file permissions of targetpath according to tarinfo.
Set file permissions of targetpath according to tarinfo.
def chmod(self, tarinfo, targetpath): """Set file permissions of targetpath according to tarinfo. """ if hasattr(os, 'chmod'): try: os.chmod(targetpath, tarinfo.mode) except OSError: raise ExtractError("could not change mode")
[ "def", "chmod", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "if", "hasattr", "(", "os", ",", "'chmod'", ")", ":", "try", ":", "os", ".", "chmod", "(", "targetpath", ",", "tarinfo", ".", "mode", ")", "except", "OSError", ":", "raise", ...
[ 2253, 4 ]
[ 2260, 59 ]
python
en
['en', 'en', 'en']
True
TarFile.utime
(self, tarinfo, targetpath)
Set modification time of targetpath according to tarinfo.
Set modification time of targetpath according to tarinfo.
def utime(self, tarinfo, targetpath): """Set modification time of targetpath according to tarinfo. """ if not hasattr(os, 'utime'): return try: os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) except OSError: raise ExtractError("could not c...
[ "def", "utime", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "if", "not", "hasattr", "(", "os", ",", "'utime'", ")", ":", "return", "try", ":", "os", ".", "utime", "(", "targetpath", ",", "(", "tarinfo", ".", "mtime", ",", "tarinfo", "...
[ 2262, 4 ]
[ 2270, 68 ]
python
en
['en', 'en', 'en']
True
TarFile.next
(self)
Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available.
Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available.
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firs...
[ "def", "next", "(", "self", ")", ":", "self", ".", "_check", "(", "\"ra\"", ")", "if", "self", ".", "firstmember", "is", "not", "None", ":", "m", "=", "self", ".", "firstmember", "self", ".", "firstmember", "=", "None", "return", "m", "# Advance the fi...
[ 2273, 4 ]
[ 2322, 22 ]
python
en
['en', 'en', 'en']
True
TarFile._getmember
(self, name, tarinfo=None, normalize=False)
Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point.
Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point.
def _getmember(self, name, tarinfo=None, normalize=False): """Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. """ # Ensure that all members have been loaded. members = self.getmembers() # Limit the member searc...
[ "def", "_getmember", "(", "self", ",", "name", ",", "tarinfo", "=", "None", ",", "normalize", "=", "False", ")", ":", "# Ensure that all members have been loaded.", "members", "=", "self", ".", "getmembers", "(", ")", "# Limit the member search list up to tarinfo.", ...
[ 2327, 4 ]
[ 2348, 29 ]
python
en
['en', 'en', 'en']
True
TarFile._load
(self)
Read through the entire archive file and look for readable members.
Read through the entire archive file and look for readable members.
def _load(self): """Read through the entire archive file and look for readable members. """ while True: tarinfo = self.next() if tarinfo is None: break self._loaded = True
[ "def", "_load", "(", "self", ")", ":", "while", "True", ":", "tarinfo", "=", "self", ".", "next", "(", ")", "if", "tarinfo", "is", "None", ":", "break", "self", ".", "_loaded", "=", "True" ]
[ 2350, 4 ]
[ 2358, 27 ]
python
en
['en', 'en', 'en']
True
TarFile._check
(self, mode=None)
Check if TarFile is still open, and if the operation's mode corresponds to TarFile's mode.
Check if TarFile is still open, and if the operation's mode corresponds to TarFile's mode.
def _check(self, mode=None): """Check if TarFile is still open, and if the operation's mode corresponds to TarFile's mode. """ if self.closed: raise OSError("%s is closed" % self.__class__.__name__) if mode is not None and self.mode not in mode: raise O...
[ "def", "_check", "(", "self", ",", "mode", "=", "None", ")", ":", "if", "self", ".", "closed", ":", "raise", "OSError", "(", "\"%s is closed\"", "%", "self", ".", "__class__", ".", "__name__", ")", "if", "mode", "is", "not", "None", "and", "self", "....
[ 2360, 4 ]
[ 2367, 66 ]
python
en
['en', 'en', 'en']
True
TarFile._find_link_target
(self, tarinfo)
Find the target member of a symlink or hardlink member in the archive.
Find the target member of a symlink or hardlink member in the archive.
def _find_link_target(self, tarinfo): """Find the target member of a symlink or hardlink member in the archive. """ if tarinfo.issym(): # Always search the entire archive. linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname))) ...
[ "def", "_find_link_target", "(", "self", ",", "tarinfo", ")", ":", "if", "tarinfo", ".", "issym", "(", ")", ":", "# Always search the entire archive.", "linkname", "=", "\"/\"", ".", "join", "(", "filter", "(", "None", ",", "(", "os", ".", "path", ".", "...
[ 2369, 4 ]
[ 2386, 21 ]
python
en
['en', 'da', 'en']
True
TarFile.__iter__
(self)
Provide an iterator object.
Provide an iterator object.
def __iter__(self): """Provide an iterator object. """ if self._loaded: yield from self.members return # Yield items using TarFile's next() method. # When all members have been read, set TarFile as _loaded. index = 0 # Fix for SF #1100429:...
[ "def", "__iter__", "(", "self", ")", ":", "if", "self", ".", "_loaded", ":", "yield", "from", "self", ".", "members", "return", "# Yield items using TarFile's next() method.", "# When all members have been read, set TarFile as _loaded.", "index", "=", "0", "# Fix for SF #...
[ 2388, 4 ]
[ 2417, 25 ]
python
en
['en', 'en', 'en']
True
TarFile._dbg
(self, level, msg)
Write debugging output to sys.stderr.
Write debugging output to sys.stderr.
def _dbg(self, level, msg): """Write debugging output to sys.stderr. """ if level <= self.debug: print(msg, file=sys.stderr)
[ "def", "_dbg", "(", "self", ",", "level", ",", "msg", ")", ":", "if", "level", "<=", "self", ".", "debug", ":", "print", "(", "msg", ",", "file", "=", "sys", ".", "stderr", ")" ]
[ 2419, 4 ]
[ 2423, 39 ]
python
en
['it', 'en', 'nl']
False
parse_bdist_wininst
(name)
Return (base,pyversion) or (None,None) for possible .exe name
Return (base,pyversion) or (None,None) for possible .exe name
def parse_bdist_wininst(name): """Return (base,pyversion) or (None,None) for possible .exe name""" lower = name.lower() base, py_ver, plat = None, None, None if lower.endswith('.exe'): if lower.endswith('.win32.exe'): base = name[:-10] plat = 'win32' elif lower....
[ "def", "parse_bdist_wininst", "(", "name", ")", ":", "lower", "=", "name", ".", "lower", "(", ")", "base", ",", "py_ver", ",", "plat", "=", "None", ",", "None", ",", "None", "if", "lower", ".", "endswith", "(", "'.exe'", ")", ":", "if", "lower", "....
[ 61, 0 ]
[ 82, 29 ]
python
en
['en', 'en', 'en']
True
distros_for_url
(url, metadata=None)
Yield egg or source distribution objects that might be found at a URL
Yield egg or source distribution objects that might be found at a URL
def distros_for_url(url, metadata=None): """Yield egg or source distribution objects that might be found at a URL""" base, fragment = egg_info_for_url(url) for dist in distros_for_location(url, base, metadata): yield dist if fragment: match = EGG_FRAGMENT.match(fragment) if match...
[ "def", "distros_for_url", "(", "url", ",", "metadata", "=", "None", ")", ":", "base", ",", "fragment", "=", "egg_info_for_url", "(", "url", ")", "for", "dist", "in", "distros_for_location", "(", "url", ",", "base", ",", "metadata", ")", ":", "yield", "di...
[ 96, 0 ]
[ 107, 26 ]
python
en
['en', 'en', 'en']
True
distros_for_location
(location, basename, metadata=None)
Yield egg or source distribution objects based on basename
Yield egg or source distribution objects based on basename
def distros_for_location(location, basename, metadata=None): """Yield egg or source distribution objects based on basename""" if basename.endswith('.egg.zip'): basename = basename[:-4] # strip the .zip if basename.endswith('.egg') and '-' in basename: # only one, unambiguous interpretation ...
[ "def", "distros_for_location", "(", "location", ",", "basename", ",", "metadata", "=", "None", ")", ":", "if", "basename", ".", "endswith", "(", "'.egg.zip'", ")", ":", "basename", "=", "basename", "[", ":", "-", "4", "]", "# strip the .zip", "if", "basena...
[ 110, 0 ]
[ 140, 13 ]
python
en
['en', 'en', 'en']
True
distros_for_filename
(filename, metadata=None)
Yield possible egg or source distribution objects based on a filename
Yield possible egg or source distribution objects based on a filename
def distros_for_filename(filename, metadata=None): """Yield possible egg or source distribution objects based on a filename""" return distros_for_location( normalize_path(filename), os.path.basename(filename), metadata )
[ "def", "distros_for_filename", "(", "filename", ",", "metadata", "=", "None", ")", ":", "return", "distros_for_location", "(", "normalize_path", "(", "filename", ")", ",", "os", ".", "path", ".", "basename", "(", "filename", ")", ",", "metadata", ")" ]
[ 143, 0 ]
[ 147, 5 ]
python
en
['en', 'en', 'en']
True
interpret_distro_name
( location, basename, metadata, py_version=None, precedence=SOURCE_DIST, platform=None )
Generate alternative interpretations of a source distro name Note: if `location` is a filesystem filename, you should call ``pkg_resources.normalize_path()`` on it before passing it to this routine!
Generate alternative interpretations of a source distro name
def interpret_distro_name( location, basename, metadata, py_version=None, precedence=SOURCE_DIST, platform=None ): """Generate alternative interpretations of a source distro name Note: if `location` is a filesystem filename, you should call ``pkg_resources.normalize_path()`` on it before pa...
[ "def", "interpret_distro_name", "(", "location", ",", "basename", ",", "metadata", ",", "py_version", "=", "None", ",", "precedence", "=", "SOURCE_DIST", ",", "platform", "=", "None", ")", ":", "# Generate alternative interpretations of a source distro name", "# Because...
[ 150, 0 ]
[ 182, 9 ]
python
en
['en', 'it', 'en']
True
unique_everseen
(iterable, key=None)
List unique elements, preserving order. Remember all elements ever seen.
List unique elements, preserving order. Remember all elements ever seen.
def unique_everseen(iterable, key=None): "List unique elements, preserving order. Remember all elements ever seen." # unique_everseen('AAAABBBCCDAABBB') --> A B C D # unique_everseen('ABBCcAD', str.lower) --> A B C D seen = set() seen_add = seen.add if key is None: for element in itertoo...
[ "def", "unique_everseen", "(", "iterable", ",", "key", "=", "None", ")", ":", "# unique_everseen('AAAABBBCCDAABBB') --> A B C D", "# unique_everseen('ABBCcAD', str.lower) --> A B C D", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "if", "key", "is...
[ 186, 0 ]
[ 201, 29 ]
python
ca
['ca', 'ca', 'en']
True
unique_values
(func)
Wrap a function returning an iterable such that the resulting iterable only ever yields unique items.
Wrap a function returning an iterable such that the resulting iterable only ever yields unique items.
def unique_values(func): """ Wrap a function returning an iterable such that the resulting iterable only ever yields unique items. """ @wraps(func) def wrapper(*args, **kwargs): return unique_everseen(func(*args, **kwargs)) return wrapper
[ "def", "unique_values", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "unique_everseen", "(", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "...
[ 204, 0 ]
[ 214, 18 ]
python
en
['en', 'error', 'th']
False
find_external_links
(url, page)
Find rel="homepage" and rel="download" links in `page`, yielding URLs
Find rel="homepage" and rel="download" links in `page`, yielding URLs
def find_external_links(url, page): """Find rel="homepage" and rel="download" links in `page`, yielding URLs""" for match in REL.finditer(page): tag, rel = match.groups() rels = set(map(str.strip, rel.lower().split(','))) if 'homepage' in rels or 'download' in rels: for matc...
[ "def", "find_external_links", "(", "url", ",", "page", ")", ":", "for", "match", "in", "REL", ".", "finditer", "(", "page", ")", ":", "tag", ",", "rel", "=", "match", ".", "groups", "(", ")", "rels", "=", "set", "(", "map", "(", "str", ".", "stri...
[ 222, 0 ]
[ 237, 75 ]
python
en
['en', 'en', 'en']
True
htmldecode
(text)
Decode HTML entities in the given text. >>> htmldecode( ... 'https://../package_name-0.1.2.tar.gz' ... '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz') 'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
Decode HTML entities in the given text.
def htmldecode(text): """ Decode HTML entities in the given text. >>> htmldecode( ... 'https://../package_name-0.1.2.tar.gz' ... '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz') 'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz' """ return en...
[ "def", "htmldecode", "(", "text", ")", ":", "return", "entity_sub", "(", "decode_entity", ",", "text", ")" ]
[ 945, 0 ]
[ 954, 42 ]
python
en
['en', 'error', 'th']
False
_encode_auth
(auth)
Encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ=' Long auth strings should not cause a newline to be inserted. >>> long_auth = 'username:' + 'password'*10 >>> chr(10) in str(_encode_auth(long_auth)) False
Encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ='
def _encode_auth(auth): """ Encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ=' Long auth strings should not cause a newline to be inserted. >>> long_auth = 'username:' + 'password'*10 >>> chr(10) in str(_encode_auth(lo...
[ "def", "_encode_auth", "(", "auth", ")", ":", "auth_s", "=", "urllib", ".", "parse", ".", "unquote", "(", "auth", ")", "# convert to bytes", "auth_bytes", "=", "auth_s", ".", "encode", "(", ")", "encoded_bytes", "=", "base64", ".", "b64encode", "(", "auth_...
[ 972, 0 ]
[ 990, 36 ]
python
en
['en', 'error', 'th']
False
open_with_auth
(url, opener=urllib.request.urlopen)
Open a urllib2 request, handling HTTP authentication
Open a urllib2 request, handling HTTP authentication
def open_with_auth(url, opener=urllib.request.urlopen): """Open a urllib2 request, handling HTTP authentication""" parsed = urllib.parse.urlparse(url) scheme, netloc, path, params, query, frag = parsed # Double scheme does not raise on macOS as revealed by a # failing test. We would expect "nonnum...
[ "def", "open_with_auth", "(", "url", ",", "opener", "=", "urllib", ".", "request", ".", "urlopen", ")", ":", "parsed", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", "...
[ 1048, 0 ]
[ 1091, 13 ]
python
en
['en', 'lb', 'en']
True
_splituser
(host)
splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.
splituser('user[:passwd]
def _splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" user, delim, host = host.rpartition('@') return (user if delim else None), host
[ "def", "_splituser", "(", "host", ")", ":", "user", ",", "delim", ",", "host", "=", "host", ".", "rpartition", "(", "'@'", ")", "return", "(", "user", "if", "delim", "else", "None", ")", ",", "host" ]
[ 1095, 0 ]
[ 1099, 42 ]
python
en
['en', 'no', 'sw']
False
local_open
(url)
Read a local path, with special support for directories
Read a local path, with special support for directories
def local_open(url): """Read a local path, with special support for directories""" scheme, server, path, param, query, frag = urllib.parse.urlparse(url) filename = urllib.request.url2pathname(path) if os.path.isfile(filename): return urllib.request.urlopen(url) elif path.endswith('/') and os...
[ "def", "local_open", "(", "url", ")", ":", "scheme", ",", "server", ",", "path", ",", "param", ",", "query", ",", "frag", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "filename", "=", "urllib", ".", "request", ".", "url2pathname", "...
[ 1110, 0 ]
[ 1138, 77 ]
python
en
['en', 'en', 'en']
True
ContentChecker.feed
(self, block)
Feed a block of data to the hash.
Feed a block of data to the hash.
def feed(self, block): """ Feed a block of data to the hash. """ return
[ "def", "feed", "(", "self", ",", "block", ")", ":", "return" ]
[ 245, 4 ]
[ 249, 14 ]
python
en
['en', 'error', 'th']
False
ContentChecker.is_valid
(self)
Check the hash. Return False if validation fails.
Check the hash. Return False if validation fails.
def is_valid(self): """ Check the hash. Return False if validation fails. """ return True
[ "def", "is_valid", "(", "self", ")", ":", "return", "True" ]
[ 251, 4 ]
[ 255, 19 ]
python
en
['en', 'error', 'th']
False
ContentChecker.report
(self, reporter, template)
Call reporter with information about the checker (hash name) substituted into the template.
Call reporter with information about the checker (hash name) substituted into the template.
def report(self, reporter, template): """ Call reporter with information about the checker (hash name) substituted into the template. """ return
[ "def", "report", "(", "self", ",", "reporter", ",", "template", ")", ":", "return" ]
[ 257, 4 ]
[ 262, 14 ]
python
en
['en', 'error', 'th']
False
HashChecker.from_url
(cls, url)
Construct a (possibly null) ContentChecker from a URL
Construct a (possibly null) ContentChecker from a URL
def from_url(cls, url): "Construct a (possibly null) ContentChecker from a URL" fragment = urllib.parse.urlparse(url)[-1] if not fragment: return ContentChecker() match = cls.pattern.search(fragment) if not match: return ContentChecker() return cls...
[ "def", "from_url", "(", "cls", ",", "url", ")", ":", "fragment", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "[", "-", "1", "]", "if", "not", "fragment", ":", "return", "ContentChecker", "(", ")", "match", "=", "cls", ".", "patte...
[ 277, 4 ]
[ 285, 39 ]
python
en
['en', 'en', 'en']
True
PackageIndex.process_url
(self, url, retrieve=False)
Evaluate a URL as a possible download, and maybe retrieve it
Evaluate a URL as a possible download, and maybe retrieve it
def process_url(self, url, retrieve=False): """Evaluate a URL as a possible download, and maybe retrieve it""" if url in self.scanned_urls and not retrieve: return self.scanned_urls[url] = True if not URL_SCHEME(url): self.process_filename(url) return ...
[ "def", "process_url", "(", "self", ",", "url", ",", "retrieve", "=", "False", ")", ":", "if", "url", "in", "self", ".", "scanned_urls", "and", "not", "retrieve", ":", "return", "self", ".", "scanned_urls", "[", "url", "]", "=", "True", "if", "not", "...
[ 322, 4 ]
[ 373, 48 ]
python
en
['en', 'en', 'en']
True
PackageIndex.process_index
(self, url, page)
Process the contents of a PyPI page
Process the contents of a PyPI page
def process_index(self, url, page): """Process the contents of a PyPI page""" def scan(link): # Process a URL to see if it's for a package page if link.startswith(self.index_url): parts = list(map( urllib.parse.unquote, link[len(self.index_url...
[ "def", "process_index", "(", "self", ",", "url", ",", "page", ")", ":", "def", "scan", "(", "link", ")", ":", "# Process a URL to see if it's for a package page", "if", "link", ".", "startswith", "(", "self", ".", "index_url", ")", ":", "parts", "=", "list",...
[ 430, 4 ]
[ 471, 21 ]
python
en
['en', 'en', 'en']
True
PackageIndex.check_hash
(self, checker, filename, tfp)
checker is a ContentChecker
checker is a ContentChecker
def check_hash(self, checker, filename, tfp): """ checker is a ContentChecker """ checker.report( self.debug, "Validating %%s checksum for %s" % filename) if not checker.is_valid(): tfp.close() os.unlink(filename) raise ...
[ "def", "check_hash", "(", "self", ",", "checker", ",", "filename", ",", "tfp", ")", ":", "checker", ".", "report", "(", "self", ".", "debug", ",", "\"Validating %%s checksum for %s\"", "%", "filename", ")", "if", "not", "checker", ".", "is_valid", "(", ")"...
[ 512, 4 ]
[ 526, 13 ]
python
en
['en', 'error', 'th']
False
PackageIndex.add_find_links
(self, urls)
Add `urls` to the list that will be prescanned for searches
Add `urls` to the list that will be prescanned for searches
def add_find_links(self, urls): """Add `urls` to the list that will be prescanned for searches""" for url in urls: if ( self.to_scan is None # if we have already "gone online" or not URL_SCHEME(url) # or it's a local file/directory or url.sta...
[ "def", "add_find_links", "(", "self", ",", "urls", ")", ":", "for", "url", "in", "urls", ":", "if", "(", "self", ".", "to_scan", "is", "None", "# if we have already \"gone online\"", "or", "not", "URL_SCHEME", "(", "url", ")", "# or it's a local file/directory",...
[ 528, 4 ]
[ 541, 40 ]
python
en
['en', 'en', 'en']
True
PackageIndex.prescan
(self)
Scan urls scheduled for prescanning (e.g. --find-links)
Scan urls scheduled for prescanning (e.g. --find-links)
def prescan(self): """Scan urls scheduled for prescanning (e.g. --find-links)""" if self.to_scan: list(map(self.scan_url, self.to_scan)) self.to_scan = None
[ "def", "prescan", "(", "self", ")", ":", "if", "self", ".", "to_scan", ":", "list", "(", "map", "(", "self", ".", "scan_url", ",", "self", ".", "to_scan", ")", ")", "self", ".", "to_scan", "=", "None" ]
[ 543, 4 ]
[ 547, 27 ]
python
en
['en', 'de', 'en']
True
PackageIndex.download
(self, spec, tmpdir)
Locate and/or download `spec` to `tmpdir`, returning a local path `spec` may be a ``Requirement`` object, or a string containing a URL, an existing local filename, or a project/version requirement spec (i.e. the string form of a ``Requirement`` object). If it is the URL of a .py file w...
Locate and/or download `spec` to `tmpdir`, returning a local path
def download(self, spec, tmpdir): """Locate and/or download `spec` to `tmpdir`, returning a local path `spec` may be a ``Requirement`` object, or a string containing a URL, an existing local filename, or a project/version requirement spec (i.e. the string form of a ``Requirement`` objec...
[ "def", "download", "(", "self", ",", "spec", ",", "tmpdir", ")", ":", "if", "not", "isinstance", "(", "spec", ",", "Requirement", ")", ":", "scheme", "=", "URL_SCHEME", "(", "spec", ")", "if", "scheme", ":", "# It's a url, download it to tmpdir", "found", ...
[ 559, 4 ]
[ 591, 79 ]
python
en
['en', 'en', 'en']
True
PackageIndex.fetch_distribution
( self, requirement, tmpdir, force_scan=False, source=False, develop_ok=False, local_index=None)
Obtain a distribution suitable for fulfilling `requirement` `requirement` must be a ``pkg_resources.Requirement`` instance. If necessary, or if the `force_scan` flag is set, the requirement is searched for in the (online) package index as well as the locally installed packages. If a di...
Obtain a distribution suitable for fulfilling `requirement`
def fetch_distribution( self, requirement, tmpdir, force_scan=False, source=False, develop_ok=False, local_index=None): """Obtain a distribution suitable for fulfilling `requirement` `requirement` must be a ``pkg_resources.Requirement`` instance. If necessary, or if the ...
[ "def", "fetch_distribution", "(", "self", ",", "requirement", ",", "tmpdir", ",", "force_scan", "=", "False", ",", "source", "=", "False", ",", "develop_ok", "=", "False", ",", "local_index", "=", "None", ")", ":", "# process a Requirement", "self", ".", "in...
[ 593, 4 ]
[ 667, 62 ]
python
en
['en', 'en', 'en']
True
PackageIndex.fetch
(self, requirement, tmpdir, force_scan=False, source=False)
Obtain a file suitable for fulfilling `requirement` DEPRECATED; use the ``fetch_distribution()`` method now instead. For backward compatibility, this routine is identical but returns the ``location`` of the downloaded distribution instead of a distribution object.
Obtain a file suitable for fulfilling `requirement`
def fetch(self, requirement, tmpdir, force_scan=False, source=False): """Obtain a file suitable for fulfilling `requirement` DEPRECATED; use the ``fetch_distribution()`` method now instead. For backward compatibility, this routine is identical but returns the ``location`` of the downlo...
[ "def", "fetch", "(", "self", ",", "requirement", ",", "tmpdir", ",", "force_scan", "=", "False", ",", "source", "=", "False", ")", ":", "dist", "=", "self", ".", "fetch_distribution", "(", "requirement", ",", "tmpdir", ",", "force_scan", ",", "source", "...
[ 669, 4 ]
[ 680, 19 ]
python
en
['en', 'en', 'en']
True
PyPIConfig.__init__
(self)
Load from ~/.pypirc
Load from ~/.pypirc
def __init__(self): """ Load from ~/.pypirc """ defaults = dict.fromkeys(['username', 'password', 'repository'], '') configparser.RawConfigParser.__init__(self, defaults) rc = os.path.join(os.path.expanduser('~'), '.pypirc') if os.path.exists(rc): sel...
[ "def", "__init__", "(", "self", ")", ":", "defaults", "=", "dict", ".", "fromkeys", "(", "[", "'username'", ",", "'password'", ",", "'repository'", "]", ",", "''", ")", "configparser", ".", "RawConfigParser", ".", "__init__", "(", "self", ",", "defaults", ...
[ 1011, 4 ]
[ 1020, 25 ]
python
en
['en', 'error', 'th']
False
PyPIConfig.find_credential
(self, url)
If the URL indicated appears to be a repository defined in this config, return the credential for that repository.
If the URL indicated appears to be a repository defined in this config, return the credential for that repository.
def find_credential(self, url): """ If the URL indicated appears to be a repository defined in this config, return the credential for that repository. """ for repository, cred in self.creds_by_repository.items(): if url.startswith(repository): return c...
[ "def", "find_credential", "(", "self", ",", "url", ")", ":", "for", "repository", ",", "cred", "in", "self", ".", "creds_by_repository", ".", "items", "(", ")", ":", "if", "url", ".", "startswith", "(", "repository", ")", ":", "return", "cred" ]
[ 1038, 4 ]
[ 1045, 27 ]
python
en
['en', 'error', 'th']
False
looks_like_ci
()
Return whether it looks like pip is running under CI.
Return whether it looks like pip is running under CI.
def looks_like_ci(): # type: () -> bool """ Return whether it looks like pip is running under CI. """ # We don't use the method of checking for a tty (e.g. using isatty()) # because some CI systems mimic a tty (e.g. Travis CI). Thus that # method doesn't provide definitive information in ei...
[ "def", "looks_like_ci", "(", ")", ":", "# type: () -> bool", "# We don't use the method of checking for a tty (e.g. using isatty())", "# because some CI systems mimic a tty (e.g. Travis CI). Thus that", "# method doesn't provide definitive information in either direction.", "return", "any", "...
[ 87, 0 ]
[ 95, 71 ]
python
en
['en', 'error', 'th']
False
user_agent
()
Return a string representing the user agent.
Return a string representing the user agent.
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": __version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["impl...
[ "def", "user_agent", "(", ")", ":", "data", "=", "{", "\"installer\"", ":", "{", "\"name\"", ":", "\"pip\"", ",", "\"version\"", ":", "__version__", "}", ",", "\"python\"", ":", "platform", ".", "python_version", "(", ")", ",", "\"implementation\"", ":", "...
[ 98, 0 ]
[ 175, 5 ]
python
en
['en', 'error', 'th']
False
PipSession.__init__
(self, *args, **kwargs)
:param trusted_hosts: Domains not to emit warnings for when not using HTTPS.
:param trusted_hosts: Domains not to emit warnings for when not using HTTPS.
def __init__(self, *args, **kwargs): """ :param trusted_hosts: Domains not to emit warnings for when not using HTTPS. """ retries = kwargs.pop("retries", 0) cache = kwargs.pop("cache", None) trusted_hosts = kwargs.pop("trusted_hosts", []) # type: List[str] ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "retries", "=", "kwargs", ".", "pop", "(", "\"retries\"", ",", "0", ")", "cache", "=", "kwargs", ".", "pop", "(", "\"cache\"", ",", "None", ")", "trusted_hosts", "...
[ 231, 4 ]
[ 305, 62 ]
python
en
['en', 'error', 'th']
False
PipSession.add_trusted_host
(self, host, source=None, suppress_logging=False)
:param host: It is okay to provide a host that has previously been added. :param source: An optional source string, for logging where the host string came from.
:param host: It is okay to provide a host that has previously been added. :param source: An optional source string, for logging where the host string came from.
def add_trusted_host(self, host, source=None, suppress_logging=False): # type: (str, Optional[str], bool) -> None """ :param host: It is okay to provide a host that has previously been added. :param source: An optional source string, for logging where the host str...
[ "def", "add_trusted_host", "(", "self", ",", "host", ",", "source", "=", "None", ",", "suppress_logging", "=", "False", ")", ":", "# type: (str, Optional[str], bool) -> None", "if", "not", "suppress_logging", ":", "msg", "=", "'adding trusted host: {!r}'", ".", "for...
[ 307, 4 ]
[ 334, 13 ]
python
en
['en', 'error', 'th']
False
register_assert_rewrite
(*names)
Register one or more module names to be rewritten on import. This function will make sure that this module or all modules inside the package will get their assert statements rewritten. Thus you should make sure to call this before the module is actually imported, usually in your __init__.py if you are ...
Register one or more module names to be rewritten on import.
def register_assert_rewrite(*names): """Register one or more module names to be rewritten on import. This function will make sure that this module or all modules inside the package will get their assert statements rewritten. Thus you should make sure to call this before the module is actually impor...
[ "def", "register_assert_rewrite", "(", "*", "names", ")", ":", "for", "name", "in", "names", ":", "if", "not", "isinstance", "(", "name", ",", "str", ")", ":", "msg", "=", "'expected module names as *args, got {0} instead'", "raise", "TypeError", "(", "msg", "...
[ 27, 0 ]
[ 48, 35 ]
python
en
['en', 'en', 'en']
True
install_importhook
(config)
Try to install the rewrite hook, raise SystemError if it fails.
Try to install the rewrite hook, raise SystemError if it fails.
def install_importhook(config): """Try to install the rewrite hook, raise SystemError if it fails.""" # Jython has an AST bug that make the assertion rewriting hook malfunction. if (sys.platform.startswith('java')): raise SystemError('rewrite not supported') config._assertstate = AssertionState...
[ "def", "install_importhook", "(", "config", ")", ":", "# Jython has an AST bug that make the assertion rewriting hook malfunction.", "if", "(", "sys", ".", "platform", ".", "startswith", "(", "'java'", ")", ")", ":", "raise", "SystemError", "(", "'rewrite not supported'",...
[ 67, 0 ]
[ 84, 15 ]
python
en
['en', 'en', 'en']
True
pytest_runtest_setup
(item)
Setup the pytest_assertrepr_compare hook The newinterpret and rewrite modules will use util._reprcompare if it exists to use custom reporting via the pytest_assertrepr_compare hook. This sets up this custom comparison for the test.
Setup the pytest_assertrepr_compare hook
def pytest_runtest_setup(item): """Setup the pytest_assertrepr_compare hook The newinterpret and rewrite modules will use util._reprcompare if it exists to use custom reporting via the pytest_assertrepr_compare hook. This sets up this custom comparison for the test. """ def callbinrepr(op,...
[ "def", "pytest_runtest_setup", "(", "item", ")", ":", "def", "callbinrepr", "(", "op", ",", "left", ",", "right", ")", ":", "\"\"\"Call the pytest_assertrepr_compare hook and prepare the result\n\n This uses the first result from the hook and then ensures the\n followin...
[ 97, 0 ]
[ 130, 35 ]
python
en
['en', 'cs', 'en']
True
check_realm_emoji_update
(var_name: str, event: Dict[str, object])
The way we send realm emojis is kinda clumsy--we send a dict mapping the emoji id to a sub_dict with the fields (including the id). Ideally we can streamline this and just send a list of dicts. The clients can make a Map as needed.
The way we send realm emojis is kinda clumsy--we send a dict mapping the emoji id to a sub_dict with the fields (including the id). Ideally we can streamline this and just send a list of dicts. The clients can make a Map as needed.
def check_realm_emoji_update(var_name: str, event: Dict[str, object]) -> None: """ The way we send realm emojis is kinda clumsy--we send a dict mapping the emoji id to a sub_dict with the fields (including the id). Ideally we can streamline this and just send a list of dicts. The clients can make ...
[ "def", "check_realm_emoji_update", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ")", "->", "None", ":", "_check_realm_emoji_update", "(", "var_name", ",", "event", ")", "assert", "isinstance", "(", "event", "[", "...
[ 720, 0 ]
[ 732, 27 ]
python
en
['en', 'error', 'th']
False
check_realm_update
( var_name: str, event: Dict[str, object], prop: str, )
Realm updates have these two fields: property value We check not only the basic schema, but also that the value people actually matches the type from Realm.property_types that we have configured for the property.
Realm updates have these two fields:
def check_realm_update( var_name: str, event: Dict[str, object], prop: str, ) -> None: """ Realm updates have these two fields: property value We check not only the basic schema, but also that the value people actually matches the type from Realm.property_types that we ...
[ "def", "check_realm_update", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ",", "prop", ":", "str", ",", ")", "->", "None", ":", "_check_realm_update", "(", "var_name", ",", "event", ")", "assert", "prop", "=="...
[ 849, 0 ]
[ 890, 73 ]
python
en
['en', 'error', 'th']
False
check_update_display_settings
( var_name: str, event: Dict[str, object], )
Display setting events have a "setting" field that is more specifically typed according to the UserProfile.property_types dictionary.
Display setting events have a "setting" field that is more specifically typed according to the UserProfile.property_types dictionary.
def check_update_display_settings( var_name: str, event: Dict[str, object], ) -> None: """ Display setting events have a "setting" field that is more specifically typed according to the UserProfile.property_types dictionary. """ _check_update_display_settings(var_name, event) setting...
[ "def", "check_update_display_settings", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ",", ")", "->", "None", ":", "_check_update_display_settings", "(", "var_name", ",", "event", ")", "setting_name", "=", "event", "...
[ 1376, 0 ]
[ 1396, 50 ]
python
en
['en', 'error', 'th']
False
check_update_global_notifications
( var_name: str, event: Dict[str, object], desired_val: Union[bool, int, str], )
See UserProfile.notification_setting_types for more details.
See UserProfile.notification_setting_types for more details.
def check_update_global_notifications( var_name: str, event: Dict[str, object], desired_val: Union[bool, int, str], ) -> None: """ See UserProfile.notification_setting_types for more details. """ _check_update_global_notifications(var_name, event) setting_name = event["notification_n...
[ "def", "check_update_global_notifications", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ",", "desired_val", ":", "Union", "[", "bool", ",", "int", ",", "str", "]", ",", ")", "->", "None", ":", "_check_update_gl...
[ 1410, 0 ]
[ 1426, 44 ]
python
en
['en', 'error', 'th']
False
get_module_path
(module_name)
Gets the module path without importing anything. Avoids conflicts with package dependencies. (taken from http://github.com/sitkatech/pypatch)
Gets the module path without importing anything.
def get_module_path(module_name): """Gets the module path without importing anything. Avoids conflicts with package dependencies. (taken from http://github.com/sitkatech/pypatch) """ path = sys.path for name in module_name.split('.'): file_pointer, path, desc = imp.find_module(name, pat...
[ "def", "get_module_path", "(", "module_name", ")", ":", "path", "=", "sys", ".", "path", "for", "name", "in", "module_name", ".", "split", "(", "'.'", ")", ":", "file_pointer", ",", "path", ",", "desc", "=", "imp", ".", "find_module", "(", "name", ",",...
[ 30, 0 ]
[ 43, 18 ]
python
en
['en', 'en', 'en']
True
Command.gendiff
(self, force=False)
Generate a diff between self.local_settings and the example file.
Generate a diff between self.local_settings and the example file.
def gendiff(self, force=False): """Generate a diff between self.local_settings and the example file. """ with DirContext(self.local_settings_dir) as dircontext: if not os.path.exists(self.local_settings_diff) or force: with open(self.local_settings_example, 'r') as ...
[ "def", "gendiff", "(", "self", ",", "force", "=", "False", ")", ":", "with", "DirContext", "(", "self", ".", "local_settings_dir", ")", "as", "dircontext", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "local_settings_diff", ")", ...
[ 119, 4 ]
[ 161, 17 ]
python
en
['en', 'en', 'en']
True
Command.patch
(self, force=False)
Patch local_settings.py.example with local_settings.diff. The patch application generates the local_settings.py file (the local_settings.py.example remains unchanged). http://github.com/sitkatech/pypatch fails if the local_settings.py.example file is not 100% identical to the one used ...
Patch local_settings.py.example with local_settings.diff.
def patch(self, force=False): """Patch local_settings.py.example with local_settings.diff. The patch application generates the local_settings.py file (the local_settings.py.example remains unchanged). http://github.com/sitkatech/pypatch fails if the local_settings.py.example fi...
[ "def", "patch", "(", "self", ",", "force", "=", "False", ")", ":", "with", "DirContext", "(", "self", ".", "local_settings_dir", ")", "as", "dircontext", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "local_settings_diff", ")", ":", "i...
[ 163, 4 ]
[ 219, 47 ]
python
en
['en', 'en', 'en']
True
contextmanager
(func)
@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <b...
@contextmanager decorator.
def contextmanager(func): """@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<argument...
[ "def", "contextmanager", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "helper", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "return", "_GeneratorContextManager", "(", "func", ",", "args", ",", "kwds", ")", "return", "helper" ]
[ 184, 0 ]
[ 215, 17 ]
python
da
['da', 'su', 'it']
False
AbstractContextManager.__enter__
(self)
Return `self` upon entering the runtime context.
Return `self` upon entering the runtime context.
def __enter__(self): """Return `self` upon entering the runtime context.""" return self
[ "def", "__enter__", "(", "self", ")", ":", "return", "self" ]
[ 55, 4 ]
[ 57, 19 ]
python
en
['en', 'en', 'en']
True
AbstractContextManager.__exit__
(self, exc_type, exc_value, traceback)
Raise any exception triggered within the runtime context.
Raise any exception triggered within the runtime context.
def __exit__(self, exc_type, exc_value, traceback): """Raise any exception triggered within the runtime context.""" return None
[ "def", "__exit__", "(", "self", ",", "exc_type", ",", "exc_value", ",", "traceback", ")", ":", "return", "None" ]
[ 60, 4 ]
[ 62, 19 ]
python
en
['en', 'en', 'en']
True
AbstractContextManager.__subclasshook__
(cls, C)
Check whether subclass is considered a subclass of this ABC.
Check whether subclass is considered a subclass of this ABC.
def __subclasshook__(cls, C): """Check whether subclass is considered a subclass of this ABC.""" if cls is AbstractContextManager: return _check_methods(C, "__enter__", "__exit__") return NotImplemented
[ "def", "__subclasshook__", "(", "cls", ",", "C", ")", ":", "if", "cls", "is", "AbstractContextManager", ":", "return", "_check_methods", "(", "C", ",", "\"__enter__\"", ",", "\"__exit__\"", ")", "return", "NotImplemented" ]
[ 65, 4 ]
[ 69, 29 ]
python
en
['en', 'en', 'en']
True
ContextDecorator.refresh_cm
(self)
Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decorators via implicit recrea...
Returns the context manager used to actually wrap the call to the decorated function.
def refresh_cm(self): """Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decor...
[ "def", "refresh_cm", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"refresh_cm was never added to the standard library\"", ",", "DeprecationWarning", ")", "return", "self", ".", "_recreate_cm", "(", ")" ]
[ 75, 4 ]
[ 90, 34 ]
python
en
['en', 'en', 'en']
True
ContextDecorator._recreate_cm
(self)
Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11647 for details.
Return a recreated instance of self.
def _recreate_cm(self): """Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11...
[ "def", "_recreate_cm", "(", "self", ")", ":", "return", "self" ]
[ 92, 4 ]
[ 102, 19 ]
python
en
['en', 'en', 'en']
True
ExitStack.pop_all
(self)
Preserve the context stack by transferring it to a new instance
Preserve the context stack by transferring it to a new instance
def pop_all(self): """Preserve the context stack by transferring it to a new instance""" new_stack = type(self)() new_stack._exit_callbacks = self._exit_callbacks self._exit_callbacks = deque() return new_stack
[ "def", "pop_all", "(", "self", ")", ":", "new_stack", "=", "type", "(", "self", ")", "(", ")", "new_stack", ".", "_exit_callbacks", "=", "self", ".", "_exit_callbacks", "self", ".", "_exit_callbacks", "=", "deque", "(", ")", "return", "new_stack" ]
[ 385, 4 ]
[ 390, 24 ]
python
en
['en', 'en', 'en']
True
ExitStack._push_cm_exit
(self, cm, cm_exit)
Helper to correctly register callbacks to __exit__ methods
Helper to correctly register callbacks to __exit__ methods
def _push_cm_exit(self, cm, cm_exit): """Helper to correctly register callbacks to __exit__ methods""" def _exit_wrapper(*exc_details): return cm_exit(cm, *exc_details) _exit_wrapper.__self__ = cm self.push(_exit_wrapper)
[ "def", "_push_cm_exit", "(", "self", ",", "cm", ",", "cm_exit", ")", ":", "def", "_exit_wrapper", "(", "*", "exc_details", ")", ":", "return", "cm_exit", "(", "cm", ",", "*", "exc_details", ")", "_exit_wrapper", ".", "__self__", "=", "cm", "self", ".", ...
[ 392, 4 ]
[ 397, 32 ]
python
en
['en', 'en', 'en']
True
ExitStack.push
(self, exit)
Registers a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself)
Registers a callback with the standard __exit__ method signature
def push(self, exit): """Registers a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself) """ # We ...
[ "def", "push", "(", "self", ",", "exit", ")", ":", "# We use an unbound method rather than a bound method to follow", "# the standard lookup behaviour for special methods", "_cb_type", "=", "_get_type", "(", "exit", ")", "try", ":", "exit_method", "=", "_cb_type", ".", "_...
[ 399, 4 ]
[ 417, 19 ]
python
en
['en', 'en', 'en']
True
ExitStack.callback
(self, callback, *args, **kwds)
Registers an arbitrary callback and arguments. Cannot suppress exceptions.
Registers an arbitrary callback and arguments.
def callback(self, callback, *args, **kwds): """Registers an arbitrary callback and arguments. Cannot suppress exceptions. """ def _exit_wrapper(exc_type, exc, tb): callback(*args, **kwds) # We changed the signature, so using @wraps is not appropriate, but # ...
[ "def", "callback", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "def", "_exit_wrapper", "(", "exc_type", ",", "exc", ",", "tb", ")", ":", "callback", "(", "*", "args", ",", "*", "*", "kwds", ")", "# We changed th...
[ 419, 4 ]
[ 430, 23 ]
python
en
['en', 'en', 'en']
True
ExitStack.enter_context
(self, cm)
Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method.
Enters the supplied context manager
def enter_context(self, cm): """Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method. """ # We look up the special methods on the type to match the with statement _cm_type = _get_t...
[ "def", "enter_context", "(", "self", ",", "cm", ")", ":", "# We look up the special methods on the type to match the with statement", "_cm_type", "=", "_get_type", "(", "cm", ")", "_exit", "=", "_cm_type", ".", "__exit__", "result", "=", "_cm_type", ".", "__enter__", ...
[ 432, 4 ]
[ 443, 21 ]
python
en
['en', 'en', 'en']
True
ExitStack.close
(self)
Immediately unwind the context stack
Immediately unwind the context stack
def close(self): """Immediately unwind the context stack""" self.__exit__(None, None, None)
[ "def", "close", "(", "self", ")", ":", "self", ".", "__exit__", "(", "None", ",", "None", ",", "None", ")" ]
[ 445, 4 ]
[ 447, 39 ]
python
en
['en', 'en', 'en']
True
urlsafe_b64encode
(data)
urlsafe_b64encode without padding
urlsafe_b64encode without padding
def urlsafe_b64encode(data): """urlsafe_b64encode without padding""" return base64.urlsafe_b64encode(data).rstrip(b'=')
[ "def", "urlsafe_b64encode", "(", "data", ")", ":", "return", "base64", ".", "urlsafe_b64encode", "(", "data", ")", ".", "rstrip", "(", "b'='", ")" ]
[ 25, 0 ]
[ 27, 54 ]
python
en
['en', 'zu', 'en']
True
urlsafe_b64decode
(data)
urlsafe_b64decode without padding
urlsafe_b64decode without padding
def urlsafe_b64decode(data): """urlsafe_b64decode without padding""" pad = b'=' * (4 - (len(data) & 3)) return base64.urlsafe_b64decode(data + pad)
[ "def", "urlsafe_b64decode", "(", "data", ")", ":", "pad", "=", "b'='", "*", "(", "4", "-", "(", "len", "(", "data", ")", "&", "3", ")", ")", "return", "base64", ".", "urlsafe_b64decode", "(", "data", "+", "pad", ")" ]
[ 30, 0 ]
[ 33, 47 ]
python
en
['en', 'jv', 'en']
True
clearcache
()
Clear the cache entirely.
Clear the cache entirely.
def clearcache(): """Clear the cache entirely.""" global cache cache = {}
[ "def", "clearcache", "(", ")", ":", "global", "cache", "cache", "=", "{", "}" ]
[ 29, 0 ]
[ 33, 14 ]
python
en
['en', 'en', 'en']
True
getlines
(filename, module_globals=None)
Get the lines for a Python source file from the cache. Update the cache if it doesn't contain an entry for this file already.
Get the lines for a Python source file from the cache. Update the cache if it doesn't contain an entry for this file already.
def getlines(filename, module_globals=None): """Get the lines for a Python source file from the cache. Update the cache if it doesn't contain an entry for this file already.""" if filename in cache: entry = cache[filename] if len(entry) != 1: return cache[filename][2] try: ...
[ "def", "getlines", "(", "filename", ",", "module_globals", "=", "None", ")", ":", "if", "filename", "in", "cache", ":", "entry", "=", "cache", "[", "filename", "]", "if", "len", "(", "entry", ")", "!=", "1", ":", "return", "cache", "[", "filename", "...
[ 36, 0 ]
[ 49, 17 ]
python
en
['en', 'en', 'en']
True
checkcache
(filename=None)
Discard cache entries that are out of date. (This is not checked upon each call!)
Discard cache entries that are out of date. (This is not checked upon each call!)
def checkcache(filename=None): """Discard cache entries that are out of date. (This is not checked upon each call!)""" if filename is None: filenames = list(cache.keys()) else: if filename in cache: filenames = [filename] else: return for filename in...
[ "def", "checkcache", "(", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filenames", "=", "list", "(", "cache", ".", "keys", "(", ")", ")", "else", ":", "if", "filename", "in", "cache", ":", "filenames", "=", "[", "filename"...
[ 52, 0 ]
[ 78, 31 ]
python
en
['en', 'en', 'en']
True
updatecache
(filename, module_globals=None)
Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.
Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.
def updatecache(filename, module_globals=None): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if filename in cache: if len(cache[filename]) != 1: del cache[filename] if not filen...
[ "def", "updatecache", "(", "filename", ",", "module_globals", "=", "None", ")", ":", "if", "filename", "in", "cache", ":", "if", "len", "(", "cache", "[", "filename", "]", ")", "!=", "1", ":", "del", "cache", "[", "filename", "]", "if", "not", "filen...
[ 81, 0 ]
[ 143, 16 ]
python
en
['en', 'en', 'en']
True
lazycache
(filename, module_globals)
Seed the cache for filename with module_globals. The module loader will be asked for the source only when getlines is called, not immediately. If there is an entry in the cache already, it is not altered. :return: True if a lazy load is registered in the cache, otherwise False. To register su...
Seed the cache for filename with module_globals.
def lazycache(filename, module_globals): """Seed the cache for filename with module_globals. The module loader will be asked for the source only when getlines is called, not immediately. If there is an entry in the cache already, it is not altered. :return: True if a lazy load is registered in th...
[ "def", "lazycache", "(", "filename", ",", "module_globals", ")", ":", "if", "filename", "in", "cache", ":", "if", "len", "(", "cache", "[", "filename", "]", ")", "==", "1", ":", "return", "True", "else", ":", "return", "False", "if", "not", "filename",...
[ 146, 0 ]
[ 176, 16 ]
python
en
['en', 'en', 'en']
True
check_word
(loc, art, word, *, ipa=False)
check if the word has correct article
check if the word has correct article
def check_word(loc, art, word, *, ipa=False): ''' check if the word has correct article ''' phon = text_to_phonemes(word, ipa=ipa) correct_art = choose_art(phon) if correct_art is NotImplemented: warn("can't determine correct article for {word!r} /{phon}/".format(word=word, phon=phon)) ...
[ "def", "check_word", "(", "loc", ",", "art", ",", "word", ",", "*", ",", "ipa", "=", "False", ")", ":", "phon", "=", "text_to_phonemes", "(", "word", ",", "ipa", "=", "ipa", ")", "correct_art", "=", "choose_art", "(", "phon", ")", "if", "correct_art"...
[ 62, 0 ]
[ 78, 10 ]
python
en
['en', 'error', 'th']
False
main
()
run the program
run the program
def main(): ''' run the program ''' signal.signal(signal.SIGPIPE, signal.SIG_DFL) ap = argparse.ArgumentParser(description='"a" vs "an" checker') ap.add_argument('--version', action=VersionAction) ap.add_argument('--ipa', action='store_true', help='use IPA instead of phoneme mnemonics') ...
[ "def", "main", "(", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGPIPE", ",", "signal", ".", "SIG_DFL", ")", "ap", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'\"a\" vs \"an\" checker'", ")", "ap", ".", "add_argument", "(...
[ 80, 0 ]
[ 110, 16 ]
python
en
['en', 'error', 'th']
False
Serializer.prepare_response
(self, request, cached)
Verify our vary headers match and construct a real urllib3 HTTPResponse object.
Verify our vary headers match and construct a real urllib3 HTTPResponse object.
def prepare_response(self, request, cached): """Verify our vary headers match and construct a real urllib3 HTTPResponse object. """ # Special case the '*' Vary value as it means we cannot actually # determine if the cached response is suitable for this request. # This cas...
[ "def", "prepare_response", "(", "self", ",", "request", ",", "cached", ")", ":", "# Special case the '*' Vary value as it means we cannot actually", "# determine if the cached response is suitable for this request.", "# This case is also handled in the controller code when creating", "# a ...
[ 103, 4 ]
[ 139, 83 ]
python
en
['en', 'en', 'en']
True
get_ipver_str
(ip_version)
Convert an ip version number to a human-friendly string.
Convert an ip version number to a human-friendly string.
def get_ipver_str(ip_version): """Convert an ip version number to a human-friendly string.""" return IP_VERSION_DICT.get(ip_version, '')
[ "def", "get_ipver_str", "(", "ip_version", ")", ":", "return", "IP_VERSION_DICT", ".", "get", "(", "ip_version", ",", "''", ")" ]
[ 815, 0 ]
[ 817, 46 ]
python
en
['en', 'en', 'en']
True
list_resources_with_long_filters
(list_method, filter_attr, filter_values, **params)
List neutron resources with handling RequestURITooLong exception. If filter parameters are long, list resources API request leads to 414 error (URL is too long). For such case, this method split list parameters specified by a list_field argument into chunks and call the specified list_method repeatedly...
List neutron resources with handling RequestURITooLong exception.
def list_resources_with_long_filters(list_method, filter_attr, filter_values, **params): """List neutron resources with handling RequestURITooLong exception. If filter parameters are long, list resources API request leads to 414 error (URL is too long). For such case, t...
[ "def", "list_resources_with_long_filters", "(", "list_method", ",", "filter_attr", ",", "filter_values", ",", "*", "*", "params", ")", ":", "try", ":", "params", "[", "filter_attr", "]", "=", "filter_values", "return", "list_method", "(", "*", "*", "params", "...
[ 841, 0 ]
[ 895, 24 ]
python
en
['en', 'en', 'en']
True