Importlib shim that enables mixed syntax in Python packages and executables.
Go to file
Elf M. Sternberg f4c8944241 Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
docs Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
polymorph Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
tests Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
.gitignore Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
AUTHORS.rst Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
CONTRIBUTING.rst Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
HISTORY.rst Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
LICENSE Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
MANIFEST.in Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
Makefile Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
README.md Fix Typo. 2016-05-29 09:46:13 -07:00
README.rst Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
polyloader.py Sorta an initial check-in. 2016-05-29 09:42:34 -07:00
requirements.txt Sorta an initial check-in. 2016-05-29 09:42:34 -07:00
requirements_dev.txt Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
run_tests.py Sorta an initial check-in. 2016-05-29 09:42:34 -07:00
setup.cfg Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
setup.py Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00
tox.ini Initial check-in of Cookiecutter version. 2016-06-04 17:54:28 -07:00

README.md

polyloader is a python module to hook into Python's import machinery and insert your own syntax parser/recognizer. Importlib uses filename suffixes to recognize which compiler to use, but is internally hard-coded to only recognize ".py" as a valid suffix.

To use:

Import polyloader in your python script's launcher or library, as well as the syntax compiler(s) you plan to use. For example, if you have Mochi and Hy installed, and you wanted to write a Django app, edit manage.py and add the following lines at the top:

 from mochi.main import compile_file as mochi_compile
 from hy.importer import ast_compile as hy_compile
 from polyloader import polyimport
 polyimport(mochi_compile, ['.mochi'])
 polyimport(hy_compile, ['.hy'])}

Now your views can be written in Hy and your models in Mochi, and everything will just work.

Dependencies

polymorph is self-contained. It has no dependencies other than Python itself and your choice of language.