partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | path_is_known_executable | Returns whether a given path is a known executable from known executable extensions
or has the executable bit toggled.
:param path: The path to the target executable.
:type path: :class:`~vistir.compat.Path`
:return: True if the path has chmod +x, or is a readable, known executable extension.
:rtyp... | pipenv/vendor/pythonfinder/utils.py | def path_is_known_executable(path):
# type: (vistir.compat.Path) -> bool
"""
Returns whether a given path is a known executable from known executable extensions
or has the executable bit toggled.
:param path: The path to the target executable.
:type path: :class:`~vistir.compat.Path`
:retur... | def path_is_known_executable(path):
# type: (vistir.compat.Path) -> bool
"""
Returns whether a given path is a known executable from known executable extensions
or has the executable bit toggled.
:param path: The path to the target executable.
:type path: :class:`~vistir.compat.Path`
:retur... | [
"Returns",
"whether",
"a",
"given",
"path",
"is",
"a",
"known",
"executable",
"from",
"known",
"executable",
"extensions",
"or",
"has",
"the",
"executable",
"bit",
"toggled",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L181-L197 | [
"def",
"path_is_known_executable",
"(",
"path",
")",
":",
"# type: (vistir.compat.Path) -> bool",
"return",
"(",
"path_is_executable",
"(",
"path",
")",
"or",
"os",
".",
"access",
"(",
"str",
"(",
"path",
")",
",",
"os",
".",
"R_OK",
")",
"and",
"path",
".",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | looks_like_python | Determine whether the supplied filename looks like a possible name of python.
:param str name: The name of the provided file.
:return: Whether the provided name looks like python.
:rtype: bool | pipenv/vendor/pythonfinder/utils.py | def looks_like_python(name):
# type: (str) -> bool
"""
Determine whether the supplied filename looks like a possible name of python.
:param str name: The name of the provided file.
:return: Whether the provided name looks like python.
:rtype: bool
"""
if not any(name.lower().startswith... | def looks_like_python(name):
# type: (str) -> bool
"""
Determine whether the supplied filename looks like a possible name of python.
:param str name: The name of the provided file.
:return: Whether the provided name looks like python.
:rtype: bool
"""
if not any(name.lower().startswith... | [
"Determine",
"whether",
"the",
"supplied",
"filename",
"looks",
"like",
"a",
"possible",
"name",
"of",
"python",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L201-L216 | [
"def",
"looks_like_python",
"(",
"name",
")",
":",
"# type: (str) -> bool",
"if",
"not",
"any",
"(",
"name",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"py_name",
")",
"for",
"py_name",
"in",
"PYTHON_IMPLEMENTATIONS",
")",
":",
"return",
"False",
"match... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ensure_path | Given a path (either a string or a Path object), expand variables and return a Path object.
:param path: A string or a :class:`~pathlib.Path` object.
:type path: str or :class:`~pathlib.Path`
:return: A fully expanded Path object.
:rtype: :class:`~pathlib.Path` | pipenv/vendor/pythonfinder/utils.py | def ensure_path(path):
# type: (Union[vistir.compat.Path, str]) -> vistir.compat.Path
"""
Given a path (either a string or a Path object), expand variables and return a Path object.
:param path: A string or a :class:`~pathlib.Path` object.
:type path: str or :class:`~pathlib.Path`
:return: A fu... | def ensure_path(path):
# type: (Union[vistir.compat.Path, str]) -> vistir.compat.Path
"""
Given a path (either a string or a Path object), expand variables and return a Path object.
:param path: A string or a :class:`~pathlib.Path` object.
:type path: str or :class:`~pathlib.Path`
:return: A fu... | [
"Given",
"a",
"path",
"(",
"either",
"a",
"string",
"or",
"a",
"Path",
"object",
")",
"expand",
"variables",
"and",
"return",
"a",
"Path",
"object",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L235-L249 | [
"def",
"ensure_path",
"(",
"path",
")",
":",
"# type: (Union[vistir.compat.Path, str]) -> vistir.compat.Path",
"if",
"isinstance",
"(",
"path",
",",
"vistir",
".",
"compat",
".",
"Path",
")",
":",
"return",
"path",
"path",
"=",
"vistir",
".",
"compat",
".",
"Pat... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | filter_pythons | Return all valid pythons in a given path | pipenv/vendor/pythonfinder/utils.py | def filter_pythons(path):
# type: (Union[str, vistir.compat.Path]) -> Iterable
"""Return all valid pythons in a given path"""
if not isinstance(path, vistir.compat.Path):
path = vistir.compat.Path(str(path))
if not path.is_dir():
return path if path_is_python(path) else None
return f... | def filter_pythons(path):
# type: (Union[str, vistir.compat.Path]) -> Iterable
"""Return all valid pythons in a given path"""
if not isinstance(path, vistir.compat.Path):
path = vistir.compat.Path(str(path))
if not path.is_dir():
return path if path_is_python(path) else None
return f... | [
"Return",
"all",
"valid",
"pythons",
"in",
"a",
"given",
"path"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L270-L277 | [
"def",
"filter_pythons",
"(",
"path",
")",
":",
"# type: (Union[str, vistir.compat.Path]) -> Iterable",
"if",
"not",
"isinstance",
"(",
"path",
",",
"vistir",
".",
"compat",
".",
"Path",
")",
":",
"path",
"=",
"vistir",
".",
"compat",
".",
"Path",
"(",
"str",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | expand_paths | Recursively expand a list or :class:`~pythonfinder.models.path.PathEntry` instance
:param Union[Sequence, PathEntry] path: The path or list of paths to expand
:param bool only_python: Whether to filter to include only python paths, default True
:returns: An iterator over the expanded set of path entries
... | pipenv/vendor/pythonfinder/utils.py | def expand_paths(path, only_python=True):
# type: (Union[Sequence, PathEntry], bool) -> Iterator
"""
Recursively expand a list or :class:`~pythonfinder.models.path.PathEntry` instance
:param Union[Sequence, PathEntry] path: The path or list of paths to expand
:param bool only_python: Whether to fil... | def expand_paths(path, only_python=True):
# type: (Union[Sequence, PathEntry], bool) -> Iterator
"""
Recursively expand a list or :class:`~pythonfinder.models.path.PathEntry` instance
:param Union[Sequence, PathEntry] path: The path or list of paths to expand
:param bool only_python: Whether to fil... | [
"Recursively",
"expand",
"a",
"list",
"or",
":",
"class",
":",
"~pythonfinder",
".",
"models",
".",
"path",
".",
"PathEntry",
"instance"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L334-L365 | [
"def",
"expand_paths",
"(",
"path",
",",
"only_python",
"=",
"True",
")",
":",
"# type: (Union[Sequence, PathEntry], bool) -> Iterator",
"if",
"path",
"is",
"not",
"None",
"and",
"(",
"isinstance",
"(",
"path",
",",
"Sequence",
")",
"and",
"not",
"getattr",
"(",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Cache._get_cache_path_parts | Get parts of part that must be os.path.joined with cache_dir | pipenv/patched/notpip/_internal/cache.py | def _get_cache_path_parts(self, link):
# type: (Link) -> List[str]
"""Get parts of part that must be os.path.joined with cache_dir
"""
# We want to generate an url to use as our cache key, we don't want to
# just re-use the URL because it might have other items in the fragment
... | def _get_cache_path_parts(self, link):
# type: (Link) -> List[str]
"""Get parts of part that must be os.path.joined with cache_dir
"""
# We want to generate an url to use as our cache key, we don't want to
# just re-use the URL because it might have other items in the fragment
... | [
"Get",
"parts",
"of",
"part",
"that",
"must",
"be",
"os",
".",
"path",
".",
"joined",
"with",
"cache_dir"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cache.py#L46-L70 | [
"def",
"_get_cache_path_parts",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> List[str]",
"# We want to generate an url to use as our cache key, we don't want to",
"# just re-use the URL because it might have other items in the fragment",
"# and we don't care about those.",
"key_par... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | SimpleWheelCache.get_path_for_link | Return a directory to store cached wheels for link
Because there are M wheels for any one sdist, we provide a directory
to cache them in, and then consult that directory when looking up
cache hits.
We only insert things into the cache if they have plausible version
numbers, so ... | pipenv/patched/notpip/_internal/cache.py | def get_path_for_link(self, link):
# type: (Link) -> str
"""Return a directory to store cached wheels for link
Because there are M wheels for any one sdist, we provide a directory
to cache them in, and then consult that directory when looking up
cache hits.
We only inse... | def get_path_for_link(self, link):
# type: (Link) -> str
"""Return a directory to store cached wheels for link
Because there are M wheels for any one sdist, we provide a directory
to cache them in, and then consult that directory when looking up
cache hits.
We only inse... | [
"Return",
"a",
"directory",
"to",
"store",
"cached",
"wheels",
"for",
"link"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cache.py#L132-L151 | [
"def",
"get_path_for_link",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> str",
"parts",
"=",
"self",
".",
"_get_cache_path_parts",
"(",
"link",
")",
"# Store wheels within the root cache_dir",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Link.is_artifact | Determines if this points to an actual artifact (e.g. a tarball) or if
it points to an "abstract" thing like a path or a VCS location. | pipenv/patched/notpip/_internal/models/link.py | def is_artifact(self):
# type: () -> bool
"""
Determines if this points to an actual artifact (e.g. a tarball) or if
it points to an "abstract" thing like a path or a VCS location.
"""
from pipenv.patched.notpip._internal.vcs import vcs
if self.scheme in vcs.all_... | def is_artifact(self):
# type: () -> bool
"""
Determines if this points to an actual artifact (e.g. a tarball) or if
it points to an "abstract" thing like a path or a VCS location.
"""
from pipenv.patched.notpip._internal.vcs import vcs
if self.scheme in vcs.all_... | [
"Determines",
"if",
"this",
"points",
"to",
"an",
"actual",
"artifact",
"(",
"e",
".",
"g",
".",
"a",
"tarball",
")",
"or",
"if",
"it",
"points",
"to",
"an",
"abstract",
"thing",
"like",
"a",
"path",
"or",
"a",
"VCS",
"location",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/models/link.py#L152-L163 | [
"def",
"is_artifact",
"(",
"self",
")",
":",
"# type: () -> bool",
"from",
"pipenv",
".",
"patched",
".",
"notpip",
".",
"_internal",
".",
"vcs",
"import",
"vcs",
"if",
"self",
".",
"scheme",
"in",
"vcs",
".",
"all_schemes",
":",
"return",
"False",
"return... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _get_dependencies_from_cache | Retrieves dependencies for the requirement from the dependency cache. | pipenv/vendor/passa/internals/dependencies.py | def _get_dependencies_from_cache(ireq):
"""Retrieves dependencies for the requirement from the dependency cache.
"""
if os.environ.get("PASSA_IGNORE_LOCAL_CACHE"):
return
if ireq.editable:
return
try:
deps = DEPENDENCY_CACHE[ireq]
pyrq = REQUIRES_PYTHON_CACHE[ireq]
... | def _get_dependencies_from_cache(ireq):
"""Retrieves dependencies for the requirement from the dependency cache.
"""
if os.environ.get("PASSA_IGNORE_LOCAL_CACHE"):
return
if ireq.editable:
return
try:
deps = DEPENDENCY_CACHE[ireq]
pyrq = REQUIRES_PYTHON_CACHE[ireq]
... | [
"Retrieves",
"dependencies",
"for",
"the",
"requirement",
"from",
"the",
"dependency",
"cache",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L49-L80 | [
"def",
"_get_dependencies_from_cache",
"(",
"ireq",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"PASSA_IGNORE_LOCAL_CACHE\"",
")",
":",
"return",
"if",
"ireq",
".",
"editable",
":",
"return",
"try",
":",
"deps",
"=",
"DEPENDENCY_CACHE",
"[",
"ir... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _get_dependencies_from_json | Retrieves dependencies for the install requirement from the JSON API.
:param ireq: A single InstallRequirement
:type ireq: :class:`~pip._internal.req.req_install.InstallRequirement`
:return: A set of dependency lines for generating new InstallRequirements.
:rtype: set(str) or None | pipenv/vendor/passa/internals/dependencies.py | def _get_dependencies_from_json(ireq, sources):
"""Retrieves dependencies for the install requirement from the JSON API.
:param ireq: A single InstallRequirement
:type ireq: :class:`~pip._internal.req.req_install.InstallRequirement`
:return: A set of dependency lines for generating new InstallRequireme... | def _get_dependencies_from_json(ireq, sources):
"""Retrieves dependencies for the install requirement from the JSON API.
:param ireq: A single InstallRequirement
:type ireq: :class:`~pip._internal.req.req_install.InstallRequirement`
:return: A set of dependency lines for generating new InstallRequireme... | [
"Retrieves",
"dependencies",
"for",
"the",
"install",
"requirement",
"from",
"the",
"JSON",
"API",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L113-L158 | [
"def",
"_get_dependencies_from_json",
"(",
"ireq",
",",
"sources",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"PASSA_IGNORE_JSON_API\"",
")",
":",
"return",
"# It is technically possible to parse extras out of the JSON API's",
"# requirement format, but it is su... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _read_requirements | Read wheel metadata to know what it depends on.
The `run_requires` attribute contains a list of dict or str specifying
requirements. For dicts, it may contain an "extra" key to specify these
requirements are for a specific extra. Unfortunately, not all fields are
specificed like this (I don't know why)... | pipenv/vendor/passa/internals/dependencies.py | def _read_requirements(metadata, extras):
"""Read wheel metadata to know what it depends on.
The `run_requires` attribute contains a list of dict or str specifying
requirements. For dicts, it may contain an "extra" key to specify these
requirements are for a specific extra. Unfortunately, not all field... | def _read_requirements(metadata, extras):
"""Read wheel metadata to know what it depends on.
The `run_requires` attribute contains a list of dict or str specifying
requirements. For dicts, it may contain an "extra" key to specify these
requirements are for a specific extra. Unfortunately, not all field... | [
"Read",
"wheel",
"metadata",
"to",
"know",
"what",
"it",
"depends",
"on",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L161-L194 | [
"def",
"_read_requirements",
"(",
"metadata",
",",
"extras",
")",
":",
"extras",
"=",
"extras",
"or",
"(",
")",
"requirements",
"=",
"[",
"]",
"for",
"entry",
"in",
"metadata",
".",
"run_requires",
":",
"if",
"isinstance",
"(",
"entry",
",",
"six",
".",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _read_requires_python | Read wheel metadata to know the value of Requires-Python.
This is surprisingly poorly supported in Distlib. This function tries
several ways to get this information:
* Metadata 2.0: metadata.dictionary.get("requires_python") is not None
* Metadata 2.1: metadata._legacy.get("Requires-Python") is not No... | pipenv/vendor/passa/internals/dependencies.py | def _read_requires_python(metadata):
"""Read wheel metadata to know the value of Requires-Python.
This is surprisingly poorly supported in Distlib. This function tries
several ways to get this information:
* Metadata 2.0: metadata.dictionary.get("requires_python") is not None
* Metadata 2.1: metad... | def _read_requires_python(metadata):
"""Read wheel metadata to know the value of Requires-Python.
This is surprisingly poorly supported in Distlib. This function tries
several ways to get this information:
* Metadata 2.0: metadata.dictionary.get("requires_python") is not None
* Metadata 2.1: metad... | [
"Read",
"wheel",
"metadata",
"to",
"know",
"the",
"value",
"of",
"Requires",
"-",
"Python",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L197-L215 | [
"def",
"_read_requires_python",
"(",
"metadata",
")",
":",
"# TODO: Support more metadata formats.",
"value",
"=",
"metadata",
".",
"dictionary",
".",
"get",
"(",
"\"requires_python\"",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"if",
"metada... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _get_dependencies_from_pip | Retrieves dependencies for the requirement from pipenv.patched.notpip internals.
The current strategy is to try the followings in order, returning the
first successful result.
1. Try to build a wheel out of the ireq, and read metadata out of it.
2. Read metadata out of the egg-info directory if it is ... | pipenv/vendor/passa/internals/dependencies.py | def _get_dependencies_from_pip(ireq, sources):
"""Retrieves dependencies for the requirement from pipenv.patched.notpip internals.
The current strategy is to try the followings in order, returning the
first successful result.
1. Try to build a wheel out of the ireq, and read metadata out of it.
2.... | def _get_dependencies_from_pip(ireq, sources):
"""Retrieves dependencies for the requirement from pipenv.patched.notpip internals.
The current strategy is to try the followings in order, returning the
first successful result.
1. Try to build a wheel out of the ireq, and read metadata out of it.
2.... | [
"Retrieves",
"dependencies",
"for",
"the",
"requirement",
"from",
"pipenv",
".",
"patched",
".",
"notpip",
"internals",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L218-L242 | [
"def",
"_get_dependencies_from_pip",
"(",
"ireq",
",",
"sources",
")",
":",
"extras",
"=",
"ireq",
".",
"extras",
"or",
"(",
")",
"try",
":",
"wheel",
"=",
"build_wheel",
"(",
"ireq",
",",
"sources",
")",
"except",
"WheelBuildError",
":",
"# XXX: This depend... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | get_dependencies | Get all dependencies for a given install requirement.
:param requirement: A requirement
:param sources: Pipfile-formatted sources
:type sources: list[dict] | pipenv/vendor/passa/internals/dependencies.py | def get_dependencies(requirement, sources):
"""Get all dependencies for a given install requirement.
:param requirement: A requirement
:param sources: Pipfile-formatted sources
:type sources: list[dict]
"""
getters = [
_get_dependencies_from_cache,
_cached(_get_dependencies_from... | def get_dependencies(requirement, sources):
"""Get all dependencies for a given install requirement.
:param requirement: A requirement
:param sources: Pipfile-formatted sources
:type sources: list[dict]
"""
getters = [
_get_dependencies_from_cache,
_cached(_get_dependencies_from... | [
"Get",
"all",
"dependencies",
"for",
"a",
"given",
"install",
"requirement",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L245-L273 | [
"def",
"get_dependencies",
"(",
"requirement",
",",
"sources",
")",
":",
"getters",
"=",
"[",
"_get_dependencies_from_cache",
",",
"_cached",
"(",
"_get_dependencies_from_json",
",",
"sources",
"=",
"sources",
")",
",",
"_cached",
"(",
"_get_dependencies_from_pip",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | format_header_param | Helper function to format and quote a single header parameter.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows RFC 2231, as
suggested by RFC 2388 Section 4.4.
:param name:
The name of the parameter, a string expected to be ASCII onl... | pipenv/vendor/urllib3/fields.py | def format_header_param(name, value):
"""
Helper function to format and quote a single header parameter.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows RFC 2231, as
suggested by RFC 2388 Section 4.4.
:param name:
The name o... | def format_header_param(name, value):
"""
Helper function to format and quote a single header parameter.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows RFC 2231, as
suggested by RFC 2388 Section 4.4.
:param name:
The name o... | [
"Helper",
"function",
"to",
"format",
"and",
"quote",
"a",
"single",
"header",
"parameter",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L22-L47 | [
"def",
"format_header_param",
"(",
"name",
",",
"value",
")",
":",
"if",
"not",
"any",
"(",
"ch",
"in",
"value",
"for",
"ch",
"in",
"'\"\\\\\\r\\n'",
")",
":",
"result",
"=",
"'%s=\"%s\"'",
"%",
"(",
"name",
",",
"value",
")",
"try",
":",
"result",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | RequestField.from_tuples | A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
Supports constructing :class:`~urllib3.fields.RequestField` from
parameter of key/value strings AND key/filetuple. A filetuple is a
(filename, data, MIME type) tuple where the MIME type is optional.
For exa... | pipenv/vendor/urllib3/fields.py | def from_tuples(cls, fieldname, value):
"""
A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
Supports constructing :class:`~urllib3.fields.RequestField` from
parameter of key/value strings AND key/filetuple. A filetuple is a
(filename, data, MIME ... | def from_tuples(cls, fieldname, value):
"""
A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
Supports constructing :class:`~urllib3.fields.RequestField` from
parameter of key/value strings AND key/filetuple. A filetuple is a
(filename, data, MIME ... | [
"A",
":",
"class",
":",
"~urllib3",
".",
"fields",
".",
"RequestField",
"factory",
"from",
"old",
"-",
"style",
"tuple",
"parameters",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L72-L103 | [
"def",
"from_tuples",
"(",
"cls",
",",
"fieldname",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"if",
"len",
"(",
"value",
")",
"==",
"3",
":",
"filename",
",",
"data",
",",
"content_type",
"=",
"value",
"else",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | RequestField._render_parts | Helper function to format and quote a single header.
Useful for single headers that are composed of multiple items. E.g.,
'Content-Disposition' fields.
:param header_parts:
A sequence of (k, v) tuples or a :class:`dict` of (k, v) to format
as `k1="v1"; k2="v2"; ...`. | pipenv/vendor/urllib3/fields.py | def _render_parts(self, header_parts):
"""
Helper function to format and quote a single header.
Useful for single headers that are composed of multiple items. E.g.,
'Content-Disposition' fields.
:param header_parts:
A sequence of (k, v) tuples or a :class:`dict` of ... | def _render_parts(self, header_parts):
"""
Helper function to format and quote a single header.
Useful for single headers that are composed of multiple items. E.g.,
'Content-Disposition' fields.
:param header_parts:
A sequence of (k, v) tuples or a :class:`dict` of ... | [
"Helper",
"function",
"to",
"format",
"and",
"quote",
"a",
"single",
"header",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L116-L136 | [
"def",
"_render_parts",
"(",
"self",
",",
"header_parts",
")",
":",
"parts",
"=",
"[",
"]",
"iterable",
"=",
"header_parts",
"if",
"isinstance",
"(",
"header_parts",
",",
"dict",
")",
":",
"iterable",
"=",
"header_parts",
".",
"items",
"(",
")",
"for",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | RequestField.render_headers | Renders the headers for this request field. | pipenv/vendor/urllib3/fields.py | def render_headers(self):
"""
Renders the headers for this request field.
"""
lines = []
sort_keys = ['Content-Disposition', 'Content-Type', 'Content-Location']
for sort_key in sort_keys:
if self.headers.get(sort_key, False):
lines.append('%s:... | def render_headers(self):
"""
Renders the headers for this request field.
"""
lines = []
sort_keys = ['Content-Disposition', 'Content-Type', 'Content-Location']
for sort_key in sort_keys:
if self.headers.get(sort_key, False):
lines.append('%s:... | [
"Renders",
"the",
"headers",
"for",
"this",
"request",
"field",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L138-L155 | [
"def",
"render_headers",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"sort_keys",
"=",
"[",
"'Content-Disposition'",
",",
"'Content-Type'",
",",
"'Content-Location'",
"]",
"for",
"sort_key",
"in",
"sort_keys",
":",
"if",
"self",
".",
"headers",
".",
"get"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | RequestField.make_multipart | Makes this request field into a multipart request field.
This method overrides "Content-Disposition", "Content-Type" and
"Content-Location" headers to the request parameter.
:param content_type:
The 'Content-Type' of the request body.
:param content_location:
Th... | pipenv/vendor/urllib3/fields.py | def make_multipart(self, content_disposition=None, content_type=None,
content_location=None):
"""
Makes this request field into a multipart request field.
This method overrides "Content-Disposition", "Content-Type" and
"Content-Location" headers to the request par... | def make_multipart(self, content_disposition=None, content_type=None,
content_location=None):
"""
Makes this request field into a multipart request field.
This method overrides "Content-Disposition", "Content-Type" and
"Content-Location" headers to the request par... | [
"Makes",
"this",
"request",
"field",
"into",
"a",
"multipart",
"request",
"field",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L157-L178 | [
"def",
"make_multipart",
"(",
"self",
",",
"content_disposition",
"=",
"None",
",",
"content_type",
"=",
"None",
",",
"content_location",
"=",
"None",
")",
":",
"self",
".",
"headers",
"[",
"'Content-Disposition'",
"]",
"=",
"content_disposition",
"or",
"'form-d... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | TreeWalker.emptyTag | Generates an EmptyTag token
:arg namespace: the namespace of the token--can be ``None``
:arg name: the name of the element
:arg attrs: the attributes of the element as a dict
:arg hasChildren: whether or not to yield a SerializationError because
this tag shouldn't have ch... | pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py | def emptyTag(self, namespace, name, attrs, hasChildren=False):
"""Generates an EmptyTag token
:arg namespace: the namespace of the token--can be ``None``
:arg name: the name of the element
:arg attrs: the attributes of the element as a dict
:arg hasChildren: whether or not to... | def emptyTag(self, namespace, name, attrs, hasChildren=False):
"""Generates an EmptyTag token
:arg namespace: the namespace of the token--can be ``None``
:arg name: the name of the element
:arg attrs: the attributes of the element as a dict
:arg hasChildren: whether or not to... | [
"Generates",
"an",
"EmptyTag",
"token"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py#L48-L67 | [
"def",
"emptyTag",
"(",
"self",
",",
"namespace",
",",
"name",
",",
"attrs",
",",
"hasChildren",
"=",
"False",
")",
":",
"yield",
"{",
"\"type\"",
":",
"\"EmptyTag\"",
",",
"\"name\"",
":",
"name",
",",
"\"namespace\"",
":",
"namespace",
",",
"\"data\"",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | TreeWalker.text | Generates SpaceCharacters and Characters tokens
Depending on what's in the data, this generates one or more
``SpaceCharacters`` and ``Characters`` tokens.
For example:
>>> from html5lib.treewalkers.base import TreeWalker
>>> # Give it an empty tree just so it instantia... | pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py | def text(self, data):
"""Generates SpaceCharacters and Characters tokens
Depending on what's in the data, this generates one or more
``SpaceCharacters`` and ``Characters`` tokens.
For example:
>>> from html5lib.treewalkers.base import TreeWalker
>>> # Give it a... | def text(self, data):
"""Generates SpaceCharacters and Characters tokens
Depending on what's in the data, this generates one or more
``SpaceCharacters`` and ``Characters`` tokens.
For example:
>>> from html5lib.treewalkers.base import TreeWalker
>>> # Give it a... | [
"Generates",
"SpaceCharacters",
"and",
"Characters",
"tokens"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py#L100-L136 | [
"def",
"text",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"data",
"middle",
"=",
"data",
".",
"lstrip",
"(",
"spaceCharacters",
")",
"left",
"=",
"data",
"[",
":",
"len",
"(",
"data",
")",
"-",
"len",
"(",
"middle",
")",
"]",
"if",
"left",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _get_activate_script | Returns the string to activate a virtualenv.
This is POSIX-only at the moment since the compat (pexpect-based) shell
does not work elsewhere anyway. | pipenv/shells.py | def _get_activate_script(cmd, venv):
"""Returns the string to activate a virtualenv.
This is POSIX-only at the moment since the compat (pexpect-based) shell
does not work elsewhere anyway.
"""
# Suffix and source command for other shells.
# Support for fish shell.
if "fish" in cmd:
... | def _get_activate_script(cmd, venv):
"""Returns the string to activate a virtualenv.
This is POSIX-only at the moment since the compat (pexpect-based) shell
does not work elsewhere anyway.
"""
# Suffix and source command for other shells.
# Support for fish shell.
if "fish" in cmd:
... | [
"Returns",
"the",
"string",
"to",
"activate",
"a",
"virtualenv",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/shells.py#L32-L54 | [
"def",
"_get_activate_script",
"(",
"cmd",
",",
"venv",
")",
":",
"# Suffix and source command for other shells.",
"# Support for fish shell.",
"if",
"\"fish\"",
"in",
"cmd",
":",
"suffix",
"=",
"\".fish\"",
"command",
"=",
"\"source\"",
"# Support for csh shell.",
"elif"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Wheel.filename | Build and return a filename from the various components. | pipenv/vendor/distlib/wheel.py | def filename(self):
"""
Build and return a filename from the various components.
"""
if self.buildver:
buildver = '-' + self.buildver
else:
buildver = ''
pyver = '.'.join(self.pyver)
abi = '.'.join(self.abi)
arch = '.'.join(self.arc... | def filename(self):
"""
Build and return a filename from the various components.
"""
if self.buildver:
buildver = '-' + self.buildver
else:
buildver = ''
pyver = '.'.join(self.pyver)
abi = '.'.join(self.abi)
arch = '.'.join(self.arc... | [
"Build",
"and",
"return",
"a",
"filename",
"from",
"the",
"various",
"components",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L186-L200 | [
"def",
"filename",
"(",
"self",
")",
":",
"if",
"self",
".",
"buildver",
":",
"buildver",
"=",
"'-'",
"+",
"self",
".",
"buildver",
"else",
":",
"buildver",
"=",
"''",
"pyver",
"=",
"'.'",
".",
"join",
"(",
"self",
".",
"pyver",
")",
"abi",
"=",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Wheel.build | Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel. | pipenv/vendor/distlib/wheel.py | def build(self, paths, tags=None, wheel_version=None):
"""
Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel.
"""
if tags is None:
tags = {}
libkey = list(filter(lambda o: o in paths, ('purelib', 'p... | def build(self, paths, tags=None, wheel_version=None):
"""
Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel.
"""
if tags is None:
tags = {}
libkey = list(filter(lambda o: o in paths, ('purelib', 'p... | [
"Build",
"a",
"wheel",
"from",
"files",
"in",
"specified",
"paths",
"and",
"use",
"any",
"specified",
"tags",
"when",
"determining",
"the",
"name",
"of",
"the",
"wheel",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L332-L434 | [
"def",
"build",
"(",
"self",
",",
"paths",
",",
"tags",
"=",
"None",
",",
"wheel_version",
"=",
"None",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"{",
"}",
"libkey",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"o",
":",
"o",
"in",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Wheel.install | Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a discrepancy in the versions.
This can be used to issue an... | pipenv/vendor/distlib/wheel.py | def install(self, paths, maker, **kwargs):
"""
Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a di... | def install(self, paths, maker, **kwargs):
"""
Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a di... | [
"Install",
"a",
"wheel",
"to",
"the",
"specified",
"paths",
".",
"If",
"kwarg",
"warner",
"is",
"specified",
"it",
"should",
"be",
"a",
"callable",
"which",
"will",
"be",
"called",
"with",
"two",
"tuples",
"indicating",
"the",
"wheel",
"version",
"of",
"th... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L436-L666 | [
"def",
"install",
"(",
"self",
",",
"paths",
",",
"maker",
",",
"*",
"*",
"kwargs",
")",
":",
"dry_run",
"=",
"maker",
".",
"dry_run",
"warner",
"=",
"kwargs",
".",
"get",
"(",
"'warner'",
")",
"lib_only",
"=",
"kwargs",
".",
"get",
"(",
"'lib_only'"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Wheel.update | Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the corresponding archive entries can be found. The
modifier is free t... | pipenv/vendor/distlib/wheel.py | def update(self, modifier, dest_dir=None, **kwargs):
"""
Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the c... | def update(self, modifier, dest_dir=None, **kwargs):
"""
Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the c... | [
"Update",
"the",
"contents",
"of",
"a",
"wheel",
"in",
"a",
"generic",
"way",
".",
"The",
"modifier",
"should",
"be",
"a",
"callable",
"which",
"expects",
"a",
"dictionary",
"argument",
":",
"its",
"keys",
"are",
"archive",
"-",
"entry",
"paths",
"and",
... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L810-L909 | [
"def",
"update",
"(",
"self",
",",
"modifier",
",",
"dest_dir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"get_version",
"(",
"path_map",
",",
"info_dir",
")",
":",
"version",
"=",
"path",
"=",
"None",
"key",
"=",
"'%s/%s'",
"%",
"(",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | load_dot_env | Loads .env file into sys.environ. | pipenv/core.py | def load_dot_env():
"""Loads .env file into sys.environ."""
if not environments.PIPENV_DONT_LOAD_ENV:
# If the project doesn't exist yet, check current directory for a .env file
project_directory = project.project_directory or "."
dotenv_file = environments.PIPENV_DOTENV_LOCATION or os.s... | def load_dot_env():
"""Loads .env file into sys.environ."""
if not environments.PIPENV_DONT_LOAD_ENV:
# If the project doesn't exist yet, check current directory for a .env file
project_directory = project.project_directory or "."
dotenv_file = environments.PIPENV_DOTENV_LOCATION or os.s... | [
"Loads",
".",
"env",
"file",
"into",
"sys",
".",
"environ",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L131-L156 | [
"def",
"load_dot_env",
"(",
")",
":",
"if",
"not",
"environments",
".",
"PIPENV_DONT_LOAD_ENV",
":",
"# If the project doesn't exist yet, check current directory for a .env file",
"project_directory",
"=",
"project",
".",
"project_directory",
"or",
"\".\"",
"dotenv_file",
"="... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | add_to_path | Adds a given path to the PATH. | pipenv/core.py | def add_to_path(p):
"""Adds a given path to the PATH."""
if p not in os.environ["PATH"]:
os.environ["PATH"] = "{0}{1}{2}".format(p, os.pathsep, os.environ["PATH"]) | def add_to_path(p):
"""Adds a given path to the PATH."""
if p not in os.environ["PATH"]:
os.environ["PATH"] = "{0}{1}{2}".format(p, os.pathsep, os.environ["PATH"]) | [
"Adds",
"a",
"given",
"path",
"to",
"the",
"PATH",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L159-L162 | [
"def",
"add_to_path",
"(",
"p",
")",
":",
"if",
"p",
"not",
"in",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
":",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
"=",
"\"{0}{1}{2}\"",
".",
"format",
"(",
"p",
",",
"os",
".",
"pathsep",
",",
"os",
".... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | cleanup_virtualenv | Removes the virtualenv directory from the system. | pipenv/core.py | def cleanup_virtualenv(bare=True):
"""Removes the virtualenv directory from the system."""
if not bare:
click.echo(crayons.red("Environment creation aborted."))
try:
# Delete the virtualenv.
vistir.path.rmtree(project.virtualenv_location)
except OSError as e:
click.echo(
... | def cleanup_virtualenv(bare=True):
"""Removes the virtualenv directory from the system."""
if not bare:
click.echo(crayons.red("Environment creation aborted."))
try:
# Delete the virtualenv.
vistir.path.rmtree(project.virtualenv_location)
except OSError as e:
click.echo(
... | [
"Removes",
"the",
"virtualenv",
"directory",
"from",
"the",
"system",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L165-L180 | [
"def",
"cleanup_virtualenv",
"(",
"bare",
"=",
"True",
")",
":",
"if",
"not",
"bare",
":",
"click",
".",
"echo",
"(",
"crayons",
".",
"red",
"(",
"\"Environment creation aborted.\"",
")",
")",
"try",
":",
"# Delete the virtualenv.",
"vistir",
".",
"path",
".... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ensure_pipfile | Creates a Pipfile for the project, if it doesn't exist. | pipenv/core.py | def ensure_pipfile(validate=True, skip_requirements=False, system=False):
"""Creates a Pipfile for the project, if it doesn't exist."""
from .environments import PIPENV_VIRTUALENV
# Assert Pipfile exists.
python = which("python") if not (USING_DEFAULT_PYTHON or system) else None
if project.pipfile_... | def ensure_pipfile(validate=True, skip_requirements=False, system=False):
"""Creates a Pipfile for the project, if it doesn't exist."""
from .environments import PIPENV_VIRTUALENV
# Assert Pipfile exists.
python = which("python") if not (USING_DEFAULT_PYTHON or system) else None
if project.pipfile_... | [
"Creates",
"a",
"Pipfile",
"for",
"the",
"project",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L255-L315 | [
"def",
"ensure_pipfile",
"(",
"validate",
"=",
"True",
",",
"skip_requirements",
"=",
"False",
",",
"system",
"=",
"False",
")",
":",
"from",
".",
"environments",
"import",
"PIPENV_VIRTUALENV",
"# Assert Pipfile exists.",
"python",
"=",
"which",
"(",
"\"python\"",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | find_a_system_python | Find a Python installation from a given line.
This tries to parse the line in various of ways:
* Looks like an absolute path? Use it directly.
* Looks like a py.exe call? Use py.exe to get the executable.
* Starts with "py" something? Looks like a python command. Try to find it
in PATH, and use ... | pipenv/core.py | def find_a_system_python(line):
"""Find a Python installation from a given line.
This tries to parse the line in various of ways:
* Looks like an absolute path? Use it directly.
* Looks like a py.exe call? Use py.exe to get the executable.
* Starts with "py" something? Looks like a python command.... | def find_a_system_python(line):
"""Find a Python installation from a given line.
This tries to parse the line in various of ways:
* Looks like an absolute path? Use it directly.
* Looks like a py.exe call? Use py.exe to get the executable.
* Starts with "py" something? Looks like a python command.... | [
"Find",
"a",
"Python",
"installation",
"from",
"a",
"given",
"line",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L318-L339 | [
"def",
"find_a_system_python",
"(",
"line",
")",
":",
"from",
".",
"vendor",
".",
"pythonfinder",
"import",
"Finder",
"finder",
"=",
"Finder",
"(",
"system",
"=",
"False",
",",
"global_search",
"=",
"True",
")",
"if",
"not",
"line",
":",
"return",
"next",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ensure_virtualenv | Creates a virtualenv, if one doesn't exist. | pipenv/core.py | def ensure_virtualenv(three=None, python=None, site_packages=False, pypi_mirror=None):
"""Creates a virtualenv, if one doesn't exist."""
from .environments import PIPENV_USE_SYSTEM
def abort():
sys.exit(1)
global USING_DEFAULT_PYTHON
if not project.virtualenv_exists:
try:
... | def ensure_virtualenv(three=None, python=None, site_packages=False, pypi_mirror=None):
"""Creates a virtualenv, if one doesn't exist."""
from .environments import PIPENV_USE_SYSTEM
def abort():
sys.exit(1)
global USING_DEFAULT_PYTHON
if not project.virtualenv_exists:
try:
... | [
"Creates",
"a",
"virtualenv",
"if",
"one",
"doesn",
"t",
"exist",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L455-L516 | [
"def",
"ensure_virtualenv",
"(",
"three",
"=",
"None",
",",
"python",
"=",
"None",
",",
"site_packages",
"=",
"False",
",",
"pypi_mirror",
"=",
"None",
")",
":",
"from",
".",
"environments",
"import",
"PIPENV_USE_SYSTEM",
"def",
"abort",
"(",
")",
":",
"sy... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ensure_project | Ensures both Pipfile and virtualenv exist for the project. | pipenv/core.py | def ensure_project(
three=None,
python=None,
validate=True,
system=False,
warn=True,
site_packages=False,
deploy=False,
skip_requirements=False,
pypi_mirror=None,
clear=False,
):
"""Ensures both Pipfile and virtualenv exist for the project."""
from .environments import PI... | def ensure_project(
three=None,
python=None,
validate=True,
system=False,
warn=True,
site_packages=False,
deploy=False,
skip_requirements=False,
pypi_mirror=None,
clear=False,
):
"""Ensures both Pipfile and virtualenv exist for the project."""
from .environments import PI... | [
"Ensures",
"both",
"Pipfile",
"and",
"virtualenv",
"exist",
"for",
"the",
"project",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L519-L594 | [
"def",
"ensure_project",
"(",
"three",
"=",
"None",
",",
"python",
"=",
"None",
",",
"validate",
"=",
"True",
",",
"system",
"=",
"False",
",",
"warn",
"=",
"True",
",",
"site_packages",
"=",
"False",
",",
"deploy",
"=",
"False",
",",
"skip_requirements"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | shorten_path | Returns a visually shorter representation of a given system path. | pipenv/core.py | def shorten_path(location, bold=False):
"""Returns a visually shorter representation of a given system path."""
original = location
short = os.sep.join(
[s[0] if len(s) > (len("2long4")) else s for s in location.split(os.sep)]
)
short = short.split(os.sep)
short[-1] = original.split(os.s... | def shorten_path(location, bold=False):
"""Returns a visually shorter representation of a given system path."""
original = location
short = os.sep.join(
[s[0] if len(s) > (len("2long4")) else s for s in location.split(os.sep)]
)
short = short.split(os.sep)
short[-1] = original.split(os.s... | [
"Returns",
"a",
"visually",
"shorter",
"representation",
"of",
"a",
"given",
"system",
"path",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L597-L607 | [
"def",
"shorten_path",
"(",
"location",
",",
"bold",
"=",
"False",
")",
":",
"original",
"=",
"location",
"short",
"=",
"os",
".",
"sep",
".",
"join",
"(",
"[",
"s",
"[",
"0",
"]",
"if",
"len",
"(",
"s",
")",
">",
"(",
"len",
"(",
"\"2long4\"",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_where | Executes the where functionality. | pipenv/core.py | def do_where(virtualenv=False, bare=True):
"""Executes the where functionality."""
if not virtualenv:
if not project.pipfile_exists:
click.echo(
"No Pipfile present at project home. Consider running "
"{0} first to automatically generate a Pipfile for you."
... | def do_where(virtualenv=False, bare=True):
"""Executes the where functionality."""
if not virtualenv:
if not project.pipfile_exists:
click.echo(
"No Pipfile present at project home. Consider running "
"{0} first to automatically generate a Pipfile for you."
... | [
"Executes",
"the",
"where",
"functionality",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L611-L640 | [
"def",
"do_where",
"(",
"virtualenv",
"=",
"False",
",",
"bare",
"=",
"True",
")",
":",
"if",
"not",
"virtualenv",
":",
"if",
"not",
"project",
".",
"pipfile_exists",
":",
"click",
".",
"echo",
"(",
"\"No Pipfile present at project home. Consider running \"",
"\... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_install_dependencies | Executes the install functionality.
If requirements is True, simply spits out a requirements format to stdout. | pipenv/core.py | def do_install_dependencies(
dev=False,
only=False,
bare=False,
requirements=False,
allow_global=False,
ignore_hashes=False,
skip_lock=False,
concurrent=True,
requirements_dir=None,
pypi_mirror=False,
):
""""
Executes the install functionality.
If requirements is Tru... | def do_install_dependencies(
dev=False,
only=False,
bare=False,
requirements=False,
allow_global=False,
ignore_hashes=False,
skip_lock=False,
concurrent=True,
requirements_dir=None,
pypi_mirror=False,
):
""""
Executes the install functionality.
If requirements is Tru... | [
"Executes",
"the",
"install",
"functionality",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L759-L856 | [
"def",
"do_install_dependencies",
"(",
"dev",
"=",
"False",
",",
"only",
"=",
"False",
",",
"bare",
"=",
"False",
",",
"requirements",
"=",
"False",
",",
"allow_global",
"=",
"False",
",",
"ignore_hashes",
"=",
"False",
",",
"skip_lock",
"=",
"False",
",",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_create_virtualenv | Creates a virtualenv. | pipenv/core.py | def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
"""Creates a virtualenv."""
click.echo(
crayons.normal(fix_utf8("Creating a virtualenv for this project…"), bold=True), err=True
)
click.echo(
u"Pipfile: {0}".format(crayons.red(project.pipfile_location, bold=... | def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
"""Creates a virtualenv."""
click.echo(
crayons.normal(fix_utf8("Creating a virtualenv for this project…"), bold=True), err=True
)
click.echo(
u"Pipfile: {0}".format(crayons.red(project.pipfile_location, bold=... | [
"Creates",
"a",
"virtualenv",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L874-L953 | [
"def",
"do_create_virtualenv",
"(",
"python",
"=",
"None",
",",
"site_packages",
"=",
"False",
",",
"pypi_mirror",
"=",
"None",
")",
":",
"click",
".",
"echo",
"(",
"crayons",
".",
"normal",
"(",
"fix_utf8",
"(",
"\"Creating a virtualenv for this project…\"),",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_lock | Executes the freeze functionality. | pipenv/core.py | def do_lock(
ctx=None,
system=False,
clear=False,
pre=False,
keep_outdated=False,
write=True,
pypi_mirror=None,
):
"""Executes the freeze functionality."""
cached_lockfile = {}
if not pre:
pre = project.settings.get("allow_prereleases")
if keep_outdated:
if n... | def do_lock(
ctx=None,
system=False,
clear=False,
pre=False,
keep_outdated=False,
write=True,
pypi_mirror=None,
):
"""Executes the freeze functionality."""
cached_lockfile = {}
if not pre:
pre = project.settings.get("allow_prereleases")
if keep_outdated:
if n... | [
"Executes",
"the",
"freeze",
"functionality",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1003-L1105 | [
"def",
"do_lock",
"(",
"ctx",
"=",
"None",
",",
"system",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"pre",
"=",
"False",
",",
"keep_outdated",
"=",
"False",
",",
"write",
"=",
"True",
",",
"pypi_mirror",
"=",
"None",
",",
")",
":",
"cached_lockf... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_purge | Executes the purge functionality. | pipenv/core.py | def do_purge(bare=False, downloads=False, allow_global=False):
"""Executes the purge functionality."""
if downloads:
if not bare:
click.echo(crayons.normal(fix_utf8("Clearing out downloads directory…"), bold=True))
vistir.path.rmtree(project.download_location)
return
# ... | def do_purge(bare=False, downloads=False, allow_global=False):
"""Executes the purge functionality."""
if downloads:
if not bare:
click.echo(crayons.normal(fix_utf8("Clearing out downloads directory…"), bold=True))
vistir.path.rmtree(project.download_location)
return
# ... | [
"Executes",
"the",
"purge",
"functionality",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1108-L1149 | [
"def",
"do_purge",
"(",
"bare",
"=",
"False",
",",
"downloads",
"=",
"False",
",",
"allow_global",
"=",
"False",
")",
":",
"if",
"downloads",
":",
"if",
"not",
"bare",
":",
"click",
".",
"echo",
"(",
"crayons",
".",
"normal",
"(",
"fix_utf8",
"(",
"\... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_init | Executes the init functionality. | pipenv/core.py | def do_init(
dev=False,
requirements=False,
allow_global=False,
ignore_pipfile=False,
skip_lock=False,
system=False,
concurrent=True,
deploy=False,
pre=False,
keep_outdated=False,
requirements_dir=None,
pypi_mirror=None,
):
"""Executes the init functionality."""
f... | def do_init(
dev=False,
requirements=False,
allow_global=False,
ignore_pipfile=False,
skip_lock=False,
system=False,
concurrent=True,
deploy=False,
pre=False,
keep_outdated=False,
requirements_dir=None,
pypi_mirror=None,
):
"""Executes the init functionality."""
f... | [
"Executes",
"the",
"init",
"functionality",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1152-L1275 | [
"def",
"do_init",
"(",
"dev",
"=",
"False",
",",
"requirements",
"=",
"False",
",",
"allow_global",
"=",
"False",
",",
"ignore_pipfile",
"=",
"False",
",",
"skip_lock",
"=",
"False",
",",
"system",
"=",
"False",
",",
"concurrent",
"=",
"True",
",",
"depl... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | fallback_which | A fallback implementation of the `which` utility command that relies exclusively on
searching the path for commands.
:param str command: The command to search for, optional
:param str location: The search location to prioritize (prepend to path), defaults to None
:param bool allow_global: Whether to se... | pipenv/core.py | def fallback_which(command, location=None, allow_global=False, system=False):
"""
A fallback implementation of the `which` utility command that relies exclusively on
searching the path for commands.
:param str command: The command to search for, optional
:param str location: The search location to ... | def fallback_which(command, location=None, allow_global=False, system=False):
"""
A fallback implementation of the `which` utility command that relies exclusively on
searching the path for commands.
:param str command: The command to search for, optional
:param str location: The search location to ... | [
"A",
"fallback",
"implementation",
"of",
"the",
"which",
"utility",
"command",
"that",
"relies",
"exclusively",
"on",
"searching",
"the",
"path",
"for",
"commands",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1544-L1575 | [
"def",
"fallback_which",
"(",
"command",
",",
"location",
"=",
"None",
",",
"allow_global",
"=",
"False",
",",
"system",
"=",
"False",
")",
":",
"from",
".",
"vendor",
".",
"pythonfinder",
"import",
"Finder",
"if",
"not",
"command",
":",
"raise",
"ValueErr... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | which_pip | Returns the location of virtualenv-installed pip. | pipenv/core.py | def which_pip(allow_global=False):
"""Returns the location of virtualenv-installed pip."""
location = None
if "VIRTUAL_ENV" in os.environ:
location = os.environ["VIRTUAL_ENV"]
if allow_global:
if location:
pip = which("pip", location=location)
if pip:
... | def which_pip(allow_global=False):
"""Returns the location of virtualenv-installed pip."""
location = None
if "VIRTUAL_ENV" in os.environ:
location = os.environ["VIRTUAL_ENV"]
if allow_global:
if location:
pip = which("pip", location=location)
if pip:
... | [
"Returns",
"the",
"location",
"of",
"virtualenv",
"-",
"installed",
"pip",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1578-L1598 | [
"def",
"which_pip",
"(",
"allow_global",
"=",
"False",
")",
":",
"location",
"=",
"None",
"if",
"\"VIRTUAL_ENV\"",
"in",
"os",
".",
"environ",
":",
"location",
"=",
"os",
".",
"environ",
"[",
"\"VIRTUAL_ENV\"",
"]",
"if",
"allow_global",
":",
"if",
"locati... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | system_which | Emulates the system's which. Returns None if not found. | pipenv/core.py | def system_which(command, mult=False):
"""Emulates the system's which. Returns None if not found."""
_which = "which -a" if not os.name == "nt" else "where"
os.environ = {
vistir.compat.fs_str(k): vistir.compat.fs_str(val)
for k, val in os.environ.items()
}
result = None
try:
... | def system_which(command, mult=False):
"""Emulates the system's which. Returns None if not found."""
_which = "which -a" if not os.name == "nt" else "where"
os.environ = {
vistir.compat.fs_str(k): vistir.compat.fs_str(val)
for k, val in os.environ.items()
}
result = None
try:
... | [
"Emulates",
"the",
"system",
"s",
"which",
".",
"Returns",
"None",
"if",
"not",
"found",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1601-L1635 | [
"def",
"system_which",
"(",
"command",
",",
"mult",
"=",
"False",
")",
":",
"_which",
"=",
"\"which -a\"",
"if",
"not",
"os",
".",
"name",
"==",
"\"nt\"",
"else",
"\"where\"",
"os",
".",
"environ",
"=",
"{",
"vistir",
".",
"compat",
".",
"fs_str",
"(",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | format_help | Formats the help string. | pipenv/core.py | def format_help(help):
"""Formats the help string."""
help = help.replace("Options:", str(crayons.normal("Options:", bold=True)))
help = help.replace(
"Usage: pipenv", str("Usage: {0}".format(crayons.normal("pipenv", bold=True)))
)
help = help.replace(" check", str(crayons.red(" check", bo... | def format_help(help):
"""Formats the help string."""
help = help.replace("Options:", str(crayons.normal("Options:", bold=True)))
help = help.replace(
"Usage: pipenv", str("Usage: {0}".format(crayons.normal("pipenv", bold=True)))
)
help = help.replace(" check", str(crayons.red(" check", bo... | [
"Formats",
"the",
"help",
"string",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1639-L1695 | [
"def",
"format_help",
"(",
"help",
")",
":",
"help",
"=",
"help",
".",
"replace",
"(",
"\"Options:\"",
",",
"str",
"(",
"crayons",
".",
"normal",
"(",
"\"Options:\"",
",",
"bold",
"=",
"True",
")",
")",
")",
"help",
"=",
"help",
".",
"replace",
"(",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ensure_lockfile | Ensures that the lockfile is up-to-date. | pipenv/core.py | def ensure_lockfile(keep_outdated=False, pypi_mirror=None):
"""Ensures that the lockfile is up-to-date."""
if not keep_outdated:
keep_outdated = project.settings.get("keep_outdated")
# Write out the lockfile if it doesn't exist, but not if the Pipfile is being ignored
if project.lockfile_exists:... | def ensure_lockfile(keep_outdated=False, pypi_mirror=None):
"""Ensures that the lockfile is up-to-date."""
if not keep_outdated:
keep_outdated = project.settings.get("keep_outdated")
# Write out the lockfile if it doesn't exist, but not if the Pipfile is being ignored
if project.lockfile_exists:... | [
"Ensures",
"that",
"the",
"lockfile",
"is",
"up",
"-",
"to",
"-",
"date",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1749-L1769 | [
"def",
"ensure_lockfile",
"(",
"keep_outdated",
"=",
"False",
",",
"pypi_mirror",
"=",
"None",
")",
":",
"if",
"not",
"keep_outdated",
":",
"keep_outdated",
"=",
"project",
".",
"settings",
".",
"get",
"(",
"\"keep_outdated\"",
")",
"# Write out the lockfile if it... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _inline_activate_venv | Built-in venv doesn't have activate_this.py, but doesn't need it anyway.
As long as we find the correct executable, built-in venv sets up the
environment automatically.
See: https://bugs.python.org/issue21496#msg218455 | pipenv/core.py | def _inline_activate_venv():
"""Built-in venv doesn't have activate_this.py, but doesn't need it anyway.
As long as we find the correct executable, built-in venv sets up the
environment automatically.
See: https://bugs.python.org/issue21496#msg218455
"""
components = []
for name in ("bin",... | def _inline_activate_venv():
"""Built-in venv doesn't have activate_this.py, but doesn't need it anyway.
As long as we find the correct executable, built-in venv sets up the
environment automatically.
See: https://bugs.python.org/issue21496#msg218455
"""
components = []
for name in ("bin",... | [
"Built",
"-",
"in",
"venv",
"doesn",
"t",
"have",
"activate_this",
".",
"py",
"but",
"doesn",
"t",
"need",
"it",
"anyway",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L2376-L2391 | [
"def",
"_inline_activate_venv",
"(",
")",
":",
"components",
"=",
"[",
"]",
"for",
"name",
"in",
"(",
"\"bin\"",
",",
"\"Scripts\"",
")",
":",
"bindir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project",
".",
"virtualenv_location",
",",
"name",
")",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | do_run | Attempt to run command either pulling from project or interpreting as executable.
Args are appended to the command in [scripts] section of project if found. | pipenv/core.py | def do_run(command, args, three=None, python=False, pypi_mirror=None):
"""Attempt to run command either pulling from project or interpreting as executable.
Args are appended to the command in [scripts] section of project if found.
"""
from .cmdparse import ScriptEmptyError
# Ensure that virtualenv... | def do_run(command, args, three=None, python=False, pypi_mirror=None):
"""Attempt to run command either pulling from project or interpreting as executable.
Args are appended to the command in [scripts] section of project if found.
"""
from .cmdparse import ScriptEmptyError
# Ensure that virtualenv... | [
"Attempt",
"to",
"run",
"command",
"either",
"pulling",
"from",
"project",
"or",
"interpreting",
"as",
"executable",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L2464-L2511 | [
"def",
"do_run",
"(",
"command",
",",
"args",
",",
"three",
"=",
"None",
",",
"python",
"=",
"False",
",",
"pypi_mirror",
"=",
"None",
")",
":",
"from",
".",
"cmdparse",
"import",
"ScriptEmptyError",
"# Ensure that virtualenv is available.",
"ensure_project",
"(... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _iter_process | Iterate through processes, yielding process ID and properties of each.
Example usage::
>>> for pid, info in _iter_process():
... print(pid, '->', info)
1509 -> {'parent_pid': 1201, 'executable': 'python.exe'} | pipenv/vendor/shellingham/nt.py | def _iter_process():
"""Iterate through processes, yielding process ID and properties of each.
Example usage::
>>> for pid, info in _iter_process():
... print(pid, '->', info)
1509 -> {'parent_pid': 1201, 'executable': 'python.exe'}
"""
# TODO: Process32{First,Next} does no... | def _iter_process():
"""Iterate through processes, yielding process ID and properties of each.
Example usage::
>>> for pid, info in _iter_process():
... print(pid, '->', info)
1509 -> {'parent_pid': 1201, 'executable': 'python.exe'}
"""
# TODO: Process32{First,Next} does no... | [
"Iterate",
"through",
"processes",
"yielding",
"process",
"ID",
"and",
"properties",
"of",
"each",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/nt.py#L44-L93 | [
"def",
"_iter_process",
"(",
")",
":",
"# TODO: Process32{First,Next} does not return full executable path, only",
"# the name. To get the full path, Module32{First,Next} is needed, but that",
"# does not contain parent process information. We probably need to call",
"# BOTH to build the correct pro... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | get_shell | Get the shell that the supplied pid or os.getpid() is running in. | pipenv/vendor/shellingham/nt.py | def get_shell(pid=None, max_depth=6):
"""Get the shell that the supplied pid or os.getpid() is running in.
"""
if not pid:
pid = os.getpid()
processes = dict(_iter_process())
def check_parent(pid, lvl=0):
ppid = processes[pid].get('parent_pid')
shell_name = _get_executable(p... | def get_shell(pid=None, max_depth=6):
"""Get the shell that the supplied pid or os.getpid() is running in.
"""
if not pid:
pid = os.getpid()
processes = dict(_iter_process())
def check_parent(pid, lvl=0):
ppid = processes[pid].get('parent_pid')
shell_name = _get_executable(p... | [
"Get",
"the",
"shell",
"that",
"the",
"supplied",
"pid",
"or",
"os",
".",
"getpid",
"()",
"is",
"running",
"in",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/nt.py#L106-L128 | [
"def",
"get_shell",
"(",
"pid",
"=",
"None",
",",
"max_depth",
"=",
"6",
")",
":",
"if",
"not",
"pid",
":",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"processes",
"=",
"dict",
"(",
"_iter_process",
"(",
")",
")",
"def",
"check_parent",
"(",
"pid",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ParamType.fail | Helper method to fail with an invalid value message. | pipenv/vendor/click/types.py | def fail(self, message, param=None, ctx=None):
"""Helper method to fail with an invalid value message."""
raise BadParameter(message, ctx=ctx, param=param) | def fail(self, message, param=None, ctx=None):
"""Helper method to fail with an invalid value message."""
raise BadParameter(message, ctx=ctx, param=param) | [
"Helper",
"method",
"to",
"fail",
"with",
"an",
"invalid",
"value",
"message",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/types.py#L67-L69 | [
"def",
"fail",
"(",
"self",
",",
"message",
",",
"param",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"raise",
"BadParameter",
"(",
"message",
",",
"ctx",
"=",
"ctx",
",",
"param",
"=",
"param",
")"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | user_cache_dir | r"""
Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
Typical user cache directories are:
macOS: ~/Library/Caches/<AppName>
Unix: ~/.cache/<AppName> (XDG default)
Windows: C:\Users\<username>\AppData\Local... | pipenv/patched/notpip/_internal/utils/appdirs.py | def user_cache_dir(appname):
# type: (str) -> str
r"""
Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
Typical user cache directories are:
macOS: ~/Library/Caches/<AppName>
Unix: ~/.cache/<AppName> (XDG defa... | def user_cache_dir(appname):
# type: (str) -> str
r"""
Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
Typical user cache directories are:
macOS: ~/Library/Caches/<AppName>
Unix: ~/.cache/<AppName> (XDG defa... | [
"r",
"Return",
"full",
"path",
"to",
"the",
"user",
"-",
"specific",
"cache",
"dir",
"for",
"this",
"application",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/appdirs.py#L21-L67 | [
"def",
"user_cache_dir",
"(",
"appname",
")",
":",
"# type: (str) -> str",
"if",
"WINDOWS",
":",
"# Get the base path",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"_get_win_folder",
"(",
"\"CSIDL_LOCAL_APPDATA\"",
")",
")",
"# When using Python 2, return pa... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | auto_decode | Check a bytes string for a BOM to correctly detect the encoding
Fallback to locale.getpreferredencoding(False) like open() on Python3 | pipenv/patched/notpip/_internal/utils/encoding.py | def auto_decode(data):
# type: (bytes) -> Text
"""Check a bytes string for a BOM to correctly detect the encoding
Fallback to locale.getpreferredencoding(False) like open() on Python3"""
for bom, encoding in BOMS:
if data.startswith(bom):
return data[len(bom):].decode(encoding)
... | def auto_decode(data):
# type: (bytes) -> Text
"""Check a bytes string for a BOM to correctly detect the encoding
Fallback to locale.getpreferredencoding(False) like open() on Python3"""
for bom, encoding in BOMS:
if data.startswith(bom):
return data[len(bom):].decode(encoding)
... | [
"Check",
"a",
"bytes",
"string",
"for",
"a",
"BOM",
"to",
"correctly",
"detect",
"the",
"encoding"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/encoding.py#L24-L39 | [
"def",
"auto_decode",
"(",
"data",
")",
":",
"# type: (bytes) -> Text",
"for",
"bom",
",",
"encoding",
"in",
"BOMS",
":",
"if",
"data",
".",
"startswith",
"(",
"bom",
")",
":",
"return",
"data",
"[",
"len",
"(",
"bom",
")",
":",
"]",
".",
"decode",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | resolve_color_default | Internal helper to get the default value of the color flag. If a
value is passed it's returned unchanged, otherwise it's looked up from
the current context. | pipenv/vendor/click/globals.py | def resolve_color_default(color=None):
""""Internal helper to get the default value of the color flag. If a
value is passed it's returned unchanged, otherwise it's looked up from
the current context.
"""
if color is not None:
return color
ctx = get_current_context(silent=True)
if ct... | def resolve_color_default(color=None):
""""Internal helper to get the default value of the color flag. If a
value is passed it's returned unchanged, otherwise it's looked up from
the current context.
"""
if color is not None:
return color
ctx = get_current_context(silent=True)
if ct... | [
"Internal",
"helper",
"to",
"get",
"the",
"default",
"value",
"of",
"the",
"color",
"flag",
".",
"If",
"a",
"value",
"is",
"passed",
"it",
"s",
"returned",
"unchanged",
"otherwise",
"it",
"s",
"looked",
"up",
"from",
"the",
"current",
"context",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/globals.py#L39-L48 | [
"def",
"resolve_color_default",
"(",
"color",
"=",
"None",
")",
":",
"if",
"color",
"is",
"not",
"None",
":",
"return",
"color",
"ctx",
"=",
"get_current_context",
"(",
"silent",
"=",
"True",
")",
"if",
"ctx",
"is",
"not",
"None",
":",
"return",
"ctx",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | load | Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictio... | pipenv/vendor/toml/decoder.py | def load(f, _dict=dict, decoder=None):
"""Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
... | def load(f, _dict=dict, decoder=None):
"""Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
... | [
"Parses",
"named",
"file",
"or",
"files",
"as",
"toml",
"and",
"returns",
"a",
"dictionary"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/decoder.py#L92-L137 | [
"def",
"load",
"(",
"f",
",",
"_dict",
"=",
"dict",
",",
"decoder",
"=",
"None",
")",
":",
"if",
"_ispath",
"(",
"f",
")",
":",
"with",
"io",
".",
"open",
"(",
"_getpath",
"(",
"f",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"ffile",
":",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | loads | Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
TomlDecodeError: Error while decoding toml | pipenv/vendor/toml/decoder.py | def loads(s, _dict=dict, decoder=None):
"""Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
... | def loads(s, _dict=dict, decoder=None):
"""Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
... | [
"Parses",
"string",
"as",
"toml"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/decoder.py#L143-L461 | [
"def",
"loads",
"(",
"s",
",",
"_dict",
"=",
"dict",
",",
"decoder",
"=",
"None",
")",
":",
"implicitgroups",
"=",
"[",
"]",
"if",
"decoder",
"is",
"None",
":",
"decoder",
"=",
"TomlDecoder",
"(",
"_dict",
")",
"retval",
"=",
"decoder",
".",
"get_emp... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | markup_join | Concatenation that escapes if necessary and converts to unicode. | pipenv/vendor/jinja2/runtime.py | def markup_join(seq):
"""Concatenation that escapes if necessary and converts to unicode."""
buf = []
iterator = imap(soft_unicode, seq)
for arg in iterator:
buf.append(arg)
if hasattr(arg, '__html__'):
return Markup(u'').join(chain(buf, iterator))
return concat(buf) | def markup_join(seq):
"""Concatenation that escapes if necessary and converts to unicode."""
buf = []
iterator = imap(soft_unicode, seq)
for arg in iterator:
buf.append(arg)
if hasattr(arg, '__html__'):
return Markup(u'').join(chain(buf, iterator))
return concat(buf) | [
"Concatenation",
"that",
"escapes",
"if",
"necessary",
"and",
"converts",
"to",
"unicode",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L43-L51 | [
"def",
"markup_join",
"(",
"seq",
")",
":",
"buf",
"=",
"[",
"]",
"iterator",
"=",
"imap",
"(",
"soft_unicode",
",",
"seq",
")",
"for",
"arg",
"in",
"iterator",
":",
"buf",
".",
"append",
"(",
"arg",
")",
"if",
"hasattr",
"(",
"arg",
",",
"'__html_... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | new_context | Internal helper to for context creation. | pipenv/vendor/jinja2/runtime.py | def new_context(environment, template_name, blocks, vars=None,
shared=None, globals=None, locals=None):
"""Internal helper to for context creation."""
if vars is None:
vars = {}
if shared:
parent = vars
else:
parent = dict(globals or (), **vars)
if locals:
... | def new_context(environment, template_name, blocks, vars=None,
shared=None, globals=None, locals=None):
"""Internal helper to for context creation."""
if vars is None:
vars = {}
if shared:
parent = vars
else:
parent = dict(globals or (), **vars)
if locals:
... | [
"Internal",
"helper",
"to",
"for",
"context",
"creation",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L59-L77 | [
"def",
"new_context",
"(",
"environment",
",",
"template_name",
",",
"blocks",
",",
"vars",
"=",
"None",
",",
"shared",
"=",
"None",
",",
"globals",
"=",
"None",
",",
"locals",
"=",
"None",
")",
":",
"if",
"vars",
"is",
"None",
":",
"vars",
"=",
"{",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | make_logging_undefined | Given a logger object this returns a new undefined class that will
log certain failures. It will log iterations and printing. If no
logger is given a default logger is created.
Example::
logger = logging.getLogger(__name__)
LoggingUndefined = make_logging_undefined(
logger=lo... | pipenv/vendor/jinja2/runtime.py | def make_logging_undefined(logger=None, base=None):
"""Given a logger object this returns a new undefined class that will
log certain failures. It will log iterations and printing. If no
logger is given a default logger is created.
Example::
logger = logging.getLogger(__name__)
Loggi... | def make_logging_undefined(logger=None, base=None):
"""Given a logger object this returns a new undefined class that will
log certain failures. It will log iterations and printing. If no
logger is given a default logger is created.
Example::
logger = logging.getLogger(__name__)
Loggi... | [
"Given",
"a",
"logger",
"object",
"this",
"returns",
"a",
"new",
"undefined",
"class",
"that",
"will",
"log",
"certain",
"failures",
".",
"It",
"will",
"log",
"iterations",
"and",
"printing",
".",
"If",
"no",
"logger",
"is",
"given",
"a",
"default",
"logge... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L677-L755 | [
"def",
"make_logging_undefined",
"(",
"logger",
"=",
"None",
",",
"base",
"=",
"None",
")",
":",
"if",
"logger",
"is",
"None",
":",
"import",
"logging",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"addHandler",
"(",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Context.super | Render a parent block. | pipenv/vendor/jinja2/runtime.py | def super(self, name, current):
"""Render a parent block."""
try:
blocks = self.blocks[name]
index = blocks.index(current) + 1
blocks[index]
except LookupError:
return self.environment.undefined('there is no parent block '
... | def super(self, name, current):
"""Render a parent block."""
try:
blocks = self.blocks[name]
index = blocks.index(current) + 1
blocks[index]
except LookupError:
return self.environment.undefined('there is no parent block '
... | [
"Render",
"a",
"parent",
"block",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L175-L185 | [
"def",
"super",
"(",
"self",
",",
"name",
",",
"current",
")",
":",
"try",
":",
"blocks",
"=",
"self",
".",
"blocks",
"[",
"name",
"]",
"index",
"=",
"blocks",
".",
"index",
"(",
"current",
")",
"+",
"1",
"blocks",
"[",
"index",
"]",
"except",
"L... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Context.resolve | Looks up a variable like `__getitem__` or `get` but returns an
:class:`Undefined` object with the name of the name looked up. | pipenv/vendor/jinja2/runtime.py | def resolve(self, key):
"""Looks up a variable like `__getitem__` or `get` but returns an
:class:`Undefined` object with the name of the name looked up.
"""
if self._legacy_resolve_mode:
rv = resolve_or_missing(self, key)
else:
rv = self.resolve_or_missing... | def resolve(self, key):
"""Looks up a variable like `__getitem__` or `get` but returns an
:class:`Undefined` object with the name of the name looked up.
"""
if self._legacy_resolve_mode:
rv = resolve_or_missing(self, key)
else:
rv = self.resolve_or_missing... | [
"Looks",
"up",
"a",
"variable",
"like",
"__getitem__",
"or",
"get",
"but",
"returns",
"an",
":",
"class",
":",
"Undefined",
"object",
"with",
"the",
"name",
"of",
"the",
"name",
"looked",
"up",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L196-L206 | [
"def",
"resolve",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_legacy_resolve_mode",
":",
"rv",
"=",
"resolve_or_missing",
"(",
"self",
",",
"key",
")",
"else",
":",
"rv",
"=",
"self",
".",
"resolve_or_missing",
"(",
"key",
")",
"if",
"rv",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Context.resolve_or_missing | Resolves a variable like :meth:`resolve` but returns the
special `missing` value if it cannot be found. | pipenv/vendor/jinja2/runtime.py | def resolve_or_missing(self, key):
"""Resolves a variable like :meth:`resolve` but returns the
special `missing` value if it cannot be found.
"""
if self._legacy_resolve_mode:
rv = self.resolve(key)
if isinstance(rv, Undefined):
rv = missing
... | def resolve_or_missing(self, key):
"""Resolves a variable like :meth:`resolve` but returns the
special `missing` value if it cannot be found.
"""
if self._legacy_resolve_mode:
rv = self.resolve(key)
if isinstance(rv, Undefined):
rv = missing
... | [
"Resolves",
"a",
"variable",
"like",
":",
"meth",
":",
"resolve",
"but",
"returns",
"the",
"special",
"missing",
"value",
"if",
"it",
"cannot",
"be",
"found",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L208-L217 | [
"def",
"resolve_or_missing",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_legacy_resolve_mode",
":",
"rv",
"=",
"self",
".",
"resolve",
"(",
"key",
")",
"if",
"isinstance",
"(",
"rv",
",",
"Undefined",
")",
":",
"rv",
"=",
"missing",
"return... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Context.get_exported | Get a new dict with the exported variables. | pipenv/vendor/jinja2/runtime.py | def get_exported(self):
"""Get a new dict with the exported variables."""
return dict((k, self.vars[k]) for k in self.exported_vars) | def get_exported(self):
"""Get a new dict with the exported variables."""
return dict((k, self.vars[k]) for k in self.exported_vars) | [
"Get",
"a",
"new",
"dict",
"with",
"the",
"exported",
"variables",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L219-L221 | [
"def",
"get_exported",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"self",
".",
"vars",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"self",
".",
"exported_vars",
")"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Context.get_all | Return the complete context as dict including the exported
variables. For optimizations reasons this might not return an
actual copy so be careful with using it. | pipenv/vendor/jinja2/runtime.py | def get_all(self):
"""Return the complete context as dict including the exported
variables. For optimizations reasons this might not return an
actual copy so be careful with using it.
"""
if not self.vars:
return self.parent
if not self.parent:
re... | def get_all(self):
"""Return the complete context as dict including the exported
variables. For optimizations reasons this might not return an
actual copy so be careful with using it.
"""
if not self.vars:
return self.parent
if not self.parent:
re... | [
"Return",
"the",
"complete",
"context",
"as",
"dict",
"including",
"the",
"exported",
"variables",
".",
"For",
"optimizations",
"reasons",
"this",
"might",
"not",
"return",
"an",
"actual",
"copy",
"so",
"be",
"careful",
"with",
"using",
"it",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L223-L232 | [
"def",
"get_all",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"vars",
":",
"return",
"self",
".",
"parent",
"if",
"not",
"self",
".",
"parent",
":",
"return",
"self",
".",
"vars",
"return",
"dict",
"(",
"self",
".",
"parent",
",",
"*",
"*",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Context.derived | Internal helper function to create a derived context. This is
used in situations where the system needs a new context in the same
template that is independent. | pipenv/vendor/jinja2/runtime.py | def derived(self, locals=None):
"""Internal helper function to create a derived context. This is
used in situations where the system needs a new context in the same
template that is independent.
"""
context = new_context(self.environment, self.name, {},
... | def derived(self, locals=None):
"""Internal helper function to create a derived context. This is
used in situations where the system needs a new context in the same
template that is independent.
"""
context = new_context(self.environment, self.name, {},
... | [
"Internal",
"helper",
"function",
"to",
"create",
"a",
"derived",
"context",
".",
"This",
"is",
"used",
"in",
"situations",
"where",
"the",
"system",
"needs",
"a",
"new",
"context",
"in",
"the",
"same",
"template",
"that",
"is",
"independent",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L268-L277 | [
"def",
"derived",
"(",
"self",
",",
"locals",
"=",
"None",
")",
":",
"context",
"=",
"new_context",
"(",
"self",
".",
"environment",
",",
"self",
".",
"name",
",",
"{",
"}",
",",
"self",
".",
"get_all",
"(",
")",
",",
"True",
",",
"None",
",",
"l... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | BlockReference.super | Super the block. | pipenv/vendor/jinja2/runtime.py | def super(self):
"""Super the block."""
if self._depth + 1 >= len(self._stack):
return self._context.environment. \
undefined('there is no parent block called %r.' %
self.name, name='super')
return BlockReference(self.name, self._context, sel... | def super(self):
"""Super the block."""
if self._depth + 1 >= len(self._stack):
return self._context.environment. \
undefined('there is no parent block called %r.' %
self.name, name='super')
return BlockReference(self.name, self._context, sel... | [
"Super",
"the",
"block",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L334-L341 | [
"def",
"super",
"(",
"self",
")",
":",
"if",
"self",
".",
"_depth",
"+",
"1",
">=",
"len",
"(",
"self",
".",
"_stack",
")",
":",
"return",
"self",
".",
"_context",
".",
"environment",
".",
"undefined",
"(",
"'there is no parent block called %r.'",
"%",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | LoopContextBase.cycle | Cycles among the arguments with the current loop index. | pipenv/vendor/jinja2/runtime.py | def cycle(self, *args):
"""Cycles among the arguments with the current loop index."""
if not args:
raise TypeError('no items for cycling given')
return args[self.index0 % len(args)] | def cycle(self, *args):
"""Cycles among the arguments with the current loop index."""
if not args:
raise TypeError('no items for cycling given')
return args[self.index0 % len(args)] | [
"Cycles",
"among",
"the",
"arguments",
"with",
"the",
"current",
"loop",
"index",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L366-L370 | [
"def",
"cycle",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"args",
":",
"raise",
"TypeError",
"(",
"'no items for cycling given'",
")",
"return",
"args",
"[",
"self",
".",
"index0",
"%",
"len",
"(",
"args",
")",
"]"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | LoopContextBase.changed | Checks whether the value has changed since the last call. | pipenv/vendor/jinja2/runtime.py | def changed(self, *value):
"""Checks whether the value has changed since the last call."""
if self._last_checked_value != value:
self._last_checked_value = value
return True
return False | def changed(self, *value):
"""Checks whether the value has changed since the last call."""
if self._last_checked_value != value:
self._last_checked_value = value
return True
return False | [
"Checks",
"whether",
"the",
"value",
"has",
"changed",
"since",
"the",
"last",
"call",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L372-L377 | [
"def",
"changed",
"(",
"self",
",",
"*",
"value",
")",
":",
"if",
"self",
".",
"_last_checked_value",
"!=",
"value",
":",
"self",
".",
"_last_checked_value",
"=",
"value",
"return",
"True",
"return",
"False"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | Macro._invoke | This method is being swapped out by the async implementation. | pipenv/vendor/jinja2/runtime.py | def _invoke(self, arguments, autoescape):
"""This method is being swapped out by the async implementation."""
rv = self._func(*arguments)
if autoescape:
rv = Markup(rv)
return rv | def _invoke(self, arguments, autoescape):
"""This method is being swapped out by the async implementation."""
rv = self._func(*arguments)
if autoescape:
rv = Markup(rv)
return rv | [
"This",
"method",
"is",
"being",
"swapped",
"out",
"by",
"the",
"async",
"implementation",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L577-L582 | [
"def",
"_invoke",
"(",
"self",
",",
"arguments",
",",
"autoescape",
")",
":",
"rv",
"=",
"self",
".",
"_func",
"(",
"*",
"arguments",
")",
"if",
"autoescape",
":",
"rv",
"=",
"Markup",
"(",
"rv",
")",
"return",
"rv"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | main | This is where the example starts and the FSM state transitions are
defined. Note that states are strings (such as 'INIT'). This is not
necessary, but it makes the example easier to read. | pipenv/vendor/pexpect/FSM.py | def main():
'''This is where the example starts and the FSM state transitions are
defined. Note that states are strings (such as 'INIT'). This is not
necessary, but it makes the example easier to read. '''
f = FSM ('INIT', [])
f.set_default_transition (Error, 'INIT')
f.add_transition_any ('IN... | def main():
'''This is where the example starts and the FSM state transitions are
defined. Note that states are strings (such as 'INIT'). This is not
necessary, but it makes the example easier to read. '''
f = FSM ('INIT', [])
f.set_default_transition (Error, 'INIT')
f.add_transition_any ('IN... | [
"This",
"is",
"where",
"the",
"example",
"starts",
"and",
"the",
"FSM",
"state",
"transitions",
"are",
"defined",
".",
"Note",
"that",
"states",
"are",
"strings",
"(",
"such",
"as",
"INIT",
")",
".",
"This",
"is",
"not",
"necessary",
"but",
"it",
"makes"... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L308-L330 | [
"def",
"main",
"(",
")",
":",
"f",
"=",
"FSM",
"(",
"'INIT'",
",",
"[",
"]",
")",
"f",
".",
"set_default_transition",
"(",
"Error",
",",
"'INIT'",
")",
"f",
".",
"add_transition_any",
"(",
"'INIT'",
",",
"None",
",",
"'INIT'",
")",
"f",
".",
"add_t... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | FSM.add_transition | This adds a transition that associates:
(input_symbol, current_state) --> (action, next_state)
The action may be set to None in which case the process() method will
ignore the action and only set the next_state. The next_state may be
set to None in which case the current state ... | pipenv/vendor/pexpect/FSM.py | def add_transition (self, input_symbol, state, action=None, next_state=None):
'''This adds a transition that associates:
(input_symbol, current_state) --> (action, next_state)
The action may be set to None in which case the process() method will
ignore the action and only set ... | def add_transition (self, input_symbol, state, action=None, next_state=None):
'''This adds a transition that associates:
(input_symbol, current_state) --> (action, next_state)
The action may be set to None in which case the process() method will
ignore the action and only set ... | [
"This",
"adds",
"a",
"transition",
"that",
"associates",
":"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L131-L146 | [
"def",
"add_transition",
"(",
"self",
",",
"input_symbol",
",",
"state",
",",
"action",
"=",
"None",
",",
"next_state",
"=",
"None",
")",
":",
"if",
"next_state",
"is",
"None",
":",
"next_state",
"=",
"state",
"self",
".",
"state_transitions",
"[",
"(",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | FSM.add_transition_list | This adds the same transition for a list of input symbols.
You can pass a list or a string. Note that it is handy to use
string.digits, string.whitespace, string.letters, etc. to add
transitions that match character classes.
The action may be set to None in which case the process() meth... | pipenv/vendor/pexpect/FSM.py | def add_transition_list (self, list_input_symbols, state, action=None, next_state=None):
'''This adds the same transition for a list of input symbols.
You can pass a list or a string. Note that it is handy to use
string.digits, string.whitespace, string.letters, etc. to add
transitions ... | def add_transition_list (self, list_input_symbols, state, action=None, next_state=None):
'''This adds the same transition for a list of input symbols.
You can pass a list or a string. Note that it is handy to use
string.digits, string.whitespace, string.letters, etc. to add
transitions ... | [
"This",
"adds",
"the",
"same",
"transition",
"for",
"a",
"list",
"of",
"input",
"symbols",
".",
"You",
"can",
"pass",
"a",
"list",
"or",
"a",
"string",
".",
"Note",
"that",
"it",
"is",
"handy",
"to",
"use",
"string",
".",
"digits",
"string",
".",
"wh... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L148-L162 | [
"def",
"add_transition_list",
"(",
"self",
",",
"list_input_symbols",
",",
"state",
",",
"action",
"=",
"None",
",",
"next_state",
"=",
"None",
")",
":",
"if",
"next_state",
"is",
"None",
":",
"next_state",
"=",
"state",
"for",
"input_symbol",
"in",
"list_in... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | FSM.add_transition_any | This adds a transition that associates:
(current_state) --> (action, next_state)
That is, any input symbol will match the current state.
The process() method checks the "any" state associations after it first
checks for an exact match of (input_symbol, current_state).
... | pipenv/vendor/pexpect/FSM.py | def add_transition_any (self, state, action=None, next_state=None):
'''This adds a transition that associates:
(current_state) --> (action, next_state)
That is, any input symbol will match the current state.
The process() method checks the "any" state associations after it fir... | def add_transition_any (self, state, action=None, next_state=None):
'''This adds a transition that associates:
(current_state) --> (action, next_state)
That is, any input symbol will match the current state.
The process() method checks the "any" state associations after it fir... | [
"This",
"adds",
"a",
"transition",
"that",
"associates",
":"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L164-L180 | [
"def",
"add_transition_any",
"(",
"self",
",",
"state",
",",
"action",
"=",
"None",
",",
"next_state",
"=",
"None",
")",
":",
"if",
"next_state",
"is",
"None",
":",
"next_state",
"=",
"state",
"self",
".",
"state_transitions_any",
"[",
"state",
"]",
"=",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | FSM.get_transition | This returns (action, next state) given an input_symbol and state.
This does not modify the FSM state, so calling this method has no side
effects. Normally you do not call this method directly. It is called by
process().
The sequence of steps to check for a defined transition goes from ... | pipenv/vendor/pexpect/FSM.py | def get_transition (self, input_symbol, state):
'''This returns (action, next state) given an input_symbol and state.
This does not modify the FSM state, so calling this method has no side
effects. Normally you do not call this method directly. It is called by
process().
The se... | def get_transition (self, input_symbol, state):
'''This returns (action, next state) given an input_symbol and state.
This does not modify the FSM state, so calling this method has no side
effects. Normally you do not call this method directly. It is called by
process().
The se... | [
"This",
"returns",
"(",
"action",
"next",
"state",
")",
"given",
"an",
"input_symbol",
"and",
"state",
".",
"This",
"does",
"not",
"modify",
"the",
"FSM",
"state",
"so",
"calling",
"this",
"method",
"has",
"no",
"side",
"effects",
".",
"Normally",
"you",
... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L195-L226 | [
"def",
"get_transition",
"(",
"self",
",",
"input_symbol",
",",
"state",
")",
":",
"if",
"(",
"input_symbol",
",",
"state",
")",
"in",
"self",
".",
"state_transitions",
":",
"return",
"self",
".",
"state_transitions",
"[",
"(",
"input_symbol",
",",
"state",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | FSM.process | This is the main method that you call to process input. This may
cause the FSM to change state and call an action. This method calls
get_transition() to find the action and next_state associated with the
input_symbol and current_state. If the action is None then the action
is not called ... | pipenv/vendor/pexpect/FSM.py | def process (self, input_symbol):
'''This is the main method that you call to process input. This may
cause the FSM to change state and call an action. This method calls
get_transition() to find the action and next_state associated with the
input_symbol and current_state. If the action ... | def process (self, input_symbol):
'''This is the main method that you call to process input. This may
cause the FSM to change state and call an action. This method calls
get_transition() to find the action and next_state associated with the
input_symbol and current_state. If the action ... | [
"This",
"is",
"the",
"main",
"method",
"that",
"you",
"call",
"to",
"process",
"input",
".",
"This",
"may",
"cause",
"the",
"FSM",
"to",
"change",
"state",
"and",
"call",
"an",
"action",
".",
"This",
"method",
"calls",
"get_transition",
"()",
"to",
"find... | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L228-L243 | [
"def",
"process",
"(",
"self",
",",
"input_symbol",
")",
":",
"self",
".",
"input_symbol",
"=",
"input_symbol",
"(",
"self",
".",
"action",
",",
"self",
".",
"next_state",
")",
"=",
"self",
".",
"get_transition",
"(",
"self",
".",
"input_symbol",
",",
"s... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ip_address | Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An IPv4Address or IPv6Address obje... | pipenv/patched/notpip/_vendor/ipaddress.py | def ip_address(address):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An... | def ip_address(address):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L135-L168 | [
"def",
"ip_address",
"(",
"address",
")",
":",
"try",
":",
"return",
"IPv4Address",
"(",
"address",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6Address",
"(",
"address",
")",
"except",
"(",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | ip_interface | Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An IPv4Interface or IPv6Interface ... | pipenv/patched/notpip/_vendor/ipaddress.py | def ip_interface(address):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
... | def ip_interface(address):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L207-L239 | [
"def",
"ip_interface",
"(",
"address",
")",
":",
"try",
":",
"return",
"IPv4Interface",
"(",
"address",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6Interface",
"(",
"address",
")",
"except",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _split_optional_netmask | Helper to split the netmask and raise AddressValueError if needed | pipenv/patched/notpip/_vendor/ipaddress.py | def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = _compat_str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = _compat_str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | [
"Helper",
"to",
"split",
"the",
"netmask",
"and",
"raise",
"AddressValueError",
"if",
"needed"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L278-L283 | [
"def",
"_split_optional_netmask",
"(",
"address",
")",
":",
"addr",
"=",
"_compat_str",
"(",
"address",
")",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"addr",
")",
">",
"2",
":",
"raise",
"AddressValueError",
"(",
"\"Only one '/' permitted in %r\"",
"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _find_address_range | Find a sequence of sorted deduplicated IPv#Address.
Args:
addresses: a list of IPv#Address objects.
Yields:
A tuple containing the first and last IP addresses in the sequence. | pipenv/patched/notpip/_vendor/ipaddress.py | def _find_address_range(addresses):
"""Find a sequence of sorted deduplicated IPv#Address.
Args:
addresses: a list of IPv#Address objects.
Yields:
A tuple containing the first and last IP addresses in the sequence.
"""
it = iter(addresses)
first = last = next(it)
for ip in... | def _find_address_range(addresses):
"""Find a sequence of sorted deduplicated IPv#Address.
Args:
addresses: a list of IPv#Address objects.
Yields:
A tuple containing the first and last IP addresses in the sequence.
"""
it = iter(addresses)
first = last = next(it)
for ip in... | [
"Find",
"a",
"sequence",
"of",
"sorted",
"deduplicated",
"IPv#Address",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L286-L303 | [
"def",
"_find_address_range",
"(",
"addresses",
")",
":",
"it",
"=",
"iter",
"(",
"addresses",
")",
"first",
"=",
"last",
"=",
"next",
"(",
"it",
")",
"for",
"ip",
"in",
"it",
":",
"if",
"ip",
".",
"_ip",
"!=",
"last",
".",
"_ip",
"+",
"1",
":",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _count_righthand_zero_bits | Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number. | pipenv/patched/notpip/_vendor/ipaddress.py | def _count_righthand_zero_bits(number, bits):
"""Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number.
"""
if number == 0:
return... | def _count_righthand_zero_bits(number, bits):
"""Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number.
"""
if number == 0:
return... | [
"Count",
"the",
"number",
"of",
"zero",
"bits",
"on",
"the",
"right",
"hand",
"side",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L306-L319 | [
"def",
"_count_righthand_zero_bits",
"(",
"number",
",",
"bits",
")",
":",
"if",
"number",
"==",
"0",
":",
"return",
"bits",
"return",
"min",
"(",
"bits",
",",
"_compat_bit_length",
"(",
"~",
"number",
"&",
"(",
"number",
"-",
"1",
")",
")",
")"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _collapse_addresses_internal | Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collapse_addresses_internal([ip1, ip2, ip3, ip4]) ->
... | pipenv/patched/notpip/_vendor/ipaddress.py | def _collapse_addresses_internal(addresses):
"""Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collapse... | def _collapse_addresses_internal(addresses):
"""Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collapse... | [
"Loops",
"through",
"the",
"addresses",
"collapsing",
"concurrent",
"netblocks",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L377-L423 | [
"def",
"_collapse_addresses_internal",
"(",
"addresses",
")",
":",
"# First merge",
"to_merge",
"=",
"list",
"(",
"addresses",
")",
"subnets",
"=",
"{",
"}",
"while",
"to_merge",
":",
"net",
"=",
"to_merge",
".",
"pop",
"(",
")",
"supernet",
"=",
"net",
".... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | collapse_addresses | Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network or IPv6Network objects.
Returns:
... | pipenv/patched/notpip/_vendor/ipaddress.py | def collapse_addresses(addresses):
"""Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network... | def collapse_addresses(addresses):
"""Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network... | [
"Collapse",
"a",
"list",
"of",
"IP",
"objects",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L426-L477 | [
"def",
"collapse_addresses",
"(",
"addresses",
")",
":",
"addrs",
"=",
"[",
"]",
"ips",
"=",
"[",
"]",
"nets",
"=",
"[",
"]",
"# split IP addresses and networks",
"for",
"ip",
"in",
"addresses",
":",
"if",
"isinstance",
"(",
"ip",
",",
"_BaseAddress",
")",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | get_mixed_type_key | Return a key suitable for sorting between networks and addresses.
Address and Network objects are not sortable by default; they're
fundamentally different so the expression
IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')
doesn't make any sense. There are some times however, where you may... | pipenv/patched/notpip/_vendor/ipaddress.py | def get_mixed_type_key(obj):
"""Return a key suitable for sorting between networks and addresses.
Address and Network objects are not sortable by default; they're
fundamentally different so the expression
IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')
doesn't make any sense. There a... | def get_mixed_type_key(obj):
"""Return a key suitable for sorting between networks and addresses.
Address and Network objects are not sortable by default; they're
fundamentally different so the expression
IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')
doesn't make any sense. There a... | [
"Return",
"a",
"key",
"suitable",
"for",
"sorting",
"between",
"networks",
"and",
"addresses",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L480-L502 | [
"def",
"get_mixed_type_key",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"_BaseNetwork",
")",
":",
"return",
"obj",
".",
"_get_networks_key",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"_BaseAddress",
")",
":",
"return",
"obj",
".",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _IPAddressBase._prefix_from_ip_int | Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & ones | pipenv/patched/notpip/_vendor/ipaddress.py | def _prefix_from_ip_int(cls, ip_int):
"""Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & o... | def _prefix_from_ip_int(cls, ip_int):
"""Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & o... | [
"Return",
"prefix",
"length",
"from",
"the",
"bitwise",
"netmask",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L570-L592 | [
"def",
"_prefix_from_ip_int",
"(",
"cls",
",",
"ip_int",
")",
":",
"trailing_zeroes",
"=",
"_count_righthand_zero_bits",
"(",
"ip_int",
",",
"cls",
".",
"_max_prefixlen",
")",
"prefixlen",
"=",
"cls",
".",
"_max_prefixlen",
"-",
"trailing_zeroes",
"leading_ones",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _IPAddressBase._prefix_from_prefix_string | Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask | pipenv/patched/notpip/_vendor/ipaddress.py | def _prefix_from_prefix_string(cls, prefixlen_str):
"""Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask
... | def _prefix_from_prefix_string(cls, prefixlen_str):
"""Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask
... | [
"Return",
"prefix",
"length",
"from",
"a",
"numeric",
"string"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L600-L622 | [
"def",
"_prefix_from_prefix_string",
"(",
"cls",
",",
"prefixlen_str",
")",
":",
"# int allows a leading +/- as well as surrounding whitespace,",
"# so we ensure that isn't the case",
"if",
"not",
"_BaseV4",
".",
"_DECIMAL_DIGITS",
".",
"issuperset",
"(",
"prefixlen_str",
")",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _IPAddressBase._prefix_from_ip_string | Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask/hostmask | pipenv/patched/notpip/_vendor/ipaddress.py | def _prefix_from_ip_string(cls, ip_str):
"""Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask... | def _prefix_from_ip_string(cls, ip_str):
"""Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask... | [
"Turn",
"a",
"netmask",
"/",
"hostmask",
"string",
"into",
"a",
"prefix",
"length"
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L625-L656 | [
"def",
"_prefix_from_ip_string",
"(",
"cls",
",",
"ip_str",
")",
":",
"# Parse the netmask/hostmask like an IP address.",
"try",
":",
"ip_int",
"=",
"cls",
".",
"_ip_int_from_string",
"(",
"ip_str",
")",
"except",
"AddressValueError",
":",
"cls",
".",
"_report_invalid... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseNetwork.overlaps | Tell if self is partly contained in other. | pipenv/patched/notpip/_vendor/ipaddress.py | def overlaps(self, other):
"""Tell if self is partly contained in other."""
return self.network_address in other or (
self.broadcast_address in other or (
other.network_address in self or (
other.broadcast_address in self))) | def overlaps(self, other):
"""Tell if self is partly contained in other."""
return self.network_address in other or (
self.broadcast_address in other or (
other.network_address in self or (
other.broadcast_address in self))) | [
"Tell",
"if",
"self",
"is",
"partly",
"contained",
"in",
"other",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L810-L815 | [
"def",
"overlaps",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"network_address",
"in",
"other",
"or",
"(",
"self",
".",
"broadcast_address",
"in",
"other",
"or",
"(",
"other",
".",
"network_address",
"in",
"self",
"or",
"(",
"other",
"."... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseNetwork.address_exclude | Remove an address from a larger block.
For example:
addr1 = ip_network('192.0.2.0/28')
addr2 = ip_network('192.0.2.1/32')
list(addr1.address_exclude(addr2)) =
[IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.2/31'),
IPv4Network('192.0.2.4/... | pipenv/patched/notpip/_vendor/ipaddress.py | def address_exclude(self, other):
"""Remove an address from a larger block.
For example:
addr1 = ip_network('192.0.2.0/28')
addr2 = ip_network('192.0.2.1/32')
list(addr1.address_exclude(addr2)) =
[IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.2/3... | def address_exclude(self, other):
"""Remove an address from a larger block.
For example:
addr1 = ip_network('192.0.2.0/28')
addr2 = ip_network('192.0.2.1/32')
list(addr1.address_exclude(addr2)) =
[IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.2/3... | [
"Remove",
"an",
"address",
"from",
"a",
"larger",
"block",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L863-L936 | [
"def",
"address_exclude",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"_version",
"==",
"other",
".",
"_version",
":",
"raise",
"TypeError",
"(",
"\"%s and %s are not of the same version\"",
"%",
"(",
"self",
",",
"other",
")",
")",
"if",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseNetwork.compare_networks | Compare two IP objects.
This is only concerned about the comparison of the integer
representation of the network addresses. This means that the
host bits aren't considered at all in this method. If you want
to compare host bits, you can easily enough do a
'HostA._ip < HostB._i... | pipenv/patched/notpip/_vendor/ipaddress.py | def compare_networks(self, other):
"""Compare two IP objects.
This is only concerned about the comparison of the integer
representation of the network addresses. This means that the
host bits aren't considered at all in this method. If you want
to compare host bits, you can ea... | def compare_networks(self, other):
"""Compare two IP objects.
This is only concerned about the comparison of the integer
representation of the network addresses. This means that the
host bits aren't considered at all in this method. If you want
to compare host bits, you can ea... | [
"Compare",
"two",
"IP",
"objects",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L938-L984 | [
"def",
"compare_networks",
"(",
"self",
",",
"other",
")",
":",
"# does this need to raise a ValueError?",
"if",
"self",
".",
"_version",
"!=",
"other",
".",
"_version",
":",
"raise",
"TypeError",
"(",
"'%s and %s are not of the same type'",
"%",
"(",
"self",
",",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseNetwork.subnets | The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
prefixlen_diff: An integer, the amount the prefix length
... | pipenv/patched/notpip/_vendor/ipaddress.py | def subnets(self, prefixlen_diff=1, new_prefix=None):
"""The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
pre... | def subnets(self, prefixlen_diff=1, new_prefix=None):
"""The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
pre... | [
"The",
"subnets",
"which",
"join",
"to",
"make",
"the",
"current",
"subnet",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L996-L1047 | [
"def",
"subnets",
"(",
"self",
",",
"prefixlen_diff",
"=",
"1",
",",
"new_prefix",
"=",
"None",
")",
":",
"if",
"self",
".",
"_prefixlen",
"==",
"self",
".",
"_max_prefixlen",
":",
"yield",
"self",
"return",
"if",
"new_prefix",
"is",
"not",
"None",
":",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseNetwork.supernet | The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of 3, a supernet with a
/21 netmask is returned.
... | pipenv/patched/notpip/_vendor/ipaddress.py | def supernet(self, prefixlen_diff=1, new_prefix=None):
"""The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of ... | def supernet(self, prefixlen_diff=1, new_prefix=None):
"""The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of ... | [
"The",
"supernet",
"containing",
"the",
"current",
"network",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1049-L1087 | [
"def",
"supernet",
"(",
"self",
",",
"prefixlen_diff",
"=",
"1",
",",
"new_prefix",
"=",
"None",
")",
":",
"if",
"self",
".",
"_prefixlen",
"==",
"0",
":",
"return",
"self",
"if",
"new_prefix",
"is",
"not",
"None",
":",
"if",
"new_prefix",
">",
"self",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV4._make_netmask | Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0") | pipenv/patched/notpip/_vendor/ipaddress.py | def _make_netmask(cls, arg):
"""Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
"""
... | def _make_netmask(cls, arg):
"""Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
"""
... | [
"Make",
"a",
"(",
"netmask",
"prefix_len",
")",
"tuple",
"from",
"the",
"given",
"argument",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1219-L1240 | [
"def",
"_make_netmask",
"(",
"cls",
",",
"arg",
")",
":",
"if",
"arg",
"not",
"in",
"cls",
".",
"_netmask_cache",
":",
"if",
"isinstance",
"(",
"arg",
",",
"_compat_int_types",
")",
":",
"prefixlen",
"=",
"arg",
"else",
":",
"try",
":",
"# Check for a ne... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV4._ip_int_from_string | Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address. | pipenv/patched/notpip/_vendor/ipaddress.py | def _ip_int_from_string(cls, ip_str):
"""Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address.
... | def _ip_int_from_string(cls, ip_str):
"""Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address.
... | [
"Turn",
"the",
"given",
"IP",
"string",
"into",
"an",
"integer",
"for",
"comparison",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1243-L1267 | [
"def",
"_ip_int_from_string",
"(",
"cls",
",",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
":",
"raise",
"AddressValueError",
"(",
"'Address cannot be empty'",
")",
"octets",
"=",
"ip_str",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"octets",
")",
"!=... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV4._string_from_ip_int | Turns a 32-bit integer into dotted decimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
The IP address as a string in dotted decimal notation. | pipenv/patched/notpip/_vendor/ipaddress.py | def _string_from_ip_int(cls, ip_int):
"""Turns a 32-bit integer into dotted decimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
The IP address as a string in dotted decimal notation.
"""
return '.'.join(_compat_str(struct.unpack(b'!B', ... | def _string_from_ip_int(cls, ip_int):
"""Turns a 32-bit integer into dotted decimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
The IP address as a string in dotted decimal notation.
"""
return '.'.join(_compat_str(struct.unpack(b'!B', ... | [
"Turns",
"a",
"32",
"-",
"bit",
"integer",
"into",
"dotted",
"decimal",
"notation",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1307-L1320 | [
"def",
"_string_from_ip_int",
"(",
"cls",
",",
"ip_int",
")",
":",
"return",
"'.'",
".",
"join",
"(",
"_compat_str",
"(",
"struct",
".",
"unpack",
"(",
"b'!B'",
",",
"b",
")",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"b",
",",
"bytes",
")",
"else",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV4._is_hostmask | Test if the IP string is a hostmask (rather than a netmask).
Args:
ip_str: A string, the potential hostmask.
Returns:
A boolean, True if the IP string is a hostmask. | pipenv/patched/notpip/_vendor/ipaddress.py | def _is_hostmask(self, ip_str):
"""Test if the IP string is a hostmask (rather than a netmask).
Args:
ip_str: A string, the potential hostmask.
Returns:
A boolean, True if the IP string is a hostmask.
"""
bits = ip_str.split('.')
try:
... | def _is_hostmask(self, ip_str):
"""Test if the IP string is a hostmask (rather than a netmask).
Args:
ip_str: A string, the potential hostmask.
Returns:
A boolean, True if the IP string is a hostmask.
"""
bits = ip_str.split('.')
try:
... | [
"Test",
"if",
"the",
"IP",
"string",
"is",
"a",
"hostmask",
"(",
"rather",
"than",
"a",
"netmask",
")",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1322-L1341 | [
"def",
"_is_hostmask",
"(",
"self",
",",
"ip_str",
")",
":",
"bits",
"=",
"ip_str",
".",
"split",
"(",
"'.'",
")",
"try",
":",
"parts",
"=",
"[",
"x",
"for",
"x",
"in",
"map",
"(",
"int",
",",
"bits",
")",
"if",
"x",
"in",
"self",
".",
"_valid_... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | IPv4Network.is_global | Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry. | pipenv/patched/notpip/_vendor/ipaddress.py | def is_global(self):
"""Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry.
"""
return (not (self.network_address in IPv4Network('100.64.0.0/10') and
self.... | def is_global(self):
"""Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry.
"""
return (not (self.network_address in IPv4Network('100.64.0.0/10') and
self.... | [
"Test",
"if",
"this",
"address",
"is",
"allocated",
"for",
"public",
"networks",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1663-L1673 | [
"def",
"is_global",
"(",
"self",
")",
":",
"return",
"(",
"not",
"(",
"self",
".",
"network_address",
"in",
"IPv4Network",
"(",
"'100.64.0.0/10'",
")",
"and",
"self",
".",
"broadcast_address",
"in",
"IPv4Network",
"(",
"'100.64.0.0/10'",
")",
")",
"and",
"no... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV6._make_netmask | Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0") | pipenv/patched/notpip/_vendor/ipaddress.py | def _make_netmask(cls, arg):
"""Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
"""
... | def _make_netmask(cls, arg):
"""Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
"""
... | [
"Make",
"a",
"(",
"netmask",
"prefix_len",
")",
"tuple",
"from",
"the",
"given",
"argument",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1732-L1747 | [
"def",
"_make_netmask",
"(",
"cls",
",",
"arg",
")",
":",
"if",
"arg",
"not",
"in",
"cls",
".",
"_netmask_cache",
":",
"if",
"isinstance",
"(",
"arg",
",",
"_compat_int_types",
")",
":",
"prefixlen",
"=",
"arg",
"else",
":",
"prefixlen",
"=",
"cls",
".... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV6._ip_int_from_string | Turn an IPv6 ip_str into an integer.
Args:
ip_str: A string, the IPv6 ip_str.
Returns:
An int, the IPv6 address
Raises:
AddressValueError: if ip_str isn't a valid IPv6 Address. | pipenv/patched/notpip/_vendor/ipaddress.py | def _ip_int_from_string(cls, ip_str):
"""Turn an IPv6 ip_str into an integer.
Args:
ip_str: A string, the IPv6 ip_str.
Returns:
An int, the IPv6 address
Raises:
AddressValueError: if ip_str isn't a valid IPv6 Address.
"""
if not ip_... | def _ip_int_from_string(cls, ip_str):
"""Turn an IPv6 ip_str into an integer.
Args:
ip_str: A string, the IPv6 ip_str.
Returns:
An int, the IPv6 address
Raises:
AddressValueError: if ip_str isn't a valid IPv6 Address.
"""
if not ip_... | [
"Turn",
"an",
"IPv6",
"ip_str",
"into",
"an",
"integer",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1750-L1852 | [
"def",
"_ip_int_from_string",
"(",
"cls",
",",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
":",
"raise",
"AddressValueError",
"(",
"'Address cannot be empty'",
")",
"parts",
"=",
"ip_str",
".",
"split",
"(",
"':'",
")",
"# An IPv6 address needs at least 2 colons (3 p... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV6._parse_hextet | Convert an IPv6 hextet string into an integer.
Args:
hextet_str: A string, the number to parse.
Returns:
The hextet as an integer.
Raises:
ValueError: if the input isn't strictly a hex number from
[0..FFFF]. | pipenv/patched/notpip/_vendor/ipaddress.py | def _parse_hextet(cls, hextet_str):
"""Convert an IPv6 hextet string into an integer.
Args:
hextet_str: A string, the number to parse.
Returns:
The hextet as an integer.
Raises:
ValueError: if the input isn't strictly a hex number from
... | def _parse_hextet(cls, hextet_str):
"""Convert an IPv6 hextet string into an integer.
Args:
hextet_str: A string, the number to parse.
Returns:
The hextet as an integer.
Raises:
ValueError: if the input isn't strictly a hex number from
... | [
"Convert",
"an",
"IPv6",
"hextet",
"string",
"into",
"an",
"integer",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1855-L1878 | [
"def",
"_parse_hextet",
"(",
"cls",
",",
"hextet_str",
")",
":",
"# Whitelist the characters, since int() allows a lot of bizarre stuff.",
"if",
"not",
"cls",
".",
"_HEX_DIGITS",
".",
"issuperset",
"(",
"hextet_str",
")",
":",
"raise",
"ValueError",
"(",
"\"Only hex dig... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | _BaseV6._compress_hextets | Compresses a list of hextets.
Compresses a list of strings, replacing the longest continuous
sequence of "0" in the list with "" and adding empty strings at
the beginning or at the end of the string such that subsequently
calling ":".join(hextets) will produce the compressed version of
... | pipenv/patched/notpip/_vendor/ipaddress.py | def _compress_hextets(cls, hextets):
"""Compresses a list of hextets.
Compresses a list of strings, replacing the longest continuous
sequence of "0" in the list with "" and adding empty strings at
the beginning or at the end of the string such that subsequently
calling ":".join(... | def _compress_hextets(cls, hextets):
"""Compresses a list of hextets.
Compresses a list of strings, replacing the longest continuous
sequence of "0" in the list with "" and adding empty strings at
the beginning or at the end of the string such that subsequently
calling ":".join(... | [
"Compresses",
"a",
"list",
"of",
"hextets",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1881-L1926 | [
"def",
"_compress_hextets",
"(",
"cls",
",",
"hextets",
")",
":",
"best_doublecolon_start",
"=",
"-",
"1",
"best_doublecolon_len",
"=",
"0",
"doublecolon_start",
"=",
"-",
"1",
"doublecolon_len",
"=",
"0",
"for",
"index",
",",
"hextet",
"in",
"enumerate",
"(",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
train | IPv6Address.teredo | Tuple of embedded teredo IPs.
Returns:
Tuple of the (server, client) IPs or None if the address
doesn't appear to be a teredo address (doesn't start with
2001::/32) | pipenv/patched/notpip/_vendor/ipaddress.py | def teredo(self):
"""Tuple of embedded teredo IPs.
Returns:
Tuple of the (server, client) IPs or None if the address
doesn't appear to be a teredo address (doesn't start with
2001::/32)
"""
if (self._ip >> 96) != 0x20010000:
return None
... | def teredo(self):
"""Tuple of embedded teredo IPs.
Returns:
Tuple of the (server, client) IPs or None if the address
doesn't appear to be a teredo address (doesn't start with
2001::/32)
"""
if (self._ip >> 96) != 0x20010000:
return None
... | [
"Tuple",
"of",
"embedded",
"teredo",
"IPs",
"."
] | pypa/pipenv | python | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L2148-L2160 | [
"def",
"teredo",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_ip",
">>",
"96",
")",
"!=",
"0x20010000",
":",
"return",
"None",
"return",
"(",
"IPv4Address",
"(",
"(",
"self",
".",
"_ip",
">>",
"64",
")",
"&",
"0xFFFFFFFF",
")",
",",
"IPv4Addres... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.