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
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)
def walk(self, path_info): return dvc_walk(path_info, self.repo.dvcignore)
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))