aboutsummaryrefslogtreecommitdiffstats
path: root/library/python
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2023-08-27 11:12:59 +0300
committershadchin <shadchin@yandex-team.com>2023-08-27 11:26:27 +0300
commit8cfc0792df1b972b7dcd1a27120102b52c80119a (patch)
tree49b6fa122abd66afbc23ead8664e9e89b54009fa /library/python
parent53e534d6b6d324487d4958e0789d00ed76438102 (diff)
downloadydb-8cfc0792df1b972b7dcd1a27120102b52c80119a.tar.gz
Put library/python/resource under ya style
Diffstat (limited to 'library/python')
-rw-r--r--library/python/resource/__init__.py20
-rw-r--r--library/python/resource/ut/lib/test_simple.py31
-rw-r--r--library/python/resource/ut/lib/ya.make15
-rw-r--r--library/python/resource/ut/py2/ya.make7
-rw-r--r--library/python/resource/ut/py3/ya.make7
-rw-r--r--library/python/resource/ut/qw.txt (renamed from library/python/resource/ut/lib/qw.txt)0
-rw-r--r--library/python/resource/ut/test_simple.py31
-rw-r--r--library/python/resource/ut/ya.make19
-rw-r--r--library/python/resource/ya.make2
9 files changed, 59 insertions, 73 deletions
diff --git a/library/python/resource/__init__.py b/library/python/resource/__init__.py
index 26503ef7fc..751186b200 100644
--- a/library/python/resource/__init__.py
+++ b/library/python/resource/__init__.py
@@ -4,31 +4,31 @@ from __res import resfs_read, resfs_resolve, resfs_src # noqa
import six
-def iterkeys(prefix='', strip_prefix=False):
+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')
+ 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):]
+ key = key[len(prefix) :]
yield decode(key)
-def itervalues(prefix=b''):
+def itervalues(prefix=b""):
for key in iterkeys(prefix=prefix):
value = find(key)
yield value
-def iteritems(prefix='', strip_prefix=False):
+def iteritems(prefix="", strip_prefix=False):
for key in iterkeys(prefix=prefix):
value = find(key)
if strip_prefix:
- key = key[len(prefix):]
+ key = key[len(prefix) :]
yield key, value
@@ -36,14 +36,14 @@ def resfs_file_exists(path):
return resfs_src(path, resfs_file=True) is not None
-def resfs_files(prefix=''):
+def resfs_files(prefix=""):
decode = lambda s: s
if isinstance(prefix, six.text_type):
- decode = lambda s: s.decode('utf-8')
+ decode = lambda s: s.decode("utf-8")
return [decode(s) for s in __resfs_files(prefix=prefix)]
def find(path):
if isinstance(path, six.text_type):
- path = path.encode('utf-8')
+ path = path.encode("utf-8")
return __find(path)
diff --git a/library/python/resource/ut/lib/test_simple.py b/library/python/resource/ut/lib/test_simple.py
deleted file mode 100644
index 52f006ff91..0000000000
--- a/library/python/resource/ut/lib/test_simple.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import six # noqa
-
-import library.python.resource as rs
-
-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),
- }
-
-
-def test_resfs_files():
- assert 'contrib/python/py/.dist-info/METADATA' in set(rs.resfs_files())
-
-
-def test_resfs_read():
- assert 'Metadata-Version' in rs.resfs_read('contrib/python/py/.dist-info/METADATA').decode('utf-8')
diff --git a/library/python/resource/ut/lib/ya.make b/library/python/resource/ut/lib/ya.make
deleted file mode 100644
index f5e28cad29..0000000000
--- a/library/python/resource/ut/lib/ya.make
+++ /dev/null
@@ -1,15 +0,0 @@
-PY23_LIBRARY()
-
-TEST_SRCS(test_simple.py)
-
-PEERDIR(
- library/python/resource
-)
-
-RESOURCE(
- qw.txt /qw.txt
- qw.txt /prefix/1.txt
- qw.txt /prefix/2.txt
-)
-
-END()
diff --git a/library/python/resource/ut/py2/ya.make b/library/python/resource/ut/py2/ya.make
deleted file mode 100644
index 073e4a68ac..0000000000
--- a/library/python/resource/ut/py2/ya.make
+++ /dev/null
@@ -1,7 +0,0 @@
-PY2TEST()
-
-PEERDIR(
- library/python/resource/ut/lib
-)
-
-END()
diff --git a/library/python/resource/ut/py3/ya.make b/library/python/resource/ut/py3/ya.make
deleted file mode 100644
index 6525628592..0000000000
--- a/library/python/resource/ut/py3/ya.make
+++ /dev/null
@@ -1,7 +0,0 @@
-PY3TEST()
-
-PEERDIR(
- library/python/resource/ut/lib
-)
-
-END()
diff --git a/library/python/resource/ut/lib/qw.txt b/library/python/resource/ut/qw.txt
index 50e37d5cac..50e37d5cac 100644
--- a/library/python/resource/ut/lib/qw.txt
+++ b/library/python/resource/ut/qw.txt
diff --git a/library/python/resource/ut/test_simple.py b/library/python/resource/ut/test_simple.py
new file mode 100644
index 0000000000..28c68366cf
--- /dev/null
+++ b/library/python/resource/ut/test_simple.py
@@ -0,0 +1,31 @@
+import six # noqa
+
+import library.python.resource as rs
+
+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),
+ }
+
+
+def test_resfs_files():
+ assert "contrib/python/py/.dist-info/METADATA" in set(rs.resfs_files())
+
+
+def test_resfs_read():
+ assert "Metadata-Version" in rs.resfs_read("contrib/python/py/.dist-info/METADATA").decode("utf-8")
diff --git a/library/python/resource/ut/ya.make b/library/python/resource/ut/ya.make
index 4cedc9fb3e..fb625af78b 100644
--- a/library/python/resource/ut/ya.make
+++ b/library/python/resource/ut/ya.make
@@ -1,4 +1,17 @@
-RECURSE(
- py2
- py3
+PY23_TEST()
+
+STYLE_PYTHON()
+
+TEST_SRCS(test_simple.py)
+
+PEERDIR(
+ library/python/resource
)
+
+RESOURCE(
+ qw.txt /qw.txt
+ qw.txt /prefix/1.txt
+ qw.txt /prefix/2.txt
+)
+
+END()
diff --git a/library/python/resource/ya.make b/library/python/resource/ya.make
index 2642f0b42b..4f4ff96ad3 100644
--- a/library/python/resource/ya.make
+++ b/library/python/resource/ya.make
@@ -1,5 +1,7 @@
PY23_LIBRARY()
+STYLE_PYTHON()
+
PEERDIR(
contrib/python/six
)