forked from zcrayman/tut-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage2
executable file
·30 lines (27 loc) · 916 Bytes
/
stage2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
import os
import re
import sys
if len(sys.argv) < 2:
print "Usage: %s <file>" % sys.argv[0]
sys.exit(1)
with open(sys.argv[1]) as input:
for line in input.readlines():
# !!!IMPORT path="src/webapp/WEB-INF/views/checkout.jsp" prefix="complete"
if "!!!IMPORT" in line:
match = re.search(r'path="(.+)" prefix="(.+)"', line)
path = match.group(1)
prefix = match.group(2)
print "`%s`" % path
print "```%s" % path.split(".")[-1]
with open(prefix + "/" + path) as code:
for line in code.readlines():
if "{!begin" in line:
pass
elif "{!end" in line:
pass
else:
print line.rstrip()
print "```"
else:
print line.rstrip()