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/utils.py | _get_requests_session | def _get_requests_session():
"""Load requests lazily."""
global requests_session
if requests_session is not None:
return requests_session
import requests
requests_session = requests.Session()
adapter = requests.adapters.HTTPAdapter(
max_retries=environments.PIPENV_MAX_RETRIES
... | python | def _get_requests_session():
"""Load requests lazily."""
global requests_session
if requests_session is not None:
return requests_session
import requests
requests_session = requests.Session()
adapter = requests.adapters.HTTPAdapter(
max_retries=environments.PIPENV_MAX_RETRIES
... | [
"def",
"_get_requests_session",
"(",
")",
":",
"global",
"requests_session",
"if",
"requests_session",
"is",
"not",
"None",
":",
"return",
"requests_session",
"import",
"requests",
"requests_session",
"=",
"requests",
".",
"Session",
"(",
")",
"adapter",
"=",
"req... | Load requests lazily. | [
"Load",
"requests",
"lazily",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L53-L65 | train |
pypa/pipenv | pipenv/utils.py | convert_toml_outline_tables | def convert_toml_outline_tables(parsed):
"""Converts all outline tables to inline tables."""
def convert_tomlkit_table(section):
for key, value in section._body:
if not key:
continue
if hasattr(value, "keys") and not isinstance(value, tomlkit.items.InlineTable):
... | python | def convert_toml_outline_tables(parsed):
"""Converts all outline tables to inline tables."""
def convert_tomlkit_table(section):
for key, value in section._body:
if not key:
continue
if hasattr(value, "keys") and not isinstance(value, tomlkit.items.InlineTable):
... | [
"def",
"convert_toml_outline_tables",
"(",
"parsed",
")",
":",
"def",
"convert_tomlkit_table",
"(",
"section",
")",
":",
"for",
"key",
",",
"value",
"in",
"section",
".",
"_body",
":",
"if",
"not",
"key",
":",
"continue",
"if",
"hasattr",
"(",
"value",
","... | Converts all outline tables to inline tables. | [
"Converts",
"all",
"outline",
"tables",
"to",
"inline",
"tables",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L91-L119 | train |
pypa/pipenv | pipenv/utils.py | run_command | def run_command(cmd, *args, **kwargs):
"""
Take an input command and run it, handling exceptions and error codes and returning
its stdout and stderr.
:param cmd: The list of command and arguments.
:type cmd: list
:returns: A 2-tuple of the output and error from the command
:rtype: Tuple[str... | python | def run_command(cmd, *args, **kwargs):
"""
Take an input command and run it, handling exceptions and error codes and returning
its stdout and stderr.
:param cmd: The list of command and arguments.
:type cmd: list
:returns: A 2-tuple of the output and error from the command
:rtype: Tuple[str... | [
"def",
"run_command",
"(",
"cmd",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"pipenv",
".",
"vendor",
"import",
"delegator",
"from",
".",
"_compat",
"import",
"decode_for_output",
"from",
".",
"cmdparse",
"import",
"Script",
"catch_exceptio... | Take an input command and run it, handling exceptions and error codes and returning
its stdout and stderr.
:param cmd: The list of command and arguments.
:type cmd: list
:returns: A 2-tuple of the output and error from the command
:rtype: Tuple[str, str]
:raises: exceptions.PipenvCmdError | [
"Take",
"an",
"input",
"command",
"and",
"run",
"it",
"handling",
"exceptions",
"and",
"error",
"codes",
"and",
"returning",
"its",
"stdout",
"and",
"stderr",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L122-L160 | train |
pypa/pipenv | pipenv/utils.py | parse_python_version | def parse_python_version(output):
"""Parse a Python version output returned by `python --version`.
Return a dict with three keys: major, minor, and micro. Each value is a
string containing a version part.
Note: The micro part would be `'0'` if it's missing from the input string.
"""
version_li... | python | def parse_python_version(output):
"""Parse a Python version output returned by `python --version`.
Return a dict with three keys: major, minor, and micro. Each value is a
string containing a version part.
Note: The micro part would be `'0'` if it's missing from the input string.
"""
version_li... | [
"def",
"parse_python_version",
"(",
"output",
")",
":",
"version_line",
"=",
"output",
".",
"split",
"(",
"\"\\n\"",
",",
"1",
")",
"[",
"0",
"]",
"version_pattern",
"=",
"re",
".",
"compile",
"(",
"r\"\"\"\n ^ # Beginning of line.\n ... | Parse a Python version output returned by `python --version`.
Return a dict with three keys: major, minor, and micro. Each value is a
string containing a version part.
Note: The micro part would be `'0'` if it's missing from the input string. | [
"Parse",
"a",
"Python",
"version",
"output",
"returned",
"by",
"python",
"--",
"version",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L163-L193 | train |
pypa/pipenv | pipenv/utils.py | escape_grouped_arguments | def escape_grouped_arguments(s):
"""Prepares a string for the shell (on Windows too!)
Only for use on grouped arguments (passed as a string to Popen)
"""
if s is None:
return None
# Additional escaping for windows paths
if os.name == "nt":
s = "{}".format(s.replace("\\", "\\\\"... | python | def escape_grouped_arguments(s):
"""Prepares a string for the shell (on Windows too!)
Only for use on grouped arguments (passed as a string to Popen)
"""
if s is None:
return None
# Additional escaping for windows paths
if os.name == "nt":
s = "{}".format(s.replace("\\", "\\\\"... | [
"def",
"escape_grouped_arguments",
"(",
"s",
")",
":",
"if",
"s",
"is",
"None",
":",
"return",
"None",
"# Additional escaping for windows paths",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"s",
"=",
"\"{}\"",
".",
"format",
"(",
"s",
".",
"replace",
"("... | Prepares a string for the shell (on Windows too!)
Only for use on grouped arguments (passed as a string to Popen) | [
"Prepares",
"a",
"string",
"for",
"the",
"shell",
"(",
"on",
"Windows",
"too!",
")"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L208-L219 | train |
pypa/pipenv | pipenv/utils.py | venv_resolve_deps | def venv_resolve_deps(
deps,
which,
project,
pre=False,
clear=False,
allow_global=False,
pypi_mirror=None,
dev=False,
pipfile=None,
lockfile=None,
keep_outdated=False
):
"""
Resolve dependencies for a pipenv project, acts as a portal to the target environment.
Re... | python | def venv_resolve_deps(
deps,
which,
project,
pre=False,
clear=False,
allow_global=False,
pypi_mirror=None,
dev=False,
pipfile=None,
lockfile=None,
keep_outdated=False
):
"""
Resolve dependencies for a pipenv project, acts as a portal to the target environment.
Re... | [
"def",
"venv_resolve_deps",
"(",
"deps",
",",
"which",
",",
"project",
",",
"pre",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"allow_global",
"=",
"False",
",",
"pypi_mirror",
"=",
"None",
",",
"dev",
"=",
"False",
",",
"pipfile",
"=",
"None",
",",... | Resolve dependencies for a pipenv project, acts as a portal to the target environment.
Regardless of whether a virtual environment is present or not, this will spawn
a subproces which is isolated to the target environment and which will perform
dependency resolution. This function reads the output of that... | [
"Resolve",
"dependencies",
"for",
"a",
"pipenv",
"project",
"acts",
"as",
"a",
"portal",
"to",
"the",
"target",
"environment",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L930-L1046 | train |
pypa/pipenv | pipenv/utils.py | resolve_deps | def resolve_deps(
deps,
which,
project,
sources=None,
python=False,
clear=False,
pre=False,
allow_global=False,
req_dir=None
):
"""Given a list of dependencies, return a resolved list of dependencies,
using pip-tools -- and their hashes, using the warehouse API / pip.
"""... | python | def resolve_deps(
deps,
which,
project,
sources=None,
python=False,
clear=False,
pre=False,
allow_global=False,
req_dir=None
):
"""Given a list of dependencies, return a resolved list of dependencies,
using pip-tools -- and their hashes, using the warehouse API / pip.
"""... | [
"def",
"resolve_deps",
"(",
"deps",
",",
"which",
",",
"project",
",",
"sources",
"=",
"None",
",",
"python",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"pre",
"=",
"False",
",",
"allow_global",
"=",
"False",
",",
"req_dir",
"=",
"None",
")",
":"... | Given a list of dependencies, return a resolved list of dependencies,
using pip-tools -- and their hashes, using the warehouse API / pip. | [
"Given",
"a",
"list",
"of",
"dependencies",
"return",
"a",
"resolved",
"list",
"of",
"dependencies",
"using",
"pip",
"-",
"tools",
"--",
"and",
"their",
"hashes",
"using",
"the",
"warehouse",
"API",
"/",
"pip",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1049-L1114 | train |
pypa/pipenv | pipenv/utils.py | convert_deps_to_pip | def convert_deps_to_pip(deps, project=None, r=True, include_index=True):
""""Converts a Pipfile-formatted dependency to a pip-formatted one."""
from .vendor.requirementslib.models.requirements import Requirement
dependencies = []
for dep_name, dep in deps.items():
if project:
projec... | python | def convert_deps_to_pip(deps, project=None, r=True, include_index=True):
""""Converts a Pipfile-formatted dependency to a pip-formatted one."""
from .vendor.requirementslib.models.requirements import Requirement
dependencies = []
for dep_name, dep in deps.items():
if project:
projec... | [
"def",
"convert_deps_to_pip",
"(",
"deps",
",",
"project",
"=",
"None",
",",
"r",
"=",
"True",
",",
"include_index",
"=",
"True",
")",
":",
"from",
".",
"vendor",
".",
"requirementslib",
".",
"models",
".",
"requirements",
"import",
"Requirement",
"dependenc... | Converts a Pipfile-formatted dependency to a pip-formatted one. | [
"Converts",
"a",
"Pipfile",
"-",
"formatted",
"dependency",
"to",
"a",
"pip",
"-",
"formatted",
"one",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1127-L1149 | train |
pypa/pipenv | pipenv/utils.py | is_required_version | def is_required_version(version, specified_version):
"""Check to see if there's a hard requirement for version
number provided in the Pipfile.
"""
# Certain packages may be defined with multiple values.
if isinstance(specified_version, dict):
specified_version = specified_version.get("versio... | python | def is_required_version(version, specified_version):
"""Check to see if there's a hard requirement for version
number provided in the Pipfile.
"""
# Certain packages may be defined with multiple values.
if isinstance(specified_version, dict):
specified_version = specified_version.get("versio... | [
"def",
"is_required_version",
"(",
"version",
",",
"specified_version",
")",
":",
"# Certain packages may be defined with multiple values.",
"if",
"isinstance",
"(",
"specified_version",
",",
"dict",
")",
":",
"specified_version",
"=",
"specified_version",
".",
"get",
"("... | Check to see if there's a hard requirement for version
number provided in the Pipfile. | [
"Check",
"to",
"see",
"if",
"there",
"s",
"a",
"hard",
"requirement",
"for",
"version",
"number",
"provided",
"in",
"the",
"Pipfile",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1185-L1195 | train |
pypa/pipenv | pipenv/utils.py | is_installable_file | def is_installable_file(path):
"""Determine if a path can potentially be installed"""
from .vendor.pip_shims.shims import is_installable_dir, is_archive_file
from .patched.notpip._internal.utils.packaging import specifiers
from ._compat import Path
if hasattr(path, "keys") and any(
key for ... | python | def is_installable_file(path):
"""Determine if a path can potentially be installed"""
from .vendor.pip_shims.shims import is_installable_dir, is_archive_file
from .patched.notpip._internal.utils.packaging import specifiers
from ._compat import Path
if hasattr(path, "keys") and any(
key for ... | [
"def",
"is_installable_file",
"(",
"path",
")",
":",
"from",
".",
"vendor",
".",
"pip_shims",
".",
"shims",
"import",
"is_installable_dir",
",",
"is_archive_file",
"from",
".",
"patched",
".",
"notpip",
".",
"_internal",
".",
"utils",
".",
"packaging",
"import... | Determine if a path can potentially be installed | [
"Determine",
"if",
"a",
"path",
"can",
"potentially",
"be",
"installed"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1206-L1241 | train |
pypa/pipenv | pipenv/utils.py | is_file | def is_file(package):
"""Determine if a package name is for a File dependency."""
if hasattr(package, "keys"):
return any(key for key in package.keys() if key in ["file", "path"])
if os.path.exists(str(package)):
return True
for start in SCHEME_LIST:
if str(package).startswith(... | python | def is_file(package):
"""Determine if a package name is for a File dependency."""
if hasattr(package, "keys"):
return any(key for key in package.keys() if key in ["file", "path"])
if os.path.exists(str(package)):
return True
for start in SCHEME_LIST:
if str(package).startswith(... | [
"def",
"is_file",
"(",
"package",
")",
":",
"if",
"hasattr",
"(",
"package",
",",
"\"keys\"",
")",
":",
"return",
"any",
"(",
"key",
"for",
"key",
"in",
"package",
".",
"keys",
"(",
")",
"if",
"key",
"in",
"[",
"\"file\"",
",",
"\"path\"",
"]",
")"... | Determine if a package name is for a File dependency. | [
"Determine",
"if",
"a",
"package",
"name",
"is",
"for",
"a",
"File",
"dependency",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1244-L1256 | train |
pypa/pipenv | pipenv/utils.py | pep423_name | def pep423_name(name):
"""Normalize package name to PEP 423 style standard."""
name = name.lower()
if any(i not in name for i in (VCS_LIST + SCHEME_LIST)):
return name.replace("_", "-")
else:
return name | python | def pep423_name(name):
"""Normalize package name to PEP 423 style standard."""
name = name.lower()
if any(i not in name for i in (VCS_LIST + SCHEME_LIST)):
return name.replace("_", "-")
else:
return name | [
"def",
"pep423_name",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"if",
"any",
"(",
"i",
"not",
"in",
"name",
"for",
"i",
"in",
"(",
"VCS_LIST",
"+",
"SCHEME_LIST",
")",
")",
":",
"return",
"name",
".",
"replace",
"(",
"\"... | Normalize package name to PEP 423 style standard. | [
"Normalize",
"package",
"name",
"to",
"PEP",
"423",
"style",
"standard",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1267-L1274 | train |
pypa/pipenv | pipenv/utils.py | proper_case | def proper_case(package_name):
"""Properly case project name from pypi.org."""
# Hit the simple API.
r = _get_requests_session().get(
"https://pypi.org/pypi/{0}/json".format(package_name), timeout=0.3, stream=True
)
if not r.ok:
raise IOError(
"Unable to find package {0} ... | python | def proper_case(package_name):
"""Properly case project name from pypi.org."""
# Hit the simple API.
r = _get_requests_session().get(
"https://pypi.org/pypi/{0}/json".format(package_name), timeout=0.3, stream=True
)
if not r.ok:
raise IOError(
"Unable to find package {0} ... | [
"def",
"proper_case",
"(",
"package_name",
")",
":",
"# Hit the simple API.",
"r",
"=",
"_get_requests_session",
"(",
")",
".",
"get",
"(",
"\"https://pypi.org/pypi/{0}/json\"",
".",
"format",
"(",
"package_name",
")",
",",
"timeout",
"=",
"0.3",
",",
"stream",
... | Properly case project name from pypi.org. | [
"Properly",
"case",
"project",
"name",
"from",
"pypi",
".",
"org",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1277-L1290 | train |
pypa/pipenv | pipenv/utils.py | find_windows_executable | def find_windows_executable(bin_path, exe_name):
"""Given an executable name, search the given location for an executable"""
requested_path = get_windows_path(bin_path, exe_name)
if os.path.isfile(requested_path):
return requested_path
try:
pathext = os.environ["PATHEXT"]
except Key... | python | def find_windows_executable(bin_path, exe_name):
"""Given an executable name, search the given location for an executable"""
requested_path = get_windows_path(bin_path, exe_name)
if os.path.isfile(requested_path):
return requested_path
try:
pathext = os.environ["PATHEXT"]
except Key... | [
"def",
"find_windows_executable",
"(",
"bin_path",
",",
"exe_name",
")",
":",
"requested_path",
"=",
"get_windows_path",
"(",
"bin_path",
",",
"exe_name",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"requested_path",
")",
":",
"return",
"requested_path",
... | Given an executable name, search the given location for an executable | [
"Given",
"an",
"executable",
"name",
"search",
"the",
"given",
"location",
"for",
"an",
"executable"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1300-L1316 | train |
pypa/pipenv | pipenv/utils.py | get_canonical_names | def get_canonical_names(packages):
"""Canonicalize a list of packages and return a set of canonical names"""
from .vendor.packaging.utils import canonicalize_name
if not isinstance(packages, Sequence):
if not isinstance(packages, six.string_types):
return packages
packages = [pa... | python | def get_canonical_names(packages):
"""Canonicalize a list of packages and return a set of canonical names"""
from .vendor.packaging.utils import canonicalize_name
if not isinstance(packages, Sequence):
if not isinstance(packages, six.string_types):
return packages
packages = [pa... | [
"def",
"get_canonical_names",
"(",
"packages",
")",
":",
"from",
".",
"vendor",
".",
"packaging",
".",
"utils",
"import",
"canonicalize_name",
"if",
"not",
"isinstance",
"(",
"packages",
",",
"Sequence",
")",
":",
"if",
"not",
"isinstance",
"(",
"packages",
... | Canonicalize a list of packages and return a set of canonical names | [
"Canonicalize",
"a",
"list",
"of",
"packages",
"and",
"return",
"a",
"set",
"of",
"canonical",
"names"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1337-L1345 | train |
pypa/pipenv | pipenv/utils.py | find_requirements | def find_requirements(max_depth=3):
"""Returns the path of a Pipfile in parent directories."""
i = 0
for c, d, f in walk_up(os.getcwd()):
i += 1
if i < max_depth:
if "requirements.txt":
r = os.path.join(c, "requirements.txt")
if os.path.isfile(r):
... | python | def find_requirements(max_depth=3):
"""Returns the path of a Pipfile in parent directories."""
i = 0
for c, d, f in walk_up(os.getcwd()):
i += 1
if i < max_depth:
if "requirements.txt":
r = os.path.join(c, "requirements.txt")
if os.path.isfile(r):
... | [
"def",
"find_requirements",
"(",
"max_depth",
"=",
"3",
")",
":",
"i",
"=",
"0",
"for",
"c",
",",
"d",
",",
"f",
"in",
"walk_up",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
":",
"i",
"+=",
"1",
"if",
"i",
"<",
"max_depth",
":",
"if",
"\"requireme... | Returns the path of a Pipfile in parent directories. | [
"Returns",
"the",
"path",
"of",
"a",
"Pipfile",
"in",
"parent",
"directories",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1376-L1387 | train |
pypa/pipenv | pipenv/utils.py | temp_environ | def temp_environ():
"""Allow the ability to set os.environ temporarily"""
environ = dict(os.environ)
try:
yield
finally:
os.environ.clear()
os.environ.update(environ) | python | def temp_environ():
"""Allow the ability to set os.environ temporarily"""
environ = dict(os.environ)
try:
yield
finally:
os.environ.clear()
os.environ.update(environ) | [
"def",
"temp_environ",
"(",
")",
":",
"environ",
"=",
"dict",
"(",
"os",
".",
"environ",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"environ",
".",
"clear",
"(",
")",
"os",
".",
"environ",
".",
"update",
"(",
"environ",
")"
] | Allow the ability to set os.environ temporarily | [
"Allow",
"the",
"ability",
"to",
"set",
"os",
".",
"environ",
"temporarily"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1393-L1401 | train |
pypa/pipenv | pipenv/utils.py | temp_path | def temp_path():
"""Allow the ability to set os.environ temporarily"""
path = [p for p in sys.path]
try:
yield
finally:
sys.path = [p for p in path] | python | def temp_path():
"""Allow the ability to set os.environ temporarily"""
path = [p for p in sys.path]
try:
yield
finally:
sys.path = [p for p in path] | [
"def",
"temp_path",
"(",
")",
":",
"path",
"=",
"[",
"p",
"for",
"p",
"in",
"sys",
".",
"path",
"]",
"try",
":",
"yield",
"finally",
":",
"sys",
".",
"path",
"=",
"[",
"p",
"for",
"p",
"in",
"path",
"]"
] | Allow the ability to set os.environ temporarily | [
"Allow",
"the",
"ability",
"to",
"set",
"os",
".",
"environ",
"temporarily"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1405-L1411 | train |
pypa/pipenv | pipenv/utils.py | is_valid_url | def is_valid_url(url):
"""Checks if a given string is an url"""
pieces = urlparse(url)
return all([pieces.scheme, pieces.netloc]) | python | def is_valid_url(url):
"""Checks if a given string is an url"""
pieces = urlparse(url)
return all([pieces.scheme, pieces.netloc]) | [
"def",
"is_valid_url",
"(",
"url",
")",
":",
"pieces",
"=",
"urlparse",
"(",
"url",
")",
"return",
"all",
"(",
"[",
"pieces",
".",
"scheme",
",",
"pieces",
".",
"netloc",
"]",
")"
] | Checks if a given string is an url | [
"Checks",
"if",
"a",
"given",
"string",
"is",
"an",
"url"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1427-L1430 | train |
pypa/pipenv | pipenv/utils.py | download_file | def download_file(url, filename):
"""Downloads file from url to a path with filename"""
r = _get_requests_session().get(url, stream=True)
if not r.ok:
raise IOError("Unable to download file")
with open(filename, "wb") as f:
f.write(r.content) | python | def download_file(url, filename):
"""Downloads file from url to a path with filename"""
r = _get_requests_session().get(url, stream=True)
if not r.ok:
raise IOError("Unable to download file")
with open(filename, "wb") as f:
f.write(r.content) | [
"def",
"download_file",
"(",
"url",
",",
"filename",
")",
":",
"r",
"=",
"_get_requests_session",
"(",
")",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
"if",
"not",
"r",
".",
"ok",
":",
"raise",
"IOError",
"(",
"\"Unable to download file\"",... | Downloads file from url to a path with filename | [
"Downloads",
"file",
"from",
"url",
"to",
"a",
"path",
"with",
"filename"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1451-L1458 | train |
pypa/pipenv | pipenv/utils.py | normalize_drive | def normalize_drive(path):
"""Normalize drive in path so they stay consistent.
This currently only affects local drives on Windows, which can be
identified with either upper or lower cased drive names. The case is
always converted to uppercase because it seems to be preferred.
See: <https://github... | python | def normalize_drive(path):
"""Normalize drive in path so they stay consistent.
This currently only affects local drives on Windows, which can be
identified with either upper or lower cased drive names. The case is
always converted to uppercase because it seems to be preferred.
See: <https://github... | [
"def",
"normalize_drive",
"(",
"path",
")",
":",
"if",
"os",
".",
"name",
"!=",
"\"nt\"",
"or",
"not",
"isinstance",
"(",
"path",
",",
"six",
".",
"string_types",
")",
":",
"return",
"path",
"drive",
",",
"tail",
"=",
"os",
".",
"path",
".",
"splitdr... | Normalize drive in path so they stay consistent.
This currently only affects local drives on Windows, which can be
identified with either upper or lower cased drive names. The case is
always converted to uppercase because it seems to be preferred.
See: <https://github.com/pypa/pipenv/issues/1218> | [
"Normalize",
"drive",
"in",
"path",
"so",
"they",
"stay",
"consistent",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1461-L1478 | train |
pypa/pipenv | pipenv/utils.py | is_readonly_path | def is_readonly_path(fn):
"""Check if a provided path exists and is readonly.
Permissions check is `bool(path.stat & stat.S_IREAD)` or `not os.access(path, os.W_OK)`
"""
if os.path.exists(fn):
return (os.stat(fn).st_mode & stat.S_IREAD) or not os.access(fn, os.W_OK)
return False | python | def is_readonly_path(fn):
"""Check if a provided path exists and is readonly.
Permissions check is `bool(path.stat & stat.S_IREAD)` or `not os.access(path, os.W_OK)`
"""
if os.path.exists(fn):
return (os.stat(fn).st_mode & stat.S_IREAD) or not os.access(fn, os.W_OK)
return False | [
"def",
"is_readonly_path",
"(",
"fn",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fn",
")",
":",
"return",
"(",
"os",
".",
"stat",
"(",
"fn",
")",
".",
"st_mode",
"&",
"stat",
".",
"S_IREAD",
")",
"or",
"not",
"os",
".",
"access",
"... | Check if a provided path exists and is readonly.
Permissions check is `bool(path.stat & stat.S_IREAD)` or `not os.access(path, os.W_OK)` | [
"Check",
"if",
"a",
"provided",
"path",
"exists",
"and",
"is",
"readonly",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1481-L1489 | train |
pypa/pipenv | pipenv/utils.py | handle_remove_readonly | def handle_remove_readonly(func, path, exc):
"""Error handler for shutil.rmtree.
Windows source repo folders are read-only by default, so this error handler
attempts to set them as writeable and then proceed with deletion."""
# Check for read-only attribute
default_warning_message = (
"Unab... | python | def handle_remove_readonly(func, path, exc):
"""Error handler for shutil.rmtree.
Windows source repo folders are read-only by default, so this error handler
attempts to set them as writeable and then proceed with deletion."""
# Check for read-only attribute
default_warning_message = (
"Unab... | [
"def",
"handle_remove_readonly",
"(",
"func",
",",
"path",
",",
"exc",
")",
":",
"# Check for read-only attribute",
"default_warning_message",
"=",
"(",
"\"Unable to remove file due to permissions restriction: {!r}\"",
")",
"# split the initial exception out into its type, exception,... | Error handler for shutil.rmtree.
Windows source repo folders are read-only by default, so this error handler
attempts to set them as writeable and then proceed with deletion. | [
"Error",
"handler",
"for",
"shutil",
".",
"rmtree",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1505-L1530 | train |
pypa/pipenv | pipenv/utils.py | safe_expandvars | def safe_expandvars(value):
"""Call os.path.expandvars if value is a string, otherwise do nothing.
"""
if isinstance(value, six.string_types):
return os.path.expandvars(value)
return value | python | def safe_expandvars(value):
"""Call os.path.expandvars if value is a string, otherwise do nothing.
"""
if isinstance(value, six.string_types):
return os.path.expandvars(value)
return value | [
"def",
"safe_expandvars",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"return",
"os",
".",
"path",
".",
"expandvars",
"(",
"value",
")",
"return",
"value"
] | Call os.path.expandvars if value is a string, otherwise do nothing. | [
"Call",
"os",
".",
"path",
".",
"expandvars",
"if",
"value",
"is",
"a",
"string",
"otherwise",
"do",
"nothing",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1539-L1544 | train |
pypa/pipenv | pipenv/utils.py | translate_markers | def translate_markers(pipfile_entry):
"""Take a pipfile entry and normalize its markers
Provide a pipfile entry which may have 'markers' as a key or it may have
any valid key from `packaging.markers.marker_context.keys()` and standardize
the format into {'markers': 'key == "some_value"'}.
:param p... | python | def translate_markers(pipfile_entry):
"""Take a pipfile entry and normalize its markers
Provide a pipfile entry which may have 'markers' as a key or it may have
any valid key from `packaging.markers.marker_context.keys()` and standardize
the format into {'markers': 'key == "some_value"'}.
:param p... | [
"def",
"translate_markers",
"(",
"pipfile_entry",
")",
":",
"if",
"not",
"isinstance",
"(",
"pipfile_entry",
",",
"Mapping",
")",
":",
"raise",
"TypeError",
"(",
"\"Entry is not a pipfile formatted mapping.\"",
")",
"from",
".",
"vendor",
".",
"distlib",
".",
"mar... | Take a pipfile entry and normalize its markers
Provide a pipfile entry which may have 'markers' as a key or it may have
any valid key from `packaging.markers.marker_context.keys()` and standardize
the format into {'markers': 'key == "some_value"'}.
:param pipfile_entry: A dictionariy of keys and value... | [
"Take",
"a",
"pipfile",
"entry",
"and",
"normalize",
"its",
"markers"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1597-L1633 | train |
pypa/pipenv | pipenv/utils.py | is_virtual_environment | def is_virtual_environment(path):
"""Check if a given path is a virtual environment's root.
This is done by checking if the directory contains a Python executable in
its bin/Scripts directory. Not technically correct, but good enough for
general usage.
"""
if not path.is_dir():
return F... | python | def is_virtual_environment(path):
"""Check if a given path is a virtual environment's root.
This is done by checking if the directory contains a Python executable in
its bin/Scripts directory. Not technically correct, but good enough for
general usage.
"""
if not path.is_dir():
return F... | [
"def",
"is_virtual_environment",
"(",
"path",
")",
":",
"if",
"not",
"path",
".",
"is_dir",
"(",
")",
":",
"return",
"False",
"for",
"bindir_name",
"in",
"(",
"'bin'",
",",
"'Scripts'",
")",
":",
"for",
"python",
"in",
"path",
".",
"joinpath",
"(",
"bi... | Check if a given path is a virtual environment's root.
This is done by checking if the directory contains a Python executable in
its bin/Scripts directory. Not technically correct, but good enough for
general usage. | [
"Check",
"if",
"a",
"given",
"path",
"is",
"a",
"virtual",
"environment",
"s",
"root",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1707-L1724 | train |
pypa/pipenv | pipenv/utils.py | sys_version | def sys_version(version_tuple):
"""
Set a temporary sys.version_info tuple
:param version_tuple: a fake sys.version_info tuple
"""
old_version = sys.version_info
sys.version_info = version_tuple
yield
sys.version_info = old_version | python | def sys_version(version_tuple):
"""
Set a temporary sys.version_info tuple
:param version_tuple: a fake sys.version_info tuple
"""
old_version = sys.version_info
sys.version_info = version_tuple
yield
sys.version_info = old_version | [
"def",
"sys_version",
"(",
"version_tuple",
")",
":",
"old_version",
"=",
"sys",
".",
"version_info",
"sys",
".",
"version_info",
"=",
"version_tuple",
"yield",
"sys",
".",
"version_info",
"=",
"old_version"
] | Set a temporary sys.version_info tuple
:param version_tuple: a fake sys.version_info tuple | [
"Set",
"a",
"temporary",
"sys",
".",
"version_info",
"tuple"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1785-L1795 | train |
pypa/pipenv | pipenv/utils.py | add_to_set | def add_to_set(original_set, element):
"""Given a set and some arbitrary element, add the element(s) to the set"""
if not element:
return original_set
if isinstance(element, Set):
original_set |= element
elif isinstance(element, (list, tuple)):
original_set |= set(element)
el... | python | def add_to_set(original_set, element):
"""Given a set and some arbitrary element, add the element(s) to the set"""
if not element:
return original_set
if isinstance(element, Set):
original_set |= element
elif isinstance(element, (list, tuple)):
original_set |= set(element)
el... | [
"def",
"add_to_set",
"(",
"original_set",
",",
"element",
")",
":",
"if",
"not",
"element",
":",
"return",
"original_set",
"if",
"isinstance",
"(",
"element",
",",
"Set",
")",
":",
"original_set",
"|=",
"element",
"elif",
"isinstance",
"(",
"element",
",",
... | Given a set and some arbitrary element, add the element(s) to the set | [
"Given",
"a",
"set",
"and",
"some",
"arbitrary",
"element",
"add",
"the",
"element",
"(",
"s",
")",
"to",
"the",
"set"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1798-L1808 | train |
pypa/pipenv | pipenv/utils.py | is_url_equal | def is_url_equal(url, other_url):
# type: (str, str) -> bool
"""
Compare two urls by scheme, host, and path, ignoring auth
:param str url: The initial URL to compare
:param str url: Second url to compare to the first
:return: Whether the URLs are equal without **auth**, **query**, and **fragmen... | python | def is_url_equal(url, other_url):
# type: (str, str) -> bool
"""
Compare two urls by scheme, host, and path, ignoring auth
:param str url: The initial URL to compare
:param str url: Second url to compare to the first
:return: Whether the URLs are equal without **auth**, **query**, and **fragmen... | [
"def",
"is_url_equal",
"(",
"url",
",",
"other_url",
")",
":",
"# type: (str, str) -> bool",
"if",
"not",
"isinstance",
"(",
"url",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected string for url, received {0!r}\"",
".",
"format",
... | Compare two urls by scheme, host, and path, ignoring auth
:param str url: The initial URL to compare
:param str url: Second url to compare to the first
:return: Whether the URLs are equal without **auth**, **query**, and **fragment**
:rtype: bool
>>> is_url_equal("https://user:pass@mydomain.com/so... | [
"Compare",
"two",
"urls",
"by",
"scheme",
"host",
"and",
"path",
"ignoring",
"auth"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1811-L1837 | train |
pypa/pipenv | pipenv/utils.py | make_posix | def make_posix(path):
# type: (str) -> str
"""
Convert a path with possible windows-style separators to a posix-style path
(with **/** separators instead of **\\** separators).
:param Text path: A path to convert.
:return: A converted posix-style path
:rtype: Text
>>> make_posix("c:/us... | python | def make_posix(path):
# type: (str) -> str
"""
Convert a path with possible windows-style separators to a posix-style path
(with **/** separators instead of **\\** separators).
:param Text path: A path to convert.
:return: A converted posix-style path
:rtype: Text
>>> make_posix("c:/us... | [
"def",
"make_posix",
"(",
"path",
")",
":",
"# type: (str) -> str",
"if",
"not",
"isinstance",
"(",
"path",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected a string for path, received {0!r}...\"",
".",
"format",
"(",
"path",
")",
... | Convert a path with possible windows-style separators to a posix-style path
(with **/** separators instead of **\\** separators).
:param Text path: A path to convert.
:return: A converted posix-style path
:rtype: Text
>>> make_posix("c:/users/user/venvs/some_venv\\Lib\\site-packages")
"c:/user... | [
"Convert",
"a",
"path",
"with",
"possible",
"windows",
"-",
"style",
"separators",
"to",
"a",
"posix",
"-",
"style",
"path",
"(",
"with",
"**",
"/",
"**",
"separators",
"instead",
"of",
"**",
"\\\\",
"**",
"separators",
")",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1841-L1865 | train |
pypa/pipenv | pipenv/utils.py | find_python | def find_python(finder, line=None):
"""
Given a `pythonfinder.Finder` instance and an optional line, find a corresponding python
:param finder: A :class:`pythonfinder.Finder` instance to use for searching
:type finder: :class:pythonfinder.Finder`
:param str line: A version, path, name, or nothing, ... | python | def find_python(finder, line=None):
"""
Given a `pythonfinder.Finder` instance and an optional line, find a corresponding python
:param finder: A :class:`pythonfinder.Finder` instance to use for searching
:type finder: :class:pythonfinder.Finder`
:param str line: A version, path, name, or nothing, ... | [
"def",
"find_python",
"(",
"finder",
",",
"line",
"=",
"None",
")",
":",
"if",
"line",
"and",
"not",
"isinstance",
"(",
"line",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"Invalid python search type: expected string, received {0!r}\"",... | Given a `pythonfinder.Finder` instance and an optional line, find a corresponding python
:param finder: A :class:`pythonfinder.Finder` instance to use for searching
:type finder: :class:pythonfinder.Finder`
:param str line: A version, path, name, or nothing, defaults to None
:return: A path to python
... | [
"Given",
"a",
"pythonfinder",
".",
"Finder",
"instance",
"and",
"an",
"optional",
"line",
"find",
"a",
"corresponding",
"python"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1877-L1916 | train |
pypa/pipenv | pipenv/utils.py | is_python_command | def is_python_command(line):
"""
Given an input, checks whether the input is a request for python or notself.
This can be a version, a python runtime name, or a generic 'python' or 'pythonX.Y'
:param str line: A potential request to find python
:returns: Whether the line is a python lookup
:rt... | python | def is_python_command(line):
"""
Given an input, checks whether the input is a request for python or notself.
This can be a version, a python runtime name, or a generic 'python' or 'pythonX.Y'
:param str line: A potential request to find python
:returns: Whether the line is a python lookup
:rt... | [
"def",
"is_python_command",
"(",
"line",
")",
":",
"if",
"not",
"isinstance",
"(",
"line",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"Not a valid command to check: {0!r}\"",
".",
"format",
"(",
"line",
")",
")",
"from",
"pipenv",
... | Given an input, checks whether the input is a request for python or notself.
This can be a version, a python runtime name, or a generic 'python' or 'pythonX.Y'
:param str line: A potential request to find python
:returns: Whether the line is a python lookup
:rtype: bool | [
"Given",
"an",
"input",
"checks",
"whether",
"the",
"input",
"is",
"a",
"request",
"for",
"python",
"or",
"notself",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L1919-L1941 | train |
pypa/pipenv | pipenv/utils.py | Resolver.get_hash | def get_hash(self, ireq, ireq_hashes=None):
"""
Retrieve hashes for a specific ``InstallRequirement`` instance.
:param ireq: An ``InstallRequirement`` to retrieve hashes for
:type ireq: :class:`~pip_shims.InstallRequirement`
:return: A set of hashes.
:rtype: Set
... | python | def get_hash(self, ireq, ireq_hashes=None):
"""
Retrieve hashes for a specific ``InstallRequirement`` instance.
:param ireq: An ``InstallRequirement`` to retrieve hashes for
:type ireq: :class:`~pip_shims.InstallRequirement`
:return: A set of hashes.
:rtype: Set
... | [
"def",
"get_hash",
"(",
"self",
",",
"ireq",
",",
"ireq_hashes",
"=",
"None",
")",
":",
"# We _ALWAYS MUST PRIORITIZE_ the inclusion of hashes from local sources",
"# PLEASE *DO NOT MODIFY THIS* TO CHECK WHETHER AN IREQ ALREADY HAS A HASH",
"# RESOLVED. The resolver will pull hashes from... | Retrieve hashes for a specific ``InstallRequirement`` instance.
:param ireq: An ``InstallRequirement`` to retrieve hashes for
:type ireq: :class:`~pip_shims.InstallRequirement`
:return: A set of hashes.
:rtype: Set | [
"Retrieve",
"hashes",
"for",
"a",
"specific",
"InstallRequirement",
"instance",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/utils.py#L682-L714 | train |
pypa/pipenv | pipenv/vendor/shellingham/posix/__init__.py | _get_process_mapping | def _get_process_mapping():
"""Select a way to obtain process information from the system.
* `/proc` is used if supported.
* The system `ps` utility is used as a fallback option.
"""
for impl in (proc, ps):
try:
mapping = impl.get_process_mapping()
except EnvironmentErro... | python | def _get_process_mapping():
"""Select a way to obtain process information from the system.
* `/proc` is used if supported.
* The system `ps` utility is used as a fallback option.
"""
for impl in (proc, ps):
try:
mapping = impl.get_process_mapping()
except EnvironmentErro... | [
"def",
"_get_process_mapping",
"(",
")",
":",
"for",
"impl",
"in",
"(",
"proc",
",",
"ps",
")",
":",
"try",
":",
"mapping",
"=",
"impl",
".",
"get_process_mapping",
"(",
")",
"except",
"EnvironmentError",
":",
"continue",
"return",
"mapping",
"raise",
"She... | Select a way to obtain process information from the system.
* `/proc` is used if supported.
* The system `ps` utility is used as a fallback option. | [
"Select",
"a",
"way",
"to",
"obtain",
"process",
"information",
"from",
"the",
"system",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/posix/__init__.py#L7-L19 | train |
pypa/pipenv | pipenv/vendor/shellingham/posix/__init__.py | _iter_process_command | def _iter_process_command(mapping, pid, max_depth):
"""Iterator to traverse up the tree, yielding `argv[0]` of each process.
"""
for _ in range(max_depth):
try:
proc = mapping[pid]
except KeyError: # We've reached the root process. Give up.
break
try:
... | python | def _iter_process_command(mapping, pid, max_depth):
"""Iterator to traverse up the tree, yielding `argv[0]` of each process.
"""
for _ in range(max_depth):
try:
proc = mapping[pid]
except KeyError: # We've reached the root process. Give up.
break
try:
... | [
"def",
"_iter_process_command",
"(",
"mapping",
",",
"pid",
",",
"max_depth",
")",
":",
"for",
"_",
"in",
"range",
"(",
"max_depth",
")",
":",
"try",
":",
"proc",
"=",
"mapping",
"[",
"pid",
"]",
"except",
"KeyError",
":",
"# We've reached the root process. ... | Iterator to traverse up the tree, yielding `argv[0]` of each process. | [
"Iterator",
"to",
"traverse",
"up",
"the",
"tree",
"yielding",
"argv",
"[",
"0",
"]",
"of",
"each",
"process",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/posix/__init__.py#L22-L36 | train |
pypa/pipenv | pipenv/vendor/shellingham/posix/__init__.py | _get_login_shell | def _get_login_shell(proc_cmd):
"""Form shell information from the SHELL environment variable if possible.
"""
login_shell = os.environ.get('SHELL', '')
if login_shell:
proc_cmd = login_shell
else:
proc_cmd = proc_cmd[1:]
return (os.path.basename(proc_cmd).lower(), proc_cmd) | python | def _get_login_shell(proc_cmd):
"""Form shell information from the SHELL environment variable if possible.
"""
login_shell = os.environ.get('SHELL', '')
if login_shell:
proc_cmd = login_shell
else:
proc_cmd = proc_cmd[1:]
return (os.path.basename(proc_cmd).lower(), proc_cmd) | [
"def",
"_get_login_shell",
"(",
"proc_cmd",
")",
":",
"login_shell",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'SHELL'",
",",
"''",
")",
"if",
"login_shell",
":",
"proc_cmd",
"=",
"login_shell",
"else",
":",
"proc_cmd",
"=",
"proc_cmd",
"[",
"1",
":",... | Form shell information from the SHELL environment variable if possible. | [
"Form",
"shell",
"information",
"from",
"the",
"SHELL",
"environment",
"variable",
"if",
"possible",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/posix/__init__.py#L39-L47 | train |
pypa/pipenv | pipenv/vendor/shellingham/posix/__init__.py | get_shell | def get_shell(pid=None, max_depth=6):
"""Get the shell that the supplied pid or os.getpid() is running in.
"""
pid = str(pid or os.getpid())
mapping = _get_process_mapping()
for proc_cmd in _iter_process_command(mapping, pid, max_depth):
if proc_cmd.startswith('-'): # Login shell! Let's u... | python | def get_shell(pid=None, max_depth=6):
"""Get the shell that the supplied pid or os.getpid() is running in.
"""
pid = str(pid or os.getpid())
mapping = _get_process_mapping()
for proc_cmd in _iter_process_command(mapping, pid, max_depth):
if proc_cmd.startswith('-'): # Login shell! Let's u... | [
"def",
"get_shell",
"(",
"pid",
"=",
"None",
",",
"max_depth",
"=",
"6",
")",
":",
"pid",
"=",
"str",
"(",
"pid",
"or",
"os",
".",
"getpid",
"(",
")",
")",
"mapping",
"=",
"_get_process_mapping",
"(",
")",
"for",
"proc_cmd",
"in",
"_iter_process_comman... | Get the shell that the supplied pid or os.getpid() is running in. | [
"Get",
"the",
"shell",
"that",
"the",
"supplied",
"pid",
"or",
"os",
".",
"getpid",
"()",
"is",
"running",
"in",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/posix/__init__.py#L50-L61 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | BaseAdapter.send | def send(self, request, stream=False, timeout=None, verify=True,
cert=None, proxies=None):
"""Sends PreparedRequest object. Returns Response object.
:param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
:param stream: (optional) Whether to stream the request co... | python | def send(self, request, stream=False, timeout=None, verify=True,
cert=None, proxies=None):
"""Sends PreparedRequest object. Returns Response object.
:param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
:param stream: (optional) Whether to stream the request co... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"None",
",",
"proxies",
"=",
"None",
")",
":",
"raise",
"NotImplementedError"
] | Sends PreparedRequest object. Returns Response object.
:param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
:param stream: (optional) Whether to stream the request content.
:param timeout: (optional) How long to wait for the server to send
data before giving up... | [
"Sends",
"PreparedRequest",
"object",
".",
"Returns",
"Response",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L61-L77 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | HTTPAdapter.init_poolmanager | def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs):
"""Initializes a urllib3 PoolManager.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
... | python | def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs):
"""Initializes a urllib3 PoolManager.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
... | [
"def",
"init_poolmanager",
"(",
"self",
",",
"connections",
",",
"maxsize",
",",
"block",
"=",
"DEFAULT_POOLBLOCK",
",",
"*",
"*",
"pool_kwargs",
")",
":",
"# save these values for pickling",
"self",
".",
"_pool_connections",
"=",
"connections",
"self",
".",
"_poo... | Initializes a urllib3 PoolManager.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param connections: The number of urllib3 connection pools to cache.
:param maxsize: The ma... | [
"Initializes",
"a",
"urllib3",
"PoolManager",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L146-L164 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | HTTPAdapter.proxy_manager_for | def proxy_manager_for(self, proxy, **proxy_kwargs):
"""Return urllib3 ProxyManager for the given proxy.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param proxy: The prox... | python | def proxy_manager_for(self, proxy, **proxy_kwargs):
"""Return urllib3 ProxyManager for the given proxy.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param proxy: The prox... | [
"def",
"proxy_manager_for",
"(",
"self",
",",
"proxy",
",",
"*",
"*",
"proxy_kwargs",
")",
":",
"if",
"proxy",
"in",
"self",
".",
"proxy_manager",
":",
"manager",
"=",
"self",
".",
"proxy_manager",
"[",
"proxy",
"]",
"elif",
"proxy",
".",
"lower",
"(",
... | Return urllib3 ProxyManager for the given proxy.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param proxy: The proxy to return a urllib3 ProxyManager for.
:param proxy_kw... | [
"Return",
"urllib3",
"ProxyManager",
"for",
"the",
"given",
"proxy",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L166-L201 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | HTTPAdapter.build_response | def build_response(self, req, resp):
"""Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The ... | python | def build_response(self, req, resp):
"""Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The ... | [
"def",
"build_response",
"(",
"self",
",",
"req",
",",
"resp",
")",
":",
"response",
"=",
"Response",
"(",
")",
"# Fallback to None if there's no status_code, for whatever reason.",
"response",
".",
"status_code",
"=",
"getattr",
"(",
"resp",
",",
"'status'",
",",
... | Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The :class:`PreparedRequest <PreparedRequest>` used ... | [
"Builds",
"a",
":",
"class",
":",
"Response",
"<requests",
".",
"Response",
">",
"object",
"from",
"a",
"urllib3",
"response",
".",
"This",
"should",
"not",
"be",
"called",
"from",
"user",
"code",
"and",
"is",
"only",
"exposed",
"for",
"use",
"when",
"su... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L255-L290 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | HTTPAdapter.get_connection | def get_connection(self, url, proxies=None):
"""Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param url: The URL to connect to.
:pa... | python | def get_connection(self, url, proxies=None):
"""Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param url: The URL to connect to.
:pa... | [
"def",
"get_connection",
"(",
"self",
",",
"url",
",",
"proxies",
"=",
"None",
")",
":",
"proxy",
"=",
"select_proxy",
"(",
"url",
",",
"proxies",
")",
"if",
"proxy",
":",
"proxy",
"=",
"prepend_scheme_if_needed",
"(",
"proxy",
",",
"'http'",
")",
"proxy... | Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param url: The URL to connect to.
:param proxies: (optional) A Requests-style dictionary of p... | [
"Returns",
"a",
"urllib3",
"connection",
"for",
"the",
"given",
"URL",
".",
"This",
"should",
"not",
"be",
"called",
"from",
"user",
"code",
"and",
"is",
"only",
"exposed",
"for",
"use",
"when",
"subclassing",
"the",
":",
"class",
":",
"HTTPAdapter",
"<req... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L292-L317 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | HTTPAdapter.close | def close(self):
"""Disposes of any internal state.
Currently, this closes the PoolManager and any active ProxyManager,
which closes any pooled connections.
"""
self.poolmanager.clear()
for proxy in self.proxy_manager.values():
proxy.clear() | python | def close(self):
"""Disposes of any internal state.
Currently, this closes the PoolManager and any active ProxyManager,
which closes any pooled connections.
"""
self.poolmanager.clear()
for proxy in self.proxy_manager.values():
proxy.clear() | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"poolmanager",
".",
"clear",
"(",
")",
"for",
"proxy",
"in",
"self",
".",
"proxy_manager",
".",
"values",
"(",
")",
":",
"proxy",
".",
"clear",
"(",
")"
] | Disposes of any internal state.
Currently, this closes the PoolManager and any active ProxyManager,
which closes any pooled connections. | [
"Disposes",
"of",
"any",
"internal",
"state",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L319-L327 | train |
pypa/pipenv | pipenv/vendor/requests/adapters.py | HTTPAdapter.request_url | def request_url(self, request, proxies):
"""Obtain the url to use when making the final request.
If the message is being sent through a HTTP proxy, the full URL has to
be used. Otherwise, we should only use the path portion of the URL.
This should not be called from user code, and is o... | python | def request_url(self, request, proxies):
"""Obtain the url to use when making the final request.
If the message is being sent through a HTTP proxy, the full URL has to
be used. Otherwise, we should only use the path portion of the URL.
This should not be called from user code, and is o... | [
"def",
"request_url",
"(",
"self",
",",
"request",
",",
"proxies",
")",
":",
"proxy",
"=",
"select_proxy",
"(",
"request",
".",
"url",
",",
"proxies",
")",
"scheme",
"=",
"urlparse",
"(",
"request",
".",
"url",
")",
".",
"scheme",
"is_proxied_http_request"... | Obtain the url to use when making the final request.
If the message is being sent through a HTTP proxy, the full URL has to
be used. Otherwise, we should only use the path portion of the URL.
This should not be called from user code, and is only exposed for use
when subclassing the
... | [
"Obtain",
"the",
"url",
"to",
"use",
"when",
"making",
"the",
"final",
"request",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/adapters.py#L329-L356 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | strip_ssh_from_git_uri | def strip_ssh_from_git_uri(uri):
# type: (S) -> S
"""Return git+ssh:// formatted URI to git+git@ format"""
if isinstance(uri, six.string_types):
if "git+ssh://" in uri:
parsed = urlparse(uri)
# split the path on the first separating / so we can put the first segment
... | python | def strip_ssh_from_git_uri(uri):
# type: (S) -> S
"""Return git+ssh:// formatted URI to git+git@ format"""
if isinstance(uri, six.string_types):
if "git+ssh://" in uri:
parsed = urlparse(uri)
# split the path on the first separating / so we can put the first segment
... | [
"def",
"strip_ssh_from_git_uri",
"(",
"uri",
")",
":",
"# type: (S) -> S",
"if",
"isinstance",
"(",
"uri",
",",
"six",
".",
"string_types",
")",
":",
"if",
"\"git+ssh://\"",
"in",
"uri",
":",
"parsed",
"=",
"urlparse",
"(",
"uri",
")",
"# split the path on the... | Return git+ssh:// formatted URI to git+git@ format | [
"Return",
"git",
"+",
"ssh",
":",
"//",
"formatted",
"URI",
"to",
"git",
"+",
"git"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L116-L130 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | add_ssh_scheme_to_git_uri | def add_ssh_scheme_to_git_uri(uri):
# type: (S) -> S
"""Cleans VCS uris from pipenv.patched.notpip format"""
if isinstance(uri, six.string_types):
# Add scheme for parsing purposes, this is also what pip does
if uri.startswith("git+") and "://" not in uri:
uri = uri.replace("git+... | python | def add_ssh_scheme_to_git_uri(uri):
# type: (S) -> S
"""Cleans VCS uris from pipenv.patched.notpip format"""
if isinstance(uri, six.string_types):
# Add scheme for parsing purposes, this is also what pip does
if uri.startswith("git+") and "://" not in uri:
uri = uri.replace("git+... | [
"def",
"add_ssh_scheme_to_git_uri",
"(",
"uri",
")",
":",
"# type: (S) -> S",
"if",
"isinstance",
"(",
"uri",
",",
"six",
".",
"string_types",
")",
":",
"# Add scheme for parsing purposes, this is also what pip does",
"if",
"uri",
".",
"startswith",
"(",
"\"git+\"",
"... | Cleans VCS uris from pipenv.patched.notpip format | [
"Cleans",
"VCS",
"uris",
"from",
"pipenv",
".",
"patched",
".",
"notpip",
"format"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L133-L145 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | is_vcs | def is_vcs(pipfile_entry):
# type: (PipfileType) -> bool
"""Determine if dictionary entry from Pipfile is for a vcs dependency."""
if isinstance(pipfile_entry, Mapping):
return any(key for key in pipfile_entry.keys() if key in VCS_LIST)
elif isinstance(pipfile_entry, six.string_types):
... | python | def is_vcs(pipfile_entry):
# type: (PipfileType) -> bool
"""Determine if dictionary entry from Pipfile is for a vcs dependency."""
if isinstance(pipfile_entry, Mapping):
return any(key for key in pipfile_entry.keys() if key in VCS_LIST)
elif isinstance(pipfile_entry, six.string_types):
... | [
"def",
"is_vcs",
"(",
"pipfile_entry",
")",
":",
"# type: (PipfileType) -> bool",
"if",
"isinstance",
"(",
"pipfile_entry",
",",
"Mapping",
")",
":",
"return",
"any",
"(",
"key",
"for",
"key",
"in",
"pipfile_entry",
".",
"keys",
"(",
")",
"if",
"key",
"in",
... | Determine if dictionary entry from Pipfile is for a vcs dependency. | [
"Determine",
"if",
"dictionary",
"entry",
"from",
"Pipfile",
"is",
"for",
"a",
"vcs",
"dependency",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L148-L160 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | multi_split | def multi_split(s, split):
# type: (S, Iterable[S]) -> List[S]
"""Splits on multiple given separators."""
for r in split:
s = s.replace(r, "|")
return [i for i in s.split("|") if len(i) > 0] | python | def multi_split(s, split):
# type: (S, Iterable[S]) -> List[S]
"""Splits on multiple given separators."""
for r in split:
s = s.replace(r, "|")
return [i for i in s.split("|") if len(i) > 0] | [
"def",
"multi_split",
"(",
"s",
",",
"split",
")",
":",
"# type: (S, Iterable[S]) -> List[S]",
"for",
"r",
"in",
"split",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"r",
",",
"\"|\"",
")",
"return",
"[",
"i",
"for",
"i",
"in",
"s",
".",
"split",
"(",
... | Splits on multiple given separators. | [
"Splits",
"on",
"multiple",
"given",
"separators",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L172-L177 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | convert_entry_to_path | def convert_entry_to_path(path):
# type: (Dict[S, Union[S, bool, Tuple[S], List[S]]]) -> S
"""Convert a pipfile entry to a string"""
if not isinstance(path, Mapping):
raise TypeError("expecting a mapping, received {0!r}".format(path))
if not any(key in path for key in ["file", "path"]):
... | python | def convert_entry_to_path(path):
# type: (Dict[S, Union[S, bool, Tuple[S], List[S]]]) -> S
"""Convert a pipfile entry to a string"""
if not isinstance(path, Mapping):
raise TypeError("expecting a mapping, received {0!r}".format(path))
if not any(key in path for key in ["file", "path"]):
... | [
"def",
"convert_entry_to_path",
"(",
"path",
")",
":",
"# type: (Dict[S, Union[S, bool, Tuple[S], List[S]]]) -> S",
"if",
"not",
"isinstance",
"(",
"path",
",",
"Mapping",
")",
":",
"raise",
"TypeError",
"(",
"\"expecting a mapping, received {0!r}\"",
".",
"format",
"(",
... | Convert a pipfile entry to a string | [
"Convert",
"a",
"pipfile",
"entry",
"to",
"a",
"string"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L187-L202 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | is_installable_file | def is_installable_file(path):
# type: (PipfileType) -> bool
"""Determine if a path can potentially be installed"""
from packaging import specifiers
if isinstance(path, Mapping):
path = convert_entry_to_path(path)
# If the string starts with a valid specifier operator, test if it is a vali... | python | def is_installable_file(path):
# type: (PipfileType) -> bool
"""Determine if a path can potentially be installed"""
from packaging import specifiers
if isinstance(path, Mapping):
path = convert_entry_to_path(path)
# If the string starts with a valid specifier operator, test if it is a vali... | [
"def",
"is_installable_file",
"(",
"path",
")",
":",
"# type: (PipfileType) -> bool",
"from",
"packaging",
"import",
"specifiers",
"if",
"isinstance",
"(",
"path",
",",
"Mapping",
")",
":",
"path",
"=",
"convert_entry_to_path",
"(",
"path",
")",
"# If the string sta... | Determine if a path can potentially be installed | [
"Determine",
"if",
"a",
"path",
"can",
"potentially",
"be",
"installed"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L205-L246 | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | get_path | def get_path(root, path, default=_UNSET):
"""Retrieve a value from a nested object via a tuple representing the
lookup path.
>>> root = {'a': {'b': {'c': [[1], [2], [3]]}}}
>>> get_path(root, ('a', 'b', 'c', 2, 0))
3
The path format is intentionally consistent with that of
:func:`remap`.
... | python | def get_path(root, path, default=_UNSET):
"""Retrieve a value from a nested object via a tuple representing the
lookup path.
>>> root = {'a': {'b': {'c': [[1], [2], [3]]}}}
>>> get_path(root, ('a', 'b', 'c', 2, 0))
3
The path format is intentionally consistent with that of
:func:`remap`.
... | [
"def",
"get_path",
"(",
"root",
",",
"path",
",",
"default",
"=",
"_UNSET",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"six",
".",
"string_types",
")",
":",
"path",
"=",
"path",
".",
"split",
"(",
"\".\"",
")",
"cur",
"=",
"root",
"try",
":",
... | Retrieve a value from a nested object via a tuple representing the
lookup path.
>>> root = {'a': {'b': {'c': [[1], [2], [3]]}}}
>>> get_path(root, ('a', 'b', 'c', 2, 0))
3
The path format is intentionally consistent with that of
:func:`remap`.
One of get_path's chief aims is improved error m... | [
"Retrieve",
"a",
"value",
"from",
"a",
"nested",
"object",
"via",
"a",
"tuple",
"representing",
"the",
"lookup",
"path",
".",
">>>",
"root",
"=",
"{",
"a",
":",
"{",
"b",
":",
"{",
"c",
":",
"[[",
"1",
"]",
"[",
"2",
"]",
"[",
"3",
"]]",
"}}}",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L409-L458 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/exceptions.py | HashMismatch._hash_comparison | def _hash_comparison(self):
"""
Return a comparison of actual and expected hash values.
Example::
Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde
or 123451234512345123451234512345123451234512345
Got bcdefbcdefb... | python | def _hash_comparison(self):
"""
Return a comparison of actual and expected hash values.
Example::
Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde
or 123451234512345123451234512345123451234512345
Got bcdefbcdefb... | [
"def",
"_hash_comparison",
"(",
"self",
")",
":",
"def",
"hash_then_or",
"(",
"hash_name",
")",
":",
"# For now, all the decent hashes have 6-char names, so we can get",
"# away with hard-coding space literals.",
"return",
"chain",
"(",
"[",
"hash_name",
"]",
",",
"repeat",... | Return a comparison of actual and expected hash values.
Example::
Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde
or 123451234512345123451234512345123451234512345
Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef | [
"Return",
"a",
"comparison",
"of",
"actual",
"and",
"expected",
"hash",
"values",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/exceptions.py#L226-L250 | train |
pypa/pipenv | pipenv/vendor/chardet/universaldetector.py | UniversalDetector.reset | def reset(self):
"""
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
"""
self.result = {'encoding': None, 'confidence': 0.0... | python | def reset(self):
"""
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
"""
self.result = {'encoding': None, 'confidence': 0.0... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"result",
"=",
"{",
"'encoding'",
":",
"None",
",",
"'confidence'",
":",
"0.0",
",",
"'language'",
":",
"None",
"}",
"self",
".",
"done",
"=",
"False",
"self",
".",
"_got_data",
"=",
"False",
"self"... | Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents. | [
"Reset",
"the",
"UniversalDetector",
"and",
"all",
"of",
"its",
"probers",
"back",
"to",
"their",
"initial",
"states",
".",
"This",
"is",
"called",
"by",
"__init__",
"so",
"you",
"only",
"need",
"to",
"call",
"this",
"directly",
"in",
"between",
"analyses",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/chardet/universaldetector.py#L94-L109 | train |
pypa/pipenv | pipenv/vendor/chardet/universaldetector.py | UniversalDetector.feed | def feed(self, byte_str):
"""
Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if... | python | def feed(self, byte_str):
"""
Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if... | [
"def",
"feed",
"(",
"self",
",",
"byte_str",
")",
":",
"if",
"self",
".",
"done",
":",
"return",
"if",
"not",
"len",
"(",
"byte_str",
")",
":",
"return",
"if",
"not",
"isinstance",
"(",
"byte_str",
",",
"bytearray",
")",
":",
"byte_str",
"=",
"bytear... | Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if it has made a prediction
(in the ``re... | [
"Takes",
"a",
"chunk",
"of",
"a",
"document",
"and",
"feeds",
"it",
"through",
"all",
"of",
"the",
"relevant",
"charset",
"probers",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/chardet/universaldetector.py#L111-L218 | train |
pypa/pipenv | pipenv/vendor/chardet/universaldetector.py | UniversalDetector.close | def close(self):
"""
Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`.
"""
# Don't bother with checks if we're already done
... | python | def close(self):
"""
Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`.
"""
# Don't bother with checks if we're already done
... | [
"def",
"close",
"(",
"self",
")",
":",
"# Don't bother with checks if we're already done",
"if",
"self",
".",
"done",
":",
"return",
"self",
".",
"result",
"self",
".",
"done",
"=",
"True",
"if",
"not",
"self",
".",
"_got_data",
":",
"self",
".",
"logger",
... | Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`. | [
"Stop",
"analyzing",
"the",
"current",
"document",
"and",
"come",
"up",
"with",
"a",
"final",
"prediction",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/chardet/universaldetector.py#L220-L286 | train |
pypa/pipenv | pipenv/vendor/pexpect/replwrap.py | bash | def bash(command="bash"):
"""Start a bash shell and return a :class:`REPLWrapper` object."""
bashrc = os.path.join(os.path.dirname(__file__), 'bashrc.sh')
child = pexpect.spawn(command, ['--rcfile', bashrc], echo=False,
encoding='utf-8')
# If the user runs 'env', the value of ... | python | def bash(command="bash"):
"""Start a bash shell and return a :class:`REPLWrapper` object."""
bashrc = os.path.join(os.path.dirname(__file__), 'bashrc.sh')
child = pexpect.spawn(command, ['--rcfile', bashrc], echo=False,
encoding='utf-8')
# If the user runs 'env', the value of ... | [
"def",
"bash",
"(",
"command",
"=",
"\"bash\"",
")",
":",
"bashrc",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'bashrc.sh'",
")",
"child",
"=",
"pexpect",
".",
"spawn",
"(",
"command",
"... | Start a bash shell and return a :class:`REPLWrapper` object. | [
"Start",
"a",
"bash",
"shell",
"and",
"return",
"a",
":",
"class",
":",
"REPLWrapper",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/replwrap.py#L107-L122 | train |
pypa/pipenv | pipenv/vendor/pexpect/replwrap.py | REPLWrapper.run_command | def run_command(self, command, timeout=-1):
"""Send a command to the REPL, wait for and return output.
:param str command: The command to send. Trailing newlines are not needed.
This should be a complete block of input that will trigger execution;
if a continuation prompt is found a... | python | def run_command(self, command, timeout=-1):
"""Send a command to the REPL, wait for and return output.
:param str command: The command to send. Trailing newlines are not needed.
This should be a complete block of input that will trigger execution;
if a continuation prompt is found a... | [
"def",
"run_command",
"(",
"self",
",",
"command",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"# Split up multiline commands and feed them in bit-by-bit",
"cmdlines",
"=",
"command",
".",
"splitlines",
"(",
")",
"# splitlines ignores trailing newlines - add it back in manuall... | Send a command to the REPL, wait for and return output.
:param str command: The command to send. Trailing newlines are not needed.
This should be a complete block of input that will trigger execution;
if a continuation prompt is found after sending input, :exc:`ValueError`
will be... | [
"Send",
"a",
"command",
"to",
"the",
"REPL",
"wait",
"for",
"and",
"return",
"output",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/replwrap.py#L68-L101 | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/requirements.py | Line.parse_hashes | def parse_hashes(self):
# type: () -> None
"""
Parse hashes from *self.line* and set them on the current object.
:returns: Nothing
:rtype: None
"""
line, hashes = self.split_hashes(self.line)
self.hashes = hashes
self.line = line | python | def parse_hashes(self):
# type: () -> None
"""
Parse hashes from *self.line* and set them on the current object.
:returns: Nothing
:rtype: None
"""
line, hashes = self.split_hashes(self.line)
self.hashes = hashes
self.line = line | [
"def",
"parse_hashes",
"(",
"self",
")",
":",
"# type: () -> None",
"line",
",",
"hashes",
"=",
"self",
".",
"split_hashes",
"(",
"self",
".",
"line",
")",
"self",
".",
"hashes",
"=",
"hashes",
"self",
".",
"line",
"=",
"line"
] | Parse hashes from *self.line* and set them on the current object.
:returns: Nothing
:rtype: None | [
"Parse",
"hashes",
"from",
"*",
"self",
".",
"line",
"*",
"and",
"set",
"them",
"on",
"the",
"current",
"object",
".",
":",
"returns",
":",
"Nothing",
":",
"rtype",
":",
"None"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/requirements.py#L483-L493 | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/requirements.py | Line.parse_extras | def parse_extras(self):
# type: () -> None
"""
Parse extras from *self.line* and set them on the current object
:returns: Nothing
:rtype: None
"""
extras = None
if "@" in self.line or self.is_vcs or self.is_url:
line = "{0}".format(self.line)
... | python | def parse_extras(self):
# type: () -> None
"""
Parse extras from *self.line* and set them on the current object
:returns: Nothing
:rtype: None
"""
extras = None
if "@" in self.line or self.is_vcs or self.is_url:
line = "{0}".format(self.line)
... | [
"def",
"parse_extras",
"(",
"self",
")",
":",
"# type: () -> None",
"extras",
"=",
"None",
"if",
"\"@\"",
"in",
"self",
".",
"line",
"or",
"self",
".",
"is_vcs",
"or",
"self",
".",
"is_url",
":",
"line",
"=",
"\"{0}\"",
".",
"format",
"(",
"self",
".",... | Parse extras from *self.line* and set them on the current object
:returns: Nothing
:rtype: None | [
"Parse",
"extras",
"from",
"*",
"self",
".",
"line",
"*",
"and",
"set",
"them",
"on",
"the",
"current",
"object",
":",
"returns",
":",
"Nothing",
":",
"rtype",
":",
"None"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/requirements.py#L495-L527 | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/requirements.py | Line.get_url | def get_url(self):
# type: () -> STRING_TYPE
"""Sets ``self.name`` if given a **PEP-508** style URL"""
line = self.line
try:
parsed = URI.parse(line)
line = parsed.to_string(escape_password=False, direct=False, strip_ref=True)
except ValueError:
... | python | def get_url(self):
# type: () -> STRING_TYPE
"""Sets ``self.name`` if given a **PEP-508** style URL"""
line = self.line
try:
parsed = URI.parse(line)
line = parsed.to_string(escape_password=False, direct=False, strip_ref=True)
except ValueError:
... | [
"def",
"get_url",
"(",
"self",
")",
":",
"# type: () -> STRING_TYPE",
"line",
"=",
"self",
".",
"line",
"try",
":",
"parsed",
"=",
"URI",
".",
"parse",
"(",
"line",
")",
"line",
"=",
"parsed",
".",
"to_string",
"(",
"escape_password",
"=",
"False",
",",
... | Sets ``self.name`` if given a **PEP-508** style URL | [
"Sets",
"self",
".",
"name",
"if",
"given",
"a",
"**",
"PEP",
"-",
"508",
"**",
"style",
"URL"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/requirements.py#L529-L562 | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/requirements.py | Line.requirement_info | def requirement_info(self):
# type: () -> Tuple[Optional[S], Tuple[Optional[S], ...], Optional[S]]
"""
Generates a 3-tuple of the requisite *name*, *extras* and *url* to generate a
:class:`~packaging.requirements.Requirement` out of.
:return: A Tuple of an optional name, a Tuple... | python | def requirement_info(self):
# type: () -> Tuple[Optional[S], Tuple[Optional[S], ...], Optional[S]]
"""
Generates a 3-tuple of the requisite *name*, *extras* and *url* to generate a
:class:`~packaging.requirements.Requirement` out of.
:return: A Tuple of an optional name, a Tuple... | [
"def",
"requirement_info",
"(",
"self",
")",
":",
"# type: () -> Tuple[Optional[S], Tuple[Optional[S], ...], Optional[S]]",
"# Direct URLs can be converted to packaging requirements directly, but",
"# only if they are `file://` (with only two slashes)",
"name",
"=",
"None",
"# type: Optional... | Generates a 3-tuple of the requisite *name*, *extras* and *url* to generate a
:class:`~packaging.requirements.Requirement` out of.
:return: A Tuple of an optional name, a Tuple of extras, and an optional URL.
:rtype: Tuple[Optional[S], Tuple[Optional[S], ...], Optional[S]] | [
"Generates",
"a",
"3",
"-",
"tuple",
"of",
"the",
"requisite",
"*",
"name",
"*",
"*",
"extras",
"*",
"and",
"*",
"url",
"*",
"to",
"generate",
"a",
":",
"class",
":",
"~packaging",
".",
"requirements",
".",
"Requirement",
"out",
"of",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/requirements.py#L1044-L1081 | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/requirements.py | Line.line_is_installable | def line_is_installable(self):
# type: () -> bool
"""
This is a safeguard against decoy requirements when a user installs a package
whose name coincides with the name of a folder in the cwd, e.g. install *alembic*
when there is a folder called *alembic* in the working directory.
... | python | def line_is_installable(self):
# type: () -> bool
"""
This is a safeguard against decoy requirements when a user installs a package
whose name coincides with the name of a folder in the cwd, e.g. install *alembic*
when there is a folder called *alembic* in the working directory.
... | [
"def",
"line_is_installable",
"(",
"self",
")",
":",
"# type: () -> bool",
"line",
"=",
"self",
".",
"line",
"if",
"is_file_url",
"(",
"line",
")",
":",
"link",
"=",
"create_link",
"(",
"line",
")",
"line",
"=",
"link",
".",
"url_without_fragment",
"line",
... | This is a safeguard against decoy requirements when a user installs a package
whose name coincides with the name of a folder in the cwd, e.g. install *alembic*
when there is a folder called *alembic* in the working directory.
In this case we first need to check that the given requirement is a v... | [
"This",
"is",
"a",
"safeguard",
"against",
"decoy",
"requirements",
"when",
"a",
"user",
"installs",
"a",
"package",
"whose",
"name",
"coincides",
"with",
"the",
"name",
"of",
"a",
"folder",
"in",
"the",
"cwd",
"e",
".",
"g",
".",
"install",
"*",
"alembi... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/requirements.py#L1084-L1109 | train |
pypa/pipenv | pipenv/vendor/ptyprocess/_fork_pty.py | fork_pty | def fork_pty():
'''This implements a substitute for the forkpty system call. This
should be more portable than the pty.fork() function. Specifically,
this should work on Solaris.
Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to
resolve the issue with Python's pty.fork() not s... | python | def fork_pty():
'''This implements a substitute for the forkpty system call. This
should be more portable than the pty.fork() function. Specifically,
this should work on Solaris.
Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to
resolve the issue with Python's pty.fork() not s... | [
"def",
"fork_pty",
"(",
")",
":",
"parent_fd",
",",
"child_fd",
"=",
"os",
".",
"openpty",
"(",
")",
"if",
"parent_fd",
"<",
"0",
"or",
"child_fd",
"<",
"0",
":",
"raise",
"OSError",
"(",
"\"os.openpty() failed\"",
")",
"pid",
"=",
"os",
".",
"fork",
... | This implements a substitute for the forkpty system call. This
should be more portable than the pty.fork() function. Specifically,
this should work on Solaris.
Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to
resolve the issue with Python's pty.fork() not supporting Solaris,
... | [
"This",
"implements",
"a",
"substitute",
"for",
"the",
"forkpty",
"system",
"call",
".",
"This",
"should",
"be",
"more",
"portable",
"than",
"the",
"pty",
".",
"fork",
"()",
"function",
".",
"Specifically",
"this",
"should",
"work",
"on",
"Solaris",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/ptyprocess/_fork_pty.py#L9-L41 | train |
pypa/pipenv | pipenv/vendor/ptyprocess/_fork_pty.py | pty_make_controlling_tty | def pty_make_controlling_tty(tty_fd):
'''This makes the pseudo-terminal the controlling tty. This should be
more portable than the pty.fork() function. Specifically, this should
work on Solaris. '''
child_name = os.ttyname(tty_fd)
# Disconnect from controlling tty, if any. Raises OSError of ENXIO... | python | def pty_make_controlling_tty(tty_fd):
'''This makes the pseudo-terminal the controlling tty. This should be
more portable than the pty.fork() function. Specifically, this should
work on Solaris. '''
child_name = os.ttyname(tty_fd)
# Disconnect from controlling tty, if any. Raises OSError of ENXIO... | [
"def",
"pty_make_controlling_tty",
"(",
"tty_fd",
")",
":",
"child_name",
"=",
"os",
".",
"ttyname",
"(",
"tty_fd",
")",
"# Disconnect from controlling tty, if any. Raises OSError of ENXIO",
"# if there was no controlling tty to begin with, such as when",
"# executed by a cron(1) jo... | This makes the pseudo-terminal the controlling tty. This should be
more portable than the pty.fork() function. Specifically, this should
work on Solaris. | [
"This",
"makes",
"the",
"pseudo",
"-",
"terminal",
"the",
"controlling",
"tty",
".",
"This",
"should",
"be",
"more",
"portable",
"than",
"the",
"pty",
".",
"fork",
"()",
"function",
".",
"Specifically",
"this",
"should",
"work",
"on",
"Solaris",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/ptyprocess/_fork_pty.py#L43-L78 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | safecall | def safecall(func):
"""Wraps a function so that it swallows exceptions."""
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception:
pass
return wrapper | python | def safecall(func):
"""Wraps a function so that it swallows exceptions."""
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception:
pass
return wrapper | [
"def",
"safecall",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
":",
"pass",
"return",
"wrapper"
] | Wraps a function so that it swallows exceptions. | [
"Wraps",
"a",
"function",
"so",
"that",
"it",
"swallows",
"exceptions",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L25-L32 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | make_str | def make_str(value):
"""Converts a value into a valid string."""
if isinstance(value, bytes):
try:
return value.decode(get_filesystem_encoding())
except UnicodeError:
return value.decode('utf-8', 'replace')
return text_type(value) | python | def make_str(value):
"""Converts a value into a valid string."""
if isinstance(value, bytes):
try:
return value.decode(get_filesystem_encoding())
except UnicodeError:
return value.decode('utf-8', 'replace')
return text_type(value) | [
"def",
"make_str",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"try",
":",
"return",
"value",
".",
"decode",
"(",
"get_filesystem_encoding",
"(",
")",
")",
"except",
"UnicodeError",
":",
"return",
"value",
".",
"deco... | Converts a value into a valid string. | [
"Converts",
"a",
"value",
"into",
"a",
"valid",
"string",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L35-L42 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | make_default_short_help | def make_default_short_help(help, max_length=45):
"""Return a condensed version of help string."""
words = help.split()
total_length = 0
result = []
done = False
for word in words:
if word[-1:] == '.':
done = True
new_length = result and 1 + len(word) or len(word)
... | python | def make_default_short_help(help, max_length=45):
"""Return a condensed version of help string."""
words = help.split()
total_length = 0
result = []
done = False
for word in words:
if word[-1:] == '.':
done = True
new_length = result and 1 + len(word) or len(word)
... | [
"def",
"make_default_short_help",
"(",
"help",
",",
"max_length",
"=",
"45",
")",
":",
"words",
"=",
"help",
".",
"split",
"(",
")",
"total_length",
"=",
"0",
"result",
"=",
"[",
"]",
"done",
"=",
"False",
"for",
"word",
"in",
"words",
":",
"if",
"wo... | Return a condensed version of help string. | [
"Return",
"a",
"condensed",
"version",
"of",
"help",
"string",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L45-L67 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | get_binary_stream | def get_binary_stream(name):
"""Returns a system stream for byte processing. This essentially
returns the stream from the sys module with the given name but it
solves some compatibility issues between different Python versions.
Primarily this function is necessary for getting binary streams on
Pyth... | python | def get_binary_stream(name):
"""Returns a system stream for byte processing. This essentially
returns the stream from the sys module with the given name but it
solves some compatibility issues between different Python versions.
Primarily this function is necessary for getting binary streams on
Pyth... | [
"def",
"get_binary_stream",
"(",
"name",
")",
":",
"opener",
"=",
"binary_streams",
".",
"get",
"(",
"name",
")",
"if",
"opener",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'Unknown standard stream %r'",
"%",
"name",
")",
"return",
"opener",
"(",
")"
] | Returns a system stream for byte processing. This essentially
returns the stream from the sys module with the given name but it
solves some compatibility issues between different Python versions.
Primarily this function is necessary for getting binary streams on
Python 3.
:param name: the name of ... | [
"Returns",
"a",
"system",
"stream",
"for",
"byte",
"processing",
".",
"This",
"essentially",
"returns",
"the",
"stream",
"from",
"the",
"sys",
"module",
"with",
"the",
"given",
"name",
"but",
"it",
"solves",
"some",
"compatibility",
"issues",
"between",
"diffe... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L264-L277 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | get_text_stream | def get_text_stream(name, encoding=None, errors='strict'):
"""Returns a system stream for text processing. This usually returns
a wrapped stream around a binary stream returned from
:func:`get_binary_stream` but it also can take shortcuts on Python 3
for already correctly configured streams.
:para... | python | def get_text_stream(name, encoding=None, errors='strict'):
"""Returns a system stream for text processing. This usually returns
a wrapped stream around a binary stream returned from
:func:`get_binary_stream` but it also can take shortcuts on Python 3
for already correctly configured streams.
:para... | [
"def",
"get_text_stream",
"(",
"name",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"opener",
"=",
"text_streams",
".",
"get",
"(",
"name",
")",
"if",
"opener",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'Unknown standard str... | Returns a system stream for text processing. This usually returns
a wrapped stream around a binary stream returned from
:func:`get_binary_stream` but it also can take shortcuts on Python 3
for already correctly configured streams.
:param name: the name of the stream to open. Valid names are ``'stdin'... | [
"Returns",
"a",
"system",
"stream",
"for",
"text",
"processing",
".",
"This",
"usually",
"returns",
"a",
"wrapped",
"stream",
"around",
"a",
"binary",
"stream",
"returned",
"from",
":",
"func",
":",
"get_binary_stream",
"but",
"it",
"also",
"can",
"take",
"s... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L280-L294 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | open_file | def open_file(filename, mode='r', encoding=None, errors='strict',
lazy=False, atomic=False):
"""This is similar to how the :class:`File` works but for manual
usage. Files are opened non lazy by default. This can open regular
files as well as stdin/stdout if ``'-'`` is passed.
If stdin/s... | python | def open_file(filename, mode='r', encoding=None, errors='strict',
lazy=False, atomic=False):
"""This is similar to how the :class:`File` works but for manual
usage. Files are opened non lazy by default. This can open regular
files as well as stdin/stdout if ``'-'`` is passed.
If stdin/s... | [
"def",
"open_file",
"(",
"filename",
",",
"mode",
"=",
"'r'",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
",",
"lazy",
"=",
"False",
",",
"atomic",
"=",
"False",
")",
":",
"if",
"lazy",
":",
"return",
"LazyFile",
"(",
"filename",
",... | This is similar to how the :class:`File` works but for manual
usage. Files are opened non lazy by default. This can open regular
files as well as stdin/stdout if ``'-'`` is passed.
If stdin/stdout is returned the stream is wrapped so that the context
manager will not close the stream accidentally. T... | [
"This",
"is",
"similar",
"to",
"how",
"the",
":",
"class",
":",
"File",
"works",
"but",
"for",
"manual",
"usage",
".",
"Files",
"are",
"opened",
"non",
"lazy",
"by",
"default",
".",
"This",
"can",
"open",
"regular",
"files",
"as",
"well",
"as",
"stdin"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L297-L327 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | format_filename | def format_filename(filename, shorten=False):
"""Formats a filename for user display. The main purpose of this
function is to ensure that the filename can be displayed at all. This
will decode the filename to unicode if necessary in a way that it will
not fail. Optionally, it can shorten the filename... | python | def format_filename(filename, shorten=False):
"""Formats a filename for user display. The main purpose of this
function is to ensure that the filename can be displayed at all. This
will decode the filename to unicode if necessary in a way that it will
not fail. Optionally, it can shorten the filename... | [
"def",
"format_filename",
"(",
"filename",
",",
"shorten",
"=",
"False",
")",
":",
"if",
"shorten",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"return",
"filename_to_ui",
"(",
"filename",
")"
] | Formats a filename for user display. The main purpose of this
function is to ensure that the filename can be displayed at all. This
will decode the filename to unicode if necessary in a way that it will
not fail. Optionally, it can shorten the filename to not include the
full path to the filename.
... | [
"Formats",
"a",
"filename",
"for",
"user",
"display",
".",
"The",
"main",
"purpose",
"of",
"this",
"function",
"is",
"to",
"ensure",
"that",
"the",
"filename",
"can",
"be",
"displayed",
"at",
"all",
".",
"This",
"will",
"decode",
"the",
"filename",
"to",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L351-L365 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | get_app_dir | def get_app_dir(app_name, roaming=True, force_posix=False):
r"""Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
To give you an idea, for an app called ``"Foo Bar"``, something like
the following folders could be re... | python | def get_app_dir(app_name, roaming=True, force_posix=False):
r"""Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
To give you an idea, for an app called ``"Foo Bar"``, something like
the following folders could be re... | [
"def",
"get_app_dir",
"(",
"app_name",
",",
"roaming",
"=",
"True",
",",
"force_posix",
"=",
"False",
")",
":",
"if",
"WIN",
":",
"key",
"=",
"roaming",
"and",
"'APPDATA'",
"or",
"'LOCALAPPDATA'",
"folder",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"... | r"""Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
To give you an idea, for an app called ``"Foo Bar"``, something like
the following folders could be returned:
Mac OS X:
``~/Library/Application Support/Foo... | [
"r",
"Returns",
"the",
"config",
"folder",
"for",
"the",
"application",
".",
"The",
"default",
"behavior",
"is",
"to",
"return",
"whatever",
"is",
"most",
"appropriate",
"for",
"the",
"operating",
"system",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L368-L416 | train |
pypa/pipenv | pipenv/vendor/click/utils.py | LazyFile.open | def open(self):
"""Opens the file if it's not yet open. This call might fail with
a :exc:`FileError`. Not handling this error will produce an error
that Click shows.
"""
if self._f is not None:
return self._f
try:
rv, self.should_close = open_str... | python | def open(self):
"""Opens the file if it's not yet open. This call might fail with
a :exc:`FileError`. Not handling this error will produce an error
that Click shows.
"""
if self._f is not None:
return self._f
try:
rv, self.should_close = open_str... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"_f",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_f",
"try",
":",
"rv",
",",
"self",
".",
"should_close",
"=",
"open_stream",
"(",
"self",
".",
"name",
",",
"self",
".",
"mode",
",",... | Opens the file if it's not yet open. This call might fail with
a :exc:`FileError`. Not handling this error will produce an error
that Click shows. | [
"Opens",
"the",
"file",
"if",
"it",
"s",
"not",
"yet",
"open",
".",
"This",
"call",
"might",
"fail",
"with",
"a",
":",
"exc",
":",
"FileError",
".",
"Not",
"handling",
"this",
"error",
"will",
"produce",
"an",
"error",
"that",
"Click",
"shows",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/utils.py#L105-L121 | train |
pypa/pipenv | pipenv/vendor/click_completion/lib.py | split_args | def split_args(line):
"""Version of shlex.split that silently accept incomplete strings.
Parameters
----------
line : str
The string to split
Returns
-------
[str]
The line split in separated arguments
"""
lex = shlex.shlex(line, posix=True)
lex.whitespace_split... | python | def split_args(line):
"""Version of shlex.split that silently accept incomplete strings.
Parameters
----------
line : str
The string to split
Returns
-------
[str]
The line split in separated arguments
"""
lex = shlex.shlex(line, posix=True)
lex.whitespace_split... | [
"def",
"split_args",
"(",
"line",
")",
":",
"lex",
"=",
"shlex",
".",
"shlex",
"(",
"line",
",",
"posix",
"=",
"True",
")",
"lex",
".",
"whitespace_split",
"=",
"True",
"lex",
".",
"commenters",
"=",
"''",
"res",
"=",
"[",
"]",
"try",
":",
"while",... | Version of shlex.split that silently accept incomplete strings.
Parameters
----------
line : str
The string to split
Returns
-------
[str]
The line split in separated arguments | [
"Version",
"of",
"shlex",
".",
"split",
"that",
"silently",
"accept",
"incomplete",
"strings",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click_completion/lib.py#L94-L120 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | confirm | def confirm(text, default=False, abort=False, prompt_suffix=': ',
show_default=True, err=False):
"""Prompts for confirmation (yes/no question).
If the user aborts the input by sending a interrupt signal this
function will catch it and raise a :exc:`Abort` exception.
.. versionadded:: 4.0
... | python | def confirm(text, default=False, abort=False, prompt_suffix=': ',
show_default=True, err=False):
"""Prompts for confirmation (yes/no question).
If the user aborts the input by sending a interrupt signal this
function will catch it and raise a :exc:`Abort` exception.
.. versionadded:: 4.0
... | [
"def",
"confirm",
"(",
"text",
",",
"default",
"=",
"False",
",",
"abort",
"=",
"False",
",",
"prompt_suffix",
"=",
"': '",
",",
"show_default",
"=",
"True",
",",
"err",
"=",
"False",
")",
":",
"prompt",
"=",
"_build_prompt",
"(",
"text",
",",
"prompt_... | Prompts for confirmation (yes/no question).
If the user aborts the input by sending a interrupt signal this
function will catch it and raise a :exc:`Abort` exception.
.. versionadded:: 4.0
Added the `err` parameter.
:param text: the question to ask.
:param default: the default for the prom... | [
"Prompts",
"for",
"confirmation",
"(",
"yes",
"/",
"no",
"question",
")",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L141-L182 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | echo_via_pager | def echo_via_pager(text_or_generator, color=None):
"""This function takes a text and shows it via an environment specific
pager on stdout.
.. versionchanged:: 3.0
Added the `color` flag.
:param text_or_generator: the text to page, or alternatively, a
generator emit... | python | def echo_via_pager(text_or_generator, color=None):
"""This function takes a text and shows it via an environment specific
pager on stdout.
.. versionchanged:: 3.0
Added the `color` flag.
:param text_or_generator: the text to page, or alternatively, a
generator emit... | [
"def",
"echo_via_pager",
"(",
"text_or_generator",
",",
"color",
"=",
"None",
")",
":",
"color",
"=",
"resolve_color_default",
"(",
"color",
")",
"if",
"inspect",
".",
"isgeneratorfunction",
"(",
"text_or_generator",
")",
":",
"i",
"=",
"text_or_generator",
"(",... | This function takes a text and shows it via an environment specific
pager on stdout.
.. versionchanged:: 3.0
Added the `color` flag.
:param text_or_generator: the text to page, or alternatively, a
generator emitting the text to page.
:param color: controls if the p... | [
"This",
"function",
"takes",
"a",
"text",
"and",
"shows",
"it",
"via",
"an",
"environment",
"specific",
"pager",
"on",
"stdout",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L232-L258 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | progressbar | def progressbar(iterable=None, length=None, label=None, show_eta=True,
show_percent=None, show_pos=False,
item_show_func=None, fill_char='#', empty_char='-',
bar_template='%(label)s [%(bar)s] %(info)s',
info_sep=' ', width=36, file=None, color=None):
... | python | def progressbar(iterable=None, length=None, label=None, show_eta=True,
show_percent=None, show_pos=False,
item_show_func=None, fill_char='#', empty_char='-',
bar_template='%(label)s [%(bar)s] %(info)s',
info_sep=' ', width=36, file=None, color=None):
... | [
"def",
"progressbar",
"(",
"iterable",
"=",
"None",
",",
"length",
"=",
"None",
",",
"label",
"=",
"None",
",",
"show_eta",
"=",
"True",
",",
"show_percent",
"=",
"None",
",",
"show_pos",
"=",
"False",
",",
"item_show_func",
"=",
"None",
",",
"fill_char"... | This function creates an iterable context manager that can be used
to iterate over something while showing a progress bar. It will
either iterate over the `iterable` or `length` items (that are counted
up). While iteration happens, this function will print a rendered
progress bar to the given `file` (... | [
"This",
"function",
"creates",
"an",
"iterable",
"context",
"manager",
"that",
"can",
"be",
"used",
"to",
"iterate",
"over",
"something",
"while",
"showing",
"a",
"progress",
"bar",
".",
"It",
"will",
"either",
"iterate",
"over",
"the",
"iterable",
"or",
"le... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L261-L351 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | clear | def clear():
"""Clears the terminal screen. This will have the effect of clearing
the whole visible space of the terminal and moving the cursor to the
top left. This does not do anything if not connected to a terminal.
.. versionadded:: 2.0
"""
if not isatty(sys.stdout):
return
# ... | python | def clear():
"""Clears the terminal screen. This will have the effect of clearing
the whole visible space of the terminal and moving the cursor to the
top left. This does not do anything if not connected to a terminal.
.. versionadded:: 2.0
"""
if not isatty(sys.stdout):
return
# ... | [
"def",
"clear",
"(",
")",
":",
"if",
"not",
"isatty",
"(",
"sys",
".",
"stdout",
")",
":",
"return",
"# If we're on Windows and we don't have colorama available, then we",
"# clear the screen by shelling out. Otherwise we can use an escape",
"# sequence.",
"if",
"WIN",
":",
... | Clears the terminal screen. This will have the effect of clearing
the whole visible space of the terminal and moving the cursor to the
top left. This does not do anything if not connected to a terminal.
.. versionadded:: 2.0 | [
"Clears",
"the",
"terminal",
"screen",
".",
"This",
"will",
"have",
"the",
"effect",
"of",
"clearing",
"the",
"whole",
"visible",
"space",
"of",
"the",
"terminal",
"and",
"moving",
"the",
"cursor",
"to",
"the",
"top",
"left",
".",
"This",
"does",
"not",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L354-L369 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | edit | def edit(text=None, editor=None, env=None, require_save=True,
extension='.txt', filename=None):
r"""Edits the given text in the defined editor. If an editor is given
(should be the full path to the executable but the regular operating
system search path is used for finding the executable) it overr... | python | def edit(text=None, editor=None, env=None, require_save=True,
extension='.txt', filename=None):
r"""Edits the given text in the defined editor. If an editor is given
(should be the full path to the executable but the regular operating
system search path is used for finding the executable) it overr... | [
"def",
"edit",
"(",
"text",
"=",
"None",
",",
"editor",
"=",
"None",
",",
"env",
"=",
"None",
",",
"require_save",
"=",
"True",
",",
"extension",
"=",
"'.txt'",
",",
"filename",
"=",
"None",
")",
":",
"from",
".",
"_termui_impl",
"import",
"Editor",
... | r"""Edits the given text in the defined editor. If an editor is given
(should be the full path to the executable but the regular operating
system search path is used for finding the executable) it overrides
the detected editor. Optionally, some environment variables can be
used. If the editor is clos... | [
"r",
"Edits",
"the",
"given",
"text",
"in",
"the",
"defined",
"editor",
".",
"If",
"an",
"editor",
"is",
"given",
"(",
"should",
"be",
"the",
"full",
"path",
"to",
"the",
"executable",
"but",
"the",
"regular",
"operating",
"system",
"search",
"path",
"is... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L481-L515 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | launch | def launch(url, wait=False, locate=False):
"""This function launches the given URL (or filename) in the default
viewer application for this file type. If this is an executable, it
might launch the executable in a new session. The return value is
the exit code of the launched application. Usually, ``0... | python | def launch(url, wait=False, locate=False):
"""This function launches the given URL (or filename) in the default
viewer application for this file type. If this is an executable, it
might launch the executable in a new session. The return value is
the exit code of the launched application. Usually, ``0... | [
"def",
"launch",
"(",
"url",
",",
"wait",
"=",
"False",
",",
"locate",
"=",
"False",
")",
":",
"from",
".",
"_termui_impl",
"import",
"open_url",
"return",
"open_url",
"(",
"url",
",",
"wait",
"=",
"wait",
",",
"locate",
"=",
"locate",
")"
] | This function launches the given URL (or filename) in the default
viewer application for this file type. If this is an executable, it
might launch the executable in a new session. The return value is
the exit code of the launched application. Usually, ``0`` indicates
success.
Examples::
... | [
"This",
"function",
"launches",
"the",
"given",
"URL",
"(",
"or",
"filename",
")",
"in",
"the",
"default",
"viewer",
"application",
"for",
"this",
"file",
"type",
".",
"If",
"this",
"is",
"an",
"executable",
"it",
"might",
"launch",
"the",
"executable",
"i... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L518-L541 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | getchar | def getchar(echo=False):
"""Fetches a single character from the terminal and returns it. This
will always return a unicode character and under certain rare
circumstances this might return more than one character. The
situations which more than one character is returned is when for
whatever reason ... | python | def getchar(echo=False):
"""Fetches a single character from the terminal and returns it. This
will always return a unicode character and under certain rare
circumstances this might return more than one character. The
situations which more than one character is returned is when for
whatever reason ... | [
"def",
"getchar",
"(",
"echo",
"=",
"False",
")",
":",
"f",
"=",
"_getchar",
"if",
"f",
"is",
"None",
":",
"from",
".",
"_termui_impl",
"import",
"getchar",
"as",
"f",
"return",
"f",
"(",
"echo",
")"
] | Fetches a single character from the terminal and returns it. This
will always return a unicode character and under certain rare
circumstances this might return more than one character. The
situations which more than one character is returned is when for
whatever reason multiple characters end up in th... | [
"Fetches",
"a",
"single",
"character",
"from",
"the",
"terminal",
"and",
"returns",
"it",
".",
"This",
"will",
"always",
"return",
"a",
"unicode",
"character",
"and",
"under",
"certain",
"rare",
"circumstances",
"this",
"might",
"return",
"more",
"than",
"one"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L549-L572 | train |
pypa/pipenv | pipenv/vendor/click/termui.py | pause | def pause(info='Press any key to continue ...', err=False):
"""This command stops execution and waits for the user to press any
key to continue. This is similar to the Windows batch "pause"
command. If the program is not run through a terminal, this command
will instead do nothing.
.. versionadde... | python | def pause(info='Press any key to continue ...', err=False):
"""This command stops execution and waits for the user to press any
key to continue. This is similar to the Windows batch "pause"
command. If the program is not run through a terminal, this command
will instead do nothing.
.. versionadde... | [
"def",
"pause",
"(",
"info",
"=",
"'Press any key to continue ...'",
",",
"err",
"=",
"False",
")",
":",
"if",
"not",
"isatty",
"(",
"sys",
".",
"stdin",
")",
"or",
"not",
"isatty",
"(",
"sys",
".",
"stdout",
")",
":",
"return",
"try",
":",
"if",
"in... | This command stops execution and waits for the user to press any
key to continue. This is similar to the Windows batch "pause"
command. If the program is not run through a terminal, this command
will instead do nothing.
.. versionadded:: 2.0
.. versionadded:: 4.0
Added the `err` parameter... | [
"This",
"command",
"stops",
"execution",
"and",
"waits",
"for",
"the",
"user",
"to",
"press",
"any",
"key",
"to",
"continue",
".",
"This",
"is",
"similar",
"to",
"the",
"Windows",
"batch",
"pause",
"command",
".",
"If",
"the",
"program",
"is",
"not",
"ru... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/termui.py#L580-L606 | train |
pypa/pipenv | pipenv/vendor/attr/validators.py | optional | def optional(validator):
"""
A validator that makes an attribute optional. An optional attribute is one
which can be set to ``None`` in addition to satisfying the requirements of
the sub-validator.
:param validator: A validator (or a list of validators) that is used for
non-``None`` values... | python | def optional(validator):
"""
A validator that makes an attribute optional. An optional attribute is one
which can be set to ``None`` in addition to satisfying the requirements of
the sub-validator.
:param validator: A validator (or a list of validators) that is used for
non-``None`` values... | [
"def",
"optional",
"(",
"validator",
")",
":",
"if",
"isinstance",
"(",
"validator",
",",
"list",
")",
":",
"return",
"_OptionalValidator",
"(",
"_AndValidator",
"(",
"validator",
")",
")",
"return",
"_OptionalValidator",
"(",
"validator",
")"
] | A validator that makes an attribute optional. An optional attribute is one
which can be set to ``None`` in addition to satisfying the requirements of
the sub-validator.
:param validator: A validator (or a list of validators) that is used for
non-``None`` values.
:type validator: callable or :c... | [
"A",
"validator",
"that",
"makes",
"an",
"attribute",
"optional",
".",
"An",
"optional",
"attribute",
"is",
"one",
"which",
"can",
"be",
"set",
"to",
"None",
"in",
"addition",
"to",
"satisfying",
"the",
"requirements",
"of",
"the",
"sub",
"-",
"validator",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/attr/validators.py#L114-L129 | train |
pypa/pipenv | pipenv/vendor/resolvelib/structs.py | DirectedGraph.copy | def copy(self):
"""Return a shallow copy of this graph.
"""
other = DirectedGraph()
other._vertices = set(self._vertices)
other._forwards = {k: set(v) for k, v in self._forwards.items()}
other._backwards = {k: set(v) for k, v in self._backwards.items()}
return oth... | python | def copy(self):
"""Return a shallow copy of this graph.
"""
other = DirectedGraph()
other._vertices = set(self._vertices)
other._forwards = {k: set(v) for k, v in self._forwards.items()}
other._backwards = {k: set(v) for k, v in self._backwards.items()}
return oth... | [
"def",
"copy",
"(",
"self",
")",
":",
"other",
"=",
"DirectedGraph",
"(",
")",
"other",
".",
"_vertices",
"=",
"set",
"(",
"self",
".",
"_vertices",
")",
"other",
".",
"_forwards",
"=",
"{",
"k",
":",
"set",
"(",
"v",
")",
"for",
"k",
",",
"v",
... | Return a shallow copy of this graph. | [
"Return",
"a",
"shallow",
"copy",
"of",
"this",
"graph",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/resolvelib/structs.py#L18-L25 | train |
pypa/pipenv | pipenv/vendor/resolvelib/structs.py | DirectedGraph.add | def add(self, key):
"""Add a new vertex to the graph.
"""
if key in self._vertices:
raise ValueError('vertex exists')
self._vertices.add(key)
self._forwards[key] = set()
self._backwards[key] = set() | python | def add(self, key):
"""Add a new vertex to the graph.
"""
if key in self._vertices:
raise ValueError('vertex exists')
self._vertices.add(key)
self._forwards[key] = set()
self._backwards[key] = set() | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_vertices",
":",
"raise",
"ValueError",
"(",
"'vertex exists'",
")",
"self",
".",
"_vertices",
".",
"add",
"(",
"key",
")",
"self",
".",
"_forwards",
"[",
"key",
"]",
... | Add a new vertex to the graph. | [
"Add",
"a",
"new",
"vertex",
"to",
"the",
"graph",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/resolvelib/structs.py#L27-L34 | train |
pypa/pipenv | pipenv/vendor/resolvelib/structs.py | DirectedGraph.remove | def remove(self, key):
"""Remove a vertex from the graph, disconnecting all edges from/to it.
"""
self._vertices.remove(key)
for f in self._forwards.pop(key):
self._backwards[f].remove(key)
for t in self._backwards.pop(key):
self._forwards[t].remove(key) | python | def remove(self, key):
"""Remove a vertex from the graph, disconnecting all edges from/to it.
"""
self._vertices.remove(key)
for f in self._forwards.pop(key):
self._backwards[f].remove(key)
for t in self._backwards.pop(key):
self._forwards[t].remove(key) | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_vertices",
".",
"remove",
"(",
"key",
")",
"for",
"f",
"in",
"self",
".",
"_forwards",
".",
"pop",
"(",
"key",
")",
":",
"self",
".",
"_backwards",
"[",
"f",
"]",
".",
"remove",
... | Remove a vertex from the graph, disconnecting all edges from/to it. | [
"Remove",
"a",
"vertex",
"from",
"the",
"graph",
"disconnecting",
"all",
"edges",
"from",
"/",
"to",
"it",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/resolvelib/structs.py#L36-L43 | train |
pypa/pipenv | pipenv/vendor/resolvelib/structs.py | DirectedGraph.connect | def connect(self, f, t):
"""Connect two existing vertices.
Nothing happens if the vertices are already connected.
"""
if t not in self._vertices:
raise KeyError(t)
self._forwards[f].add(t)
self._backwards[t].add(f) | python | def connect(self, f, t):
"""Connect two existing vertices.
Nothing happens if the vertices are already connected.
"""
if t not in self._vertices:
raise KeyError(t)
self._forwards[f].add(t)
self._backwards[t].add(f) | [
"def",
"connect",
"(",
"self",
",",
"f",
",",
"t",
")",
":",
"if",
"t",
"not",
"in",
"self",
".",
"_vertices",
":",
"raise",
"KeyError",
"(",
"t",
")",
"self",
".",
"_forwards",
"[",
"f",
"]",
".",
"add",
"(",
"t",
")",
"self",
".",
"_backwards... | Connect two existing vertices.
Nothing happens if the vertices are already connected. | [
"Connect",
"two",
"existing",
"vertices",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/resolvelib/structs.py#L48-L56 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | _const_compare_digest_backport | def _const_compare_digest_backport(a, b):
"""
Compare two digests of equal length in constant time.
The digests must be of type str/bytes.
Returns True if the digests match, and False otherwise.
"""
result = abs(len(a) - len(b))
for l, r in zip(bytearray(a), bytearray(b)):
result |=... | python | def _const_compare_digest_backport(a, b):
"""
Compare two digests of equal length in constant time.
The digests must be of type str/bytes.
Returns True if the digests match, and False otherwise.
"""
result = abs(len(a) - len(b))
for l, r in zip(bytearray(a), bytearray(b)):
result |=... | [
"def",
"_const_compare_digest_backport",
"(",
"a",
",",
"b",
")",
":",
"result",
"=",
"abs",
"(",
"len",
"(",
"a",
")",
"-",
"len",
"(",
"b",
")",
")",
"for",
"l",
",",
"r",
"in",
"zip",
"(",
"bytearray",
"(",
"a",
")",
",",
"bytearray",
"(",
"... | Compare two digests of equal length in constant time.
The digests must be of type str/bytes.
Returns True if the digests match, and False otherwise. | [
"Compare",
"two",
"digests",
"of",
"equal",
"length",
"in",
"constant",
"time",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L27-L37 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | assert_fingerprint | def assert_fingerprint(cert, fingerprint):
"""
Checks if given fingerprint matches the supplied certificate.
:param cert:
Certificate as bytes object.
:param fingerprint:
Fingerprint as string of hexdigits, can be interspersed by colons.
"""
fingerprint = fingerprint.replace(':... | python | def assert_fingerprint(cert, fingerprint):
"""
Checks if given fingerprint matches the supplied certificate.
:param cert:
Certificate as bytes object.
:param fingerprint:
Fingerprint as string of hexdigits, can be interspersed by colons.
"""
fingerprint = fingerprint.replace(':... | [
"def",
"assert_fingerprint",
"(",
"cert",
",",
"fingerprint",
")",
":",
"fingerprint",
"=",
"fingerprint",
".",
"replace",
"(",
"':'",
",",
"''",
")",
".",
"lower",
"(",
")",
"digest_length",
"=",
"len",
"(",
"fingerprint",
")",
"hashfunc",
"=",
"HASHFUNC_... | Checks if given fingerprint matches the supplied certificate.
:param cert:
Certificate as bytes object.
:param fingerprint:
Fingerprint as string of hexdigits, can be interspersed by colons. | [
"Checks",
"if",
"given",
"fingerprint",
"matches",
"the",
"supplied",
"certificate",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L163-L187 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | resolve_cert_reqs | def resolve_cert_reqs(candidate):
"""
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_NONE`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbrevi... | python | def resolve_cert_reqs(candidate):
"""
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_NONE`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbrevi... | [
"def",
"resolve_cert_reqs",
"(",
"candidate",
")",
":",
"if",
"candidate",
"is",
"None",
":",
"return",
"CERT_NONE",
"if",
"isinstance",
"(",
"candidate",
",",
"str",
")",
":",
"res",
"=",
"getattr",
"(",
"ssl",
",",
"candidate",
",",
"None",
")",
"if",
... | Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_NONE`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbreviation.
(So you can specify `REQUIRED` inst... | [
"Resolves",
"the",
"argument",
"to",
"a",
"numeric",
"constant",
"which",
"can",
"be",
"passed",
"to",
"the",
"wrap_socket",
"function",
"/",
"method",
"from",
"the",
"ssl",
"module",
".",
"Defaults",
"to",
":",
"data",
":",
"ssl",
".",
"CERT_NONE",
".",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L190-L210 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | resolve_ssl_version | def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_SSLv23
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'PROTOCOL_' + candidate)
return res
... | python | def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_SSLv23
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'PROTOCOL_' + candidate)
return res
... | [
"def",
"resolve_ssl_version",
"(",
"candidate",
")",
":",
"if",
"candidate",
"is",
"None",
":",
"return",
"PROTOCOL_SSLv23",
"if",
"isinstance",
"(",
"candidate",
",",
"str",
")",
":",
"res",
"=",
"getattr",
"(",
"ssl",
",",
"candidate",
",",
"None",
")",
... | like resolve_cert_reqs | [
"like",
"resolve_cert_reqs"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L213-L226 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | ssl_wrap_socket | def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
ca_certs=None, server_hostname=None,
ssl_version=None, ciphers=None, ssl_context=None,
ca_cert_dir=None):
"""
All arguments except for server_hostname, ssl_context, and ca_cert_dir ... | python | def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
ca_certs=None, server_hostname=None,
ssl_version=None, ciphers=None, ssl_context=None,
ca_cert_dir=None):
"""
All arguments except for server_hostname, ssl_context, and ca_cert_dir ... | [
"def",
"ssl_wrap_socket",
"(",
"sock",
",",
"keyfile",
"=",
"None",
",",
"certfile",
"=",
"None",
",",
"cert_reqs",
"=",
"None",
",",
"ca_certs",
"=",
"None",
",",
"server_hostname",
"=",
"None",
",",
"ssl_version",
"=",
"None",
",",
"ciphers",
"=",
"Non... | All arguments except for server_hostname, ssl_context, and ca_cert_dir have
the same meaning as they do when using :func:`ssl.wrap_socket`.
:param server_hostname:
When SNI is supported, the expected hostname of the certificate
:param ssl_context:
A pre-made :class:`SSLContext` object. If n... | [
"All",
"arguments",
"except",
"for",
"server_hostname",
"ssl_context",
"and",
"ca_cert_dir",
"have",
"the",
"same",
"meaning",
"as",
"they",
"do",
"when",
"using",
":",
"func",
":",
"ssl",
".",
"wrap_socket",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L291-L357 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | is_ipaddress | def is_ipaddress(hostname):
"""Detects whether the hostname given is an IP address.
:param str hostname: Hostname to examine.
:return: True if the hostname is an IP address, False otherwise.
"""
if six.PY3 and isinstance(hostname, bytes):
# IDN A-label bytes are ASCII compatible.
ho... | python | def is_ipaddress(hostname):
"""Detects whether the hostname given is an IP address.
:param str hostname: Hostname to examine.
:return: True if the hostname is an IP address, False otherwise.
"""
if six.PY3 and isinstance(hostname, bytes):
# IDN A-label bytes are ASCII compatible.
ho... | [
"def",
"is_ipaddress",
"(",
"hostname",
")",
":",
"if",
"six",
".",
"PY3",
"and",
"isinstance",
"(",
"hostname",
",",
"bytes",
")",
":",
"# IDN A-label bytes are ASCII compatible.",
"hostname",
"=",
"hostname",
".",
"decode",
"(",
"'ascii'",
")",
"families",
"... | Detects whether the hostname given is an IP address.
:param str hostname: Hostname to examine.
:return: True if the hostname is an IP address, False otherwise. | [
"Detects",
"whether",
"the",
"hostname",
"given",
"is",
"an",
"IP",
"address",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L360-L381 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry.get_backoff_time | def get_backoff_time(self):
""" Formula for computing the current backoff
:rtype: float
"""
# We want to consider only the last consecutive errors sequence (Ignore redirects).
consecutive_errors_len = len(list(takewhile(lambda x: x.redirect_location is None,
... | python | def get_backoff_time(self):
""" Formula for computing the current backoff
:rtype: float
"""
# We want to consider only the last consecutive errors sequence (Ignore redirects).
consecutive_errors_len = len(list(takewhile(lambda x: x.redirect_location is None,
... | [
"def",
"get_backoff_time",
"(",
"self",
")",
":",
"# We want to consider only the last consecutive errors sequence (Ignore redirects).",
"consecutive_errors_len",
"=",
"len",
"(",
"list",
"(",
"takewhile",
"(",
"lambda",
"x",
":",
"x",
".",
"redirect_location",
"is",
"Non... | Formula for computing the current backoff
:rtype: float | [
"Formula",
"for",
"computing",
"the",
"current",
"backoff"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L213-L225 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry.get_retry_after | def get_retry_after(self, response):
""" Get the value of Retry-After in seconds. """
retry_after = response.getheader("Retry-After")
if retry_after is None:
return None
return self.parse_retry_after(retry_after) | python | def get_retry_after(self, response):
""" Get the value of Retry-After in seconds. """
retry_after = response.getheader("Retry-After")
if retry_after is None:
return None
return self.parse_retry_after(retry_after) | [
"def",
"get_retry_after",
"(",
"self",
",",
"response",
")",
":",
"retry_after",
"=",
"response",
".",
"getheader",
"(",
"\"Retry-After\"",
")",
"if",
"retry_after",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"parse_retry_after",
"(",
"retry_a... | Get the value of Retry-After in seconds. | [
"Get",
"the",
"value",
"of",
"Retry",
"-",
"After",
"in",
"seconds",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L243-L251 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry.sleep | def sleep(self, response=None):
""" Sleep between retry attempts.
This method will respect a server's ``Retry-After`` response header
and sleep the duration of the time requested. If that is not present, it
will use an exponential backoff. By default, the backoff factor is 0 and
... | python | def sleep(self, response=None):
""" Sleep between retry attempts.
This method will respect a server's ``Retry-After`` response header
and sleep the duration of the time requested. If that is not present, it
will use an exponential backoff. By default, the backoff factor is 0 and
... | [
"def",
"sleep",
"(",
"self",
",",
"response",
"=",
"None",
")",
":",
"if",
"response",
":",
"slept",
"=",
"self",
".",
"sleep_for_retry",
"(",
"response",
")",
"if",
"slept",
":",
"return",
"self",
".",
"_sleep_backoff",
"(",
")"
] | Sleep between retry attempts.
This method will respect a server's ``Retry-After`` response header
and sleep the duration of the time requested. If that is not present, it
will use an exponential backoff. By default, the backoff factor is 0 and
this method will return immediately. | [
"Sleep",
"between",
"retry",
"attempts",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L267-L281 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry._is_method_retryable | def _is_method_retryable(self, method):
""" Checks if a given HTTP method should be retried upon, depending if
it is included on the method whitelist.
"""
if self.method_whitelist and method.upper() not in self.method_whitelist:
return False
return True | python | def _is_method_retryable(self, method):
""" Checks if a given HTTP method should be retried upon, depending if
it is included on the method whitelist.
"""
if self.method_whitelist and method.upper() not in self.method_whitelist:
return False
return True | [
"def",
"_is_method_retryable",
"(",
"self",
",",
"method",
")",
":",
"if",
"self",
".",
"method_whitelist",
"and",
"method",
".",
"upper",
"(",
")",
"not",
"in",
"self",
".",
"method_whitelist",
":",
"return",
"False",
"return",
"True"
] | Checks if a given HTTP method should be retried upon, depending if
it is included on the method whitelist. | [
"Checks",
"if",
"a",
"given",
"HTTP",
"method",
"should",
"be",
"retried",
"upon",
"depending",
"if",
"it",
"is",
"included",
"on",
"the",
"method",
"whitelist",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L295-L302 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry.is_retry | def is_retry(self, method, status_code, has_retry_after=False):
""" Is this method/status code retryable? (Based on whitelists and control
variables such as the number of total retries to allow, whether to
respect the Retry-After header, whether this header is present, and
whether the re... | python | def is_retry(self, method, status_code, has_retry_after=False):
""" Is this method/status code retryable? (Based on whitelists and control
variables such as the number of total retries to allow, whether to
respect the Retry-After header, whether this header is present, and
whether the re... | [
"def",
"is_retry",
"(",
"self",
",",
"method",
",",
"status_code",
",",
"has_retry_after",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_is_method_retryable",
"(",
"method",
")",
":",
"return",
"False",
"if",
"self",
".",
"status_forcelist",
"and",
"... | Is this method/status code retryable? (Based on whitelists and control
variables such as the number of total retries to allow, whether to
respect the Retry-After header, whether this header is present, and
whether the returned status code is on the list of status codes to
be retried upon... | [
"Is",
"this",
"method",
"/",
"status",
"code",
"retryable?",
"(",
"Based",
"on",
"whitelists",
"and",
"control",
"variables",
"such",
"as",
"the",
"number",
"of",
"total",
"retries",
"to",
"allow",
"whether",
"to",
"respect",
"the",
"Retry",
"-",
"After",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L304-L318 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry.is_exhausted | def is_exhausted(self):
""" Are we out of retries? """
retry_counts = (self.total, self.connect, self.read, self.redirect, self.status)
retry_counts = list(filter(None, retry_counts))
if not retry_counts:
return False
return min(retry_counts) < 0 | python | def is_exhausted(self):
""" Are we out of retries? """
retry_counts = (self.total, self.connect, self.read, self.redirect, self.status)
retry_counts = list(filter(None, retry_counts))
if not retry_counts:
return False
return min(retry_counts) < 0 | [
"def",
"is_exhausted",
"(",
"self",
")",
":",
"retry_counts",
"=",
"(",
"self",
".",
"total",
",",
"self",
".",
"connect",
",",
"self",
".",
"read",
",",
"self",
".",
"redirect",
",",
"self",
".",
"status",
")",
"retry_counts",
"=",
"list",
"(",
"fil... | Are we out of retries? | [
"Are",
"we",
"out",
"of",
"retries?"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L320-L327 | train |
pypa/pipenv | pipenv/vendor/urllib3/util/retry.py | Retry.increment | def increment(self, method=None, url=None, response=None, error=None,
_pool=None, _stacktrace=None):
""" Return a new Retry object with incremented retry counters.
:param response: A response object, or None, if the server did not
return a response.
:type response:... | python | def increment(self, method=None, url=None, response=None, error=None,
_pool=None, _stacktrace=None):
""" Return a new Retry object with incremented retry counters.
:param response: A response object, or None, if the server did not
return a response.
:type response:... | [
"def",
"increment",
"(",
"self",
",",
"method",
"=",
"None",
",",
"url",
"=",
"None",
",",
"response",
"=",
"None",
",",
"error",
"=",
"None",
",",
"_pool",
"=",
"None",
",",
"_stacktrace",
"=",
"None",
")",
":",
"if",
"self",
".",
"total",
"is",
... | Return a new Retry object with incremented retry counters.
:param response: A response object, or None, if the server did not
return a response.
:type response: :class:`~urllib3.response.HTTPResponse`
:param Exception error: An error encountered during the request, or
No... | [
"Return",
"a",
"new",
"Retry",
"object",
"with",
"incremented",
"retry",
"counters",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/retry.py#L329-L402 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.