-
Notifications
You must be signed in to change notification settings - Fork 0
/
html2ps.py
executable file
·46 lines (35 loc) · 1.23 KB
/
html2ps.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
"""HTML to PostScript translator.
This is a standalone script for command line conversion of HTML documents
to PostScript. Use the '-h' option to see information about all too many
command-line options.
"""
import os
import sys
# Always figure the script_dir; this is used to initialize the module
# (see loading of PostScript templates at the end).
script_name = sys.argv[0]
while 1:
script_dir = os.path.dirname(script_name)
if not os.path.islink(script_name):
break
script_name = os.path.join(script_dir, os.readlink(script_name))
script_dir = os.path.join(os.getcwd(), script_dir)
script_dir = os.path.normpath(script_dir)
if __name__ == '__main__':
for path in 'pythonlib', 'utils', 'ancillary', 'sgml_lex', script_dir:
sys.path.insert(0, os.path.join(script_dir, path))
# don't load this twice when used as a script:
sys.modules['html2ps'] = sys.modules['__main__']
if sys.version < "1.5":
import ni
import grailutil
grailutil._grail_root = script_dir
import printing.main
import printing.utils
if __name__ == '__main__':
if sys.argv[1:] and sys.argv[1] == "--profile":
del sys.argv[1]
printing.main.profile_main()
else:
printing.main.main()