mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
Move _chmod to fs.py
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user