Make .docx files executable for the python interpreter
Project description
Pydocxrunner
Is Word or Libre Office Writer you favorite IDE? Do you recognize docx as a superior file format? And are you tired of the high effort required to execute the code stored in .docx
files? Then don't worry, pydocxrunner
is the tool of your dreams. pydocxrunner
provides a simple command to make a .docx
file executable like any normal .py
file.
Features
- Make
.docx
files executable via thepython
command. Once the file is made executable,pydocxrunner
is no longer required. - The
.docx
file can then be executed on any device withpython
installed. - What else do you need?
Example
Assuming you have a file called printquad.docx
with the following content:
for i in range(10):
print(i)
Then you can make it executable using pydocxrunner
:
$ pydocxrunner printquad.docx
And execute it (on any device having python3
installed):
$ python3 printquad.docx
0
1
4
9
16
25
36
49
64
81
How it works
Unknown to most, .docx
files are .zip
files with a fancy name. Also unknown to most, python
can execute .zip
files. pydocxrunner
writes a simple __main__.py
file as well as python-docx2txt into the .docx
file. The __main__.py
script will be executed by the python interpreter and read the contents of the .docx
file. This content is then passed to an exec()
call.
Caveats
- This is not tested beyond a few simple statements
- I do not recommend using this tool for production
- An internet connection is required when running
pydocxrunner
aspython-docx2txt
needs to be downloaded. No connection is required to actually execute the.docx
file. - You still have to use
'
and"
for strings,„
and“
will not work.
TODO
- Make this work with other types of documents
- Make this work with other languages
- Find a better solution for installing
python-docx2txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pydocxrunner-0.0.3.tar.gz
.
File metadata
- Download URL: pydocxrunner-0.0.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaab29f62d910b9288765dfc5c7de3cb0817e442b5bdf8b05df38952e34b5a37 |
|
MD5 | 62c126079eeaedf02c81ed99a0ce04f4 |
|
BLAKE2b-256 | e7968fcdd44c74efa04135ff7cf3ab8856d23bfdf6568bffef525ab469792468 |
File details
Details for the file pydocxrunner-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pydocxrunner-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 729f1b83e850cb6f4efea9482c03acbb8087a857cb2c44b70697fee35e326016 |
|
MD5 | 3d7d0a8b83b8e87012ebfc68a1442f01 |
|
BLAKE2b-256 | e176a421ae55bdb45da85ff5910f1bb32b4dd71c4376ee5c7271fff09cfa1016 |