{ "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 ODir \ud83d\udcc1\n========\n\nDealing with paths and directories isn't rocket science, but it can be a\npain. **ODir** allows you to build directory trees by treating your\ndirectory tree as a first-class object.\n\n**Documentation** can be found here\nhttps://opath.readthedocs.io/en/latest/\n\n**without ODir**\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\n**with ODir**\n\n.. code:: python\n\n # define paths\n env = ODir('top').add('middle').add('bottom').root\n env.bottom.write('log.txt', 'w', 'some log information')\n\nInstallation\n============\n\nInstallation via pip is the easiest way...\n\n.. code:: bash\n\n pip install opath\n\nAlternatives\n============\n\nProjects like\n`pathlib `__ or\n`path.py `__ encapsulating paths into\nobjects and may be better suited for you purposes.\n\nHowever, ODir provides some useful features for managing large directory\ntree structures. \\* building directory and file structure trees as an\nabstract tree \\* quick access to deeply nested directories and files\nusing custom attribute names \\* directories and files are treated as\nnested attributes in python objects\n\nExamples\n========\n\n.. figure:: images/dir_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 opath import *\n\n # create folder structure\n env = ODir('opath')\n env.add('opath', 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', '# ODir\\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 chainable making it easy to do complex things. Pretty\ncool!\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\nBasic usage\n===========\n\nUse ``add`` to create folders.\n\n.. code:: python\n\n from opath import *\n\n env = ODir('bin')\n env.add('subfolder1')\n env.add('subfolder2')\n env.print()\n\n >>>\n *bin\n | *subfolder1\n | *subfolder2\n\nFunctions return ODir objects and so can be chained together.\n\n.. code:: python\n\n env = ODir('bin')\n env.add('subfolder1').add('subsubfolder')\n env.print()\n\n >>>\n *bin\n | *subfolder1\n | | *subsubfolder\n\nFiles can be written quickly\n\n.. code:: python\n\n env = ODir('bin')\n env.add('subfolder1').add('subsubfolder')\n env.subsubfolder.write('My Data', 'w')\n\nOr a OFile can be added:\n\n.. code:: python\n\n env = ODir('bin')\n env.add_file('myfile.txt', attr='myfile')\n env.myfile.write('this is my data', 'w')\n\nFolders create accesible ODir attributes automatically. Alternative\nattribute names can be set using 'alias='\n\n.. code:: python\n\n env = ODir('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 = ODir('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 ChainList 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/opath.svg\n :target: https://travis-ci.org/jvrana/opath\n.. |Coverage Status| image:: https://coveralls.io/repos/github/jvrana/opath/badge.svg?branch=master\n :target: https://coveralls.io/github/jvrana/opath?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/opath/master.svg\n :target: https://travis-ci.org/jvrana/opath/master\n.. |travis build| image:: https://img.shields.io/travis/jvrana/opath/development.svg\n :target: https://travis-ci.org/jvrana/opath/development\n.. |Coverage Status| image:: https://coveralls.io/repos/github/jvrana/opath/badge.svg?branch=development\n :target: https://coveralls.io/github/jvrana/opath?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/opath", "keywords": "directory python tree path", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "opath", "package_url": "https://pypi.org/project/opath/", "platform": "", "project_url": "https://pypi.org/project/opath/", "project_urls": { "Homepage": "https://github.com/jvrana/opath" }, "release_url": "https://pypi.org/project/opath/0.5.1/", "requires_dist": null, "requires_python": "", "summary": "intuitive python directory tree management for all", "version": "0.5.1" }, "last_serial": 3483108, "releases": { "0.5.1": [ { "comment_text": "", "digests": { "md5": "a938fcbbb6b892fca1b87eb790244cb4", "sha256": "5ad8ace1a4ace310eb504db476fe53378e9b8ac3fb2c4326eeea698d3176bea1" }, "downloads": -1, "filename": "opath-0.5.1.tar.gz", "has_sig": false, "md5_digest": "a938fcbbb6b892fca1b87eb790244cb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11804, "upload_time": "2018-01-12T06:57:16", "url": "https://files.pythonhosted.org/packages/ed/90/d3836626dfd7ab17b34980336741ea42fca09fdc077f070c809c160c142d/opath-0.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a938fcbbb6b892fca1b87eb790244cb4", "sha256": "5ad8ace1a4ace310eb504db476fe53378e9b8ac3fb2c4326eeea698d3176bea1" }, "downloads": -1, "filename": "opath-0.5.1.tar.gz", "has_sig": false, "md5_digest": "a938fcbbb6b892fca1b87eb790244cb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11804, "upload_time": "2018-01-12T06:57:16", "url": "https://files.pythonhosted.org/packages/ed/90/d3836626dfd7ab17b34980336741ea42fca09fdc077f070c809c160c142d/opath-0.5.1.tar.gz" } ] }