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/patched/notpip/_vendor/msgpack/fallback.py | Unpacker._consume | def _consume(self):
""" Gets rid of the used parts of the buffer. """
self._stream_offset += self._buff_i - self._buf_checkpoint
self._buf_checkpoint = self._buff_i | python | def _consume(self):
""" Gets rid of the used parts of the buffer. """
self._stream_offset += self._buff_i - self._buf_checkpoint
self._buf_checkpoint = self._buff_i | [
"def",
"_consume",
"(",
"self",
")",
":",
"self",
".",
"_stream_offset",
"+=",
"self",
".",
"_buff_i",
"-",
"self",
".",
"_buf_checkpoint",
"self",
".",
"_buf_checkpoint",
"=",
"self",
".",
"_buff_i"
] | Gets rid of the used parts of the buffer. | [
"Gets",
"rid",
"of",
"the",
"used",
"parts",
"of",
"the",
"buffer",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/msgpack/fallback.py#L300-L303 | train |
pypa/pipenv | pipenv/vendor/urllib3/connection.py | HTTPConnection._new_conn | def _new_conn(self):
""" Establish a socket connection and set nodelay settings on it.
:return: New socket connection.
"""
extra_kw = {}
if self.source_address:
extra_kw['source_address'] = self.source_address
if self.socket_options:
extra_kw['so... | python | def _new_conn(self):
""" Establish a socket connection and set nodelay settings on it.
:return: New socket connection.
"""
extra_kw = {}
if self.source_address:
extra_kw['source_address'] = self.source_address
if self.socket_options:
extra_kw['so... | [
"def",
"_new_conn",
"(",
"self",
")",
":",
"extra_kw",
"=",
"{",
"}",
"if",
"self",
".",
"source_address",
":",
"extra_kw",
"[",
"'source_address'",
"]",
"=",
"self",
".",
"source_address",
"if",
"self",
".",
"socket_options",
":",
"extra_kw",
"[",
"'socke... | Establish a socket connection and set nodelay settings on it.
:return: New socket connection. | [
"Establish",
"a",
"socket",
"connection",
"and",
"set",
"nodelay",
"settings",
"on",
"it",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/connection.py#L145-L170 | train |
pypa/pipenv | pipenv/vendor/urllib3/connection.py | HTTPConnection.request_chunked | def request_chunked(self, method, url, body=None, headers=None):
"""
Alternative to the common request method, which sends the
body with chunked encoding and not as one block
"""
headers = HTTPHeaderDict(headers if headers is not None else {})
skip_accept_encoding = 'acce... | python | def request_chunked(self, method, url, body=None, headers=None):
"""
Alternative to the common request method, which sends the
body with chunked encoding and not as one block
"""
headers = HTTPHeaderDict(headers if headers is not None else {})
skip_accept_encoding = 'acce... | [
"def",
"request_chunked",
"(",
"self",
",",
"method",
",",
"url",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"headers",
"=",
"HTTPHeaderDict",
"(",
"headers",
"if",
"headers",
"is",
"not",
"None",
"else",
"{",
"}",
")",
"skip_acce... | Alternative to the common request method, which sends the
body with chunked encoding and not as one block | [
"Alternative",
"to",
"the",
"common",
"request",
"method",
"which",
"sends",
"the",
"body",
"with",
"chunked",
"encoding",
"and",
"not",
"as",
"one",
"block"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/connection.py#L184-L220 | train |
pypa/pipenv | pipenv/vendor/urllib3/connection.py | VerifiedHTTPSConnection.set_cert | def set_cert(self, key_file=None, cert_file=None,
cert_reqs=None, ca_certs=None,
assert_hostname=None, assert_fingerprint=None,
ca_cert_dir=None):
"""
This method should only be called once, before the connection is used.
"""
# If cert_r... | python | def set_cert(self, key_file=None, cert_file=None,
cert_reqs=None, ca_certs=None,
assert_hostname=None, assert_fingerprint=None,
ca_cert_dir=None):
"""
This method should only be called once, before the connection is used.
"""
# If cert_r... | [
"def",
"set_cert",
"(",
"self",
",",
"key_file",
"=",
"None",
",",
"cert_file",
"=",
"None",
",",
"cert_reqs",
"=",
"None",
",",
"ca_certs",
"=",
"None",
",",
"assert_hostname",
"=",
"None",
",",
"assert_fingerprint",
"=",
"None",
",",
"ca_cert_dir",
"=",
... | This method should only be called once, before the connection is used. | [
"This",
"method",
"should",
"only",
"be",
"called",
"once",
"before",
"the",
"connection",
"is",
"used",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/connection.py#L274-L297 | train |
pypa/pipenv | pipenv/exceptions.py | prettify_exc | def prettify_exc(error):
"""Catch known errors and prettify them instead of showing the
entire traceback, for better UX"""
matched_exceptions = [k for k in KNOWN_EXCEPTIONS.keys() if k in error]
if not matched_exceptions:
return "{}".format(vistir.misc.decode_for_output(error))
errors = []
... | python | def prettify_exc(error):
"""Catch known errors and prettify them instead of showing the
entire traceback, for better UX"""
matched_exceptions = [k for k in KNOWN_EXCEPTIONS.keys() if k in error]
if not matched_exceptions:
return "{}".format(vistir.misc.decode_for_output(error))
errors = []
... | [
"def",
"prettify_exc",
"(",
"error",
")",
":",
"matched_exceptions",
"=",
"[",
"k",
"for",
"k",
"in",
"KNOWN_EXCEPTIONS",
".",
"keys",
"(",
")",
"if",
"k",
"in",
"error",
"]",
"if",
"not",
"matched_exceptions",
":",
"return",
"\"{}\"",
".",
"format",
"("... | Catch known errors and prettify them instead of showing the
entire traceback, for better UX | [
"Catch",
"known",
"errors",
"and",
"prettify",
"them",
"instead",
"of",
"showing",
"the",
"entire",
"traceback",
"for",
"better",
"UX"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/exceptions.py#L412-L423 | train |
pypa/pipenv | pipenv/vendor/vistir/cursor.py | get_stream_handle | def get_stream_handle(stream=sys.stdout):
"""
Get the OS appropriate handle for the corresponding output stream.
:param str stream: The the stream to get the handle for
:return: A handle to the appropriate stream, either a ctypes buffer
or **sys.stdout** or **sys.stderr**.
"""
hand... | python | def get_stream_handle(stream=sys.stdout):
"""
Get the OS appropriate handle for the corresponding output stream.
:param str stream: The the stream to get the handle for
:return: A handle to the appropriate stream, either a ctypes buffer
or **sys.stdout** or **sys.stderr**.
"""
hand... | [
"def",
"get_stream_handle",
"(",
"stream",
"=",
"sys",
".",
"stdout",
")",
":",
"handle",
"=",
"stream",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"from",
"ctypes",
"import",
"windll",
"handle_id",
"=",
"WIN_STDOUT_HANDLE_ID",
"handle",
"=",
"windll",
... | Get the OS appropriate handle for the corresponding output stream.
:param str stream: The the stream to get the handle for
:return: A handle to the appropriate stream, either a ctypes buffer
or **sys.stdout** or **sys.stderr**. | [
"Get",
"the",
"OS",
"appropriate",
"handle",
"for",
"the",
"corresponding",
"output",
"stream",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/cursor.py#L19-L33 | train |
pypa/pipenv | pipenv/vendor/vistir/cursor.py | hide_cursor | def hide_cursor(stream=sys.stdout):
"""
Hide the console cursor on the given stream
:param stream: The name of the stream to get the handle for
:return: None
:rtype: None
"""
handle = get_stream_handle(stream=stream)
if os.name == "nt":
from ctypes import windll
cursor... | python | def hide_cursor(stream=sys.stdout):
"""
Hide the console cursor on the given stream
:param stream: The name of the stream to get the handle for
:return: None
:rtype: None
"""
handle = get_stream_handle(stream=stream)
if os.name == "nt":
from ctypes import windll
cursor... | [
"def",
"hide_cursor",
"(",
"stream",
"=",
"sys",
".",
"stdout",
")",
":",
"handle",
"=",
"get_stream_handle",
"(",
"stream",
"=",
"stream",
")",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"from",
"ctypes",
"import",
"windll",
"cursor_info",
"=",
"CONS... | Hide the console cursor on the given stream
:param stream: The name of the stream to get the handle for
:return: None
:rtype: None | [
"Hide",
"the",
"console",
"cursor",
"on",
"the",
"given",
"stream"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/cursor.py#L36-L55 | train |
pypa/pipenv | pipenv/vendor/click_completion/patch.py | choice_complete | def choice_complete(self, ctx, incomplete):
"""Returns the completion results for click.core.Choice
Parameters
----------
ctx : click.core.Context
The current context
incomplete :
The string to complete
Returns
-------
[(str, str)]
A list of completion results
... | python | def choice_complete(self, ctx, incomplete):
"""Returns the completion results for click.core.Choice
Parameters
----------
ctx : click.core.Context
The current context
incomplete :
The string to complete
Returns
-------
[(str, str)]
A list of completion results
... | [
"def",
"choice_complete",
"(",
"self",
",",
"ctx",
",",
"incomplete",
")",
":",
"return",
"[",
"(",
"c",
",",
"None",
")",
"for",
"c",
"in",
"self",
".",
"choices",
"if",
"completion_configuration",
".",
"match_incomplete",
"(",
"c",
",",
"incomplete",
"... | Returns the completion results for click.core.Choice
Parameters
----------
ctx : click.core.Context
The current context
incomplete :
The string to complete
Returns
-------
[(str, str)]
A list of completion results | [
"Returns",
"the",
"completion",
"results",
"for",
"click",
".",
"core",
".",
"Choice"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click_completion/patch.py#L39-L57 | train |
pypa/pipenv | pipenv/vendor/click_completion/patch.py | _shellcomplete | def _shellcomplete(cli, prog_name, complete_var=None):
"""Internal handler for the bash completion support.
Parameters
----------
cli : click.Command
The main click Command of the program
prog_name : str
The program name on the command line
complete_var : str
The environ... | python | def _shellcomplete(cli, prog_name, complete_var=None):
"""Internal handler for the bash completion support.
Parameters
----------
cli : click.Command
The main click Command of the program
prog_name : str
The program name on the command line
complete_var : str
The environ... | [
"def",
"_shellcomplete",
"(",
"cli",
",",
"prog_name",
",",
"complete_var",
"=",
"None",
")",
":",
"if",
"complete_var",
"is",
"None",
":",
"complete_var",
"=",
"'_%s_COMPLETE'",
"%",
"(",
"prog_name",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
")",
".... | Internal handler for the bash completion support.
Parameters
----------
cli : click.Command
The main click Command of the program
prog_name : str
The program name on the command line
complete_var : str
The environment variable name used to control the completion behavior (De... | [
"Internal",
"handler",
"for",
"the",
"bash",
"completion",
"support",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click_completion/patch.py#L81-L133 | train |
pypa/pipenv | pipenv/vendor/click_completion/patch.py | patch | def patch():
"""Patch click"""
import click
click.types.ParamType.complete = param_type_complete
click.types.Choice.complete = choice_complete
click.core.MultiCommand.get_command_short_help = multicommand_get_command_short_help
click.core._bashcomplete = _shellcomplete | python | def patch():
"""Patch click"""
import click
click.types.ParamType.complete = param_type_complete
click.types.Choice.complete = choice_complete
click.core.MultiCommand.get_command_short_help = multicommand_get_command_short_help
click.core._bashcomplete = _shellcomplete | [
"def",
"patch",
"(",
")",
":",
"import",
"click",
"click",
".",
"types",
".",
"ParamType",
".",
"complete",
"=",
"param_type_complete",
"click",
".",
"types",
".",
"Choice",
".",
"complete",
"=",
"choice_complete",
"click",
".",
"core",
".",
"MultiCommand",
... | Patch click | [
"Patch",
"click"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click_completion/patch.py#L136-L142 | train |
pypa/pipenv | pipenv/vendor/docopt.py | parse_expr | def parse_expr(tokens, options):
"""expr ::= seq ( '|' seq )* ;"""
seq = parse_seq(tokens, options)
if tokens.current() != '|':
return seq
result = [Required(*seq)] if len(seq) > 1 else seq
while tokens.current() == '|':
tokens.move()
seq = parse_seq(tokens, options)
... | python | def parse_expr(tokens, options):
"""expr ::= seq ( '|' seq )* ;"""
seq = parse_seq(tokens, options)
if tokens.current() != '|':
return seq
result = [Required(*seq)] if len(seq) > 1 else seq
while tokens.current() == '|':
tokens.move()
seq = parse_seq(tokens, options)
... | [
"def",
"parse_expr",
"(",
"tokens",
",",
"options",
")",
":",
"seq",
"=",
"parse_seq",
"(",
"tokens",
",",
"options",
")",
"if",
"tokens",
".",
"current",
"(",
")",
"!=",
"'|'",
":",
"return",
"seq",
"result",
"=",
"[",
"Required",
"(",
"*",
"seq",
... | expr ::= seq ( '|' seq )* ; | [
"expr",
"::",
"=",
"seq",
"(",
"|",
"seq",
")",
"*",
";"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/docopt.py#L379-L389 | train |
pypa/pipenv | pipenv/vendor/docopt.py | parse_seq | def parse_seq(tokens, options):
"""seq ::= ( atom [ '...' ] )* ;"""
result = []
while tokens.current() not in [None, ']', ')', '|']:
atom = parse_atom(tokens, options)
if tokens.current() == '...':
atom = [OneOrMore(*atom)]
tokens.move()
result += atom
ret... | python | def parse_seq(tokens, options):
"""seq ::= ( atom [ '...' ] )* ;"""
result = []
while tokens.current() not in [None, ']', ')', '|']:
atom = parse_atom(tokens, options)
if tokens.current() == '...':
atom = [OneOrMore(*atom)]
tokens.move()
result += atom
ret... | [
"def",
"parse_seq",
"(",
"tokens",
",",
"options",
")",
":",
"result",
"=",
"[",
"]",
"while",
"tokens",
".",
"current",
"(",
")",
"not",
"in",
"[",
"None",
",",
"']'",
",",
"')'",
",",
"'|'",
"]",
":",
"atom",
"=",
"parse_atom",
"(",
"tokens",
"... | seq ::= ( atom [ '...' ] )* ; | [
"seq",
"::",
"=",
"(",
"atom",
"[",
"...",
"]",
")",
"*",
";"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/docopt.py#L392-L401 | train |
pypa/pipenv | pipenv/vendor/docopt.py | parse_argv | def parse_argv(tokens, options, options_first=False):
"""Parse command-line argument vector.
If options_first:
argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;
else:
argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ;
"""
parsed = []
while tokens.c... | python | def parse_argv(tokens, options, options_first=False):
"""Parse command-line argument vector.
If options_first:
argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;
else:
argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ;
"""
parsed = []
while tokens.c... | [
"def",
"parse_argv",
"(",
"tokens",
",",
"options",
",",
"options_first",
"=",
"False",
")",
":",
"parsed",
"=",
"[",
"]",
"while",
"tokens",
".",
"current",
"(",
")",
"is",
"not",
"None",
":",
"if",
"tokens",
".",
"current",
"(",
")",
"==",
"'--'",
... | Parse command-line argument vector.
If options_first:
argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;
else:
argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ; | [
"Parse",
"command",
"-",
"line",
"argument",
"vector",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/docopt.py#L430-L451 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | unnest | def unnest(elem):
"""Flatten an arbitrarily nested iterable
:param elem: An iterable to flatten
:type elem: :class:`~collections.Iterable`
>>> nested_iterable = (1234, (3456, 4398345, (234234)), (2396, (23895750, 9283798, 29384, (289375983275, 293759, 2347, (2098, 7987, 27599)))))
>>> list(vistir.... | python | def unnest(elem):
"""Flatten an arbitrarily nested iterable
:param elem: An iterable to flatten
:type elem: :class:`~collections.Iterable`
>>> nested_iterable = (1234, (3456, 4398345, (234234)), (2396, (23895750, 9283798, 29384, (289375983275, 293759, 2347, (2098, 7987, 27599)))))
>>> list(vistir.... | [
"def",
"unnest",
"(",
"elem",
")",
":",
"if",
"isinstance",
"(",
"elem",
",",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"elem",
",",
"six",
".",
"string_types",
")",
":",
"elem",
",",
"target",
"=",
"tee",
"(",
"elem",
",",
"2",
")",
"else"... | Flatten an arbitrarily nested iterable
:param elem: An iterable to flatten
:type elem: :class:`~collections.Iterable`
>>> nested_iterable = (1234, (3456, 4398345, (234234)), (2396, (23895750, 9283798, 29384, (289375983275, 293759, 2347, (2098, 7987, 27599)))))
>>> list(vistir.misc.unnest(nested_iterab... | [
"Flatten",
"an",
"arbitrarily",
"nested",
"iterable"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L74-L95 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | run | def run(
cmd,
env=None,
return_object=False,
block=True,
cwd=None,
verbose=False,
nospin=False,
spinner_name=None,
combine_stderr=True,
display_limit=200,
write_to_stdout=True,
):
"""Use `subprocess.Popen` to get the output of a command and decode it.
:param list cmd... | python | def run(
cmd,
env=None,
return_object=False,
block=True,
cwd=None,
verbose=False,
nospin=False,
spinner_name=None,
combine_stderr=True,
display_limit=200,
write_to_stdout=True,
):
"""Use `subprocess.Popen` to get the output of a command and decode it.
:param list cmd... | [
"def",
"run",
"(",
"cmd",
",",
"env",
"=",
"None",
",",
"return_object",
"=",
"False",
",",
"block",
"=",
"True",
",",
"cwd",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"nospin",
"=",
"False",
",",
"spinner_name",
"=",
"None",
",",
"combine_stde... | Use `subprocess.Popen` to get the output of a command and decode it.
:param list cmd: A list representing the command you want to run.
:param dict env: Additional environment settings to pass through to the subprocess.
:param bool return_object: When True, returns the whole subprocess instance
:param b... | [
"Use",
"subprocess",
".",
"Popen",
"to",
"get",
"the",
"output",
"of",
"a",
"command",
"and",
"decode",
"it",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L265-L335 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | load_path | def load_path(python):
"""Load the :mod:`sys.path` from the given python executable's environment as json
:param str python: Path to a valid python executable
:return: A python representation of the `sys.path` value of the given python executable.
:rtype: list
>>> load_path("/home/user/.virtualenv... | python | def load_path(python):
"""Load the :mod:`sys.path` from the given python executable's environment as json
:param str python: Path to a valid python executable
:return: A python representation of the `sys.path` value of the given python executable.
:rtype: list
>>> load_path("/home/user/.virtualenv... | [
"def",
"load_path",
"(",
"python",
")",
":",
"python",
"=",
"Path",
"(",
"python",
")",
".",
"as_posix",
"(",
")",
"out",
",",
"err",
"=",
"run",
"(",
"[",
"python",
",",
"\"-c\"",
",",
"\"import json, sys; print(json.dumps(sys.path))\"",
"]",
",",
"nospin... | Load the :mod:`sys.path` from the given python executable's environment as json
:param str python: Path to a valid python executable
:return: A python representation of the `sys.path` value of the given python executable.
:rtype: list
>>> load_path("/home/user/.virtualenvs/requirementslib-5MhGuG3C/bin... | [
"Load",
"the",
":",
"mod",
":",
"sys",
".",
"path",
"from",
"the",
"given",
"python",
"executable",
"s",
"environment",
"as",
"json"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L338-L356 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | to_bytes | def to_bytes(string, encoding="utf-8", errors="ignore"):
"""Force a value to bytes.
:param string: Some input that can be converted to a bytes.
:type string: str or bytes unicode or a memoryview subclass
:param encoding: The encoding to use for conversions, defaults to "utf-8"
:param encoding: str,... | python | def to_bytes(string, encoding="utf-8", errors="ignore"):
"""Force a value to bytes.
:param string: Some input that can be converted to a bytes.
:type string: str or bytes unicode or a memoryview subclass
:param encoding: The encoding to use for conversions, defaults to "utf-8"
:param encoding: str,... | [
"def",
"to_bytes",
"(",
"string",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"errors",
"=",
"\"ignore\"",
")",
":",
"if",
"not",
"errors",
":",
"if",
"encoding",
".",
"lower",
"(",
")",
"==",
"\"utf-8\"",
":",
"errors",
"=",
"\"surrogateescape\"",
"if",
"si... | Force a value to bytes.
:param string: Some input that can be converted to a bytes.
:type string: str or bytes unicode or a memoryview subclass
:param encoding: The encoding to use for conversions, defaults to "utf-8"
:param encoding: str, optional
:return: Corresponding byte representation (for us... | [
"Force",
"a",
"value",
"to",
"bytes",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L397-L431 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | to_text | def to_text(string, encoding="utf-8", errors=None):
"""Force a value to a text-type.
:param string: Some input that can be converted to a unicode representation.
:type string: str or bytes unicode
:param encoding: The encoding to use for conversions, defaults to "utf-8"
:param encoding: str, option... | python | def to_text(string, encoding="utf-8", errors=None):
"""Force a value to a text-type.
:param string: Some input that can be converted to a unicode representation.
:type string: str or bytes unicode
:param encoding: The encoding to use for conversions, defaults to "utf-8"
:param encoding: str, option... | [
"def",
"to_text",
"(",
"string",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"errors",
"=",
"None",
")",
":",
"if",
"not",
"errors",
":",
"if",
"encoding",
".",
"lower",
"(",
")",
"==",
"\"utf-8\"",
":",
"errors",
"=",
"\"surrogateescape\"",
"if",
"six",
"... | Force a value to a text-type.
:param string: Some input that can be converted to a unicode representation.
:type string: str or bytes unicode
:param encoding: The encoding to use for conversions, defaults to "utf-8"
:param encoding: str, optional
:return: The unicode representation of the string
... | [
"Force",
"a",
"value",
"to",
"a",
"text",
"-",
"type",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L434-L467 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | divide | def divide(n, iterable):
"""
split an iterable into n groups, per https://more-itertools.readthedocs.io/en/latest/api.html#grouping
:param int n: Number of unique groups
:param iter iterable: An iterable to split up
:return: a list of new iterables derived from the original iterable
:rtype: lis... | python | def divide(n, iterable):
"""
split an iterable into n groups, per https://more-itertools.readthedocs.io/en/latest/api.html#grouping
:param int n: Number of unique groups
:param iter iterable: An iterable to split up
:return: a list of new iterables derived from the original iterable
:rtype: lis... | [
"def",
"divide",
"(",
"n",
",",
"iterable",
")",
":",
"seq",
"=",
"tuple",
"(",
"iterable",
")",
"q",
",",
"r",
"=",
"divmod",
"(",
"len",
"(",
"seq",
")",
",",
"n",
")",
"ret",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
... | split an iterable into n groups, per https://more-itertools.readthedocs.io/en/latest/api.html#grouping
:param int n: Number of unique groups
:param iter iterable: An iterable to split up
:return: a list of new iterables derived from the original iterable
:rtype: list | [
"split",
"an",
"iterable",
"into",
"n",
"groups",
"per",
"https",
":",
"//",
"more",
"-",
"itertools",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"api",
".",
"html#grouping"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L470-L489 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | getpreferredencoding | def getpreferredencoding():
"""Determine the proper output encoding for terminal rendering"""
# Borrowed from Invoke
# (see https://github.com/pyinvoke/invoke/blob/93af29d/invoke/runners.py#L881)
_encoding = locale.getpreferredencoding(False)
if six.PY2 and not sys.platform == "win32":
_def... | python | def getpreferredencoding():
"""Determine the proper output encoding for terminal rendering"""
# Borrowed from Invoke
# (see https://github.com/pyinvoke/invoke/blob/93af29d/invoke/runners.py#L881)
_encoding = locale.getpreferredencoding(False)
if six.PY2 and not sys.platform == "win32":
_def... | [
"def",
"getpreferredencoding",
"(",
")",
":",
"# Borrowed from Invoke",
"# (see https://github.com/pyinvoke/invoke/blob/93af29d/invoke/runners.py#L881)",
"_encoding",
"=",
"locale",
".",
"getpreferredencoding",
"(",
"False",
")",
"if",
"six",
".",
"PY2",
"and",
"not",
"sys"... | Determine the proper output encoding for terminal rendering | [
"Determine",
"the",
"proper",
"output",
"encoding",
"for",
"terminal",
"rendering"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L522-L532 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | decode_for_output | def decode_for_output(output, target_stream=None, translation_map=None):
"""Given a string, decode it for output to a terminal
:param str output: A string to print to a terminal
:param target_stream: A stream to write to, we will encode to target this stream if possible.
:param dict translation_map: A ... | python | def decode_for_output(output, target_stream=None, translation_map=None):
"""Given a string, decode it for output to a terminal
:param str output: A string to print to a terminal
:param target_stream: A stream to write to, we will encode to target this stream if possible.
:param dict translation_map: A ... | [
"def",
"decode_for_output",
"(",
"output",
",",
"target_stream",
"=",
"None",
",",
"translation_map",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"output",
",",
"six",
".",
"string_types",
")",
":",
"return",
"output",
"encoding",
"=",
"None",
"... | Given a string, decode it for output to a terminal
:param str output: A string to print to a terminal
:param target_stream: A stream to write to, we will encode to target this stream if possible.
:param dict translation_map: A mapping of unicode character ordinals to replacement strings.
:return: A re-... | [
"Given",
"a",
"string",
"decode",
"it",
"for",
"output",
"to",
"a",
"terminal"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L574-L597 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | get_canonical_encoding_name | def get_canonical_encoding_name(name):
# type: (str) -> str
"""
Given an encoding name, get the canonical name from a codec lookup.
:param str name: The name of the codec to lookup
:return: The canonical version of the codec name
:rtype: str
"""
import codecs
try:
codec = ... | python | def get_canonical_encoding_name(name):
# type: (str) -> str
"""
Given an encoding name, get the canonical name from a codec lookup.
:param str name: The name of the codec to lookup
:return: The canonical version of the codec name
:rtype: str
"""
import codecs
try:
codec = ... | [
"def",
"get_canonical_encoding_name",
"(",
"name",
")",
":",
"# type: (str) -> str",
"import",
"codecs",
"try",
":",
"codec",
"=",
"codecs",
".",
"lookup",
"(",
"name",
")",
"except",
"LookupError",
":",
"return",
"name",
"else",
":",
"return",
"codec",
".",
... | Given an encoding name, get the canonical name from a codec lookup.
:param str name: The name of the codec to lookup
:return: The canonical version of the codec name
:rtype: str | [
"Given",
"an",
"encoding",
"name",
"get",
"the",
"canonical",
"name",
"from",
"a",
"codec",
"lookup",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L600-L617 | train |
pypa/pipenv | pipenv/vendor/vistir/misc.py | get_wrapped_stream | def get_wrapped_stream(stream):
"""
Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream.
:param stream: A stream instance to wrap
:returns: A new, wrapped stream
:rtype: :class:`StreamWrapper`
"""
if stream is None:
raise TypeError("must provide a st... | python | def get_wrapped_stream(stream):
"""
Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream.
:param stream: A stream instance to wrap
:returns: A new, wrapped stream
:rtype: :class:`StreamWrapper`
"""
if stream is None:
raise TypeError("must provide a st... | [
"def",
"get_wrapped_stream",
"(",
"stream",
")",
":",
"if",
"stream",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"must provide a stream to wrap\"",
")",
"encoding",
"=",
"getattr",
"(",
"stream",
",",
"\"encoding\"",
",",
"None",
")",
"encoding",
"=",
"ge... | Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream.
:param stream: A stream instance to wrap
:returns: A new, wrapped stream
:rtype: :class:`StreamWrapper` | [
"Given",
"a",
"stream",
"wrap",
"it",
"in",
"a",
"StreamWrapper",
"instance",
"and",
"return",
"the",
"wrapped",
"stream",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/misc.py#L620-L633 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/connection.py | is_connection_dropped | def is_connection_dropped(conn): # Platform-specific
"""
Returns True if the connection is dropped and should be closed.
:param conn:
:class:`httplib.HTTPConnection` object.
Note: For platforms like AppEngine, this will always return ``False`` to
let the platform handle connection recycli... | python | def is_connection_dropped(conn): # Platform-specific
"""
Returns True if the connection is dropped and should be closed.
:param conn:
:class:`httplib.HTTPConnection` object.
Note: For platforms like AppEngine, this will always return ``False`` to
let the platform handle connection recycli... | [
"def",
"is_connection_dropped",
"(",
"conn",
")",
":",
"# Platform-specific",
"sock",
"=",
"getattr",
"(",
"conn",
",",
"'sock'",
",",
"False",
")",
"if",
"sock",
"is",
"False",
":",
"# Platform-specific: AppEngine",
"return",
"False",
"if",
"sock",
"is",
"Non... | Returns True if the connection is dropped and should be closed.
:param conn:
:class:`httplib.HTTPConnection` object.
Note: For platforms like AppEngine, this will always return ``False`` to
let the platform handle connection recycling transparently for us. | [
"Returns",
"True",
"if",
"the",
"connection",
"is",
"dropped",
"and",
"should",
"be",
"closed",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/connection.py#L7-L26 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/connection.py | create_connection | def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, socket_options=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the o... | python | def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, socket_options=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the o... | [
"def",
"create_connection",
"(",
"address",
",",
"timeout",
"=",
"socket",
".",
"_GLOBAL_DEFAULT_TIMEOUT",
",",
"source_address",
"=",
"None",
",",
"socket_options",
"=",
"None",
")",
":",
"host",
",",
"port",
"=",
"address",
"if",
"host",
".",
"startswith",
... | Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the... | [
"Connect",
"to",
"*",
"address",
"*",
"and",
"return",
"the",
"socket",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/connection.py#L33-L82 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/connection.py | _has_ipv6 | def _has_ipv6(host):
""" Returns True if the system can bind an IPv6 address. """
sock = None
has_ipv6 = False
# App Engine doesn't support IPV6 sockets and actually has a quota on the
# number of sockets that can be used, so just early out here instead of
# creating a socket needlessly.
# ... | python | def _has_ipv6(host):
""" Returns True if the system can bind an IPv6 address. """
sock = None
has_ipv6 = False
# App Engine doesn't support IPV6 sockets and actually has a quota on the
# number of sockets that can be used, so just early out here instead of
# creating a socket needlessly.
# ... | [
"def",
"_has_ipv6",
"(",
"host",
")",
":",
"sock",
"=",
"None",
"has_ipv6",
"=",
"False",
"# App Engine doesn't support IPV6 sockets and actually has a quota on the",
"# number of sockets that can be used, so just early out here instead of",
"# creating a socket needlessly.",
"# See ht... | Returns True if the system can bind an IPv6 address. | [
"Returns",
"True",
"if",
"the",
"system",
"can",
"bind",
"an",
"IPv6",
"address",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/connection.py#L104-L131 | train |
pypa/pipenv | pipenv/vendor/packaging/version.py | _parse_local_version | def _parse_local_version(local):
"""
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
"""
if local is not None:
return tuple(
part.lower() if not part.isdigit() else int(part)
for part in _local_version_separators.split(local)
) | python | def _parse_local_version(local):
"""
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
"""
if local is not None:
return tuple(
part.lower() if not part.isdigit() else int(part)
for part in _local_version_separators.split(local)
) | [
"def",
"_parse_local_version",
"(",
"local",
")",
":",
"if",
"local",
"is",
"not",
"None",
":",
"return",
"tuple",
"(",
"part",
".",
"lower",
"(",
")",
"if",
"not",
"part",
".",
"isdigit",
"(",
")",
"else",
"int",
"(",
"part",
")",
"for",
"part",
"... | Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve"). | [
"Takes",
"a",
"string",
"like",
"abc",
".",
"1",
".",
"twelve",
"and",
"turns",
"it",
"into",
"(",
"abc",
"1",
"twelve",
")",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/packaging/version.py#L367-L375 | train |
pypa/pipenv | pipenv/vendor/requests/_internal_utils.py | unicode_is_ascii | def unicode_is_ascii(u_string):
"""Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool
"""
assert isinstance(u_string, str)
try:
u_string.encode('ascii')
return Tru... | python | def unicode_is_ascii(u_string):
"""Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool
"""
assert isinstance(u_string, str)
try:
u_string.encode('ascii')
return Tru... | [
"def",
"unicode_is_ascii",
"(",
"u_string",
")",
":",
"assert",
"isinstance",
"(",
"u_string",
",",
"str",
")",
"try",
":",
"u_string",
".",
"encode",
"(",
"'ascii'",
")",
"return",
"True",
"except",
"UnicodeEncodeError",
":",
"return",
"False"
] | Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool | [
"Determine",
"if",
"unicode",
"string",
"only",
"contains",
"ASCII",
"characters",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/_internal_utils.py#L30-L42 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | raise_option_error | def raise_option_error(parser, option, msg):
"""
Raise an option parsing error using parser.error().
Args:
parser: an OptionParser instance.
option: an Option instance.
msg: the error text.
"""
msg = '{} error: {}'.format(option, msg)
msg = textwrap.fill(' '.join(msg.split()))... | python | def raise_option_error(parser, option, msg):
"""
Raise an option parsing error using parser.error().
Args:
parser: an OptionParser instance.
option: an Option instance.
msg: the error text.
"""
msg = '{} error: {}'.format(option, msg)
msg = textwrap.fill(' '.join(msg.split()))... | [
"def",
"raise_option_error",
"(",
"parser",
",",
"option",
",",
"msg",
")",
":",
"msg",
"=",
"'{} error: {}'",
".",
"format",
"(",
"option",
",",
"msg",
")",
"msg",
"=",
"textwrap",
".",
"fill",
"(",
"' '",
".",
"join",
"(",
"msg",
".",
"split",
"(",... | Raise an option parsing error using parser.error().
Args:
parser: an OptionParser instance.
option: an Option instance.
msg: the error text. | [
"Raise",
"an",
"option",
"parsing",
"error",
"using",
"parser",
".",
"error",
"()",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L32-L43 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | make_option_group | def make_option_group(group, parser):
# type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup
"""
Return an OptionGroup object
group -- assumed to be dict with 'name' and 'options' keys
parser -- an optparse Parser
"""
option_group = OptionGroup(parser, group['name'])
for option in ... | python | def make_option_group(group, parser):
# type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup
"""
Return an OptionGroup object
group -- assumed to be dict with 'name' and 'options' keys
parser -- an optparse Parser
"""
option_group = OptionGroup(parser, group['name'])
for option in ... | [
"def",
"make_option_group",
"(",
"group",
",",
"parser",
")",
":",
"# type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup",
"option_group",
"=",
"OptionGroup",
"(",
"parser",
",",
"group",
"[",
"'name'",
"]",
")",
"for",
"option",
"in",
"group",
"[",
"'options... | Return an OptionGroup object
group -- assumed to be dict with 'name' and 'options' keys
parser -- an optparse Parser | [
"Return",
"an",
"OptionGroup",
"object",
"group",
"--",
"assumed",
"to",
"be",
"dict",
"with",
"name",
"and",
"options",
"keys",
"parser",
"--",
"an",
"optparse",
"Parser"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L46-L56 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | check_install_build_global | def check_install_build_global(options, check_options=None):
# type: (Values, Optional[Values]) -> None
"""Disable wheels if per-setup.py call options are set.
:param options: The OptionParser options to update.
:param check_options: The options to check, if not supplied defaults to
options.
... | python | def check_install_build_global(options, check_options=None):
# type: (Values, Optional[Values]) -> None
"""Disable wheels if per-setup.py call options are set.
:param options: The OptionParser options to update.
:param check_options: The options to check, if not supplied defaults to
options.
... | [
"def",
"check_install_build_global",
"(",
"options",
",",
"check_options",
"=",
"None",
")",
":",
"# type: (Values, Optional[Values]) -> None",
"if",
"check_options",
"is",
"None",
":",
"check_options",
"=",
"options",
"def",
"getname",
"(",
"n",
")",
":",
"return",... | Disable wheels if per-setup.py call options are set.
:param options: The OptionParser options to update.
:param check_options: The options to check, if not supplied defaults to
options. | [
"Disable",
"wheels",
"if",
"per",
"-",
"setup",
".",
"py",
"call",
"options",
"are",
"set",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L59-L79 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | check_dist_restriction | def check_dist_restriction(options, check_target=False):
# type: (Values, bool) -> None
"""Function for determining if custom platform options are allowed.
:param options: The OptionParser options.
:param check_target: Whether or not to check if --target is being used.
"""
dist_restriction_set ... | python | def check_dist_restriction(options, check_target=False):
# type: (Values, bool) -> None
"""Function for determining if custom platform options are allowed.
:param options: The OptionParser options.
:param check_target: Whether or not to check if --target is being used.
"""
dist_restriction_set ... | [
"def",
"check_dist_restriction",
"(",
"options",
",",
"check_target",
"=",
"False",
")",
":",
"# type: (Values, bool) -> None",
"dist_restriction_set",
"=",
"any",
"(",
"[",
"options",
".",
"python_version",
",",
"options",
".",
"platform",
",",
"options",
".",
"a... | Function for determining if custom platform options are allowed.
:param options: The OptionParser options.
:param check_target: Whether or not to check if --target is being used. | [
"Function",
"for",
"determining",
"if",
"custom",
"platform",
"options",
"are",
"allowed",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L82-L119 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | no_cache_dir_callback | def no_cache_dir_callback(option, opt, value, parser):
"""
Process a value provided for the --no-cache-dir option.
This is an optparse.Option callback for the --no-cache-dir option.
"""
# The value argument will be None if --no-cache-dir is passed via the
# command-line, since the option doesn'... | python | def no_cache_dir_callback(option, opt, value, parser):
"""
Process a value provided for the --no-cache-dir option.
This is an optparse.Option callback for the --no-cache-dir option.
"""
# The value argument will be None if --no-cache-dir is passed via the
# command-line, since the option doesn'... | [
"def",
"no_cache_dir_callback",
"(",
"option",
",",
"opt",
",",
"value",
",",
"parser",
")",
":",
"# The value argument will be None if --no-cache-dir is passed via the",
"# command-line, since the option doesn't accept arguments. However,",
"# the value can be non-None if the option is... | Process a value provided for the --no-cache-dir option.
This is an optparse.Option callback for the --no-cache-dir option. | [
"Process",
"a",
"value",
"provided",
"for",
"the",
"--",
"no",
"-",
"cache",
"-",
"dir",
"option",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L546-L570 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | no_use_pep517_callback | def no_use_pep517_callback(option, opt, value, parser):
"""
Process a value provided for the --no-use-pep517 option.
This is an optparse.Option callback for the no_use_pep517 option.
"""
# Since --no-use-pep517 doesn't accept arguments, the value argument
# will be None if --no-use-pep517 is pa... | python | def no_use_pep517_callback(option, opt, value, parser):
"""
Process a value provided for the --no-use-pep517 option.
This is an optparse.Option callback for the no_use_pep517 option.
"""
# Since --no-use-pep517 doesn't accept arguments, the value argument
# will be None if --no-use-pep517 is pa... | [
"def",
"no_use_pep517_callback",
"(",
"option",
",",
"opt",
",",
"value",
",",
"parser",
")",
":",
"# Since --no-use-pep517 doesn't accept arguments, the value argument",
"# will be None if --no-use-pep517 is passed via the command-line.",
"# However, the value can be non-None if the opt... | Process a value provided for the --no-use-pep517 option.
This is an optparse.Option callback for the no_use_pep517 option. | [
"Process",
"a",
"value",
"provided",
"for",
"the",
"--",
"no",
"-",
"use",
"-",
"pep517",
"option",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L623-L643 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | _merge_hash | def _merge_hash(option, opt_str, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name."""
if not parser.values.hashes:
parser.values.hashes = {} # type: ignore
try:
... | python | def _merge_hash(option, opt_str, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name."""
if not parser.values.hashes:
parser.values.hashes = {} # type: ignore
try:
... | [
"def",
"_merge_hash",
"(",
"option",
",",
"opt_str",
",",
"value",
",",
"parser",
")",
":",
"# type: (Option, str, str, OptionParser) -> None",
"if",
"not",
"parser",
".",
"values",
".",
"hashes",
":",
"parser",
".",
"values",
".",
"hashes",
"=",
"{",
"}",
"... | Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name. | [
"Given",
"a",
"value",
"spelled",
"algo",
":",
"digest",
"append",
"the",
"digest",
"to",
"a",
"list",
"pointed",
"to",
"in",
"a",
"dict",
"by",
"the",
"algo",
"name",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L727-L742 | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/pipfile.py | PipfileLoader.populate_source | def populate_source(cls, source):
"""Derive missing values of source from the existing fields."""
# Only URL pararemter is mandatory, let the KeyError be thrown.
if "name" not in source:
source["name"] = get_url_name(source["url"])
if "verify_ssl" not in source:
s... | python | def populate_source(cls, source):
"""Derive missing values of source from the existing fields."""
# Only URL pararemter is mandatory, let the KeyError be thrown.
if "name" not in source:
source["name"] = get_url_name(source["url"])
if "verify_ssl" not in source:
s... | [
"def",
"populate_source",
"(",
"cls",
",",
"source",
")",
":",
"# Only URL pararemter is mandatory, let the KeyError be thrown.",
"if",
"\"name\"",
"not",
"in",
"source",
":",
"source",
"[",
"\"name\"",
"]",
"=",
"get_url_name",
"(",
"source",
"[",
"\"url\"",
"]",
... | Derive missing values of source from the existing fields. | [
"Derive",
"missing",
"values",
"of",
"source",
"from",
"the",
"existing",
"fields",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/pipfile.py#L111-L120 | train |
pypa/pipenv | pipenv/vendor/passa/internals/utils.py | get_pinned_version | def get_pinned_version(ireq):
"""Get the pinned version of an InstallRequirement.
An InstallRequirement is considered pinned if:
- Is not editable
- It has exactly one specifier
- That specifier is "=="
- The version does not contain a wildcard
Examples:
django==1.8 # pinned
... | python | def get_pinned_version(ireq):
"""Get the pinned version of an InstallRequirement.
An InstallRequirement is considered pinned if:
- Is not editable
- It has exactly one specifier
- That specifier is "=="
- The version does not contain a wildcard
Examples:
django==1.8 # pinned
... | [
"def",
"get_pinned_version",
"(",
"ireq",
")",
":",
"try",
":",
"specifier",
"=",
"ireq",
".",
"specifier",
"except",
"AttributeError",
":",
"raise",
"TypeError",
"(",
"\"Expected InstallRequirement, not {}\"",
".",
"format",
"(",
"type",
"(",
"ireq",
")",
".",
... | Get the pinned version of an InstallRequirement.
An InstallRequirement is considered pinned if:
- Is not editable
- It has exactly one specifier
- That specifier is "=="
- The version does not contain a wildcard
Examples:
django==1.8 # pinned
django>1.8 # NOT pinned
... | [
"Get",
"the",
"pinned",
"version",
"of",
"an",
"InstallRequirement",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/utils.py#L20-L59 | train |
pypa/pipenv | pipenv/vendor/passa/internals/utils.py | strip_extras | def strip_extras(requirement):
"""Returns a new requirement object with extras removed.
"""
line = requirement.as_line()
new = type(requirement).from_line(line)
new.extras = None
return new | python | def strip_extras(requirement):
"""Returns a new requirement object with extras removed.
"""
line = requirement.as_line()
new = type(requirement).from_line(line)
new.extras = None
return new | [
"def",
"strip_extras",
"(",
"requirement",
")",
":",
"line",
"=",
"requirement",
".",
"as_line",
"(",
")",
"new",
"=",
"type",
"(",
"requirement",
")",
".",
"from_line",
"(",
"line",
")",
"new",
".",
"extras",
"=",
"None",
"return",
"new"
] | Returns a new requirement object with extras removed. | [
"Returns",
"a",
"new",
"requirement",
"object",
"with",
"extras",
"removed",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/utils.py#L112-L118 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | _subst_vars | def _subst_vars(path, local_vars):
"""In the string `path`, replace tokens like {some.thing} with the
corresponding value from the map `local_vars`.
If there is no corresponding value, leave the token unchanged.
"""
def _replacer(matchobj):
name = matchobj.group(1)
if name in local_... | python | def _subst_vars(path, local_vars):
"""In the string `path`, replace tokens like {some.thing} with the
corresponding value from the map `local_vars`.
If there is no corresponding value, leave the token unchanged.
"""
def _replacer(matchobj):
name = matchobj.group(1)
if name in local_... | [
"def",
"_subst_vars",
"(",
"path",
",",
"local_vars",
")",
":",
"def",
"_replacer",
"(",
"matchobj",
")",
":",
"name",
"=",
"matchobj",
".",
"group",
"(",
"1",
")",
"if",
"name",
"in",
"local_vars",
":",
"return",
"local_vars",
"[",
"name",
"]",
"elif"... | In the string `path`, replace tokens like {some.thing} with the
corresponding value from the map `local_vars`.
If there is no corresponding value, leave the token unchanged. | [
"In",
"the",
"string",
"path",
"replace",
"tokens",
"like",
"{",
"some",
".",
"thing",
"}",
"with",
"the",
"corresponding",
"value",
"from",
"the",
"map",
"local_vars",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L133-L146 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | get_makefile_filename | def get_makefile_filename():
"""Return the path of the Makefile."""
if _PYTHON_BUILD:
return os.path.join(_PROJECT_BASE, "Makefile")
if hasattr(sys, 'abiflags'):
config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
else:
config_dir_name = 'config'
return os.pat... | python | def get_makefile_filename():
"""Return the path of the Makefile."""
if _PYTHON_BUILD:
return os.path.join(_PROJECT_BASE, "Makefile")
if hasattr(sys, 'abiflags'):
config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
else:
config_dir_name = 'config'
return os.pat... | [
"def",
"get_makefile_filename",
"(",
")",
":",
"if",
"_PYTHON_BUILD",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"_PROJECT_BASE",
",",
"\"Makefile\"",
")",
"if",
"hasattr",
"(",
"sys",
",",
"'abiflags'",
")",
":",
"config_dir_name",
"=",
"'config-%s... | Return the path of the Makefile. | [
"Return",
"the",
"path",
"of",
"the",
"Makefile",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L333-L341 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | _init_posix | def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# load the installed Makefile:
makefile = get_makefile_filename()
try:
_parse_makefile(makefile, vars)
except IOError as e:
msg = "invalid Python installation: unable to open %s" % makefile
i... | python | def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# load the installed Makefile:
makefile = get_makefile_filename()
try:
_parse_makefile(makefile, vars)
except IOError as e:
msg = "invalid Python installation: unable to open %s" % makefile
i... | [
"def",
"_init_posix",
"(",
"vars",
")",
":",
"# load the installed Makefile:",
"makefile",
"=",
"get_makefile_filename",
"(",
")",
"try",
":",
"_parse_makefile",
"(",
"makefile",
",",
"vars",
")",
"except",
"IOError",
"as",
"e",
":",
"msg",
"=",
"\"invalid Pytho... | Initialize the module as appropriate for POSIX systems. | [
"Initialize",
"the",
"module",
"as",
"appropriate",
"for",
"POSIX",
"systems",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L344-L369 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | _init_non_posix | def _init_non_posix(vars):
"""Initialize the module as appropriate for NT"""
# set basic install directories
vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include')
vars['SO'] = '.pyd'
vars['EXE'] = '.exe'
vars['VERSION'] =... | python | def _init_non_posix(vars):
"""Initialize the module as appropriate for NT"""
# set basic install directories
vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include')
vars['SO'] = '.pyd'
vars['EXE'] = '.exe'
vars['VERSION'] =... | [
"def",
"_init_non_posix",
"(",
"vars",
")",
":",
"# set basic install directories",
"vars",
"[",
"'LIBDEST'",
"]",
"=",
"get_path",
"(",
"'stdlib'",
")",
"vars",
"[",
"'BINLIBDEST'",
"]",
"=",
"get_path",
"(",
"'platstdlib'",
")",
"vars",
"[",
"'INCLUDEPY'",
"... | Initialize the module as appropriate for NT | [
"Initialize",
"the",
"module",
"as",
"appropriate",
"for",
"NT"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L372-L381 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | parse_config_h | def parse_config_h(fp, vars=None):
"""Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
if vars is None:
vars = {}
define_rx = re.compile("#de... | python | def parse_config_h(fp, vars=None):
"""Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
if vars is None:
vars = {}
define_rx = re.compile("#de... | [
"def",
"parse_config_h",
"(",
"fp",
",",
"vars",
"=",
"None",
")",
":",
"if",
"vars",
"is",
"None",
":",
"vars",
"=",
"{",
"}",
"define_rx",
"=",
"re",
".",
"compile",
"(",
"\"#define ([A-Z][A-Za-z0-9_]+) (.*)\\n\"",
")",
"undef_rx",
"=",
"re",
".",
"com... | Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary. | [
"Parse",
"a",
"config",
".",
"h",
"-",
"style",
"file",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L388-L416 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | get_config_h_filename | def get_config_h_filename():
"""Return the path of pyconfig.h."""
if _PYTHON_BUILD:
if os.name == "nt":
inc_dir = os.path.join(_PROJECT_BASE, "PC")
else:
inc_dir = _PROJECT_BASE
else:
inc_dir = get_path('platinclude')
return os.path.join(inc_dir, 'pyconfig... | python | def get_config_h_filename():
"""Return the path of pyconfig.h."""
if _PYTHON_BUILD:
if os.name == "nt":
inc_dir = os.path.join(_PROJECT_BASE, "PC")
else:
inc_dir = _PROJECT_BASE
else:
inc_dir = get_path('platinclude')
return os.path.join(inc_dir, 'pyconfig... | [
"def",
"get_config_h_filename",
"(",
")",
":",
"if",
"_PYTHON_BUILD",
":",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"inc_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_PROJECT_BASE",
",",
"\"PC\"",
")",
"else",
":",
"inc_dir",
"=",
"_PROJECT_BASE... | Return the path of pyconfig.h. | [
"Return",
"the",
"path",
"of",
"pyconfig",
".",
"h",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L419-L428 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | get_paths | def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
"""Return a mapping containing an install scheme.
``scheme`` is the install scheme name. If not provided, it will
return the default scheme for the current platform.
"""
_ensure_cfg_read()
if expand:
return _expand_var... | python | def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
"""Return a mapping containing an install scheme.
``scheme`` is the install scheme name. If not provided, it will
return the default scheme for the current platform.
"""
_ensure_cfg_read()
if expand:
return _expand_var... | [
"def",
"get_paths",
"(",
"scheme",
"=",
"_get_default_scheme",
"(",
")",
",",
"vars",
"=",
"None",
",",
"expand",
"=",
"True",
")",
":",
"_ensure_cfg_read",
"(",
")",
"if",
"expand",
":",
"return",
"_expand_vars",
"(",
"scheme",
",",
"vars",
")",
"else",... | Return a mapping containing an install scheme.
``scheme`` is the install scheme name. If not provided, it will
return the default scheme for the current platform. | [
"Return",
"a",
"mapping",
"containing",
"an",
"install",
"scheme",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L442-L452 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | get_path | def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):
"""Return a path corresponding to the scheme.
``scheme`` is the install scheme name.
"""
return get_paths(scheme, vars, expand)[name] | python | def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):
"""Return a path corresponding to the scheme.
``scheme`` is the install scheme name.
"""
return get_paths(scheme, vars, expand)[name] | [
"def",
"get_path",
"(",
"name",
",",
"scheme",
"=",
"_get_default_scheme",
"(",
")",
",",
"vars",
"=",
"None",
",",
"expand",
"=",
"True",
")",
":",
"return",
"get_paths",
"(",
"scheme",
",",
"vars",
",",
"expand",
")",
"[",
"name",
"]"
] | Return a path corresponding to the scheme.
``scheme`` is the install scheme name. | [
"Return",
"a",
"path",
"corresponding",
"to",
"the",
"scheme",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L455-L460 | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/sysconfig.py | _main | def _main():
"""Display all information sysconfig detains."""
print('Platform: "%s"' % get_platform())
print('Python version: "%s"' % get_python_version())
print('Current installation scheme: "%s"' % _get_default_scheme())
print()
_print_dict('Paths', get_paths())
print()
_print_dict('Va... | python | def _main():
"""Display all information sysconfig detains."""
print('Platform: "%s"' % get_platform())
print('Python version: "%s"' % get_python_version())
print('Current installation scheme: "%s"' % _get_default_scheme())
print()
_print_dict('Paths', get_paths())
print()
_print_dict('Va... | [
"def",
"_main",
"(",
")",
":",
"print",
"(",
"'Platform: \"%s\"'",
"%",
"get_platform",
"(",
")",
")",
"print",
"(",
"'Python version: \"%s\"'",
"%",
"get_python_version",
"(",
")",
")",
"print",
"(",
"'Current installation scheme: \"%s\"'",
"%",
"_get_default_schem... | Display all information sysconfig detains. | [
"Display",
"all",
"information",
"sysconfig",
"detains",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/sysconfig.py#L776-L784 | train |
pypa/pipenv | pipenv/vendor/tomlkit/source.py | Source.inc | def inc(self, exception=None): # type: (Optional[ParseError.__class__]) -> bool
"""
Increments the parser if the end of the input has not been reached.
Returns whether or not it was able to advance.
"""
try:
self._idx, self._current = next(self._chars)
r... | python | def inc(self, exception=None): # type: (Optional[ParseError.__class__]) -> bool
"""
Increments the parser if the end of the input has not been reached.
Returns whether or not it was able to advance.
"""
try:
self._idx, self._current = next(self._chars)
r... | [
"def",
"inc",
"(",
"self",
",",
"exception",
"=",
"None",
")",
":",
"# type: (Optional[ParseError.__class__]) -> bool",
"try",
":",
"self",
".",
"_idx",
",",
"self",
".",
"_current",
"=",
"next",
"(",
"self",
".",
"_chars",
")",
"return",
"True",
"except",
... | Increments the parser if the end of the input has not been reached.
Returns whether or not it was able to advance. | [
"Increments",
"the",
"parser",
"if",
"the",
"end",
"of",
"the",
"input",
"has",
"not",
"been",
"reached",
".",
"Returns",
"whether",
"or",
"not",
"it",
"was",
"able",
"to",
"advance",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/source.py#L117-L132 | train |
pypa/pipenv | pipenv/vendor/tomlkit/source.py | Source.inc_n | def inc_n(self, n, exception=None): # type: (int, Exception) -> bool
"""
Increments the parser by n characters
if the end of the input has not been reached.
"""
for _ in range(n):
if not self.inc(exception=exception):
return False
return True | python | def inc_n(self, n, exception=None): # type: (int, Exception) -> bool
"""
Increments the parser by n characters
if the end of the input has not been reached.
"""
for _ in range(n):
if not self.inc(exception=exception):
return False
return True | [
"def",
"inc_n",
"(",
"self",
",",
"n",
",",
"exception",
"=",
"None",
")",
":",
"# type: (int, Exception) -> bool",
"for",
"_",
"in",
"range",
"(",
"n",
")",
":",
"if",
"not",
"self",
".",
"inc",
"(",
"exception",
"=",
"exception",
")",
":",
"return",
... | Increments the parser by n characters
if the end of the input has not been reached. | [
"Increments",
"the",
"parser",
"by",
"n",
"characters",
"if",
"the",
"end",
"of",
"the",
"input",
"has",
"not",
"been",
"reached",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/source.py#L134-L143 | train |
pypa/pipenv | pipenv/vendor/tomlkit/source.py | Source.consume | def consume(self, chars, min=0, max=-1):
"""
Consume chars until min/max is satisfied is valid.
"""
while self.current in chars and max != 0:
min -= 1
max -= 1
if not self.inc():
break
# failed to consume minimum number of char... | python | def consume(self, chars, min=0, max=-1):
"""
Consume chars until min/max is satisfied is valid.
"""
while self.current in chars and max != 0:
min -= 1
max -= 1
if not self.inc():
break
# failed to consume minimum number of char... | [
"def",
"consume",
"(",
"self",
",",
"chars",
",",
"min",
"=",
"0",
",",
"max",
"=",
"-",
"1",
")",
":",
"while",
"self",
".",
"current",
"in",
"chars",
"and",
"max",
"!=",
"0",
":",
"min",
"-=",
"1",
"max",
"-=",
"1",
"if",
"not",
"self",
"."... | Consume chars until min/max is satisfied is valid. | [
"Consume",
"chars",
"until",
"min",
"/",
"max",
"is",
"satisfied",
"is",
"valid",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/source.py#L145-L157 | train |
pypa/pipenv | pipenv/vendor/tomlkit/source.py | Source.parse_error | def parse_error(
self, exception=ParseError, *args
): # type: (ParseError.__class__, ...) -> ParseError
"""
Creates a generic "parse error" at the current position.
"""
line, col = self._to_linecol()
return exception(line, col, *args) | python | def parse_error(
self, exception=ParseError, *args
): # type: (ParseError.__class__, ...) -> ParseError
"""
Creates a generic "parse error" at the current position.
"""
line, col = self._to_linecol()
return exception(line, col, *args) | [
"def",
"parse_error",
"(",
"self",
",",
"exception",
"=",
"ParseError",
",",
"*",
"args",
")",
":",
"# type: (ParseError.__class__, ...) -> ParseError",
"line",
",",
"col",
"=",
"self",
".",
"_to_linecol",
"(",
")",
"return",
"exception",
"(",
"line",
",",
"co... | Creates a generic "parse error" at the current position. | [
"Creates",
"a",
"generic",
"parse",
"error",
"at",
"the",
"current",
"position",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/source.py#L171-L179 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/commands/__init__.py | get_summaries | def get_summaries(ordered=True):
"""Yields sorted (command name, command summary) tuples."""
if ordered:
cmditems = _sort_commands(commands_dict, commands_order)
else:
cmditems = commands_dict.items()
for name, command_class in cmditems:
yield (name, command_class.summary) | python | def get_summaries(ordered=True):
"""Yields sorted (command name, command summary) tuples."""
if ordered:
cmditems = _sort_commands(commands_dict, commands_order)
else:
cmditems = commands_dict.items()
for name, command_class in cmditems:
yield (name, command_class.summary) | [
"def",
"get_summaries",
"(",
"ordered",
"=",
"True",
")",
":",
"if",
"ordered",
":",
"cmditems",
"=",
"_sort_commands",
"(",
"commands_dict",
",",
"commands_order",
")",
"else",
":",
"cmditems",
"=",
"commands_dict",
".",
"items",
"(",
")",
"for",
"name",
... | Yields sorted (command name, command summary) tuples. | [
"Yields",
"sorted",
"(",
"command",
"name",
"command",
"summary",
")",
"tuples",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/commands/__init__.py#L45-L54 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/commands/__init__.py | get_similar_commands | def get_similar_commands(name):
"""Command name auto-correct."""
from difflib import get_close_matches
name = name.lower()
close_commands = get_close_matches(name, commands_dict.keys())
if close_commands:
return close_commands[0]
else:
return False | python | def get_similar_commands(name):
"""Command name auto-correct."""
from difflib import get_close_matches
name = name.lower()
close_commands = get_close_matches(name, commands_dict.keys())
if close_commands:
return close_commands[0]
else:
return False | [
"def",
"get_similar_commands",
"(",
"name",
")",
":",
"from",
"difflib",
"import",
"get_close_matches",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"close_commands",
"=",
"get_close_matches",
"(",
"name",
",",
"commands_dict",
".",
"keys",
"(",
")",
")",
"i... | Command name auto-correct. | [
"Command",
"name",
"auto",
"-",
"correct",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/commands/__init__.py#L57-L68 | train |
pypa/pipenv | pipenv/vendor/jinja2/ext.py | Extension.bind | def bind(self, environment):
"""Create a copy of this extension bound to another environment."""
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.environment = environment
return rv | python | def bind(self, environment):
"""Create a copy of this extension bound to another environment."""
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.environment = environment
return rv | [
"def",
"bind",
"(",
"self",
",",
"environment",
")",
":",
"rv",
"=",
"object",
".",
"__new__",
"(",
"self",
".",
"__class__",
")",
"rv",
".",
"__dict__",
".",
"update",
"(",
"self",
".",
"__dict__",
")",
"rv",
".",
"environment",
"=",
"environment",
... | Create a copy of this extension bound to another environment. | [
"Create",
"a",
"copy",
"of",
"this",
"extension",
"bound",
"to",
"another",
"environment",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/ext.py#L75-L80 | train |
pypa/pipenv | pipenv/vendor/jinja2/ext.py | Extension.attr | def attr(self, name, lineno=None):
"""Return an attribute node for the current extension. This is useful
to pass constants on extensions to generated template code.
::
self.attr('_my_attribute', lineno=lineno)
"""
return nodes.ExtensionAttribute(self.identifier, na... | python | def attr(self, name, lineno=None):
"""Return an attribute node for the current extension. This is useful
to pass constants on extensions to generated template code.
::
self.attr('_my_attribute', lineno=lineno)
"""
return nodes.ExtensionAttribute(self.identifier, na... | [
"def",
"attr",
"(",
"self",
",",
"name",
",",
"lineno",
"=",
"None",
")",
":",
"return",
"nodes",
".",
"ExtensionAttribute",
"(",
"self",
".",
"identifier",
",",
"name",
",",
"lineno",
"=",
"lineno",
")"
] | Return an attribute node for the current extension. This is useful
to pass constants on extensions to generated template code.
::
self.attr('_my_attribute', lineno=lineno) | [
"Return",
"an",
"attribute",
"node",
"for",
"the",
"current",
"extension",
".",
"This",
"is",
"useful",
"to",
"pass",
"constants",
"on",
"extensions",
"to",
"generated",
"template",
"code",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/ext.py#L109-L117 | train |
pypa/pipenv | pipenv/vendor/jinja2/ext.py | Extension.call_method | def call_method(self, name, args=None, kwargs=None, dyn_args=None,
dyn_kwargs=None, lineno=None):
"""Call a method of the extension. This is a shortcut for
:meth:`attr` + :class:`jinja2.nodes.Call`.
"""
if args is None:
args = []
if kwargs is None... | python | def call_method(self, name, args=None, kwargs=None, dyn_args=None,
dyn_kwargs=None, lineno=None):
"""Call a method of the extension. This is a shortcut for
:meth:`attr` + :class:`jinja2.nodes.Call`.
"""
if args is None:
args = []
if kwargs is None... | [
"def",
"call_method",
"(",
"self",
",",
"name",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"dyn_args",
"=",
"None",
",",
"dyn_kwargs",
"=",
"None",
",",
"lineno",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
... | Call a method of the extension. This is a shortcut for
:meth:`attr` + :class:`jinja2.nodes.Call`. | [
"Call",
"a",
"method",
"of",
"the",
"extension",
".",
"This",
"is",
"a",
"shortcut",
"for",
":",
"meth",
":",
"attr",
"+",
":",
"class",
":",
"jinja2",
".",
"nodes",
".",
"Call",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/ext.py#L119-L129 | train |
pypa/pipenv | pipenv/vendor/jinja2/ext.py | InternationalizationExtension.parse | def parse(self, parser):
"""Parse a translatable tag."""
lineno = next(parser.stream).lineno
num_called_num = False
# find all the variables referenced. Additionally a variable can be
# defined in the body of the trans block too, but this is checked at
# a later state.
... | python | def parse(self, parser):
"""Parse a translatable tag."""
lineno = next(parser.stream).lineno
num_called_num = False
# find all the variables referenced. Additionally a variable can be
# defined in the body of the trans block too, but this is checked at
# a later state.
... | [
"def",
"parse",
"(",
"self",
",",
"parser",
")",
":",
"lineno",
"=",
"next",
"(",
"parser",
".",
"stream",
")",
".",
"lineno",
"num_called_num",
"=",
"False",
"# find all the variables referenced. Additionally a variable can be",
"# defined in the body of the trans block... | Parse a translatable tag. | [
"Parse",
"a",
"translatable",
"tag",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/ext.py#L217-L320 | train |
pypa/pipenv | pipenv/vendor/jinja2/ext.py | InternationalizationExtension._parse_block | def _parse_block(self, parser, allow_pluralize):
"""Parse until the next block tag with a given name."""
referenced = []
buf = []
while 1:
if parser.stream.current.type == 'data':
buf.append(parser.stream.current.value.replace('%', '%%'))
next(... | python | def _parse_block(self, parser, allow_pluralize):
"""Parse until the next block tag with a given name."""
referenced = []
buf = []
while 1:
if parser.stream.current.type == 'data':
buf.append(parser.stream.current.value.replace('%', '%%'))
next(... | [
"def",
"_parse_block",
"(",
"self",
",",
"parser",
",",
"allow_pluralize",
")",
":",
"referenced",
"=",
"[",
"]",
"buf",
"=",
"[",
"]",
"while",
"1",
":",
"if",
"parser",
".",
"stream",
".",
"current",
".",
"type",
"==",
"'data'",
":",
"buf",
".",
... | Parse until the next block tag with a given name. | [
"Parse",
"until",
"the",
"next",
"block",
"tag",
"with",
"a",
"given",
"name",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/ext.py#L325-L355 | train |
pypa/pipenv | pipenv/vendor/jinja2/ext.py | InternationalizationExtension._make_node | def _make_node(self, singular, plural, variables, plural_expr,
vars_referenced, num_called_num):
"""Generates a useful node from the data provided."""
# no variables referenced? no need to escape for old style
# gettext invocations only if there are vars.
if not vars_... | python | def _make_node(self, singular, plural, variables, plural_expr,
vars_referenced, num_called_num):
"""Generates a useful node from the data provided."""
# no variables referenced? no need to escape for old style
# gettext invocations only if there are vars.
if not vars_... | [
"def",
"_make_node",
"(",
"self",
",",
"singular",
",",
"plural",
",",
"variables",
",",
"plural_expr",
",",
"vars_referenced",
",",
"num_called_num",
")",
":",
"# no variables referenced? no need to escape for old style",
"# gettext invocations only if there are vars.",
"if... | Generates a useful node from the data provided. | [
"Generates",
"a",
"useful",
"node",
"from",
"the",
"data",
"provided",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/ext.py#L357-L403 | train |
pypa/pipenv | pipenv/vendor/dotenv/__init__.py | get_cli_string | def get_cli_string(path=None, action=None, key=None, value=None, quote=None):
"""Returns a string suitable for running as a shell script.
Useful for converting a arguments passed to a fabric task
to be passed to a `local` or `run` command.
"""
command = ['dotenv']
if quote:
command.appe... | python | def get_cli_string(path=None, action=None, key=None, value=None, quote=None):
"""Returns a string suitable for running as a shell script.
Useful for converting a arguments passed to a fabric task
to be passed to a `local` or `run` command.
"""
command = ['dotenv']
if quote:
command.appe... | [
"def",
"get_cli_string",
"(",
"path",
"=",
"None",
",",
"action",
"=",
"None",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
",",
"quote",
"=",
"None",
")",
":",
"command",
"=",
"[",
"'dotenv'",
"]",
"if",
"quote",
":",
"command",
".",
"appen... | Returns a string suitable for running as a shell script.
Useful for converting a arguments passed to a fabric task
to be passed to a `local` or `run` command. | [
"Returns",
"a",
"string",
"suitable",
"for",
"running",
"as",
"a",
"shell",
"script",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/dotenv/__init__.py#L9-L30 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | merge_hooks | def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get('response') == []:
... | python | def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get('response') == []:
... | [
"def",
"merge_hooks",
"(",
"request_hooks",
",",
"session_hooks",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_hooks",
"is",
"None",
"or",
"session_hooks",
".",
"get",
"(",
"'response'",
")",
"==",
"[",
"]",
":",
"return",
"request_hooks",
... | Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely. | [
"Properly",
"merges",
"both",
"requests",
"and",
"session",
"hooks",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L80-L92 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | SessionRedirectMixin.get_redirect_target | def get_redirect_target(self, resp):
"""Receives a Response. Returns a redirect URI or ``None``"""
# Due to the nature of how requests processes redirects this method will
# be called at least once upon the original response and at least twice
# on each subsequent redirect response (if a... | python | def get_redirect_target(self, resp):
"""Receives a Response. Returns a redirect URI or ``None``"""
# Due to the nature of how requests processes redirects this method will
# be called at least once upon the original response and at least twice
# on each subsequent redirect response (if a... | [
"def",
"get_redirect_target",
"(",
"self",
",",
"resp",
")",
":",
"# Due to the nature of how requests processes redirects this method will",
"# be called at least once upon the original response and at least twice",
"# on each subsequent redirect response (if any).",
"# If a custom mixin is u... | Receives a Response. Returns a redirect URI or ``None`` | [
"Receives",
"a",
"Response",
".",
"Returns",
"a",
"redirect",
"URI",
"or",
"None"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L97-L116 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | SessionRedirectMixin.should_strip_auth | def should_strip_auth(self, old_url, new_url):
"""Decide whether Authorization header should be removed when redirecting"""
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow h... | python | def should_strip_auth(self, old_url, new_url):
"""Decide whether Authorization header should be removed when redirecting"""
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow h... | [
"def",
"should_strip_auth",
"(",
"self",
",",
"old_url",
",",
"new_url",
")",
":",
"old_parsed",
"=",
"urlparse",
"(",
"old_url",
")",
"new_parsed",
"=",
"urlparse",
"(",
"new_url",
")",
"if",
"old_parsed",
".",
"hostname",
"!=",
"new_parsed",
".",
"hostname... | Decide whether Authorization header should be removed when redirecting | [
"Decide",
"whether",
"Authorization",
"header",
"should",
"be",
"removed",
"when",
"redirecting"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L118-L141 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | SessionRedirectMixin.rebuild_auth | def rebuild_auth(self, prepared_request, response):
"""When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
"""
headers = pr... | python | def rebuild_auth(self, prepared_request, response):
"""When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
"""
headers = pr... | [
"def",
"rebuild_auth",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
".",
"url",
"if",
"'Authorization'",
"in",
"headers",
"and",
"self",
".",
"should_strip_au... | When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss. | [
"When",
"being",
"redirected",
"we",
"may",
"want",
"to",
"strip",
"authentication",
"from",
"the",
"request",
"to",
"avoid",
"leaking",
"credentials",
".",
"This",
"method",
"intelligently",
"removes",
"and",
"reapplies",
"authentication",
"where",
"possible",
"t... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L256-L274 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | SessionRedirectMixin.rebuild_proxies | def rebuild_proxies(self, prepared_request, proxies):
"""This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in c... | python | def rebuild_proxies(self, prepared_request, proxies):
"""This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in c... | [
"def",
"rebuild_proxies",
"(",
"self",
",",
"prepared_request",
",",
"proxies",
")",
":",
"proxies",
"=",
"proxies",
"if",
"proxies",
"is",
"not",
"None",
"else",
"{",
"}",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
"... | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).
... | [
"This",
"method",
"re",
"-",
"evaluates",
"the",
"proxy",
"configuration",
"by",
"considering",
"the",
"environment",
"variables",
".",
"If",
"we",
"are",
"redirected",
"to",
"a",
"URL",
"covered",
"by",
"NO_PROXY",
"we",
"strip",
"the",
"proxy",
"configuratio... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L276-L315 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.prepare_request | def prepare_request(self, request):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class... | python | def prepare_request(self, request):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class... | [
"def",
"prepare_request",
"(",
"self",
",",
"request",
")",
":",
"cookies",
"=",
"request",
".",
"cookies",
"or",
"{",
"}",
"# Bootstrap CookieJar.",
"if",
"not",
"isinstance",
"(",
"cookies",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"cookies",
"=",
"... | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
... | [
"Constructs",
"a",
":",
"class",
":",
"PreparedRequest",
"<PreparedRequest",
">",
"for",
"transmission",
"and",
"returns",
"it",
".",
"The",
":",
"class",
":",
"PreparedRequest",
"has",
"settings",
"merged",
"from",
"the",
":",
"class",
":",
"Request",
"<Reque... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L426-L464 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.request | def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
"""Constructs a :class:`Request <Request>`, prepares it and... | python | def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
"""Constructs a :class:`Request <Request>`, prepares it and... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"N... | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the... | [
"Constructs",
"a",
":",
"class",
":",
"Request",
"<Request",
">",
"prepares",
"it",
"and",
"sends",
"it",
".",
"Returns",
":",
"class",
":",
"Response",
"<Response",
">",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L466-L535 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.get | def get(self, url, **kwargs):
r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects',... | python | def get(self, url, **kwargs):
r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects',... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'GET'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response | [
"r",
"Sends",
"a",
"GET",
"request",
".",
"Returns",
":",
"class",
":",
"Response",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L537-L546 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.options | def options(self, url, **kwargs):
r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_red... | python | def options(self, url, **kwargs):
r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_red... | [
"def",
"options",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'OPTIONS'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response | [
"r",
"Sends",
"a",
"OPTIONS",
"request",
".",
"Returns",
":",
"class",
":",
"Response",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L548-L557 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.head | def head(self, url, **kwargs):
r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects... | python | def head(self, url, **kwargs):
r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects... | [
"def",
"head",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"self",
".",
"request",
"(",
"'HEAD'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response | [
"r",
"Sends",
"a",
"HEAD",
"request",
".",
"Returns",
":",
"class",
":",
"Response",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L559-L568 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.send | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | python | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults that the hooks can utilize to ensure they always have",
"# the correct parameters to reproduce the previous request.",
"kwargs",
".",
"setdefault",
"(",
"'stream'",
",",
"self",
"... | Send a given PreparedRequest.
:rtype: requests.Response | [
"Send",
"a",
"given",
"PreparedRequest",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L617-L688 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.merge_environment_settings | def merge_environment_settings(self, url, proxies, stream, verify, cert):
"""
Check the environment and merge it with some settings.
:rtype: dict
"""
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
... | python | def merge_environment_settings(self, url, proxies, stream, verify, cert):
"""
Check the environment and merge it with some settings.
:rtype: dict
"""
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
... | [
"def",
"merge_environment_settings",
"(",
"self",
",",
"url",
",",
"proxies",
",",
"stream",
",",
"verify",
",",
"cert",
")",
":",
"# Gather clues from the surrounding environment.",
"if",
"self",
".",
"trust_env",
":",
"# Set environment's proxies.",
"no_proxy",
"=",... | Check the environment and merge it with some settings.
:rtype: dict | [
"Check",
"the",
"environment",
"and",
"merge",
"it",
"with",
"some",
"settings",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L690-L717 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.get_adapter | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
... | python | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
... | [
"def",
"get_adapter",
"(",
"self",
",",
"url",
")",
":",
"for",
"(",
"prefix",
",",
"adapter",
")",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"prefix",
".",
"lower",
"... | Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter | [
"Returns",
"the",
"appropriate",
"connection",
"adapter",
"for",
"the",
"given",
"URL",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L719-L731 | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | Session.mount | def mount(self, prefix, adapter):
"""Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
"""
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
... | python | def mount(self, prefix, adapter):
"""Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
"""
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
... | [
"def",
"mount",
"(",
"self",
",",
"prefix",
",",
"adapter",
")",
":",
"self",
".",
"adapters",
"[",
"prefix",
"]",
"=",
"adapter",
"keys_to_move",
"=",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"adapters",
"if",
"len",
"(",
"k",
")",
"<",
"len",
"... | Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length. | [
"Registers",
"a",
"connection",
"adapter",
"to",
"a",
"prefix",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L738-L747 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/utils/compat.py | console_to_str | def console_to_str(data):
# type: (bytes) -> Text
"""Return a string, safe for output, of subprocess output.
We assume the data is in the locale preferred encoding.
If it won't decode properly, we warn the user but decode as
best we can.
We also ensure that the output can be safely written to
... | python | def console_to_str(data):
# type: (bytes) -> Text
"""Return a string, safe for output, of subprocess output.
We assume the data is in the locale preferred encoding.
If it won't decode properly, we warn the user but decode as
best we can.
We also ensure that the output can be safely written to
... | [
"def",
"console_to_str",
"(",
"data",
")",
":",
"# type: (bytes) -> Text",
"# First, get the encoding we assume. This is the preferred",
"# encoding for the locale, unless that is not found, or",
"# it is ASCII, in which case assume UTF-8",
"encoding",
"=",
"locale",
".",
"getpreferreden... | Return a string, safe for output, of subprocess output.
We assume the data is in the locale preferred encoding.
If it won't decode properly, we warn the user but decode as
best we can.
We also ensure that the output can be safely written to
standard output without encoding errors. | [
"Return",
"a",
"string",
"safe",
"for",
"output",
"of",
"subprocess",
"output",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/compat.py#L75-L127 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/utils/compat.py | get_path_uid | def get_path_uid(path):
# type: (str) -> int
"""
Return path's uid.
Does not follow symlinks:
https://github.com/pypa/pip/pull/935#discussion_r5307003
Placed this function in compat due to differences on AIX and
Jython, that should eventually go away.
:raises OSError: When path is... | python | def get_path_uid(path):
# type: (str) -> int
"""
Return path's uid.
Does not follow symlinks:
https://github.com/pypa/pip/pull/935#discussion_r5307003
Placed this function in compat due to differences on AIX and
Jython, that should eventually go away.
:raises OSError: When path is... | [
"def",
"get_path_uid",
"(",
"path",
")",
":",
"# type: (str) -> int",
"if",
"hasattr",
"(",
"os",
",",
"'O_NOFOLLOW'",
")",
":",
"fd",
"=",
"os",
".",
"open",
"(",
"path",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_NOFOLLOW",
")",
"file_uid",
"=",
... | Return path's uid.
Does not follow symlinks:
https://github.com/pypa/pip/pull/935#discussion_r5307003
Placed this function in compat due to differences on AIX and
Jython, that should eventually go away.
:raises OSError: When path is a symlink or can't be read. | [
"Return",
"path",
"s",
"uid",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/compat.py#L146-L173 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/utils/compat.py | expanduser | def expanduser(path):
# type: (str) -> str
"""
Expand ~ and ~user constructions.
Includes a workaround for https://bugs.python.org/issue14768
"""
expanded = os.path.expanduser(path)
if path.startswith('~/') and expanded.startswith('//'):
expanded = expanded[1:]
return expanded | python | def expanduser(path):
# type: (str) -> str
"""
Expand ~ and ~user constructions.
Includes a workaround for https://bugs.python.org/issue14768
"""
expanded = os.path.expanduser(path)
if path.startswith('~/') and expanded.startswith('//'):
expanded = expanded[1:]
return expanded | [
"def",
"expanduser",
"(",
"path",
")",
":",
"# type: (str) -> str",
"expanded",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
"if",
"path",
".",
"startswith",
"(",
"'~/'",
")",
"and",
"expanded",
".",
"startswith",
"(",
"'//'",
")",
":",
... | Expand ~ and ~user constructions.
Includes a workaround for https://bugs.python.org/issue14768 | [
"Expand",
"~",
"and",
"~user",
"constructions",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/compat.py#L188-L198 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/utils/compat.py | samefile | def samefile(file1, file2):
# type: (str, str) -> bool
"""Provide an alternative for os.path.samefile on Windows/Python2"""
if hasattr(os.path, 'samefile'):
return os.path.samefile(file1, file2)
else:
path1 = os.path.normcase(os.path.abspath(file1))
path2 = os.path.normcase(os.pa... | python | def samefile(file1, file2):
# type: (str, str) -> bool
"""Provide an alternative for os.path.samefile on Windows/Python2"""
if hasattr(os.path, 'samefile'):
return os.path.samefile(file1, file2)
else:
path1 = os.path.normcase(os.path.abspath(file1))
path2 = os.path.normcase(os.pa... | [
"def",
"samefile",
"(",
"file1",
",",
"file2",
")",
":",
"# type: (str, str) -> bool",
"if",
"hasattr",
"(",
"os",
".",
"path",
",",
"'samefile'",
")",
":",
"return",
"os",
".",
"path",
".",
"samefile",
"(",
"file1",
",",
"file2",
")",
"else",
":",
"pa... | Provide an alternative for os.path.samefile on Windows/Python2 | [
"Provide",
"an",
"alternative",
"for",
"os",
".",
"path",
".",
"samefile",
"on",
"Windows",
"/",
"Python2"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/compat.py#L214-L222 | train |
pypa/pipenv | pipenv/resolver.py | Entry.ensure_least_updates_possible | def ensure_least_updates_possible(self):
"""
Mutate the current entry to ensure that we are making the smallest amount of
changes possible to the existing lockfile -- this will keep the old locked
versions of packages if they satisfy new constraints.
:return: None
"""
... | python | def ensure_least_updates_possible(self):
"""
Mutate the current entry to ensure that we are making the smallest amount of
changes possible to the existing lockfile -- this will keep the old locked
versions of packages if they satisfy new constraints.
:return: None
"""
... | [
"def",
"ensure_least_updates_possible",
"(",
"self",
")",
":",
"constraints",
"=",
"self",
".",
"get_constraints",
"(",
")",
"can_use_original",
"=",
"True",
"can_use_updated",
"=",
"True",
"satisfied_by_versions",
"=",
"set",
"(",
")",
"for",
"constraint",
"in",
... | Mutate the current entry to ensure that we are making the smallest amount of
changes possible to the existing lockfile -- this will keep the old locked
versions of packages if they satisfy new constraints.
:return: None | [
"Mutate",
"the",
"current",
"entry",
"to",
"ensure",
"that",
"we",
"are",
"making",
"the",
"smallest",
"amount",
"of",
"changes",
"possible",
"to",
"the",
"existing",
"lockfile",
"--",
"this",
"will",
"keep",
"the",
"old",
"locked",
"versions",
"of",
"packag... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/resolver.py#L314-L361 | train |
pypa/pipenv | pipenv/resolver.py | Entry.get_constraints | def get_constraints(self):
"""
Retrieve all of the relevant constraints, aggregated from the pipfile, resolver,
and parent dependencies and their respective conflict resolution where possible.
:return: A set of **InstallRequirement** instances representing constraints
:rtype: Se... | python | def get_constraints(self):
"""
Retrieve all of the relevant constraints, aggregated from the pipfile, resolver,
and parent dependencies and their respective conflict resolution where possible.
:return: A set of **InstallRequirement** instances representing constraints
:rtype: Se... | [
"def",
"get_constraints",
"(",
"self",
")",
":",
"constraints",
"=",
"{",
"c",
"for",
"c",
"in",
"self",
".",
"resolver",
".",
"parsed_constraints",
"if",
"c",
"and",
"c",
".",
"name",
"==",
"self",
".",
"entry",
".",
"name",
"}",
"pipfile_constraint",
... | Retrieve all of the relevant constraints, aggregated from the pipfile, resolver,
and parent dependencies and their respective conflict resolution where possible.
:return: A set of **InstallRequirement** instances representing constraints
:rtype: Set | [
"Retrieve",
"all",
"of",
"the",
"relevant",
"constraints",
"aggregated",
"from",
"the",
"pipfile",
"resolver",
"and",
"parent",
"dependencies",
"and",
"their",
"respective",
"conflict",
"resolution",
"where",
"possible",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/resolver.py#L363-L378 | train |
pypa/pipenv | pipenv/resolver.py | Entry.constraint_from_parent_conflicts | def constraint_from_parent_conflicts(self):
"""
Given a resolved entry with multiple parent dependencies with different
constraints, searches for the resolution that satisfies all of the parent
constraints.
:return: A new **InstallRequirement** satisfying all parent constraints
... | python | def constraint_from_parent_conflicts(self):
"""
Given a resolved entry with multiple parent dependencies with different
constraints, searches for the resolution that satisfies all of the parent
constraints.
:return: A new **InstallRequirement** satisfying all parent constraints
... | [
"def",
"constraint_from_parent_conflicts",
"(",
"self",
")",
":",
"# ensure that we satisfy the parent dependencies of this dep",
"from",
"pipenv",
".",
"vendor",
".",
"packaging",
".",
"specifiers",
"import",
"Specifier",
"parent_dependencies",
"=",
"set",
"(",
")",
"has... | Given a resolved entry with multiple parent dependencies with different
constraints, searches for the resolution that satisfies all of the parent
constraints.
:return: A new **InstallRequirement** satisfying all parent constraints
:raises: :exc:`~pipenv.exceptions.DependencyConflict` if... | [
"Given",
"a",
"resolved",
"entry",
"with",
"multiple",
"parent",
"dependencies",
"with",
"different",
"constraints",
"searches",
"for",
"the",
"resolution",
"that",
"satisfies",
"all",
"of",
"the",
"parent",
"constraints",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/resolver.py#L391-L433 | train |
pypa/pipenv | pipenv/resolver.py | Entry.validate_constraints | def validate_constraints(self):
"""
Retrieves the full set of available constraints and iterate over them, validating
that they exist and that they are not causing unresolvable conflicts.
:return: True if the constraints are satisfied by the resolution provided
:raises: :exc:`pi... | python | def validate_constraints(self):
"""
Retrieves the full set of available constraints and iterate over them, validating
that they exist and that they are not causing unresolvable conflicts.
:return: True if the constraints are satisfied by the resolution provided
:raises: :exc:`pi... | [
"def",
"validate_constraints",
"(",
"self",
")",
":",
"constraints",
"=",
"self",
".",
"get_constraints",
"(",
")",
"for",
"constraint",
"in",
"constraints",
":",
"try",
":",
"constraint",
".",
"check_if_exists",
"(",
"False",
")",
"except",
"Exception",
":",
... | Retrieves the full set of available constraints and iterate over them, validating
that they exist and that they are not causing unresolvable conflicts.
:return: True if the constraints are satisfied by the resolution provided
:raises: :exc:`pipenv.exceptions.DependencyConflict` if the constrain... | [
"Retrieves",
"the",
"full",
"set",
"of",
"available",
"constraints",
"and",
"iterate",
"over",
"them",
"validating",
"that",
"they",
"exist",
"and",
"that",
"they",
"are",
"not",
"causing",
"unresolvable",
"conflicts",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/resolver.py#L435-L456 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | inject_into_urllib3 | def inject_into_urllib3():
"""
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
"""
util.ssl_.SSLContext = SecureTransportContext
util.HAS_SNI = HAS_SNI
util.ssl_.HAS_SNI = HAS_SNI
util.IS_SECURETRANSPORT = True
util.ssl_.IS_SECURETRANSPORT = True | python | def inject_into_urllib3():
"""
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
"""
util.ssl_.SSLContext = SecureTransportContext
util.HAS_SNI = HAS_SNI
util.ssl_.HAS_SNI = HAS_SNI
util.IS_SECURETRANSPORT = True
util.ssl_.IS_SECURETRANSPORT = True | [
"def",
"inject_into_urllib3",
"(",
")",
":",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"SecureTransportContext",
"util",
".",
"HAS_SNI",
"=",
"HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",
"HAS_SNI",
"util",
".",
"IS_SECURETRANSPORT",
"=",
"True",
"... | Monkey-patch urllib3 with SecureTransport-backed SSL-support. | [
"Monkey",
"-",
"patch",
"urllib3",
"with",
"SecureTransport",
"-",
"backed",
"SSL",
"-",
"support",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L154-L162 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | extract_from_urllib3 | def extract_from_urllib3():
"""
Undo monkey-patching by :func:`inject_into_urllib3`.
"""
util.ssl_.SSLContext = orig_util_SSLContext
util.HAS_SNI = orig_util_HAS_SNI
util.ssl_.HAS_SNI = orig_util_HAS_SNI
util.IS_SECURETRANSPORT = False
util.ssl_.IS_SECURETRANSPORT = False | python | def extract_from_urllib3():
"""
Undo monkey-patching by :func:`inject_into_urllib3`.
"""
util.ssl_.SSLContext = orig_util_SSLContext
util.HAS_SNI = orig_util_HAS_SNI
util.ssl_.HAS_SNI = orig_util_HAS_SNI
util.IS_SECURETRANSPORT = False
util.ssl_.IS_SECURETRANSPORT = False | [
"def",
"extract_from_urllib3",
"(",
")",
":",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"orig_util_SSLContext",
"util",
".",
"HAS_SNI",
"=",
"orig_util_HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",
"orig_util_HAS_SNI",
"util",
".",
"IS_SECURETRANSPORT",
... | Undo monkey-patching by :func:`inject_into_urllib3`. | [
"Undo",
"monkey",
"-",
"patching",
"by",
":",
"func",
":",
"inject_into_urllib3",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L165-L173 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | _read_callback | def _read_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_socket is ... | python | def _read_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_socket is ... | [
"def",
"_read_callback",
"(",
"connection_id",
",",
"data_buffer",
",",
"data_length_pointer",
")",
":",
"wrapped_socket",
"=",
"None",
"try",
":",
"wrapped_socket",
"=",
"_connection_refs",
".",
"get",
"(",
"connection_id",
")",
"if",
"wrapped_socket",
"is",
"Non... | SecureTransport read callback. This is called by ST to request that data
be returned from the socket. | [
"SecureTransport",
"read",
"callback",
".",
"This",
"is",
"called",
"by",
"ST",
"to",
"request",
"that",
"data",
"be",
"returned",
"from",
"the",
"socket",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L176-L228 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | _write_callback | def _write_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_sock... | python | def _write_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_sock... | [
"def",
"_write_callback",
"(",
"connection_id",
",",
"data_buffer",
",",
"data_length_pointer",
")",
":",
"wrapped_socket",
"=",
"None",
"try",
":",
"wrapped_socket",
"=",
"_connection_refs",
".",
"get",
"(",
"connection_id",
")",
"if",
"wrapped_socket",
"is",
"No... | SecureTransport write callback. This is called by ST to request that data
actually be sent on the network. | [
"SecureTransport",
"write",
"callback",
".",
"This",
"is",
"called",
"by",
"ST",
"to",
"request",
"that",
"data",
"actually",
"be",
"sent",
"on",
"the",
"network",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L231-L279 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | WrappedSocket._raise_on_error | def _raise_on_error(self):
"""
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those except... | python | def _raise_on_error(self):
"""
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those except... | [
"def",
"_raise_on_error",
"(",
"self",
")",
":",
"self",
".",
"_exception",
"=",
"None",
"# We explicitly don't catch around this yield because in the unlikely",
"# event that an exception was hit in the block we don't want to swallow",
"# it.",
"yield",
"if",
"self",
".",
"_exce... | A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those exceptions.
It also correctly forces the soc... | [
"A",
"context",
"manager",
"that",
"can",
"be",
"used",
"to",
"wrap",
"calls",
"that",
"do",
"I",
"/",
"O",
"from",
"SecureTransport",
".",
"If",
"any",
"of",
"the",
"I",
"/",
"O",
"callbacks",
"hit",
"an",
"exception",
"this",
"context",
"manager",
"w... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L315-L333 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | WrappedSocket._set_ciphers | def _set_ciphers(self):
"""
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freak... | python | def _set_ciphers(self):
"""
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freak... | [
"def",
"_set_ciphers",
"(",
"self",
")",
":",
"ciphers",
"=",
"(",
"Security",
".",
"SSLCipherSuite",
"*",
"len",
"(",
"CIPHER_SUITES",
")",
")",
"(",
"*",
"CIPHER_SUITES",
")",
"result",
"=",
"Security",
".",
"SSLSetEnabledCiphers",
"(",
"self",
".",
"con... | Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freaking nightmare. | [
"Sets",
"up",
"the",
"allowed",
"ciphers",
".",
"By",
"default",
"this",
"matches",
"the",
"set",
"in",
"util",
".",
"ssl_",
".",
"DEFAULT_CIPHERS",
"at",
"least",
"as",
"supported",
"by",
"macOS",
".",
"This",
"is",
"done",
"custom",
"and",
"doesn",
"t"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L335-L346 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | WrappedSocket._custom_validate | def _custom_validate(self, verify, trust_bundle):
"""
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
"""
# If we disabled cert validation, just say: cool.
... | python | def _custom_validate(self, verify, trust_bundle):
"""
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
"""
# If we disabled cert validation, just say: cool.
... | [
"def",
"_custom_validate",
"(",
"self",
",",
"verify",
",",
"trust_bundle",
")",
":",
"# If we disabled cert validation, just say: cool.",
"if",
"not",
"verify",
":",
"return",
"# We want data in memory, so load it up.",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"t... | Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB. | [
"Called",
"when",
"we",
"have",
"set",
"custom",
"validation",
".",
"We",
"do",
"this",
"in",
"two",
"cases",
":",
"first",
"when",
"cert",
"validation",
"is",
"entirely",
"disabled",
";",
"and",
"second",
"when",
"using",
"a",
"custom",
"trust",
"DB",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L348-L408 | train |
pypa/pipenv | pipenv/vendor/urllib3/contrib/securetransport.py | WrappedSocket.handshake | def handshake(self,
server_hostname,
verify,
trust_bundle,
min_version,
max_version,
client_cert,
client_key,
client_key_passphrase):
"""
Actually performs the ... | python | def handshake(self,
server_hostname,
verify,
trust_bundle,
min_version,
max_version,
client_cert,
client_key,
client_key_passphrase):
"""
Actually performs the ... | [
"def",
"handshake",
"(",
"self",
",",
"server_hostname",
",",
"verify",
",",
"trust_bundle",
",",
"min_version",
",",
"max_version",
",",
"client_cert",
",",
"client_key",
",",
"client_key_passphrase",
")",
":",
"# First, we do the initial bits of connection setup. We nee... | Actually performs the TLS handshake. This is run automatically by
wrapped socket, and shouldn't be needed in user code. | [
"Actually",
"performs",
"the",
"TLS",
"handshake",
".",
"This",
"is",
"run",
"automatically",
"by",
"wrapped",
"socket",
"and",
"shouldn",
"t",
"be",
"needed",
"in",
"user",
"code",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L410-L498 | train |
pypa/pipenv | pipenv/vendor/jinja2/bccache.py | Bucket.write_bytecode | def write_bytecode(self, f):
"""Dump the bytecode into the file or file like object passed."""
if self.code is None:
raise TypeError('can\'t write empty bucket')
f.write(bc_magic)
pickle.dump(self.checksum, f, 2)
marshal_dump(self.code, f) | python | def write_bytecode(self, f):
"""Dump the bytecode into the file or file like object passed."""
if self.code is None:
raise TypeError('can\'t write empty bucket')
f.write(bc_magic)
pickle.dump(self.checksum, f, 2)
marshal_dump(self.code, f) | [
"def",
"write_bytecode",
"(",
"self",
",",
"f",
")",
":",
"if",
"self",
".",
"code",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'can\\'t write empty bucket'",
")",
"f",
".",
"write",
"(",
"bc_magic",
")",
"pickle",
".",
"dump",
"(",
"self",
".",
"c... | Dump the bytecode into the file or file like object passed. | [
"Dump",
"the",
"bytecode",
"into",
"the",
"file",
"or",
"file",
"like",
"object",
"passed",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/bccache.py#L98-L104 | train |
pypa/pipenv | pipenv/vendor/jinja2/bccache.py | BytecodeCache.get_cache_key | def get_cache_key(self, name, filename=None):
"""Returns the unique hash key for this template name."""
hash = sha1(name.encode('utf-8'))
if filename is not None:
filename = '|' + filename
if isinstance(filename, text_type):
filename = filename.encode('utf... | python | def get_cache_key(self, name, filename=None):
"""Returns the unique hash key for this template name."""
hash = sha1(name.encode('utf-8'))
if filename is not None:
filename = '|' + filename
if isinstance(filename, text_type):
filename = filename.encode('utf... | [
"def",
"get_cache_key",
"(",
"self",
",",
"name",
",",
"filename",
"=",
"None",
")",
":",
"hash",
"=",
"sha1",
"(",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"if",
"filename",
"is",
"not",
"None",
":",
"filename",
"=",
"'|'",
"+",
"filename",
... | Returns the unique hash key for this template name. | [
"Returns",
"the",
"unique",
"hash",
"key",
"for",
"this",
"template",
"name",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/bccache.py#L166-L174 | train |
pypa/pipenv | pipenv/vendor/jinja2/bccache.py | BytecodeCache.get_bucket | def get_bucket(self, environment, name, filename, source):
"""Return a cache bucket for the given template. All arguments are
mandatory but filename may be `None`.
"""
key = self.get_cache_key(name, filename)
checksum = self.get_source_checksum(source)
bucket = Bucket(en... | python | def get_bucket(self, environment, name, filename, source):
"""Return a cache bucket for the given template. All arguments are
mandatory but filename may be `None`.
"""
key = self.get_cache_key(name, filename)
checksum = self.get_source_checksum(source)
bucket = Bucket(en... | [
"def",
"get_bucket",
"(",
"self",
",",
"environment",
",",
"name",
",",
"filename",
",",
"source",
")",
":",
"key",
"=",
"self",
".",
"get_cache_key",
"(",
"name",
",",
"filename",
")",
"checksum",
"=",
"self",
".",
"get_source_checksum",
"(",
"source",
... | Return a cache bucket for the given template. All arguments are
mandatory but filename may be `None`. | [
"Return",
"a",
"cache",
"bucket",
"for",
"the",
"given",
"template",
".",
"All",
"arguments",
"are",
"mandatory",
"but",
"filename",
"may",
"be",
"None",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/bccache.py#L180-L188 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | lookup | def lookup(label):
"""
Look for an encoding by its label.
This is the spec’s `get an encoding
<http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
Supported labels are listed there.
:param label: A string.
:returns:
An :class:`Encoding` object, or :obj:`None` for an ... | python | def lookup(label):
"""
Look for an encoding by its label.
This is the spec’s `get an encoding
<http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
Supported labels are listed there.
:param label: A string.
:returns:
An :class:`Encoding` object, or :obj:`None` for an ... | [
"def",
"lookup",
"(",
"label",
")",
":",
"# Only strip ASCII whitespace: U+0009, U+000A, U+000C, U+000D, and U+0020.",
"label",
"=",
"ascii_lower",
"(",
"label",
".",
"strip",
"(",
"'\\t\\n\\f\\r '",
")",
")",
"name",
"=",
"LABELS",
".",
"get",
"(",
"label",
")",
... | Look for an encoding by its label.
This is the spec’s `get an encoding
<http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
Supported labels are listed there.
:param label: A string.
:returns:
An :class:`Encoding` object, or :obj:`None` for an unknown label. | [
"Look",
"for",
"an",
"encoding",
"by",
"its",
"label",
".",
"This",
"is",
"the",
"spec’s",
"get",
"an",
"encoding",
"<http",
":",
"//",
"encoding",
".",
"spec",
".",
"whatwg",
".",
"org",
"/",
"#concept",
"-",
"encoding",
"-",
"get",
">",
"_",
"algor... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L61-L88 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | _get_encoding | def _get_encoding(encoding_or_label):
"""
Accept either an encoding object or label.
:param encoding: An :class:`Encoding` object or a label string.
:returns: An :class:`Encoding` object.
:raises: :exc:`~exceptions.LookupError` for an unknown label.
"""
if hasattr(encoding_or_label, 'codec... | python | def _get_encoding(encoding_or_label):
"""
Accept either an encoding object or label.
:param encoding: An :class:`Encoding` object or a label string.
:returns: An :class:`Encoding` object.
:raises: :exc:`~exceptions.LookupError` for an unknown label.
"""
if hasattr(encoding_or_label, 'codec... | [
"def",
"_get_encoding",
"(",
"encoding_or_label",
")",
":",
"if",
"hasattr",
"(",
"encoding_or_label",
",",
"'codec_info'",
")",
":",
"return",
"encoding_or_label",
"encoding",
"=",
"lookup",
"(",
"encoding_or_label",
")",
"if",
"encoding",
"is",
"None",
":",
"r... | Accept either an encoding object or label.
:param encoding: An :class:`Encoding` object or a label string.
:returns: An :class:`Encoding` object.
:raises: :exc:`~exceptions.LookupError` for an unknown label. | [
"Accept",
"either",
"an",
"encoding",
"object",
"or",
"label",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L91-L106 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | decode | def decode(input, fallback_encoding, errors='replace'):
"""
Decode a single string.
:param input: A byte string
:param fallback_encoding:
An :class:`Encoding` object or a label string.
The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. S... | python | def decode(input, fallback_encoding, errors='replace'):
"""
Decode a single string.
:param input: A byte string
:param fallback_encoding:
An :class:`Encoding` object or a label string.
The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. S... | [
"def",
"decode",
"(",
"input",
",",
"fallback_encoding",
",",
"errors",
"=",
"'replace'",
")",
":",
"# Fail early if `encoding` is an invalid label.",
"fallback_encoding",
"=",
"_get_encoding",
"(",
"fallback_encoding",
")",
"bom_encoding",
",",
"input",
"=",
"_detect_b... | Decode a single string.
:param input: A byte string
:param fallback_encoding:
An :class:`Encoding` object or a label string.
The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupErr... | [
"Decode",
"a",
"single",
"string",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L139-L158 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | _detect_bom | def _detect_bom(input):
"""Return (bom_encoding, input), with any BOM removed from the input."""
if input.startswith(b'\xFF\xFE'):
return _UTF16LE, input[2:]
if input.startswith(b'\xFE\xFF'):
return _UTF16BE, input[2:]
if input.startswith(b'\xEF\xBB\xBF'):
return UTF8, input[3:]
... | python | def _detect_bom(input):
"""Return (bom_encoding, input), with any BOM removed from the input."""
if input.startswith(b'\xFF\xFE'):
return _UTF16LE, input[2:]
if input.startswith(b'\xFE\xFF'):
return _UTF16BE, input[2:]
if input.startswith(b'\xEF\xBB\xBF'):
return UTF8, input[3:]
... | [
"def",
"_detect_bom",
"(",
"input",
")",
":",
"if",
"input",
".",
"startswith",
"(",
"b'\\xFF\\xFE'",
")",
":",
"return",
"_UTF16LE",
",",
"input",
"[",
"2",
":",
"]",
"if",
"input",
".",
"startswith",
"(",
"b'\\xFE\\xFF'",
")",
":",
"return",
"_UTF16BE"... | Return (bom_encoding, input), with any BOM removed from the input. | [
"Return",
"(",
"bom_encoding",
"input",
")",
"with",
"any",
"BOM",
"removed",
"from",
"the",
"input",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L161-L169 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | encode | def encode(input, encoding=UTF8, errors='strict'):
"""
Encode a single string.
:param input: An Unicode string.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unkn... | python | def encode(input, encoding=UTF8, errors='strict'):
"""
Encode a single string.
:param input: An Unicode string.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unkn... | [
"def",
"encode",
"(",
"input",
",",
"encoding",
"=",
"UTF8",
",",
"errors",
"=",
"'strict'",
")",
":",
"return",
"_get_encoding",
"(",
"encoding",
")",
".",
"codec_info",
".",
"encode",
"(",
"input",
",",
"errors",
")",
"[",
"0",
"]"
] | Encode a single string.
:param input: An Unicode string.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.
:return: A byte string. | [
"Encode",
"a",
"single",
"string",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L172-L183 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | iter_decode | def iter_decode(input, fallback_encoding, errors='replace'):
"""
"Pull"-based decoder.
:param input:
An iterable of byte strings.
The input is first consumed just enough to determine the encoding
based on the precense of a BOM,
then consumed on demand when the return value ... | python | def iter_decode(input, fallback_encoding, errors='replace'):
"""
"Pull"-based decoder.
:param input:
An iterable of byte strings.
The input is first consumed just enough to determine the encoding
based on the precense of a BOM,
then consumed on demand when the return value ... | [
"def",
"iter_decode",
"(",
"input",
",",
"fallback_encoding",
",",
"errors",
"=",
"'replace'",
")",
":",
"decoder",
"=",
"IncrementalDecoder",
"(",
"fallback_encoding",
",",
"errors",
")",
"generator",
"=",
"_iter_decode_generator",
"(",
"input",
",",
"decoder",
... | "Pull"-based decoder.
:param input:
An iterable of byte strings.
The input is first consumed just enough to determine the encoding
based on the precense of a BOM,
then consumed on demand when the return value is.
:param fallback_encoding:
An :class:`Encoding` object or ... | [
"Pull",
"-",
"based",
"decoder",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L186-L211 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/webencodings/__init__.py | _iter_decode_generator | def _iter_decode_generator(input, decoder):
"""Return a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings.
"""
decode = decoder.decode
input = iter(input)
for chunck in input:
output = decode(chunck)
if output:
assert decod... | python | def _iter_decode_generator(input, decoder):
"""Return a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings.
"""
decode = decoder.decode
input = iter(input)
for chunck in input:
output = decode(chunck)
if output:
assert decod... | [
"def",
"_iter_decode_generator",
"(",
"input",
",",
"decoder",
")",
":",
"decode",
"=",
"decoder",
".",
"decode",
"input",
"=",
"iter",
"(",
"input",
")",
"for",
"chunck",
"in",
"input",
":",
"output",
"=",
"decode",
"(",
"chunck",
")",
"if",
"output",
... | Return a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings. | [
"Return",
"a",
"generator",
"that",
"first",
"yields",
"the",
":",
"obj",
":",
"Encoding",
"then",
"yields",
"output",
"chukns",
"as",
"Unicode",
"strings",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/webencodings/__init__.py#L214-L243 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.