comparison lib/python3.8/site-packages/pip/_internal/utils/pkg_resources.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 pip._vendor.pkg_resources import yield_lines
2 from pip._vendor.six import ensure_str
3
4 from pip._internal.utils.typing import MYPY_CHECK_RUNNING
5
6 if MYPY_CHECK_RUNNING:
7 from typing import Dict, Iterable, List
8
9
10 class DictMetadata(object):
11 """IMetadataProvider that reads metadata files from a dictionary.
12 """
13 def __init__(self, metadata):
14 # type: (Dict[str, bytes]) -> None
15 self._metadata = metadata
16
17 def has_metadata(self, name):
18 # type: (str) -> bool
19 return name in self._metadata
20
21 def get_metadata(self, name):
22 # type: (str) -> str
23 try:
24 return ensure_str(self._metadata[name])
25 except UnicodeDecodeError as e:
26 # Mirrors handling done in pkg_resources.NullProvider.
27 e.reason += " in {} file".format(name)
28 raise
29
30 def get_metadata_lines(self, name):
31 # type: (str) -> Iterable[str]
32 return yield_lines(self.get_metadata(name))
33
34 def metadata_isdir(self, name):
35 # type: (str) -> bool
36 return False
37
38 def metadata_listdir(self, name):
39 # type: (str) -> List[str]
40 return []
41
42 def run_script(self, script_name, namespace):
43 # type: (str, str) -> None
44 pass