aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-04-14 13:33:45 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-04-14 13:42:54 +0300
commit51e5eb32e4344ee9c710455de559b5bbfd95c35d (patch)
treea397d4c8166ff568b048ebdc1ff482c11dac4cb8 /contrib
parentda6de0aefb4620d2a3515de3f478b5a0925d55ef (diff)
downloadydb-51e5eb32e4344ee9c710455de559b5bbfd95c35d.tar.gz
Intermediate changes
Diffstat (limited to 'contrib')
-rw-r--r--contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py40
-rw-r--r--contrib/python/importlib-metadata/py3/ya.make4
2 files changed, 18 insertions, 26 deletions
diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py b/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py
index 0ed3e8dfb5..b512d89d6e 100644
--- a/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py
+++ b/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py
@@ -50,7 +50,7 @@ __all__ = [
]
try:
- import library.python.resource
+ import __res as res
ARCADIA = True
except ImportError:
ARCADIA = False
@@ -966,24 +966,24 @@ class PathDistribution(Distribution):
class ArcadiaDistribution(Distribution):
-
def __init__(self, prefix):
- self.prefix = prefix
+ self._prefix = prefix
+ self._path = pathlib.Path(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')
+ data = res.resfs_read(f"{self._prefix}{filename}")
+ if data is not None:
+ return data.decode("utf-8")
+
read_text.__doc__ = Distribution.read_text.__doc__
def locate_file(self, path):
- return '{}{}'.format(self.prefix, path)
+ return self._path.parent / path
@install(ARCADIA == True)
-class ArcadiaMetadataFinder(NullFinder, DistributionFinder):
-
+class MetadataArcadiaFinder(DistributionFinder):
+ METADATA_NAME = re.compile("^Name: (.*)$", re.MULTILINE)
prefixes = {}
@classmethod
@@ -993,19 +993,16 @@ class ArcadiaMetadataFinder(NullFinder, DistributionFinder):
@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'):
+ for resource in res.resfs_files():
+ resource = resource.decode("utf-8")
+ if not resource.endswith("METADATA"):
continue
- data = resfs_read(resource).decode('utf-8')
- metadata_name = METADATA_NAME.search(data)
+ data = res.resfs_read(resource).decode("utf-8")
+ metadata_name = cls.METADATA_NAME.search(data)
if metadata_name:
- metadata_name = Prepared(metadata_name.group(1))
- cls.prefixes[metadata_name.normalized] = resource[:-len('METADATA')]
+ cls.prefixes[Prepared(metadata_name.group(1)).normalized] = resource.removesuffix("METADATA")
@classmethod
def _search_prefixes(cls, name):
@@ -1016,10 +1013,9 @@ class ArcadiaMetadataFinder(NullFinder, DistributionFinder):
try:
yield cls.prefixes[Prepared(name).normalized]
except KeyError:
- raise PackageNotFoundError(name)
+ pass
else:
- for prefix in sorted(cls.prefixes.values()):
- yield prefix
+ yield from sorted(cls.prefixes.values())
def distribution(distribution_name: str) -> Distribution:
diff --git a/contrib/python/importlib-metadata/py3/ya.make b/contrib/python/importlib-metadata/py3/ya.make
index 00d69e1c37..ecdc5d99ec 100644
--- a/contrib/python/importlib-metadata/py3/ya.make
+++ b/contrib/python/importlib-metadata/py3/ya.make
@@ -6,10 +6,6 @@ VERSION(7.1.0)
LICENSE(Apache-2.0)
-PEERDIR(
- library/python/resource
-)
-
NO_LINT()
PY_SRCS(