From d9cd9ece8b7dd296617a3488be006e46248bd9b6 Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Sat, 16 Nov 2019 00:44:20 +0530 Subject: [PATCH] Move `_chmod` to fs.py --- dvc/utils/__init__.py | 16 ---------------- dvc/utils/fs.py | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dvc/utils/__init__.py b/dvc/utils/__init__.py index a318842115..61b25eee10 100644 --- a/dvc/utils/__init__.py +++ b/dvc/utils/__init__.py @@ -1,14 +1,12 @@ """Helpers for other modules.""" from __future__ import unicode_literals -import errno import hashlib import json import logging import math import os import re -import stat import sys import time @@ -158,20 +156,6 @@ def makedirs(path, exist_ok=False, mode=None): os.umask(umask) -def _chmod(func, p, excinfo): - perm = os.lstat(p).st_mode - perm |= stat.S_IWRITE - - try: - os.chmod(p, perm) - except OSError as exc: - # broken symlink or file is not owned by us - if exc.errno not in [errno.ENOENT, errno.EPERM]: - raise - - func(p) - - def _split(list_to_split, chunk_size): return [ list_to_split[i : i + chunk_size] diff --git a/dvc/utils/fs.py b/dvc/utils/fs.py index eff297693c..c73a23563e 100644 --- a/dvc/utils/fs.py +++ b/dvc/utils/fs.py @@ -4,13 +4,13 @@ import logging import os import shutil +import stat import nanotime from shortuuid import uuid from dvc.exceptions import DvcException from dvc.system import System -from dvc.utils import _chmod from dvc.utils import dict_md5 from dvc.utils import fspath from dvc.utils import fspath_py35 @@ -107,6 +107,20 @@ def move(src, dst, mode=None): shutil.move(tmp, dst) +def _chmod(func, p, excinfo): + perm = os.lstat(p).st_mode + perm |= stat.S_IWRITE + + try: + os.chmod(p, perm) + except OSError as exc: + # broken symlink or file is not owned by us + if exc.errno not in [errno.ENOENT, errno.EPERM]: + raise + + func(p) + + def remove(path): path = fspath_py35(path)