예제 #1
0
파일: tree.py 프로젝트: vyloy/dvc
    def walk(self, top, topdown=True, ignore_file_handler=None):
        """Directory tree generator.

        See `os.walk` for the docs. Differences:
        - no support for symlinks
        - it could raise exceptions, there is no onerror argument
        """
        def onerror(e):
            raise e

        for root, dirs, files in dvc_walk(
                top,
                topdown=topdown,
                onerror=onerror,
                ignore_file_handler=ignore_file_handler,
        ):
            yield os.path.normpath(root), dirs, files
예제 #2
0
파일: fs.py 프로젝트: vyloy/dvc
def get_mtime_and_size(path):
    size = os.path.getsize(path)
    mtime = os.path.getmtime(path)

    if os.path.isdir(path):
        for root, dirs, files in dvc_walk(str(path)):
            for name in dirs + files:
                entry = os.path.join(root, name)
                try:
                    stat = os.stat(entry)
                except OSError as exc:
                    # NOTE: broken symlink case.
                    if exc.errno != errno.ENOENT:
                        raise
                    continue
                size += stat.st_size
                entry_mtime = stat.st_mtime
                if entry_mtime > mtime:
                    mtime = entry_mtime

    # State of files handled by dvc is stored in db as TEXT.
    # We cast results to string for later comparisons with stored values.
    return str(int(nanotime.timestamp(mtime))), str(size)
예제 #3
0
 def walk(self, path_info):
     return dvc_walk(path_info, self.repo.dvcignore)
예제 #4
0
파일: ignore.py 프로젝트: Nirvi1/dvc
 def __init__(self, root_dir):
     self.ignores = {DvcIgnoreDirs([".git", ".hg", ".dvc"])}
     self._update(root_dir)
     for root, dirs, _ in dvc_walk(root_dir, self):
         for d in dirs:
             self._update(os.path.join(root, d))