aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authordvshkurko <dvshkurko@yandex-team.ru>2022-02-10 16:45:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:52 +0300
commitc768a99151e47c3a4bb7b92c514d256abd301c4d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library
parent321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff)
downloadydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
-rw-r--r--library/cpp/grpc/client/grpc_client_low.h4
-rw-r--r--library/cpp/grpc/server/grpc_request.h4
-rw-r--r--library/cpp/svnversion/svn_interface.c2
-rw-r--r--library/cpp/svnversion/svnversion.h8
-rw-r--r--library/cpp/svnversion/test/main.cpp56
-rw-r--r--library/cpp/svnversion/test/ya.make6
-rw-r--r--library/cpp/svnversion/ya.make8
-rw-r--r--library/python/fs/__init__.py54
-rw-r--r--library/python/fs/test/test_fs.py46
-rw-r--r--library/python/fs/test/ya.make2
-rw-r--r--library/python/pytest/plugins/ya.py52
-rw-r--r--library/python/runtime_py3/importer.pxi2
-rw-r--r--library/python/strings/strings.py54
-rw-r--r--library/python/strings/ut/test_strings.py58
-rw-r--r--library/python/strings/ut/ya.make2
-rw-r--r--library/python/strings/ya.make2
-rw-r--r--library/python/svn_version/__init__.py2
-rw-r--r--library/python/svn_version/__svn_version.pyx24
-rw-r--r--library/python/svn_version/ut/lib/test_simple.py14
-rw-r--r--library/python/symbols/libc/syms.cpp4
-rw-r--r--library/python/testing/yatest_common/ya.make2
-rw-r--r--library/python/testing/yatest_common/yatest/common/path.py60
-rw-r--r--library/python/testing/yatest_common/yatest/common/runtime.py18
23 files changed, 242 insertions, 242 deletions
diff --git a/library/cpp/grpc/client/grpc_client_low.h b/library/cpp/grpc/client/grpc_client_low.h
index f7aba62b69..ab0a0627be 100644
--- a/library/cpp/grpc/client/grpc_client_low.h
+++ b/library/cpp/grpc/client/grpc_client_low.h
@@ -4,8 +4,8 @@
#include <util/thread/factory.h>
#include <grpc++/grpc++.h>
-#include <grpc++/support/async_stream.h>
-#include <grpc++/support/async_unary_call.h>
+#include <grpc++/support/async_stream.h>
+#include <grpc++/support/async_unary_call.h>
#include <deque>
#include <typeindex>
diff --git a/library/cpp/grpc/server/grpc_request.h b/library/cpp/grpc/server/grpc_request.h
index ea48222562..5bd8d3902b 100644
--- a/library/cpp/grpc/server/grpc_request.h
+++ b/library/cpp/grpc/server/grpc_request.h
@@ -19,8 +19,8 @@
#include <grpc++/server.h>
#include <grpc++/server_context.h>
-#include <grpc++/support/async_stream.h>
-#include <grpc++/support/async_unary_call.h>
+#include <grpc++/support/async_stream.h>
+#include <grpc++/support/async_unary_call.h>
#include <grpc++/support/byte_buffer.h>
#include <grpc++/impl/codegen/async_stream.h>
diff --git a/library/cpp/svnversion/svn_interface.c b/library/cpp/svnversion/svn_interface.c
index c3e2f7bb9c..12884956b1 100644
--- a/library/cpp/svnversion/svn_interface.c
+++ b/library/cpp/svnversion/svn_interface.c
@@ -1 +1 @@
-// See build/scripts/c_templates/svn_interface.c instead.
+// See build/scripts/c_templates/svn_interface.c instead.
diff --git a/library/cpp/svnversion/svnversion.h b/library/cpp/svnversion/svnversion.h
index 6beae68969..b99615daa9 100644
--- a/library/cpp/svnversion/svnversion.h
+++ b/library/cpp/svnversion/svnversion.h
@@ -7,7 +7,7 @@
#define PRINT_VERSION_EX(opts) PrintSvnVersionAndExitEx(argc, (char**)argv, opts)
#endif
-#include <util/system/compiler.h>
-
-// Automatically generated functions.
-#include "build/scripts/c_templates/svnversion.h"
+#include <util/system/compiler.h>
+
+// Automatically generated functions.
+#include "build/scripts/c_templates/svnversion.h"
diff --git a/library/cpp/svnversion/test/main.cpp b/library/cpp/svnversion/test/main.cpp
index 916e4ef6ca..3c8209047f 100644
--- a/library/cpp/svnversion/test/main.cpp
+++ b/library/cpp/svnversion/test/main.cpp
@@ -1,30 +1,30 @@
-#include <build/scripts/c_templates/svnversion.h>
-#include <util/stream/str.h>
-#include <util/system/compiler.h>
-#include <util/stream/output.h>
-
+#include <build/scripts/c_templates/svnversion.h>
+#include <util/stream/str.h>
+#include <util/system/compiler.h>
+#include <util/stream/output.h>
+
// ya make -DFORCE_VCS_INFO_UPDATE --vcs-file=<vcs.json> library/cpp/svnversion/test/
-// ./library/svnversion/test/test[.exe]
-int main() {
- Cout << "GetProgramSvnVersion(): " << GetProgramSvnVersion() << Endl;
- Cout << "PrintProgramSvnVersion(): " << Endl; PrintProgramSvnVersion();
- Cout << "GetArcadiaSourcePath(): " << GetArcadiaSourcePath() << Endl;
- Cout << "GetArcadiaSourceUrl(): " << GetArcadiaSourceUrl() << Endl;
- Cout << "GetArcadiaLastChange(): " << GetArcadiaLastChange() << Endl;
- Cout << "GetArcadiaLastChangeNum(): " << GetArcadiaLastChangeNum() << Endl;
- Cout << "GetArcadiaLastAuthor(): " << GetArcadiaLastAuthor() << Endl;
- Cout << "GetProgramSvnRevision(): " << GetProgramSvnRevision() << Endl;
- Cout << "GetProgramHash(): " << GetProgramHash() << Endl;
- Cout << "GetProgramCommitId(): " << GetProgramCommitId() << Endl;
- Cout << "GetProgramScmData(): " << GetProgramScmData() << Endl;
- Cout << "GetProgramBuildUser(): " << GetProgramBuildUser() << Endl;
- Cout << "GetProgramBuildHost(): " << GetProgramBuildHost() << Endl;
- Cout << "GetProgramBuildDate(): " << GetProgramBuildDate() << Endl;
- Cout << "GetVCS(): " << GetVCS() << Endl;
- Cout << "GetBranch(): " << GetBranch() << Endl;
- Cout << "GetTag(): " << GetTag() << Endl;
- Cout << "GetArcadiaPatchNumber(): " << GetArcadiaPatchNumber() << Endl;
+// ./library/svnversion/test/test[.exe]
+int main() {
+ Cout << "GetProgramSvnVersion(): " << GetProgramSvnVersion() << Endl;
+ Cout << "PrintProgramSvnVersion(): " << Endl; PrintProgramSvnVersion();
+ Cout << "GetArcadiaSourcePath(): " << GetArcadiaSourcePath() << Endl;
+ Cout << "GetArcadiaSourceUrl(): " << GetArcadiaSourceUrl() << Endl;
+ Cout << "GetArcadiaLastChange(): " << GetArcadiaLastChange() << Endl;
+ Cout << "GetArcadiaLastChangeNum(): " << GetArcadiaLastChangeNum() << Endl;
+ Cout << "GetArcadiaLastAuthor(): " << GetArcadiaLastAuthor() << Endl;
+ Cout << "GetProgramSvnRevision(): " << GetProgramSvnRevision() << Endl;
+ Cout << "GetProgramHash(): " << GetProgramHash() << Endl;
+ Cout << "GetProgramCommitId(): " << GetProgramCommitId() << Endl;
+ Cout << "GetProgramScmData(): " << GetProgramScmData() << Endl;
+ Cout << "GetProgramBuildUser(): " << GetProgramBuildUser() << Endl;
+ Cout << "GetProgramBuildHost(): " << GetProgramBuildHost() << Endl;
+ Cout << "GetProgramBuildDate(): " << GetProgramBuildDate() << Endl;
+ Cout << "GetVCS(): " << GetVCS() << Endl;
+ Cout << "GetBranch(): " << GetBranch() << Endl;
+ Cout << "GetTag(): " << GetTag() << Endl;
+ Cout << "GetArcadiaPatchNumber(): " << GetArcadiaPatchNumber() << Endl;
Cout << "GetVCSDirty(): " << GetVCSDirty() << Endl;
- return 0;
-}
-
+ return 0;
+}
+
diff --git a/library/cpp/svnversion/test/ya.make b/library/cpp/svnversion/test/ya.make
index 38649c24e7..59c0a2d970 100644
--- a/library/cpp/svnversion/test/ya.make
+++ b/library/cpp/svnversion/test/ya.make
@@ -1,6 +1,6 @@
OWNER(g:cpp-contrib)
-PROGRAM()
+PROGRAM()
PEERDIR(library/cpp/svnversion)
-SRCS(main.cpp)
-END()
+SRCS(main.cpp)
+END()
diff --git a/library/cpp/svnversion/ya.make b/library/cpp/svnversion/ya.make
index c6880e172a..04e1a4c4fd 100644
--- a/library/cpp/svnversion/ya.make
+++ b/library/cpp/svnversion/ya.make
@@ -4,9 +4,9 @@ LIBRARY()
SRCS(
svnversion.cpp
- svn_interface.c
+ svn_interface.c
)
END()
-RECURSE(
- test
-)
+RECURSE(
+ test
+)
diff --git a/library/python/fs/__init__.py b/library/python/fs/__init__.py
index 3c596f0e42..b1b7cde079 100644
--- a/library/python/fs/__init__.py
+++ b/library/python/fs/__init__.py
@@ -6,7 +6,7 @@ import logging
import os
import random
import shutil
-import six
+import six
import stat
import sys
@@ -128,7 +128,7 @@ def remove_dir(path):
def fix_path_encoding(path):
- return library.python.strings.to_str(path, library.python.strings.fs_encoding())
+ return library.python.strings.to_str(path, library.python.strings.fs_encoding())
# File/directory remove
@@ -201,7 +201,7 @@ def hardlink_or_copy(src, lnk):
def should_fallback_to_copy(exc):
if WindowsError is not None and isinstance(exc, WindowsError) and exc.winerror == 1142: # too many hardlinks
return True
- # cross-device hardlink or too many hardlinks, or some known WSL error
+ # cross-device hardlink or too many hardlinks, or some known WSL error
if isinstance(exc, OSError) and exc.errno in (
errno.EXDEV,
errno.EMLINK,
@@ -217,7 +217,7 @@ def hardlink_or_copy(src, lnk):
except Exception as e:
logger.debug('Failed to hardlink %s to %s with error %s, will copy it', src, lnk, repr(e))
if should_fallback_to_copy(e):
- copy2(src, lnk, follow_symlinks=False)
+ copy2(src, lnk, follow_symlinks=False)
else:
raise
@@ -234,19 +234,19 @@ def symlink(src, lnk):
os.symlink(src, lnk)
-# shutil.copy2 with follow_symlinks=False parameter (Unix only)
-def copy2(src, lnk, follow_symlinks=True):
- if six.PY3:
- shutil.copy2(src, lnk, follow_symlinks=follow_symlinks)
- return
-
- if follow_symlinks or not os.path.islink(src):
- shutil.copy2(src, lnk)
- return
-
- symlink(os.readlink(src), lnk)
-
-
+# shutil.copy2 with follow_symlinks=False parameter (Unix only)
+def copy2(src, lnk, follow_symlinks=True):
+ if six.PY3:
+ shutil.copy2(src, lnk, follow_symlinks=follow_symlinks)
+ return
+
+ if follow_symlinks or not os.path.islink(src):
+ shutil.copy2(src, lnk)
+ return
+
+ symlink(os.readlink(src), lnk)
+
+
# Recursively hardlink directory
# Uses plain hardlink for files
# Dst must not exist
@@ -299,12 +299,12 @@ def read_file(path, binary=True):
@errorfix_win
def read_file_unicode(path, binary=True, enc='utf-8'):
if not binary:
- if six.PY2:
- with open(path, 'r') as f:
- return library.python.strings.to_unicode(f.read(), enc)
- else:
- with open(path, 'r', encoding=enc) as f:
- return f.read()
+ if six.PY2:
+ with open(path, 'r') as f:
+ return library.python.strings.to_unicode(f.read(), enc)
+ else:
+ with open(path, 'r', encoding=enc) as f:
+ return f.read()
# codecs.open is always binary
with codecs.open(path, 'r', encoding=enc, errors=library.python.strings.ENCODING_ERRORS_POLICY) as f:
return f.read()
@@ -417,9 +417,9 @@ def copytree3(
else:
ignored_names = set()
- if not (dirs_exist_ok and os.path.isdir(dst)):
- os.makedirs(dst)
-
+ if not (dirs_exist_ok and os.path.isdir(dst)):
+ os.makedirs(dst)
+
errors = []
for name in names:
if name in ignored_names:
@@ -441,7 +441,7 @@ def copytree3(
# otherwise let the copy occurs. copy2 will raise an error
copy_function(srcname, dstname)
elif os.path.isdir(srcname):
- copytree3(srcname, dstname, symlinks, ignore, copy_function, dirs_exist_ok=dirs_exist_ok)
+ copytree3(srcname, dstname, symlinks, ignore, copy_function, dirs_exist_ok=dirs_exist_ok)
else:
# Will raise a SpecialFileError for unsupported file types
copy_function(srcname, dstname)
diff --git a/library/python/fs/test/test_fs.py b/library/python/fs/test/test_fs.py
index 00bd7e3d29..9e2c70c069 100644
--- a/library/python/fs/test/test_fs.py
+++ b/library/python/fs/test/test_fs.py
@@ -4,10 +4,10 @@ import errno
import os
import pytest
import shutil
-import six
+import six
import library.python.fs
-import library.python.strings
+import library.python.strings
import library.python.tmp
import library.python.windows
@@ -23,7 +23,7 @@ def in_env(case):
def mkfile(path, data=''):
- with open(path, 'wb') as f:
+ with open(path, 'wb') as f:
if data:
f.write(data) if isinstance(data, six.binary_type) else f.write(
data.encode(library.python.strings.fs_encoding())
@@ -40,8 +40,8 @@ def mktree_example(path, name):
def file_data(path):
- with open(path, 'rb') as f:
- return f.read().decode('utf-8')
+ with open(path, 'rb') as f:
+ return f.read().decode('utf-8')
def serialize_tree(path):
@@ -92,8 +92,8 @@ def test_errorfix_win():
erroneous_func()
assert errinfo.value.errno == errno.EACCES
assert errinfo.value.filename == 'unknown/file'
- # See transcode_error, which encodes strerror, in library/python/windows/__init__.py
- assert isinstance(errinfo.value.strerror, (six.binary_type, six.text_type))
+ # See transcode_error, which encodes strerror, in library/python/windows/__init__.py
+ assert isinstance(errinfo.value.strerror, (six.binary_type, six.text_type))
assert errinfo.value.strerror
@@ -101,8 +101,8 @@ def test_custom_fs_error():
with pytest.raises(OSError) as errinfo:
raise library.python.fs.CustomFsError(errno.EACCES, filename='some/file')
assert errinfo.value.errno == errno.EACCES
- # See transcode_error, which encodes strerror, in library/python/windows/__init__.py
- assert isinstance(errinfo.value.strerror, (six.binary_type, six.text_type))
+ # See transcode_error, which encodes strerror, in library/python/windows/__init__.py
+ assert isinstance(errinfo.value.strerror, (six.binary_type, six.text_type))
assert errinfo.value.filename == 'some/file'
@@ -806,14 +806,14 @@ def test_copy_tree_file_exists(path):
@in_env
def test_read_file(path):
mkfile(path('src'), 'SRC')
- assert library.python.fs.read_file(path('src')).decode(library.python.strings.fs_encoding()) == 'SRC'
+ assert library.python.fs.read_file(path('src')).decode(library.python.strings.fs_encoding()) == 'SRC'
assert library.python.fs.read_file(path('src'), binary=False) == 'SRC'
@in_env
def test_read_file_empty(path):
mkfile(path('src'))
- assert library.python.fs.read_file(path('src')).decode(library.python.strings.fs_encoding()) == ''
+ assert library.python.fs.read_file(path('src')).decode(library.python.strings.fs_encoding()) == ''
assert library.python.fs.read_file(path('src'), binary=False) == ''
@@ -834,7 +834,7 @@ def test_read_file_multiline_crlf(path):
library.python.fs.read_file(path('src')).decode(library.python.strings.fs_encoding())
== 'SRC line 1\r\nSRC line 2\r\n'
)
- if library.python.windows.on_win() or six.PY3: # universal newlines are by default in text mode in python3
+ if library.python.windows.on_win() or six.PY3: # universal newlines are by default in text mode in python3
assert library.python.fs.read_file(path('src'), binary=False) == 'SRC line 1\nSRC line 2\n'
else:
assert library.python.fs.read_file(path('src'), binary=False) == 'SRC line 1\r\nSRC line 2\r\n'
@@ -879,7 +879,7 @@ def test_read_file_unicode_multiline_crlf(path):
mkfile(path('src_cp1251'), s.encode('cp1251'))
assert library.python.fs.read_file_unicode(path('src')) == s
assert library.python.fs.read_file_unicode(path('src_cp1251'), enc='cp1251') == s
- if library.python.windows.on_win() or six.PY3: # universal newlines are by default in text mode in python3
+ if library.python.windows.on_win() or six.PY3: # universal newlines are by default in text mode in python3
assert library.python.fs.read_file_unicode(path('src'), binary=False) == u'АБВ\nИ еще\n'
assert library.python.fs.read_file_unicode(path('src_cp1251'), binary=False, enc='cp1251') == u'АБВ\nИ еще\n'
else:
@@ -984,14 +984,14 @@ def test_hardlink_or_copy():
def test_remove_tree_unicode():
path = u"test_remove_tree_unicode/русский".encode("utf-8")
os.makedirs(path)
- library.python.fs.remove_tree(six.text_type("test_remove_tree_unicode"))
+ library.python.fs.remove_tree(six.text_type("test_remove_tree_unicode"))
assert not os.path.exists("test_remove_tree_unicode")
def test_remove_tree_safe_unicode():
path = u"test_remove_tree_safe_unicode/русский".encode("utf-8")
os.makedirs(path)
- library.python.fs.remove_tree_safe(six.text_type("test_remove_tree_safe_unicode"))
+ library.python.fs.remove_tree_safe(six.text_type("test_remove_tree_safe_unicode"))
assert not os.path.exists("test_remove_tree_safe_unicode")
@@ -1011,14 +1011,14 @@ def test_copy_tree_custom_copy_function():
assert len(copied) == 2
assert yatest.common.work_path("test_copy_tree_dst/deepper/deepper.txt") in copied
assert yatest.common.work_path("test_copy_tree_dst/deepper/inner/inner.txt") in copied
-
-
-def test_copy2():
- library.python.fs.symlink("non-existent", "link")
- library.python.fs.copy2("link", "link2", follow_symlinks=False)
-
- assert os.path.islink("link2")
- assert os.readlink("link2") == "non-existent"
+
+
+def test_copy2():
+ library.python.fs.symlink("non-existent", "link")
+ library.python.fs.copy2("link", "link2", follow_symlinks=False)
+
+ assert os.path.islink("link2")
+ assert os.readlink("link2") == "non-existent"
def test_commonpath():
diff --git a/library/python/fs/test/ya.make b/library/python/fs/test/ya.make
index b0e636c446..33e3f5b4ff 100644
--- a/library/python/fs/test/ya.make
+++ b/library/python/fs/test/ya.make
@@ -1,6 +1,6 @@
OWNER(g:yatool)
-PY23_TEST()
+PY23_TEST()
TEST_SRCS(
test_fs.py
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index 60bb08cfeb..1bde03042d 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -98,31 +98,31 @@ class YaTestLoggingFileHandler(logging.FileHandler):
pass
-class _TokenFilterFormatter(logging.Formatter):
- def __init__(self, fmt):
- super(_TokenFilterFormatter, self).__init__(fmt)
- self._replacements = []
- if not self._replacements:
- if six.PY2:
- for k, v in os.environ.iteritems():
- if k.endswith('TOKEN') and v:
- self._replacements.append(v)
- elif six.PY3:
- for k, v in os.environ.items():
- if k.endswith('TOKEN') and v:
- self._replacements.append(v)
- self._replacements = sorted(self._replacements)
-
- def _filter(self, s):
- for r in self._replacements:
- s = s.replace(r, "[SECRET]")
-
- return s
-
- def format(self, record):
- return self._filter(super(_TokenFilterFormatter, self).format(record))
-
-
+class _TokenFilterFormatter(logging.Formatter):
+ def __init__(self, fmt):
+ super(_TokenFilterFormatter, self).__init__(fmt)
+ self._replacements = []
+ if not self._replacements:
+ if six.PY2:
+ for k, v in os.environ.iteritems():
+ if k.endswith('TOKEN') and v:
+ self._replacements.append(v)
+ elif six.PY3:
+ for k, v in os.environ.items():
+ if k.endswith('TOKEN') and v:
+ self._replacements.append(v)
+ self._replacements = sorted(self._replacements)
+
+ def _filter(self, s):
+ for r in self._replacements:
+ s = s.replace(r, "[SECRET]")
+
+ return s
+
+ def format(self, record):
+ return self._filter(super(_TokenFilterFormatter, self).format(record))
+
+
def setup_logging(log_path, level=logging.DEBUG, *other_logs):
logs = [log_path] + list(other_logs)
root_logger = logging.getLogger()
@@ -133,7 +133,7 @@ def setup_logging(log_path, level=logging.DEBUG, *other_logs):
for log_file in logs:
file_handler = YaTestLoggingFileHandler(log_file)
log_format = '%(asctime)s - %(levelname)s - %(name)s - %(funcName)s: %(message)s'
- file_handler.setFormatter(_TokenFilterFormatter(log_format))
+ file_handler.setFormatter(_TokenFilterFormatter(log_format))
file_handler.setLevel(level)
root_logger.addHandler(file_handler)
diff --git a/library/python/runtime_py3/importer.pxi b/library/python/runtime_py3/importer.pxi
index e352bced50..904f94dea2 100644
--- a/library/python/runtime_py3/importer.pxi
+++ b/library/python/runtime_py3/importer.pxi
@@ -234,7 +234,7 @@ class ResourceImporter(object):
abspath = resfs_resolve(path)
if abspath:
return file_bytes(abspath)
- path = path.replace(_b('\\'), _b('/'))
+ path = path.replace(_b('\\'), _b('/'))
data = resfs_read(path, builtin=True)
if data is None:
raise IOError(path) # Y_PYTHON_ENTRY_POINT=:resource_files
diff --git a/library/python/strings/strings.py b/library/python/strings/strings.py
index 2e018ae038..5bfddfe78a 100644
--- a/library/python/strings/strings.py
+++ b/library/python/strings/strings.py
@@ -1,6 +1,6 @@
import locale
import logging
-import six
+import six
import sys
import codecs
@@ -23,15 +23,15 @@ def left_strip(el, prefix):
# Explicit to-text conversion
-# Chooses between str/unicode, i.e. six.binary_type/six.text_type
+# Chooses between str/unicode, i.e. six.binary_type/six.text_type
def to_basestring(value):
- if isinstance(value, (six.binary_type, six.text_type)):
+ if isinstance(value, (six.binary_type, six.text_type)):
return value
try:
- if six.PY2:
- return unicode(value)
- else:
- return str(value)
+ if six.PY2:
+ return unicode(value)
+ else:
+ return str(value)
except UnicodeDecodeError:
try:
return str(value)
@@ -41,35 +41,35 @@ to_text = to_basestring
def to_unicode(value, from_enc=DEFAULT_ENCODING):
- if isinstance(value, six.text_type):
+ if isinstance(value, six.text_type):
return value
- if isinstance(value, six.binary_type):
- if six.PY2:
- return unicode(value, from_enc, ENCODING_ERRORS_POLICY)
- else:
- return value.decode(from_enc, errors=ENCODING_ERRORS_POLICY)
- return six.text_type(value)
+ if isinstance(value, six.binary_type):
+ if six.PY2:
+ return unicode(value, from_enc, ENCODING_ERRORS_POLICY)
+ else:
+ return value.decode(from_enc, errors=ENCODING_ERRORS_POLICY)
+ return six.text_type(value)
# Optional from_enc enables transcoding
def to_str(value, to_enc=DEFAULT_ENCODING, from_enc=None):
- if isinstance(value, six.binary_type):
+ if isinstance(value, six.binary_type):
if from_enc is None or to_enc == from_enc:
# Unknown input encoding or input and output encoding are the same
return value
value = to_unicode(value, from_enc=from_enc)
- if isinstance(value, six.text_type):
+ if isinstance(value, six.text_type):
return value.encode(to_enc, ENCODING_ERRORS_POLICY)
- return six.binary_type(value)
+ return six.binary_type(value)
def _convert_deep(x, enc, convert, relaxed=True):
if x is None:
return None
- if isinstance(x, (six.text_type, six.binary_type)):
+ if isinstance(x, (six.text_type, six.binary_type)):
return convert(x, enc)
if isinstance(x, dict):
- return {convert(k, enc): _convert_deep(v, enc, convert, relaxed) for k, v in six.iteritems(x)}
+ return {convert(k, enc): _convert_deep(v, enc, convert, relaxed) for k, v in six.iteritems(x)}
if isinstance(x, list):
return [_convert_deep(e, enc, convert, relaxed) for e in x]
if isinstance(x, tuple):
@@ -91,13 +91,13 @@ def stringize_deep(x, enc=DEFAULT_ENCODING, relaxed=True):
@library.python.func.memoize()
def locale_encoding():
try:
- loc = locale.getdefaultlocale()[1]
- if loc:
- codecs.lookup(loc)
- return loc
- except LookupError as e:
- logger.debug('Cannot get system locale: %s', e)
- return None
+ loc = locale.getdefaultlocale()[1]
+ if loc:
+ codecs.lookup(loc)
+ return loc
+ except LookupError as e:
+ logger.debug('Cannot get system locale: %s', e)
+ return None
except ValueError as e:
logger.warn('Cannot get system locale: %s', e)
return None
@@ -124,6 +124,6 @@ def get_stream_encoding(stream):
def encode(value, encoding=DEFAULT_ENCODING):
- if isinstance(value, six.binary_type):
+ if isinstance(value, six.binary_type):
value = value.decode(encoding, errors='ignore')
return value.encode(encoding)
diff --git a/library/python/strings/ut/test_strings.py b/library/python/strings/ut/test_strings.py
index 9a862ed060..dd0c694ee1 100644
--- a/library/python/strings/ut/test_strings.py
+++ b/library/python/strings/ut/test_strings.py
@@ -1,7 +1,7 @@
# coding=utf-8
import pytest
-import six
+import six
import library.python.strings
@@ -34,11 +34,11 @@ class NonConvertible(ConvertibleToUnicodeOnly, ConvertibleToStrOnly):
def test_to_basestring():
assert library.python.strings.to_basestring('str') == 'str'
assert library.python.strings.to_basestring(u'юникод') == u'юникод'
- if six.PY2: # __str__ should return str not bytes in Python3
- assert library.python.strings.to_basestring(Convertible()) == Convertible.text
- assert library.python.strings.to_basestring(ConvertibleToUnicodeOnly()) == Convertible.text
- assert library.python.strings.to_basestring(ConvertibleToStrOnly()) == Convertible.text_utf8
- assert library.python.strings.to_basestring(NonConvertible())
+ if six.PY2: # __str__ should return str not bytes in Python3
+ assert library.python.strings.to_basestring(Convertible()) == Convertible.text
+ assert library.python.strings.to_basestring(ConvertibleToUnicodeOnly()) == Convertible.text
+ assert library.python.strings.to_basestring(ConvertibleToStrOnly()) == Convertible.text_utf8
+ assert library.python.strings.to_basestring(NonConvertible())
def test_to_unicode():
@@ -46,13 +46,13 @@ def test_to_unicode():
assert library.python.strings.to_unicode('str') == u'str'
assert library.python.strings.to_unicode(u'строка'.encode('utf-8')) == u'строка'
assert library.python.strings.to_unicode(u'строка'.encode('cp1251'), 'cp1251') == u'строка'
- if six.PY2: # __str__ should return str not bytes in Python3
- assert library.python.strings.to_unicode(Convertible()) == Convertible.text
- assert library.python.strings.to_unicode(ConvertibleToUnicodeOnly()) == Convertible.text
- with pytest.raises(UnicodeDecodeError):
- library.python.strings.to_unicode(ConvertibleToStrOnly())
- with pytest.raises(UnicodeDecodeError):
- library.python.strings.to_unicode(NonConvertible())
+ if six.PY2: # __str__ should return str not bytes in Python3
+ assert library.python.strings.to_unicode(Convertible()) == Convertible.text
+ assert library.python.strings.to_unicode(ConvertibleToUnicodeOnly()) == Convertible.text
+ with pytest.raises(UnicodeDecodeError):
+ library.python.strings.to_unicode(ConvertibleToStrOnly())
+ with pytest.raises(UnicodeDecodeError):
+ library.python.strings.to_unicode(NonConvertible())
def test_to_unicode_errors_replace():
@@ -61,17 +61,17 @@ def test_to_unicode_errors_replace():
def test_to_str():
- assert library.python.strings.to_str('str') == 'str' if six.PY2 else b'str'
- assert library.python.strings.to_str(u'unicode') == 'unicode' if six.PY2 else b'unicode'
+ assert library.python.strings.to_str('str') == 'str' if six.PY2 else b'str'
+ assert library.python.strings.to_str(u'unicode') == 'unicode' if six.PY2 else b'unicode'
assert library.python.strings.to_str(u'юникод') == u'юникод'.encode('utf-8')
assert library.python.strings.to_str(u'юникод', 'cp1251') == u'юникод'.encode('cp1251')
- if six.PY2:
- assert library.python.strings.to_str(Convertible()) == Convertible.text_utf8
- with pytest.raises(UnicodeEncodeError):
- library.python.strings.to_str(ConvertibleToUnicodeOnly())
- assert library.python.strings.to_str(ConvertibleToStrOnly()) == Convertible.text_utf8
- with pytest.raises(UnicodeEncodeError):
- library.python.strings.to_str(NonConvertible())
+ if six.PY2:
+ assert library.python.strings.to_str(Convertible()) == Convertible.text_utf8
+ with pytest.raises(UnicodeEncodeError):
+ library.python.strings.to_str(ConvertibleToUnicodeOnly())
+ assert library.python.strings.to_str(ConvertibleToStrOnly()) == Convertible.text_utf8
+ with pytest.raises(UnicodeEncodeError):
+ library.python.strings.to_str(NonConvertible())
def test_to_str_errors_replace():
@@ -80,8 +80,8 @@ def test_to_str_errors_replace():
def test_to_str_transcode():
- assert library.python.strings.to_str('str', from_enc='ascii') == 'str' if six.PY2 else b'str'
- assert library.python.strings.to_str('str', from_enc='utf-8') == 'str' if six.PY2 else b'str'
+ assert library.python.strings.to_str('str', from_enc='ascii') == 'str' if six.PY2 else b'str'
+ assert library.python.strings.to_str('str', from_enc='utf-8') == 'str' if six.PY2 else b'str'
assert library.python.strings.to_str(u'юникод'.encode('utf-8'), from_enc='utf-8') == u'юникод'.encode('utf-8')
assert library.python.strings.to_str(u'юникод'.encode('utf-8'), to_enc='utf-8', from_enc='utf-8') == u'юникод'.encode('utf-8')
@@ -117,9 +117,9 @@ def test_stringize_deep():
u'ключ 2': u'значение 2',
'list': [u'ключ 2', 'key 1', (u'к', 2)]
}) == {
- 'key 1' if six.PY2 else b'key 1': 'value 1' if six.PY2 else b'value 1',
+ 'key 1' if six.PY2 else b'key 1': 'value 1' if six.PY2 else b'value 1',
u'ключ 2'.encode('utf-8'): u'значение 2'.encode('utf-8'),
- 'list' if six.PY2 else b'list': [u'ключ 2'.encode('utf-8'), 'key 1' if six.PY2 else b'key 1', (u'к'.encode('utf-8'), 2)]
+ 'list' if six.PY2 else b'list': [u'ключ 2'.encode('utf-8'), 'key 1' if six.PY2 else b'key 1', (u'к'.encode('utf-8'), 2)]
}
@@ -141,16 +141,16 @@ def test_stringize_deep_nested():
u'подключ 2': u'value 2',
},
}) == {
- 'key 1' if six.PY2 else b'key 1': 'value 1' if six.PY2 else b'value 1',
+ 'key 1' if six.PY2 else b'key 1': 'value 1' if six.PY2 else b'value 1',
u'ключ 2'.encode('utf-8'): {
- 'subkey 1' if six.PY2 else b'subkey 1': 'value 1' if six.PY2 else b'value 1',
+ 'subkey 1' if six.PY2 else b'subkey 1': 'value 1' if six.PY2 else b'value 1',
u'подключ 2'.encode('utf-8'): u'value 2'.encode('utf-8'),
},
}
def test_stringize_deep_plain():
- assert library.python.strings.stringize_deep('str') == 'str' if six.PY2 else b'str'
+ assert library.python.strings.stringize_deep('str') == 'str' if six.PY2 else b'str'
assert library.python.strings.stringize_deep(u'юникод') == u'юникод'.encode('utf-8')
assert library.python.strings.stringize_deep(u'юникод'.encode('utf-8')) == u'юникод'.encode('utf-8')
diff --git a/library/python/strings/ut/ya.make b/library/python/strings/ut/ya.make
index 30800efd37..dfacb226c7 100644
--- a/library/python/strings/ut/ya.make
+++ b/library/python/strings/ut/ya.make
@@ -1,6 +1,6 @@
OWNER(g:yatool)
-PY23_TEST()
+PY23_TEST()
TEST_SRCS(test_strings.py)
diff --git a/library/python/strings/ya.make b/library/python/strings/ya.make
index 49d4fa9b04..7e0b033717 100644
--- a/library/python/strings/ya.make
+++ b/library/python/strings/ya.make
@@ -10,7 +10,7 @@ PY_SRCS(
PEERDIR(
library/python/func
- contrib/python/six
+ contrib/python/six
)
END()
diff --git a/library/python/svn_version/__init__.py b/library/python/svn_version/__init__.py
index d2a6dc1a49..7ef7d6dac7 100644
--- a/library/python/svn_version/__init__.py
+++ b/library/python/svn_version/__init__.py
@@ -1 +1 @@
-from .__svn_version import svn_version, commit_id, svn_revision, svn_last_revision, hash, svn_branch, svn_tag, patch_number # noqa
+from .__svn_version import svn_version, commit_id, svn_revision, svn_last_revision, hash, svn_branch, svn_tag, patch_number # noqa
diff --git a/library/python/svn_version/__svn_version.pyx b/library/python/svn_version/__svn_version.pyx
index 4be75f808d..d66bc09d24 100644
--- a/library/python/svn_version/__svn_version.pyx
+++ b/library/python/svn_version/__svn_version.pyx
@@ -3,12 +3,12 @@ import future.utils as fu
cdef extern from "library/cpp/svnversion/svnversion.h":
cdef const char* GetProgramSvnVersion() except +;
cdef int GetProgramSvnRevision() except +;
- cdef int GetArcadiaLastChangeNum() except +;
- cdef const char* GetProgramCommitId() except +;
+ cdef int GetArcadiaLastChangeNum() except +;
+ cdef const char* GetProgramCommitId() except +;
cdef const char* GetProgramHash() except +;
cdef const char* GetBranch() except +;
cdef const char* GetTag() except +;
- cdef int GetArcadiaPatchNumber() except +;
+ cdef int GetArcadiaPatchNumber() except +;
def svn_version():
return fu.bytes_to_native_str(GetProgramSvnVersion())
@@ -16,12 +16,12 @@ def svn_version():
def svn_revision():
return GetProgramSvnRevision()
-def svn_last_revision():
- return GetArcadiaLastChangeNum()
-
-def commit_id():
- return fu.bytes_to_native_str(GetProgramCommitId())
-
+def svn_last_revision():
+ return GetArcadiaLastChangeNum()
+
+def commit_id():
+ return fu.bytes_to_native_str(GetProgramCommitId())
+
def hash():
return fu.bytes_to_native_str(GetProgramHash())
@@ -30,6 +30,6 @@ def svn_branch():
def svn_tag():
return fu.bytes_to_native_str(GetTag())
-
-def patch_number():
- return GetArcadiaPatchNumber()
+
+def patch_number():
+ return GetArcadiaPatchNumber()
diff --git a/library/python/svn_version/ut/lib/test_simple.py b/library/python/svn_version/ut/lib/test_simple.py
index c1218895c1..2c27af6c68 100644
--- a/library/python/svn_version/ut/lib/test_simple.py
+++ b/library/python/svn_version/ut/lib/test_simple.py
@@ -6,11 +6,11 @@ def test_simple():
assert isinstance(sv.svn_version(), str)
assert sv.svn_revision()
assert isinstance(sv.svn_revision(), int)
- assert sv.svn_last_revision()
- assert isinstance(sv.svn_last_revision(), int)
- assert sv.svn_last_revision() > 0
- assert sv.commit_id()
- assert isinstance(sv.commit_id(), str)
- assert len(sv.commit_id()) > 0
+ assert sv.svn_last_revision()
+ assert isinstance(sv.svn_last_revision(), int)
+ assert sv.svn_last_revision() > 0
+ assert sv.commit_id()
+ assert isinstance(sv.commit_id(), str)
+ assert len(sv.commit_id()) > 0
assert isinstance(sv.hash(), str)
- assert isinstance(sv.patch_number(), int)
+ assert isinstance(sv.patch_number(), int)
diff --git a/library/python/symbols/libc/syms.cpp b/library/python/symbols/libc/syms.cpp
index fa43606557..6c04a7ef6e 100644
--- a/library/python/symbols/libc/syms.cpp
+++ b/library/python/symbols/libc/syms.cpp
@@ -42,7 +42,7 @@
#if defined(_linux_)
#include <sys/inotify.h>
-#include <sys/mman.h>
+#include <sys/mman.h>
#endif
namespace {
@@ -137,7 +137,7 @@ SYM(sem_timedwait)
SYM(inotify_init)
SYM(inotify_add_watch)
SYM(inotify_rm_watch)
-SYM(mlockall)
+SYM(mlockall)
#endif
#if defined(_darwin_)
diff --git a/library/python/testing/yatest_common/ya.make b/library/python/testing/yatest_common/ya.make
index 7d4abfe704..5662db4c5d 100644
--- a/library/python/testing/yatest_common/ya.make
+++ b/library/python/testing/yatest_common/ya.make
@@ -28,7 +28,7 @@ PEERDIR(
contrib/python/six
library/python/cores
library/python/filelock
- library/python/fs
+ library/python/fs
)
IF (NOT CATBOOST_OPENSOURCE)
diff --git a/library/python/testing/yatest_common/yatest/common/path.py b/library/python/testing/yatest_common/yatest/common/path.py
index 1d08f72e62..6fed7dda8a 100644
--- a/library/python/testing/yatest_common/yatest/common/path.py
+++ b/library/python/testing/yatest_common/yatest/common/path.py
@@ -1,13 +1,13 @@
# coding=utf-8
-import errno
+import errno
import os
import shutil
import contextlib
-import library.python.fs as lpf
+import library.python.fs as lpf
+
-
def replace_in_file(path, old, new):
"""
Replace text occurrences in a file
@@ -18,7 +18,7 @@ def replace_in_file(path, old, new):
with open(path) as fp:
content = fp.read()
- lpf.ensure_removed(path)
+ lpf.ensure_removed(path)
with open(path, 'w') as fp:
fp.write(content.replace(old, new))
@@ -56,35 +56,35 @@ def copytree(src, dst, symlinks=False, ignore=None, postprocessing=None):
postprocessing(os.path.join(root, path), True)
-def get_unique_file_path(dir_path, file_pattern, create_file=True, max_suffix=10000):
- def atomic_file_create(path):
- try:
+def get_unique_file_path(dir_path, file_pattern, create_file=True, max_suffix=10000):
+ def atomic_file_create(path):
+ try:
fd = os.open(path, os.O_CREAT | os.O_EXCL, 0o644)
- os.close(fd)
- return True
- except OSError as e:
- if e.errno in [errno.EEXIST, errno.EISDIR, errno.ETXTBSY]:
- return False
- # Access issue with file itself, not parent directory.
- if e.errno == errno.EACCES and os.path.exists(path):
- return False
- raise e
-
- def atomic_dir_create(path):
- try:
- os.mkdir(path)
- return True
- except OSError as e:
- if e.errno == errno.EEXIST:
- return False
- raise e
-
+ os.close(fd)
+ return True
+ except OSError as e:
+ if e.errno in [errno.EEXIST, errno.EISDIR, errno.ETXTBSY]:
+ return False
+ # Access issue with file itself, not parent directory.
+ if e.errno == errno.EACCES and os.path.exists(path):
+ return False
+ raise e
+
+ def atomic_dir_create(path):
+ try:
+ os.mkdir(path)
+ return True
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ return False
+ raise e
+
file_path = os.path.join(dir_path, file_pattern)
- lpf.ensure_dir(os.path.dirname(file_path))
+ lpf.ensure_dir(os.path.dirname(file_path))
file_counter = 0
- handler = atomic_file_create if create_file else atomic_dir_create
- while os.path.exists(file_path) or not handler(file_path):
+ handler = atomic_file_create if create_file else atomic_dir_create
+ while os.path.exists(file_path) or not handler(file_path):
file_path = os.path.join(dir_path, file_pattern + ".{}".format(file_counter))
file_counter += 1
- assert file_counter < max_suffix
+ assert file_counter < max_suffix
return file_path
diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py
index 95d96b468a..e55e193446 100644
--- a/library/python/testing/yatest_common/yatest/common/runtime.py
+++ b/library/python/testing/yatest_common/yatest/common/runtime.py
@@ -2,14 +2,14 @@ import errno
import functools
import json
import os
-import threading
+import threading
import six
-_lock = threading.Lock()
-
-
+_lock = threading.Lock()
+
+
def _get_ya_config():
try:
import library.python.pytest.plugins.ya as ya_plugin
@@ -263,13 +263,13 @@ def global_resources():
def _register_core(name, binary_path, core_path, bt_path, pbt_path):
config = _get_ya_config()
-
- with _lock:
+
+ with _lock:
if not hasattr(config, 'test_cores_count'):
config.test_cores_count = 0
- config.test_cores_count += 1
- count_str = '' if config.test_cores_count == 1 else str(config.test_cores_count)
-
+ config.test_cores_count += 1
+ count_str = '' if config.test_cores_count == 1 else str(config.test_cores_count)
+
log_entry = config.test_logs[config.current_item_nodeid]
if binary_path:
log_entry['{} binary{}'.format(name, count_str)] = binary_path