aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/runtime_py3/sitecustomize.pyx
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /library/python/runtime_py3/sitecustomize.pyx
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/runtime_py3/sitecustomize.pyx')
-rw-r--r--library/python/runtime_py3/sitecustomize.pyx138
1 files changed, 69 insertions, 69 deletions
diff --git a/library/python/runtime_py3/sitecustomize.pyx b/library/python/runtime_py3/sitecustomize.pyx
index 0273d059de..966bbe8ba6 100644
--- a/library/python/runtime_py3/sitecustomize.pyx
+++ b/library/python/runtime_py3/sitecustomize.pyx
@@ -1,69 +1,69 @@
-import re
-import sys
-
-import __res
-
-from importlib.abc import ResourceReader
-from importlib.metadata import Distribution, DistributionFinder, PackageNotFoundError, Prepared
-
-ResourceReader.register(__res._ResfsResourceReader)
-
-METADATA_NAME = re.compile('^Name: (.*)$', re.MULTILINE)
-
-
-class ArcadiaDistribution(Distribution):
-
- def __init__(self, prefix):
- self.prefix = prefix
-
- def read_text(self, filename):
- data = __res.resfs_read(f'{self.prefix}{filename}')
- if data:
- return data.decode('utf-8')
- read_text.__doc__ = Distribution.read_text.__doc__
-
- def locate_file(self, path):
- return f'{self.prefix}{path}'
-
-
-class ArcadiaMetadataFinder(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):
- cls.prefixes.clear()
-
- for resource in __res.resfs_files():
- resource = resource.decode('utf-8')
- if not resource.endswith('METADATA'):
- continue
- data = __res.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
-
-
-# monkeypatch standart library
-import importlib.metadata
-importlib.metadata.MetadataPathFinder = ArcadiaMetadataFinder
+import re
+import sys
+
+import __res
+
+from importlib.abc import ResourceReader
+from importlib.metadata import Distribution, DistributionFinder, PackageNotFoundError, Prepared
+
+ResourceReader.register(__res._ResfsResourceReader)
+
+METADATA_NAME = re.compile('^Name: (.*)$', re.MULTILINE)
+
+
+class ArcadiaDistribution(Distribution):
+
+ def __init__(self, prefix):
+ self.prefix = prefix
+
+ def read_text(self, filename):
+ data = __res.resfs_read(f'{self.prefix}{filename}')
+ if data:
+ return data.decode('utf-8')
+ read_text.__doc__ = Distribution.read_text.__doc__
+
+ def locate_file(self, path):
+ return f'{self.prefix}{path}'
+
+
+class ArcadiaMetadataFinder(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):
+ cls.prefixes.clear()
+
+ for resource in __res.resfs_files():
+ resource = resource.decode('utf-8')
+ if not resource.endswith('METADATA'):
+ continue
+ data = __res.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
+
+
+# monkeypatch standart library
+import importlib.metadata
+importlib.metadata.MetadataPathFinder = ArcadiaMetadataFinder