1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
--- contrib/python/importlib-metadata/py2/.dist-info/METADATA (index)
+++ contrib/python/importlib-metadata/py2/.dist-info/METADATA (working tree)
@@ -15,7 +15,6 @@ Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 2
Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
License-File: LICENSE
-Requires-Dist: zipp (>=0.5)
Requires-Dist: pathlib2 ; python_version < "3"
Requires-Dist: contextlib2 ; python_version < "3"
Requires-Dist: configparser (>=3.5) ; python_version < "3"
--- contrib/python/importlib-metadata/py2/importlib_metadata/__init__.py (index)
+++ contrib/python/importlib-metadata/py2/importlib_metadata/__init__.py (working tree)
@@ -6,7 +6,6 @@ import re
import abc
import csv
import sys
-import zipp
import operator
import functools
import itertools
@@ -525,7 +525,7 @@ class Prepared:
and base.endswith('.egg'))
-@install
+#@install
class MetadataPathFinder(NullFinder, DistributionFinder):
"""A degenerate finder for distribution packages on the file system.
@@ -573,6 +572,63 @@ class PathDistribution(Distribution):
return self._path.parent / path
+class ArcadiaDistribution(Distribution):
+
+ def __init__(self, prefix):
+ self.prefix = prefix
+
+ def read_text(self, filename):
+ from library.python.resource import resfs_read
+ data = resfs_read('{}{}'.format(self.prefix, filename))
+ if data:
+ return data.decode('utf-8')
+ read_text.__doc__ = Distribution.read_text.__doc__
+
+ def locate_file(self, path):
+ return '{}{}'.format(self.prefix, path)
+
+
+@install
+class ArcadiaMetadataFinder(NullFinder, DistributionFinder):
+
+ prefixes = {}
+
+ @classmethod
+ def find_distributions(cls, context=DistributionFinder.Context()):
+ found = cls._search_prefixes(context.name)
+ return map(ArcadiaDistribution, found)
+
+ @classmethod
+ def _init_prefixes(cls):
+ from library.python.resource import resfs_read, resfs_files
+ cls.prefixes.clear()
+
+ METADATA_NAME = re.compile('^Name: (.*)$', re.MULTILINE)
+
+ for resource in resfs_files():
+ if not resource.endswith('METADATA'):
+ continue
+ data = resfs_read(resource).decode('utf-8')
+ metadata_name = METADATA_NAME.search(data)
+ if metadata_name:
+ metadata_name = Prepared(metadata_name.group(1))
+ cls.prefixes[metadata_name.normalized] = resource[:-len('METADATA')]
+
+ @classmethod
+ def _search_prefixes(cls, name):
+ if not cls.prefixes:
+ cls._init_prefixes()
+
+ if name:
+ try:
+ yield cls.prefixes[Prepared(name).normalized]
+ except KeyError:
+ raise PackageNotFoundError(name)
+ else:
+ for prefix in sorted(cls.prefixes.values()):
+ yield prefix
+
+
def distribution(distribution_name):
"""Get the ``Distribution`` instance for the named package.
|