diff options
author | exprmntr <exprmntr@yandex-team.ru> | 2022-02-10 16:46:50 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:50 +0300 |
commit | a6396ea4e82c2605dcf9a11ebc4c289d0b1c734c (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/python/windows | |
parent | 078ddb2fb76387cae14e8c3ceb5a896009a5a539 (diff) | |
download | ydb-a6396ea4e82c2605dcf9a11ebc4c289d0b1c734c.tar.gz |
Restoring authorship annotation for exprmntr <exprmntr@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/windows')
-rw-r--r-- | library/python/windows/__init__.py | 24 | ||||
-rw-r--r-- | library/python/windows/ut/test_windows.py | 30 | ||||
-rw-r--r-- | library/python/windows/ut/ya.make | 18 | ||||
-rw-r--r-- | library/python/windows/ya.make | 26 |
4 files changed, 49 insertions, 49 deletions
diff --git a/library/python/windows/__init__.py b/library/python/windows/__init__.py index 0b43073e35..62861b3309 100644 --- a/library/python/windows/__init__.py +++ b/library/python/windows/__init__.py @@ -6,10 +6,10 @@ import sys import shutil import logging -from six import reraise - -import library.python.func -import library.python.strings +from six import reraise + +import library.python.func +import library.python.strings logger = logging.getLogger(__name__) @@ -28,7 +28,7 @@ RETRIABLE_DIR_ERRORS = (ERRORS['ACCESS_DENIED'], ERRORS['DIR_NOT_EMPTY'], ERRORS # Check if on Windows -@library.python.func.lazy +@library.python.func.lazy def on_win(): return os.name == 'nt' @@ -78,7 +78,7 @@ def errorfix(f): except WindowsError: tp, value, tb = sys.exc_info() fix_error(value) - reraise(tp, value, tb) + reraise(tp, value, tb) return f_wrapped @@ -100,7 +100,7 @@ if on_win(): import msvcrt import time - import library.python.strings + import library.python.strings _has_ctypes = True try: @@ -153,7 +153,7 @@ if on_win(): raise ei = sys.exc_info() time.sleep(delay) - reraise(ei[0], ei[1], ei[2]) + reraise(ei[0], ei[1], ei[2]) # Placeholder for disabled functions @win_only @@ -170,7 +170,7 @@ if on_win(): @win_only def unicode_path(path): - return library.python.strings.to_unicode(path, library.python.strings.fs_encoding()) + return library.python.strings.to_unicode(path, library.python.strings.fs_encoding()) @win_only @require_ctypes @@ -189,9 +189,9 @@ if on_win(): @win_only def transcode_error(windows_error, to_enc='utf-8'): - from_enc = 'utf-8' if getattr(windows_error, 'utf8', False) else library.python.strings.guess_default_encoding() + from_enc = 'utf-8' if getattr(windows_error, 'utf8', False) else library.python.strings.guess_default_encoding() if from_enc != to_enc: - windows_error.strerror = library.python.strings.to_str(windows_error.strerror, to_enc=to_enc, from_enc=from_enc) + windows_error.strerror = library.python.strings.to_str(windows_error.strerror, to_enc=to_enc, from_enc=from_enc) setattr(windows_error, 'utf8', to_enc == 'utf-8') class Transaction(object): @@ -236,7 +236,7 @@ if on_win(): @win_only @require_ctypes def replace_file_across_devices(src, dst): - with Transaction(timeout=_ATOMIC_RENAME_FILE_TRANSACTION_DEFAULT_TIMEOUT, description='ya library.python.windows replace_file_across_devices') as transaction: + with Transaction(timeout=_ATOMIC_RENAME_FILE_TRANSACTION_DEFAULT_TIMEOUT, description='ya library.python.windows replace_file_across_devices') as transaction: if not ctypes.windll.kernel32.MoveFileTransactedW(unicode_path(src), unicode_path(dst), None, None, _MOVEFILE_REPLACE_EXISTING | _MOVEFILE_WRITE_THROUGH, transaction): raise ctypes.WinError() diff --git a/library/python/windows/ut/test_windows.py b/library/python/windows/ut/test_windows.py index e255d0560e..bef3ec2dc5 100644 --- a/library/python/windows/ut/test_windows.py +++ b/library/python/windows/ut/test_windows.py @@ -4,16 +4,16 @@ import errno import os import pytest -import library.python.strings -import library.python.windows +import library.python.strings +import library.python.windows def gen_error_access_denied(): - if library.python.windows.on_win(): + if library.python.windows.on_win(): err = WindowsError() err.errno = errno.EACCES err.strerror = '' - err.winerror = library.python.windows.ERRORS['ACCESS_DENIED'] + err.winerror = library.python.windows.ERRORS['ACCESS_DENIED'] else: err = OSError() err.errno = errno.EACCES @@ -23,7 +23,7 @@ def gen_error_access_denied(): def test_errorfix_buggy(): - @library.python.windows.errorfix + @library.python.windows.errorfix def erroneous_func(): gen_error_access_denied() @@ -36,11 +36,11 @@ def test_errorfix_buggy(): def test_errorfix_explicit(): - @library.python.windows.errorfix + @library.python.windows.errorfix def erroneous_func(): - if library.python.windows.on_win(): + if library.python.windows.on_win(): err = WindowsError() - err.winerror = library.python.windows.ERRORS['ACCESS_DENIED'] + err.winerror = library.python.windows.ERRORS['ACCESS_DENIED'] else: err = OSError() err.errno = errno.EACCES @@ -56,27 +56,27 @@ def test_errorfix_explicit(): def test_errorfix_decoding_cp1251(): - @library.python.windows.errorfix + @library.python.windows.errorfix def erroneous_func(): model_msg = u'Какое-то описание ошибки' - if library.python.windows.on_win(): + if library.python.windows.on_win(): err = WindowsError() - err.strerror = library.python.strings.to_str(model_msg, 'cp1251') + err.strerror = library.python.strings.to_str(model_msg, 'cp1251') else: err = OSError() - err.strerror = library.python.strings.to_str(model_msg) + err.strerror = library.python.strings.to_str(model_msg) raise err with pytest.raises(OSError) as errinfo: erroneous_func() error_msg = errinfo.value.strerror if not isinstance(errinfo.value.strerror, unicode): - error_msg = library.python.strings.to_unicode(error_msg) + error_msg = library.python.strings.to_unicode(error_msg) assert error_msg == u'Какое-то описание ошибки' def test_diehard(): - @library.python.windows.diehard(library.python.windows.ERRORS['ACCESS_DENIED'], tries=5) + @library.python.windows.diehard(library.python.windows.ERRORS['ACCESS_DENIED'], tries=5) def erroneous_func(errors): try: gen_error_access_denied() @@ -90,7 +90,7 @@ def test_diehard(): assert errinfo.value.errno == errno.EACCES assert any(e.errno == errno.EACCES for e in raised_errors) assert raised_errors and errinfo.value == raised_errors[-1] - if library.python.windows.on_win(): + if library.python.windows.on_win(): assert len(raised_errors) == 5 else: assert len(raised_errors) == 1 diff --git a/library/python/windows/ut/ya.make b/library/python/windows/ut/ya.make index 5045153b93..c39f1797b8 100644 --- a/library/python/windows/ut/ya.make +++ b/library/python/windows/ut/ya.make @@ -1,11 +1,11 @@ -OWNER(g:yatool) - +OWNER(g:yatool) + PY2TEST() - + TEST_SRCS(test_windows.py) - -PEERDIR( - library/python/windows -) - -END() + +PEERDIR( + library/python/windows +) + +END() diff --git a/library/python/windows/ya.make b/library/python/windows/ya.make index 3b80fb944f..e17f86b67e 100644 --- a/library/python/windows/ya.make +++ b/library/python/windows/ya.make @@ -1,13 +1,13 @@ -OWNER(g:yatool) - -PY23_LIBRARY() - -PY_SRCS(__init__.py) - -PEERDIR( - library/python/func - library/python/strings - contrib/python/six -) - -END() +OWNER(g:yatool) + +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +PEERDIR( + library/python/func + library/python/strings + contrib/python/six +) + +END() |