{ "info": { "author": "Justin Dane Vrana", "author_email": "justin.vrana@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "|travis build| |Coverage Status| |PyPI version| |License: MIT|\n\nBuild/Coverage Status\n^^^^^^^^^^^^^^^^^^^^^\n\n+-------------------+------------------+---------------------+\n| Branch | Build | Coverage |\n+===================+==================+=====================+\n| **master** | |travis build| | |Coverage Status| |\n+-------------------+------------------+---------------------+\n| **development** | |travis build| | |Coverage Status| |\n+-------------------+------------------+---------------------+\n\n\ud83d\udcc1 MagicDir \ud83d\udcc1\n============\n\nDealing with paths and directories isn't rocket science, but it can be a\npain. **MagicDir** allows you to build directory trees by treating your\ndirectory tree as a first-class object.\n\nStop writing your directory trees like this:\n\n.. code:: python\n\n # define paths\n top = os.path.abspath('top')\n middle = os.path.join(str(top), 'middle')\n bottom = os.path.join(str(middle), 'bottom')\n os.makedirs(bottom)\n with open(os.path.join(bottom, 'bottomlog.txt', 'w') as f:\n f.write(\"some log information\")\n\nAnd start writing them like this:\n\n.. code:: python\n\n # define paths\n env = MagicDir('top').add('middle').add('bottom').root\n env.bottom.write('log.txt', 'w', 'some log information')\n\nLive usage:\n\n.. figure:: images/magicdir_example.gif?raw=true\n :alt: live\\_example\n\n live\\_example\n\nIts very easy to create, move, or delete directory trees. For example,\nthe following builds the directory skeleton for this repo.\n\n.. figure:: images/directory_example.png?raw=true\n :alt: demo\n\n demo\n\n.. code:: python\n\n from magicdir import *\n\n # create folder structure\n env = MagicDir('magicdir')\n env.add('magicdir', alias='core')\n env.core.add('tests')\n env.tests.add('env')\n env.tests.add('env2')\n\n # make the directory\n env.set_dir(Path(__file__).absolute().parent)\n env.mkdirs()\n\n # write some files\n env.write('README.md', 'w', '# Magic Dir\\nThis is a test readme file')\n env.core.write(\"__init__.py\", \"w\", \"__version__ = \\\"1.0\\\"\")\n\nOther things you can do:\n\nAbstracting the directory structure lets your create, remove, copy, move\ndirectory trees easily.\n\n.. figure:: images/rmdirs_example.gif?raw=true\n :alt: rmdirs\\_example\n\n rmdirs\\_example\n\nAll paths are easily accessible.\n\n.. code:: python\n\n print(env.test.abspath) # absolute path\n print(env.test.path) # relative path\n\nYou can even read and write files intuitively.\n\n.. code:: python\n\n # writes file to 'test' folder\n env.test.write('test.txt', 'w', 'some data')\n\n # reads test file\n env.test.read('test.txt', 'r')\n\n # open file and read lines\n env.test.open('test.txt', 'r').readlines()\n\nAll iterables are magically chainable making it easy to do complex\nthings. Pretty cool!\n\n.. code:: python\n\n # recurseively write a log file to all subfolders of 'core'\n env.core.descendents.write('log.txt', 'w', 'some log file')\n\n # read all files named 'log.txt' for subfolders in 'test'\n env.test.children.read('log.txt', 'r')\n\n # readlines files named 'log.txt' for subfolders in 'test'\n env.test.children.open('log.txt', 'r').readlines()\n\n # recursively get stats on folders\n d = env.descendents()\n zip(d, d.stat().st_mtime)\n\nBetter documentation about chaining methods is soon to come along with\nrecipes.\n\nInstallation\n============\n\nInstallation via pip is the easiest way...\n\n.. code:: bash\n\n pip install magicdir\n\nBasic usage\n===========\n\nUse ``add`` to create folders.\n\n.. code:: python\n\n from magicdir import *\n\n env = MagicDir('bin')\n env.add('subfolder1')\n env.add('subfolder2')\n env.print()\n\n >>>\n *bin\n | *subfolder1\n | *subfolder2\n\nFunctions return MagicDir objects and so can be chained together.\n\n.. code:: python\n\n env = MagicDir('bin')\n env.add('subfolder1').add('subsubfolder')\n env.print()\n\n >>>\n *bin\n | *subfolder1\n | | *subsubfolder\n\nAdd can be chained together\n\n.. code:: python\n\n env = MagicDir('bin')\n env.add('subfolder1').add('subsubfolder')\n env.print()\n\n >>>\n *bin\n | *subfolder1\n | | *subsubfolder\n\nFolders create accesible MagicDir attributes automatically. Alternative\nattribute names can be set using 'alias='\n\n.. code:: python\n\n env = MagicDir('bin')\n env.add('subfolder1')\n env.subfolder1.add('misc')\n env.subfolder1.misc.add('.hidden', alias='hidden')\n env.subfolder1.misc.hidden.add('hiddenbin')\n env.print()\n\n *bin\n | *subfolder1\n | | *misc\n | | | *.hidden (\"hidden\")\n | | | | *hiddenbin\n\nBy default, attributes are *pushed* back the the root directory. The\nfollowing is equivalent to above.\n\n.. code:: python\n\n env = MagicDir('bin')\n env.add('subfolder1')\n env.subfolder1.add('misc')\n env.misc.add('.hidden', alias='hidden')\n env.hidden.add('hiddenbin')\n env.print()\n\n *bin\n | *subfolder1\n | | *misc\n | | | *.hidden (\"hidden\")\n | | | | *hiddenbin\n\nMaking, moving, copying, and deleting directories\n=================================================\n\nThe location of the root folder can be set by ``set_bin``\n\n.. code:: python\n\n env.set_bin('../bin')\n\nDirectories can be created, deleted, copied or moved using ``mkdirs``,\n``cpdirs``, ``mvdirs``, ``rmdirs``\n\n.. code:: python\n\n env.mkdirs()\n env_copy = env.cpdirs()\n # you can do stuff with env_copy independently\n env.mvdirs('~/Document')\n env_copy.rmdirs()\n\nAdvanced usage\n==============\n\nAll iterables return special list-like objects that can be chained in\none-liners.\n\n.. code:: python\n\n env.descendents() # returns a MagicList object\n\n # find all txt files\n env.descendents(include_self=True).glob(\"*.txt\")\n\n # recursively change permissions for directories\n env.abspaths.chmod(0o444)\n\n.. |travis build| image:: https://img.shields.io/travis/jvrana/magicdir.svg\n :target: https://travis-ci.org/jvrana/magicdir\n.. |Coverage Status| image:: https://coveralls.io/repos/github/jvrana/magicdir/badge.svg?branch=master\n :target: https://coveralls.io/github/jvrana/magicdir?branch=master\n.. |PyPI version| image:: https://badge.fury.io/py/REPO.svg\n :target: https://badge.fury.io/py/REPO\n.. |License: MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg\n :target: https://opensource.org/licenses/MIT\n.. |travis build| image:: https://img.shields.io/travis/jvrana/magicdir/master.svg\n :target: https://travis-ci.org/jvrana/magicdir/master\n.. |travis build| image:: https://img.shields.io/travis/jvrana/magicdir/development.svg\n :target: https://travis-ci.org/jvrana/magicdir/development\n.. |Coverage Status| image:: https://coveralls.io/repos/github/jvrana/magicdir/badge.svg?branch=development\n :target: https://coveralls.io/github/jvrana/magicdir?branch=development", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jvrana/magicdir", "keywords": "directory python tree", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "magicdir", "package_url": "https://pypi.org/project/magicdir/", "platform": "", "project_url": "https://pypi.org/project/magicdir/", "project_urls": { "Homepage": "https://github.com/jvrana/magicdir" }, "release_url": "https://pypi.org/project/magicdir/0.3.1a/", "requires_dist": null, "requires_python": "", "summary": "intuitive python directory tree management for all", "version": "0.3.1a" }, "last_serial": 3408235, "releases": { "0.1.2a": [ { "comment_text": "", "digests": { "md5": "348d64f4899b5ca168f8ac7cbf4421f1", "sha256": "f544df56ca3a3f0e4c52039600faf2017eff5952e04e43a714aea47cbf9bec9d" }, "downloads": -1, "filename": "magicdir-0.1.2a.tar.gz", "has_sig": false, "md5_digest": "348d64f4899b5ca168f8ac7cbf4421f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7257, "upload_time": "2017-10-30T08:16:35", "url": "https://files.pythonhosted.org/packages/70/9d/2a6e3e67cf970b194a573fa512112b91023f82b0a907f4d9d00f52aeb9b2/magicdir-0.1.2a.tar.gz" } ], "0.2.0a": [ { "comment_text": "", "digests": { "md5": "2eb878f3f0768afcd6ac87d71b5ac56e", "sha256": "3b9596b74d494dfcf5b069e79fbf9592d5286b32c4aa298eac81929acebe05f3" }, "downloads": -1, "filename": "magicdir-0.2.0a.tar.gz", "has_sig": false, "md5_digest": "2eb878f3f0768afcd6ac87d71b5ac56e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8869, "upload_time": "2017-11-02T06:52:29", "url": "https://files.pythonhosted.org/packages/fa/33/260ae34fcaa7d0d3f26dedce3123f7dfe3a78fb893ed5d0a65d97c8718bc/magicdir-0.2.0a.tar.gz" } ], "0.2.1a": [ { "comment_text": "", "digests": { "md5": "a00ca607e6f3c20574e512b3b80134aa", "sha256": "5c1173badeee779858cba2655b5d2e8426c57d2a682c5789beae373bf5c378ce" }, "downloads": -1, "filename": "magicdir-0.2.1a.tar.gz", "has_sig": false, "md5_digest": "a00ca607e6f3c20574e512b3b80134aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8864, "upload_time": "2017-11-02T07:22:41", "url": "https://files.pythonhosted.org/packages/74/03/4a8e20caab65b9ae380606c4b7b27e5a8e040baedef8b8abd75764b055a5/magicdir-0.2.1a.tar.gz" } ], "0.3.1a": [ { "comment_text": "", "digests": { "md5": "0fce15e2779ab992b09f006a4f212d15", "sha256": "6ae69266a4893ad516d2c3afc81795a10de86570720067dc3afe7c33f203f8ab" }, "downloads": -1, "filename": "magicdir-0.3.1a.tar.gz", "has_sig": false, "md5_digest": "0fce15e2779ab992b09f006a4f212d15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10361, "upload_time": "2017-12-11T19:04:42", "url": "https://files.pythonhosted.org/packages/ac/1e/228ad6f17c74be17bc396f68f085abbea5beeb5b4896a44a3923cf633322/magicdir-0.3.1a.tar.gz" } ], "0.3a": [ { "comment_text": "", "digests": { "md5": "09194f55632081c71ffccba0152447cb", "sha256": "67d28a394b1dba25a86c372b142fb6a699e3cc36551d4c7c6e2ba701c9b2013c" }, "downloads": -1, "filename": "magicdir-0.3a.tar.gz", "has_sig": false, "md5_digest": "09194f55632081c71ffccba0152447cb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10328, "upload_time": "2017-12-09T20:23:21", "url": "https://files.pythonhosted.org/packages/97/31/1c91b3f5bb0d8fddbcb3d419c7b85140e9e007887cc01f5f2fd857728655/magicdir-0.3a.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0fce15e2779ab992b09f006a4f212d15", "sha256": "6ae69266a4893ad516d2c3afc81795a10de86570720067dc3afe7c33f203f8ab" }, "downloads": -1, "filename": "magicdir-0.3.1a.tar.gz", "has_sig": false, "md5_digest": "0fce15e2779ab992b09f006a4f212d15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10361, "upload_time": "2017-12-11T19:04:42", "url": "https://files.pythonhosted.org/packages/ac/1e/228ad6f17c74be17bc396f68f085abbea5beeb5b4896a44a3923cf633322/magicdir-0.3.1a.tar.gz" } ] }