repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_last | def do_last(environment, seq):
"""Return the last item of a sequence."""
try:
return next(iter(reversed(seq)))
except StopIteration:
return environment.undefined('No last item, sequence was empty.') | python | def do_last(environment, seq):
"""Return the last item of a sequence."""
try:
return next(iter(reversed(seq)))
except StopIteration:
return environment.undefined('No last item, sequence was empty.') | [
"def",
"do_last",
"(",
"environment",
",",
"seq",
")",
":",
"try",
":",
"return",
"next",
"(",
"iter",
"(",
"reversed",
"(",
"seq",
")",
")",
")",
"except",
"StopIteration",
":",
"return",
"environment",
".",
"undefined",
"(",
"'No last item, sequence was em... | Return the last item of a sequence. | [
"Return",
"the",
"last",
"item",
"of",
"a",
"sequence",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L442-L447 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_random | def do_random(context, seq):
"""Return a random item from the sequence."""
try:
return random.choice(seq)
except IndexError:
return context.environment.undefined('No random item, sequence was empty.') | python | def do_random(context, seq):
"""Return a random item from the sequence."""
try:
return random.choice(seq)
except IndexError:
return context.environment.undefined('No random item, sequence was empty.') | [
"def",
"do_random",
"(",
"context",
",",
"seq",
")",
":",
"try",
":",
"return",
"random",
".",
"choice",
"(",
"seq",
")",
"except",
"IndexError",
":",
"return",
"context",
".",
"environment",
".",
"undefined",
"(",
"'No random item, sequence was empty.'",
")"
... | Return a random item from the sequence. | [
"Return",
"a",
"random",
"item",
"from",
"the",
"sequence",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L451-L456 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_filesizeformat | def do_filesizeformat(value, binary=False):
"""Format the value like a 'human-readable' file size (i.e. 13 kB,
4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega,
Giga, etc.), if the second parameter is set to `True` the binary
prefixes are used (Mebi, Gibi).
"""
bytes = float... | python | def do_filesizeformat(value, binary=False):
"""Format the value like a 'human-readable' file size (i.e. 13 kB,
4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega,
Giga, etc.), if the second parameter is set to `True` the binary
prefixes are used (Mebi, Gibi).
"""
bytes = float... | [
"def",
"do_filesizeformat",
"(",
"value",
",",
"binary",
"=",
"False",
")",
":",
"bytes",
"=",
"float",
"(",
"value",
")",
"base",
"=",
"binary",
"and",
"1024",
"or",
"1000",
"prefixes",
"=",
"[",
"(",
"binary",
"and",
"'KiB'",
"or",
"'kB'",
")",
","... | Format the value like a 'human-readable' file size (i.e. 13 kB,
4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega,
Giga, etc.), if the second parameter is set to `True` the binary
prefixes are used (Mebi, Gibi). | [
"Format",
"the",
"value",
"like",
"a",
"human",
"-",
"readable",
"file",
"size",
"(",
"i",
".",
"e",
".",
"13",
"kB",
"4",
".",
"1",
"MB",
"102",
"Bytes",
"etc",
")",
".",
"Per",
"default",
"decimal",
"prefixes",
"are",
"used",
"(",
"Mega",
"Giga",... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L459-L486 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_urlize | def do_urlize(eval_ctx, value, trim_url_limit=None, nofollow=False,
target=None, rel=None):
"""Converts URLs in plain text into clickable links.
If you pass the filter an additional integer it will shorten the urls
to that number. Also a third argument exists that makes the urls
"nofollow... | python | def do_urlize(eval_ctx, value, trim_url_limit=None, nofollow=False,
target=None, rel=None):
"""Converts URLs in plain text into clickable links.
If you pass the filter an additional integer it will shorten the urls
to that number. Also a third argument exists that makes the urls
"nofollow... | [
"def",
"do_urlize",
"(",
"eval_ctx",
",",
"value",
",",
"trim_url_limit",
"=",
"None",
",",
"nofollow",
"=",
"False",
",",
"target",
"=",
"None",
",",
"rel",
"=",
"None",
")",
":",
"policies",
"=",
"eval_ctx",
".",
"environment",
".",
"policies",
"rel",
... | Converts URLs in plain text into clickable links.
If you pass the filter an additional integer it will shorten the urls
to that number. Also a third argument exists that makes the urls
"nofollow":
.. sourcecode:: jinja
{{ mytext|urlize(40, true) }}
links are shortened to 40 chars ... | [
"Converts",
"URLs",
"in",
"plain",
"text",
"into",
"clickable",
"links",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L499-L533 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_indent | def do_indent(
s, width=4, first=False, blank=False, indentfirst=None
):
"""Return a copy of the string with each line indented by 4 spaces. The
first line and blank lines are not indented by default.
:param width: Number of spaces to indent by.
:param first: Don't skip indenting the first line.
... | python | def do_indent(
s, width=4, first=False, blank=False, indentfirst=None
):
"""Return a copy of the string with each line indented by 4 spaces. The
first line and blank lines are not indented by default.
:param width: Number of spaces to indent by.
:param first: Don't skip indenting the first line.
... | [
"def",
"do_indent",
"(",
"s",
",",
"width",
"=",
"4",
",",
"first",
"=",
"False",
",",
"blank",
"=",
"False",
",",
"indentfirst",
"=",
"None",
")",
":",
"if",
"indentfirst",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"DeprecationWarning",
... | Return a copy of the string with each line indented by 4 spaces. The
first line and blank lines are not indented by default.
:param width: Number of spaces to indent by.
:param first: Don't skip indenting the first line.
:param blank: Don't skip indenting empty lines.
.. versionchanged:: 2.10
... | [
"Return",
"a",
"copy",
"of",
"the",
"string",
"with",
"each",
"line",
"indented",
"by",
"4",
"spaces",
".",
"The",
"first",
"line",
"and",
"blank",
"lines",
"are",
"not",
"indented",
"by",
"default",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L536-L574 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_truncate | def do_truncate(env, s, length=255, killwords=False, end='...', leeway=None):
"""Return a truncated copy of the string. The length is specified
with the first parameter which defaults to ``255``. If the second
parameter is ``true`` the filter will cut the text at length. Otherwise
it will discard the la... | python | def do_truncate(env, s, length=255, killwords=False, end='...', leeway=None):
"""Return a truncated copy of the string. The length is specified
with the first parameter which defaults to ``255``. If the second
parameter is ``true`` the filter will cut the text at length. Otherwise
it will discard the la... | [
"def",
"do_truncate",
"(",
"env",
",",
"s",
",",
"length",
"=",
"255",
",",
"killwords",
"=",
"False",
",",
"end",
"=",
"'...'",
",",
"leeway",
"=",
"None",
")",
":",
"if",
"leeway",
"is",
"None",
":",
"leeway",
"=",
"env",
".",
"policies",
"[",
... | Return a truncated copy of the string. The length is specified
with the first parameter which defaults to ``255``. If the second
parameter is ``true`` the filter will cut the text at length. Otherwise
it will discard the last word. If the text was in fact
truncated it will append an ellipsis sign (``"..... | [
"Return",
"a",
"truncated",
"copy",
"of",
"the",
"string",
".",
"The",
"length",
"is",
"specified",
"with",
"the",
"first",
"parameter",
"which",
"defaults",
"to",
"255",
".",
"If",
"the",
"second",
"parameter",
"is",
"true",
"the",
"filter",
"will",
"cut"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L578-L611 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_wordwrap | def do_wordwrap(environment, s, width=79, break_long_words=True,
wrapstring=None):
"""
Return a copy of the string passed to the filter wrapped after
``79`` characters. You can override this default using the first
parameter. If you set the second parameter to `false` Jinja will not
... | python | def do_wordwrap(environment, s, width=79, break_long_words=True,
wrapstring=None):
"""
Return a copy of the string passed to the filter wrapped after
``79`` characters. You can override this default using the first
parameter. If you set the second parameter to `false` Jinja will not
... | [
"def",
"do_wordwrap",
"(",
"environment",
",",
"s",
",",
"width",
"=",
"79",
",",
"break_long_words",
"=",
"True",
",",
"wrapstring",
"=",
"None",
")",
":",
"if",
"not",
"wrapstring",
":",
"wrapstring",
"=",
"environment",
".",
"newline_sequence",
"import",
... | Return a copy of the string passed to the filter wrapped after
``79`` characters. You can override this default using the first
parameter. If you set the second parameter to `false` Jinja will not
split words apart if they are longer than `width`. By default, the newlines
will be the default newlines ... | [
"Return",
"a",
"copy",
"of",
"the",
"string",
"passed",
"to",
"the",
"filter",
"wrapped",
"after",
"79",
"characters",
".",
"You",
"can",
"override",
"this",
"default",
"using",
"the",
"first",
"parameter",
".",
"If",
"you",
"set",
"the",
"second",
"parame... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L615-L633 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_int | def do_int(value, default=0, base=10):
"""Convert the value into an integer. If the
conversion doesn't work it will return ``0``. You can
override this default using the first parameter. You
can also override the default base (10) in the second
parameter, which handles input with prefixes such as
... | python | def do_int(value, default=0, base=10):
"""Convert the value into an integer. If the
conversion doesn't work it will return ``0``. You can
override this default using the first parameter. You
can also override the default base (10) in the second
parameter, which handles input with prefixes such as
... | [
"def",
"do_int",
"(",
"value",
",",
"default",
"=",
"0",
",",
"base",
"=",
"10",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"return",
"int",
"(",
"value",
",",
"base",
")",
"return",
"int",
"(",
"value",
... | Convert the value into an integer. If the
conversion doesn't work it will return ``0``. You can
override this default using the first parameter. You
can also override the default base (10) in the second
parameter, which handles input with prefixes such as
0b, 0o and 0x for bases 2, 8 and 16 respecti... | [
"Convert",
"the",
"value",
"into",
"an",
"integer",
".",
"If",
"the",
"conversion",
"doesn",
"t",
"work",
"it",
"will",
"return",
"0",
".",
"You",
"can",
"override",
"this",
"default",
"using",
"the",
"first",
"parameter",
".",
"You",
"can",
"also",
"ove... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L641-L659 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_format | def do_format(value, *args, **kwargs):
"""
Apply python string formatting on an object:
.. sourcecode:: jinja
{{ "%s - %s"|format("Hello?", "Foo!") }}
-> Hello? - Foo!
"""
if args and kwargs:
raise FilterArgumentError('can\'t handle positional and keyword '
... | python | def do_format(value, *args, **kwargs):
"""
Apply python string formatting on an object:
.. sourcecode:: jinja
{{ "%s - %s"|format("Hello?", "Foo!") }}
-> Hello? - Foo!
"""
if args and kwargs:
raise FilterArgumentError('can\'t handle positional and keyword '
... | [
"def",
"do_format",
"(",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"and",
"kwargs",
":",
"raise",
"FilterArgumentError",
"(",
"'can\\'t handle positional and keyword '",
"'arguments at the same time'",
")",
"return",
"soft_unicode",... | Apply python string formatting on an object:
.. sourcecode:: jinja
{{ "%s - %s"|format("Hello?", "Foo!") }}
-> Hello? - Foo! | [
"Apply",
"python",
"string",
"formatting",
"on",
"an",
"object",
":"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L673-L685 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_striptags | def do_striptags(value):
"""Strip SGML/XML tags and replace adjacent whitespace by one space.
"""
if hasattr(value, '__html__'):
value = value.__html__()
return Markup(text_type(value)).striptags() | python | def do_striptags(value):
"""Strip SGML/XML tags and replace adjacent whitespace by one space.
"""
if hasattr(value, '__html__'):
value = value.__html__()
return Markup(text_type(value)).striptags() | [
"def",
"do_striptags",
"(",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'__html__'",
")",
":",
"value",
"=",
"value",
".",
"__html__",
"(",
")",
"return",
"Markup",
"(",
"text_type",
"(",
"value",
")",
")",
".",
"striptags",
"(",
")"
] | Strip SGML/XML tags and replace adjacent whitespace by one space. | [
"Strip",
"SGML",
"/",
"XML",
"tags",
"and",
"replace",
"adjacent",
"whitespace",
"by",
"one",
"space",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L693-L698 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_slice | def do_slice(value, slices, fill_with=None):
"""Slice an iterator and return a list of lists containing
those items. Useful if you want to create a div containing
three ul tags that represent columns:
.. sourcecode:: html+jinja
<div class="columwrapper">
{%- for column in items|slice... | python | def do_slice(value, slices, fill_with=None):
"""Slice an iterator and return a list of lists containing
those items. Useful if you want to create a div containing
three ul tags that represent columns:
.. sourcecode:: html+jinja
<div class="columwrapper">
{%- for column in items|slice... | [
"def",
"do_slice",
"(",
"value",
",",
"slices",
",",
"fill_with",
"=",
"None",
")",
":",
"seq",
"=",
"list",
"(",
"value",
")",
"length",
"=",
"len",
"(",
"seq",
")",
"items_per_slice",
"=",
"length",
"//",
"slices",
"slices_with_extra",
"=",
"length",
... | Slice an iterator and return a list of lists containing
those items. Useful if you want to create a div containing
three ul tags that represent columns:
.. sourcecode:: html+jinja
<div class="columwrapper">
{%- for column in items|slice(3) %}
<ul class="column-{{ loop.index }... | [
"Slice",
"an",
"iterator",
"and",
"return",
"a",
"list",
"of",
"lists",
"containing",
"those",
"items",
".",
"Useful",
"if",
"you",
"want",
"to",
"create",
"a",
"div",
"containing",
"three",
"ul",
"tags",
"that",
"represent",
"columns",
":"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L701-L734 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_batch | def do_batch(value, linecount, fill_with=None):
"""
A filter that batches items. It works pretty much like `slice`
just the other way round. It returns a list of lists with the
given number of items. If you provide a second parameter this
is used to fill up missing items. See this example:
.. s... | python | def do_batch(value, linecount, fill_with=None):
"""
A filter that batches items. It works pretty much like `slice`
just the other way round. It returns a list of lists with the
given number of items. If you provide a second parameter this
is used to fill up missing items. See this example:
.. s... | [
"def",
"do_batch",
"(",
"value",
",",
"linecount",
",",
"fill_with",
"=",
"None",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"item",
"in",
"value",
":",
"if",
"len",
"(",
"tmp",
")",
"==",
"linecount",
":",
"yield",
"tmp",
"tmp",
"=",
"[",
"]",
"tmp"... | A filter that batches items. It works pretty much like `slice`
just the other way round. It returns a list of lists with the
given number of items. If you provide a second parameter this
is used to fill up missing items. See this example:
.. sourcecode:: html+jinja
<table>
{%- for row ... | [
"A",
"filter",
"that",
"batches",
"items",
".",
"It",
"works",
"pretty",
"much",
"like",
"slice",
"just",
"the",
"other",
"way",
"round",
".",
"It",
"returns",
"a",
"list",
"of",
"lists",
"with",
"the",
"given",
"number",
"of",
"items",
".",
"If",
"you... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L737-L765 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_round | def do_round(value, precision=0, method='common'):
"""Round the number to a given precision. The first
parameter specifies the precision (default is ``0``), the
second the rounding method:
- ``'common'`` rounds either up or down
- ``'ceil'`` always rounds up
- ``'floor'`` always rounds down
... | python | def do_round(value, precision=0, method='common'):
"""Round the number to a given precision. The first
parameter specifies the precision (default is ``0``), the
second the rounding method:
- ``'common'`` rounds either up or down
- ``'ceil'`` always rounds up
- ``'floor'`` always rounds down
... | [
"def",
"do_round",
"(",
"value",
",",
"precision",
"=",
"0",
",",
"method",
"=",
"'common'",
")",
":",
"if",
"not",
"method",
"in",
"(",
"'common'",
",",
"'ceil'",
",",
"'floor'",
")",
":",
"raise",
"FilterArgumentError",
"(",
"'method must be common, ceil o... | Round the number to a given precision. The first
parameter specifies the precision (default is ``0``), the
second the rounding method:
- ``'common'`` rounds either up or down
- ``'ceil'`` always rounds up
- ``'floor'`` always rounds down
If you don't specify a method ``'common'`` is used.
... | [
"Round",
"the",
"number",
"to",
"a",
"given",
"precision",
".",
"The",
"first",
"parameter",
"specifies",
"the",
"precision",
"(",
"default",
"is",
"0",
")",
"the",
"second",
"the",
"rounding",
"method",
":"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L768-L799 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_groupby | def do_groupby(environment, value, attribute):
"""Group a sequence of objects by a common attribute.
If you for example have a list of dicts or objects that represent persons
with `gender`, `first_name` and `last_name` attributes and you want to
group all users by genders you can do something like the ... | python | def do_groupby(environment, value, attribute):
"""Group a sequence of objects by a common attribute.
If you for example have a list of dicts or objects that represent persons
with `gender`, `first_name` and `last_name` attributes and you want to
group all users by genders you can do something like the ... | [
"def",
"do_groupby",
"(",
"environment",
",",
"value",
",",
"attribute",
")",
":",
"expr",
"=",
"make_attrgetter",
"(",
"environment",
",",
"attribute",
")",
"return",
"[",
"_GroupTuple",
"(",
"key",
",",
"list",
"(",
"values",
")",
")",
"for",
"key",
",... | Group a sequence of objects by a common attribute.
If you for example have a list of dicts or objects that represent persons
with `gender`, `first_name` and `last_name` attributes and you want to
group all users by genders you can do something like the following
snippet:
.. sourcecode:: html+jinja... | [
"Group",
"a",
"sequence",
"of",
"objects",
"by",
"a",
"common",
"attribute",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L812-L852 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_sum | def do_sum(environment, iterable, attribute=None, start=0):
"""Returns the sum of a sequence of numbers plus the value of parameter
'start' (which defaults to 0). When the sequence is empty it returns
start.
It is also possible to sum up only certain attributes:
.. sourcecode:: jinja
Tot... | python | def do_sum(environment, iterable, attribute=None, start=0):
"""Returns the sum of a sequence of numbers plus the value of parameter
'start' (which defaults to 0). When the sequence is empty it returns
start.
It is also possible to sum up only certain attributes:
.. sourcecode:: jinja
Tot... | [
"def",
"do_sum",
"(",
"environment",
",",
"iterable",
",",
"attribute",
"=",
"None",
",",
"start",
"=",
"0",
")",
":",
"if",
"attribute",
"is",
"not",
"None",
":",
"iterable",
"=",
"imap",
"(",
"make_attrgetter",
"(",
"environment",
",",
"attribute",
")"... | Returns the sum of a sequence of numbers plus the value of parameter
'start' (which defaults to 0). When the sequence is empty it returns
start.
It is also possible to sum up only certain attributes:
.. sourcecode:: jinja
Total: {{ items|sum(attribute='price') }}
.. versionchanged:: 2.6... | [
"Returns",
"the",
"sum",
"of",
"a",
"sequence",
"of",
"numbers",
"plus",
"the",
"value",
"of",
"parameter",
"start",
"(",
"which",
"defaults",
"to",
"0",
")",
".",
"When",
"the",
"sequence",
"is",
"empty",
"it",
"returns",
"start",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L856-L873 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_reverse | def do_reverse(value):
"""Reverse the object or return an iterator that iterates over it the other
way round.
"""
if isinstance(value, string_types):
return value[::-1]
try:
return reversed(value)
except TypeError:
try:
rv = list(value)
rv.reverse(... | python | def do_reverse(value):
"""Reverse the object or return an iterator that iterates over it the other
way round.
"""
if isinstance(value, string_types):
return value[::-1]
try:
return reversed(value)
except TypeError:
try:
rv = list(value)
rv.reverse(... | [
"def",
"do_reverse",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"return",
"value",
"[",
":",
":",
"-",
"1",
"]",
"try",
":",
"return",
"reversed",
"(",
"value",
")",
"except",
"TypeError",
":",
"try",
":"... | Reverse the object or return an iterator that iterates over it the other
way round. | [
"Reverse",
"the",
"object",
"or",
"return",
"an",
"iterator",
"that",
"iterates",
"over",
"it",
"the",
"other",
"way",
"round",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L895-L909 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_attr | def do_attr(environment, obj, name):
"""Get an attribute of an object. ``foo|attr("bar")`` works like
``foo.bar`` just that always an attribute is returned and items are not
looked up.
See :ref:`Notes on subscriptions <notes-on-subscriptions>` for more details.
"""
try:
name = str(name... | python | def do_attr(environment, obj, name):
"""Get an attribute of an object. ``foo|attr("bar")`` works like
``foo.bar`` just that always an attribute is returned and items are not
looked up.
See :ref:`Notes on subscriptions <notes-on-subscriptions>` for more details.
"""
try:
name = str(name... | [
"def",
"do_attr",
"(",
"environment",
",",
"obj",
",",
"name",
")",
":",
"try",
":",
"name",
"=",
"str",
"(",
"name",
")",
"except",
"UnicodeError",
":",
"pass",
"else",
":",
"try",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"name",
")",
"excep... | Get an attribute of an object. ``foo|attr("bar")`` works like
``foo.bar`` just that always an attribute is returned and items are not
looked up.
See :ref:`Notes on subscriptions <notes-on-subscriptions>` for more details. | [
"Get",
"an",
"attribute",
"of",
"an",
"object",
".",
"foo|attr",
"(",
"bar",
")",
"works",
"like",
"foo",
".",
"bar",
"just",
"that",
"always",
"an",
"attribute",
"is",
"returned",
"and",
"items",
"are",
"not",
"looked",
"up",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L913-L934 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_map | def do_map(*args, **kwargs):
"""Applies a filter on a sequence of objects or looks up an attribute.
This is useful when dealing with lists of objects but you are really
only interested in a certain value of it.
The basic usage is mapping on an attribute. Imagine you have a list
of users but you ar... | python | def do_map(*args, **kwargs):
"""Applies a filter on a sequence of objects or looks up an attribute.
This is useful when dealing with lists of objects but you are really
only interested in a certain value of it.
The basic usage is mapping on an attribute. Imagine you have a list
of users but you ar... | [
"def",
"do_map",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"seq",
",",
"func",
"=",
"prepare_map",
"(",
"args",
",",
"kwargs",
")",
"if",
"seq",
":",
"for",
"item",
"in",
"seq",
":",
"yield",
"func",
"(",
"item",
")"
] | Applies a filter on a sequence of objects or looks up an attribute.
This is useful when dealing with lists of objects but you are really
only interested in a certain value of it.
The basic usage is mapping on an attribute. Imagine you have a list
of users but you are only interested in a list of usern... | [
"Applies",
"a",
"filter",
"on",
"a",
"sequence",
"of",
"objects",
"or",
"looks",
"up",
"an",
"attribute",
".",
"This",
"is",
"useful",
"when",
"dealing",
"with",
"lists",
"of",
"objects",
"but",
"you",
"are",
"really",
"only",
"interested",
"in",
"a",
"c... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L938-L963 | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | do_tojson | def do_tojson(eval_ctx, value, indent=None):
"""Dumps a structure to JSON so that it's safe to use in ``<script>``
tags. It accepts the same arguments and returns a JSON string. Note that
this is available in templates through the ``|tojson`` filter which will
also mark the result as safe. Due to how... | python | def do_tojson(eval_ctx, value, indent=None):
"""Dumps a structure to JSON so that it's safe to use in ``<script>``
tags. It accepts the same arguments and returns a JSON string. Note that
this is available in templates through the ``|tojson`` filter which will
also mark the result as safe. Due to how... | [
"def",
"do_tojson",
"(",
"eval_ctx",
",",
"value",
",",
"indent",
"=",
"None",
")",
":",
"policies",
"=",
"eval_ctx",
".",
"environment",
".",
"policies",
"dumper",
"=",
"policies",
"[",
"'json.dumps_function'",
"]",
"options",
"=",
"policies",
"[",
"'json.d... | Dumps a structure to JSON so that it's safe to use in ``<script>``
tags. It accepts the same arguments and returns a JSON string. Note that
this is available in templates through the ``|tojson`` filter which will
also mark the result as safe. Due to how this function escapes certain
characters this i... | [
"Dumps",
"a",
"structure",
"to",
"JSON",
"so",
"that",
"it",
"s",
"safe",
"to",
"use",
"in",
"<script",
">",
"tags",
".",
"It",
"accepts",
"the",
"same",
"arguments",
"and",
"returns",
"a",
"JSON",
"string",
".",
"Note",
"that",
"this",
"is",
"availabl... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L1047-L1078 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/autocompletion.py | autocomplete | def autocomplete():
"""Entry Point for completion of main and subcommand options.
"""
# Don't complete if user hasn't sourced bash_completion file.
if 'PIP_AUTO_COMPLETE' not in os.environ:
return
cwords = os.environ['COMP_WORDS'].split()[1:]
cword = int(os.environ['COMP_CWORD'])
try... | python | def autocomplete():
"""Entry Point for completion of main and subcommand options.
"""
# Don't complete if user hasn't sourced bash_completion file.
if 'PIP_AUTO_COMPLETE' not in os.environ:
return
cwords = os.environ['COMP_WORDS'].split()[1:]
cword = int(os.environ['COMP_CWORD'])
try... | [
"def",
"autocomplete",
"(",
")",
":",
"# Don't complete if user hasn't sourced bash_completion file.",
"if",
"'PIP_AUTO_COMPLETE'",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"cwords",
"=",
"os",
".",
"environ",
"[",
"'COMP_WORDS'",
"]",
".",
"split",
"(",
... | Entry Point for completion of main and subcommand options. | [
"Entry",
"Point",
"for",
"completion",
"of",
"main",
"and",
"subcommand",
"options",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/autocompletion.py#L13-L101 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/autocompletion.py | get_path_completion_type | def get_path_completion_type(cwords, cword, opts):
"""Get the type of path completion (``file``, ``dir``, ``path`` or None)
:param cwords: same as the environmental variable ``COMP_WORDS``
:param cword: same as the environmental variable ``COMP_CWORD``
:param opts: The available options to check
:r... | python | def get_path_completion_type(cwords, cword, opts):
"""Get the type of path completion (``file``, ``dir``, ``path`` or None)
:param cwords: same as the environmental variable ``COMP_WORDS``
:param cword: same as the environmental variable ``COMP_CWORD``
:param opts: The available options to check
:r... | [
"def",
"get_path_completion_type",
"(",
"cwords",
",",
"cword",
",",
"opts",
")",
":",
"if",
"cword",
"<",
"2",
"or",
"not",
"cwords",
"[",
"cword",
"-",
"2",
"]",
".",
"startswith",
"(",
"'-'",
")",
":",
"return",
"for",
"opt",
"in",
"opts",
":",
... | Get the type of path completion (``file``, ``dir``, ``path`` or None)
:param cwords: same as the environmental variable ``COMP_WORDS``
:param cword: same as the environmental variable ``COMP_CWORD``
:param opts: The available options to check
:return: path completion type (``file``, ``dir``, ``path`` o... | [
"Get",
"the",
"type",
"of",
"path",
"completion",
"(",
"file",
"dir",
"path",
"or",
"None",
")"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/autocompletion.py#L104-L122 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/autocompletion.py | auto_complete_paths | def auto_complete_paths(current, completion_type):
"""If ``completion_type`` is ``file`` or ``path``, list all regular files
and directories starting with ``current``; otherwise only list directories
starting with ``current``.
:param current: The word to be completed
:param completion_type: path co... | python | def auto_complete_paths(current, completion_type):
"""If ``completion_type`` is ``file`` or ``path``, list all regular files
and directories starting with ``current``; otherwise only list directories
starting with ``current``.
:param current: The word to be completed
:param completion_type: path co... | [
"def",
"auto_complete_paths",
"(",
"current",
",",
"completion_type",
")",
":",
"directory",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"current",
")",
"current_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"directory",
")",
"# Don't... | If ``completion_type`` is ``file`` or ``path``, list all regular files
and directories starting with ``current``; otherwise only list directories
starting with ``current``.
:param current: The word to be completed
:param completion_type: path completion type(`file`, `path` or `dir`)i
:return: A gen... | [
"If",
"completion_type",
"is",
"file",
"or",
"path",
"list",
"all",
"regular",
"files",
"and",
"directories",
"starting",
"with",
"current",
";",
"otherwise",
"only",
"list",
"directories",
"starting",
"with",
"current",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/autocompletion.py#L125-L152 | train |
pypa/pipenv | pipenv/vendor/passa/internals/_pip_shims.py | _build_wheel_modern | def _build_wheel_modern(ireq, output_dir, finder, wheel_cache, kwargs):
"""Build a wheel.
* ireq: The InstallRequirement object to build
* output_dir: The directory to build the wheel in.
* finder: pip's internal Finder object to find the source out of ireq.
* kwargs: Various keyword arguments from... | python | def _build_wheel_modern(ireq, output_dir, finder, wheel_cache, kwargs):
"""Build a wheel.
* ireq: The InstallRequirement object to build
* output_dir: The directory to build the wheel in.
* finder: pip's internal Finder object to find the source out of ireq.
* kwargs: Various keyword arguments from... | [
"def",
"_build_wheel_modern",
"(",
"ireq",
",",
"output_dir",
",",
"finder",
",",
"wheel_cache",
",",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"\"progress_bar\"",
":",
"\"off\"",
",",
"\"build_isolation\"",
":",
"False",
"}",
")",
"with",
"pip_... | Build a wheel.
* ireq: The InstallRequirement object to build
* output_dir: The directory to build the wheel in.
* finder: pip's internal Finder object to find the source out of ireq.
* kwargs: Various keyword arguments from `_prepare_wheel_building_kwargs`. | [
"Build",
"a",
"wheel",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/_pip_shims.py#L24-L38 | train |
pypa/pipenv | pipenv/vendor/pythonfinder/utils.py | get_python_version | def get_python_version(path):
# type: (str) -> str
"""Get python version string using subprocess from a given path."""
version_cmd = [path, "-c", "import sys; print(sys.version.split()[0])"]
try:
c = vistir.misc.run(
version_cmd,
block=True,
nospin=True,
... | python | def get_python_version(path):
# type: (str) -> str
"""Get python version string using subprocess from a given path."""
version_cmd = [path, "-c", "import sys; print(sys.version.split()[0])"]
try:
c = vistir.misc.run(
version_cmd,
block=True,
nospin=True,
... | [
"def",
"get_python_version",
"(",
"path",
")",
":",
"# type: (str) -> str",
"version_cmd",
"=",
"[",
"path",
",",
"\"-c\"",
",",
"\"import sys; print(sys.version.split()[0])\"",
"]",
"try",
":",
"c",
"=",
"vistir",
".",
"misc",
".",
"run",
"(",
"version_cmd",
",... | Get python version string using subprocess from a given path. | [
"Get",
"python",
"version",
"string",
"using",
"subprocess",
"from",
"a",
"given",
"path",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L87-L104 | train |
pypa/pipenv | pipenv/vendor/pythonfinder/utils.py | path_is_known_executable | 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... | python | 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",
"return",
"(",
"path_is_executable",
"(",
"path",
")",
"or",
"os",
".",
"access",
"(",
"str",
"(",
"path",
")",
",",
"os",
".",
"R_OK",
")",
"and",
"path",
".",... | 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... | [
"Returns",
"whether",
"a",
"given",
"path",
"is",
"a",
"known",
"executable",
"from",
"known",
"executable",
"extensions",
"or",
"has",
"the",
"executable",
"bit",
"toggled",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L181-L197 | train |
pypa/pipenv | pipenv/vendor/pythonfinder/utils.py | looks_like_python | 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... | python | 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",
"if",
"not",
"any",
"(",
"name",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"py_name",
")",
"for",
"py_name",
"in",
"PYTHON_IMPLEMENTATIONS",
")",
":",
"return",
"False",
"match... | 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 | [
"Determine",
"whether",
"the",
"supplied",
"filename",
"looks",
"like",
"a",
"possible",
"name",
"of",
"python",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L201-L216 | train |
pypa/pipenv | pipenv/vendor/pythonfinder/utils.py | ensure_path | 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... | python | 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",
"if",
"isinstance",
"(",
"path",
",",
"vistir",
".",
"compat",
".",
"Path",
")",
":",
"return",
"path",
"path",
"=",
"vistir",
".",
"compat",
".",
"Pat... | 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` | [
"Given",
"a",
"path",
"(",
"either",
"a",
"string",
"or",
"a",
"Path",
"object",
")",
"expand",
"variables",
"and",
"return",
"a",
"Path",
"object",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L235-L249 | train |
pypa/pipenv | pipenv/vendor/pythonfinder/utils.py | filter_pythons | 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... | python | 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",
"if",
"not",
"isinstance",
"(",
"path",
",",
"vistir",
".",
"compat",
".",
"Path",
")",
":",
"path",
"=",
"vistir",
".",
"compat",
".",
"Path",
"(",
"str",
... | Return all valid pythons in a given path | [
"Return",
"all",
"valid",
"pythons",
"in",
"a",
"given",
"path"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L270-L277 | train |
pypa/pipenv | pipenv/vendor/pythonfinder/utils.py | expand_paths | 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... | python | 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",
"if",
"path",
"is",
"not",
"None",
"and",
"(",
"isinstance",
"(",
"path",
",",
"Sequence",
")",
"and",
"not",
"getattr",
"(",... | 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
... | [
"Recursively",
"expand",
"a",
"list",
"or",
":",
"class",
":",
"~pythonfinder",
".",
"models",
".",
"path",
".",
"PathEntry",
"instance"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pythonfinder/utils.py#L334-L365 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cache.py | Cache._get_cache_path_parts | 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
... | python | 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]",
"# 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... | Get parts of part that must be os.path.joined with cache_dir | [
"Get",
"parts",
"of",
"part",
"that",
"must",
"be",
"os",
".",
"path",
".",
"joined",
"with",
"cache_dir"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cache.py#L46-L70 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/cache.py | SimpleWheelCache.get_path_for_link | 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... | python | 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",
"parts",
"=",
"self",
".",
"_get_cache_path_parts",
"(",
"link",
")",
"# Store wheels within the root cache_dir",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
... | 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 ... | [
"Return",
"a",
"directory",
"to",
"store",
"cached",
"wheels",
"for",
"link"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cache.py#L132-L151 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/models/link.py | Link.is_artifact | 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_... | python | 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",
"from",
"pipenv",
".",
"patched",
".",
"notpip",
".",
"_internal",
".",
"vcs",
"import",
"vcs",
"if",
"self",
".",
"scheme",
"in",
"vcs",
".",
"all_schemes",
":",
"return",
"False",
"return... | 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. | [
"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",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/models/link.py#L152-L163 | train |
pypa/pipenv | pipenv/vendor/passa/internals/dependencies.py | _get_dependencies_from_cache | 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]
... | python | 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",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"PASSA_IGNORE_LOCAL_CACHE\"",
")",
":",
"return",
"if",
"ireq",
".",
"editable",
":",
"return",
"try",
":",
"deps",
"=",
"DEPENDENCY_CACHE",
"[",
"ir... | Retrieves dependencies for the requirement from the dependency cache. | [
"Retrieves",
"dependencies",
"for",
"the",
"requirement",
"from",
"the",
"dependency",
"cache",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L49-L80 | train |
pypa/pipenv | pipenv/vendor/passa/internals/dependencies.py | _get_dependencies_from_json | 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... | python | 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",
")",
":",
"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... | 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 | [
"Retrieves",
"dependencies",
"for",
"the",
"install",
"requirement",
"from",
"the",
"JSON",
"API",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L113-L158 | train |
pypa/pipenv | pipenv/vendor/passa/internals/dependencies.py | _read_requirements | 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... | python | 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",
")",
":",
"extras",
"=",
"extras",
"or",
"(",
")",
"requirements",
"=",
"[",
"]",
"for",
"entry",
"in",
"metadata",
".",
"run_requires",
":",
"if",
"isinstance",
"(",
"entry",
",",
"six",
".",
... | 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)... | [
"Read",
"wheel",
"metadata",
"to",
"know",
"what",
"it",
"depends",
"on",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L161-L194 | train |
pypa/pipenv | pipenv/vendor/passa/internals/dependencies.py | _read_requires_python | 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... | python | 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",
")",
":",
"# TODO: Support more metadata formats.",
"value",
"=",
"metadata",
".",
"dictionary",
".",
"get",
"(",
"\"requires_python\"",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"if",
"metada... | 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... | [
"Read",
"wheel",
"metadata",
"to",
"know",
"the",
"value",
"of",
"Requires",
"-",
"Python",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L197-L215 | train |
pypa/pipenv | pipenv/vendor/passa/internals/dependencies.py | _get_dependencies_from_pip | 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.... | python | 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",
")",
":",
"extras",
"=",
"ireq",
".",
"extras",
"or",
"(",
")",
"try",
":",
"wheel",
"=",
"build_wheel",
"(",
"ireq",
",",
"sources",
")",
"except",
"WheelBuildError",
":",
"# XXX: This depend... | 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 ... | [
"Retrieves",
"dependencies",
"for",
"the",
"requirement",
"from",
"pipenv",
".",
"patched",
".",
"notpip",
"internals",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L218-L242 | train |
pypa/pipenv | pipenv/vendor/passa/internals/dependencies.py | get_dependencies | 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... | python | 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",
")",
":",
"getters",
"=",
"[",
"_get_dependencies_from_cache",
",",
"_cached",
"(",
"_get_dependencies_from_json",
",",
"sources",
"=",
"sources",
")",
",",
"_cached",
"(",
"_get_dependencies_from_pip",
... | Get all dependencies for a given install requirement.
:param requirement: A requirement
:param sources: Pipfile-formatted sources
:type sources: list[dict] | [
"Get",
"all",
"dependencies",
"for",
"a",
"given",
"install",
"requirement",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/dependencies.py#L245-L273 | train |
pypa/pipenv | pipenv/vendor/urllib3/fields.py | format_header_param | 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... | python | 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",
")",
":",
"if",
"not",
"any",
"(",
"ch",
"in",
"value",
"for",
"ch",
"in",
"'\"\\\\\\r\\n'",
")",
":",
"result",
"=",
"'%s=\"%s\"'",
"%",
"(",
"name",
",",
"value",
")",
"try",
":",
"result",
"... | 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... | [
"Helper",
"function",
"to",
"format",
"and",
"quote",
"a",
"single",
"header",
"parameter",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L22-L47 | train |
pypa/pipenv | pipenv/vendor/urllib3/fields.py | RequestField.from_tuples | 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 ... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"if",
"len",
"(",
"value",
")",
"==",
"3",
":",
"filename",
",",
"data",
",",
"content_type",
"=",
"value",
"else",
... | 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... | [
"A",
":",
"class",
":",
"~urllib3",
".",
"fields",
".",
"RequestField",
"factory",
"from",
"old",
"-",
"style",
"tuple",
"parameters",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L72-L103 | train |
pypa/pipenv | pipenv/vendor/urllib3/fields.py | RequestField._render_parts | 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 ... | python | 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",
")",
":",
"parts",
"=",
"[",
"]",
"iterable",
"=",
"header_parts",
"if",
"isinstance",
"(",
"header_parts",
",",
"dict",
")",
":",
"iterable",
"=",
"header_parts",
".",
"items",
"(",
")",
"for",
"... | 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"; ...`. | [
"Helper",
"function",
"to",
"format",
"and",
"quote",
"a",
"single",
"header",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L116-L136 | train |
pypa/pipenv | pipenv/vendor/urllib3/fields.py | RequestField.render_headers | 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:... | python | 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",
")",
":",
"lines",
"=",
"[",
"]",
"sort_keys",
"=",
"[",
"'Content-Disposition'",
",",
"'Content-Type'",
",",
"'Content-Location'",
"]",
"for",
"sort_key",
"in",
"sort_keys",
":",
"if",
"self",
".",
"headers",
".",
"get"... | Renders the headers for this request field. | [
"Renders",
"the",
"headers",
"for",
"this",
"request",
"field",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L138-L155 | train |
pypa/pipenv | pipenv/vendor/urllib3/fields.py | RequestField.make_multipart | 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... | python | 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",
")",
":",
"self",
".",
"headers",
"[",
"'Content-Disposition'",
"]",
"=",
"content_disposition",
"or",
"'form-d... | 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... | [
"Makes",
"this",
"request",
"field",
"into",
"a",
"multipart",
"request",
"field",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/fields.py#L157-L178 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py | TreeWalker.emptyTag | 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... | python | 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",
")",
":",
"yield",
"{",
"\"type\"",
":",
"\"EmptyTag\"",
",",
"\"name\"",
":",
"name",
",",
"\"namespace\"",
":",
"namespace",
",",
"\"data\"",
... | 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... | [
"Generates",
"an",
"EmptyTag",
"token"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py#L48-L67 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py | TreeWalker.text | 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... | python | 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",
")",
":",
"data",
"=",
"data",
"middle",
"=",
"data",
".",
"lstrip",
"(",
"spaceCharacters",
")",
"left",
"=",
"data",
"[",
":",
"len",
"(",
"data",
")",
"-",
"len",
"(",
"middle",
")",
"]",
"if",
"left",
... | 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... | [
"Generates",
"SpaceCharacters",
"and",
"Characters",
"tokens"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/treewalkers/base.py#L100-L136 | train |
pypa/pipenv | pipenv/shells.py | _get_activate_script | 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:
... | python | 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",
")",
":",
"# Suffix and source command for other shells.",
"# Support for fish shell.",
"if",
"\"fish\"",
"in",
"cmd",
":",
"suffix",
"=",
"\".fish\"",
"command",
"=",
"\"source\"",
"# Support for csh shell.",
"elif"... | 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. | [
"Returns",
"the",
"string",
"to",
"activate",
"a",
"virtualenv",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/shells.py#L32-L54 | train |
pypa/pipenv | pipenv/vendor/distlib/wheel.py | Wheel.filename | 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... | python | 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",
")",
":",
"if",
"self",
".",
"buildver",
":",
"buildver",
"=",
"'-'",
"+",
"self",
".",
"buildver",
"else",
":",
"buildver",
"=",
"''",
"pyver",
"=",
"'.'",
".",
"join",
"(",
"self",
".",
"pyver",
")",
"abi",
"=",
... | Build and return a filename from the various components. | [
"Build",
"and",
"return",
"a",
"filename",
"from",
"the",
"various",
"components",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L186-L200 | train |
pypa/pipenv | pipenv/vendor/distlib/wheel.py | Wheel.build | 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... | python | 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",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"{",
"}",
"libkey",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"o",
":",
"o",
"in",
... | Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel. | [
"Build",
"a",
"wheel",
"from",
"files",
"in",
"specified",
"paths",
"and",
"use",
"any",
"specified",
"tags",
"when",
"determining",
"the",
"name",
"of",
"the",
"wheel",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L332-L434 | train |
pypa/pipenv | pipenv/vendor/distlib/wheel.py | Wheel.install | 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... | python | 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",
")",
":",
"dry_run",
"=",
"maker",
".",
"dry_run",
"warner",
"=",
"kwargs",
".",
"get",
"(",
"'warner'",
")",
"lib_only",
"=",
"kwargs",
".",
"get",
"(",
"'lib_only'"... | 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... | [
"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... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L436-L666 | train |
pypa/pipenv | pipenv/vendor/distlib/wheel.py | Wheel.update | 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... | python | 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",
")",
":",
"def",
"get_version",
"(",
"path_map",
",",
"info_dir",
")",
":",
"version",
"=",
"path",
"=",
"None",
"key",
"=",
"'%s/%s'",
"%",
"(",
... | 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... | [
"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",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/wheel.py#L810-L909 | train |
pypa/pipenv | pipenv/core.py | load_dot_env | 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... | python | 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",
"(",
")",
":",
"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",
"="... | Loads .env file into sys.environ. | [
"Loads",
".",
"env",
"file",
"into",
"sys",
".",
"environ",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L131-L156 | train |
pypa/pipenv | pipenv/core.py | add_to_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"]) | python | 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",
")",
":",
"if",
"p",
"not",
"in",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
":",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
"=",
"\"{0}{1}{2}\"",
".",
"format",
"(",
"p",
",",
"os",
".",
"pathsep",
",",
"os",
".... | Adds a given path to the PATH. | [
"Adds",
"a",
"given",
"path",
"to",
"the",
"PATH",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L159-L162 | train |
pypa/pipenv | pipenv/core.py | cleanup_virtualenv | 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(
... | python | 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",
")",
":",
"if",
"not",
"bare",
":",
"click",
".",
"echo",
"(",
"crayons",
".",
"red",
"(",
"\"Environment creation aborted.\"",
")",
")",
"try",
":",
"# Delete the virtualenv.",
"vistir",
".",
"path",
".... | Removes the virtualenv directory from the system. | [
"Removes",
"the",
"virtualenv",
"directory",
"from",
"the",
"system",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L165-L180 | train |
pypa/pipenv | pipenv/core.py | ensure_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_... | python | 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",
")",
":",
"from",
".",
"environments",
"import",
"PIPENV_VIRTUALENV",
"# Assert Pipfile exists.",
"python",
"=",
"which",
"(",
"\"python\"",... | Creates a Pipfile for the project, if it doesn't exist. | [
"Creates",
"a",
"Pipfile",
"for",
"the",
"project",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L255-L315 | train |
pypa/pipenv | pipenv/core.py | find_a_system_python | 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.... | python | 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",
")",
":",
"from",
".",
"vendor",
".",
"pythonfinder",
"import",
"Finder",
"finder",
"=",
"Finder",
"(",
"system",
"=",
"False",
",",
"global_search",
"=",
"True",
")",
"if",
"not",
"line",
":",
"return",
"next",
... | 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 ... | [
"Find",
"a",
"Python",
"installation",
"from",
"a",
"given",
"line",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L318-L339 | train |
pypa/pipenv | pipenv/core.py | ensure_virtualenv | 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:
... | python | 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",
")",
":",
"from",
".",
"environments",
"import",
"PIPENV_USE_SYSTEM",
"def",
"abort",
"(",
")",
":",
"sy... | Creates a virtualenv, if one doesn't exist. | [
"Creates",
"a",
"virtualenv",
"if",
"one",
"doesn",
"t",
"exist",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L455-L516 | train |
pypa/pipenv | pipenv/core.py | ensure_project | 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... | python | 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"... | Ensures both Pipfile and virtualenv exist for the project. | [
"Ensures",
"both",
"Pipfile",
"and",
"virtualenv",
"exist",
"for",
"the",
"project",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L519-L594 | train |
pypa/pipenv | pipenv/core.py | shorten_path | 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... | python | 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",
")",
":",
"original",
"=",
"location",
"short",
"=",
"os",
".",
"sep",
".",
"join",
"(",
"[",
"s",
"[",
"0",
"]",
"if",
"len",
"(",
"s",
")",
">",
"(",
"len",
"(",
"\"2long4\"",
... | Returns a visually shorter representation of a given system path. | [
"Returns",
"a",
"visually",
"shorter",
"representation",
"of",
"a",
"given",
"system",
"path",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L597-L607 | train |
pypa/pipenv | pipenv/core.py | do_where | 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."
... | python | 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",
")",
":",
"if",
"not",
"virtualenv",
":",
"if",
"not",
"project",
".",
"pipfile_exists",
":",
"click",
".",
"echo",
"(",
"\"No Pipfile present at project home. Consider running \"",
"\... | Executes the where functionality. | [
"Executes",
"the",
"where",
"functionality",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L611-L640 | train |
pypa/pipenv | pipenv/core.py | do_install_dependencies | 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... | python | 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",
",",... | Executes the install functionality.
If requirements is True, simply spits out a requirements format to stdout. | [
"Executes",
"the",
"install",
"functionality",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L759-L856 | train |
pypa/pipenv | pipenv/core.py | do_create_virtualenv | 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=... | python | 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",
")",
":",
"click",
".",
"echo",
"(",
"crayons",
".",
"normal",
"(",
"fix_utf8",
"(",
"\"Creating a virtualenv for this project…\"),",
... | Creates a virtualenv. | [
"Creates",
"a",
"virtualenv",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L874-L953 | train |
pypa/pipenv | pipenv/core.py | do_lock | 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... | python | 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",
",",
")",
":",
"cached_lockf... | Executes the freeze functionality. | [
"Executes",
"the",
"freeze",
"functionality",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1003-L1105 | train |
pypa/pipenv | pipenv/core.py | do_purge | 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
# ... | python | 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",
")",
":",
"if",
"downloads",
":",
"if",
"not",
"bare",
":",
"click",
".",
"echo",
"(",
"crayons",
".",
"normal",
"(",
"fix_utf8",
"(",
"\... | Executes the purge functionality. | [
"Executes",
"the",
"purge",
"functionality",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1108-L1149 | train |
pypa/pipenv | pipenv/core.py | do_init | 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... | python | 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",
",",
"depl... | Executes the init functionality. | [
"Executes",
"the",
"init",
"functionality",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1152-L1275 | train |
pypa/pipenv | pipenv/core.py | fallback_which | 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 ... | python | 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",
")",
":",
"from",
".",
"vendor",
".",
"pythonfinder",
"import",
"Finder",
"if",
"not",
"command",
":",
"raise",
"ValueErr... | 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... | [
"A",
"fallback",
"implementation",
"of",
"the",
"which",
"utility",
"command",
"that",
"relies",
"exclusively",
"on",
"searching",
"the",
"path",
"for",
"commands",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1544-L1575 | train |
pypa/pipenv | pipenv/core.py | which_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:
... | python | 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",
")",
":",
"location",
"=",
"None",
"if",
"\"VIRTUAL_ENV\"",
"in",
"os",
".",
"environ",
":",
"location",
"=",
"os",
".",
"environ",
"[",
"\"VIRTUAL_ENV\"",
"]",
"if",
"allow_global",
":",
"if",
"locati... | Returns the location of virtualenv-installed pip. | [
"Returns",
"the",
"location",
"of",
"virtualenv",
"-",
"installed",
"pip",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1578-L1598 | train |
pypa/pipenv | pipenv/core.py | system_which | 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:
... | python | 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",
")",
":",
"_which",
"=",
"\"which -a\"",
"if",
"not",
"os",
".",
"name",
"==",
"\"nt\"",
"else",
"\"where\"",
"os",
".",
"environ",
"=",
"{",
"vistir",
".",
"compat",
".",
"fs_str",
"(",... | Emulates the system's which. Returns None if not found. | [
"Emulates",
"the",
"system",
"s",
"which",
".",
"Returns",
"None",
"if",
"not",
"found",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1601-L1635 | train |
pypa/pipenv | pipenv/core.py | format_help | 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... | python | 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",
")",
":",
"help",
"=",
"help",
".",
"replace",
"(",
"\"Options:\"",
",",
"str",
"(",
"crayons",
".",
"normal",
"(",
"\"Options:\"",
",",
"bold",
"=",
"True",
")",
")",
")",
"help",
"=",
"help",
".",
"replace",
"(",
... | Formats the help string. | [
"Formats",
"the",
"help",
"string",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1639-L1695 | train |
pypa/pipenv | pipenv/core.py | ensure_lockfile | 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:... | python | 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",
")",
":",
"if",
"not",
"keep_outdated",
":",
"keep_outdated",
"=",
"project",
".",
"settings",
".",
"get",
"(",
"\"keep_outdated\"",
")",
"# Write out the lockfile if it... | Ensures that the lockfile is up-to-date. | [
"Ensures",
"that",
"the",
"lockfile",
"is",
"up",
"-",
"to",
"-",
"date",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1749-L1769 | train |
pypa/pipenv | pipenv/core.py | _inline_activate_venv | 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",... | python | 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",
"(",
")",
":",
"components",
"=",
"[",
"]",
"for",
"name",
"in",
"(",
"\"bin\"",
",",
"\"Scripts\"",
")",
":",
"bindir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project",
".",
"virtualenv_location",
",",
"name",
")",
... | 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 | [
"Built",
"-",
"in",
"venv",
"doesn",
"t",
"have",
"activate_this",
".",
"py",
"but",
"doesn",
"t",
"need",
"it",
"anyway",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L2376-L2391 | train |
pypa/pipenv | pipenv/core.py | do_run | 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... | python | 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",
")",
":",
"from",
".",
"cmdparse",
"import",
"ScriptEmptyError",
"# Ensure that virtualenv is available.",
"ensure_project",
"(... | 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. | [
"Attempt",
"to",
"run",
"command",
"either",
"pulling",
"from",
"project",
"or",
"interpreting",
"as",
"executable",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L2464-L2511 | train |
pypa/pipenv | pipenv/vendor/shellingham/nt.py | _iter_process | 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... | python | 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",
"(",
")",
":",
"# 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... | 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'} | [
"Iterate",
"through",
"processes",
"yielding",
"process",
"ID",
"and",
"properties",
"of",
"each",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/nt.py#L44-L93 | train |
pypa/pipenv | pipenv/vendor/shellingham/nt.py | get_shell | 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... | python | 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",
")",
":",
"if",
"not",
"pid",
":",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"processes",
"=",
"dict",
"(",
"_iter_process",
"(",
")",
")",
"def",
"check_parent",
"(",
"pid",... | Get the shell that the supplied pid or os.getpid() is running in. | [
"Get",
"the",
"shell",
"that",
"the",
"supplied",
"pid",
"or",
"os",
".",
"getpid",
"()",
"is",
"running",
"in",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/nt.py#L106-L128 | train |
pypa/pipenv | pipenv/vendor/click/types.py | ParamType.fail | def fail(self, message, param=None, ctx=None):
"""Helper method to fail with an invalid value message."""
raise BadParameter(message, ctx=ctx, param=param) | python | 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",
")",
":",
"raise",
"BadParameter",
"(",
"message",
",",
"ctx",
"=",
"ctx",
",",
"param",
"=",
"param",
")"
] | Helper method to fail with an invalid value message. | [
"Helper",
"method",
"to",
"fail",
"with",
"an",
"invalid",
"value",
"message",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/types.py#L67-L69 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/utils/appdirs.py | user_cache_dir | 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... | python | 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",
"if",
"WINDOWS",
":",
"# Get the base path",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"_get_win_folder",
"(",
"\"CSIDL_LOCAL_APPDATA\"",
")",
")",
"# When using Python 2, return pa... | 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... | [
"r",
"Return",
"full",
"path",
"to",
"the",
"user",
"-",
"specific",
"cache",
"dir",
"for",
"this",
"application",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/appdirs.py#L21-L67 | train |
pypa/pipenv | pipenv/patched/notpip/_internal/utils/encoding.py | auto_decode | 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)
... | python | 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",
"for",
"bom",
",",
"encoding",
"in",
"BOMS",
":",
"if",
"data",
".",
"startswith",
"(",
"bom",
")",
":",
"return",
"data",
"[",
"len",
"(",
"bom",
")",
":",
"]",
".",
"decode",
"... | Check a bytes string for a BOM to correctly detect the encoding
Fallback to locale.getpreferredencoding(False) like open() on Python3 | [
"Check",
"a",
"bytes",
"string",
"for",
"a",
"BOM",
"to",
"correctly",
"detect",
"the",
"encoding"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/utils/encoding.py#L24-L39 | train |
pypa/pipenv | pipenv/vendor/click/globals.py | resolve_color_default | 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... | python | 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",
")",
":",
"if",
"color",
"is",
"not",
"None",
":",
"return",
"color",
"ctx",
"=",
"get_current_context",
"(",
"silent",
"=",
"True",
")",
"if",
"ctx",
"is",
"not",
"None",
":",
"return",
"ctx",
... | 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. | [
"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",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/globals.py#L39-L48 | train |
pypa/pipenv | pipenv/vendor/toml/decoder.py | load | 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:
... | python | 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",
")",
":",
"if",
"_ispath",
"(",
"f",
")",
":",
"with",
"io",
".",
"open",
"(",
"_getpath",
"(",
"f",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"ffile",
":",... | 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... | [
"Parses",
"named",
"file",
"or",
"files",
"as",
"toml",
"and",
"returns",
"a",
"dictionary"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/decoder.py#L92-L137 | train |
pypa/pipenv | pipenv/vendor/toml/decoder.py | loads | 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
... | python | 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",
")",
":",
"implicitgroups",
"=",
"[",
"]",
"if",
"decoder",
"is",
"None",
":",
"decoder",
"=",
"TomlDecoder",
"(",
"_dict",
")",
"retval",
"=",
"decoder",
".",
"get_emp... | 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 | [
"Parses",
"string",
"as",
"toml"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/decoder.py#L143-L461 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | markup_join | 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) | python | 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",
")",
":",
"buf",
"=",
"[",
"]",
"iterator",
"=",
"imap",
"(",
"soft_unicode",
",",
"seq",
")",
"for",
"arg",
"in",
"iterator",
":",
"buf",
".",
"append",
"(",
"arg",
")",
"if",
"hasattr",
"(",
"arg",
",",
"'__html_... | Concatenation that escapes if necessary and converts to unicode. | [
"Concatenation",
"that",
"escapes",
"if",
"necessary",
"and",
"converts",
"to",
"unicode",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L43-L51 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | new_context | 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:
... | python | 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",
")",
":",
"if",
"vars",
"is",
"None",
":",
"vars",
"=",
"{",... | Internal helper to for context creation. | [
"Internal",
"helper",
"to",
"for",
"context",
"creation",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L59-L77 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | make_logging_undefined | 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... | python | 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",
")",
":",
"if",
"logger",
"is",
"None",
":",
"import",
"logging",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"addHandler",
"(",
"... | 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... | [
"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... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L677-L755 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Context.super | 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 '
... | python | 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",
")",
":",
"try",
":",
"blocks",
"=",
"self",
".",
"blocks",
"[",
"name",
"]",
"index",
"=",
"blocks",
".",
"index",
"(",
"current",
")",
"+",
"1",
"blocks",
"[",
"index",
"]",
"except",
"L... | Render a parent block. | [
"Render",
"a",
"parent",
"block",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L175-L185 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Context.resolve | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_legacy_resolve_mode",
":",
"rv",
"=",
"resolve_or_missing",
"(",
"self",
",",
"key",
")",
"else",
":",
"rv",
"=",
"self",
".",
"resolve_or_missing",
"(",
"key",
")",
"if",
"rv",
... | Looks up a variable like `__getitem__` or `get` but returns an
:class:`Undefined` object with the name of the name looked up. | [
"Looks",
"up",
"a",
"variable",
"like",
"__getitem__",
"or",
"get",
"but",
"returns",
"an",
":",
"class",
":",
"Undefined",
"object",
"with",
"the",
"name",
"of",
"the",
"name",
"looked",
"up",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L196-L206 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Context.resolve_or_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
... | python | 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",
")",
":",
"if",
"self",
".",
"_legacy_resolve_mode",
":",
"rv",
"=",
"self",
".",
"resolve",
"(",
"key",
")",
"if",
"isinstance",
"(",
"rv",
",",
"Undefined",
")",
":",
"rv",
"=",
"missing",
"return... | Resolves a variable like :meth:`resolve` but returns the
special `missing` value if it cannot be found. | [
"Resolves",
"a",
"variable",
"like",
":",
"meth",
":",
"resolve",
"but",
"returns",
"the",
"special",
"missing",
"value",
"if",
"it",
"cannot",
"be",
"found",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L208-L217 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Context.get_exported | def get_exported(self):
"""Get a new dict with the exported variables."""
return dict((k, self.vars[k]) for k in self.exported_vars) | python | 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",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"self",
".",
"vars",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"self",
".",
"exported_vars",
")"
] | Get a new dict with the exported variables. | [
"Get",
"a",
"new",
"dict",
"with",
"the",
"exported",
"variables",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L219-L221 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Context.get_all | 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... | python | 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",
")",
":",
"if",
"not",
"self",
".",
"vars",
":",
"return",
"self",
".",
"parent",
"if",
"not",
"self",
".",
"parent",
":",
"return",
"self",
".",
"vars",
"return",
"dict",
"(",
"self",
".",
"parent",
",",
"*",
"*",
... | 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. | [
"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",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L223-L232 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Context.derived | 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, {},
... | python | 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",
")",
":",
"context",
"=",
"new_context",
"(",
"self",
".",
"environment",
",",
"self",
".",
"name",
",",
"{",
"}",
",",
"self",
".",
"get_all",
"(",
")",
",",
"True",
",",
"None",
",",
"l... | 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. | [
"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",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L268-L277 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | BlockReference.super | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_depth",
"+",
"1",
">=",
"len",
"(",
"self",
".",
"_stack",
")",
":",
"return",
"self",
".",
"_context",
".",
"environment",
".",
"undefined",
"(",
"'there is no parent block called %r.'",
"%",
"... | Super the block. | [
"Super",
"the",
"block",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L334-L341 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | LoopContextBase.cycle | 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)] | python | 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",
")",
":",
"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. | [
"Cycles",
"among",
"the",
"arguments",
"with",
"the",
"current",
"loop",
"index",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L366-L370 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | LoopContextBase.changed | 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 | python | 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",
")",
":",
"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. | [
"Checks",
"whether",
"the",
"value",
"has",
"changed",
"since",
"the",
"last",
"call",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L372-L377 | train |
pypa/pipenv | pipenv/vendor/jinja2/runtime.py | Macro._invoke | 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 | python | 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",
")",
":",
"rv",
"=",
"self",
".",
"_func",
"(",
"*",
"arguments",
")",
"if",
"autoescape",
":",
"rv",
"=",
"Markup",
"(",
"rv",
")",
"return",
"rv"
] | This method is being swapped out by the async implementation. | [
"This",
"method",
"is",
"being",
"swapped",
"out",
"by",
"the",
"async",
"implementation",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/runtime.py#L577-L582 | train |
pypa/pipenv | pipenv/vendor/pexpect/FSM.py | main | 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... | python | 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",
"(",
")",
":",
"f",
"=",
"FSM",
"(",
"'INIT'",
",",
"[",
"]",
")",
"f",
".",
"set_default_transition",
"(",
"Error",
",",
"'INIT'",
")",
"f",
".",
"add_transition_any",
"(",
"'INIT'",
",",
"None",
",",
"'INIT'",
")",
"f",
".",
"add_t... | 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. | [
"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"... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L308-L330 | train |
pypa/pipenv | pipenv/vendor/pexpect/FSM.py | FSM.add_transition | 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 ... | python | 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",
")",
":",
"if",
"next_state",
"is",
"None",
":",
"next_state",
"=",
"state",
"self",
".",
"state_transitions",
"[",
"(",
... | 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 ... | [
"This",
"adds",
"a",
"transition",
"that",
"associates",
":"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L131-L146 | train |
pypa/pipenv | pipenv/vendor/pexpect/FSM.py | FSM.add_transition_list | 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 ... | python | 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",
")",
":",
"if",
"next_state",
"is",
"None",
":",
"next_state",
"=",
"state",
"for",
"input_symbol",
"in",
"list_in... | 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... | [
"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... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L148-L162 | train |
pypa/pipenv | pipenv/vendor/pexpect/FSM.py | FSM.add_transition_any | 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... | python | 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",
")",
":",
"if",
"next_state",
"is",
"None",
":",
"next_state",
"=",
"state",
"self",
".",
"state_transitions_any",
"[",
"state",
"]",
"=",
... | 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).
... | [
"This",
"adds",
"a",
"transition",
"that",
"associates",
":"
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L164-L180 | train |
pypa/pipenv | pipenv/vendor/pexpect/FSM.py | FSM.get_transition | 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... | python | 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",
")",
":",
"if",
"(",
"input_symbol",
",",
"state",
")",
"in",
"self",
".",
"state_transitions",
":",
"return",
"self",
".",
"state_transitions",
"[",
"(",
"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 sequence of steps to check for a defined transition goes from ... | [
"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",
... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L195-L226 | train |
pypa/pipenv | pipenv/vendor/pexpect/FSM.py | FSM.process | 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 ... | python | 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",
")",
":",
"self",
".",
"input_symbol",
"=",
"input_symbol",
"(",
"self",
".",
"action",
",",
"self",
".",
"next_state",
")",
"=",
"self",
".",
"get_transition",
"(",
"self",
".",
"input_symbol",
",",
"s... | 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 ... | [
"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... | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/FSM.py#L228-L243 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/ipaddress.py | ip_address | 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... | python | 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",
")",
":",
"try",
":",
"return",
"IPv4Address",
"(",
"address",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6Address",
"(",
"address",
")",
"except",
"(",
... | 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... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L135-L168 | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/ipaddress.py | ip_interface | 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:
... | python | 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",
")",
":",
"try",
":",
"return",
"IPv4Interface",
"(",
"address",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6Interface",
"(",
"address",
")",
"except",
... | 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 ... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | cae8d76c210b9777e90aab76e9c4b0e53bb19cde | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L207-L239 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.