Move _chmod to fs.py

This commit is contained in:
Aman Sharma
2019-11-16 00:44:20 +05:30
parent 636d850c84
commit d9cd9ece8b
2 changed files with 15 additions and 17 deletions
-16
View File
@@ -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]
+15 -1
View File
@@ -4,13 +4,13 @@ import errno
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)