aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/setuptools/py3/patches/02-arcadia.patch
blob: 6443f619b820478e5fea2a9540faefd7de1e7a77 (plain) (blame)
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
--- contrib/python/setuptools/py3/pkg_resources/__init__.py	(revision 10490147)
+++ contrib/python/setuptools/py3/pkg_resources/__init__.py	(revision 10490148)
@@ -3234,6 +3234,45 @@
 from library.python import resource
 
 
+class UnionProvider(EmptyProvider):
+    def __init__(self, *pp):
+        self.module_path = [(p, p.module_path) for p in pp]
+
+    def _has(self, path):
+        for p, pp in path:
+            if p._has(pp):
+                return True
+
+        return False
+
+    def _fn(self, base, resource_name):
+        return [(p, p._fn(pp, resource_name)) for p, pp in base]
+
+    def _get(self, path):
+        for p, pp in path:
+            if p._has(pp):
+                return p._get(pp)
+
+        raise IOError(path)
+
+    def _itdir(self, path):
+        for p, pp in path:
+            if not p._isdir(pp):
+                continue
+            for np in p._listdir(pp):
+                yield np
+
+    def _listdir(self, path):
+        return list(self._itdir(path))
+
+    def _isdir(self, path):
+        for p, pp in path:
+            if p._has(pp):
+                return p._isdir(pp)
+
+        return False
+
+
 class ResProvider(EmptyProvider):
     _resource_fs = {}
 
@@ -3252,7 +3289,7 @@
     @staticmethod
     def from_module(module):
         if Y_PYTHON_SOURCE_ROOT:
-            return DefaultProvider(module)
+            return UnionProvider(DefaultProvider(module), ResProvider(module))
         else:
             return ResProvider(module)