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
sys_path_directories
()
Yield absolute directories from sys.path, ignoring entries that don't exist.
Yield absolute directories from sys.path, ignoring entries that don't exist.
def sys_path_directories(): """ Yield absolute directories from sys.path, ignoring entries that don't exist. """ for path in sys.path: path = Path(path) try: resolved_path = path.resolve(strict=True).absolute() except FileNotFoundError: continue ...
[ "def", "sys_path_directories", "(", ")", ":", "for", "path", "in", "sys", ".", "path", ":", "path", "=", "Path", "(", "path", ")", "try", ":", "resolved_path", "=", "path", ".", "resolve", "(", "strict", "=", "True", ")", ".", "absolute", "(", ")", ...
[ 184, 0 ]
[ 199, 31 ]
python
en
['en', 'error', 'th']
False
get_child_arguments
()
Return the executable. This contains a workaround for Windows if the executable is reported to not have the .exe extension which can cause bugs on reloading.
Return the executable. This contains a workaround for Windows if the executable is reported to not have the .exe extension which can cause bugs on reloading.
def get_child_arguments(): """ Return the executable. This contains a workaround for Windows if the executable is reported to not have the .exe extension which can cause bugs on reloading. """ import django.__main__ args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] if sys....
[ "def", "get_child_arguments", "(", ")", ":", "import", "django", ".", "__main__", "args", "=", "[", "sys", ".", "executable", "]", "+", "[", "'-W%s'", "%", "o", "for", "o", "in", "sys", ".", "warnoptions", "]", "if", "sys", ".", "argv", "[", "0", "...
[ 202, 0 ]
[ 217, 15 ]
python
en
['en', 'error', 'th']
False
get_reloader
()
Return the most suitable reloader for this environment.
Return the most suitable reloader for this environment.
def get_reloader(): """Return the most suitable reloader for this environment.""" try: WatchmanReloader.check_availability() except WatchmanUnavailable: return StatReloader() return WatchmanReloader()
[ "def", "get_reloader", "(", ")", ":", "try", ":", "WatchmanReloader", ".", "check_availability", "(", ")", "except", "WatchmanUnavailable", ":", "return", "StatReloader", "(", ")", "return", "WatchmanReloader", "(", ")" ]
[ 564, 0 ]
[ 570, 29 ]
python
en
['en', 'en', 'en']
True
BaseReloader.watched_files
(self, include_globs=True)
Yield all files that need to be watched, including module files and files within globs.
Yield all files that need to be watched, including module files and files within globs.
def watched_files(self, include_globs=True): """ Yield all files that need to be watched, including module files and files within globs. """ yield from iter_all_python_module_files() yield from self.extra_files if include_globs: for directory, patterns...
[ "def", "watched_files", "(", "self", ",", "include_globs", "=", "True", ")", ":", "yield", "from", "iter_all_python_module_files", "(", ")", "yield", "from", "self", ".", "extra_files", "if", "include_globs", ":", "for", "directory", ",", "patterns", "in", "se...
[ 254, 4 ]
[ 264, 54 ]
python
en
['en', 'error', 'th']
False
BaseReloader.wait_for_apps_ready
(self, app_reg, django_main_thread)
Wait until Django reports that the apps have been loaded. If the given thread has terminated before the apps are ready, then a SyntaxError or other non-recoverable error has been raised. In that case, stop waiting for the apps_ready event and continue processing. Return True if...
Wait until Django reports that the apps have been loaded. If the given thread has terminated before the apps are ready, then a SyntaxError or other non-recoverable error has been raised. In that case, stop waiting for the apps_ready event and continue processing.
def wait_for_apps_ready(self, app_reg, django_main_thread): """ Wait until Django reports that the apps have been loaded. If the given thread has terminated before the apps are ready, then a SyntaxError or other non-recoverable error has been raised. In that case, stop waiting fo...
[ "def", "wait_for_apps_ready", "(", "self", ",", "app_reg", ",", "django_main_thread", ")", ":", "while", "django_main_thread", ".", "is_alive", "(", ")", ":", "if", "app_reg", ".", "ready_event", ".", "wait", "(", "timeout", "=", "0.1", ")", ":", "return", ...
[ 266, 4 ]
[ 282, 24 ]
python
en
['en', 'error', 'th']
False
BaseReloader.tick
(self)
This generator is called in a loop from run_loop. It's important that the method takes care of pausing or otherwise waiting for a period of time. This split between run_loop() and tick() is to improve the testability of the reloader implementations by decoupling the work they do...
This generator is called in a loop from run_loop. It's important that the method takes care of pausing or otherwise waiting for a period of time. This split between run_loop() and tick() is to improve the testability of the reloader implementations by decoupling the work they do...
def tick(self): """ This generator is called in a loop from run_loop. It's important that the method takes care of pausing or otherwise waiting for a period of time. This split between run_loop() and tick() is to improve the testability of the reloader implementations by decoupli...
[ "def", "tick", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses must implement tick().'", ")" ]
[ 309, 4 ]
[ 317, 70 ]
python
en
['en', 'error', 'th']
False
WatchmanReloader._watch_glob
(self, directory, patterns)
Watch a directory with a specific glob. If the directory doesn't yet exist, attempt to watch the parent directory and amend the patterns to include this. It's important this method isn't called more than one per directory when updating all subscriptions. Subsequent calls will ov...
Watch a directory with a specific glob. If the directory doesn't yet exist, attempt to watch the parent directory and amend the patterns to include this. It's important this method isn't called more than one per directory when updating all subscriptions. Subsequent calls will ov...
def _watch_glob(self, directory, patterns): """ Watch a directory with a specific glob. If the directory doesn't yet exist, attempt to watch the parent directory and amend the patterns to include this. It's important this method isn't called more than one per directory when updat...
[ "def", "_watch_glob", "(", "self", ",", "directory", ",", "patterns", ")", ":", "prefix", "=", "'glob'", "if", "not", "directory", ".", "exists", "(", ")", ":", "if", "not", "directory", ".", "parent", ".", "exists", "(", ")", ":", "logger", ".", "wa...
[ 443, 4 ]
[ 464, 77 ]
python
en
['en', 'error', 'th']
False
WatchmanReloader.check_server_status
(self, inner_ex=None)
Return True if the server is available.
Return True if the server is available.
def check_server_status(self, inner_ex=None): """Return True if the server is available.""" try: self.client.query('version') except Exception: raise WatchmanUnavailable(str(inner_ex)) from inner_ex return True
[ "def", "check_server_status", "(", "self", ",", "inner_ex", "=", "None", ")", ":", "try", ":", "self", ".", "client", ".", "query", "(", "'version'", ")", "except", "Exception", ":", "raise", "WatchmanUnavailable", "(", "str", "(", "inner_ex", ")", ")", ...
[ 538, 4 ]
[ 544, 19 ]
python
en
['en', 'en', 'en']
True
_parse_version
(text)
Internal parsing method. Factored out for testing purposes.
Internal parsing method. Factored out for testing purposes.
def _parse_version(text): "Internal parsing method. Factored out for testing purposes." major, major2, minor = VERSION_RE.search(text).groups() try: return int(major) * 10000 + int(major2) * 100 + int(minor) except (ValueError, TypeError): return int(major) * 10000 + int(major2) * 100
[ "def", "_parse_version", "(", "text", ")", ":", "major", ",", "major2", ",", "minor", "=", "VERSION_RE", ".", "search", "(", "text", ")", ".", "groups", "(", ")", "try", ":", "return", "int", "(", "major", ")", "*", "10000", "+", "int", "(", "major...
[ 15, 0 ]
[ 21, 53 ]
python
en
['en', 'en', 'en']
True
get_version
(connection)
Returns an integer representing the major, minor and revision number of the server. Format is the one used for the return value of libpq PQServerVersion()/``server_version`` connection attribute (available in newer psycopg2 versions.) For example, 90304 for 9.3.4. The last two digits will be 00 in...
Returns an integer representing the major, minor and revision number of the server. Format is the one used for the return value of libpq PQServerVersion()/``server_version`` connection attribute (available in newer psycopg2 versions.)
def get_version(connection): """ Returns an integer representing the major, minor and revision number of the server. Format is the one used for the return value of libpq PQServerVersion()/``server_version`` connection attribute (available in newer psycopg2 versions.) For example, 90304 for 9.3....
[ "def", "get_version", "(", "connection", ")", ":", "if", "hasattr", "(", "connection", ",", "'server_version'", ")", ":", "return", "connection", ".", "server_version", "else", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor"...
[ 24, 0 ]
[ 43, 55 ]
python
en
['en', 'error', 'th']
False
read_keys
(base, key)
Return list of registry keys.
Return list of registry keys.
def read_keys(base, key): """Return list of registry keys.""" try: handle = RegOpenKeyEx(base, key) except RegError: return None L = [] i = 0 while True: try: k = RegEnumKey(handle, i) except RegError: break L.append(k) i +=...
[ "def", "read_keys", "(", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "L", "=", "[", "]", "i", "=", "0", "while", "True", ":", "try", ":", "k",...
[ 54, 0 ]
[ 69, 12 ]
python
en
['en', 'no', 'en']
True
read_values
(base, key)
Return dict of registry keys and values. All names are converted to lowercase.
Return dict of registry keys and values.
def read_values(base, key): """Return dict of registry keys and values. All names are converted to lowercase. """ try: handle = RegOpenKeyEx(base, key) except RegError: return None d = {} i = 0 while True: try: name, value, type = RegEnumValue(handle,...
[ "def", "read_values", "(", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "d", "=", "{", "}", "i", "=", "0", "while", "True", ":", "try", ":", "n...
[ 71, 0 ]
[ 90, 12 ]
python
en
['en', 'en', 'en']
True
get_build_version
()
Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6.
Return the version of MSVC that was used to build Python.
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = sys.version.find(prefix) if i == -1: return 6 ...
[ "def", "get_build_version", "(", ")", ":", "prefix", "=", "\"MSC v.\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "6", "i", "=", "i", "+", "len", "(", "prefix", ")", "s", ",", "r...
[ 146, 0 ]
[ 169, 15 ]
python
en
['en', 'en', 'en']
True
get_build_architecture
()
Return the processor architecture. Possible results are "Intel" or "AMD64".
Return the processor architecture.
def get_build_architecture(): """Return the processor architecture. Possible results are "Intel" or "AMD64". """ prefix = " bit (" i = sys.version.find(prefix) if i == -1: return "Intel" j = sys.version.find(")", i) return sys.version[i+len(prefix):j]
[ "def", "get_build_architecture", "(", ")", ":", "prefix", "=", "\" bit (\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "\"Intel\"", "j", "=", "sys", ".", "version", ".", "find", "(", ...
[ 171, 0 ]
[ 182, 39 ]
python
en
['en', 'it', 'en']
True
normalize_and_reduce_paths
(paths)
Return a list of normalized paths with duplicates removed. The current order of paths is maintained.
Return a list of normalized paths with duplicates removed.
def normalize_and_reduce_paths(paths): """Return a list of normalized paths with duplicates removed. The current order of paths is maintained. """ # Paths are normalized so things like: /a and /a/ aren't both preserved. reduced_paths = [] for p in paths: np = os.path.normpath(p) ...
[ "def", "normalize_and_reduce_paths", "(", "paths", ")", ":", "# Paths are normalized so things like: /a and /a/ aren't both preserved.", "reduced_paths", "=", "[", "]", "for", "p", "in", "paths", ":", "np", "=", "os", ".", "path", ".", "normpath", "(", "p", ")", ...
[ 184, 0 ]
[ 196, 24 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.find_exe
(self, exe)
Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none ...
Return path to an MSVC executable program.
def find_exe(self, exe): """Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute pa...
[ "def", "find_exe", "(", "self", ",", "exe", ")", ":", "for", "p", "in", "self", ".", "__paths", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "p", ")", ",", "exe", ")", "if", "os", ".", "path", ...
[ 564, 4 ]
[ 584, 18 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.get_msvc_paths
(self, path, platform='x86')
Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found.
Get a list of devstudio directories (include, lib or path).
def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. """ if not _can_read_reg: return ...
[ "def", "get_msvc_paths", "(", "self", ",", "path", ",", "platform", "=", "'x86'", ")", ":", "if", "not", "_can_read_reg", ":", "return", "[", "]", "path", "=", "path", "+", "\" dirs\"", "if", "self", ".", "__version", ">=", "7", ":", "key", "=", "(",...
[ 586, 4 ]
[ 620, 17 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.set_path_env_var
(self, name)
Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands.
Set environment variable 'name' to an MSVC path type value.
def set_path_env_var(self, name): """Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands. """ if name == "lib": p = self.get_msvc_paths("library") else: p = self.g...
[ "def", "set_path_env_var", "(", "self", ",", "name", ")", ":", "if", "name", "==", "\"lib\"", ":", "p", "=", "self", ".", "get_msvc_paths", "(", "\"library\"", ")", "else", ":", "p", "=", "self", ".", "get_msvc_paths", "(", "name", ")", "if", "p", ":...
[ 622, 4 ]
[ 634, 42 ]
python
en
['en', 'en', 'en']
True
GeoQuery.resolve_aggregate
(self, value, aggregate, connection)
Overridden from GeoQuery's normalize to handle the conversion of GeoAggregate objects.
Overridden from GeoQuery's normalize to handle the conversion of GeoAggregate objects.
def resolve_aggregate(self, value, aggregate, connection): """ Overridden from GeoQuery's normalize to handle the conversion of GeoAggregate objects. """ if isinstance(aggregate, self.aggregates_module.GeoAggregate): if aggregate.is_extent: if aggregat...
[ "def", "resolve_aggregate", "(", "self", ",", "value", ",", "aggregate", ",", "connection", ")", ":", "if", "isinstance", "(", "aggregate", ",", "self", ".", "aggregates_module", ".", "GeoAggregate", ")", ":", "if", "aggregate", ".", "is_extent", ":", "if", ...
[ 48, 4 ]
[ 62, 88 ]
python
en
['en', 'error', 'th']
False
GeoQuery._geo_field
(self, field_name=None)
Returns the first Geometry field encountered; or specified via the `field_name` keyword. The `field_name` may be a string specifying the geometry field on this GeoQuery's model, or a lookup string to a geometry field via a ForeignKey relation.
Returns the first Geometry field encountered; or specified via the `field_name` keyword. The `field_name` may be a string specifying the geometry field on this GeoQuery's model, or a lookup string to a geometry field via a ForeignKey relation.
def _geo_field(self, field_name=None): """ Returns the first Geometry field encountered; or specified via the `field_name` keyword. The `field_name` may be a string specifying the geometry field on this GeoQuery's model, or a lookup string to a geometry field via a ForeignKey re...
[ "def", "_geo_field", "(", "self", ",", "field_name", "=", "None", ")", ":", "if", "field_name", "is", "None", ":", "# Incrementing until the first geographic field is found.", "for", "fld", "in", "self", ".", "model", ".", "_meta", ".", "fields", ":", "if", "i...
[ 65, 4 ]
[ 81, 75 ]
python
en
['en', 'error', 'th']
False
MessageMiddleware.process_response
(self, request, response)
Update the storage backend (i.e., save the messages). Raise ValueError if not all messages could be stored and DEBUG is True.
Update the storage backend (i.e., save the messages).
def process_response(self, request, response): """ Update the storage backend (i.e., save the messages). Raise ValueError if not all messages could be stored and DEBUG is True. """ # A higher middleware layer may return a request which does not contain # messages storage...
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ")", ":", "# A higher middleware layer may return a request which does not contain", "# messages storage, so make no assumption that it will be there.", "if", "hasattr", "(", "request", ",", "'_messages'", "...
[ 13, 4 ]
[ 25, 23 ]
python
en
['en', 'error', 'th']
False
make_distribution_for_install_requirement
(install_req)
Returns a Distribution for the given InstallRequirement
Returns a Distribution for the given InstallRequirement
def make_distribution_for_install_requirement(install_req): # type: (InstallRequirement) -> AbstractDistribution """Returns a Distribution for the given InstallRequirement """ # Editable requirements will always be source distributions. They use the # legacy logic until we create a modern standard f...
[ "def", "make_distribution_for_install_requirement", "(", "install_req", ")", ":", "# type: (InstallRequirement) -> AbstractDistribution", "# Editable requirements will always be source distributions. They use the", "# legacy logic until we create a modern standard for them.", "if", "install_req"...
[ 9, 0 ]
[ 23, 42 ]
python
en
['en', 'en', 'en']
True
mkpath
(name, mode=0o777, verbose=1, dry_run=0)
Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, b...
Create a directory and any missing ancestor directories.
def mkpath(name, mode=0o777, verbose=1, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create so...
[ "def", "mkpath", "(", "name", ",", "mode", "=", "0o777", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "global", "_path_created", "# Detect a common bug -- name is None", "if", "not", "isinstance", "(", "name", ",", "str", ")", ":", "raise"...
[ 16, 0 ]
[ 77, 23 ]
python
en
['en', 'en', 'en']
True
create_tree
(base_dir, files, mode=0o777, verbose=1, dry_run=0)
Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the name of a directory which doesn't necessarily exist yet; 'files' is a list of filenames to be interpreted relative to 'base_dir'. 'base_dir' + the directory portion of every file in 'files' will b...
Create all the empty directories under 'base_dir' needed to put 'files' there.
def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0): """Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the name of a directory which doesn't necessarily exist yet; 'files' is a list of filenames to be interpreted relative to 'base_di...
[ "def", "create_tree", "(", "base_dir", ",", "files", ",", "mode", "=", "0o777", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "# First get the list of directories to create", "need_dir", "=", "set", "(", ")", "for", "file", "in", "files", "...
[ 79, 0 ]
[ 96, 59 ]
python
en
['en', 'en', 'en']
True
copy_tree
(src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=1, dry_run=0)
Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and dir...
Copy an entire directory tree 'src' to a new location 'dst'.
def copy_tree(src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=1, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does...
[ "def", "copy_tree", "(", "src", ",", "dst", ",", "preserve_mode", "=", "1", ",", "preserve_times", "=", "1", ",", "preserve_symlinks", "=", "0", ",", "update", "=", "0", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "from", "distutils...
[ 98, 0 ]
[ 165, 18 ]
python
en
['en', 'en', 'en']
True
_build_cmdtuple
(path, cmdtuples)
Helper for remove_tree().
Helper for remove_tree().
def _build_cmdtuple(path, cmdtuples): """Helper for remove_tree().""" for f in os.listdir(path): real_f = os.path.join(path,f) if os.path.isdir(real_f) and not os.path.islink(real_f): _build_cmdtuple(real_f, cmdtuples) else: cmdtuples.append((os.remove, real_f)) ...
[ "def", "_build_cmdtuple", "(", "path", ",", "cmdtuples", ")", ":", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "real_f", "=", "os", ".", "path", ".", "join", "(", "path", ",", "f", ")", "if", "os", ".", "path", ".", "isdir", ...
[ 167, 0 ]
[ 175, 38 ]
python
da
['da', 'it', 'en']
False
remove_tree
(directory, verbose=1, dry_run=0)
Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).
Recursively remove an entire directory tree.
def remove_tree(directory, verbose=1, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true). """ global _path_created if verbose >= 1: log.info("removing '%s' (and everything under it)", directory) ...
[ "def", "remove_tree", "(", "directory", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "global", "_path_created", "if", "verbose", ">=", "1", ":", "log", ".", "info", "(", "\"removing '%s' (and everything under it)\"", ",", "directory", ")", "...
[ 177, 0 ]
[ 199, 61 ]
python
en
['en', 'en', 'en']
True
ensure_relative
(path)
Take the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join().
Take the full path 'path', and make it a relative path.
def ensure_relative(path): """Take the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join(). """ drive, path = os.path.splitdrive(path) if path[0:1] == os.sep: path = drive + path[1:] return path
[ "def", "ensure_relative", "(", "path", ")", ":", "drive", ",", "path", "=", "os", ".", "path", ".", "splitdrive", "(", "path", ")", "if", "path", "[", "0", ":", "1", "]", "==", "os", ".", "sep", ":", "path", "=", "drive", "+", "path", "[", "1",...
[ 201, 0 ]
[ 209, 15 ]
python
en
['en', 'en', 'en']
True
reset_format_cache
()
Clear any cached formats. This method is provided primarily for testing purposes, so that the effects of cached formats can be removed.
Clear any cached formats.
def reset_format_cache(): """Clear any cached formats. This method is provided primarily for testing purposes, so that the effects of cached formats can be removed. """ global _format_cache, _format_modules_cache _format_cache = {} _format_modules_cache = {}
[ "def", "reset_format_cache", "(", ")", ":", "global", "_format_cache", ",", "_format_modules_cache", "_format_cache", "=", "{", "}", "_format_modules_cache", "=", "{", "}" ]
[ 48, 0 ]
[ 56, 30 ]
python
en
['en', 'en', 'en']
True
iter_format_modules
(lang, format_module_path=None)
Find format modules.
Find format modules.
def iter_format_modules(lang, format_module_path=None): """Find format modules.""" if not check_for_language(lang): return if format_module_path is None: format_module_path = settings.FORMAT_MODULE_PATH format_locations = [] if format_module_path: if isinstance(format_modul...
[ "def", "iter_format_modules", "(", "lang", ",", "format_module_path", "=", "None", ")", ":", "if", "not", "check_for_language", "(", "lang", ")", ":", "return", "if", "format_module_path", "is", "None", ":", "format_module_path", "=", "settings", ".", "FORMAT_MO...
[ 59, 0 ]
[ 83, 20 ]
python
en
['en', 'co', 'en']
True
get_format_modules
(lang=None, reverse=False)
Return a list of the format modules found.
Return a list of the format modules found.
def get_format_modules(lang=None, reverse=False): """Return a list of the format modules found.""" if lang is None: lang = get_language() if lang not in _format_modules_cache: _format_modules_cache[lang] = list(iter_format_modules(lang, settings.FORMAT_MODULE_PATH)) modules = _format_mod...
[ "def", "get_format_modules", "(", "lang", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "lang", "is", "None", ":", "lang", "=", "get_language", "(", ")", "if", "lang", "not", "in", "_format_modules_cache", ":", "_format_modules_cache", "[", "l...
[ 86, 0 ]
[ 95, 18 ]
python
en
['en', 'en', 'en']
True
get_format
(format_type, lang=None, use_l10n=None)
For a specific format type, return the format for the current language (locale). Default to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT'. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings...
For a specific format type, return the format for the current language (locale). Default to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT'.
def get_format(format_type, lang=None, use_l10n=None): """ For a specific format type, return the format for the current language (locale). Default to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT'. If use_l10n is provided and is not None, it forces the value ...
[ "def", "get_format", "(", "format_type", ",", "lang", "=", "None", ",", "use_l10n", "=", "None", ")", ":", "use_l10n", "=", "use_l10n", "or", "(", "use_l10n", "is", "None", "and", "settings", ".", "USE_L10N", ")", "if", "use_l10n", "and", "lang", "is", ...
[ 98, 0 ]
[ 137, 14 ]
python
en
['en', 'error', 'th']
False
date_format
(value, format=None, use_l10n=None)
Format a datetime.date or datetime.datetime object using a localizable format. If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N.
Format a datetime.date or datetime.datetime object using a localizable format.
def date_format(value, format=None, use_l10n=None): """ Format a datetime.date or datetime.datetime object using a localizable format. If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N. """ return dateforma...
[ "def", "date_format", "(", "value", ",", "format", "=", "None", ",", "use_l10n", "=", "None", ")", ":", "return", "dateformat", ".", "format", "(", "value", ",", "get_format", "(", "format", "or", "'DATE_FORMAT'", ",", "use_l10n", "=", "use_l10n", ")", "...
[ 143, 0 ]
[ 151, 91 ]
python
en
['en', 'error', 'th']
False
time_format
(value, format=None, use_l10n=None)
Format a datetime.time object using a localizable format. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.
Format a datetime.time object using a localizable format.
def time_format(value, format=None, use_l10n=None): """ Format a datetime.time object using a localizable format. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N. """ return dateformat.time_format(value, get_format...
[ "def", "time_format", "(", "value", ",", "format", "=", "None", ",", "use_l10n", "=", "None", ")", ":", "return", "dateformat", ".", "time_format", "(", "value", ",", "get_format", "(", "format", "or", "'TIME_FORMAT'", ",", "use_l10n", "=", "use_l10n", ")"...
[ 154, 0 ]
[ 161, 96 ]
python
en
['en', 'error', 'th']
False
number_format
(value, decimal_pos=None, use_l10n=None, force_grouping=False)
Format a numeric value using localization settings. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.
Format a numeric value using localization settings.
def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False): """ Format a numeric value using localization settings. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N. """ if use_l10n or (use_l10n...
[ "def", "number_format", "(", "value", ",", "decimal_pos", "=", "None", ",", "use_l10n", "=", "None", ",", "force_grouping", "=", "False", ")", ":", "if", "use_l10n", "or", "(", "use_l10n", "is", "None", "and", "settings", ".", "USE_L10N", ")", ":", "lang...
[ 164, 0 ]
[ 183, 5 ]
python
en
['en', 'error', 'th']
False
localize
(value, use_l10n=None)
Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.
Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format.
def localize(value, use_l10n=None): """ Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N. """ ...
[ "def", "localize", "(", "value", ",", "use_l10n", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "# Handle strings first for performance reasons.", "return", "value", "elif", "isinstance", "(", "value", ",", "bool", ")", ":", ...
[ 186, 0 ]
[ 206, 16 ]
python
en
['en', 'error', 'th']
False
localize_input
(value, default=None)
Check if an input value is a localizable type and return it formatted with the appropriate formatting string of the current locale.
Check if an input value is a localizable type and return it formatted with the appropriate formatting string of the current locale.
def localize_input(value, default=None): """ Check if an input value is a localizable type and return it formatted with the appropriate formatting string of the current locale. """ if isinstance(value, str): # Handle strings first for performance reasons. return value elif isinstance(va...
[ "def", "localize_input", "(", "value", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "# Handle strings first for performance reasons.", "return", "value", "elif", "isinstance", "(", "value", ",", "bool", ")", ":...
[ 209, 0 ]
[ 231, 16 ]
python
en
['en', 'error', 'th']
False
sanitize_separators
(value)
Sanitize a value according to the current decimal and thousand separator setting. Used with form field input.
Sanitize a value according to the current decimal and thousand separator setting. Used with form field input.
def sanitize_separators(value): """ Sanitize a value according to the current decimal and thousand separator setting. Used with form field input. """ if isinstance(value, str): parts = [] decimal_separator = get_format('DECIMAL_SEPARATOR') if decimal_separator in value: ...
[ "def", "sanitize_separators", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "parts", "=", "[", "]", "decimal_separator", "=", "get_format", "(", "'DECIMAL_SEPARATOR'", ")", "if", "decimal_separator", "in", "value", ":", "val...
[ 234, 0 ]
[ 256, 16 ]
python
en
['en', 'error', 'th']
False
CurrentSiteManager._get_field_name
(self)
Return self.__field_name or 'site' or 'sites'.
Return self.__field_name or 'site' or 'sites'.
def _get_field_name(self): """ Return self.__field_name or 'site' or 'sites'. """ if not self.__field_name: try: self.model._meta.get_field('site') except FieldDoesNotExist: self.__field_name = 'sites' else: self.__fiel...
[ "def", "_get_field_name", "(", "self", ")", ":", "if", "not", "self", ".", "__field_name", ":", "try", ":", "self", ".", "model", ".", "_meta", ".", "get_field", "(", "'site'", ")", "except", "FieldDoesNotExist", ":", "self", ".", "__field_name", "=", "'...
[ 49, 4 ]
[ 59, 32 ]
python
en
['en', 'en', 'en']
True
setup
(**attrs)
The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options supplied to 'setup()' (as ...
The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options supplied to 'setup()' (as ...
def setup (**attrs): """The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options ...
[ "def", "setup", "(", "*", "*", "attrs", ")", ":", "global", "_setup_stop_after", ",", "_setup_distribution", "# Determine the distribution class -- either caller-supplied or", "# our Distribution (see below).", "klass", "=", "attrs", ".", "get", "(", "'distclass'", ")", "...
[ 56, 0 ]
[ 164, 15 ]
python
en
['en', 'en', 'en']
True
run_setup
(script_name, script_args=None, stop_after="run")
Run a setup script in a somewhat controlled environment, and return the Distribution instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from 'script' to 'setup()', or the contents of the config files or command-line. 'script_name'...
Run a setup script in a somewhat controlled environment, and return the Distribution instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from 'script' to 'setup()', or the contents of the config files or command-line.
def run_setup (script_name, script_args=None, stop_after="run"): """Run a setup script in a somewhat controlled environment, and return the Distribution instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from 'script' to 'setup()', or ...
[ "def", "run_setup", "(", "script_name", ",", "script_args", "=", "None", ",", "stop_after", "=", "\"run\"", ")", ":", "if", "stop_after", "not", "in", "(", "'init'", ",", "'config'", ",", "'commandline'", ",", "'run'", ")", ":", "raise", "ValueError", "(",...
[ 169, 0 ]
[ 231, 30 ]
python
en
['en', 'en', 'en']
True
DatabaseWrapper.disable_constraint_checking
(self)
Disable foreign key checks, primarily for use in adding rows with forward references. Always return True to indicate constraint checks need to be re-enabled.
Disable foreign key checks, primarily for use in adding rows with forward references. Always return True to indicate constraint checks need to be re-enabled.
def disable_constraint_checking(self): """ Disable foreign key checks, primarily for use in adding rows with forward references. Always return True to indicate constraint checks need to be re-enabled. """ self.cursor().execute('SET foreign_key_checks=0') return Tr...
[ "def", "disable_constraint_checking", "(", "self", ")", ":", "self", ".", "cursor", "(", ")", ".", "execute", "(", "'SET foreign_key_checks=0'", ")", "return", "True" ]
[ 265, 4 ]
[ 272, 19 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper.enable_constraint_checking
(self)
Re-enable foreign key checks after they have been disabled.
Re-enable foreign key checks after they have been disabled.
def enable_constraint_checking(self): """ Re-enable foreign key checks after they have been disabled. """ # Override needs_rollback in case constraint_checks_disabled is # nested inside transaction.atomic. self.needs_rollback, needs_rollback = False, self.needs_rollback ...
[ "def", "enable_constraint_checking", "(", "self", ")", ":", "# Override needs_rollback in case constraint_checks_disabled is", "# nested inside transaction.atomic.", "self", ".", "needs_rollback", ",", "needs_rollback", "=", "False", ",", "self", ".", "needs_rollback", "try", ...
[ 274, 4 ]
[ 284, 48 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper.check_constraints
(self, table_names=None)
Check each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint ...
Check each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint ...
def check_constraints(self, table_names=None): """ Check each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows ...
[ "def", "check_constraints", "(", "self", ",", "table_names", "=", "None", ")", ":", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "if", "table_names", "is", "None", ":", "table_names", "=", "self", ".", "introspection", ".", "table_names", ...
[ 286, 4 ]
[ 324, 25 ]
python
en
['en', 'error', 'th']
False
stn
(s, length, encoding, errors)
Convert a string to a null-terminated bytes object.
Convert a string to a null-terminated bytes object.
def stn(s, length, encoding, errors): """Convert a string to a null-terminated bytes object. """ s = s.encode(encoding, errors) return s[:length] + (length - len(s)) * NUL
[ "def", "stn", "(", "s", ",", "length", ",", "encoding", ",", "errors", ")", ":", "s", "=", "s", ".", "encode", "(", "encoding", ",", "errors", ")", "return", "s", "[", ":", "length", "]", "+", "(", "length", "-", "len", "(", "s", ")", ")", "*...
[ 184, 0 ]
[ 188, 47 ]
python
en
['en', 'en', 'en']
True
nts
(s, encoding, errors)
Convert a null-terminated bytes object to a string.
Convert a null-terminated bytes object to a string.
def nts(s, encoding, errors): """Convert a null-terminated bytes object to a string. """ p = s.find(b"\0") if p != -1: s = s[:p] return s.decode(encoding, errors)
[ "def", "nts", "(", "s", ",", "encoding", ",", "errors", ")", ":", "p", "=", "s", ".", "find", "(", "b\"\\0\"", ")", "if", "p", "!=", "-", "1", ":", "s", "=", "s", "[", ":", "p", "]", "return", "s", ".", "decode", "(", "encoding", ",", "erro...
[ 190, 0 ]
[ 196, 37 ]
python
en
['en', 'en', 'en']
True
nti
(s)
Convert a number field to a python number.
Convert a number field to a python number.
def nti(s): """Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0o200): try: n = int(nts(s, "ascii", "strict") or "0", 8) except ValueError: raise InvalidHeaderError("invali...
[ "def", "nti", "(", "s", ")", ":", "# There are two possible encodings for a number field, see", "# itn() below.", "if", "s", "[", "0", "]", "!=", "chr", "(", "0o200", ")", ":", "try", ":", "n", "=", "int", "(", "nts", "(", "s", ",", "\"ascii\"", ",", "\"...
[ 198, 0 ]
[ 213, 12 ]
python
en
['en', 'en', 'en']
True
itn
(n, digits=8, format=DEFAULT_FORMAT)
Convert a python number to a number field.
Convert a python number to a number field.
def itn(n, digits=8, format=DEFAULT_FORMAT): """Convert a python number to a number field. """ # POSIX 1003.1-1988 requires numbers to be encoded as a string of # octal digits followed by a null-byte, this allows values up to # (8**(digits-1))-1. GNU tar allows storing numbers greater than # tha...
[ "def", "itn", "(", "n", ",", "digits", "=", "8", ",", "format", "=", "DEFAULT_FORMAT", ")", ":", "# POSIX 1003.1-1988 requires numbers to be encoded as a string of", "# octal digits followed by a null-byte, this allows values up to", "# (8**(digits-1))-1. GNU tar allows storing numbe...
[ 215, 0 ]
[ 240, 12 ]
python
en
['en', 'en', 'en']
True
calc_chksums
(buf)
Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in ...
Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in ...
def calc_chksums(buf): """Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be di...
[ "def", "calc_chksums", "(", "buf", ")", ":", "unsigned_chksum", "=", "256", "+", "sum", "(", "struct", ".", "unpack", "(", "\"148B\"", ",", "buf", "[", ":", "148", "]", ")", "+", "struct", ".", "unpack", "(", "\"356B\"", ",", "buf", "[", "156", ":"...
[ 242, 0 ]
[ 253, 41 ]
python
en
['en', 'en', 'en']
True
copyfileobj
(src, dst, length=None)
Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content.
Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content.
def copyfileobj(src, dst, length=None): """Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. """ if length == 0: return if length is None: while True: buf = src.read(16*1024) if not buf: break ...
[ "def", "copyfileobj", "(", "src", ",", "dst", ",", "length", "=", "None", ")", ":", "if", "length", "==", "0", ":", "return", "if", "length", "is", "None", ":", "while", "True", ":", "buf", "=", "src", ".", "read", "(", "16", "*", "1024", ")", ...
[ 255, 0 ]
[ 282, 10 ]
python
en
['en', 'pt', 'en']
True
filemode
(mode)
Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list()
Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list()
def filemode(mode): """Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() """ perm = [] for table in filemode_table: for bit, char in table: if mode & bit == bit: perm.append(char) break else: ...
[ "def", "filemode", "(", "mode", ")", ":", "perm", "=", "[", "]", "for", "table", "in", "filemode_table", ":", "for", "bit", ",", "char", "in", "table", ":", "if", "mode", "&", "bit", "==", "bit", ":", "perm", ".", "append", "(", "char", ")", "bre...
[ 311, 0 ]
[ 324, 24 ]
python
en
['en', 'en', 'en']
True
is_tarfile
(name)
Return True if name points to a tar archive that we are able to handle, else return False.
Return True if name points to a tar archive that we are able to handle, else return False.
def is_tarfile(name): """Return True if name points to a tar archive that we are able to handle, else return False. """ try: t = open(name) t.close() return True except TarError: return False
[ "def", "is_tarfile", "(", "name", ")", ":", "try", ":", "t", "=", "open", "(", "name", ")", "t", ".", "close", "(", ")", "return", "True", "except", "TarError", ":", "return", "False" ]
[ 2594, 0 ]
[ 2603, 20 ]
python
en
['en', 'en', 'en']
True
_Stream.__init__
(self, name, mode, comptype, fileobj, bufsize)
Construct a _Stream object.
Construct a _Stream object.
def __init__(self, name, mode, comptype, fileobj, bufsize): """Construct a _Stream object. """ self._extfileobj = True if fileobj is None: fileobj = _LowLevelFile(name, mode) self._extfileobj = False if comptype == '*': # Enable transparent co...
[ "def", "__init__", "(", "self", ",", "name", ",", "mode", ",", "comptype", ",", "fileobj", ",", "bufsize", ")", ":", "self", ".", "_extfileobj", "=", "True", "if", "fileobj", "is", "None", ":", "fileobj", "=", "_LowLevelFile", "(", "name", ",", "mode",...
[ 398, 4 ]
[ 448, 17 ]
python
en
['en', 'en', 'en']
True
_Stream._init_write_gz
(self)
Initialize for writing with gzip compression.
Initialize for writing with gzip compression.
def _init_write_gz(self): """Initialize for writing with gzip compression. """ self.cmp = self.zlib.compressobj(9, self.zlib.DEFLATED, -self.zlib.MAX_WBITS, self.zlib.DEF_MEM_LEVEL, ...
[ "def", "_init_write_gz", "(", "self", ")", ":", "self", ".", "cmp", "=", "self", ".", "zlib", ".", "compressobj", "(", "9", ",", "self", ".", "zlib", ".", "DEFLATED", ",", "-", "self", ".", "zlib", ".", "MAX_WBITS", ",", "self", ".", "zlib", ".", ...
[ 454, 4 ]
[ 466, 69 ]
python
en
['en', 'en', 'en']
True
_Stream.write
(self, s)
Write string s to the stream.
Write string s to the stream.
def write(self, s): """Write string s to the stream. """ if self.comptype == "gz": self.crc = self.zlib.crc32(s, self.crc) self.pos += len(s) if self.comptype != "tar": s = self.cmp.compress(s) self.__write(s)
[ "def", "write", "(", "self", ",", "s", ")", ":", "if", "self", ".", "comptype", "==", "\"gz\"", ":", "self", ".", "crc", "=", "self", ".", "zlib", ".", "crc32", "(", "s", ",", "self", ".", "crc", ")", "self", ".", "pos", "+=", "len", "(", "s"...
[ 468, 4 ]
[ 476, 23 ]
python
en
['en', 'en', 'en']
True
_Stream.__write
(self, s)
Write string s to the stream if a whole new block is ready to be written.
Write string s to the stream if a whole new block is ready to be written.
def __write(self, s): """Write string s to the stream if a whole new block is ready to be written. """ self.buf += s while len(self.buf) > self.bufsize: self.fileobj.write(self.buf[:self.bufsize]) self.buf = self.buf[self.bufsize:]
[ "def", "__write", "(", "self", ",", "s", ")", ":", "self", ".", "buf", "+=", "s", "while", "len", "(", "self", ".", "buf", ")", ">", "self", ".", "bufsize", ":", "self", ".", "fileobj", ".", "write", "(", "self", ".", "buf", "[", ":", "self", ...
[ 478, 4 ]
[ 485, 46 ]
python
en
['en', 'en', 'en']
True
_Stream.close
(self)
Close the _Stream object. No operation should be done on it afterwards.
Close the _Stream object. No operation should be done on it afterwards.
def close(self): """Close the _Stream object. No operation should be done on it afterwards. """ if self.closed: return if self.mode == "w" and self.comptype != "tar": self.buf += self.cmp.flush() if self.mode == "w" and self.buf: s...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "return", "if", "self", ".", "mode", "==", "\"w\"", "and", "self", ".", "comptype", "!=", "\"tar\"", ":", "self", ".", "buf", "+=", "self", ".", "cmp", ".", "flush", "(", ")...
[ 487, 4 ]
[ 513, 26 ]
python
en
['en', 'en', 'en']
True
_Stream._init_read_gz
(self)
Initialize for reading a gzip compressed fileobj.
Initialize for reading a gzip compressed fileobj.
def _init_read_gz(self): """Initialize for reading a gzip compressed fileobj. """ self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS) self.dbuf = b"" # taken from gzip.GzipFile with some alterations if self.__read(2) != b"\037\213": raise ReadError("not ...
[ "def", "_init_read_gz", "(", "self", ")", ":", "self", ".", "cmp", "=", "self", ".", "zlib", ".", "decompressobj", "(", "-", "self", ".", "zlib", ".", "MAX_WBITS", ")", "self", ".", "dbuf", "=", "b\"\"", "# taken from gzip.GzipFile with some alterations", "i...
[ 515, 4 ]
[ 544, 26 ]
python
en
['en', 'en', 'pt']
True
_Stream.tell
(self)
Return the stream's file pointer position.
Return the stream's file pointer position.
def tell(self): """Return the stream's file pointer position. """ return self.pos
[ "def", "tell", "(", "self", ")", ":", "return", "self", ".", "pos" ]
[ 546, 4 ]
[ 549, 23 ]
python
en
['en', 'en', 'en']
True
_Stream.seek
(self, pos=0)
Set the stream's file pointer to pos. Negative seeking is forbidden.
Set the stream's file pointer to pos. Negative seeking is forbidden.
def seek(self, pos=0): """Set the stream's file pointer to pos. Negative seeking is forbidden. """ if pos - self.pos >= 0: blocks, remainder = divmod(pos - self.pos, self.bufsize) for i in range(blocks): self.read(self.bufsize) self....
[ "def", "seek", "(", "self", ",", "pos", "=", "0", ")", ":", "if", "pos", "-", "self", ".", "pos", ">=", "0", ":", "blocks", ",", "remainder", "=", "divmod", "(", "pos", "-", "self", ".", "pos", ",", "self", ".", "bufsize", ")", "for", "i", "i...
[ 551, 4 ]
[ 562, 23 ]
python
en
['en', 'en', 'en']
True
_Stream.read
(self, size=None)
Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF.
Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF.
def read(self, size=None): """Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF. """ if size is None: t = [] while True: buf = self._read(self.bufsize) ...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "t", "=", "[", "]", "while", "True", ":", "buf", "=", "self", ".", "_read", "(", "self", ".", "bufsize", ")", "if", "not", "buf", ":", "break", "...
[ 564, 4 ]
[ 580, 18 ]
python
en
['en', 'en', 'en']
True
_Stream._read
(self, size)
Return size bytes from the stream.
Return size bytes from the stream.
def _read(self, size): """Return size bytes from the stream. """ if self.comptype == "tar": return self.__read(size) c = len(self.dbuf) while c < size: buf = self.__read(self.bufsize) if not buf: break try: ...
[ "def", "_read", "(", "self", ",", "size", ")", ":", "if", "self", ".", "comptype", "==", "\"tar\"", ":", "return", "self", ".", "__read", "(", "size", ")", "c", "=", "len", "(", "self", ".", "dbuf", ")", "while", "c", "<", "size", ":", "buf", "...
[ 582, 4 ]
[ 601, 18 ]
python
en
['en', 'en', 'en']
True
_Stream.__read
(self, size)
Return size bytes from stream. If internal buffer is empty, read another block from the stream.
Return size bytes from stream. If internal buffer is empty, read another block from the stream.
def __read(self, size): """Return size bytes from stream. If internal buffer is empty, read another block from the stream. """ c = len(self.buf) while c < size: buf = self.fileobj.read(self.bufsize) if not buf: break self.buf...
[ "def", "__read", "(", "self", ",", "size", ")", ":", "c", "=", "len", "(", "self", ".", "buf", ")", "while", "c", "<", "size", ":", "buf", "=", "self", ".", "fileobj", ".", "read", "(", "self", ".", "bufsize", ")", "if", "not", "buf", ":", "b...
[ 603, 4 ]
[ 616, 18 ]
python
en
['en', 'fy', 'en']
True
_FileInFile.tell
(self)
Return the current file position.
Return the current file position.
def tell(self): """Return the current file position. """ return self.position
[ "def", "tell", "(", "self", ")", ":", "return", "self", ".", "position" ]
[ 741, 4 ]
[ 744, 28 ]
python
en
['en', 'en', 'en']
True
_FileInFile.seek
(self, position)
Seek to a position in the file.
Seek to a position in the file.
def seek(self, position): """Seek to a position in the file. """ self.position = position
[ "def", "seek", "(", "self", ",", "position", ")", ":", "self", ".", "position", "=", "position" ]
[ 746, 4 ]
[ 749, 32 ]
python
en
['en', 'en', 'en']
True
_FileInFile.read
(self, size=None)
Read data from the file.
Read data from the file.
def read(self, size=None): """Read data from the file. """ if size is None: size = self.size - self.position else: size = min(size, self.size - self.position) buf = b"" while size > 0: while True: data, start, stop, off...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "size", "-", "self", ".", "position", "else", ":", "size", "=", "min", "(", "size", ",", "self", ".", "size", "-", "self"...
[ 751, 4 ]
[ 777, 18 ]
python
en
['en', 'en', 'en']
True
ExFileObject.read
(self, size=None)
Read at most size bytes from the file. If size is not present or None, read all data until EOF is reached.
Read at most size bytes from the file. If size is not present or None, read all data until EOF is reached.
def read(self, size=None): """Read at most size bytes from the file. If size is not present or None, read all data until EOF is reached. """ if self.closed: raise ValueError("I/O operation on closed file") buf = b"" if self.buffer: if size is N...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "buf", "=", "b\"\"", "if", "self", ".", "buffer", ":", "if", "size", "is", "None", ":...
[ 809, 4 ]
[ 831, 18 ]
python
en
['en', 'en', 'en']
True
ExFileObject.readline
(self, size=-1)
Read one entire line from the file. If size is present and non-negative, return a string with at most that size, which may be an incomplete line.
Read one entire line from the file. If size is present and non-negative, return a string with at most that size, which may be an incomplete line.
def readline(self, size=-1): """Read one entire line from the file. If size is present and non-negative, return a string with at most that size, which may be an incomplete line. """ if self.closed: raise ValueError("I/O operation on closed file") pos = ...
[ "def", "readline", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "pos", "=", "self", ".", "buffer", ".", "find", "(", "b\"\\n\"", ")", "+", "1",...
[ 836, 4 ]
[ 863, 18 ]
python
en
['en', 'en', 'en']
True
ExFileObject.readlines
(self)
Return a list with all remaining lines.
Return a list with all remaining lines.
def readlines(self): """Return a list with all remaining lines. """ result = [] while True: line = self.readline() if not line: break result.append(line) return result
[ "def", "readlines", "(", "self", ")", ":", "result", "=", "[", "]", "while", "True", ":", "line", "=", "self", ".", "readline", "(", ")", "if", "not", "line", ":", "break", "result", ".", "append", "(", "line", ")", "return", "result" ]
[ 865, 4 ]
[ 873, 21 ]
python
en
['en', 'en', 'en']
True
ExFileObject.tell
(self)
Return the current file position.
Return the current file position.
def tell(self): """Return the current file position. """ if self.closed: raise ValueError("I/O operation on closed file") return self.position
[ "def", "tell", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "return", "self", ".", "position" ]
[ 875, 4 ]
[ 881, 28 ]
python
en
['en', 'en', 'en']
True
ExFileObject.seek
(self, pos, whence=os.SEEK_SET)
Seek to a position in the file.
Seek to a position in the file.
def seek(self, pos, whence=os.SEEK_SET): """Seek to a position in the file. """ if self.closed: raise ValueError("I/O operation on closed file") if whence == os.SEEK_SET: self.position = min(max(pos, 0), self.size) elif whence == os.SEEK_CUR: ...
[ "def", "seek", "(", "self", ",", "pos", ",", "whence", "=", "os", ".", "SEEK_SET", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "if", "whence", "==", "os", ".", "SEEK_SET", ":", "self", ...
[ 883, 4 ]
[ 902, 40 ]
python
en
['en', 'en', 'en']
True
ExFileObject.close
(self)
Close the file object.
Close the file object.
def close(self): """Close the file object. """ self.closed = True
[ "def", "close", "(", "self", ")", ":", "self", ".", "closed", "=", "True" ]
[ 904, 4 ]
[ 907, 26 ]
python
en
['en', 'en', 'en']
True
ExFileObject.__iter__
(self)
Get an iterator over the file's lines.
Get an iterator over the file's lines.
def __iter__(self): """Get an iterator over the file's lines. """ while True: line = self.readline() if not line: break yield line
[ "def", "__iter__", "(", "self", ")", ":", "while", "True", ":", "line", "=", "self", ".", "readline", "(", ")", "if", "not", "line", ":", "break", "yield", "line" ]
[ 909, 4 ]
[ 916, 22 ]
python
en
['en', 'en', 'en']
True
TarInfo.__init__
(self, name="")
Construct a TarInfo object. name is the optional name of the member.
Construct a TarInfo object. name is the optional name of the member.
def __init__(self, name=""): """Construct a TarInfo object. name is the optional name of the member. """ self.name = name # member name self.mode = 0o644 # file permissions self.uid = 0 # user id self.gid = 0 # group id ...
[ "def", "__init__", "(", "self", ",", "name", "=", "\"\"", ")", ":", "self", ".", "name", "=", "name", "# member name", "self", ".", "mode", "=", "0o644", "# file permissions", "self", ".", "uid", "=", "0", "# user id", "self", ".", "gid", "=", "0", "...
[ 936, 4 ]
[ 958, 29 ]
python
en
['en', 'en', 'en']
True
TarInfo.get_info
(self)
Return the TarInfo's attributes as a dictionary.
Return the TarInfo's attributes as a dictionary.
def get_info(self): """Return the TarInfo's attributes as a dictionary. """ info = { "name": self.name, "mode": self.mode & 0o7777, "uid": self.uid, "gid": self.gid, "size": self.size, "mtime": self....
[ "def", "get_info", "(", "self", ")", ":", "info", "=", "{", "\"name\"", ":", "self", ".", "name", ",", "\"mode\"", ":", "self", ".", "mode", "&", "0o7777", ",", "\"uid\"", ":", "self", ".", "uid", ",", "\"gid\"", ":", "self", ".", "gid", ",", "\"...
[ 977, 4 ]
[ 999, 19 ]
python
en
['en', 'en', 'en']
True
TarInfo.tobuf
(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape")
Return a tar header as a string of 512 byte blocks.
Return a tar header as a string of 512 byte blocks.
def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"): """Return a tar header as a string of 512 byte blocks. """ info = self.get_info() if format == USTAR_FORMAT: return self.create_ustar_header(info, encoding, errors) elif format == GN...
[ "def", "tobuf", "(", "self", ",", "format", "=", "DEFAULT_FORMAT", ",", "encoding", "=", "ENCODING", ",", "errors", "=", "\"surrogateescape\"", ")", ":", "info", "=", "self", ".", "get_info", "(", ")", "if", "format", "==", "USTAR_FORMAT", ":", "return", ...
[ 1001, 4 ]
[ 1013, 46 ]
python
en
['en', 'cy', 'en']
True
TarInfo.create_ustar_header
(self, info, encoding, errors)
Return the object as a ustar header block.
Return the object as a ustar header block.
def create_ustar_header(self, info, encoding, errors): """Return the object as a ustar header block. """ info["magic"] = POSIX_MAGIC if len(info["linkname"]) > LENGTH_LINK: raise ValueError("linkname is too long") if len(info["name"]) > LENGTH_NAME: info...
[ "def", "create_ustar_header", "(", "self", ",", "info", ",", "encoding", ",", "errors", ")", ":", "info", "[", "\"magic\"", "]", "=", "POSIX_MAGIC", "if", "len", "(", "info", "[", "\"linkname\"", "]", ")", ">", "LENGTH_LINK", ":", "raise", "ValueError", ...
[ 1015, 4 ]
[ 1026, 72 ]
python
en
['en', 'ga', 'en']
True
TarInfo.create_gnu_header
(self, info, encoding, errors)
Return the object as a GNU header block sequence.
Return the object as a GNU header block sequence.
def create_gnu_header(self, info, encoding, errors): """Return the object as a GNU header block sequence. """ info["magic"] = GNU_MAGIC buf = b"" if len(info["linkname"]) > LENGTH_LINK: buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding,...
[ "def", "create_gnu_header", "(", "self", ",", "info", ",", "encoding", ",", "errors", ")", ":", "info", "[", "\"magic\"", "]", "=", "GNU_MAGIC", "buf", "=", "b\"\"", "if", "len", "(", "info", "[", "\"linkname\"", "]", ")", ">", "LENGTH_LINK", ":", "buf...
[ 1028, 4 ]
[ 1040, 76 ]
python
en
['en', 'en', 'en']
True
TarInfo.create_pax_header
(self, info, encoding)
Return the object as a ustar header block. If it cannot be represented this way, prepend a pax extended header sequence with supplement information.
Return the object as a ustar header block. If it cannot be represented this way, prepend a pax extended header sequence with supplement information.
def create_pax_header(self, info, encoding): """Return the object as a ustar header block. If it cannot be represented this way, prepend a pax extended header sequence with supplement information. """ info["magic"] = POSIX_MAGIC pax_headers = self.pax_headers.copy()...
[ "def", "create_pax_header", "(", "self", ",", "info", ",", "encoding", ")", ":", "info", "[", "\"magic\"", "]", "=", "POSIX_MAGIC", "pax_headers", "=", "self", ".", "pax_headers", ".", "copy", "(", ")", "# Test string fields for values that exceed the field length o...
[ 1042, 4 ]
[ 1089, 80 ]
python
en
['en', 'en', 'en']
True
TarInfo.create_pax_global_header
(cls, pax_headers)
Return the object as a pax global header block sequence.
Return the object as a pax global header block sequence.
def create_pax_global_header(cls, pax_headers): """Return the object as a pax global header block sequence. """ return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf8")
[ "def", "create_pax_global_header", "(", "cls", ",", "pax_headers", ")", ":", "return", "cls", ".", "_create_pax_generic_header", "(", "pax_headers", ",", "XGLTYPE", ",", "\"utf8\"", ")" ]
[ 1092, 4 ]
[ 1095, 75 ]
python
en
['en', 'en', 'en']
True
TarInfo._posix_split_name
(self, name)
Split a name longer than 100 chars into a prefix and a name part.
Split a name longer than 100 chars into a prefix and a name part.
def _posix_split_name(self, name): """Split a name longer than 100 chars into a prefix and a name part. """ prefix = name[:LENGTH_PREFIX + 1] while prefix and prefix[-1] != "/": prefix = prefix[:-1] name = name[len(prefix):] prefix = prefix[:-1] ...
[ "def", "_posix_split_name", "(", "self", ",", "name", ")", ":", "prefix", "=", "name", "[", ":", "LENGTH_PREFIX", "+", "1", "]", "while", "prefix", "and", "prefix", "[", "-", "1", "]", "!=", "\"/\"", ":", "prefix", "=", "prefix", "[", ":", "-", "1"...
[ 1097, 4 ]
[ 1110, 27 ]
python
en
['en', 'ht', 'en']
True
TarInfo._create_header
(info, format, encoding, errors)
Return a header block. info is a dictionary with file information, format must be one of the *_FORMAT constants.
Return a header block. info is a dictionary with file information, format must be one of the *_FORMAT constants.
def _create_header(info, format, encoding, errors): """Return a header block. info is a dictionary with file information, format must be one of the *_FORMAT constants. """ parts = [ stn(info.get("name", ""), 100, encoding, errors), itn(info.get("mode", 0) & 0o7...
[ "def", "_create_header", "(", "info", ",", "format", ",", "encoding", ",", "errors", ")", ":", "parts", "=", "[", "stn", "(", "info", ".", "get", "(", "\"name\"", ",", "\"\"", ")", ",", "100", ",", "encoding", ",", "errors", ")", ",", "itn", "(", ...
[ 1113, 4 ]
[ 1138, 18 ]
python
en
['en', 'en', 'en']
True
TarInfo._create_payload
(payload)
Return the string payload filled with zero bytes up to the next 512 byte border.
Return the string payload filled with zero bytes up to the next 512 byte border.
def _create_payload(payload): """Return the string payload filled with zero bytes up to the next 512 byte border. """ blocks, remainder = divmod(len(payload), BLOCKSIZE) if remainder > 0: payload += (BLOCKSIZE - remainder) * NUL return payload
[ "def", "_create_payload", "(", "payload", ")", ":", "blocks", ",", "remainder", "=", "divmod", "(", "len", "(", "payload", ")", ",", "BLOCKSIZE", ")", "if", "remainder", ">", "0", ":", "payload", "+=", "(", "BLOCKSIZE", "-", "remainder", ")", "*", "NUL...
[ 1141, 4 ]
[ 1148, 22 ]
python
en
['en', 'en', 'en']
True
TarInfo._create_gnu_long_header
(cls, name, type, encoding, errors)
Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence for name.
Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence for name.
def _create_gnu_long_header(cls, name, type, encoding, errors): """Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence for name. """ name = name.encode(encoding, errors) + NUL info = {} info["name"] = "././@LongLink" info["type"] = type info["size"]...
[ "def", "_create_gnu_long_header", "(", "cls", ",", "name", ",", "type", ",", "encoding", ",", "errors", ")", ":", "name", "=", "name", ".", "encode", "(", "encoding", ",", "errors", ")", "+", "NUL", "info", "=", "{", "}", "info", "[", "\"name\"", "]"...
[ 1151, 4 ]
[ 1165, 41 ]
python
en
['en', 'en', 'en']
True
TarInfo._create_pax_generic_header
(cls, pax_headers, type, encoding)
Return a POSIX.1-2008 extended or global header sequence that contains a list of keyword, value pairs. The values must be strings.
Return a POSIX.1-2008 extended or global header sequence that contains a list of keyword, value pairs. The values must be strings.
def _create_pax_generic_header(cls, pax_headers, type, encoding): """Return a POSIX.1-2008 extended or global header sequence that contains a list of keyword, value pairs. The values must be strings. """ # Check if one of the fields contains surrogate characters and thereby...
[ "def", "_create_pax_generic_header", "(", "cls", ",", "pax_headers", ",", "type", ",", "encoding", ")", ":", "# Check if one of the fields contains surrogate characters and thereby", "# forces hdrcharset=BINARY, see _proc_pax() for more information.", "binary", "=", "False", "for",...
[ 1168, 4 ]
[ 1216, 44 ]
python
en
['en', 'en', 'en']
True
TarInfo.frombuf
(cls, buf, encoding, errors)
Construct a TarInfo object from a 512 byte bytes object.
Construct a TarInfo object from a 512 byte bytes object.
def frombuf(cls, buf, encoding, errors): """Construct a TarInfo object from a 512 byte bytes object. """ if len(buf) == 0: raise EmptyHeaderError("empty header") if len(buf) != BLOCKSIZE: raise TruncatedHeaderError("truncated header") if buf.count(NUL) == ...
[ "def", "frombuf", "(", "cls", ",", "buf", ",", "encoding", ",", "errors", ")", ":", "if", "len", "(", "buf", ")", "==", "0", ":", "raise", "EmptyHeaderError", "(", "\"empty header\"", ")", "if", "len", "(", "buf", ")", "!=", "BLOCKSIZE", ":", "raise"...
[ 1219, 4 ]
[ 1279, 18 ]
python
en
['en', 'en', 'en']
True
TarInfo.fromtarfile
(cls, tarfile)
Return the next TarInfo object from TarFile object tarfile.
Return the next TarInfo object from TarFile object tarfile.
def fromtarfile(cls, tarfile): """Return the next TarInfo object from TarFile object tarfile. """ buf = tarfile.fileobj.read(BLOCKSIZE) obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors) obj.offset = tarfile.fileobj.tell() - BLOCKSIZE return obj._proc_mem...
[ "def", "fromtarfile", "(", "cls", ",", "tarfile", ")", ":", "buf", "=", "tarfile", ".", "fileobj", ".", "read", "(", "BLOCKSIZE", ")", "obj", "=", "cls", ".", "frombuf", "(", "buf", ",", "tarfile", ".", "encoding", ",", "tarfile", ".", "errors", ")",...
[ 1282, 4 ]
[ 1289, 40 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_member
(self, tarfile)
Choose the right processing method depending on the type and call it.
Choose the right processing method depending on the type and call it.
def _proc_member(self, tarfile): """Choose the right processing method depending on the type and call it. """ if self.type in (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK): return self._proc_gnulong(tarfile) elif self.type == GNUTYPE_SPARSE: return self._proc_sp...
[ "def", "_proc_member", "(", "self", ",", "tarfile", ")", ":", "if", "self", ".", "type", "in", "(", "GNUTYPE_LONGNAME", ",", "GNUTYPE_LONGLINK", ")", ":", "return", "self", ".", "_proc_gnulong", "(", "tarfile", ")", "elif", "self", ".", "type", "==", "GN...
[ 1302, 4 ]
[ 1313, 46 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_builtin
(self, tarfile)
Process a builtin type or an unknown type which will be treated as a regular file.
Process a builtin type or an unknown type which will be treated as a regular file.
def _proc_builtin(self, tarfile): """Process a builtin type or an unknown type which will be treated as a regular file. """ self.offset_data = tarfile.fileobj.tell() offset = self.offset_data if self.isreg() or self.type not in SUPPORTED_TYPES: # Skip the f...
[ "def", "_proc_builtin", "(", "self", ",", "tarfile", ")", ":", "self", ".", "offset_data", "=", "tarfile", ".", "fileobj", ".", "tell", "(", ")", "offset", "=", "self", ".", "offset_data", "if", "self", ".", "isreg", "(", ")", "or", "self", ".", "typ...
[ 1315, 4 ]
[ 1330, 19 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_gnulong
(self, tarfile)
Process the blocks that hold a GNU longname or longlink member.
Process the blocks that hold a GNU longname or longlink member.
def _proc_gnulong(self, tarfile): """Process the blocks that hold a GNU longname or longlink member. """ buf = tarfile.fileobj.read(self._block(self.size)) # Fetch the next header and process it. try: next = self.fromtarfile(tarfile) except HeaderE...
[ "def", "_proc_gnulong", "(", "self", ",", "tarfile", ")", ":", "buf", "=", "tarfile", ".", "fileobj", ".", "read", "(", "self", ".", "_block", "(", "self", ".", "size", ")", ")", "# Fetch the next header and process it.", "try", ":", "next", "=", "self", ...
[ 1332, 4 ]
[ 1352, 19 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_sparse
(self, tarfile)
Process a GNU sparse header plus extra headers.
Process a GNU sparse header plus extra headers.
def _proc_sparse(self, tarfile): """Process a GNU sparse header plus extra headers. """ # We already collected some sparse structures in frombuf(). structs, isextended, origsize = self._sparse_structs del self._sparse_structs # Collect sparse structures from extended hea...
[ "def", "_proc_sparse", "(", "self", ",", "tarfile", ")", ":", "# We already collected some sparse structures in frombuf().", "structs", ",", "isextended", ",", "origsize", "=", "self", ".", "_sparse_structs", "del", "self", ".", "_sparse_structs", "# Collect sparse struct...
[ 1354, 4 ]
[ 1380, 19 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_pax
(self, tarfile)
Process an extended or global header as described in POSIX.1-2008.
Process an extended or global header as described in POSIX.1-2008.
def _proc_pax(self, tarfile): """Process an extended or global header as described in POSIX.1-2008. """ # Read the header information. buf = tarfile.fileobj.read(self._block(self.size)) # A pax header stores supplemental information for either # the following ...
[ "def", "_proc_pax", "(", "self", ",", "tarfile", ")", ":", "# Read the header information.", "buf", "=", "tarfile", ".", "fileobj", ".", "read", "(", "self", ".", "_block", "(", "self", ".", "size", ")", ")", "# A pax header stores supplemental information for eit...
[ 1382, 4 ]
[ 1482, 19 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_gnusparse_00
(self, next, pax_headers, buf)
Process a GNU tar extended sparse header, version 0.0.
Process a GNU tar extended sparse header, version 0.0.
def _proc_gnusparse_00(self, next, pax_headers, buf): """Process a GNU tar extended sparse header, version 0.0. """ offsets = [] for match in re.finditer(br"\d+ GNU.sparse.offset=(\d+)\n", buf): offsets.append(int(match.group(1))) numbytes = [] for match in re...
[ "def", "_proc_gnusparse_00", "(", "self", ",", "next", ",", "pax_headers", ",", "buf", ")", ":", "offsets", "=", "[", "]", "for", "match", "in", "re", ".", "finditer", "(", "br\"\\d+ GNU.sparse.offset=(\\d+)\\n\"", ",", "buf", ")", ":", "offsets", ".", "ap...
[ 1484, 4 ]
[ 1493, 50 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_gnusparse_01
(self, next, pax_headers)
Process a GNU tar extended sparse header, version 0.1.
Process a GNU tar extended sparse header, version 0.1.
def _proc_gnusparse_01(self, next, pax_headers): """Process a GNU tar extended sparse header, version 0.1. """ sparse = [int(x) for x in pax_headers["GNU.sparse.map"].split(",")] next.sparse = list(zip(sparse[::2], sparse[1::2]))
[ "def", "_proc_gnusparse_01", "(", "self", ",", "next", ",", "pax_headers", ")", ":", "sparse", "=", "[", "int", "(", "x", ")", "for", "x", "in", "pax_headers", "[", "\"GNU.sparse.map\"", "]", ".", "split", "(", "\",\"", ")", "]", "next", ".", "sparse",...
[ 1495, 4 ]
[ 1499, 58 ]
python
en
['en', 'en', 'en']
True
TarInfo._proc_gnusparse_10
(self, next, pax_headers, tarfile)
Process a GNU tar extended sparse header, version 1.0.
Process a GNU tar extended sparse header, version 1.0.
def _proc_gnusparse_10(self, next, pax_headers, tarfile): """Process a GNU tar extended sparse header, version 1.0. """ fields = None sparse = [] buf = tarfile.fileobj.read(BLOCKSIZE) fields, buf = buf.split(b"\n", 1) fields = int(fields) while len(sparse)...
[ "def", "_proc_gnusparse_10", "(", "self", ",", "next", ",", "pax_headers", ",", "tarfile", ")", ":", "fields", "=", "None", "sparse", "=", "[", "]", "buf", "=", "tarfile", ".", "fileobj", ".", "read", "(", "BLOCKSIZE", ")", "fields", ",", "buf", "=", ...
[ 1501, 4 ]
[ 1515, 58 ]
python
en
['en', 'en', 'en']
True
TarInfo._apply_pax_info
(self, pax_headers, encoding, errors)
Replace fields with supplemental information from a previous pax extended or global header.
Replace fields with supplemental information from a previous pax extended or global header.
def _apply_pax_info(self, pax_headers, encoding, errors): """Replace fields with supplemental information from a previous pax extended or global header. """ for keyword, value in pax_headers.items(): if keyword == "GNU.sparse.name": setattr(self, "path", va...
[ "def", "_apply_pax_info", "(", "self", ",", "pax_headers", ",", "encoding", ",", "errors", ")", ":", "for", "keyword", ",", "value", "in", "pax_headers", ".", "items", "(", ")", ":", "if", "keyword", "==", "\"GNU.sparse.name\"", ":", "setattr", "(", "self"...
[ 1517, 4 ]
[ 1538, 45 ]
python
en
['en', 'en', 'en']
True
TarInfo._decode_pax_field
(self, value, encoding, fallback_encoding, fallback_errors)
Decode a single field from a pax record.
Decode a single field from a pax record.
def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors): """Decode a single field from a pax record. """ try: return value.decode(encoding, "strict") except UnicodeDecodeError: return value.decode(fallback_encoding, fallback_errors)
[ "def", "_decode_pax_field", "(", "self", ",", "value", ",", "encoding", ",", "fallback_encoding", ",", "fallback_errors", ")", ":", "try", ":", "return", "value", ".", "decode", "(", "encoding", ",", "\"strict\"", ")", "except", "UnicodeDecodeError", ":", "ret...
[ 1540, 4 ]
[ 1546, 67 ]
python
en
['en', 'en', 'en']
True
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" ]
[ 1548, 4 ]
[ 1555, 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)
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): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to ...
[ "def", "__init__", "(", "self", ",", "name", "=", "None", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "format", "=", "None", ",", "tarinfo", "=", "None", ",", "dereference", "=", "None", ",", "ignore_zeros", "=", "None", ",", "encodi...
[ 1605, 4 ]
[ 1699, 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...
[ 1713, 4 ]
[ 1786, 46 ]
python
en
['en', 'en', 'en']
True