-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathspac
More file actions
executable file
·32 lines (23 loc) · 783 Bytes
/
spac
File metadata and controls
executable file
·32 lines (23 loc) · 783 Bytes
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
31
32
#!/usr/bin/env python
import sys
import os
from spackager.spa import compile, _readfile
def main(args):
args = [unicode(arg, 'utf-8') for arg in args]
legacy_mode = not ('-l' in args or '--no-legacy' in args) # TODO: optparse
filename = args[1] if legacy_mode else args[2]
# XXX: hacky?
if os.sep in filename:
cwd = os.path.dirname(filename)
os.chdir(cwd)
filename = os.path.basename(filename)
original = _readfile(filename)
html = compile(original, legacy_mode)
outfile = filename.replace('.html', '.spa.html') # TODO: configurable (e.g. stdout)
f = open(outfile, 'w')
f.write(html.encode('utf-8'))
f.close()
return True
if __name__ == '__main__':
status = not main(sys.argv)
sys.exit(status)