{ "info": { "author": "Iv\u00e1n de Paz Centeno", "author_email": "ipazc@unileon.es", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "Natural Language :: English", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "==============\npyfolder 0.0.2\n==============\n\n`PyFolder` is a package for managing a filesystem folders as a dictionary.\n\n.. image:: https://badge.fury.io/py/pyfolder.svg\n :target: https://badge.fury.io/py/pyfolder\n\n.. image:: https://travis-ci.org/ipazc/pyfolder.svg?branch=master\n :target: https://travis-ci.org/ipazc/pyfolder\n\n.. image:: https://coveralls.io/repos/github/ipazc/pyfolder/badge.svg?branch=master\n :target: https://coveralls.io/github/ipazc/pyfolder?branch=master\n\n.. image:: https://landscape.io/github/ipazc/pyfolder/master/landscape.svg?style=flat\n :target: https://landscape.io/github/ipazc/pyfolder/master\n :alt: Code Health\n\n\nInstallation\n============\nCurrently it is only supported **Python 3.4.1** onwards:\n\n.. code:: bash\n\n sudo pip3 install pyfolder\n\n\nExample\n=======\n.. code:: python\n\n >>> from pyfolder import PyFolder\n >>> \n >>> pyfolder = PyFolder(\"/path/to/folder\")\n >>> pyfolder[\"file.txt\"] = \"hello, this is going to be instantly the content of this file.\"\n\nBasic Usage\n===========\n`PyFolder` can easily store or read content from the filesystem. The usage is the same as a normal dictionary:\n\n* **Create a file with specific binary content:**\n\n.. code:: python\n\n >>> from pyfolder import PyFolder\n >>> \n >>> pyfolder = PyFolder(\"/path/to/folder\")\n >>> pyfolder['file.bin'] = b\"Content as bytes\"\n >>> pyfolder['file.txt'] = \"Content as text\"\n >>> pyfolder['file.json'] = {\"content\": \"Content as JSON\"}\n\n\n`PyFolder` automatically detects the kind of content to store.\n\nIt is also possible to reference the creation of a file in relative file URI notation:\n\n.. code:: python\n\n >>> pyfolder[\"folder1/folder2/file.txt\"] = \"content\"\n\nIf folder specified doesn't exist, by default it will be created automatically unless the flag `auto_create_folder` is set to `False` during instantiation:\n\n.. code:: python\n\n >>> pyfolder = PyFolder(\"/path/to/folder\", auto_create_folder=False)\n\nNote that \".\" or \"..\" chars are not allowed in URI notation, it must be relative URIs to the root.\n\n\n* **Get specific content:**\n\n.. code:: python\n\n >>> pyfolder = PyFolder(\"/path/to/folder\")\n >>> pyfolder['file.bin']\n b\"Content as bytes\"\n >>> pyfolder['file.txt']\n \"Content as text\"\n >>> pyfolder['file.json']\n {\"content\": \"Content as JSON\"}\n >>> pyfolder['folder1/folder2/file.bin']\n b\"Other content\"\n\nBy default `PyFolder` will attempt to load the content with the best interpreter it has, based on the file extension. If no interpreter is found for\na content, it will return the content in bytes format. This behaviour can be disabled with the flag `interpret=False` during instantiation:\n\n.. code:: python\n\n >>> pyfolder = PyFolder(\"/path/to/folder\", interpret=False)\n\n\n* **Edit content:**\n\n`PyFolder` won't allow modification or removal of elements unless the flag `allow_override` is specified during instantiation:\n\n.. code:: python\n\n >>> pyfolder = PyFolder(\"/path/to/folder\", allow_override=True)\n >>> pyfolder['file.bin'] = b\"replaced_content_bytes\"\n\n\n* **Remove content:**\n\n.. code:: python\n\n >>> del pyfolder['file.bin']\n\n\nNote that a folder can also be removed:\n\n.. code:: python\n\n >>> del pyfolder['folder1']\n >>> del pyfolder['.'] # deletes PyFolder root folder\n\n\nBy default PyFolder won't remove a folder unless its content is empty. In order to be able to remove folders without restriction, enable the flag `allow_remove_folders_with_content`\n\n.. code:: python\n\n >>> pyfolder = PyFolder(\"/path/to/folder\", allow_remove_folders_with_content=True)\n\n\n* **Iterate over the files:**\n\nBy default `PyFolder` allows iteration over files, including the folders:\n\n.. code:: python\n\n >>> for file_name in pyfolder:\n >>> print(file_name)\n\nIf it is wanted to access also the content, it can be done with the `items()` method:\n\n.. code:: python\n\n >>> for file_name, content in pyfolder.items():\n >>> print(file_name, content)\n\nIf only files are wanted, the `files()` method exists to serve the purpose:\n\n.. code:: python\n\n >>> for file_name in pyfolder.files()\n ...\n >>> for file_name, content in pyfolder.files_items()\n\n\n* **Iterate over folders:**\n\n.. code:: python\n\n >>> for folder_name in pyfolder.folders():\n ...\n\n\nit is also possible to iterate over the folder name and its content at the same time:\n\n\n.. code:: python\n\n >>> for folder_name, folder_content in pyfolder.folders_items():\n ...\n\n\nIn `PyFolder`, each folder is a `PyFolder` object. It is perfectly possible to nest folders as follows:\n\n.. code:: python\n\n >>> pyfolder[\"folder1\"][\"folder2\"]\n >>> pyfolder[\"folder1/folder2\"] # Equivalent in relative URI notation\n\n\n* **Search for files:**\n\n`PyFolder` eases the search of a file/folder by matching a name. It will return the list of relative URIs of the file-names found:\n\n.. code:: python\n\n >>> pyfolder.index(\"name.bin\")\n >>> ['path/to/name.bin', 'path2/to/name.bin']\n\n\nLICENSE\n=======\n\nIt is released under the MIT license.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/ipazc/pyfolder", "keywords": "pyfolder dict folder file filesystem", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pyfolder", "package_url": "https://pypi.org/project/pyfolder/", "platform": "", "project_url": "https://pypi.org/project/pyfolder/", "project_urls": { "Homepage": "http://github.com/ipazc/pyfolder" }, "release_url": "https://pypi.org/project/pyfolder/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "PyFolder is a package for managing filesystem folders as a dictionary.", "version": "0.0.2" }, "last_serial": 3236830, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "55e919d825c05816b0772ee219d634c6", "sha256": "47ab2298a22befb382aa13b69649cfc075c2f39a61965407a589d5a67bd2d3b7" }, "downloads": -1, "filename": "pyfolder-0.0.1.tar.gz", "has_sig": false, "md5_digest": "55e919d825c05816b0772ee219d634c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8035, "upload_time": "2017-10-08T18:21:39", "url": "https://files.pythonhosted.org/packages/ac/06/2e2b5aabaf4f0125e196635d95e08d400f6da6fd9cb3163124c53bbacfed/pyfolder-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "af8a8371efd574a54d64a37ac4dd283e", "sha256": "7a3c0fb1e6387939881d419fbd891036cc55cfa04cede704ff2f58120a27b002" }, "downloads": -1, "filename": "pyfolder-0.0.2.tar.gz", "has_sig": false, "md5_digest": "af8a8371efd574a54d64a37ac4dd283e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9517, "upload_time": "2017-10-09T16:59:07", "url": "https://files.pythonhosted.org/packages/1b/0f/8e997f6a735b9e59af76eb3c292106503d40ccc2b9662e817914ef8b114a/pyfolder-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af8a8371efd574a54d64a37ac4dd283e", "sha256": "7a3c0fb1e6387939881d419fbd891036cc55cfa04cede704ff2f58120a27b002" }, "downloads": -1, "filename": "pyfolder-0.0.2.tar.gz", "has_sig": false, "md5_digest": "af8a8371efd574a54d64a37ac4dd283e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9517, "upload_time": "2017-10-09T16:59:07", "url": "https://files.pythonhosted.org/packages/1b/0f/8e997f6a735b9e59af76eb3c292106503d40ccc2b9662e817914ef8b114a/pyfolder-0.0.2.tar.gz" } ] }