comparison lib/python3.8/site-packages/pip/_internal/utils/distutils_args.py @ 0:9e54283cc701 draft

"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author guerler
date Mon, 27 Jul 2020 03:47:31 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:9e54283cc701
1 from distutils.errors import DistutilsArgError
2 from distutils.fancy_getopt import FancyGetopt
3
4 from pip._internal.utils.typing import MYPY_CHECK_RUNNING
5
6 if MYPY_CHECK_RUNNING:
7 from typing import Dict, List
8
9
10 _options = [
11 ("exec-prefix=", None, ""),
12 ("home=", None, ""),
13 ("install-base=", None, ""),
14 ("install-data=", None, ""),
15 ("install-headers=", None, ""),
16 ("install-lib=", None, ""),
17 ("install-platlib=", None, ""),
18 ("install-purelib=", None, ""),
19 ("install-scripts=", None, ""),
20 ("prefix=", None, ""),
21 ("root=", None, ""),
22 ("user", None, ""),
23 ]
24
25
26 # typeshed doesn't permit Tuple[str, None, str], see python/typeshed#3469.
27 _distutils_getopt = FancyGetopt(_options) # type: ignore
28
29
30 def parse_distutils_args(args):
31 # type: (List[str]) -> Dict[str, str]
32 """Parse provided arguments, returning an object that has the
33 matched arguments.
34
35 Any unknown arguments are ignored.
36 """
37 result = {}
38 for arg in args:
39 try:
40 _, match = _distutils_getopt.getopt(args=[arg])
41 except DistutilsArgError:
42 # We don't care about any other options, which here may be
43 # considered unrecognized since our option list is not
44 # exhaustive.
45 pass
46 else:
47 result.update(match.__dict__)
48 return result