diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /library/python/resource/__init__.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/resource/__init__.py')
-rw-r--r-- | library/python/resource/__init__.py | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/library/python/resource/__init__.py b/library/python/resource/__init__.py index 26503ef7fc..dd00de7b43 100644 --- a/library/python/resource/__init__.py +++ b/library/python/resource/__init__.py @@ -1,46 +1,46 @@ -from __res import find as __find, count, key_by_index, resfs_files as __resfs_files -from __res import resfs_read, resfs_resolve, resfs_src # noqa +from __res import find as __find, count, key_by_index, resfs_files as __resfs_files +from __res import resfs_read, resfs_resolve, resfs_src # noqa -import six +import six -def iterkeys(prefix='', strip_prefix=False): - decode = lambda s: s - if isinstance(prefix, six.text_type): - prefix = prefix.encode('utf-8') - decode = lambda s: s.decode('utf-8') - - for i in six.moves.range(count()): +def iterkeys(prefix='', strip_prefix=False): + decode = lambda s: s + if isinstance(prefix, six.text_type): + prefix = prefix.encode('utf-8') + decode = lambda s: s.decode('utf-8') + + for i in six.moves.range(count()): key = key_by_index(i) - if key.startswith(prefix): - if strip_prefix: - key = key[len(prefix):] - yield decode(key) - - -def itervalues(prefix=b''): - for key in iterkeys(prefix=prefix): - value = find(key) - yield value - - -def iteritems(prefix='', strip_prefix=False): - for key in iterkeys(prefix=prefix): - value = find(key) - if strip_prefix: - key = key[len(prefix):] - yield key, value - - -def resfs_file_exists(path): - return resfs_src(path, resfs_file=True) is not None - - -def resfs_files(prefix=''): - decode = lambda s: s - if isinstance(prefix, six.text_type): - decode = lambda s: s.decode('utf-8') - return [decode(s) for s in __resfs_files(prefix=prefix)] + if key.startswith(prefix): + if strip_prefix: + key = key[len(prefix):] + yield decode(key) + + +def itervalues(prefix=b''): + for key in iterkeys(prefix=prefix): + value = find(key) + yield value + + +def iteritems(prefix='', strip_prefix=False): + for key in iterkeys(prefix=prefix): + value = find(key) + if strip_prefix: + key = key[len(prefix):] + yield key, value + + +def resfs_file_exists(path): + return resfs_src(path, resfs_file=True) is not None + + +def resfs_files(prefix=''): + decode = lambda s: s + if isinstance(prefix, six.text_type): + decode = lambda s: s.decode('utf-8') + return [decode(s) for s in __resfs_files(prefix=prefix)] def find(path): |