diff options
author | workfork <workfork@yandex-team.ru> | 2022-02-10 16:46:43 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:43 +0300 |
commit | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/python | |
parent | c3745173272d1cf5b0642debb40d019e7ae71094 (diff) | |
download | ydb-89db6fe2fe2c32d2a832ddfeb04e8d078e301084.tar.gz |
Restoring authorship annotation for <workfork@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python')
-rw-r--r-- | library/python/find_root/ya.make | 2 | ||||
-rw-r--r-- | library/python/fs/__init__.py | 12 | ||||
-rw-r--r-- | library/python/func/__init__.py | 40 | ||||
-rw-r--r-- | library/python/windows/__init__.py | 46 | ||||
-rw-r--r-- | library/python/ya.make | 4 |
5 files changed, 52 insertions, 52 deletions
diff --git a/library/python/find_root/ya.make b/library/python/find_root/ya.make index ac947a6ab8..beaa8e3c52 100644 --- a/library/python/find_root/ya.make +++ b/library/python/find_root/ya.make @@ -1,6 +1,6 @@ PY23_LIBRARY() -OWNER(g:yatool) +OWNER(g:yatool) PY_SRCS(__init__.py) diff --git a/library/python/fs/__init__.py b/library/python/fs/__init__.py index f56b9a9c0b..b1b7cde079 100644 --- a/library/python/fs/__init__.py +++ b/library/python/fs/__init__.py @@ -215,7 +215,7 @@ def hardlink_or_copy(src, lnk): try: hardlink(src, lnk) except Exception as e: - logger.debug('Failed to hardlink %s to %s with error %s, will copy it', src, lnk, repr(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) else: @@ -310,13 +310,13 @@ def read_file_unicode(path, binary=True, enc='utf-8'): return f.read() -@errorfix_win -def open_file(*args, **kwargs): +@errorfix_win +def open_file(*args, **kwargs): return ( library.python.windows.open_file(*args, **kwargs) if library.python.windows.on_win() else open(*args, **kwargs) ) - - + + # Atomic file write # Throws OSError @errorfix_win @@ -325,7 +325,7 @@ def write_file(path, data, binary=True): if dir_path: ensure_dir(dir_path) tmp_path = path + '.tmp.' + str(random.random()) - with open_file(tmp_path, 'w' + ('b' if binary else '')) as f: + with open_file(tmp_path, 'w' + ('b' if binary else '')) as f: if not isinstance(data, bytes) and binary: data = data.encode('UTF-8') f.write(data) diff --git a/library/python/func/__init__.py b/library/python/func/__init__.py index 82de2e60ea..7424361635 100644 --- a/library/python/func/__init__.py +++ b/library/python/func/__init__.py @@ -44,26 +44,26 @@ def lazy_property(fn): return _lazy_property -class classproperty(object): - def __init__(self, func): - self.func = func - - def __get__(self, _, owner): - return self.func(owner) - - -class lazy_classproperty(object): - def __init__(self, func): - self.func = func - - def __get__(self, _, owner): - attr_name = '_lazy_' + self.func.__name__ - - if not hasattr(owner, attr_name): - setattr(owner, attr_name, self.func(owner)) - return getattr(owner, attr_name) - - +class classproperty(object): + def __init__(self, func): + self.func = func + + def __get__(self, _, owner): + return self.func(owner) + + +class lazy_classproperty(object): + def __init__(self, func): + self.func = func + + def __get__(self, _, owner): + attr_name = '_lazy_' + self.func.__name__ + + if not hasattr(owner, attr_name): + setattr(owner, attr_name, self.func(owner)) + return getattr(owner, attr_name) + + def memoize(limit=0, thread_local=False): assert limit >= 0 diff --git a/library/python/windows/__init__.py b/library/python/windows/__init__.py index 5d650f0b07..62861b3309 100644 --- a/library/python/windows/__init__.py +++ b/library/python/windows/__init__.py @@ -1,7 +1,7 @@ # coding: utf-8 import os -import stat +import stat import sys import shutil import logging @@ -125,8 +125,8 @@ if on_win(): _ATOMIC_RENAME_FILE_TRANSACTION_DEFAULT_TIMEOUT = 1000 - _HANDLE_FLAG_INHERIT = 0x1 - + _HANDLE_FLAG_INHERIT = 0x1 + @win_only def require_ctypes(f): def f_wrapped(*args, **kwargs): @@ -218,16 +218,16 @@ if on_win(): def file_handle(f): return msvcrt.get_osfhandle(f.fileno()) - # https://www.python.org/dev/peps/pep-0446/ - # http://mihalop.blogspot.ru/2014/05/python-subprocess-and-file-descriptors.html - @require_ctypes + # https://www.python.org/dev/peps/pep-0446/ + # http://mihalop.blogspot.ru/2014/05/python-subprocess-and-file-descriptors.html + @require_ctypes + @win_only + def open_file(*args, **kwargs): + f = open(*args, **kwargs) + ctypes.windll.kernel32.SetHandleInformation(file_handle(f), _HANDLE_FLAG_INHERIT, 0) + return f + @win_only - def open_file(*args, **kwargs): - f = open(*args, **kwargs) - ctypes.windll.kernel32.SetHandleInformation(file_handle(f), _HANDLE_FLAG_INHERIT, 0) - return f - - @win_only @require_ctypes def replace_file(src, dst): if not ctypes.windll.kernel32.MoveFileExW(unicode_path(src), unicode_path(dst), _MOVEFILE_REPLACE_EXISTING | _MOVEFILE_WRITE_THROUGH): @@ -293,16 +293,16 @@ if on_win(): handling_path = "\\\\?\\" + handling_path # handle path over 256 symbols if os.path.exists(path): return func(handling_path) - if e.winerror == ERRORS['ACCESS_DENIED']: - try: - # removing of r/w directory with read-only files in it yields ACCESS_DENIED - # which is not an insuperable obstacle https://bugs.python.org/issue19643 - os.chmod(handling_path, stat.S_IWRITE) - except OSError: - pass - else: - # propagate true last error if this attempt fails - return func(handling_path) + if e.winerror == ERRORS['ACCESS_DENIED']: + try: + # removing of r/w directory with read-only files in it yields ACCESS_DENIED + # which is not an insuperable obstacle https://bugs.python.org/issue19643 + os.chmod(handling_path, stat.S_IWRITE) + except OSError: + pass + else: + # propagate true last error if this attempt fails + return func(handling_path) raise e shutil.rmtree(path, onerror=error_handler) @@ -310,7 +310,7 @@ if on_win(): # http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx @win_only def disable_error_dialogs(): - set_error_mode(_SEM_NOGPFAULTERRORBOX | _SEM_FAILCRITICALERRORS) + set_error_mode(_SEM_NOGPFAULTERRORBOX | _SEM_FAILCRITICALERRORS) @win_only def default_process_creation_flags(): diff --git a/library/python/ya.make b/library/python/ya.make index 2e8b53b6e9..2e1eb6e0e1 100644 --- a/library/python/ya.make +++ b/library/python/ya.make @@ -180,7 +180,7 @@ RECURSE( step strings strings/ut - svn_ssh + svn_ssh svn_version svn_version/ut symbols @@ -212,7 +212,7 @@ RECURSE( yt/test ylock ylock/tests - zipatch + zipatch ) IF (NOT MUSL) |