diff --git a/CHANGES.rst b/CHANGES.rst index 8da79b8..da98924 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,8 @@ - Now ``Dir.files`` and ``Dir.subdirs`` methods return sorted list. allowing custom sort options and abspath args that allow to choose between relative/absolute path. - Added Dir.size method to recursively compute directory size. +- New ``DirState`` and ``compute_diff`` method. +- Now skipping symlinks 0.1.0 (2013-07-01) ================== diff --git a/dirtools.py b/dirtools.py index 5b4e068..8d0211a 100644 --- a/dirtools.py +++ b/dirtools.py @@ -254,12 +254,12 @@ def walk(self): for d in list(dirs): if self.is_excluded(os.path.join(root, d)): dirs.remove(d) - else: + elif not os.path.islink(os.path.join(root, d)): ndirs.append(d) nfiles = [] for fpath in (os.path.join(root, f) for f in files): - if not self.is_excluded(fpath): + if not self.is_excluded(fpath) and not os.path.islink(fpath): nfiles.append(os.path.relpath(fpath, root)) yield root, ndirs, nfiles @@ -354,11 +354,12 @@ def to_json(self, base_path='.', dt=None, fmt=None): dt = datetime.utcnow() path = fmt.format(self._dir.path.strip('/').split('/')[-1], dt.isoformat()) + path = os.path.join(base_path, path) - with open(os.path.join(base_path, path), 'wb') as f: + with open(path, 'wb') as f: f.write(json.dumps(self.state)) - return os.path.abspath(path) + return path @classmethod def from_json(cls, path):