Last active
August 29, 2015 14:07
-
-
Save keitheis/903efff4b582fa6b913e to your computer and use it in GitHub Desktop.
Bulk compile plim files to mako files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Usage: | |
1. Enter your plim templates folder | |
cd app/templates | |
2. Run this Python script | |
python bulk_compile_plims.py | |
3. Check it out | |
tree __plim_output | |
""" | |
from pathlib import Path | |
from subprocess import Popen | |
def run(args): | |
Popen(args) | |
CMD = 'plimc -o {out_path} {input_file}' | |
def extract_plims(templates_path, out_dir='__plim_output'): | |
plims = Path(templates_path).glob('**/*.plim') | |
cwd = Path.cwd() | |
for p in plims: | |
to_dir = Path("{}/{}/{}".format(cwd, out_dir, p.parent)) | |
if not to_dir.exists(): | |
to_dir.mkdir(parents=True) | |
out_path = "{}/{}.mako".format(to_dir, p.stem) | |
cmd = CMD.format(out_path=out_path, input_file=p) | |
run(cmd.split(" ")) | |
def main(): | |
extract_plims(".") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment