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/pathlib2/__init__.py
Path.rename
def rename(self, target): """ Rename this path to the given path. """ if self._closed: self._raise_closed() self._accessor.rename(self, target)
python
def rename(self, target): """ Rename this path to the given path. """ if self._closed: self._raise_closed() self._accessor.rename(self, target)
[ "def", "rename", "(", "self", ",", "target", ")", ":", "if", "self", ".", "_closed", ":", "self", ".", "_raise_closed", "(", ")", "self", ".", "_accessor", ".", "rename", "(", "self", ",", "target", ")" ]
Rename this path to the given path.
[ "Rename", "this", "path", "to", "the", "given", "path", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1512-L1518
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.replace
def replace(self, target): """ Rename this path to the given path, clobbering the existing destination if it exists. """ if sys.version_info < (3, 3): raise NotImplementedError("replace() is only available " "with Python 3.3 and l...
python
def replace(self, target): """ Rename this path to the given path, clobbering the existing destination if it exists. """ if sys.version_info < (3, 3): raise NotImplementedError("replace() is only available " "with Python 3.3 and l...
[ "def", "replace", "(", "self", ",", "target", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "3", ")", ":", "raise", "NotImplementedError", "(", "\"replace() is only available \"", "\"with Python 3.3 and later\"", ")", "if", "self", ".", "_clo...
Rename this path to the given path, clobbering the existing destination if it exists.
[ "Rename", "this", "path", "to", "the", "given", "path", "clobbering", "the", "existing", "destination", "if", "it", "exists", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1520-L1530
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.symlink_to
def symlink_to(self, target, target_is_directory=False): """ Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's. """ if self._closed: self._raise_closed() self._accessor.symlin...
python
def symlink_to(self, target, target_is_directory=False): """ Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's. """ if self._closed: self._raise_closed() self._accessor.symlin...
[ "def", "symlink_to", "(", "self", ",", "target", ",", "target_is_directory", "=", "False", ")", ":", "if", "self", ".", "_closed", ":", "self", ".", "_raise_closed", "(", ")", "self", ".", "_accessor", ".", "symlink", "(", "target", ",", "self", ",", "...
Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's.
[ "Make", "this", "path", "a", "symlink", "pointing", "to", "the", "given", "path", ".", "Note", "the", "order", "of", "arguments", "(", "self", "target", ")", "is", "the", "reverse", "of", "os", ".", "symlink", "s", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1532-L1540
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.exists
def exists(self): """ Whether this path exists. """ try: self.stat() except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise return False return True
python
def exists(self): """ Whether this path exists. """ try: self.stat() except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise return False return True
[ "def", "exists", "(", "self", ")", ":", "try", ":", "self", ".", "stat", "(", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "not", "in", "(", "ENOENT", ",", "ENOTDIR", ")", ":", "raise", "return", "False", "return", "True" ]
Whether this path exists.
[ "Whether", "this", "path", "exists", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1544-L1554
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.is_dir
def is_dir(self): """ Whether this path is a directory. """ try: return S_ISDIR(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see ...
python
def is_dir(self): """ Whether this path is a directory. """ try: return S_ISDIR(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see ...
[ "def", "is_dir", "(", "self", ")", ":", "try", ":", "return", "S_ISDIR", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "not", "in", "(", "ENOENT", ",", "ENOTDIR", ")", ":", ...
Whether this path is a directory.
[ "Whether", "this", "path", "is", "a", "directory", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1556-L1567
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.is_file
def is_file(self): """ Whether this path is a regular file (also True for symlinks pointing to regular files). """ try: return S_ISREG(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise ...
python
def is_file(self): """ Whether this path is a regular file (also True for symlinks pointing to regular files). """ try: return S_ISREG(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise ...
[ "def", "is_file", "(", "self", ")", ":", "try", ":", "return", "S_ISREG", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "not", "in", "(", "ENOENT", ",", "ENOTDIR", ")", ":",...
Whether this path is a regular file (also True for symlinks pointing to regular files).
[ "Whether", "this", "path", "is", "a", "regular", "file", "(", "also", "True", "for", "symlinks", "pointing", "to", "regular", "files", ")", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1569-L1581
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.is_fifo
def is_fifo(self): """ Whether this path is a FIFO. """ try: return S_ISFIFO(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see htt...
python
def is_fifo(self): """ Whether this path is a FIFO. """ try: return S_ISFIFO(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see htt...
[ "def", "is_fifo", "(", "self", ")", ":", "try", ":", "return", "S_ISFIFO", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "not", "in", "(", "ENOENT", ",", "ENOTDIR", ")", ":"...
Whether this path is a FIFO.
[ "Whether", "this", "path", "is", "a", "FIFO", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1621-L1632
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.is_socket
def is_socket(self): """ Whether this path is a socket. """ try: return S_ISSOCK(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see...
python
def is_socket(self): """ Whether this path is a socket. """ try: return S_ISSOCK(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see...
[ "def", "is_socket", "(", "self", ")", ":", "try", ":", "return", "S_ISSOCK", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "not", "in", "(", "ENOENT", ",", "ENOTDIR", ")", "...
Whether this path is a socket.
[ "Whether", "this", "path", "is", "a", "socket", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1634-L1645
train
pypa/pipenv
pipenv/vendor/pathlib2/__init__.py
Path.expanduser
def expanduser(self): """ Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) """ if (not (self._drv or self._root) and self._parts and self._parts[0][:1] == '~'): homedir = self._flavour.gethomedir(self._parts[0][1:]) ...
python
def expanduser(self): """ Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) """ if (not (self._drv or self._root) and self._parts and self._parts[0][:1] == '~'): homedir = self._flavour.gethomedir(self._parts[0][1:]) ...
[ "def", "expanduser", "(", "self", ")", ":", "if", "(", "not", "(", "self", ".", "_drv", "or", "self", ".", "_root", ")", "and", "self", ".", "_parts", "and", "self", ".", "_parts", "[", "0", "]", "[", ":", "1", "]", "==", "'~'", ")", ":", "ho...
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
[ "Return", "a", "new", "path", "with", "expanded", "~", "and", "~user", "constructs", "(", "as", "returned", "by", "os", ".", "path", ".", "expanduser", ")" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1647-L1656
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
lookupEncoding
def lookupEncoding(encoding): """Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.""" if isinstance(encoding, binary_type): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return...
python
def lookupEncoding(encoding): """Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.""" if isinstance(encoding, binary_type): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return...
[ "def", "lookupEncoding", "(", "encoding", ")", ":", "if", "isinstance", "(", "encoding", ",", "binary_type", ")", ":", "try", ":", "encoding", "=", "encoding", ".", "decode", "(", "\"ascii\"", ")", "except", "UnicodeDecodeError", ":", "return", "None", "if",...
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
[ "Return", "the", "python", "codec", "name", "corresponding", "to", "an", "encoding", "or", "None", "if", "the", "string", "doesn", "t", "correspond", "to", "a", "valid", "encoding", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L908-L923
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
HTMLUnicodeInputStream.openStream
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) ...
python
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) ...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "StringIO", "(", "source", ")", "return", "stream" ]
Produces a file object from source. source can be either a file object, local filename or a string.
[ "Produces", "a", "file", "object", "from", "source", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L210-L222
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
HTMLUnicodeInputStream.position
def position(self): """Returns (line, col) of the current position in the stream.""" line, col = self._position(self.chunkOffset) return (line + 1, col)
python
def position(self): """Returns (line, col) of the current position in the stream.""" line, col = self._position(self.chunkOffset) return (line + 1, col)
[ "def", "position", "(", "self", ")", ":", "line", ",", "col", "=", "self", ".", "_position", "(", "self", ".", "chunkOffset", ")", "return", "(", "line", "+", "1", ",", "col", ")" ]
Returns (line, col) of the current position in the stream.
[ "Returns", "(", "line", "col", ")", "of", "the", "current", "position", "in", "the", "stream", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L235-L238
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
HTMLUnicodeInputStream.char
def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF ...
python
def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF ...
[ "def", "char", "(", "self", ")", ":", "# Read a new chunk from the input stream if necessary", "if", "self", ".", "chunkOffset", ">=", "self", ".", "chunkSize", ":", "if", "not", "self", ".", "readChunk", "(", ")", ":", "return", "EOF", "chunkOffset", "=", "se...
Read one character from the stream or queue if available. Return EOF when EOF is reached.
[ "Read", "one", "character", "from", "the", "stream", "or", "queue", "if", "available", ".", "Return", "EOF", "when", "EOF", "is", "reached", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L240-L253
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
HTMLUnicodeInputStream.charsUntil
def charsUntil(self, characters, opposite=False): """ Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. """ # Use ...
python
def charsUntil(self, characters, opposite=False): """ Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. """ # Use ...
[ "def", "charsUntil", "(", "self", ",", "characters", ",", "opposite", "=", "False", ")", ":", "# Use a cache of regexps to find the required characters", "try", ":", "chars", "=", "charsUntilRegEx", "[", "(", "characters", ",", "opposite", ")", "]", "except", "Key...
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
[ "Returns", "a", "string", "of", "characters", "from", "the", "stream", "up", "to", "but", "not", "including", "any", "character", "in", "characters", "or", "EOF", ".", "characters", "must", "be", "a", "container", "that", "supports", "the", "in", "method", ...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L320-L365
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
HTMLBinaryInputStream.openStream
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) t...
python
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) t...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "BytesIO", "(", "source", ")", "try", ":", "stream", ".", ...
Produces a file object from source. source can be either a file object, local filename or a string.
[ "Produces", "a", "file", "object", "from", "source", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L438-L455
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
HTMLBinaryInputStream.detectEncodingMeta
def detectEncodingMeta(self): """Report the encoding declared by the meta element """ buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() i...
python
def detectEncodingMeta(self): """Report the encoding declared by the meta element """ buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() i...
[ "def", "detectEncodingMeta", "(", "self", ")", ":", "buffer", "=", "self", ".", "rawStream", ".", "read", "(", "self", ".", "numBytesMeta", ")", "assert", "isinstance", "(", "buffer", ",", "bytes", ")", "parser", "=", "EncodingParser", "(", "buffer", ")", ...
Report the encoding declared by the meta element
[ "Report", "the", "encoding", "declared", "by", "the", "meta", "element" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L569-L581
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
EncodingBytes.skip
def skip(self, chars=spaceCharactersBytes): """Skip past a list of characters""" p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p return c ...
python
def skip(self, chars=spaceCharactersBytes): """Skip past a list of characters""" p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p return c ...
[ "def", "skip", "(", "self", ",", "chars", "=", "spaceCharactersBytes", ")", ":", "p", "=", "self", ".", "position", "# use property for the error-checking", "while", "p", "<", "len", "(", "self", ")", ":", "c", "=", "self", "[", "p", ":", "p", "+", "1"...
Skip past a list of characters
[ "Skip", "past", "a", "list", "of", "characters" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L640-L650
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
EncodingBytes.matchBytes
def matchBytes(self, bytes): """Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone""" p = self.position data = self[p:p + len(bytes)] ...
python
def matchBytes(self, bytes): """Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone""" p = self.position data = self[p:p + len(bytes)] ...
[ "def", "matchBytes", "(", "self", ",", "bytes", ")", ":", "p", "=", "self", ".", "position", "data", "=", "self", "[", "p", ":", "p", "+", "len", "(", "bytes", ")", "]", "rv", "=", "data", ".", "startswith", "(", "bytes", ")", "if", "rv", ":", ...
Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone
[ "Look", "for", "a", "sequence", "of", "bytes", "at", "the", "start", "of", "a", "string", ".", "If", "the", "bytes", "are", "found", "return", "True", "and", "advance", "the", "position", "to", "the", "byte", "after", "the", "match", ".", "Otherwise", ...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L663-L672
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
EncodingBytes.jumpTo
def jumpTo(self, bytes): """Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match""" newPosition = self[self.position:].find(bytes) if newPosition > -1: # XXX: This is ugly, but I can't see a nice...
python
def jumpTo(self, bytes): """Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match""" newPosition = self[self.position:].find(bytes) if newPosition > -1: # XXX: This is ugly, but I can't see a nice...
[ "def", "jumpTo", "(", "self", ",", "bytes", ")", ":", "newPosition", "=", "self", "[", "self", ".", "position", ":", "]", ".", "find", "(", "bytes", ")", "if", "newPosition", ">", "-", "1", ":", "# XXX: This is ugly, but I can't see a nicer way to fix this.", ...
Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match
[ "Look", "for", "the", "next", "sequence", "of", "bytes", "matching", "a", "given", "sequence", ".", "If", "a", "match", "is", "found", "advance", "the", "position", "to", "the", "last", "byte", "of", "the", "match" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L674-L685
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
EncodingParser.getAttribute
def getAttribute(self): """Return a name,value pair for the next attribute in the stream, if one is found, or None""" data = self.data # Step 1 (skip chars) c = data.skip(spaceCharactersBytes | frozenset([b"/"])) assert c is None or len(c) == 1 # Step 2 if...
python
def getAttribute(self): """Return a name,value pair for the next attribute in the stream, if one is found, or None""" data = self.data # Step 1 (skip chars) c = data.skip(spaceCharactersBytes | frozenset([b"/"])) assert c is None or len(c) == 1 # Step 2 if...
[ "def", "getAttribute", "(", "self", ")", ":", "data", "=", "self", ".", "data", "# Step 1 (skip chars)", "c", "=", "data", ".", "skip", "(", "spaceCharactersBytes", "|", "frozenset", "(", "[", "b\"/\"", "]", ")", ")", "assert", "c", "is", "None", "or", ...
Return a name,value pair for the next attribute in the stream, if one is found, or None
[ "Return", "a", "name", "value", "pair", "for", "the", "next", "attribute", "in", "the", "stream", "if", "one", "is", "found", "or", "None" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L792-L866
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
_build_backend
def _build_backend(): """Find and load the build backend""" ep = os.environ['PEP517_BUILD_BACKEND'] mod_path, _, obj_path = ep.partition(':') try: obj = import_module(mod_path) except ImportError: raise BackendUnavailable if obj_path: for path_part in obj_path.split('.'):...
python
def _build_backend(): """Find and load the build backend""" ep = os.environ['PEP517_BUILD_BACKEND'] mod_path, _, obj_path = ep.partition(':') try: obj = import_module(mod_path) except ImportError: raise BackendUnavailable if obj_path: for path_part in obj_path.split('.'):...
[ "def", "_build_backend", "(", ")", ":", "ep", "=", "os", ".", "environ", "[", "'PEP517_BUILD_BACKEND'", "]", "mod_path", ",", "_", ",", "obj_path", "=", "ep", ".", "partition", "(", "':'", ")", "try", ":", "obj", "=", "import_module", "(", "mod_path", ...
Find and load the build backend
[ "Find", "and", "load", "the", "build", "backend" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L29-L40
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
get_requires_for_build_wheel
def get_requires_for_build_wheel(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_wheel except AttributeError: return [] else: r...
python
def get_requires_for_build_wheel(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_wheel except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_wheel", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_wheel", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
[ "Invoke", "the", "optional", "get_requires_for_build_wheel", "hook" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L43-L54
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
prepare_metadata_for_build_wheel
def prepare_metadata_for_build_wheel(metadata_directory, config_settings): """Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined. """ backend = _build_backend() try: hook = backend.prepare_metadata_for_build_wheel except ...
python
def prepare_metadata_for_build_wheel(metadata_directory, config_settings): """Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined. """ backend = _build_backend() try: hook = backend.prepare_metadata_for_build_wheel except ...
[ "def", "prepare_metadata_for_build_wheel", "(", "metadata_directory", ",", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "prepare_metadata_for_build_wheel", "except", "AttributeError", ":", "return", ...
Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined.
[ "Invoke", "optional", "prepare_metadata_for_build_wheel" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L57-L69
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
_dist_info_files
def _dist_info_files(whl_zip): """Identify the .dist-info folder inside a wheel ZipFile.""" res = [] for path in whl_zip.namelist(): m = re.match(r'[^/\\]+-[^/\\]+\.dist-info/', path) if m: res.append(path) if res: return res raise Exception("No .dist-info folder ...
python
def _dist_info_files(whl_zip): """Identify the .dist-info folder inside a wheel ZipFile.""" res = [] for path in whl_zip.namelist(): m = re.match(r'[^/\\]+-[^/\\]+\.dist-info/', path) if m: res.append(path) if res: return res raise Exception("No .dist-info folder ...
[ "def", "_dist_info_files", "(", "whl_zip", ")", ":", "res", "=", "[", "]", "for", "path", "in", "whl_zip", ".", "namelist", "(", ")", ":", "m", "=", "re", ".", "match", "(", "r'[^/\\\\]+-[^/\\\\]+\\.dist-info/'", ",", "path", ")", "if", "m", ":", "res"...
Identify the .dist-info folder inside a wheel ZipFile.
[ "Identify", "the", ".", "dist", "-", "info", "folder", "inside", "a", "wheel", "ZipFile", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L75-L84
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
_get_wheel_metadata_from_wheel
def _get_wheel_metadata_from_wheel( backend, metadata_directory, config_settings): """Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook. """ from zipfile import ZipFile whl_basename = backend.build_wheel(met...
python
def _get_wheel_metadata_from_wheel( backend, metadata_directory, config_settings): """Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook. """ from zipfile import ZipFile whl_basename = backend.build_wheel(met...
[ "def", "_get_wheel_metadata_from_wheel", "(", "backend", ",", "metadata_directory", ",", "config_settings", ")", ":", "from", "zipfile", "import", "ZipFile", "whl_basename", "=", "backend", ".", "build_wheel", "(", "metadata_directory", ",", "config_settings", ")", "w...
Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook.
[ "Build", "a", "wheel", "and", "extract", "the", "metadata", "from", "it", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L87-L103
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
_find_already_built_wheel
def _find_already_built_wheel(metadata_directory): """Check for a wheel already built during the get_wheel_metadata hook. """ if not metadata_directory: return None metadata_parent = os.path.dirname(metadata_directory) if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)): ...
python
def _find_already_built_wheel(metadata_directory): """Check for a wheel already built during the get_wheel_metadata hook. """ if not metadata_directory: return None metadata_parent = os.path.dirname(metadata_directory) if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)): ...
[ "def", "_find_already_built_wheel", "(", "metadata_directory", ")", ":", "if", "not", "metadata_directory", ":", "return", "None", "metadata_parent", "=", "os", ".", "path", ".", "dirname", "(", "metadata_directory", ")", "if", "not", "os", ".", "path", ".", "...
Check for a wheel already built during the get_wheel_metadata hook.
[ "Check", "for", "a", "wheel", "already", "built", "during", "the", "get_wheel_metadata", "hook", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L106-L125
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
build_wheel
def build_wheel(wheel_directory, config_settings, metadata_directory=None): """Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel. """ prebuilt_whl = _find_already_built_wheel(m...
python
def build_wheel(wheel_directory, config_settings, metadata_directory=None): """Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel. """ prebuilt_whl = _find_already_built_wheel(m...
[ "def", "build_wheel", "(", "wheel_directory", ",", "config_settings", ",", "metadata_directory", "=", "None", ")", ":", "prebuilt_whl", "=", "_find_already_built_wheel", "(", "metadata_directory", ")", "if", "prebuilt_whl", ":", "shutil", ".", "copy2", "(", "prebuil...
Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel.
[ "Invoke", "the", "mandatory", "build_wheel", "hook", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L128-L141
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
get_requires_for_build_sdist
def get_requires_for_build_sdist(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_sdist except AttributeError: return [] else: r...
python
def get_requires_for_build_sdist(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_sdist except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_sdist", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_sdist", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
[ "Invoke", "the", "optional", "get_requires_for_build_wheel", "hook" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L144-L155
train
pypa/pipenv
pipenv/vendor/tomlkit/items.py
Table.append
def append(self, key, _item): # type: (Union[Key, str], Any) -> Table """ Appends a (key, item) to the table. """ if not isinstance(_item, Item): _item = item(_item) self._value.append(key, _item) if isinstance(key, Key): key = key.key ...
python
def append(self, key, _item): # type: (Union[Key, str], Any) -> Table """ Appends a (key, item) to the table. """ if not isinstance(_item, Item): _item = item(_item) self._value.append(key, _item) if isinstance(key, Key): key = key.key ...
[ "def", "append", "(", "self", ",", "key", ",", "_item", ")", ":", "# type: (Union[Key, str], Any) -> Table", "if", "not", "isinstance", "(", "_item", ",", "Item", ")", ":", "_item", "=", "item", "(", "_item", ")", "self", ".", "_value", ".", "append", "(...
Appends a (key, item) to the table.
[ "Appends", "a", "(", "key", "item", ")", "to", "the", "table", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/items.py#L780-L808
train
pypa/pipenv
pipenv/vendor/tomlkit/items.py
InlineTable.append
def append(self, key, _item): # type: (Union[Key, str], Any) -> InlineTable """ Appends a (key, item) to the table. """ if not isinstance(_item, Item): _item = item(_item) if not isinstance(_item, (Whitespace, Comment)): if not _item.trivia.indent and le...
python
def append(self, key, _item): # type: (Union[Key, str], Any) -> InlineTable """ Appends a (key, item) to the table. """ if not isinstance(_item, Item): _item = item(_item) if not isinstance(_item, (Whitespace, Comment)): if not _item.trivia.indent and le...
[ "def", "append", "(", "self", ",", "key", ",", "_item", ")", ":", "# type: (Union[Key, str], Any) -> InlineTable", "if", "not", "isinstance", "(", "_item", ",", "Item", ")", ":", "_item", "=", "item", "(", "_item", ")", "if", "not", "isinstance", "(", "_it...
Appends a (key, item) to the table.
[ "Appends", "a", "(", "key", "item", ")", "to", "the", "table", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/items.py#L932-L953
train
pypa/pipenv
pipenv/vendor/backports/functools_lru_cache.py
update_wrapper
def update_wrapper(wrapper, wrapped, assigned = functools.WRAPPER_ASSIGNMENTS, updated = functools.WRAPPER_UPDATES): """ Patch two bugs in functools.update_wrapper. """ # workaround for http://bugs.python.org/issue3445 assigned = tuple(attr fo...
python
def update_wrapper(wrapper, wrapped, assigned = functools.WRAPPER_ASSIGNMENTS, updated = functools.WRAPPER_UPDATES): """ Patch two bugs in functools.update_wrapper. """ # workaround for http://bugs.python.org/issue3445 assigned = tuple(attr fo...
[ "def", "update_wrapper", "(", "wrapper", ",", "wrapped", ",", "assigned", "=", "functools", ".", "WRAPPER_ASSIGNMENTS", ",", "updated", "=", "functools", ".", "WRAPPER_UPDATES", ")", ":", "# workaround for http://bugs.python.org/issue3445", "assigned", "=", "tuple", "...
Patch two bugs in functools.update_wrapper.
[ "Patch", "two", "bugs", "in", "functools", ".", "update_wrapper", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/backports/functools_lru_cache.py#L11-L23
train
pypa/pipenv
pipenv/vendor/backports/functools_lru_cache.py
lru_cache
def lru_cache(maxsize=100, typed=False): """Least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated...
python
def lru_cache(maxsize=100, typed=False): """Least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated...
[ "def", "lru_cache", "(", "maxsize", "=", "100", ",", "typed", "=", "False", ")", ":", "# Users should only access the lru_cache through its public API:", "# cache_info, cache_clear, and f.__wrapped__", "# The internals of the lru_cache are encapsulated for thread safety and", "# ...
Least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct calls with distinct results. ...
[ "Least", "-", "recently", "-", "used", "cache", "decorator", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/backports/functools_lru_cache.py#L57-L184
train
pypa/pipenv
pipenv/vendor/first.py
first
def first(iterable, default=None, key=None): """ Return first element of `iterable` that evaluates true, else return None (or an optional default value). >>> first([0, False, None, [], (), 42]) 42 >>> first([0, False, None, [], ()]) is None True >>> first([0, False, None, [], ()], def...
python
def first(iterable, default=None, key=None): """ Return first element of `iterable` that evaluates true, else return None (or an optional default value). >>> first([0, False, None, [], (), 42]) 42 >>> first([0, False, None, [], ()]) is None True >>> first([0, False, None, [], ()], def...
[ "def", "first", "(", "iterable", ",", "default", "=", "None", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "for", "el", "in", "iterable", ":", "if", "el", ":", "return", "el", "else", ":", "for", "el", "in", "iterable", ":",...
Return first element of `iterable` that evaluates true, else return None (or an optional default value). >>> first([0, False, None, [], (), 42]) 42 >>> first([0, False, None, [], ()]) is None True >>> first([0, False, None, [], ()], default='ohai') 'ohai' >>> import re >>> m = fi...
[ "Return", "first", "element", "of", "iterable", "that", "evaluates", "true", "else", "return", "None", "(", "or", "an", "optional", "default", "value", ")", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/first.py#L42-L78
train
pypa/pipenv
pipenv/vendor/shellingham/posix/ps.py
get_process_mapping
def get_process_mapping(): """Try to look up the process tree via the output of `ps`. """ try: output = subprocess.check_output([ 'ps', '-ww', '-o', 'pid=', '-o', 'ppid=', '-o', 'args=', ]) except OSError as e: # Python 2-compatible FileNotFoundError. if e.errno !=...
python
def get_process_mapping(): """Try to look up the process tree via the output of `ps`. """ try: output = subprocess.check_output([ 'ps', '-ww', '-o', 'pid=', '-o', 'ppid=', '-o', 'args=', ]) except OSError as e: # Python 2-compatible FileNotFoundError. if e.errno !=...
[ "def", "get_process_mapping", "(", ")", ":", "try", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "'ps'", ",", "'-ww'", ",", "'-o'", ",", "'pid='", ",", "'-o'", ",", "'ppid='", ",", "'-o'", ",", "'args='", ",", "]", ")", "except", ...
Try to look up the process tree via the output of `ps`.
[ "Try", "to", "look", "up", "the", "process", "tree", "via", "the", "output", "of", "ps", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/posix/ps.py#L12-L45
train
pypa/pipenv
pipenv/vendor/jinja2/idtracking.py
FrameSymbolVisitor.visit_Name
def visit_Name(self, node, store_as_param=False, **kwargs): """All assignments to names go through this function.""" if store_as_param or node.ctx == 'param': self.symbols.declare_parameter(node.name) elif node.ctx == 'store': self.symbols.store(node.name) elif no...
python
def visit_Name(self, node, store_as_param=False, **kwargs): """All assignments to names go through this function.""" if store_as_param or node.ctx == 'param': self.symbols.declare_parameter(node.name) elif node.ctx == 'store': self.symbols.store(node.name) elif no...
[ "def", "visit_Name", "(", "self", ",", "node", ",", "store_as_param", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "store_as_param", "or", "node", ".", "ctx", "==", "'param'", ":", "self", ".", "symbols", ".", "declare_parameter", "(", "node", ...
All assignments to names go through this function.
[ "All", "assignments", "to", "names", "go", "through", "this", "function", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/idtracking.py#L209-L216
train
pypa/pipenv
pipenv/vendor/jinja2/idtracking.py
FrameSymbolVisitor.visit_Assign
def visit_Assign(self, node, **kwargs): """Visit assignments in the correct order.""" self.visit(node.node, **kwargs) self.visit(node.target, **kwargs)
python
def visit_Assign(self, node, **kwargs): """Visit assignments in the correct order.""" self.visit(node.node, **kwargs) self.visit(node.target, **kwargs)
[ "def", "visit_Assign", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "self", ".", "visit", "(", "node", ".", "node", ",", "*", "*", "kwargs", ")", "self", ".", "visit", "(", "node", ".", "target", ",", "*", "*", "kwargs", ")" ]
Visit assignments in the correct order.
[ "Visit", "assignments", "in", "the", "correct", "order", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/idtracking.py#L254-L257
train
pypa/pipenv
pipenv/vendor/attr/_compat.py
make_set_closure_cell
def make_set_closure_cell(): """ Moved into a function for testability. """ if PYPY: # pragma: no cover def set_closure_cell(cell, value): cell.__setstate__((value,)) else: try: ctypes = import_ctypes() set_closure_cell = ctypes.pythonapi.PyCel...
python
def make_set_closure_cell(): """ Moved into a function for testability. """ if PYPY: # pragma: no cover def set_closure_cell(cell, value): cell.__setstate__((value,)) else: try: ctypes = import_ctypes() set_closure_cell = ctypes.pythonapi.PyCel...
[ "def", "make_set_closure_cell", "(", ")", ":", "if", "PYPY", ":", "# pragma: no cover", "def", "set_closure_cell", "(", "cell", ",", "value", ")", ":", "cell", ".", "__setstate__", "(", "(", "value", ",", ")", ")", "else", ":", "try", ":", "ctypes", "=",...
Moved into a function for testability.
[ "Moved", "into", "a", "function", "for", "testability", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/attr/_compat.py#L136-L156
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn._spawn
def _spawn(self, command, args=[], preexec_fn=None, dimensions=None): '''This starts the given command in a child process. This does all the fork/exec type of stuff for a pty. This is called by __init__. If args is empty then command will be parsed (split on spaces) and args will be set ...
python
def _spawn(self, command, args=[], preexec_fn=None, dimensions=None): '''This starts the given command in a child process. This does all the fork/exec type of stuff for a pty. This is called by __init__. If args is empty then command will be parsed (split on spaces) and args will be set ...
[ "def", "_spawn", "(", "self", ",", "command", ",", "args", "=", "[", "]", ",", "preexec_fn", "=", "None", ",", "dimensions", "=", "None", ")", ":", "# The pid and child_fd of this object get set by this method.", "# Note that it is difficult for this method to fail.", "...
This starts the given command in a child process. This does all the fork/exec type of stuff for a pty. This is called by __init__. If args is empty then command will be parsed (split on spaces) and args will be set to parsed arguments.
[ "This", "starts", "the", "given", "command", "in", "a", "child", "process", ".", "This", "does", "all", "the", "fork", "/", "exec", "type", "of", "stuff", "for", "a", "pty", ".", "This", "is", "called", "by", "__init__", ".", "If", "args", "is", "emp...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L239-L310
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.close
def close(self, force=True): '''This closes the connection with the child application. Note that calling close() more than once is valid. This emulates standard Python behavior with files. Set force to True if you want to make sure that the child is terminated (SIGKILL is sent if the chi...
python
def close(self, force=True): '''This closes the connection with the child application. Note that calling close() more than once is valid. This emulates standard Python behavior with files. Set force to True if you want to make sure that the child is terminated (SIGKILL is sent if the chi...
[ "def", "close", "(", "self", ",", "force", "=", "True", ")", ":", "self", ".", "flush", "(", ")", "with", "_wrap_ptyprocess_err", "(", ")", ":", "# PtyProcessError may be raised if it is not possible to terminate", "# the child.", "self", ".", "ptyproc", ".", "clo...
This closes the connection with the child application. Note that calling close() more than once is valid. This emulates standard Python behavior with files. Set force to True if you want to make sure that the child is terminated (SIGKILL is sent if the child ignores SIGHUP and SIGINT).
[ "This", "closes", "the", "connection", "with", "the", "child", "application", ".", "Note", "that", "calling", "close", "()", "more", "than", "once", "is", "valid", ".", "This", "emulates", "standard", "Python", "behavior", "with", "files", ".", "Set", "force...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L316-L330
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.waitnoecho
def waitnoecho(self, timeout=-1): '''This waits until the terminal ECHO flag is set False. This returns True if the echo mode is off. This returns False if the ECHO flag was not set False before the timeout. This can be used to detect when the child is waiting for a password. Usually a c...
python
def waitnoecho(self, timeout=-1): '''This waits until the terminal ECHO flag is set False. This returns True if the echo mode is off. This returns False if the ECHO flag was not set False before the timeout. This can be used to detect when the child is waiting for a password. Usually a c...
[ "def", "waitnoecho", "(", "self", ",", "timeout", "=", "-", "1", ")", ":", "if", "timeout", "==", "-", "1", ":", "timeout", "=", "self", ".", "timeout", "if", "timeout", "is", "not", "None", ":", "end_time", "=", "time", ".", "time", "(", ")", "+...
This waits until the terminal ECHO flag is set False. This returns True if the echo mode is off. This returns False if the ECHO flag was not set False before the timeout. This can be used to detect when the child is waiting for a password. Usually a child application will turn off echo m...
[ "This", "waits", "until", "the", "terminal", "ECHO", "flag", "is", "set", "False", ".", "This", "returns", "True", "if", "the", "echo", "mode", "is", "off", ".", "This", "returns", "False", "if", "the", "ECHO", "flag", "was", "not", "set", "False", "be...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L343-L371
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.read_nonblocking
def read_nonblocking(self, size=1, timeout=-1): '''This reads at most size characters from the child application. It includes a timeout. If the read does not complete within the timeout period then a TIMEOUT exception is raised. If the end of file is read then an EOF exception will be ra...
python
def read_nonblocking(self, size=1, timeout=-1): '''This reads at most size characters from the child application. It includes a timeout. If the read does not complete within the timeout period then a TIMEOUT exception is raised. If the end of file is read then an EOF exception will be ra...
[ "def", "read_nonblocking", "(", "self", ",", "size", "=", "1", ",", "timeout", "=", "-", "1", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "'I/O operation on closed file.'", ")", "if", "timeout", "==", "-", "1", ":", "timeout",...
This reads at most size characters from the child application. It includes a timeout. If the read does not complete within the timeout period then a TIMEOUT exception is raised. If the end of file is read then an EOF exception will be raised. If a logfile is specified, a copy is written...
[ "This", "reads", "at", "most", "size", "characters", "from", "the", "child", "application", ".", "It", "includes", "a", "timeout", ".", "If", "the", "read", "does", "not", "complete", "within", "the", "timeout", "period", "then", "a", "TIMEOUT", "exception",...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L415-L487
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.send
def send(self, s): '''Sends string ``s`` to the child process, returning the number of bytes written. If a logfile is specified, a copy is written to that log. The default terminal input mode is canonical processing unless set otherwise by the child process. This allows backspac...
python
def send(self, s): '''Sends string ``s`` to the child process, returning the number of bytes written. If a logfile is specified, a copy is written to that log. The default terminal input mode is canonical processing unless set otherwise by the child process. This allows backspac...
[ "def", "send", "(", "self", ",", "s", ")", ":", "if", "self", ".", "delaybeforesend", "is", "not", "None", ":", "time", ".", "sleep", "(", "self", ".", "delaybeforesend", ")", "s", "=", "self", ".", "_coerce_send_string", "(", "s", ")", "self", ".", ...
Sends string ``s`` to the child process, returning the number of bytes written. If a logfile is specified, a copy is written to that log. The default terminal input mode is canonical processing unless set otherwise by the child process. This allows backspace and other line proce...
[ "Sends", "string", "s", "to", "the", "child", "process", "returning", "the", "number", "of", "bytes", "written", ".", "If", "a", "logfile", "is", "specified", "a", "copy", "is", "written", "to", "that", "log", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L504-L546
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.sendline
def sendline(self, s=''): '''Wraps send(), sending string ``s`` to child process, with ``os.linesep`` automatically appended. Returns number of bytes written. Only a limited number of bytes may be sent for each line in the default terminal mode, see docstring of :meth:`send`. ''...
python
def sendline(self, s=''): '''Wraps send(), sending string ``s`` to child process, with ``os.linesep`` automatically appended. Returns number of bytes written. Only a limited number of bytes may be sent for each line in the default terminal mode, see docstring of :meth:`send`. ''...
[ "def", "sendline", "(", "self", ",", "s", "=", "''", ")", ":", "s", "=", "self", ".", "_coerce_send_string", "(", "s", ")", "return", "self", ".", "send", "(", "s", "+", "self", ".", "linesep", ")" ]
Wraps send(), sending string ``s`` to child process, with ``os.linesep`` automatically appended. Returns number of bytes written. Only a limited number of bytes may be sent for each line in the default terminal mode, see docstring of :meth:`send`.
[ "Wraps", "send", "()", "sending", "string", "s", "to", "child", "process", "with", "os", ".", "linesep", "automatically", "appended", ".", "Returns", "number", "of", "bytes", "written", ".", "Only", "a", "limited", "number", "of", "bytes", "may", "be", "se...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L548-L555
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn._log_control
def _log_control(self, s): """Write control characters to the appropriate log files""" if self.encoding is not None: s = s.decode(self.encoding, 'replace') self._log(s, 'send')
python
def _log_control(self, s): """Write control characters to the appropriate log files""" if self.encoding is not None: s = s.decode(self.encoding, 'replace') self._log(s, 'send')
[ "def", "_log_control", "(", "self", ",", "s", ")", ":", "if", "self", ".", "encoding", "is", "not", "None", ":", "s", "=", "s", ".", "decode", "(", "self", ".", "encoding", ",", "'replace'", ")", "self", ".", "_log", "(", "s", ",", "'send'", ")" ...
Write control characters to the appropriate log files
[ "Write", "control", "characters", "to", "the", "appropriate", "log", "files" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L557-L561
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.sendcontrol
def sendcontrol(self, char): '''Helper method that wraps send() with mnemonic access for sending control character to the child (such as Ctrl-C or Ctrl-D). For example, to send Ctrl-G (ASCII 7, bell, '\a'):: child.sendcontrol('g') See also, sendintr() and sendeof(). ...
python
def sendcontrol(self, char): '''Helper method that wraps send() with mnemonic access for sending control character to the child (such as Ctrl-C or Ctrl-D). For example, to send Ctrl-G (ASCII 7, bell, '\a'):: child.sendcontrol('g') See also, sendintr() and sendeof(). ...
[ "def", "sendcontrol", "(", "self", ",", "char", ")", ":", "n", ",", "byte", "=", "self", ".", "ptyproc", ".", "sendcontrol", "(", "char", ")", "self", ".", "_log_control", "(", "byte", ")", "return", "n" ]
Helper method that wraps send() with mnemonic access for sending control character to the child (such as Ctrl-C or Ctrl-D). For example, to send Ctrl-G (ASCII 7, bell, '\a'):: child.sendcontrol('g') See also, sendintr() and sendeof().
[ "Helper", "method", "that", "wraps", "send", "()", "with", "mnemonic", "access", "for", "sending", "control", "character", "to", "the", "child", "(", "such", "as", "Ctrl", "-", "C", "or", "Ctrl", "-", "D", ")", ".", "For", "example", "to", "send", "Ctr...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L563-L574
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.sendeof
def sendeof(self): '''This sends an EOF to the child. This sends a character which causes the pending parent output buffer to be sent to the waiting child program without waiting for end-of-line. If it is the first character of the line, the read() in the user program returns 0, which si...
python
def sendeof(self): '''This sends an EOF to the child. This sends a character which causes the pending parent output buffer to be sent to the waiting child program without waiting for end-of-line. If it is the first character of the line, the read() in the user program returns 0, which si...
[ "def", "sendeof", "(", "self", ")", ":", "n", ",", "byte", "=", "self", ".", "ptyproc", ".", "sendeof", "(", ")", "self", ".", "_log_control", "(", "byte", ")" ]
This sends an EOF to the child. This sends a character which causes the pending parent output buffer to be sent to the waiting child program without waiting for end-of-line. If it is the first character of the line, the read() in the user program returns 0, which signifies end-of-file. T...
[ "This", "sends", "an", "EOF", "to", "the", "child", ".", "This", "sends", "a", "character", "which", "causes", "the", "pending", "parent", "output", "buffer", "to", "be", "sent", "to", "the", "waiting", "child", "program", "without", "waiting", "for", "end...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L576-L587
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.sendintr
def sendintr(self): '''This sends a SIGINT to the child. It does not require the SIGINT to be the first character on a line. ''' n, byte = self.ptyproc.sendintr() self._log_control(byte)
python
def sendintr(self): '''This sends a SIGINT to the child. It does not require the SIGINT to be the first character on a line. ''' n, byte = self.ptyproc.sendintr() self._log_control(byte)
[ "def", "sendintr", "(", "self", ")", ":", "n", ",", "byte", "=", "self", ".", "ptyproc", ".", "sendintr", "(", ")", "self", ".", "_log_control", "(", "byte", ")" ]
This sends a SIGINT to the child. It does not require the SIGINT to be the first character on a line.
[ "This", "sends", "a", "SIGINT", "to", "the", "child", ".", "It", "does", "not", "require", "the", "SIGINT", "to", "be", "the", "first", "character", "on", "a", "line", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L589-L594
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.wait
def wait(self): '''This waits until the child exits. This is a blocking call. This will not read any data from the child, so this will block forever if the child has unread output and has terminated. In other words, the child may have printed output then called exit(), but, the child is ...
python
def wait(self): '''This waits until the child exits. This is a blocking call. This will not read any data from the child, so this will block forever if the child has unread output and has terminated. In other words, the child may have printed output then called exit(), but, the child is ...
[ "def", "wait", "(", "self", ")", ":", "ptyproc", "=", "self", ".", "ptyproc", "with", "_wrap_ptyprocess_err", "(", ")", ":", "# exception may occur if \"Is some other process attempting", "# \"job control with our child pid?\"", "exitstatus", "=", "ptyproc", ".", "wait", ...
This waits until the child exits. This is a blocking call. This will not read any data from the child, so this will block forever if the child has unread output and has terminated. In other words, the child may have printed output then called exit(), but, the child is technically still a...
[ "This", "waits", "until", "the", "child", "exits", ".", "This", "is", "a", "blocking", "call", ".", "This", "will", "not", "read", "any", "data", "from", "the", "child", "so", "this", "will", "block", "forever", "if", "the", "child", "has", "unread", "...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L649-L671
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.isalive
def isalive(self): '''This tests if the child process is running or not. This is non-blocking. If the child was terminated then this will read the exitstatus or signalstatus of the child. This returns True if the child process appears to be running or False if not. It can take literally ...
python
def isalive(self): '''This tests if the child process is running or not. This is non-blocking. If the child was terminated then this will read the exitstatus or signalstatus of the child. This returns True if the child process appears to be running or False if not. It can take literally ...
[ "def", "isalive", "(", "self", ")", ":", "ptyproc", "=", "self", ".", "ptyproc", "with", "_wrap_ptyprocess_err", "(", ")", ":", "alive", "=", "ptyproc", ".", "isalive", "(", ")", "if", "not", "alive", ":", "self", ".", "status", "=", "ptyproc", ".", ...
This tests if the child process is running or not. This is non-blocking. If the child was terminated then this will read the exitstatus or signalstatus of the child. This returns True if the child process appears to be running or False if not. It can take literally SECONDS for Solaris to...
[ "This", "tests", "if", "the", "child", "process", "is", "running", "or", "not", ".", "This", "is", "non", "-", "blocking", ".", "If", "the", "child", "was", "terminated", "then", "this", "will", "read", "the", "exitstatus", "or", "signalstatus", "of", "t...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L673-L690
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.interact
def interact(self, escape_character=chr(29), input_filter=None, output_filter=None): '''This gives control of the child process to the interactive user (the human at the keyboard). Keystrokes are sent to the child process, and the stdout and stderr output of the child process is pri...
python
def interact(self, escape_character=chr(29), input_filter=None, output_filter=None): '''This gives control of the child process to the interactive user (the human at the keyboard). Keystrokes are sent to the child process, and the stdout and stderr output of the child process is pri...
[ "def", "interact", "(", "self", ",", "escape_character", "=", "chr", "(", "29", ")", ",", "input_filter", "=", "None", ",", "output_filter", "=", "None", ")", ":", "# Flush the buffer.", "self", ".", "write_to_stdout", "(", "self", ".", "buffer", ")", "sel...
This gives control of the child process to the interactive user (the human at the keyboard). Keystrokes are sent to the child process, and the stdout and stderr output of the child process is printed. This simply echos the child stdout and child stderr to the real stdout and it echos the...
[ "This", "gives", "control", "of", "the", "child", "process", "to", "the", "interactive", "user", "(", "the", "human", "at", "the", "keyboard", ")", ".", "Keystrokes", "are", "sent", "to", "the", "child", "process", "and", "the", "stdout", "and", "stderr", ...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L716-L768
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.__interact_writen
def __interact_writen(self, fd, data): '''This is used by the interact() method. ''' while data != b'' and self.isalive(): n = os.write(fd, data) data = data[n:]
python
def __interact_writen(self, fd, data): '''This is used by the interact() method. ''' while data != b'' and self.isalive(): n = os.write(fd, data) data = data[n:]
[ "def", "__interact_writen", "(", "self", ",", "fd", ",", "data", ")", ":", "while", "data", "!=", "b''", "and", "self", ".", "isalive", "(", ")", ":", "n", "=", "os", ".", "write", "(", "fd", ",", "data", ")", "data", "=", "data", "[", "n", ":"...
This is used by the interact() method.
[ "This", "is", "used", "by", "the", "interact", "()", "method", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L770-L776
train
pypa/pipenv
pipenv/vendor/pexpect/pty_spawn.py
spawn.__interact_copy
def __interact_copy( self, escape_character=None, input_filter=None, output_filter=None ): '''This is used by the interact() method. ''' while self.isalive(): if self.use_poll: r = poll_ignore_interrupts([self.child_fd, self.STDIN_FILENO]) el...
python
def __interact_copy( self, escape_character=None, input_filter=None, output_filter=None ): '''This is used by the interact() method. ''' while self.isalive(): if self.use_poll: r = poll_ignore_interrupts([self.child_fd, self.STDIN_FILENO]) el...
[ "def", "__interact_copy", "(", "self", ",", "escape_character", "=", "None", ",", "input_filter", "=", "None", ",", "output_filter", "=", "None", ")", ":", "while", "self", ".", "isalive", "(", ")", ":", "if", "self", ".", "use_poll", ":", "r", "=", "p...
This is used by the interact() method.
[ "This", "is", "used", "by", "the", "interact", "()", "method", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L784-L827
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
extras_to_string
def extras_to_string(extras): # type: (Iterable[S]) -> S """Turn a list of extras into a string""" if isinstance(extras, six.string_types): if extras.startswith("["): return extras else: extras = [extras] if not extras: return "" return "[{0}]".format(...
python
def extras_to_string(extras): # type: (Iterable[S]) -> S """Turn a list of extras into a string""" if isinstance(extras, six.string_types): if extras.startswith("["): return extras else: extras = [extras] if not extras: return "" return "[{0}]".format(...
[ "def", "extras_to_string", "(", "extras", ")", ":", "# type: (Iterable[S]) -> S", "if", "isinstance", "(", "extras", ",", "six", ".", "string_types", ")", ":", "if", "extras", ".", "startswith", "(", "\"[\"", ")", ":", "return", "extras", "else", ":", "extra...
Turn a list of extras into a string
[ "Turn", "a", "list", "of", "extras", "into", "a", "string" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L143-L153
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
parse_extras
def parse_extras(extras_str): # type: (AnyStr) -> List[AnyStr] """ Turn a string of extras into a parsed extras list """ from pkg_resources import Requirement extras = Requirement.parse("fakepkg{0}".format(extras_to_string(extras_str))).extras return sorted(dedup([extra.lower() for extra i...
python
def parse_extras(extras_str): # type: (AnyStr) -> List[AnyStr] """ Turn a string of extras into a parsed extras list """ from pkg_resources import Requirement extras = Requirement.parse("fakepkg{0}".format(extras_to_string(extras_str))).extras return sorted(dedup([extra.lower() for extra i...
[ "def", "parse_extras", "(", "extras_str", ")", ":", "# type: (AnyStr) -> List[AnyStr]", "from", "pkg_resources", "import", "Requirement", "extras", "=", "Requirement", ".", "parse", "(", "\"fakepkg{0}\"", ".", "format", "(", "extras_to_string", "(", "extras_str", ")",...
Turn a string of extras into a parsed extras list
[ "Turn", "a", "string", "of", "extras", "into", "a", "parsed", "extras", "list" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L156-L165
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
specs_to_string
def specs_to_string(specs): # type: (List[Union[STRING_TYPE, Specifier]]) -> AnyStr """ Turn a list of specifier tuples into a string """ if specs: if isinstance(specs, six.string_types): return specs try: extras = ",".join(["".join(spec) for spec in specs]) ...
python
def specs_to_string(specs): # type: (List[Union[STRING_TYPE, Specifier]]) -> AnyStr """ Turn a list of specifier tuples into a string """ if specs: if isinstance(specs, six.string_types): return specs try: extras = ",".join(["".join(spec) for spec in specs]) ...
[ "def", "specs_to_string", "(", "specs", ")", ":", "# type: (List[Union[STRING_TYPE, Specifier]]) -> AnyStr", "if", "specs", ":", "if", "isinstance", "(", "specs", ",", "six", ".", "string_types", ")", ":", "return", "specs", "try", ":", "extras", "=", "\",\"", "...
Turn a list of specifier tuples into a string
[ "Turn", "a", "list", "of", "specifier", "tuples", "into", "a", "string" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L168-L182
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
convert_direct_url_to_url
def convert_direct_url_to_url(direct_url): # type: (AnyStr) -> AnyStr """ Given a direct url as defined by *PEP 508*, convert to a :class:`~pip_shims.shims.Link` compatible URL by moving the name and extras into an **egg_fragment**. :param str direct_url: A pep-508 compliant direct url. :return...
python
def convert_direct_url_to_url(direct_url): # type: (AnyStr) -> AnyStr """ Given a direct url as defined by *PEP 508*, convert to a :class:`~pip_shims.shims.Link` compatible URL by moving the name and extras into an **egg_fragment**. :param str direct_url: A pep-508 compliant direct url. :return...
[ "def", "convert_direct_url_to_url", "(", "direct_url", ")", ":", "# type: (AnyStr) -> AnyStr", "direct_match", "=", "DIRECT_URL_RE", ".", "match", "(", "direct_url", ")", "# type: Optional[Match]", "if", "direct_match", "is", "None", ":", "url_match", "=", "URL_RE", "...
Given a direct url as defined by *PEP 508*, convert to a :class:`~pip_shims.shims.Link` compatible URL by moving the name and extras into an **egg_fragment**. :param str direct_url: A pep-508 compliant direct url. :return: A reformatted URL for use with Link objects and :class:`~pip_shims.shims.InstallRequ...
[ "Given", "a", "direct", "url", "as", "defined", "by", "*", "PEP", "508", "*", "convert", "to", "a", ":", "class", ":", "~pip_shims", ".", "shims", ".", "Link", "compatible", "URL", "by", "moving", "the", "name", "and", "extras", "into", "an", "**", "...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L213-L250
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
convert_url_to_direct_url
def convert_url_to_direct_url(url, name=None): # type: (AnyStr, Optional[AnyStr]) -> AnyStr """ Given a :class:`~pip_shims.shims.Link` compatible URL, convert to a direct url as defined by *PEP 508* by extracting the name and extras from the **egg_fragment**. :param AnyStr url: A :class:`~pip_shims...
python
def convert_url_to_direct_url(url, name=None): # type: (AnyStr, Optional[AnyStr]) -> AnyStr """ Given a :class:`~pip_shims.shims.Link` compatible URL, convert to a direct url as defined by *PEP 508* by extracting the name and extras from the **egg_fragment**. :param AnyStr url: A :class:`~pip_shims...
[ "def", "convert_url_to_direct_url", "(", "url", ",", "name", "=", "None", ")", ":", "# type: (AnyStr, Optional[AnyStr]) -> AnyStr", "if", "not", "isinstance", "(", "url", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "\"Expected a string to c...
Given a :class:`~pip_shims.shims.Link` compatible URL, convert to a direct url as defined by *PEP 508* by extracting the name and extras from the **egg_fragment**. :param AnyStr url: A :class:`~pip_shims.shims.InstallRequirement` compliant URL. :param Optiona[AnyStr] name: A name to use in case the supplie...
[ "Given", "a", ":", "class", ":", "~pip_shims", ".", "shims", ".", "Link", "compatible", "URL", "convert", "to", "a", "direct", "url", "as", "defined", "by", "*", "PEP", "508", "*", "by", "extracting", "the", "name", "and", "extras", "from", "the", "**"...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L253-L298
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
strip_extras_markers_from_requirement
def strip_extras_markers_from_requirement(req): # type: (TRequirement) -> TRequirement """ Given a :class:`~packaging.requirements.Requirement` instance with markers defining *extra == 'name'*, strip out the extras from the markers and return the cleaned requirement :param PackagingRequirement ...
python
def strip_extras_markers_from_requirement(req): # type: (TRequirement) -> TRequirement """ Given a :class:`~packaging.requirements.Requirement` instance with markers defining *extra == 'name'*, strip out the extras from the markers and return the cleaned requirement :param PackagingRequirement ...
[ "def", "strip_extras_markers_from_requirement", "(", "req", ")", ":", "# type: (TRequirement) -> TRequirement", "if", "req", "is", "None", ":", "raise", "TypeError", "(", "\"Must pass in a valid requirement, received {0!r}\"", ".", "format", "(", "req", ")", ")", "if", ...
Given a :class:`~packaging.requirements.Requirement` instance with markers defining *extra == 'name'*, strip out the extras from the markers and return the cleaned requirement :param PackagingRequirement req: A packaging requirement to clean :return: A cleaned requirement :rtype: PackagingRequireme...
[ "Given", "a", ":", "class", ":", "~packaging", ".", "requirements", ".", "Requirement", "instance", "with", "markers", "defining", "*", "extra", "==", "name", "*", "strip", "out", "the", "extras", "from", "the", "markers", "and", "return", "the", "cleaned", ...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L316-L336
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
get_pyproject
def get_pyproject(path): # type: (Union[STRING_TYPE, Path]) -> Optional[Tuple[List[STRING_TYPE], STRING_TYPE]] """ Given a base path, look for the corresponding ``pyproject.toml`` file and return its build_requires and build_backend. :param AnyStr path: The root path of the project, should be a dir...
python
def get_pyproject(path): # type: (Union[STRING_TYPE, Path]) -> Optional[Tuple[List[STRING_TYPE], STRING_TYPE]] """ Given a base path, look for the corresponding ``pyproject.toml`` file and return its build_requires and build_backend. :param AnyStr path: The root path of the project, should be a dir...
[ "def", "get_pyproject", "(", "path", ")", ":", "# type: (Union[STRING_TYPE, Path]) -> Optional[Tuple[List[STRING_TYPE], STRING_TYPE]]", "if", "not", "path", ":", "return", "from", "vistir", ".", "compat", "import", "Path", "if", "not", "isinstance", "(", "path", ",", ...
Given a base path, look for the corresponding ``pyproject.toml`` file and return its build_requires and build_backend. :param AnyStr path: The root path of the project, should be a directory (will be truncated) :return: A 2 tuple of build requirements and the build backend :rtype: Optional[Tuple[List[A...
[ "Given", "a", "base", "path", "look", "for", "the", "corresponding", "pyproject", ".", "toml", "file", "and", "return", "its", "build_requires", "and", "build_backend", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L382-L425
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
split_markers_from_line
def split_markers_from_line(line): # type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]] """Split markers from a dependency""" if not any(line.startswith(uri_prefix) for uri_prefix in SCHEME_LIST): marker_sep = ";" else: marker_sep = "; " markers = None if marker_sep in line: ...
python
def split_markers_from_line(line): # type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]] """Split markers from a dependency""" if not any(line.startswith(uri_prefix) for uri_prefix in SCHEME_LIST): marker_sep = ";" else: marker_sep = "; " markers = None if marker_sep in line: ...
[ "def", "split_markers_from_line", "(", "line", ")", ":", "# type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]]", "if", "not", "any", "(", "line", ".", "startswith", "(", "uri_prefix", ")", "for", "uri_prefix", "in", "SCHEME_LIST", ")", ":", "marker_sep", "=", "\";\""...
Split markers from a dependency
[ "Split", "markers", "from", "a", "dependency" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L428-L439
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
split_vcs_method_from_uri
def split_vcs_method_from_uri(uri): # type: (AnyStr) -> Tuple[Optional[STRING_TYPE], STRING_TYPE] """Split a vcs+uri formatted uri into (vcs, uri)""" vcs_start = "{0}+" vcs = None # type: Optional[STRING_TYPE] vcs = first([vcs for vcs in VCS_LIST if uri.startswith(vcs_start.format(vcs))]) if vc...
python
def split_vcs_method_from_uri(uri): # type: (AnyStr) -> Tuple[Optional[STRING_TYPE], STRING_TYPE] """Split a vcs+uri formatted uri into (vcs, uri)""" vcs_start = "{0}+" vcs = None # type: Optional[STRING_TYPE] vcs = first([vcs for vcs in VCS_LIST if uri.startswith(vcs_start.format(vcs))]) if vc...
[ "def", "split_vcs_method_from_uri", "(", "uri", ")", ":", "# type: (AnyStr) -> Tuple[Optional[STRING_TYPE], STRING_TYPE]", "vcs_start", "=", "\"{0}+\"", "vcs", "=", "None", "# type: Optional[STRING_TYPE]", "vcs", "=", "first", "(", "[", "vcs", "for", "vcs", "in", "VCS_L...
Split a vcs+uri formatted uri into (vcs, uri)
[ "Split", "a", "vcs", "+", "uri", "formatted", "uri", "into", "(", "vcs", "uri", ")" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L442-L450
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
split_ref_from_uri
def split_ref_from_uri(uri): # type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]] """ Given a path or URI, check for a ref and split it from the path if it is present, returning a tuple of the original input and the ref or None. :param AnyStr uri: The path or URI to split :returns: A 2-tuple of ...
python
def split_ref_from_uri(uri): # type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]] """ Given a path or URI, check for a ref and split it from the path if it is present, returning a tuple of the original input and the ref or None. :param AnyStr uri: The path or URI to split :returns: A 2-tuple of ...
[ "def", "split_ref_from_uri", "(", "uri", ")", ":", "# type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]]", "if", "not", "isinstance", "(", "uri", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "\"Expected a string, received {0!r}\"", ".", "format",...
Given a path or URI, check for a ref and split it from the path if it is present, returning a tuple of the original input and the ref or None. :param AnyStr uri: The path or URI to split :returns: A 2-tuple of the path or URI and the ref :rtype: Tuple[AnyStr, Optional[AnyStr]]
[ "Given", "a", "path", "or", "URI", "check", "for", "a", "ref", "and", "split", "it", "from", "the", "path", "if", "it", "is", "present", "returning", "a", "tuple", "of", "the", "original", "input", "and", "the", "ref", "or", "None", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L453-L471
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
key_from_ireq
def key_from_ireq(ireq): """Get a standardized key for an InstallRequirement.""" if ireq.req is None and ireq.link is not None: return str(ireq.link) else: return key_from_req(ireq.req)
python
def key_from_ireq(ireq): """Get a standardized key for an InstallRequirement.""" if ireq.req is None and ireq.link is not None: return str(ireq.link) else: return key_from_req(ireq.req)
[ "def", "key_from_ireq", "(", "ireq", ")", ":", "if", "ireq", ".", "req", "is", "None", "and", "ireq", ".", "link", "is", "not", "None", ":", "return", "str", "(", "ireq", ".", "link", ")", "else", ":", "return", "key_from_req", "(", "ireq", ".", "r...
Get a standardized key for an InstallRequirement.
[ "Get", "a", "standardized", "key", "for", "an", "InstallRequirement", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L500-L505
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
key_from_req
def key_from_req(req): """Get an all-lowercase version of the requirement's name.""" if hasattr(req, "key"): # from pkg_resources, such as installed dists for pip-sync key = req.key else: # from packaging, such as install requirements from requirements.txt key = req.name ...
python
def key_from_req(req): """Get an all-lowercase version of the requirement's name.""" if hasattr(req, "key"): # from pkg_resources, such as installed dists for pip-sync key = req.key else: # from packaging, such as install requirements from requirements.txt key = req.name ...
[ "def", "key_from_req", "(", "req", ")", ":", "if", "hasattr", "(", "req", ",", "\"key\"", ")", ":", "# from pkg_resources, such as installed dists for pip-sync", "key", "=", "req", ".", "key", "else", ":", "# from packaging, such as install requirements from requirements....
Get an all-lowercase version of the requirement's name.
[ "Get", "an", "all", "-", "lowercase", "version", "of", "the", "requirement", "s", "name", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L508-L518
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
_requirement_to_str_lowercase_name
def _requirement_to_str_lowercase_name(requirement): """ Formats a packaging.requirements.Requirement with a lowercase name. This is simply a copy of https://github.com/pypa/packaging/blob/16.8/packaging/requirements.py#L109-L124 modified to lowercase the dependency name. Previously, we were i...
python
def _requirement_to_str_lowercase_name(requirement): """ Formats a packaging.requirements.Requirement with a lowercase name. This is simply a copy of https://github.com/pypa/packaging/blob/16.8/packaging/requirements.py#L109-L124 modified to lowercase the dependency name. Previously, we were i...
[ "def", "_requirement_to_str_lowercase_name", "(", "requirement", ")", ":", "parts", "=", "[", "requirement", ".", "name", ".", "lower", "(", ")", "]", "if", "requirement", ".", "extras", ":", "parts", ".", "append", "(", "\"[{0}]\"", ".", "format", "(", "\...
Formats a packaging.requirements.Requirement with a lowercase name. This is simply a copy of https://github.com/pypa/packaging/blob/16.8/packaging/requirements.py#L109-L124 modified to lowercase the dependency name. Previously, we were invoking the original Requirement.__str__ method and lower-cas...
[ "Formats", "a", "packaging", ".", "requirements", ".", "Requirement", "with", "a", "lowercase", "name", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L521-L549
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
format_requirement
def format_requirement(ireq): """ Generic formatter for pretty printing InstallRequirements to the terminal in a less verbose way than using its `__str__` method. """ if ireq.editable: line = "-e {}".format(ireq.link) else: line = _requirement_to_str_lowercase_name(ireq.req) ...
python
def format_requirement(ireq): """ Generic formatter for pretty printing InstallRequirements to the terminal in a less verbose way than using its `__str__` method. """ if ireq.editable: line = "-e {}".format(ireq.link) else: line = _requirement_to_str_lowercase_name(ireq.req) ...
[ "def", "format_requirement", "(", "ireq", ")", ":", "if", "ireq", ".", "editable", ":", "line", "=", "\"-e {}\"", ".", "format", "(", "ireq", ".", "link", ")", "else", ":", "line", "=", "_requirement_to_str_lowercase_name", "(", "ireq", ".", "req", ")", ...
Generic formatter for pretty printing InstallRequirements to the terminal in a less verbose way than using its `__str__` method.
[ "Generic", "formatter", "for", "pretty", "printing", "InstallRequirements", "to", "the", "terminal", "in", "a", "less", "verbose", "way", "than", "using", "its", "__str__", "method", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L552-L571
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
format_specifier
def format_specifier(ireq): """ Generic formatter for pretty printing the specifier part of InstallRequirements to the terminal. """ # TODO: Ideally, this is carried over to the pip library itself specs = ireq.specifier._specs if ireq.req is not None else [] specs = sorted(specs, key=lambda ...
python
def format_specifier(ireq): """ Generic formatter for pretty printing the specifier part of InstallRequirements to the terminal. """ # TODO: Ideally, this is carried over to the pip library itself specs = ireq.specifier._specs if ireq.req is not None else [] specs = sorted(specs, key=lambda ...
[ "def", "format_specifier", "(", "ireq", ")", ":", "# TODO: Ideally, this is carried over to the pip library itself", "specs", "=", "ireq", ".", "specifier", ".", "_specs", "if", "ireq", ".", "req", "is", "not", "None", "else", "[", "]", "specs", "=", "sorted", "...
Generic formatter for pretty printing the specifier part of InstallRequirements to the terminal.
[ "Generic", "formatter", "for", "pretty", "printing", "the", "specifier", "part", "of", "InstallRequirements", "to", "the", "terminal", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L574-L582
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
as_tuple
def as_tuple(ireq): """ Pulls out the (name: str, version:str, extras:(str)) tuple from the pinned InstallRequirement. """ if not is_pinned_requirement(ireq): raise TypeError("Expected a pinned InstallRequirement, got {}".format(ireq)) name = key_from_req(ireq.req) version = first(ireq...
python
def as_tuple(ireq): """ Pulls out the (name: str, version:str, extras:(str)) tuple from the pinned InstallRequirement. """ if not is_pinned_requirement(ireq): raise TypeError("Expected a pinned InstallRequirement, got {}".format(ireq)) name = key_from_req(ireq.req) version = first(ireq...
[ "def", "as_tuple", "(", "ireq", ")", ":", "if", "not", "is_pinned_requirement", "(", "ireq", ")", ":", "raise", "TypeError", "(", "\"Expected a pinned InstallRequirement, got {}\"", ".", "format", "(", "ireq", ")", ")", "name", "=", "key_from_req", "(", "ireq", ...
Pulls out the (name: str, version:str, extras:(str)) tuple from the pinned InstallRequirement.
[ "Pulls", "out", "the", "(", "name", ":", "str", "version", ":", "str", "extras", ":", "(", "str", "))", "tuple", "from", "the", "pinned", "InstallRequirement", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L650-L661
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
full_groupby
def full_groupby(iterable, key=None): """ Like groupby(), but sorts the input on the group key first. """ return groupby(sorted(iterable, key=key), key=key)
python
def full_groupby(iterable, key=None): """ Like groupby(), but sorts the input on the group key first. """ return groupby(sorted(iterable, key=key), key=key)
[ "def", "full_groupby", "(", "iterable", ",", "key", "=", "None", ")", ":", "return", "groupby", "(", "sorted", "(", "iterable", ",", "key", "=", "key", ")", ",", "key", "=", "key", ")" ]
Like groupby(), but sorts the input on the group key first.
[ "Like", "groupby", "()", "but", "sorts", "the", "input", "on", "the", "group", "key", "first", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L664-L669
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
lookup_table
def lookup_table(values, key=None, keyval=None, unique=False, use_lists=False): """ Builds a dict-based lookup table (index) elegantly. Supports building normal and unique lookup tables. For example: >>> assert lookup_table( ... ['foo', 'bar', 'baz', 'qux', 'quux'], lambda s: s[0]) == { ....
python
def lookup_table(values, key=None, keyval=None, unique=False, use_lists=False): """ Builds a dict-based lookup table (index) elegantly. Supports building normal and unique lookup tables. For example: >>> assert lookup_table( ... ['foo', 'bar', 'baz', 'qux', 'quux'], lambda s: s[0]) == { ....
[ "def", "lookup_table", "(", "values", ",", "key", "=", "None", ",", "keyval", "=", "None", ",", "unique", "=", "False", ",", "use_lists", "=", "False", ")", ":", "if", "keyval", "is", "None", ":", "if", "key", "is", "None", ":", "keyval", "=", "lam...
Builds a dict-based lookup table (index) elegantly. Supports building normal and unique lookup tables. For example: >>> assert lookup_table( ... ['foo', 'bar', 'baz', 'qux', 'quux'], lambda s: s[0]) == { ... 'b': {'bar', 'baz'}, ... 'f': {'foo'}, ... 'q': {'quux', 'qux'} ....
[ "Builds", "a", "dict", "-", "based", "lookup", "table", "(", "index", ")", "elegantly", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L680-L739
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
make_install_requirement
def make_install_requirement(name, version, extras, markers, constraint=False): """ Generates an :class:`~pip._internal.req.req_install.InstallRequirement`. Create an InstallRequirement from the supplied metadata. :param name: The requirement's name. :type name: str :param version: The require...
python
def make_install_requirement(name, version, extras, markers, constraint=False): """ Generates an :class:`~pip._internal.req.req_install.InstallRequirement`. Create an InstallRequirement from the supplied metadata. :param name: The requirement's name. :type name: str :param version: The require...
[ "def", "make_install_requirement", "(", "name", ",", "version", ",", "extras", ",", "markers", ",", "constraint", "=", "False", ")", ":", "# If no extras are specified, the extras string is blank", "from", "pip_shims", ".", "shims", "import", "install_req_from_line", "e...
Generates an :class:`~pip._internal.req.req_install.InstallRequirement`. Create an InstallRequirement from the supplied metadata. :param name: The requirement's name. :type name: str :param version: The requirement version (must be pinned). :type version: str. :param extras: The desired extras...
[ "Generates", "an", ":", "class", ":", "~pip", ".", "_internal", ".", "req", ".", "req_install", ".", "InstallRequirement", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L752-L788
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
clean_requires_python
def clean_requires_python(candidates): """Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.""" all_candidates = [] sys_version = ".".join(map(str, sys.version_info[:3])) from packaging.version import parse as parse_version py_version = parse_version...
python
def clean_requires_python(candidates): """Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.""" all_candidates = [] sys_version = ".".join(map(str, sys.version_info[:3])) from packaging.version import parse as parse_version py_version = parse_version...
[ "def", "clean_requires_python", "(", "candidates", ")", ":", "all_candidates", "=", "[", "]", "sys_version", "=", "\".\"", ".", "join", "(", "map", "(", "str", ",", "sys", ".", "version_info", "[", ":", "3", "]", ")", ")", "from", "packaging", ".", "ve...
Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.
[ "Get", "a", "cleaned", "list", "of", "all", "the", "candidates", "with", "valid", "specifiers", "in", "the", "requires_python", "attributes", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L803-L828
train
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
get_name_variants
def get_name_variants(pkg): # type: (STRING_TYPE) -> Set[STRING_TYPE] """ Given a packager name, get the variants of its name for both the canonicalized and "safe" forms. :param AnyStr pkg: The package to lookup :returns: A list of names. :rtype: Set """ if not isinstance(pkg, six....
python
def get_name_variants(pkg): # type: (STRING_TYPE) -> Set[STRING_TYPE] """ Given a packager name, get the variants of its name for both the canonicalized and "safe" forms. :param AnyStr pkg: The package to lookup :returns: A list of names. :rtype: Set """ if not isinstance(pkg, six....
[ "def", "get_name_variants", "(", "pkg", ")", ":", "# type: (STRING_TYPE) -> Set[STRING_TYPE]", "if", "not", "isinstance", "(", "pkg", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "\"must provide a string to derive package names\"", ")", "from", ...
Given a packager name, get the variants of its name for both the canonicalized and "safe" forms. :param AnyStr pkg: The package to lookup :returns: A list of names. :rtype: Set
[ "Given", "a", "packager", "name", "get", "the", "variants", "of", "its", "name", "for", "both", "the", "canonicalized", "and", "safe", "forms", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L870-L888
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
_best_version
def _best_version(fields): """Detect the best version depending on the fields used.""" def _has_marker(keys, markers): for marker in markers: if marker in keys: return True return False keys = [] for key, value in fields.items(): if value in ([], 'UNK...
python
def _best_version(fields): """Detect the best version depending on the fields used.""" def _has_marker(keys, markers): for marker in markers: if marker in keys: return True return False keys = [] for key, value in fields.items(): if value in ([], 'UNK...
[ "def", "_best_version", "(", "fields", ")", ":", "def", "_has_marker", "(", "keys", ",", "markers", ")", ":", "for", "marker", "in", "markers", ":", "if", "marker", "in", "keys", ":", "return", "True", "return", "False", "keys", "=", "[", "]", "for", ...
Detect the best version depending on the fields used.
[ "Detect", "the", "best", "version", "depending", "on", "the", "fields", "used", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L124-L193
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
_get_name_and_version
def _get_name_and_version(name, version, for_filename=False): """Return the distribution name with version. If for_filename is true, return a filename-escaped form.""" if for_filename: # For both name and version any runs of non-alphanumeric or '.' # characters are replaced with a single '-...
python
def _get_name_and_version(name, version, for_filename=False): """Return the distribution name with version. If for_filename is true, return a filename-escaped form.""" if for_filename: # For both name and version any runs of non-alphanumeric or '.' # characters are replaced with a single '-...
[ "def", "_get_name_and_version", "(", "name", ",", "version", ",", "for_filename", "=", "False", ")", ":", "if", "for_filename", ":", "# For both name and version any runs of non-alphanumeric or '.'", "# characters are replaced with a single '-'. Additionally any", "# spaces in the...
Return the distribution name with version. If for_filename is true, return a filename-escaped form.
[ "Return", "the", "distribution", "name", "with", "version", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L247-L257
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.read
def read(self, filepath): """Read the metadata values from a file path.""" fp = codecs.open(filepath, 'r', encoding='utf-8') try: self.read_file(fp) finally: fp.close()
python
def read(self, filepath): """Read the metadata values from a file path.""" fp = codecs.open(filepath, 'r', encoding='utf-8') try: self.read_file(fp) finally: fp.close()
[ "def", "read", "(", "self", ",", "filepath", ")", ":", "fp", "=", "codecs", ".", "open", "(", "filepath", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "try", ":", "self", ".", "read_file", "(", "fp", ")", "finally", ":", "fp", ".", "close", ...
Read the metadata values from a file path.
[ "Read", "the", "metadata", "values", "from", "a", "file", "path", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L354-L360
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.write
def write(self, filepath, skip_unknown=False): """Write the metadata fields to filepath.""" fp = codecs.open(filepath, 'w', encoding='utf-8') try: self.write_file(fp, skip_unknown) finally: fp.close()
python
def write(self, filepath, skip_unknown=False): """Write the metadata fields to filepath.""" fp = codecs.open(filepath, 'w', encoding='utf-8') try: self.write_file(fp, skip_unknown) finally: fp.close()
[ "def", "write", "(", "self", ",", "filepath", ",", "skip_unknown", "=", "False", ")", ":", "fp", "=", "codecs", ".", "open", "(", "filepath", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "try", ":", "self", ".", "write_file", "(", "fp", ",", "...
Write the metadata fields to filepath.
[ "Write", "the", "metadata", "fields", "to", "filepath", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L385-L391
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.write_file
def write_file(self, fileobject, skip_unknown=False): """Write the PKG-INFO format data to a file object.""" self.set_metadata_version() for field in _version2fieldlist(self['Metadata-Version']): values = self.get(field) if skip_unknown and values in ('UNKNOWN', [], ['UN...
python
def write_file(self, fileobject, skip_unknown=False): """Write the PKG-INFO format data to a file object.""" self.set_metadata_version() for field in _version2fieldlist(self['Metadata-Version']): values = self.get(field) if skip_unknown and values in ('UNKNOWN', [], ['UN...
[ "def", "write_file", "(", "self", ",", "fileobject", ",", "skip_unknown", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "for", "field", "in", "_version2fieldlist", "(", "self", "[", "'Metadata-Version'", "]", ")", ":", "values", "=",...
Write the PKG-INFO format data to a file object.
[ "Write", "the", "PKG", "-", "INFO", "format", "data", "to", "a", "file", "object", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L393-L416
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.update
def update(self, other=None, **kwargs): """Set metadata values from the given iterable `other` and kwargs. Behavior is like `dict.update`: If `other` has a ``keys`` method, they are looped over and ``self[key]`` is assigned ``other[key]``. Else, ``other`` is an iterable of ``(key, value...
python
def update(self, other=None, **kwargs): """Set metadata values from the given iterable `other` and kwargs. Behavior is like `dict.update`: If `other` has a ``keys`` method, they are looped over and ``self[key]`` is assigned ``other[key]``. Else, ``other`` is an iterable of ``(key, value...
[ "def", "update", "(", "self", ",", "other", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "_set", "(", "key", ",", "value", ")", ":", "if", "key", "in", "_ATTR2FIELD", "and", "value", ":", "self", ".", "set", "(", "self", ".", "_convert_...
Set metadata values from the given iterable `other` and kwargs. Behavior is like `dict.update`: If `other` has a ``keys`` method, they are looped over and ``self[key]`` is assigned ``other[key]``. Else, ``other`` is an iterable of ``(key, value)`` iterables. Keys that don't match a met...
[ "Set", "metadata", "values", "from", "the", "given", "iterable", "other", "and", "kwargs", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L418-L444
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.set
def set(self, name, value): """Control then set a metadata field.""" name = self._convert_name(name) if ((name in _ELEMENTSFIELD or name == 'Platform') and not isinstance(value, (list, tuple))): if isinstance(value, string_types): value = [v.strip() for v...
python
def set(self, name, value): """Control then set a metadata field.""" name = self._convert_name(name) if ((name in _ELEMENTSFIELD or name == 'Platform') and not isinstance(value, (list, tuple))): if isinstance(value, string_types): value = [v.strip() for v...
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "name", "=", "self", ".", "_convert_name", "(", "name", ")", "if", "(", "(", "name", "in", "_ELEMENTSFIELD", "or", "name", "==", "'Platform'", ")", "and", "not", "isinstance", "(", "valu...
Control then set a metadata field.
[ "Control", "then", "set", "a", "metadata", "field", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L446-L488
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.get
def get(self, name, default=_MISSING): """Get a metadata field.""" name = self._convert_name(name) if name not in self._fields: if default is _MISSING: default = self._default_value(name) return default if name in _UNICODEFIELDS: value ...
python
def get(self, name, default=_MISSING): """Get a metadata field.""" name = self._convert_name(name) if name not in self._fields: if default is _MISSING: default = self._default_value(name) return default if name in _UNICODEFIELDS: value ...
[ "def", "get", "(", "self", ",", "name", ",", "default", "=", "_MISSING", ")", ":", "name", "=", "self", ".", "_convert_name", "(", "name", ")", "if", "name", "not", "in", "self", ".", "_fields", ":", "if", "default", "is", "_MISSING", ":", "default",...
Get a metadata field.
[ "Get", "a", "metadata", "field", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L490-L517
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
LegacyMetadata.todict
def todict(self, skip_missing=False): """Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page). """ self.set_metadata_version() mapping_1_0 = ( ('metada...
python
def todict(self, skip_missing=False): """Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page). """ self.set_metadata_version() mapping_1_0 = ( ('metada...
[ "def", "todict", "(", "self", ",", "skip_missing", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "mapping_1_0", "=", "(", "(", "'metadata_version'", ",", "'Metadata-Version'", ")", ",", "(", "'name'", ",", "'Name'", ")", ",", "(", ...
Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page).
[ "Return", "fields", "as", "a", "dict", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L563-L620
train
pypa/pipenv
pipenv/vendor/distlib/metadata.py
Metadata.get_requirements
def get_requirements(self, reqts, extras=None, env=None): """ Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. ...
python
def get_requirements(self, reqts, extras=None, env=None): """ Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. ...
[ "def", "get_requirements", "(", "self", ",", "reqts", ",", "extras", "=", "None", ",", "env", "=", "None", ")", ":", "if", "self", ".", "_legacy", ":", "result", "=", "reqts", "else", ":", "result", "=", "[", "]", "extras", "=", "get_extras", "(", ...
Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. :param extras: A list of optional components being requested. :...
[ "Base", "method", "to", "get", "dependencies", "given", "a", "set", "of", "extras", "to", "satisfy", "and", "an", "optional", "environment", "context", ".", ":", "param", "reqts", ":", "A", "list", "of", "sometimes", "-", "wanted", "dependencies", "perhaps",...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/metadata.py#L880-L920
train
pypa/pipenv
pipenv/vendor/six.py
remove_move
def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,))
python
def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,))
[ "def", "remove_move", "(", "name", ")", ":", "try", ":", "delattr", "(", "_MovedItems", ",", "name", ")", "except", "AttributeError", ":", "try", ":", "del", "moves", ".", "__dict__", "[", "name", "]", "except", "KeyError", ":", "raise", "AttributeError", ...
Remove item from six.moves.
[ "Remove", "item", "from", "six", ".", "moves", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/six.py#L497-L505
train
pypa/pipenv
pipenv/vendor/six.py
ensure_binary
def ensure_binary(s, encoding='utf-8', errors='strict'): """Coerce **s** to six.binary_type. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> encoded to `bytes` - `bytes` -> `bytes` """ if isinstance(s, text_type): return s.enc...
python
def ensure_binary(s, encoding='utf-8', errors='strict'): """Coerce **s** to six.binary_type. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> encoded to `bytes` - `bytes` -> `bytes` """ if isinstance(s, text_type): return s.enc...
[ "def", "ensure_binary", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "s", ",", "text_type", ")", ":", "return", "s", ".", "encode", "(", "encoding", ",", "errors", ")", "elif", "isinstanc...
Coerce **s** to six.binary_type. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> encoded to `bytes` - `bytes` -> `bytes`
[ "Coerce", "**", "s", "**", "to", "six", ".", "binary_type", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/six.py#L853-L869
train
pypa/pipenv
pipenv/vendor/six.py
ensure_str
def ensure_str(s, encoding='utf-8', errors='strict'): """Coerce *s* to `str`. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str` """ if not isinstance(s, (text_type, binary_type)): raise TypeEr...
python
def ensure_str(s, encoding='utf-8', errors='strict'): """Coerce *s* to `str`. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str` """ if not isinstance(s, (text_type, binary_type)): raise TypeEr...
[ "def", "ensure_str", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "not", "isinstance", "(", "s", ",", "(", "text_type", ",", "binary_type", ")", ")", ":", "raise", "TypeError", "(", "\"not expecting type '%s'\"...
Coerce *s* to `str`. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str`
[ "Coerce", "*", "s", "*", "to", "str", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/six.py#L872-L889
train
pypa/pipenv
pipenv/vendor/six.py
ensure_text
def ensure_text(s, encoding='utf-8', errors='strict'): """Coerce *s* to six.text_type. For Python 2: - `unicode` -> `unicode` - `str` -> `unicode` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str` """ if isinstance(s, binary_type): return s.decode(encodin...
python
def ensure_text(s, encoding='utf-8', errors='strict'): """Coerce *s* to six.text_type. For Python 2: - `unicode` -> `unicode` - `str` -> `unicode` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str` """ if isinstance(s, binary_type): return s.decode(encodin...
[ "def", "ensure_text", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "s", ",", "binary_type", ")", ":", "return", "s", ".", "decode", "(", "encoding", ",", "errors", ")", "elif", "isinstanc...
Coerce *s* to six.text_type. For Python 2: - `unicode` -> `unicode` - `str` -> `unicode` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str`
[ "Coerce", "*", "s", "*", "to", "six", ".", "text_type", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/six.py#L892-L908
train
pypa/pipenv
pipenv/vendor/six.py
python_2_unicode_compatible
def python_2_unicode_compatible(klass): """ A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class. """ if PY2: ...
python
def python_2_unicode_compatible(klass): """ A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class. """ if PY2: ...
[ "def", "python_2_unicode_compatible", "(", "klass", ")", ":", "if", "PY2", ":", "if", "'__str__'", "not", "in", "klass", ".", "__dict__", ":", "raise", "ValueError", "(", "\"@python_2_unicode_compatible cannot be applied \"", "\"to %s because it doesn't define __str__().\""...
A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class.
[ "A", "decorator", "that", "defines", "__unicode__", "and", "__str__", "methods", "under", "Python", "2", ".", "Under", "Python", "3", "it", "does", "nothing", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/six.py#L912-L927
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
parse_requirements
def parse_requirements( filename, # type: str finder=None, # type: Optional[PackageFinder] comes_from=None, # type: Optional[str] options=None, # type: Optional[optparse.Values] session=None, # type: Optional[PipSession] constraint=False, # type: bool wheel_cache=None, # type: Optiona...
python
def parse_requirements( filename, # type: str finder=None, # type: Optional[PackageFinder] comes_from=None, # type: Optional[str] options=None, # type: Optional[optparse.Values] session=None, # type: Optional[PipSession] constraint=False, # type: bool wheel_cache=None, # type: Optiona...
[ "def", "parse_requirements", "(", "filename", ",", "# type: str", "finder", "=", "None", ",", "# type: Optional[PackageFinder]", "comes_from", "=", "None", ",", "# type: Optional[str]", "options", "=", "None", ",", "# type: Optional[optparse.Values]", "session", "=", "N...
Parse a requirements file and yield InstallRequirement instances. :param filename: Path or url of requirements file. :param finder: Instance of pip.index.PackageFinder. :param comes_from: Origin description of requirements. :param options: cli options. :param session: Instance of p...
[ "Parse", "a", "requirements", "file", "and", "yield", "InstallRequirement", "instances", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L73-L113
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
preprocess
def preprocess(content, options): # type: (Text, Optional[optparse.Values]) -> ReqFileLines """Split, filter, and join lines, and return a line iterator :param content: the content of the requirements file :param options: cli options """ lines_enum = enumerate(content.splitlines(), start=1) # ...
python
def preprocess(content, options): # type: (Text, Optional[optparse.Values]) -> ReqFileLines """Split, filter, and join lines, and return a line iterator :param content: the content of the requirements file :param options: cli options """ lines_enum = enumerate(content.splitlines(), start=1) # ...
[ "def", "preprocess", "(", "content", ",", "options", ")", ":", "# type: (Text, Optional[optparse.Values]) -> ReqFileLines", "lines_enum", "=", "enumerate", "(", "content", ".", "splitlines", "(", ")", ",", "start", "=", "1", ")", "# type: ReqFileLines", "lines_enum", ...
Split, filter, and join lines, and return a line iterator :param content: the content of the requirements file :param options: cli options
[ "Split", "filter", "and", "join", "lines", "and", "return", "a", "line", "iterator" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L116-L128
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
process_line
def process_line( line, # type: Text filename, # type: str line_number, # type: int finder=None, # type: Optional[PackageFinder] comes_from=None, # type: Optional[str] options=None, # type: Optional[optparse.Values] session=None, # type: Optional[PipSession] wheel_cache=None, # t...
python
def process_line( line, # type: Text filename, # type: str line_number, # type: int finder=None, # type: Optional[PackageFinder] comes_from=None, # type: Optional[str] options=None, # type: Optional[optparse.Values] session=None, # type: Optional[PipSession] wheel_cache=None, # t...
[ "def", "process_line", "(", "line", ",", "# type: Text", "filename", ",", "# type: str", "line_number", ",", "# type: int", "finder", "=", "None", ",", "# type: Optional[PackageFinder]", "comes_from", "=", "None", ",", "# type: Optional[str]", "options", "=", "None", ...
Process a single requirements line; This can result in creating/yielding requirements, or updating the finder. For lines that contain requirements, the only options that have an effect are from SUPPORTED_OPTIONS_REQ, and they are scoped to the requirement. Other options from SUPPORTED_OPTIONS may be pr...
[ "Process", "a", "single", "requirements", "line", ";", "This", "can", "result", "in", "creating", "/", "yielding", "requirements", "or", "updating", "the", "finder", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L131-L255
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
break_args_options
def break_args_options(line): # type: (Text) -> Tuple[str, Text] """Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex. """ tokens = line.split(' ') args = [] opti...
python
def break_args_options(line): # type: (Text) -> Tuple[str, Text] """Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex. """ tokens = line.split(' ') args = [] opti...
[ "def", "break_args_options", "(", "line", ")", ":", "# type: (Text) -> Tuple[str, Text]", "tokens", "=", "line", ".", "split", "(", "' '", ")", "args", "=", "[", "]", "options", "=", "tokens", "[", ":", "]", "for", "token", "in", "tokens", ":", "if", "to...
Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex.
[ "Break", "up", "the", "line", "into", "an", "args", "and", "options", "string", ".", "We", "only", "want", "to", "shlex", "(", "and", "then", "optparse", ")", "the", "options", "not", "the", "args", ".", "args", "can", "contain", "markers", "which", "a...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L258-L273
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
build_parser
def build_parser(line): # type: (Text) -> optparse.OptionParser """ Return a parser for parsing requirement lines """ parser = optparse.OptionParser(add_help_option=False) option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ for option_factory in option_factories: option = o...
python
def build_parser(line): # type: (Text) -> optparse.OptionParser """ Return a parser for parsing requirement lines """ parser = optparse.OptionParser(add_help_option=False) option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ for option_factory in option_factories: option = o...
[ "def", "build_parser", "(", "line", ")", ":", "# type: (Text) -> optparse.OptionParser", "parser", "=", "optparse", ".", "OptionParser", "(", "add_help_option", "=", "False", ")", "option_factories", "=", "SUPPORTED_OPTIONS", "+", "SUPPORTED_OPTIONS_REQ", "for", "option...
Return a parser for parsing requirement lines
[ "Return", "a", "parser", "for", "parsing", "requirement", "lines" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L276-L298
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
join_lines
def join_lines(lines_enum): # type: (ReqFileLines) -> ReqFileLines """Joins a line ending in '\' with the previous line (except when following comments). The joined line takes on the index of the first line. """ primary_line_number = None new_line = [] # type: List[Text] for line_number, l...
python
def join_lines(lines_enum): # type: (ReqFileLines) -> ReqFileLines """Joins a line ending in '\' with the previous line (except when following comments). The joined line takes on the index of the first line. """ primary_line_number = None new_line = [] # type: List[Text] for line_number, l...
[ "def", "join_lines", "(", "lines_enum", ")", ":", "# type: (ReqFileLines) -> ReqFileLines", "primary_line_number", "=", "None", "new_line", "=", "[", "]", "# type: List[Text]", "for", "line_number", ",", "line", "in", "lines_enum", ":", "if", "not", "line", ".", "...
Joins a line ending in '\' with the previous line (except when following comments). The joined line takes on the index of the first line.
[ "Joins", "a", "line", "ending", "in", "\\", "with", "the", "previous", "line", "(", "except", "when", "following", "comments", ")", ".", "The", "joined", "line", "takes", "on", "the", "index", "of", "the", "first", "line", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L301-L326
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
ignore_comments
def ignore_comments(lines_enum): # type: (ReqFileLines) -> ReqFileLines """ Strips comments and filter empty lines. """ for line_number, line in lines_enum: line = COMMENT_RE.sub('', line) line = line.strip() if line: yield line_number, line
python
def ignore_comments(lines_enum): # type: (ReqFileLines) -> ReqFileLines """ Strips comments and filter empty lines. """ for line_number, line in lines_enum: line = COMMENT_RE.sub('', line) line = line.strip() if line: yield line_number, line
[ "def", "ignore_comments", "(", "lines_enum", ")", ":", "# type: (ReqFileLines) -> ReqFileLines", "for", "line_number", ",", "line", "in", "lines_enum", ":", "line", "=", "COMMENT_RE", ".", "sub", "(", "''", ",", "line", ")", "line", "=", "line", ".", "strip", ...
Strips comments and filter empty lines.
[ "Strips", "comments", "and", "filter", "empty", "lines", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L331-L340
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
skip_regex
def skip_regex(lines_enum, options): # type: (ReqFileLines, Optional[optparse.Values]) -> ReqFileLines """ Skip lines that match '--skip-requirements-regex' pattern Note: the regex pattern is only built once """ skip_regex = options.skip_requirements_regex if options else None if skip_regex...
python
def skip_regex(lines_enum, options): # type: (ReqFileLines, Optional[optparse.Values]) -> ReqFileLines """ Skip lines that match '--skip-requirements-regex' pattern Note: the regex pattern is only built once """ skip_regex = options.skip_requirements_regex if options else None if skip_regex...
[ "def", "skip_regex", "(", "lines_enum", ",", "options", ")", ":", "# type: (ReqFileLines, Optional[optparse.Values]) -> ReqFileLines", "skip_regex", "=", "options", ".", "skip_requirements_regex", "if", "options", "else", "None", "if", "skip_regex", ":", "pattern", "=", ...
Skip lines that match '--skip-requirements-regex' pattern Note: the regex pattern is only built once
[ "Skip", "lines", "that", "match", "--", "skip", "-", "requirements", "-", "regex", "pattern" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L343-L354
train
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_file.py
expand_env_variables
def expand_env_variables(lines_enum): # type: (ReqFileLines) -> ReqFileLines """Replace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that con...
python
def expand_env_variables(lines_enum): # type: (ReqFileLines) -> ReqFileLines """Replace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that con...
[ "def", "expand_env_variables", "(", "lines_enum", ")", ":", "# type: (ReqFileLines) -> ReqFileLines", "for", "line_number", ",", "line", "in", "lines_enum", ":", "for", "env_var", ",", "var_name", "in", "ENV_VAR_RE", ".", "findall", "(", "line", ")", ":", "value",...
Replace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that contain a `$` aren't accidentally (partially) expanded. 2. Ensure consistency across pl...
[ "Replace", "all", "environment", "variables", "that", "can", "be", "retrieved", "via", "os", ".", "getenv", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_file.py#L357-L382
train
pypa/pipenv
pipenv/patched/notpip/_internal/utils/ui.py
InterruptibleMixin.finish
def finish(self): """ Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted. """ super(InterruptibleMixin, self).finish() signal(SIGINT, self.original_handler)
python
def finish(self): """ Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted. """ super(InterruptibleMixin, self).finish() signal(SIGINT, self.original_handler)
[ "def", "finish", "(", "self", ")", ":", "super", "(", "InterruptibleMixin", ",", "self", ")", ".", "finish", "(", ")", "signal", "(", "SIGINT", ",", "self", ".", "original_handler", ")" ]
Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted.
[ "Restore", "the", "original", "SIGINT", "handler", "after", "finishing", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/ui.py#L100-L108
train
pypa/pipenv
pipenv/patched/notpip/_internal/utils/ui.py
InterruptibleMixin.handle_sigint
def handle_sigint(self, signum, frame): """ Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active. """ self.finish() self.original_handler(signum, frame)
python
def handle_sigint(self, signum, frame): """ Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active. """ self.finish() self.original_handler(signum, frame)
[ "def", "handle_sigint", "(", "self", ",", "signum", ",", "frame", ")", ":", "self", ".", "finish", "(", ")", "self", ".", "original_handler", "(", "signum", ",", "frame", ")" ]
Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active.
[ "Call", "self", ".", "finish", "()", "before", "delegating", "to", "the", "original", "SIGINT", "handler", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/ui.py#L110-L118
train
pypa/pipenv
pipenv/vendor/jinja2/nodes.py
Node.iter_fields
def iter_fields(self, exclude=None, only=None): """This method iterates over all fields that are defined and yields ``(key, value)`` tuples. Per default all fields are returned, but it's possible to limit that to some fields by providing the `only` parameter or to exclude some using the...
python
def iter_fields(self, exclude=None, only=None): """This method iterates over all fields that are defined and yields ``(key, value)`` tuples. Per default all fields are returned, but it's possible to limit that to some fields by providing the `only` parameter or to exclude some using the...
[ "def", "iter_fields", "(", "self", ",", "exclude", "=", "None", ",", "only", "=", "None", ")", ":", "for", "name", "in", "self", ".", "fields", ":", "if", "(", "exclude", "is", "only", "is", "None", ")", "or", "(", "exclude", "is", "not", "None", ...
This method iterates over all fields that are defined and yields ``(key, value)`` tuples. Per default all fields are returned, but it's possible to limit that to some fields by providing the `only` parameter or to exclude some using the `exclude` parameter. Both should be sets or tuple...
[ "This", "method", "iterates", "over", "all", "fields", "that", "are", "defined", "and", "yields", "(", "key", "value", ")", "tuples", ".", "Per", "default", "all", "fields", "are", "returned", "but", "it", "s", "possible", "to", "limit", "that", "to", "s...
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/nodes.py#L148-L162
train