RandomFileTree: Generate random file tree
===========================================================================
|Build Status| |Coveralls| |Doc Status| |Pypi status| |Chat| |License|
.. |Build Status| image:: https://travis-ci.org/klieret/RandomFileTree.svg?branch=master
:target: https://travis-ci.org/klieret/RandomFileTree
.. |Coveralls| image:: https://coveralls.io/repos/github/klieret/RandomFileTree/badge.svg?branch=master
:target: https://coveralls.io/github/klieret/RandomFileTree?branch=master
.. |Doc Status| image:: https://readthedocs.org/projects/randomfiletree/badge/?version=latest
:target: https://randomfiletree.readthedocs.io/
:alt: Documentation Status
.. |Pypi Status| image:: https://badge.fury.io/py/RandomFileTree.svg
:target: https://badge.fury.io/py/RandomFileTree
:alt: Pypi status
.. |Chat| image:: https://img.shields.io/gitter/room/RandomFileTree/community.svg
:target: https://gitter.im/RandomFileTree/community
:alt: Gitter
.. |License| image:: https://img.shields.io/github/license/klieret/RandomFileTree.svg
:target: https://github.com/klieret/RandomFileTree/blob/master/LICENSE.txt
:alt: License
.. start-body
Description
-----------
Create a random file and directory tree/structure for testing purposes.
Installation
------------
``AnkiPandas`` can be installed with the python package manager:
.. code:: sh
pip3 install randomfiletree
For a local installation, you might want to use the ``--user`` switch of ``pip``.
You can also update your current installation with ``pip3 install --upgrade ankipandas``.
For the latest development version you can also work from a cloned version
of this repository:
.. code:: sh
git clone https://github.com/klieret/randomfiletree/
cd randomfiletree
pip3 install --user .
Usage
-----
Simple command line interface:
.. code:: sh
randomfiletree <folder> -f <file creation probability> -d <directory creation probability> -r <repeat>
Type ``randomfiletree -h`` to see all supported arguments.
If the executable is not in your path after installation, you can also use
``python3 -m randomfiletree <arguments as above>``.
.. code:: python
import randomfiletree
randomfiletree.iterative_gaussian_tree(
"/path/to/basedir",
nfiles=2.0,
nfolders=0.5,
maxdepth=5,
repeat=4
)
Randomfiletree will now crawl through all directories in ``/path/to/basedir`` and
create new files with the probabilities given in the arguments.
It is possible to pass an optional function to generate the random filenames oneself:
.. code:: python
import random
import string
def fname():
length = random.randint(5, 10)
return "".join(
random.choice(string.ascii_uppercase + string.digits)
for _ in range(length)
) + '.docx'
randomfiletree.core.iterative_gaussian_tree(
"/path/to/basedir",
nfiles=100,
nfolders=10,
maxdepth=2,
filename=fname
)
The ``payload`` optional argument can be used to generate file contents together with their names.
For example, it can be used to replicate some template files with randomized names:
.. code:: python
import itertools
import pathlib
import randomfiletree
def callback(target_dir: pathlib.Path) -> pathlib.Path:
sourcedir = pathlib.Path("/path/to/templates/")
sources = []
for srcfile in sourcedir.iterdir():
with open(srcfile, 'rb') as f:
content = f.read()
sources.append((srcfile.suffix, content))
for srcfile in itertools.cycle(sources):
path = target_dir / (randomfiletree.core.random_string() + srcfile[0])
with path.open('wb') as f:
f.write(srcfile[1])
yield path
randomfiletree.core.iterative_gaussian_tree(
"/path/to/basedir",
nfiles=10,
nfolders=10,
maxdepth=5,
repeat=4,
payload=callback
)
if both ``filename`` and ``payload`` passed, the first option is ignored.
Take a look at the documentation_ to find out more about the additional functionality provided.
.. _documentation: https://randomfiletree.readthedocs.io/
License
-------
This software is lienced under the `MIT license`_.
.. _MIT license: https://github.com/klieret/ankipandas/blob/master/LICENSE.txt
.. end-body
Raw data
{
"_id": null,
"home_page": "https://github.com/klieret/RandomFileTree",
"name": "RandomFileTree",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "testing,filetree,tree",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/8d/72/0ffefe0e5a4d9c9c289947f8ee9467cf66780cfd5c2346b8b1ad4ba84944/RandomFileTree-1.2.0.tar.gz",
"platform": "",
"description": "RandomFileTree: Generate random file tree\n===========================================================================\n\n|Build Status| |Coveralls| |Doc Status| |Pypi status| |Chat| |License|\n\n.. |Build Status| image:: https://travis-ci.org/klieret/RandomFileTree.svg?branch=master\n :target: https://travis-ci.org/klieret/RandomFileTree\n\n.. |Coveralls| image:: https://coveralls.io/repos/github/klieret/RandomFileTree/badge.svg?branch=master\n :target: https://coveralls.io/github/klieret/RandomFileTree?branch=master\n\n.. |Doc Status| image:: https://readthedocs.org/projects/randomfiletree/badge/?version=latest\n :target: https://randomfiletree.readthedocs.io/\n :alt: Documentation Status\n\n.. |Pypi Status| image:: https://badge.fury.io/py/RandomFileTree.svg\n :target: https://badge.fury.io/py/RandomFileTree\n :alt: Pypi status\n\n.. |Chat| image:: https://img.shields.io/gitter/room/RandomFileTree/community.svg\n :target: https://gitter.im/RandomFileTree/community\n :alt: Gitter\n\n.. |License| image:: https://img.shields.io/github/license/klieret/RandomFileTree.svg\n :target: https://github.com/klieret/RandomFileTree/blob/master/LICENSE.txt\n :alt: License\n\n.. start-body\n\nDescription\n-----------\n\nCreate a random file and directory tree/structure for testing purposes.\n\n\nInstallation\n------------\n\n``AnkiPandas`` can be installed with the python package manager:\n\n.. code:: sh\n\n pip3 install randomfiletree\n\nFor a local installation, you might want to use the ``--user`` switch of ``pip``.\nYou can also update your current installation with ``pip3 install --upgrade ankipandas``.\n\nFor the latest development version you can also work from a cloned version\nof this repository:\n\n.. code:: sh\n\n git clone https://github.com/klieret/randomfiletree/\n cd randomfiletree\n pip3 install --user .\n\nUsage\n-----\n\nSimple command line interface:\n\n.. code:: sh\n\n randomfiletree <folder> -f <file creation probability> -d <directory creation probability> -r <repeat>\n\nType ``randomfiletree -h`` to see all supported arguments.\n\nIf the executable is not in your path after installation, you can also use\n``python3 -m randomfiletree <arguments as above>``.\n\n.. code:: python\n\n import randomfiletree\n\n randomfiletree.iterative_gaussian_tree(\n \"/path/to/basedir\",\n nfiles=2.0,\n nfolders=0.5,\n maxdepth=5,\n repeat=4\n )\n\n\nRandomfiletree will now crawl through all directories in ``/path/to/basedir`` and\ncreate new files with the probabilities given in the arguments.\n\nIt is possible to pass an optional function to generate the random filenames oneself:\n\n.. code:: python\n\n import random\n import string\n\n def fname():\n length = random.randint(5, 10)\n return \"\".join(\n random.choice(string.ascii_uppercase + string.digits)\n for _ in range(length)\n ) + '.docx'\n\n randomfiletree.core.iterative_gaussian_tree(\n \"/path/to/basedir\",\n nfiles=100,\n nfolders=10,\n maxdepth=2,\n filename=fname\n )\n\nThe ``payload`` optional argument can be used to generate file contents together with their names.\nFor example, it can be used to replicate some template files with randomized names:\n\n.. code:: python\n\n import itertools\n import pathlib\n import randomfiletree\n\n def callback(target_dir: pathlib.Path) -> pathlib.Path:\n sourcedir = pathlib.Path(\"/path/to/templates/\")\n sources = []\n for srcfile in sourcedir.iterdir():\n with open(srcfile, 'rb') as f:\n content = f.read()\n sources.append((srcfile.suffix, content))\n for srcfile in itertools.cycle(sources):\n path = target_dir / (randomfiletree.core.random_string() + srcfile[0])\n with path.open('wb') as f:\n f.write(srcfile[1])\n yield path\n\n randomfiletree.core.iterative_gaussian_tree(\n \"/path/to/basedir\",\n nfiles=10,\n nfolders=10,\n maxdepth=5,\n repeat=4,\n payload=callback\n )\n\nif both ``filename`` and ``payload`` passed, the first option is ignored.\n\nTake a look at the documentation_ to find out more about the additional functionality provided.\n\n.. _documentation: https://randomfiletree.readthedocs.io/\n\nLicense\n-------\n\nThis software is lienced under the `MIT license`_.\n\n.. _MIT license: https://github.com/klieret/ankipandas/blob/master/LICENSE.txt\n\n.. end-body\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Create a random file/directory tree/structure in python fortesting purposes.",
"version": "1.2.0",
"split_keywords": [
"testing",
"filetree",
"tree"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "9dcfdd616f120b0d115e0176a8e3d6a3",
"sha256": "5c22868879754231452c715b97829a6ddb1d5d59941ed05822f7a0285204c8fe"
},
"downloads": -1,
"filename": "RandomFileTree-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9dcfdd616f120b0d115e0176a8e3d6a3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9435,
"upload_time": "2020-04-10T12:41:15",
"upload_time_iso_8601": "2020-04-10T12:41:15.325567Z",
"url": "https://files.pythonhosted.org/packages/34/8d/436df1300452ef6991aa5013fc75356f14ccb94dfacedc58f2139e935358/RandomFileTree-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "f98c28f5d46a222bf71c77ea946f4273",
"sha256": "3a92e12ecbf093dc6b3fc1405c69030ed32db3a8a4a71f28724bd347f4c49afc"
},
"downloads": -1,
"filename": "RandomFileTree-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "f98c28f5d46a222bf71c77ea946f4273",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6977,
"upload_time": "2020-04-10T12:41:17",
"upload_time_iso_8601": "2020-04-10T12:41:17.004464Z",
"url": "https://files.pythonhosted.org/packages/8d/72/0ffefe0e5a4d9c9c289947f8ee9467cf66780cfd5c2346b8b1ad4ba84944/RandomFileTree-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-04-10 12:41:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "klieret",
"github_project": "RandomFileTree",
"travis_ci": true,
"coveralls": true,
"github_actions": true,
"lcname": "randomfiletree"
}