aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/resource
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /library/python/resource
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/resource')
-rw-r--r--library/python/resource/__init__.py78
-rw-r--r--library/python/resource/ut/lib/test_simple.py34
-rw-r--r--library/python/resource/ut/lib/ya.make2
-rw-r--r--library/python/resource/ut/py2/ya.make2
-rw-r--r--library/python/resource/ut/py3/ya.make4
-rw-r--r--library/python/resource/ya.make8
6 files changed, 64 insertions, 64 deletions
diff --git a/library/python/resource/__init__.py b/library/python/resource/__init__.py
index dd00de7b43..26503ef7fc 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):
diff --git a/library/python/resource/ut/lib/test_simple.py b/library/python/resource/ut/lib/test_simple.py
index 4fd3747311..52f006ff91 100644
--- a/library/python/resource/ut/lib/test_simple.py
+++ b/library/python/resource/ut/lib/test_simple.py
@@ -2,25 +2,25 @@ import six # noqa
import library.python.resource as rs
-text = b'na gorshke sidel korol\n'
+text = b'na gorshke sidel korol\n'
+
-
def test_find():
- assert rs.find('/qw.txt') == text
-
-
-def test_iter():
- assert set(rs.iterkeys()).issuperset({'/qw.txt', '/prefix/1.txt', '/prefix/2.txt'})
- assert set(rs.iterkeys(prefix='/prefix/')) == {'/prefix/1.txt', '/prefix/2.txt'}
- assert set(rs.iterkeys(prefix='/prefix/', strip_prefix=True)) == {'1.txt', '2.txt'}
- assert set(rs.iteritems(prefix='/prefix')) == {
- ('/prefix/1.txt', text),
- ('/prefix/2.txt', text),
- }
- assert set(rs.iteritems(prefix='/prefix', strip_prefix=True)) == {
- ('/1.txt', text),
- ('/2.txt', text),
- }
+ assert rs.find('/qw.txt') == text
+
+
+def test_iter():
+ assert set(rs.iterkeys()).issuperset({'/qw.txt', '/prefix/1.txt', '/prefix/2.txt'})
+ assert set(rs.iterkeys(prefix='/prefix/')) == {'/prefix/1.txt', '/prefix/2.txt'}
+ assert set(rs.iterkeys(prefix='/prefix/', strip_prefix=True)) == {'1.txt', '2.txt'}
+ assert set(rs.iteritems(prefix='/prefix')) == {
+ ('/prefix/1.txt', text),
+ ('/prefix/2.txt', text),
+ }
+ assert set(rs.iteritems(prefix='/prefix', strip_prefix=True)) == {
+ ('/1.txt', text),
+ ('/2.txt', text),
+ }
def test_resfs_files():
diff --git a/library/python/resource/ut/lib/ya.make b/library/python/resource/ut/lib/ya.make
index 5019adb9f7..693e388878 100644
--- a/library/python/resource/ut/lib/ya.make
+++ b/library/python/resource/ut/lib/ya.make
@@ -1,4 +1,4 @@
-PY23_LIBRARY()
+PY23_LIBRARY()
OWNER(pg)
diff --git a/library/python/resource/ut/py2/ya.make b/library/python/resource/ut/py2/ya.make
index 52028b5f4e..5085610faf 100644
--- a/library/python/resource/ut/py2/ya.make
+++ b/library/python/resource/ut/py2/ya.make
@@ -3,7 +3,7 @@ PY2TEST()
OWNER(pg)
PEERDIR(
- library/python/resource/ut/lib
+ library/python/resource/ut/lib
)
END()
diff --git a/library/python/resource/ut/py3/ya.make b/library/python/resource/ut/py3/ya.make
index bcd5b141b5..64eb2e83ce 100644
--- a/library/python/resource/ut/py3/ya.make
+++ b/library/python/resource/ut/py3/ya.make
@@ -1,9 +1,9 @@
PY3TEST()
-OWNER(pg)
+OWNER(pg)
PEERDIR(
- library/python/resource/ut/lib
+ library/python/resource/ut/lib
)
END()
diff --git a/library/python/resource/ya.make b/library/python/resource/ya.make
index 7e5af9a55e..989329fa4b 100644
--- a/library/python/resource/ya.make
+++ b/library/python/resource/ya.make
@@ -2,10 +2,10 @@ PY23_LIBRARY()
OWNER(pg)
-PEERDIR(
- contrib/python/six
-)
-
+PEERDIR(
+ contrib/python/six
+)
+
PY_SRCS(__init__.py)
END()