repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
pypa/pipenv
pipenv/vendor/distlib/util.py
zip_dir
def zip_dir(directory): """zip a directory tree into a BytesIO object""" result = io.BytesIO() dlen = len(directory) with ZipFile(result, "w") as zf: for root, dirs, files in os.walk(directory): for name in files: full = os.path.join(root, name) rel = ...
python
def zip_dir(directory): """zip a directory tree into a BytesIO object""" result = io.BytesIO() dlen = len(directory) with ZipFile(result, "w") as zf: for root, dirs, files in os.walk(directory): for name in files: full = os.path.join(root, name) rel = ...
[ "def", "zip_dir", "(", "directory", ")", ":", "result", "=", "io", ".", "BytesIO", "(", ")", "dlen", "=", "len", "(", "directory", ")", "with", "ZipFile", "(", "result", ",", "\"w\"", ")", "as", "zf", ":", "for", "root", ",", "dirs", ",", "files", ...
zip a directory tree into a BytesIO object
[ "zip", "a", "directory", "tree", "into", "a", "BytesIO", "object" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L1249-L1260
train
pypa/pipenv
pipenv/vendor/distlib/util.py
iglob
def iglob(path_glob): """Extended globbing function that supports ** and {opt1,opt2,opt3}.""" if _CHECK_RECURSIVE_GLOB.search(path_glob): msg = """invalid glob %r: recursive glob "**" must be used alone""" raise ValueError(msg % path_glob) if _CHECK_MISMATCH_SET.search(path_glob): ms...
python
def iglob(path_glob): """Extended globbing function that supports ** and {opt1,opt2,opt3}.""" if _CHECK_RECURSIVE_GLOB.search(path_glob): msg = """invalid glob %r: recursive glob "**" must be used alone""" raise ValueError(msg % path_glob) if _CHECK_MISMATCH_SET.search(path_glob): ms...
[ "def", "iglob", "(", "path_glob", ")", ":", "if", "_CHECK_RECURSIVE_GLOB", ".", "search", "(", "path_glob", ")", ":", "msg", "=", "\"\"\"invalid glob %r: recursive glob \"**\" must be used alone\"\"\"", "raise", "ValueError", "(", "msg", "%", "path_glob", ")", "if", ...
Extended globbing function that supports ** and {opt1,opt2,opt3}.
[ "Extended", "globbing", "function", "that", "supports", "**", "and", "{", "opt1", "opt2", "opt3", "}", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L1367-L1375
train
pypa/pipenv
pipenv/vendor/distlib/util.py
FileOperator.newer
def newer(self, source, target): """Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'so...
python
def newer(self, source, target): """Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'so...
[ "def", "newer", "(", "self", ",", "source", ",", "target", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "source", ")", ":", "raise", "DistlibException", "(", "\"file '%r' does not exist\"", "%", "os", ".", "path", ".", "abspath", "(", ...
Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'source'. Raise PackagingFileError if 'source' ...
[ "Tell", "if", "the", "target", "is", "newer", "than", "the", "source", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L493-L511
train
pypa/pipenv
pipenv/vendor/distlib/util.py
FileOperator.copy_file
def copy_file(self, infile, outfile, check=True): """Copy a file respecting dry-run and force flags. """ self.ensure_dir(os.path.dirname(outfile)) logger.info('Copying %s to %s', infile, outfile) if not self.dry_run: msg = None if check: if...
python
def copy_file(self, infile, outfile, check=True): """Copy a file respecting dry-run and force flags. """ self.ensure_dir(os.path.dirname(outfile)) logger.info('Copying %s to %s', infile, outfile) if not self.dry_run: msg = None if check: if...
[ "def", "copy_file", "(", "self", ",", "infile", ",", "outfile", ",", "check", "=", "True", ")", ":", "self", ".", "ensure_dir", "(", "os", ".", "path", ".", "dirname", "(", "outfile", ")", ")", "logger", ".", "info", "(", "'Copying %s to %s'", ",", "...
Copy a file respecting dry-run and force flags.
[ "Copy", "a", "file", "respecting", "dry", "-", "run", "and", "force", "flags", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L513-L528
train
pypa/pipenv
pipenv/vendor/distlib/util.py
FileOperator.commit
def commit(self): """ Commit recorded changes, turn off recording, return changes. """ assert self.record result = self.files_written, self.dirs_created self._init_record() return result
python
def commit(self): """ Commit recorded changes, turn off recording, return changes. """ assert self.record result = self.files_written, self.dirs_created self._init_record() return result
[ "def", "commit", "(", "self", ")", ":", "assert", "self", ".", "record", "result", "=", "self", ".", "files_written", ",", "self", ".", "dirs_created", "self", ".", "_init_record", "(", ")", "return", "result" ]
Commit recorded changes, turn off recording, return changes.
[ "Commit", "recorded", "changes", "turn", "off", "recording", "return", "changes", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L633-L641
train
pypa/pipenv
pipenv/vendor/distlib/util.py
Cache.clear
def clear(self): """ Clear the cache. """ not_removed = [] for fn in os.listdir(self.base): fn = os.path.join(self.base, fn) try: if os.path.islink(fn) or os.path.isfile(fn): os.remove(fn) elif os.path.is...
python
def clear(self): """ Clear the cache. """ not_removed = [] for fn in os.listdir(self.base): fn = os.path.join(self.base, fn) try: if os.path.islink(fn) or os.path.isfile(fn): os.remove(fn) elif os.path.is...
[ "def", "clear", "(", "self", ")", ":", "not_removed", "=", "[", "]", "for", "fn", "in", "os", ".", "listdir", "(", "self", ".", "base", ")", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "fn", ")", "try", ":",...
Clear the cache.
[ "Clear", "the", "cache", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L964-L978
train
pypa/pipenv
pipenv/vendor/distlib/util.py
EventMixin.add
def add(self, event, subscriber, append=True): """ Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend th...
python
def add(self, event, subscriber, append=True): """ Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend th...
[ "def", "add", "(", "self", ",", "event", ",", "subscriber", ",", "append", "=", "True", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "subs", "[", "event", "]", "=", "deque", "(", "[", "subscriber", "]...
Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend the subscriber to an existing subscriber list ...
[ "Add", "a", "subscriber", "for", "an", "event", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L988-L1006
train
pypa/pipenv
pipenv/vendor/distlib/util.py
EventMixin.remove
def remove(self, event, subscriber): """ Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. """ subs = self._subscribers if event not in subs: raise ValueError('No subscribers: %r' % ...
python
def remove(self, event, subscriber): """ Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. """ subs = self._subscribers if event not in subs: raise ValueError('No subscribers: %r' % ...
[ "def", "remove", "(", "self", ",", "event", ",", "subscriber", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "raise", "ValueError", "(", "'No subscribers: %r'", "%", "event", ")", "subs", "[", "event", "]", ...
Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed.
[ "Remove", "a", "subscriber", "for", "an", "event", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L1008-L1018
train
pypa/pipenv
pipenv/vendor/distlib/util.py
EventMixin.publish
def publish(self, event, *args, **kwargs): """ Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The k...
python
def publish(self, event, *args, **kwargs): """ Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The k...
[ "def", "publish", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "for", "subscriber", "in", "self", ".", "get_subscribers", "(", "event", ")", ":", "try", ":", "value", "=", "subscriber", "(...
Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The keyword arguments to pass to the event's ...
[ "Publish", "a", "event", "and", "return", "a", "list", "of", "values", "returned", "by", "its", "subscribers", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L1027-L1048
train
pypa/pipenv
pipenv/vendor/distlib/util.py
Configurator.inc_convert
def inc_convert(self, value): """Default converter for the inc:// protocol.""" if not os.path.isabs(value): value = os.path.join(self.base, value) with codecs.open(value, 'r', encoding='utf-8') as f: result = json.load(f) return result
python
def inc_convert(self, value): """Default converter for the inc:// protocol.""" if not os.path.isabs(value): value = os.path.join(self.base, value) with codecs.open(value, 'r', encoding='utf-8') as f: result = json.load(f) return result
[ "def", "inc_convert", "(", "self", ",", "value", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "value", ")", ":", "value", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "value", ")", "with", "codecs", ".", "...
Default converter for the inc:// protocol.
[ "Default", "converter", "for", "the", "inc", ":", "//", "protocol", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L1698-L1704
train
pypa/pipenv
pipenv/vendor/distlib/util.py
SubprocessMixin.reader
def reader(self, stream, context): """ Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. """ progress = self.progress verbose = self.verbose while True: s = st...
python
def reader(self, stream, context): """ Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. """ progress = self.progress verbose = self.verbose while True: s = st...
[ "def", "reader", "(", "self", ",", "stream", ",", "context", ")", ":", "progress", "=", "self", ".", "progress", "verbose", "=", "self", ".", "verbose", "while", "True", ":", "s", "=", "stream", ".", "readline", "(", ")", "if", "not", "s", ":", "br...
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
[ "Read", "lines", "from", "a", "subprocess", "output", "stream", "and", "either", "pass", "to", "a", "progress", "callable", "(", "if", "specified", ")", "or", "write", "progress", "information", "to", "sys", ".", "stderr", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/util.py#L1715-L1734
train
pypa/pipenv
pipenv/vendor/yarg/parse.py
_get
def _get(pypi_server): """ Query the PyPI RSS feed and return a list of XML items. """ response = requests.get(pypi_server) if response.status_code >= 300: raise HTTPError(status_code=response.status_code, reason=response.reason) if hasattr(response.content, '...
python
def _get(pypi_server): """ Query the PyPI RSS feed and return a list of XML items. """ response = requests.get(pypi_server) if response.status_code >= 300: raise HTTPError(status_code=response.status_code, reason=response.reason) if hasattr(response.content, '...
[ "def", "_get", "(", "pypi_server", ")", ":", "response", "=", "requests", ".", "get", "(", "pypi_server", ")", "if", "response", ".", "status_code", ">=", "300", ":", "raise", "HTTPError", "(", "status_code", "=", "response", ".", "status_code", ",", "reas...
Query the PyPI RSS feed and return a list of XML items.
[ "Query", "the", "PyPI", "RSS", "feed", "and", "return", "a", "list", "of", "XML", "items", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/yarg/parse.py#L33-L47
train
pypa/pipenv
pipenv/vendor/yarg/parse.py
newest_packages
def newest_packages( pypi_server="https://pypi.python.org/pypi?%3Aaction=packages_rss"): """ Constructs a request to the PyPI server and returns a list of :class:`yarg.parse.Package`. :param pypi_server: (option) URL to the PyPI server. >>> import yarg >>> yarg.newest_packages(...
python
def newest_packages( pypi_server="https://pypi.python.org/pypi?%3Aaction=packages_rss"): """ Constructs a request to the PyPI server and returns a list of :class:`yarg.parse.Package`. :param pypi_server: (option) URL to the PyPI server. >>> import yarg >>> yarg.newest_packages(...
[ "def", "newest_packages", "(", "pypi_server", "=", "\"https://pypi.python.org/pypi?%3Aaction=packages_rss\"", ")", ":", "items", "=", "_get", "(", "pypi_server", ")", "i", "=", "[", "]", "for", "item", "in", "items", ":", "i_dict", "=", "{", "'name'", ":", "it...
Constructs a request to the PyPI server and returns a list of :class:`yarg.parse.Package`. :param pypi_server: (option) URL to the PyPI server. >>> import yarg >>> yarg.newest_packages() [<Package yarg>, <Package gray>, <Package ragy>]
[ "Constructs", "a", "request", "to", "the", "PyPI", "server", "and", "returns", "a", "list", "of", ":", "class", ":", "yarg", ".", "parse", ".", "Package", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/yarg/parse.py#L50-L70
train
pypa/pipenv
pipenv/vendor/passa/models/lockers.py
_get_requirements
def _get_requirements(model, section_name): """Produce a mapping of identifier: requirement from the section. """ if not model: return {} return {identify_requirment(r): r for r in ( requirementslib.Requirement.from_pipfile(name, package._data) for name, package in model.get(sect...
python
def _get_requirements(model, section_name): """Produce a mapping of identifier: requirement from the section. """ if not model: return {} return {identify_requirment(r): r for r in ( requirementslib.Requirement.from_pipfile(name, package._data) for name, package in model.get(sect...
[ "def", "_get_requirements", "(", "model", ",", "section_name", ")", ":", "if", "not", "model", ":", "return", "{", "}", "return", "{", "identify_requirment", "(", "r", ")", ":", "r", "for", "r", "in", "(", "requirementslib", ".", "Requirement", ".", "fro...
Produce a mapping of identifier: requirement from the section.
[ "Produce", "a", "mapping", "of", "identifier", ":", "requirement", "from", "the", "section", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/models/lockers.py#L22-L30
train
pypa/pipenv
pipenv/vendor/passa/models/lockers.py
_collect_derived_entries
def _collect_derived_entries(state, traces, identifiers): """Produce a mapping containing all candidates derived from `identifiers`. `identifiers` should provide a collection of requirement identifications from a section (i.e. `packages` or `dev-packages`). This function uses `trace` to filter out cand...
python
def _collect_derived_entries(state, traces, identifiers): """Produce a mapping containing all candidates derived from `identifiers`. `identifiers` should provide a collection of requirement identifications from a section (i.e. `packages` or `dev-packages`). This function uses `trace` to filter out cand...
[ "def", "_collect_derived_entries", "(", "state", ",", "traces", ",", "identifiers", ")", ":", "identifiers", "=", "set", "(", "identifiers", ")", "if", "not", "identifiers", ":", "return", "{", "}", "entries", "=", "{", "}", "extras", "=", "{", "}", "for...
Produce a mapping containing all candidates derived from `identifiers`. `identifiers` should provide a collection of requirement identifications from a section (i.e. `packages` or `dev-packages`). This function uses `trace` to filter out candidates in the state that are present because of an entry in t...
[ "Produce", "a", "mapping", "containing", "all", "candidates", "derived", "from", "identifiers", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/models/lockers.py#L48-L78
train
pypa/pipenv
pipenv/vendor/passa/models/lockers.py
AbstractLocker.lock
def lock(self): """Lock specified (abstract) requirements into (concrete) candidates. The locking procedure consists of four stages: * Resolve versions and dependency graph (powered by ResolveLib). * Walk the graph to determine "why" each candidate came to be, i.e. what top-l...
python
def lock(self): """Lock specified (abstract) requirements into (concrete) candidates. The locking procedure consists of four stages: * Resolve versions and dependency graph (powered by ResolveLib). * Walk the graph to determine "why" each candidate came to be, i.e. what top-l...
[ "def", "lock", "(", "self", ")", ":", "provider", "=", "self", ".", "get_provider", "(", ")", "reporter", "=", "self", ".", "get_reporter", "(", ")", "resolver", "=", "resolvelib", ".", "Resolver", "(", "provider", ",", "reporter", ")", "with", "vistir",...
Lock specified (abstract) requirements into (concrete) candidates. The locking procedure consists of four stages: * Resolve versions and dependency graph (powered by ResolveLib). * Walk the graph to determine "why" each candidate came to be, i.e. what top-level requirements result in...
[ "Lock", "specified", "(", "abstract", ")", "requirements", "into", "(", "concrete", ")", "candidates", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/models/lockers.py#L124-L163
train
pypa/pipenv
pipenv/patched/notpip/_internal/utils/logging.py
setup_logging
def setup_logging(verbosity, no_color, user_log_file): """Configures and sets up all of the logging Returns the requested logging level, as its integer value. """ # Determine the level to be logging at. if verbosity >= 1: level = "DEBUG" elif verbosity == -1: level = "WARNING" ...
python
def setup_logging(verbosity, no_color, user_log_file): """Configures and sets up all of the logging Returns the requested logging level, as its integer value. """ # Determine the level to be logging at. if verbosity >= 1: level = "DEBUG" elif verbosity == -1: level = "WARNING" ...
[ "def", "setup_logging", "(", "verbosity", ",", "no_color", ",", "user_log_file", ")", ":", "# Determine the level to be logging at.", "if", "verbosity", ">=", "1", ":", "level", "=", "\"DEBUG\"", "elif", "verbosity", "==", "-", "1", ":", "level", "=", "\"WARNING...
Configures and sets up all of the logging Returns the requested logging level, as its integer value.
[ "Configures", "and", "sets", "up", "all", "of", "the", "logging" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/logging.py#L217-L318
train
pypa/pipenv
pipenv/patched/notpip/_internal/utils/logging.py
IndentingFormatter.format
def format(self, record): """ Calls the standard formatter, but will indent all of the log messages by our current indentation level. """ formatted = super(IndentingFormatter, self).format(record) prefix = '' if self.add_timestamp: prefix = self.format...
python
def format(self, record): """ Calls the standard formatter, but will indent all of the log messages by our current indentation level. """ formatted = super(IndentingFormatter, self).format(record) prefix = '' if self.add_timestamp: prefix = self.format...
[ "def", "format", "(", "self", ",", "record", ")", ":", "formatted", "=", "super", "(", "IndentingFormatter", ",", "self", ")", ".", "format", "(", "record", ")", "prefix", "=", "''", "if", "self", ".", "add_timestamp", ":", "prefix", "=", "self", ".", ...
Calls the standard formatter, but will indent all of the log messages by our current indentation level.
[ "Calls", "the", "standard", "formatter", "but", "will", "indent", "all", "of", "the", "log", "messages", "by", "our", "current", "indentation", "level", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/logging.py#L103-L117
train
pypa/pipenv
pipenv/patched/notpip/_internal/utils/logging.py
ColorizedStreamHandler._using_stdout
def _using_stdout(self): """ Return whether the handler is using sys.stdout. """ if WINDOWS and colorama: # Then self.stream is an AnsiToWin32 object. return self.stream.wrapped is sys.stdout return self.stream is sys.stdout
python
def _using_stdout(self): """ Return whether the handler is using sys.stdout. """ if WINDOWS and colorama: # Then self.stream is an AnsiToWin32 object. return self.stream.wrapped is sys.stdout return self.stream is sys.stdout
[ "def", "_using_stdout", "(", "self", ")", ":", "if", "WINDOWS", "and", "colorama", ":", "# Then self.stream is an AnsiToWin32 object.", "return", "self", ".", "stream", ".", "wrapped", "is", "sys", ".", "stdout", "return", "self", ".", "stream", "is", "sys", "...
Return whether the handler is using sys.stdout.
[ "Return", "whether", "the", "handler", "is", "using", "sys", ".", "stdout", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/logging.py#L145-L153
train
pypa/pipenv
pipenv/vendor/dotenv/environ.py
_cast_boolean
def _cast_boolean(value): """ Helper to convert config values to boolean as ConfigParser do. """ _BOOLEANS = {'1': True, 'yes': True, 'true': True, 'on': True, '0': False, 'no': False, 'false': False, 'off': False, '': False} value = str(value) if value.lower() not in _BOOLEANS:...
python
def _cast_boolean(value): """ Helper to convert config values to boolean as ConfigParser do. """ _BOOLEANS = {'1': True, 'yes': True, 'true': True, 'on': True, '0': False, 'no': False, 'false': False, 'off': False, '': False} value = str(value) if value.lower() not in _BOOLEANS:...
[ "def", "_cast_boolean", "(", "value", ")", ":", "_BOOLEANS", "=", "{", "'1'", ":", "True", ",", "'yes'", ":", "True", ",", "'true'", ":", "True", ",", "'on'", ":", "True", ",", "'0'", ":", "False", ",", "'no'", ":", "False", ",", "'false'", ":", ...
Helper to convert config values to boolean as ConfigParser do.
[ "Helper", "to", "convert", "config", "values", "to", "boolean", "as", "ConfigParser", "do", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/dotenv/environ.py#L17-L27
train
pypa/pipenv
pipenv/vendor/dotenv/environ.py
getenv
def getenv(option, default=undefined, cast=undefined): """ Return the value for option or default if defined. """ # We can't avoid __contains__ because value may be empty. if option in os.environ: value = os.environ[option] else: if isinstance(default, Undefined): ra...
python
def getenv(option, default=undefined, cast=undefined): """ Return the value for option or default if defined. """ # We can't avoid __contains__ because value may be empty. if option in os.environ: value = os.environ[option] else: if isinstance(default, Undefined): ra...
[ "def", "getenv", "(", "option", ",", "default", "=", "undefined", ",", "cast", "=", "undefined", ")", ":", "# We can't avoid __contains__ because value may be empty.", "if", "option", "in", "os", ".", "environ", ":", "value", "=", "os", ".", "environ", "[", "o...
Return the value for option or default if defined.
[ "Return", "the", "value", "for", "option", "or", "default", "if", "defined", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/dotenv/environ.py#L30-L54
train
pypa/pipenv
pipenv/vendor/click/formatting.py
join_options
def join_options(options): """Given a list of option strings this joins them in the most appropriate way and returns them in the form ``(formatted_string, any_prefix_is_slash)`` where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash. """ rv = [] ...
python
def join_options(options): """Given a list of option strings this joins them in the most appropriate way and returns them in the form ``(formatted_string, any_prefix_is_slash)`` where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash. """ rv = [] ...
[ "def", "join_options", "(", "options", ")", ":", "rv", "=", "[", "]", "any_prefix_is_slash", "=", "False", "for", "opt", "in", "options", ":", "prefix", "=", "split_opt", "(", "opt", ")", "[", "0", "]", "if", "prefix", "==", "'/'", ":", "any_prefix_is_...
Given a list of option strings this joins them in the most appropriate way and returns them in the form ``(formatted_string, any_prefix_is_slash)`` where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash.
[ "Given", "a", "list", "of", "option", "strings", "this", "joins", "them", "in", "the", "most", "appropriate", "way", "and", "returns", "them", "in", "the", "form", "(", "formatted_string", "any_prefix_is_slash", ")", "where", "the", "second", "item", "in", "...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/formatting.py#L239-L256
train
pypa/pipenv
pipenv/vendor/click/formatting.py
HelpFormatter.write_usage
def write_usage(self, prog, args='', prefix='Usage: '): """Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line. """ usage_prefix = '%*s%s ' % (self.current_i...
python
def write_usage(self, prog, args='', prefix='Usage: '): """Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line. """ usage_prefix = '%*s%s ' % (self.current_i...
[ "def", "write_usage", "(", "self", ",", "prog", ",", "args", "=", "''", ",", "prefix", "=", "'Usage: '", ")", ":", "usage_prefix", "=", "'%*s%s '", "%", "(", "self", ".", "current_indent", ",", "prefix", ",", "prog", ")", "text_width", "=", "self", "."...
Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line.
[ "Writes", "a", "usage", "line", "into", "the", "buffer", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/formatting.py#L125-L150
train
pypa/pipenv
pipenv/vendor/click/formatting.py
HelpFormatter.write_text
def write_text(self, text): """Writes re-indented text into the buffer. This rewraps and preserves paragraphs. """ text_width = max(self.width - self.current_indent, 11) indent = ' ' * self.current_indent self.write(wrap_text(text, text_width, ...
python
def write_text(self, text): """Writes re-indented text into the buffer. This rewraps and preserves paragraphs. """ text_width = max(self.width - self.current_indent, 11) indent = ' ' * self.current_indent self.write(wrap_text(text, text_width, ...
[ "def", "write_text", "(", "self", ",", "text", ")", ":", "text_width", "=", "max", "(", "self", ".", "width", "-", "self", ".", "current_indent", ",", "11", ")", "indent", "=", "' '", "*", "self", ".", "current_indent", "self", ".", "write", "(", "wr...
Writes re-indented text into the buffer. This rewraps and preserves paragraphs.
[ "Writes", "re", "-", "indented", "text", "into", "the", "buffer", ".", "This", "rewraps", "and", "preserves", "paragraphs", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/formatting.py#L161-L171
train
pypa/pipenv
pipenv/vendor/click/formatting.py
HelpFormatter.write_dl
def write_dl(self, rows, col_max=30, col_spacing=2): """Writes a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :par...
python
def write_dl(self, rows, col_max=30, col_spacing=2): """Writes a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :par...
[ "def", "write_dl", "(", "self", ",", "rows", ",", "col_max", "=", "30", ",", "col_spacing", "=", "2", ")", ":", "rows", "=", "list", "(", "rows", ")", "widths", "=", "measure_table", "(", "rows", ")", "if", "len", "(", "widths", ")", "!=", "2", "...
Writes a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :param col_spacing: the number of spaces between the first and ...
[ "Writes", "a", "definition", "list", "into", "the", "buffer", ".", "This", "is", "how", "options", "and", "commands", "are", "usually", "formatted", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/formatting.py#L173-L208
train
pypa/pipenv
pipenv/vendor/click/formatting.py
HelpFormatter.section
def section(self, name): """Helpful context manager that writes a paragraph, a heading, and the indents. :param name: the section name that is written as heading. """ self.write_paragraph() self.write_heading(name) self.indent() try: yield ...
python
def section(self, name): """Helpful context manager that writes a paragraph, a heading, and the indents. :param name: the section name that is written as heading. """ self.write_paragraph() self.write_heading(name) self.indent() try: yield ...
[ "def", "section", "(", "self", ",", "name", ")", ":", "self", ".", "write_paragraph", "(", ")", "self", ".", "write_heading", "(", "name", ")", "self", ".", "indent", "(", ")", "try", ":", "yield", "finally", ":", "self", ".", "dedent", "(", ")" ]
Helpful context manager that writes a paragraph, a heading, and the indents. :param name: the section name that is written as heading.
[ "Helpful", "context", "manager", "that", "writes", "a", "paragraph", "a", "heading", "and", "the", "indents", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/formatting.py#L211-L223
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
invalid_config_error_message
def invalid_config_error_message(action, key, val): """Returns a better error message when invalid configuration option is provided.""" if action in ('store_true', 'store_false'): return ("{0} is not a valid value for {1} option, " "please specify a boolean value like yes/no, " ...
python
def invalid_config_error_message(action, key, val): """Returns a better error message when invalid configuration option is provided.""" if action in ('store_true', 'store_false'): return ("{0} is not a valid value for {1} option, " "please specify a boolean value like yes/no, " ...
[ "def", "invalid_config_error_message", "(", "action", ",", "key", ",", "val", ")", ":", "if", "action", "in", "(", "'store_true'", ",", "'store_false'", ")", ":", "return", "(", "\"{0} is not a valid value for {1} option, \"", "\"please specify a boolean value like yes/no...
Returns a better error message when invalid configuration option is provided.
[ "Returns", "a", "better", "error", "message", "when", "invalid", "configuration", "option", "is", "provided", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L251-L261
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
PrettyHelpFormatter._format_option_strings
def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '): """ Return a comma-separated list of option strings and metavars. :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar ...
python
def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '): """ Return a comma-separated list of option strings and metavars. :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar ...
[ "def", "_format_option_strings", "(", "self", ",", "option", ",", "mvarfmt", "=", "' <%s>'", ",", "optsep", "=", "', '", ")", ":", "opts", "=", "[", "]", "if", "option", ".", "_short_opts", ":", "opts", ".", "append", "(", "option", ".", "_short_opts", ...
Return a comma-separated list of option strings and metavars. :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar :param optsep: separator
[ "Return", "a", "comma", "-", "separated", "list", "of", "option", "strings", "and", "metavars", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L32-L53
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
PrettyHelpFormatter.format_usage
def format_usage(self, usage): """ Ensure there is only one newline between usage and the first heading if there is no description. """ msg = '\nUsage: %s\n' % self.indent_lines(textwrap.dedent(usage), " ") return msg
python
def format_usage(self, usage): """ Ensure there is only one newline between usage and the first heading if there is no description. """ msg = '\nUsage: %s\n' % self.indent_lines(textwrap.dedent(usage), " ") return msg
[ "def", "format_usage", "(", "self", ",", "usage", ")", ":", "msg", "=", "'\\nUsage: %s\\n'", "%", "self", ".", "indent_lines", "(", "textwrap", ".", "dedent", "(", "usage", ")", ",", "\" \"", ")", "return", "msg" ]
Ensure there is only one newline between usage and the first heading if there is no description.
[ "Ensure", "there", "is", "only", "one", "newline", "between", "usage", "and", "the", "first", "heading", "if", "there", "is", "no", "description", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L60-L66
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
CustomOptionParser.insert_option_group
def insert_option_group(self, idx, *args, **kwargs): """Insert an OptionGroup at a given position.""" group = self.add_option_group(*args, **kwargs) self.option_groups.pop() self.option_groups.insert(idx, group) return group
python
def insert_option_group(self, idx, *args, **kwargs): """Insert an OptionGroup at a given position.""" group = self.add_option_group(*args, **kwargs) self.option_groups.pop() self.option_groups.insert(idx, group) return group
[ "def", "insert_option_group", "(", "self", ",", "idx", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "group", "=", "self", ".", "add_option_group", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "option_groups", ".", "pop", "(", ...
Insert an OptionGroup at a given position.
[ "Insert", "an", "OptionGroup", "at", "a", "given", "position", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L113-L120
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
CustomOptionParser.option_list_all
def option_list_all(self): """Get a list of all options, including those in option groups.""" res = self.option_list[:] for i in self.option_groups: res.extend(i.option_list) return res
python
def option_list_all(self): """Get a list of all options, including those in option groups.""" res = self.option_list[:] for i in self.option_groups: res.extend(i.option_list) return res
[ "def", "option_list_all", "(", "self", ")", ":", "res", "=", "self", ".", "option_list", "[", ":", "]", "for", "i", "in", "self", ".", "option_groups", ":", "res", ".", "extend", "(", "i", ".", "option_list", ")", "return", "res" ]
Get a list of all options, including those in option groups.
[ "Get", "a", "list", "of", "all", "options", "including", "those", "in", "option", "groups", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L123-L129
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
ConfigOptionParser._update_defaults
def _update_defaults(self, defaults): """Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).""" # Accumulate complex default state. self.values = optparse.Values(self.defaults) ...
python
def _update_defaults(self, defaults): """Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).""" # Accumulate complex default state. self.values = optparse.Values(self.defaults) ...
[ "def", "_update_defaults", "(", "self", ",", "defaults", ")", ":", "# Accumulate complex default state.", "self", ".", "values", "=", "optparse", ".", "Values", "(", "self", ".", "defaults", ")", "late_eval", "=", "set", "(", ")", "# Then set the options with thos...
Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).
[ "Updates", "the", "given", "defaults", "with", "values", "from", "the", "config", "files", "and", "the", "environ", ".", "Does", "a", "little", "special", "handling", "for", "certain", "types", "of", "options", "(", "lists", ")", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L176-L223
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
ConfigOptionParser.get_default_values
def get_default_values(self): """Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.""" if not self.process_default_values: # Old, pre-Optik 1.5 behaviour. return optparse.Values(self.defaults...
python
def get_default_values(self): """Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.""" if not self.process_default_values: # Old, pre-Optik 1.5 behaviour. return optparse.Values(self.defaults...
[ "def", "get_default_values", "(", "self", ")", ":", "if", "not", "self", ".", "process_default_values", ":", "# Old, pre-Optik 1.5 behaviour.", "return", "optparse", ".", "Values", "(", "self", ".", "defaults", ")", "# Load the configuration, or error out in case of an er...
Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.
[ "Overriding", "to", "make", "updating", "the", "defaults", "after", "instantiation", "of", "the", "option", "parser", "possible", "_update_defaults", "()", "does", "the", "dirty", "work", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L225-L244
train
pypa/pipenv
pipenv/environment.py
Environment.safe_import
def safe_import(self, name): """Helper utility for reimporting previously imported modules while inside the env""" module = None if name not in self._modules: self._modules[name] = importlib.import_module(name) module = self._modules[name] if not module: d...
python
def safe_import(self, name): """Helper utility for reimporting previously imported modules while inside the env""" module = None if name not in self._modules: self._modules[name] = importlib.import_module(name) module = self._modules[name] if not module: d...
[ "def", "safe_import", "(", "self", ",", "name", ")", ":", "module", "=", "None", "if", "name", "not", "in", "self", ".", "_modules", ":", "self", ".", "_modules", "[", "name", "]", "=", "importlib", ".", "import_module", "(", "name", ")", "module", "...
Helper utility for reimporting previously imported modules while inside the env
[ "Helper", "utility", "for", "reimporting", "previously", "imported", "modules", "while", "inside", "the", "env" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L51-L71
train
pypa/pipenv
pipenv/environment.py
Environment.resolve_dist
def resolve_dist(cls, dist, working_set): """Given a local distribution and a working set, returns all dependencies from the set. :param dist: A single distribution to find the dependencies of :type dist: :class:`pkg_resources.Distribution` :param working_set: A working set to search fo...
python
def resolve_dist(cls, dist, working_set): """Given a local distribution and a working set, returns all dependencies from the set. :param dist: A single distribution to find the dependencies of :type dist: :class:`pkg_resources.Distribution` :param working_set: A working set to search fo...
[ "def", "resolve_dist", "(", "cls", ",", "dist", ",", "working_set", ")", ":", "deps", "=", "set", "(", ")", "deps", ".", "add", "(", "dist", ")", "try", ":", "reqs", "=", "dist", ".", "requires", "(", ")", "except", "(", "AttributeError", ",", "OSE...
Given a local distribution and a working set, returns all dependencies from the set. :param dist: A single distribution to find the dependencies of :type dist: :class:`pkg_resources.Distribution` :param working_set: A working set to search for all packages :type working_set: :class:`pkg...
[ "Given", "a", "local", "distribution", "and", "a", "working", "set", "returns", "all", "dependencies", "from", "the", "set", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L74-L94
train
pypa/pipenv
pipenv/environment.py
Environment.base_paths
def base_paths(self): """ Returns the context appropriate paths for the environment. :return: A dictionary of environment specific paths to be used for installation operations :rtype: dict .. note:: The implementation of this is borrowed from a combination of pip and ...
python
def base_paths(self): """ Returns the context appropriate paths for the environment. :return: A dictionary of environment specific paths to be used for installation operations :rtype: dict .. note:: The implementation of this is borrowed from a combination of pip and ...
[ "def", "base_paths", "(", "self", ")", ":", "prefix", "=", "make_posix", "(", "self", ".", "prefix", ".", "as_posix", "(", ")", ")", "install_scheme", "=", "'nt'", "if", "(", "os", ".", "name", "==", "'nt'", ")", "else", "'posix_prefix'", "paths", "=",...
Returns the context appropriate paths for the environment. :return: A dictionary of environment specific paths to be used for installation operations :rtype: dict .. note:: The implementation of this is borrowed from a combination of pip and virtualenv and is likely to change at som...
[ "Returns", "the", "context", "appropriate", "paths", "for", "the", "environment", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L124-L173
train
pypa/pipenv
pipenv/environment.py
Environment.python
def python(self): """Path to the environment python""" py = vistir.compat.Path(self.base_paths["scripts"]).joinpath("python").absolute().as_posix() if not py: return vistir.compat.Path(sys.executable).as_posix() return py
python
def python(self): """Path to the environment python""" py = vistir.compat.Path(self.base_paths["scripts"]).joinpath("python").absolute().as_posix() if not py: return vistir.compat.Path(sys.executable).as_posix() return py
[ "def", "python", "(", "self", ")", ":", "py", "=", "vistir", ".", "compat", ".", "Path", "(", "self", ".", "base_paths", "[", "\"scripts\"", "]", ")", ".", "joinpath", "(", "\"python\"", ")", ".", "absolute", "(", ")", ".", "as_posix", "(", ")", "i...
Path to the environment python
[ "Path", "to", "the", "environment", "python" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L182-L187
train
pypa/pipenv
pipenv/environment.py
Environment.sys_path
def sys_path(self): """ The system path inside the environment :return: The :data:`sys.path` from the environment :rtype: list """ from .vendor.vistir.compat import JSONDecodeError current_executable = vistir.compat.Path(sys.executable).as_posix() if not...
python
def sys_path(self): """ The system path inside the environment :return: The :data:`sys.path` from the environment :rtype: list """ from .vendor.vistir.compat import JSONDecodeError current_executable = vistir.compat.Path(sys.executable).as_posix() if not...
[ "def", "sys_path", "(", "self", ")", ":", "from", ".", "vendor", ".", "vistir", ".", "compat", "import", "JSONDecodeError", "current_executable", "=", "vistir", ".", "compat", ".", "Path", "(", "sys", ".", "executable", ")", ".", "as_posix", "(", ")", "i...
The system path inside the environment :return: The :data:`sys.path` from the environment :rtype: list
[ "The", "system", "path", "inside", "the", "environment" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L190-L210
train
pypa/pipenv
pipenv/environment.py
Environment.sys_prefix
def sys_prefix(self): """ The prefix run inside the context of the environment :return: The python prefix inside the environment :rtype: :data:`sys.prefix` """ command = [self.python, "-c" "import sys; print(sys.prefix)"] c = vistir.misc.run(command, return_obje...
python
def sys_prefix(self): """ The prefix run inside the context of the environment :return: The python prefix inside the environment :rtype: :data:`sys.prefix` """ command = [self.python, "-c" "import sys; print(sys.prefix)"] c = vistir.misc.run(command, return_obje...
[ "def", "sys_prefix", "(", "self", ")", ":", "command", "=", "[", "self", ".", "python", ",", "\"-c\"", "\"import sys; print(sys.prefix)\"", "]", "c", "=", "vistir", ".", "misc", ".", "run", "(", "command", ",", "return_object", "=", "True", ",", "block", ...
The prefix run inside the context of the environment :return: The python prefix inside the environment :rtype: :data:`sys.prefix`
[ "The", "prefix", "run", "inside", "the", "context", "of", "the", "environment" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L213-L224
train
pypa/pipenv
pipenv/environment.py
Environment.pip_version
def pip_version(self): """ Get the pip version in the environment. Useful for knowing which args we can use when installing. """ from .vendor.packaging.version import parse as parse_version pip = next(iter( pkg for pkg in self.get_installed_packages() if pkg....
python
def pip_version(self): """ Get the pip version in the environment. Useful for knowing which args we can use when installing. """ from .vendor.packaging.version import parse as parse_version pip = next(iter( pkg for pkg in self.get_installed_packages() if pkg....
[ "def", "pip_version", "(", "self", ")", ":", "from", ".", "vendor", ".", "packaging", ".", "version", "import", "parse", "as", "parse_version", "pip", "=", "next", "(", "iter", "(", "pkg", "for", "pkg", "in", "self", ".", "get_installed_packages", "(", "...
Get the pip version in the environment. Useful for knowing which args we can use when installing.
[ "Get", "the", "pip", "version", "in", "the", "environment", ".", "Useful", "for", "knowing", "which", "args", "we", "can", "use", "when", "installing", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L251-L262
train
pypa/pipenv
pipenv/environment.py
Environment.get_distributions
def get_distributions(self): """ Retrives the distributions installed on the library path of the environment :return: A set of distributions found on the library path :rtype: iterator """ pkg_resources = self.safe_import("pkg_resources") libdirs = self.base_path...
python
def get_distributions(self): """ Retrives the distributions installed on the library path of the environment :return: A set of distributions found on the library path :rtype: iterator """ pkg_resources = self.safe_import("pkg_resources") libdirs = self.base_path...
[ "def", "get_distributions", "(", "self", ")", ":", "pkg_resources", "=", "self", ".", "safe_import", "(", "\"pkg_resources\"", ")", "libdirs", "=", "self", ".", "base_paths", "[", "\"libdirs\"", "]", ".", "split", "(", "os", ".", "pathsep", ")", "dists", "...
Retrives the distributions installed on the library path of the environment :return: A set of distributions found on the library path :rtype: iterator
[ "Retrives", "the", "distributions", "installed", "on", "the", "library", "path", "of", "the", "environment" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L264-L276
train
pypa/pipenv
pipenv/environment.py
Environment.find_egg
def find_egg(self, egg_dist): """Find an egg by name in the given environment""" site_packages = self.libdir[1] search_filename = "{0}.egg-link".format(egg_dist.project_name) try: user_site = site.getusersitepackages() except AttributeError: user_site = si...
python
def find_egg(self, egg_dist): """Find an egg by name in the given environment""" site_packages = self.libdir[1] search_filename = "{0}.egg-link".format(egg_dist.project_name) try: user_site = site.getusersitepackages() except AttributeError: user_site = si...
[ "def", "find_egg", "(", "self", ",", "egg_dist", ")", ":", "site_packages", "=", "self", ".", "libdir", "[", "1", "]", "search_filename", "=", "\"{0}.egg-link\"", ".", "format", "(", "egg_dist", ".", "project_name", ")", "try", ":", "user_site", "=", "site...
Find an egg by name in the given environment
[ "Find", "an", "egg", "by", "name", "in", "the", "given", "environment" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L278-L290
train
pypa/pipenv
pipenv/environment.py
Environment.dist_is_in_project
def dist_is_in_project(self, dist): """Determine whether the supplied distribution is in the environment.""" from .project import _normalized prefixes = [ _normalized(prefix) for prefix in self.base_paths["libdirs"].split(os.pathsep) if _normalized(prefix).startswith(_nor...
python
def dist_is_in_project(self, dist): """Determine whether the supplied distribution is in the environment.""" from .project import _normalized prefixes = [ _normalized(prefix) for prefix in self.base_paths["libdirs"].split(os.pathsep) if _normalized(prefix).startswith(_nor...
[ "def", "dist_is_in_project", "(", "self", ",", "dist", ")", ":", "from", ".", "project", "import", "_normalized", "prefixes", "=", "[", "_normalized", "(", "prefix", ")", "for", "prefix", "in", "self", ".", "base_paths", "[", "\"libdirs\"", "]", ".", "spli...
Determine whether the supplied distribution is in the environment.
[ "Determine", "whether", "the", "supplied", "distribution", "is", "in", "the", "environment", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L300-L311
train
pypa/pipenv
pipenv/environment.py
Environment.is_installed
def is_installed(self, pkgname): """Given a package name, returns whether it is installed in the environment :param str pkgname: The name of a package :return: Whether the supplied package is installed in the environment :rtype: bool """ return any(d for d in self.get_d...
python
def is_installed(self, pkgname): """Given a package name, returns whether it is installed in the environment :param str pkgname: The name of a package :return: Whether the supplied package is installed in the environment :rtype: bool """ return any(d for d in self.get_d...
[ "def", "is_installed", "(", "self", ",", "pkgname", ")", ":", "return", "any", "(", "d", "for", "d", "in", "self", ".", "get_distributions", "(", ")", "if", "d", ".", "project_name", "==", "pkgname", ")" ]
Given a package name, returns whether it is installed in the environment :param str pkgname: The name of a package :return: Whether the supplied package is installed in the environment :rtype: bool
[ "Given", "a", "package", "name", "returns", "whether", "it", "is", "installed", "in", "the", "environment" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L481-L489
train
pypa/pipenv
pipenv/environment.py
Environment.run_py
def run_py(self, cmd, cwd=os.curdir): """Run a python command in the enviornment context. :param cmd: A command to run in the environment - runs with `python -c` :type cmd: str or list :param str cwd: The working directory in which to execute the command, defaults to :data:`os.curdir` ...
python
def run_py(self, cmd, cwd=os.curdir): """Run a python command in the enviornment context. :param cmd: A command to run in the environment - runs with `python -c` :type cmd: str or list :param str cwd: The working directory in which to execute the command, defaults to :data:`os.curdir` ...
[ "def", "run_py", "(", "self", ",", "cmd", ",", "cwd", "=", "os", ".", "curdir", ")", ":", "c", "=", "None", "if", "isinstance", "(", "cmd", ",", "six", ".", "string_types", ")", ":", "script", "=", "vistir", ".", "cmdparse", ".", "Script", ".", "...
Run a python command in the enviornment context. :param cmd: A command to run in the environment - runs with `python -c` :type cmd: str or list :param str cwd: The working directory in which to execute the command, defaults to :data:`os.curdir` :return: A finished command object ...
[ "Run", "a", "python", "command", "in", "the", "enviornment", "context", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L507-L524
train
pypa/pipenv
pipenv/environment.py
Environment.run_activate_this
def run_activate_this(self): """Runs the environment's inline activation script""" if self.is_venv: activate_this = os.path.join(self.scripts_dir, "activate_this.py") if not os.path.isfile(activate_this): raise OSError("No such file: {0!s}".format(activate_this)) ...
python
def run_activate_this(self): """Runs the environment's inline activation script""" if self.is_venv: activate_this = os.path.join(self.scripts_dir, "activate_this.py") if not os.path.isfile(activate_this): raise OSError("No such file: {0!s}".format(activate_this)) ...
[ "def", "run_activate_this", "(", "self", ")", ":", "if", "self", ".", "is_venv", ":", "activate_this", "=", "os", ".", "path", ".", "join", "(", "self", ".", "scripts_dir", ",", "\"activate_this.py\"", ")", "if", "not", "os", ".", "path", ".", "isfile", ...
Runs the environment's inline activation script
[ "Runs", "the", "environment", "s", "inline", "activation", "script" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L526-L534
train
pypa/pipenv
pipenv/environment.py
Environment.activated
def activated(self, include_extras=True, extra_dists=None): """Helper context manager to activate the environment. This context manager will set the following variables for the duration of its activation: * sys.prefix * sys.path * os.environ["VIRTUAL_ENV"] ...
python
def activated(self, include_extras=True, extra_dists=None): """Helper context manager to activate the environment. This context manager will set the following variables for the duration of its activation: * sys.prefix * sys.path * os.environ["VIRTUAL_ENV"] ...
[ "def", "activated", "(", "self", ",", "include_extras", "=", "True", ",", "extra_dists", "=", "None", ")", ":", "if", "not", "extra_dists", ":", "extra_dists", "=", "[", "]", "original_path", "=", "sys", ".", "path", "original_prefix", "=", "sys", ".", "...
Helper context manager to activate the environment. This context manager will set the following variables for the duration of its activation: * sys.prefix * sys.path * os.environ["VIRTUAL_ENV"] * os.environ["PATH"] In addition, it will make any ...
[ "Helper", "context", "manager", "to", "activate", "the", "environment", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L537-L605
train
pypa/pipenv
pipenv/environment.py
Environment.uninstall
def uninstall(self, pkgname, *args, **kwargs): """A context manager which allows uninstallation of packages from the environment :param str pkgname: The name of a package to uninstall >>> env = Environment("/path/to/env/root") >>> with env.uninstall("pytz", auto_confirm=True, verbose=F...
python
def uninstall(self, pkgname, *args, **kwargs): """A context manager which allows uninstallation of packages from the environment :param str pkgname: The name of a package to uninstall >>> env = Environment("/path/to/env/root") >>> with env.uninstall("pytz", auto_confirm=True, verbose=F...
[ "def", "uninstall", "(", "self", ",", "pkgname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "auto_confirm", "=", "kwargs", ".", "pop", "(", "\"auto_confirm\"", ",", "True", ")", "verbose", "=", "kwargs", ".", "pop", "(", "\"verbose\"", ",", ...
A context manager which allows uninstallation of packages from the environment :param str pkgname: The name of a package to uninstall >>> env = Environment("/path/to/env/root") >>> with env.uninstall("pytz", auto_confirm=True, verbose=False) as uninstaller: cleaned = uninstalle...
[ "A", "context", "manager", "which", "allows", "uninstallation", "of", "packages", "from", "the", "environment" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L673-L713
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
stn
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
python
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", ")", ")", "*...
Convert a string to a null-terminated bytes object.
[ "Convert", "a", "string", "to", "a", "null", "-", "terminated", "bytes", "object", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L185-L189
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
nts
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)
python
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...
Convert a null-terminated bytes object to a string.
[ "Convert", "a", "null", "-", "terminated", "bytes", "object", "to", "a", "string", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L191-L197
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
nti
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...
python
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\"", ",", "\"...
Convert a number field to a python number.
[ "Convert", "a", "number", "field", "to", "a", "python", "number", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L199-L214
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
itn
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...
python
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...
Convert a python number to a number field.
[ "Convert", "a", "python", "number", "to", "a", "number", "field", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L216-L241
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
calc_chksums
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...
python
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", ":"...
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...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L243-L254
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
copyfileobj
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 ...
python
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", ")", ...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L256-L283
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
filemode
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: ...
python
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...
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", "()" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L312-L325
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
is_tarfile
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
python
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" ]
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L2595-L2604
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream._init_write_gz
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, ...
python
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", ".", ...
Initialize for writing with gzip compression.
[ "Initialize", "for", "writing", "with", "gzip", "compression", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L455-L467
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream.write
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)
python
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"...
Write string s to the stream.
[ "Write", "string", "s", "to", "the", "stream", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L469-L477
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream.__write
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:]
python
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", ...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L479-L486
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream.close
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...
python
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", "(", ")...
Close the _Stream object. No operation should be done on it afterwards.
[ "Close", "the", "_Stream", "object", ".", "No", "operation", "should", "be", "done", "on", "it", "afterwards", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L488-L514
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream._init_read_gz
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 ...
python
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...
Initialize for reading a gzip compressed fileobj.
[ "Initialize", "for", "reading", "a", "gzip", "compressed", "fileobj", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L516-L545
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream.seek
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....
python
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...
Set the stream's file pointer to pos. Negative seeking is forbidden.
[ "Set", "the", "stream", "s", "file", "pointer", "to", "pos", ".", "Negative", "seeking", "is", "forbidden", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L552-L563
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream.read
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) ...
python
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", "...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L565-L581
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream._read
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: ...
python
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", "...
Return size bytes from the stream.
[ "Return", "size", "bytes", "from", "the", "stream", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L583-L602
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_Stream.__read
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...
python
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...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L604-L617
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
_FileInFile.read
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...
python
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"...
Read data from the file.
[ "Read", "data", "from", "the", "file", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L752-L778
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
ExFileObject.read
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...
python
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", ":...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L810-L832
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
ExFileObject.readline
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 = ...
python
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",...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L837-L864
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
ExFileObject.seek
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: ...
python
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", ...
Seek to a position in the file.
[ "Seek", "to", "a", "position", "in", "the", "file", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L884-L903
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.get_info
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....
python
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", ",", "\"...
Return the TarInfo's attributes as a dictionary.
[ "Return", "the", "TarInfo", "s", "attributes", "as", "a", "dictionary", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L978-L1000
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.tobuf
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...
python
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", ...
Return a tar header as a string of 512 byte blocks.
[ "Return", "a", "tar", "header", "as", "a", "string", "of", "512", "byte", "blocks", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1002-L1014
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.create_ustar_header
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...
python
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", ...
Return the object as a ustar header block.
[ "Return", "the", "object", "as", "a", "ustar", "header", "block", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1016-L1027
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.create_gnu_header
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,...
python
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...
Return the object as a GNU header block sequence.
[ "Return", "the", "object", "as", "a", "GNU", "header", "block", "sequence", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1029-L1041
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.create_pax_header
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()...
python
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...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1043-L1090
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._posix_split_name
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] ...
python
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"...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1098-L1111
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._create_header
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...
python
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", "(", ...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1114-L1139
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._create_payload
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
python
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...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1142-L1149
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._create_gnu_long_header
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"]...
python
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\"", "]"...
Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence for name.
[ "Return", "a", "GNUTYPE_LONGNAME", "or", "GNUTYPE_LONGLINK", "sequence", "for", "name", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1152-L1166
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._create_pax_generic_header
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...
python
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",...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1169-L1217
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.frombuf
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) == ...
python
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"...
Construct a TarInfo object from a 512 byte bytes object.
[ "Construct", "a", "TarInfo", "object", "from", "a", "512", "byte", "bytes", "object", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1220-L1280
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo.fromtarfile
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...
python
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", ")",...
Return the next TarInfo object from TarFile object tarfile.
[ "Return", "the", "next", "TarInfo", "object", "from", "TarFile", "object", "tarfile", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1283-L1290
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_member
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...
python
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...
Choose the right processing method depending on the type and call it.
[ "Choose", "the", "right", "processing", "method", "depending", "on", "the", "type", "and", "call", "it", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1303-L1314
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_builtin
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...
python
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...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1316-L1331
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_gnulong
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...
python
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", ...
Process the blocks that hold a GNU longname or longlink member.
[ "Process", "the", "blocks", "that", "hold", "a", "GNU", "longname", "or", "longlink", "member", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1333-L1353
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_sparse
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...
python
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...
Process a GNU sparse header plus extra headers.
[ "Process", "a", "GNU", "sparse", "header", "plus", "extra", "headers", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1355-L1381
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_pax
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 ...
python
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...
Process an extended or global header as described in POSIX.1-2008.
[ "Process", "an", "extended", "or", "global", "header", "as", "described", "in", "POSIX", ".", "1", "-", "2008", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1383-L1483
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_gnusparse_00
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...
python
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...
Process a GNU tar extended sparse header, version 0.0.
[ "Process", "a", "GNU", "tar", "extended", "sparse", "header", "version", "0", ".", "0", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1485-L1494
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_gnusparse_01
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]))
python
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",...
Process a GNU tar extended sparse header, version 0.1.
[ "Process", "a", "GNU", "tar", "extended", "sparse", "header", "version", "0", ".", "1", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1496-L1500
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._proc_gnusparse_10
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)...
python
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", "=", ...
Process a GNU tar extended sparse header, version 1.0.
[ "Process", "a", "GNU", "tar", "extended", "sparse", "header", "version", "1", ".", "0", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1502-L1516
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._apply_pax_info
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...
python
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"...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1518-L1539
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._decode_pax_field
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)
python
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...
Decode a single field from a pax record.
[ "Decode", "a", "single", "field", "from", "a", "pax", "record", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1541-L1547
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarInfo._block
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
python
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" ]
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1549-L1556
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.open
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...
python
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...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1714-L1787
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.taropen
def taropen(cls, name, mode="r", fileobj=None, **kwargs): """Open uncompressed tar archive name for reading or writing. """ if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") return cls(name, mode, fileobj, **kwargs)
python
def taropen(cls, name, mode="r", fileobj=None, **kwargs): """Open uncompressed tar archive name for reading or writing. """ if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") return cls(name, mode, fileobj, **kwargs)
[ "def", "taropen", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "mode", ")", ">", "1", "or", "mode", "not", "in", "\"raw\"", ":", "raise", "ValueError", "(", ...
Open uncompressed tar archive name for reading or writing.
[ "Open", "uncompressed", "tar", "archive", "name", "for", "reading", "or", "writing", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1790-L1795
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.gzopen
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 len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'") try: ...
python
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 len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'") try: ...
[ "def", "gzopen", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "compresslevel", "=", "9", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "mode", ")", ">", "1", "or", "mode", "not", "in", "\"rw\"", "...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1798-L1826
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.bz2open
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 len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'.") try: ...
python
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 len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'.") try: ...
[ "def", "bz2open", "(", "cls", ",", "name", ",", "mode", "=", "\"r\"", ",", "fileobj", "=", "None", ",", "compresslevel", "=", "9", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "mode", ")", ">", "1", "or", "mode", "not", "in", "\"rw\"", ...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1829-L1852
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.close
def close(self): """Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive. """ if self.closed: return if self.mode in "aw": self.fileobj.write(NUL * (BLOCKSIZE * 2)) self.offset += (BLOCKSIZE * 2) ...
python
def close(self): """Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive. """ if self.closed: return if self.mode in "aw": self.fileobj.write(NUL * (BLOCKSIZE * 2)) self.offset += (BLOCKSIZE * 2) ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "return", "if", "self", ".", "mode", "in", "\"aw\"", ":", "self", ".", "fileobj", ".", "write", "(", "NUL", "*", "(", "BLOCKSIZE", "*", "2", ")", ")", "self", ".", "offset",...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1864-L1882
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.getmember
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...
python
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" ]
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", ...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1884-L1893
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.getmembers
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...
python
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...
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", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1895-L1903
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
TarFile.gettarinfo
def gettarinfo(self, name=None, arcname=None, fileobj=None): """Create a TarInfo object for either the file `name' or the file object `fileobj' (using os.fstat on its file descriptor). You can modify some of the TarInfo's attributes before you add it using addfile(). If given, `...
python
def gettarinfo(self, name=None, arcname=None, fileobj=None): """Create a TarInfo object for either the file `name' or the file object `fileobj' (using os.fstat on its file descriptor). You can modify some of the TarInfo's attributes before you add it using addfile(). If given, `...
[ "def", "gettarinfo", "(", "self", ",", "name", "=", "None", ",", "arcname", "=", "None", ",", "fileobj", "=", "None", ")", ":", "self", ".", "_check", "(", "\"aw\"", ")", "# When fileobj is given, replace name by", "# fileobj's real name.", "if", "fileobj", "i...
Create a TarInfo object for either the file `name' or the file object `fileobj' (using os.fstat on its file descriptor). You can modify some of the TarInfo's attributes before you add it using addfile(). If given, `arcname' specifies an alternative name for the file in the ar...
[ "Create", "a", "TarInfo", "object", "for", "either", "the", "file", "name", "or", "the", "file", "object", "fileobj", "(", "using", "os", ".", "fstat", "on", "its", "file", "descriptor", ")", ".", "You", "can", "modify", "some", "of", "the", "TarInfo", ...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L1911-L2007
train