mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Move walk_files to fs.py
This commit is contained in:
+1
-1
@@ -25,9 +25,9 @@ from dvc.utils.fs import copyfile
|
||||
from dvc.utils import file_md5
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils import tmp_fname
|
||||
from dvc.utils import walk_files
|
||||
from dvc.compat import fspath_py35
|
||||
from dvc.utils.fs import move, makedirs, remove
|
||||
from dvc.utils.fs import walk_files
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -231,12 +231,6 @@ def to_yaml_string(data):
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
def walk_files(directory):
|
||||
for root, _, files in os.walk(fspath(directory)):
|
||||
for f in files:
|
||||
yield os.path.join(root, f)
|
||||
|
||||
|
||||
def colorize(message, color=None):
|
||||
"""Returns a message in a specified color."""
|
||||
if not color:
|
||||
|
||||
@@ -201,3 +201,9 @@ def copyfile(src, dest, no_progress_bar=False, name=None):
|
||||
break
|
||||
fdest.write(buf)
|
||||
pbar.update(len(buf))
|
||||
|
||||
|
||||
def walk_files(directory):
|
||||
for root, _, files in os.walk(fspath(directory)):
|
||||
for f in files:
|
||||
yield os.path.join(root, f)
|
||||
|
||||
@@ -18,7 +18,8 @@ from dvc.stage import Stage
|
||||
from dvc.stage import StageFileBadNameError
|
||||
from dvc.stage import StageFileDoesNotExistError
|
||||
from dvc.system import System
|
||||
from dvc.utils import relpath, walk_files
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils.fs import walk_files
|
||||
from dvc.utils.stage import dump_stage_file
|
||||
from dvc.utils.stage import load_stage_file
|
||||
from tests.basic_env import TestDvc
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import pytest
|
||||
import os
|
||||
from dvc.remote.s3 import RemoteS3
|
||||
from dvc.utils import walk_files
|
||||
from dvc.utils.fs import walk_files
|
||||
from dvc.path_info import PathInfo
|
||||
from tests.remotes import GCP, S3Mocked
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ from dvc.utils.fs import get_mtime_and_size
|
||||
from dvc.utils.fs import move
|
||||
from dvc.utils.fs import path_isin, remove
|
||||
from dvc.utils.fs import makedirs
|
||||
from dvc.utils.fs import walk_files
|
||||
from tests.basic_env import TestDir
|
||||
from tests.utils import spy
|
||||
|
||||
@@ -244,3 +245,7 @@ def test_copyfile(path, repo_dir):
|
||||
)
|
||||
else:
|
||||
assert filecmp.cmp(src_info.fspath, dest_info.fspath, shallow=False)
|
||||
|
||||
|
||||
def test_walk_files(tmp_dir):
|
||||
assert list(walk_files(".")) == list(walk_files(tmp_dir))
|
||||
|
||||
@@ -9,7 +9,6 @@ from dvc.utils import fix_env
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils import to_chunks
|
||||
from dvc.utils import tmp_fname
|
||||
from dvc.utils import walk_files
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -105,7 +104,3 @@ def test_relpath():
|
||||
path_info = PathInfo(path)
|
||||
|
||||
assert relpath(path) == relpath(path_info)
|
||||
|
||||
|
||||
def test_walk_files(tmp_dir):
|
||||
assert list(walk_files(".")) == list(walk_files(tmp_dir))
|
||||
|
||||
Reference in New Issue
Block a user