Skip to content

Commit

Permalink
Move walk_files to fs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Jan 9, 2020
1 parent a798169 commit 74850fe
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dvc/remote/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
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__)

Expand Down
6 changes: 0 additions & 6 deletions dvc/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions dvc/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion tests/func/test_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/remote/test_remote_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions tests/unit/utils/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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

Expand Down Expand Up @@ -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))
5 changes: 0 additions & 5 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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(
Expand Down Expand Up @@ -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))

0 comments on commit 74850fe

Please sign in to comment.