diff --git a/.gitignore b/.gitignore index f02af27..2b05435 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +*.egg build/ dist/ *.egg-info/ diff --git a/CHANGES.rst b/CHANGES.rst index da98924..df3a6d1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,8 +2,8 @@ Dirtools Changelog ==================== -0.1.1 (not released yet) -======================== +0.1.1 (2013-12-12) +================== - New ``compress_to`` methods for easy gzip compression with tarfile. - Added patterns support to ``Dir.files`` and ``Dir.subdirs`` methods. @@ -11,13 +11,15 @@ 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 +- Now skipping symlinks. + 0.1.0 (2013-07-01) ================== - v0.1.0 on pypi. + 0.0.0 (2013-06-17) ================== diff --git a/README.rst b/README.rst index eeb622e..126d50e 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,8 @@ Dirtools is a little Python package aimed to provide the following features: * Exclude/ignore files in a directory, using .gitignore like syntax (unix filename pattern matching). * Generate a hash for a directory tree in order to check if a directory has been modified. * Search recursively for all subidirs containing a given filename (all projects directory inside a dir). +* Track changes in a directory over time (without duplicating it or without having direct access to it). + .. image:: https://pypip.in/v/dirtools/badge.png :target: https://crate.io/packages/dirtools @@ -101,6 +103,28 @@ Or if you want to do it manually: tar.add(filename, arcname=arcname, exclude=d.is_excluded) +Track changes in directories +---------------------------- + +Dirtools provides an helper ``DirIndex`` to help tracking changes in a directory over time, without duplicating it or without having direct access to it. + +.. code-block:: python + + from dirtools import Dir, DirIndex + + d = Dir(path) + dir_index = DirIndex(d) + + index_file = dir_index.to_json() + + # Later... after some changes + + dir_index = DirIndex.from_json(index_file) + dir_index2 = DirIndex(d) + + changes = dir_index2 - dir_index + + Helpers ------- diff --git a/dirtools.py b/dirtools.py index 8d0211a..b65879a 100644 --- a/dirtools.py +++ b/dirtools.py @@ -310,6 +310,7 @@ def compress_to(self, archive_path=None): class DirState(object): + """ Hold a directory state / snapshot meta-data for later comparison. """ def __init__(self, _dir=None, state=None, index_cmp=os.path.getmtime): self._dir = _dir self.index_cmp = index_cmp @@ -336,7 +337,7 @@ def index(self): def __sub__(self, other): """ Compute diff with operator overloading. - >>> path =DirState(Dir('/path')) + >>> path = DirState(Dir('/path')) >>> path_copy = DirState(Dir('/path_copy')) >>> diff = path_copy - path >>> # Equals to