{ "info": { "author": "Thomas Sileo", "author_email": "thomas.sileo@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python" ], "description": "==========\n Dirtools\n==========\n\nDirtools is a little Python package aimed to provide the following features:\n\n* Exclude/ignore files in a directory, using .gitignore like syntax (unix filename pattern matching).\n* Generate a hash for a directory tree in order to check if a directory has been modified.\n* Search recursively for all subidirs containing a given filename (all projects directory inside a dir).\n* Track changes in a directory over time (without duplicating it or without having direct access to it).\n\n\n.. image:: https://pypip.in/v/dirtools/badge.png\n :target: https://crate.io/packages/dirtools\n\n.. image:: https://pypip.in/d/dirtools/badge.png\n :target: https://crate.io/packages/dirtools\n\n\nInstallation\n============\n\n.. code-block::\n\n $ pip install dirtools\n\n\nGetting Started\n===============\n\nExcluding files\n---------------\n\nDirtools let you exlude files using .gitignore like syntax (unix filename pattern matching), by default ``dirtools`` will look for a ``.exclude`` file at root.\n\nHere is how to check if a file should be excluded:\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir', exclude_file='.gitignore')\n d.is_excluded('/path/to/dir/script.pyc')\n\n\nHashdir\n-------\n\nThe hashdir represent the state of every files in a directory. It compute the hash of the hash of each file recursively.\n\nHere is how to compute the hash of a directory, excluded files ares skipped if any.\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir')\n hashdir = d.hash()\n\n\nFind directories containing a file\n----------------------------------\n\nWe'll call these directories **project**, ``find_projects`` will search recursively for subdirectories with a ``file_identifier`` file in it.\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir')\n projects = d.find_projects('.project')\n\n\nCompress the directory with gzip\n----------------------------------\n\nDirtools provides a helper to compress the whole directory (except excluded files/dirs) with gzip.\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir')\n \n # By default, dirtools will create a temporary file to store the archive for you\n tmp_archive = d.compress_to()\n\n # But you can specify a file\n archive_path = '/home/thomas/mydir.tgz'\n d.compress_to(archive_path)\n\n\nOr if you want to do it manually:\n\n.. code-block:: python\n\n import tarfile\n from dirtools import Dir\n\n d = Dir('/path/to/mydir', exclude_file='.gitignore')\n\n with tarfile.open(fileobj=out, mode=\"w:gz\")) as tar:\n tar.add(filename, arcname=arcname, exclude=d.is_excluded)\n\n\nTrack changes in directories\n----------------------------\n\nDirtools provides an helper ``DirState`` to help tracking changes in a directory over time, without duplicating it or without having direct access to it.\n\n.. code-block:: python\n\n from dirtools import Dir, DirState\n\n d = Dir(path)\n dir_state = DirState(d)\n\n state_file = dir_state.to_json()\n\n # Later... after some changes\n\n dir_state = DirState.from_json(state_file)\n dir_state2 = DirState(d)\n\n changes = dir_state2 - dir_state\n\n\nHelpers\n-------\n\nAll methods/properties exclude files and directories based on patterns in ``exclude_file`` and the ``excludes`` list.\n\nCustom Walker\n~~~~~~~~~~~~~\n\nIf you need to perform operations on files or directories, you can use ``Dir.walk``, it works exactly like ``os.walk``, except it will skip excluded files/directories on the fly.\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir')\n \n for root, dirs, files in self.walk():\n # do something\n\n\nList all subdirectories of a directory\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir')\n\n dirs = d.subdirs()\n\n myproject_dirs = d.subdirs('myproject_*')\n\n\nList all files recursively\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from dirtools import Dir\n\n d = Dir('/path/to/dir')\n\n files = d.files()\n\n py_files = d.files('*.py')\n\n\nLicense (MIT)\n=============\n\nCopyright (c) 2013 Thomas Sileo\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tsileo/dirtools", "keywords": "exclude exclusion directory hash compression gzip", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "dirtools", "package_url": "https://pypi.org/project/dirtools/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dirtools/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tsileo/dirtools" }, "release_url": "https://pypi.org/project/dirtools/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "Exclude/ignore files in a directory (using .gitignore like syntax), compute hash, search projects for an entire directory tree and gzip compression.", "version": "0.2.0" }, "last_serial": 943146, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "1ab496a99fdef777549c886c0583e227", "sha256": "65eabf347d8c1feeeee8a78643e7352c80f89a7d6ae63067225a8c2617eed8ac" }, "downloads": -1, "filename": "dirtools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "1ab496a99fdef777549c886c0583e227", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5451, "upload_time": "2013-07-01T06:49:06", "url": "https://files.pythonhosted.org/packages/84/0c/ea877796384bad2fa0a730cab09cdf3e0a116038765dfbe096c7b82188ed/dirtools-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "819ebf8044e51bbd1967a9c4e8c94564", "sha256": "59a9cd97e622aad22b142344ba36a62903ba0ba2e11b5f028fea34442eab14df" }, "downloads": -1, "filename": "dirtools-0.2.0.tar.gz", "has_sig": false, "md5_digest": "819ebf8044e51bbd1967a9c4e8c94564", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8377, "upload_time": "2013-12-12T21:25:55", "url": "https://files.pythonhosted.org/packages/ad/77/6bd881348551f0c6f0ca0385721228c61b7dd55ec66028ae1e05c77fb0ec/dirtools-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "819ebf8044e51bbd1967a9c4e8c94564", "sha256": "59a9cd97e622aad22b142344ba36a62903ba0ba2e11b5f028fea34442eab14df" }, "downloads": -1, "filename": "dirtools-0.2.0.tar.gz", "has_sig": false, "md5_digest": "819ebf8044e51bbd1967a9c4e8c94564", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8377, "upload_time": "2013-12-12T21:25:55", "url": "https://files.pythonhosted.org/packages/ad/77/6bd881348551f0c6f0ca0385721228c61b7dd55ec66028ae1e05c77fb0ec/dirtools-0.2.0.tar.gz" } ] }