diff options
author | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
commit | 227b2d30a8675b44918f9d9ca89b24144a938215 (patch) | |
tree | 9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/packaging/requirements.py | |
parent | 842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff) |
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/packaging/requirements.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/packaging/requirements.py | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/packaging/requirements.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/packaging/requirements.py deleted file mode 100644 index 98bc507..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/packaging/requirements.py +++ /dev/null | |||
@@ -1,130 +0,0 @@ | |||
1 | # This file is dual licensed under the terms of the Apache License, Version | ||
2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository | ||
3 | # for complete details. | ||
4 | from __future__ import absolute_import, division, print_function | ||
5 | |||
6 | import string | ||
7 | import re | ||
8 | |||
9 | from pip._vendor.pyparsing import stringStart, stringEnd, originalTextFor, ParseException | ||
10 | from pip._vendor.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine | ||
11 | from pip._vendor.pyparsing import Literal as L # noqa | ||
12 | from pip._vendor.six.moves.urllib import parse as urlparse | ||
13 | |||
14 | from .markers import MARKER_EXPR, Marker | ||
15 | from .specifiers import LegacySpecifier, Specifier, SpecifierSet | ||
16 | |||
17 | |||
18 | class InvalidRequirement(ValueError): | ||
19 | """ | ||
20 | An invalid requirement was found, users should refer to PEP 508. | ||
21 | """ | ||
22 | |||
23 | |||
24 | ALPHANUM = Word(string.ascii_letters + string.digits) | ||
25 | |||
26 | LBRACKET = L("[").suppress() | ||
27 | RBRACKET = L("]").suppress() | ||
28 | LPAREN = L("(").suppress() | ||
29 | RPAREN = L(")").suppress() | ||
30 | COMMA = L(",").suppress() | ||
31 | SEMICOLON = L(";").suppress() | ||
32 | AT = L("@").suppress() | ||
33 | |||
34 | PUNCTUATION = Word("-_.") | ||
35 | IDENTIFIER_END = ALPHANUM | (ZeroOrMore(PUNCTUATION) + ALPHANUM) | ||
36 | IDENTIFIER = Combine(ALPHANUM + ZeroOrMore(IDENTIFIER_END)) | ||
37 | |||
38 | NAME = IDENTIFIER("name") | ||
39 | EXTRA = IDENTIFIER | ||
40 | |||
41 | URI = Regex(r'[^ ]+')("url") | ||
42 | URL = (AT + URI) | ||
43 | |||
44 | EXTRAS_LIST = EXTRA + ZeroOrMore(COMMA + EXTRA) | ||
45 | EXTRAS = (LBRACKET + Optional(EXTRAS_LIST) + RBRACKET)("extras") | ||
46 | |||
47 | VERSION_PEP440 = Regex(Specifier._regex_str, re.VERBOSE | re.IGNORECASE) | ||
48 | VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE) | ||
49 | |||
50 | VERSION_ONE = VERSION_PEP440 ^ VERSION_LEGACY | ||
51 | VERSION_MANY = Combine(VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE), | ||
52 | joinString=",", adjacent=False)("_raw_spec") | ||
53 | _VERSION_SPEC = Optional(((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY)) | ||
54 | _VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or '') | ||
55 | |||
56 | VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier") | ||
57 | VERSION_SPEC.setParseAction(lambda s, l, t: t[1]) | ||
58 | |||
59 | MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") | ||
60 | MARKER_EXPR.setParseAction( | ||
61 | lambda s, l, t: Marker(s[t._original_start:t._original_end]) | ||
62 | ) | ||
63 | MARKER_SEPARATOR = SEMICOLON | ||
64 | MARKER = MARKER_SEPARATOR + MARKER_EXPR | ||
65 | |||
66 | VERSION_AND_MARKER = VERSION_SPEC + Optional(MARKER) | ||
67 | URL_AND_MARKER = URL + Optional(MARKER) | ||
68 | |||
69 | NAMED_REQUIREMENT = \ | ||
70 | NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER) | ||
71 | |||
72 | REQUIREMENT = stringStart + NAMED_REQUIREMENT + stringEnd | ||
73 | # pyparsing isn't thread safe during initialization, so we do it eagerly, see | ||
74 | # issue #104 | ||
75 | REQUIREMENT.parseString("x[]") | ||
76 | |||
77 | |||
78 | class Requirement(object): | ||
79 | """Parse a requirement. | ||
80 | |||
81 | Parse a given requirement string into its parts, such as name, specifier, | ||
82 | URL, and extras. Raises InvalidRequirement on a badly-formed requirement | ||
83 | string. | ||
84 | """ | ||
85 | |||
86 | # TODO: Can we test whether something is contained within a requirement? | ||
87 | # If so how do we do that? Do we need to test against the _name_ of | ||
88 | # the thing as well as the version? What about the markers? | ||
89 | # TODO: Can we normalize the name and extra name? | ||
90 | |||
91 | def __init__(self, requirement_string): | ||
92 | try: | ||
93 | req = REQUIREMENT.parseString(requirement_string) | ||
94 | except ParseException as e: | ||
95 | raise InvalidRequirement( | ||
96 | "Invalid requirement, parse error at \"{0!r}\"".format( | ||
97 | requirement_string[e.loc:e.loc + 8])) | ||
98 | |||
99 | self.name = req.name | ||
100 | if req.url: | ||
101 | parsed_url = urlparse.urlparse(req.url) | ||
102 | if not (parsed_url.scheme and parsed_url.netloc) or ( | ||
103 | not parsed_url.scheme and not parsed_url.netloc): | ||
104 | raise InvalidRequirement("Invalid URL given") | ||
105 | self.url = req.url | ||
106 | else: | ||
107 | self.url = None | ||
108 | self.extras = set(req.extras.asList() if req.extras else []) | ||
109 | self.specifier = SpecifierSet(req.specifier) | ||
110 | self.marker = req.marker if req.marker else None | ||
111 | |||
112 | def __str__(self): | ||
113 | parts = [self.name] | ||
114 | |||
115 | if self.extras: | ||
116 | parts.append("[{0}]".format(",".join(sorted(self.extras)))) | ||
117 | |||
118 | if self.specifier: | ||
119 | parts.append(str(self.specifier)) | ||
120 | |||
121 | if self.url: | ||
122 | parts.append("@ {0}".format(self.url)) | ||
123 | |||
124 | if self.marker: | ||
125 | parts.append("; {0}".format(self.marker)) | ||
126 | |||
127 | return "".join(parts) | ||
128 | |||
129 | def __repr__(self): | ||
130 | return "<Requirement({0!r})>".format(str(self)) | ||