{ "info": { "author": "Matt Bodenhamer", "author_email": "mbodenhamer@mbodenhamer.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Utilities" ], "description": "fmap\r\n====\r\n\r\n.. image:: https://travis-ci.org/mbodenhamer/fmap.svg?branch=master\r\n :target: https://travis-ci.org/mbodenhamer/fmap\r\n \r\n.. image:: https://img.shields.io/coveralls/mbodenhamer/fmap.svg\r\n :target: https://coveralls.io/r/mbodenhamer/fmap\r\n \r\n.. image:: https://readthedocs.org/projects/fmap/badge/?version=latest\r\n :target: http://fmap.readthedocs.org/en/latest/?badge=latest\r\n\r\nA Python command-line utility for recursively applying a command to a filesystem tree.\r\n\r\nThe program works by walking the filesystem tree (either the value of ``-r``, if supplied, or the current working directory) using Python's ``os.walk``. The program is invoked with a string specifying a command to be executed at each directory in the tree. In each directory, each file (and sub-directory, if ``-d`` is specified) is matched against the list of include and exclude patterns specified at the command line. If a file (and/or directory) matches an include pattern and does not match any exclude patterns, the command is executed with that file (or directory) name as an argument. If no include patterns are specified, the program applies the command to all files (or directories) that do not match any exclude pattern.\r\n\r\nInstallation\r\n------------\r\n::\r\n\r\n $ pip install -U fmap\r\n\r\nUsage\r\n-----\r\n::\r\n\r\n Usage: fmap [-h] [-p] [-v] [-d] [-l] [-b] [-z ] [-x ] [-r ]\r\n [ [ ...]]\r\n\r\n Recursively apply a command to a filesystem tree.\r\n\r\n positional arguments:\r\n The command to apply. The file to be applied may be\r\n\t\t\t optionally specified by '{}'. If '{}' is not\r\n\t\t\t supplied, the file will be passed in as the last\r\n\t\t\t argument.\r\n Unix filename pattern that specifies which files to\r\n\t\t\t apply the command to.\r\n\r\n optional arguments:\r\n -h, --help Show this help message and exit\r\n -p, --preview Doesn't apply the command. Instead, prints command\r\n\t\t\t invocations that would be performed.\r\n -v, --verbose Print command invocations as they are performed.\r\n -d, --apply-dirs Apply the command to directories after it is applied\r\n\t\t\t to files at each level of the tree.\r\n -l, --follow-links Follow symbolic links.\r\n -b, --bottom-up Walk the tree from the bottom up. By default, the tree\r\n\t\t\t is traversed from the top down.\r\n -z , --max-depth \r\n\t\t\t Maximum recursion depth. Any negative number results\r\n\t\t\t in unlimited recursion. Default is -1.\r\n -x , --exclude \r\n\t\t\t Unix pattern that specifies which files to exclude\r\n\t\t\t applying the command to.\r\n -r , --root Directory in which to begin the traversal. Is the\r\n\t\t\t current directory by default.\r\n\r\nExamples\r\n--------\r\n\r\nSuppose you have a directory structure under ``/root``, like so::\r\n\r\n .profile\r\n file1\r\n file2\r\n dir1/\r\n file3\r\n dir3/\r\n file4\r\n dir2/\r\n file5\r\n\r\nAs a trivial example, to list all the file paths under the current directory::\r\n\r\n $ pwd\r\n /root\r\n\r\n $ fmap echo\r\n /root/file1\r\n /root/file2\r\n /root/.profile\r\n /root/dir2/file5\r\n /root/dir1/file3\r\n /root/dir1/dir3/file4\r\n\r\nTo exclude certain patterns, use the ``-x`` option::\r\n\r\n $ fmap -x .profile echo\r\n /root/file1\r\n /root/file2\r\n /root/dir2/file5\r\n /root/dir1/file3\r\n /root/dir1/dir3/file4\r\n \r\n $ fmap -x '.*' -x file[35] echo\r\n /root/file1\r\n /root/file2\r\n /root/dir1/dir3/file4\r\n \r\nRemember to quote any wildcard patterns to prevent them from being expanded by the shell.\r\n\r\nBy default, the command is applied to all files. However, you can specify include patterns after the command::\r\n\r\n $ fmap echo file1 file[35]\r\n /root/file1\r\n /root/dir2/file5\r\n /root/dir1/file3\r\n\r\nInclude and exclude patterns can be combined::\r\n\r\n $ fmap -x file[35] echo 'file*'\r\n /root/file1\r\n /root/file2\r\n /root/dir1/dir3/file4\r\n\r\nBy default, the command is not applied to directories. This can changed, however, by supplying ``-d``::\r\n\r\n $ fmap -d echo\r\n /root/file1\r\n /root/file2\r\n /root/.profile\r\n /root/dir2\r\n /root/dir1\r\n /root/dir2/file5\r\n /root/dir1/file3\r\n /root/dir1/dir3\r\n /root/dir1/dir3/file4\r\n\r\nThe command is applied to directories after it has been applied to all applicable files at that level.\r\n\r\nBy default, the file tree is walked top-down. To walk the tree bottom-up, supply the ``-b`` option::\r\n\r\n $ fmap -b echo\r\n /root/dir2/file5\r\n /root/dir1/dir3/file4\r\n /root/dir1/file3\r\n /root/file1\r\n /root/file2\r\n /root/.profile\r\n\r\nTo print out the command invocation as it is executed, supply ``-v``::\r\n\r\n $ fmap -v echo\r\n echo /root/file1\r\n /root/file1\r\n echo /root/file2\r\n /root/file2\r\n echo /root/.profile\r\n /root/.profile\r\n echo /root/dir2/file5\r\n /root/dir2/file5\r\n echo /root/dir1/file3\r\n /root/dir1/file3\r\n echo /root/dir1/dir3/file4\r\n /root/dir1/dir3/file4\r\n\r\nTo preview which command invocations will take place without actually invoking them, use the ``-p`` option::\r\n\r\n $ fmap -p 'rm -f' 'file*'\r\n rm -f /root/file1\r\n rm -f /root/file2\r\n rm -f /root/dir2/file5\r\n rm -f /root/dir1/file3\r\n rm -f /root/dir1/dir3/file4\r\n \r\nHowever, no files will actually be deleted using the above command.\r\n\r\nRemember to quote the command invocation if it includes arguments or subcommands. You can also use ``{}`` to specify where the file path should be inserted into the command invocation::\r\n\r\n $ fmap -v 'echo {} >> out'\r\n echo /root/file1 >> /root/out\r\n echo /root/file2 >> /root/out\r\n echo /root/.profile >> /root/out\r\n echo /root/dir2/file5 >> /root/out\r\n echo /root/dir1/file3 >> /root/out\r\n echo /root/dir1/dir3/file4 >> /root/out\r\n\r\n $ cat out\r\n /root/file1\r\n /root/file2\r\n /root/.profile\r\n /root/dir2/file5\r\n /root/dir1/file3\r\n /root/dir1/dir3/file4", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mbodenhamer/fmap", "keywords": "fmap,recursive,apply,command,filesystem,tree", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "fmap", "package_url": "https://pypi.org/project/fmap/", "platform": "Any", "project_url": "https://pypi.org/project/fmap/", "project_urls": { "Homepage": "https://github.com/mbodenhamer/fmap" }, "release_url": "https://pypi.org/project/fmap/0.1/", "requires_dist": null, "requires_python": null, "summary": "A command-line utility for recursively applying a command to a filesystem tree", "version": "0.1" }, "last_serial": 2066964, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "33f290e44ae1bf704461e7d1599ffa9d", "sha256": "dafee88674bcb4e4667d577862135a8f6a17efcc7cd7d1f75e28e8d18caac32b" }, "downloads": -1, "filename": "fmap-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "33f290e44ae1bf704461e7d1599ffa9d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8488, "upload_time": "2016-04-16T09:50:55", "url": "https://files.pythonhosted.org/packages/f4/18/cc15b3e5e57e2bfe7b434e11077fede701222bd707b4432a9bbee427076f/fmap-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af6a4f13dd77ecc7741c160d023b0292", "sha256": "d9c2ec12120c34ba1f176b36f5bafd3d3b1c5181ccce2ef37fe0c8348350fc47" }, "downloads": -1, "filename": "fmap-0.1.tar.gz", "has_sig": false, "md5_digest": "af6a4f13dd77ecc7741c160d023b0292", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15926, "upload_time": "2016-04-16T10:26:55", "url": "https://files.pythonhosted.org/packages/a0/15/7efbc93490a0afa1dbe986be65d3b9202079a69a29e61040c003da283053/fmap-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "33f290e44ae1bf704461e7d1599ffa9d", "sha256": "dafee88674bcb4e4667d577862135a8f6a17efcc7cd7d1f75e28e8d18caac32b" }, "downloads": -1, "filename": "fmap-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "33f290e44ae1bf704461e7d1599ffa9d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8488, "upload_time": "2016-04-16T09:50:55", "url": "https://files.pythonhosted.org/packages/f4/18/cc15b3e5e57e2bfe7b434e11077fede701222bd707b4432a9bbee427076f/fmap-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af6a4f13dd77ecc7741c160d023b0292", "sha256": "d9c2ec12120c34ba1f176b36f5bafd3d3b1c5181ccce2ef37fe0c8348350fc47" }, "downloads": -1, "filename": "fmap-0.1.tar.gz", "has_sig": false, "md5_digest": "af6a4f13dd77ecc7741c160d023b0292", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15926, "upload_time": "2016-04-16T10:26:55", "url": "https://files.pythonhosted.org/packages/a0/15/7efbc93490a0afa1dbe986be65d3b9202079a69a29e61040c003da283053/fmap-0.1.tar.gz" } ] }