diff options
author | Aleksandr <ivansduck@gmail.com> | 2022-02-10 16:47:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
commit | ea6c5b7f172becca389cacaff7d5f45f6adccbe6 (patch) | |
tree | d16cef493ac1e092b4a03ab9437ec06ffe3d188f /library/python/fs/__init__.py | |
parent | 37de222addabbef336dcaaea5f7c7645a629fc6d (diff) | |
download | ydb-ea6c5b7f172becca389cacaff7d5f45f6adccbe6.tar.gz |
Restoring authorship annotation for Aleksandr <ivansduck@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/python/fs/__init__.py')
-rw-r--r-- | library/python/fs/__init__.py | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/library/python/fs/__init__.py b/library/python/fs/__init__.py index b1b7cde079..c9651b03ae 100644 --- a/library/python/fs/__init__.py +++ b/library/python/fs/__init__.py @@ -4,11 +4,11 @@ import codecs import errno import logging import os -import random +import random import shutil import six import stat -import sys +import sys import library.python.func import library.python.strings @@ -202,13 +202,13 @@ def hardlink_or_copy(src, lnk): 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 - if isinstance(exc, OSError) and exc.errno in ( - errno.EXDEV, - errno.EMLINK, - errno.EINVAL, - errno.EACCES, - errno.EPERM, - ): + if isinstance(exc, OSError) and exc.errno in ( + errno.EXDEV, + errno.EMLINK, + errno.EINVAL, + errno.EACCES, + errno.EPERM, + ): return True return False @@ -312,9 +312,9 @@ def read_file_unicode(path, binary=True, enc='utf-8'): @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) - ) + return ( + library.python.windows.open_file(*args, **kwargs) if library.python.windows.on_win() else open(*args, **kwargs) + ) # Atomic file write @@ -363,15 +363,15 @@ def get_tree_size(path, recursive=False, raise_all_errors=False): # Directory copy ported from Python 3 -def copytree3( - src, - dst, - symlinks=False, - ignore=None, - copy_function=shutil.copy2, - ignore_dangling_symlinks=False, - dirs_exist_ok=False, -): +def copytree3( + src, + dst, + symlinks=False, + ignore=None, + copy_function=shutil.copy2, + ignore_dangling_symlinks=False, + dirs_exist_ok=False, +): """Recursively copy a directory tree. The copytree3 is a port of shutil.copytree function from python-3.2. @@ -467,35 +467,35 @@ def walk_relative(path, topdown=True, onerror=None, followlinks=False): for dirpath, dirnames, filenames in os.walk(path, topdown=topdown, onerror=onerror, followlinks=followlinks): yield os.path.relpath(dirpath, path), dirnames, filenames - + def supports_clone(): if 'darwin' in sys.platform: import platform - + return list(map(int, platform.mac_ver()[0].split('.'))) >= [10, 13] return False - - -def commonpath(paths): - assert paths - if len(paths) == 1: - return next(iter(paths)) - - split_paths = [path.split(os.sep) for path in paths] - smin = min(split_paths) - smax = max(split_paths) - - common = smin - for i, c in enumerate(smin): - if c != smax[i]: - common = smin[:i] - break - - return os.path.sep.join(common) - - -def set_execute_bits(filename): - stm = os.stat(filename).st_mode - exe = stm | 0o111 - if stm != exe: - os.chmod(filename, exe) + + +def commonpath(paths): + assert paths + if len(paths) == 1: + return next(iter(paths)) + + split_paths = [path.split(os.sep) for path in paths] + smin = min(split_paths) + smax = max(split_paths) + + common = smin + for i, c in enumerate(smin): + if c != smax[i]: + common = smin[:i] + break + + return os.path.sep.join(common) + + +def set_execute_bits(filename): + stm = os.stat(filename).st_mode + exe = stm | 0o111 + if stm != exe: + os.chmod(filename, exe) |