file structure generator with onefile script
Project description
filegen
========================================
.. code-block:: python
fg = Filegen()
with fg.dir("foo"):
with fg.file("hello.txt") as wf:
wf.write("hello")
with fg.dir("bar"):
with fg.file("x") as wf:
wf.write("x")
with fg.file("bye.txt") as wf:
wf.write("bye")
fg.to_python_module()
generated files ::
foo/
├── __init__.py
├── bar
│ ├── __init__.py
│ └── x
├── bye.txt
└── hello.txt
making file-structure generating application
----------------------------------------
Using `FilegenApplication` for creating file structure generating command.
Writing a script file such as below.
.. code-block:: python
# myscript.py
if __name__ == "__main__":
from filegen import Filegen, FilegenApplication
fg = Filegen()
with fg.dir("foo"):
with fg.file("bar.py") as wf:
wf.write("# this is comment file")
with fg.file("readme.txt") as wf:
wf.write("# foo")
FilegenApplication().run(fg)
then.
.. code-block:: shell
$ python myscript.py --action=string /tmp
d:/tmp
d:/tmp/foo
f:/tmp/foo/bar.py
# this is comment file
d:/tmp/foo
f:/tmp/foo/readme.txt
# foo
$ python myscript.py --action=string /foo/bar
d:/foo/bar
d:/foo/bar/foo
f:/foo/bar/foo/bar.py
# this is comment file
d:/foo/bar/foo
f:/foo/bar/foo/readme.txt
# foo
========================================
.. code-block:: python
fg = Filegen()
with fg.dir("foo"):
with fg.file("hello.txt") as wf:
wf.write("hello")
with fg.dir("bar"):
with fg.file("x") as wf:
wf.write("x")
with fg.file("bye.txt") as wf:
wf.write("bye")
fg.to_python_module()
generated files ::
foo/
├── __init__.py
├── bar
│ ├── __init__.py
│ └── x
├── bye.txt
└── hello.txt
making file-structure generating application
----------------------------------------
Using `FilegenApplication` for creating file structure generating command.
Writing a script file such as below.
.. code-block:: python
# myscript.py
if __name__ == "__main__":
from filegen import Filegen, FilegenApplication
fg = Filegen()
with fg.dir("foo"):
with fg.file("bar.py") as wf:
wf.write("# this is comment file")
with fg.file("readme.txt") as wf:
wf.write("# foo")
FilegenApplication().run(fg)
then.
.. code-block:: shell
$ python myscript.py --action=string /tmp
d:/tmp
d:/tmp/foo
f:/tmp/foo/bar.py
# this is comment file
d:/tmp/foo
f:/tmp/foo/readme.txt
# foo
$ python myscript.py --action=string /foo/bar
d:/foo/bar
d:/foo/bar/foo
f:/foo/bar/foo/bar.py
# this is comment file
d:/foo/bar/foo
f:/foo/bar/foo/readme.txt
# foo
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
filegen-0.2.1.tar.gz
(11.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
filegen-0.2.1-py3-none-any.whl
(15.5 kB
view details)
File details
Details for the file filegen-0.2.1.tar.gz.
File metadata
- Download URL: filegen-0.2.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff7425a6322e5d7cb4d221e1d543dca6973fbca11a1b35e09221afc96218b2d9
|
|
| MD5 |
35551ec35e5fb9632ede6ce24cadbbf4
|
|
| BLAKE2b-256 |
fccbf6b2b13b08afb291e8603e31724510cfb9935d3d017eaa4adc908eb90e4b
|
File details
Details for the file filegen-0.2.1-py3-none-any.whl.
File metadata
- Download URL: filegen-0.2.1-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d65d36b8896e1a29800af5060ef6cd4b75ea8a93e751908de221a19f089ba938
|
|
| MD5 |
42022c9643f737976044f4375dede732
|
|
| BLAKE2b-256 |
022e4959e582cbdde46ec2fbe4ca0b77f492e9dda2ee140e856696c17418db73
|