3 |
import alph |
import alph |
4 |
from copy import deepcopy |
from copy import deepcopy |
5 |
|
|
6 |
|
dbg = 0 |
7 |
|
|
8 |
def reliablePS2DSC(infile, outfile): |
def reliablePS2DSC(infile, outfile): |
9 |
"""Convert a postscript file to a .dsc file reliably. |
"""Convert a postscript file to a .dsc file reliably. |
10 |
Because several files have broken dsc comments, we |
Because several files have broken dsc comments, we |
18 |
|
|
19 |
cmdline = cmdline % locals() |
cmdline = cmdline % locals() |
20 |
|
|
21 |
print 'cmdline -- ', cmdline |
if dbg: |
22 |
|
print 'cmdline -- ', cmdline |
23 |
result = os.system(cmdline) |
result = os.system(cmdline) |
24 |
print 'result -- ', result |
if dbg: |
25 |
|
print 'result -- ', result |
26 |
if result: return 0 |
if result: return 0 |
27 |
|
|
28 |
return 1 |
return 1 |
32 |
""" |
""" |
33 |
cmdline = "pdf2dsc %(infile)s %(outfile)s" % locals() |
cmdline = "pdf2dsc %(infile)s %(outfile)s" % locals() |
34 |
|
|
35 |
print "CMD:",cmdline |
if dbg: |
36 |
|
print "CMD:",cmdline |
37 |
result = os.system(cmdline) |
result = os.system(cmdline) |
38 |
print "PDFDSC:",result |
if dbg: |
39 |
|
print "PDFDSC:",result |
40 |
if result: return 0 |
if result: return 0 |
41 |
|
|
42 |
return 1 |
return 1 |
63 |
lastspace = 0 |
lastspace = 0 |
64 |
if not lastspace: |
if not lastspace: |
65 |
tokens.append(string[last:]) |
tokens.append(string[last:]) |
66 |
print "Tok: '"+string+"' ",tokens |
if dbg: |
67 |
|
print "Tok: '"+string+"' ",tokens |
68 |
return tokens |
return tokens |
69 |
|
|
70 |
class SinglePageInfo: |
class SinglePageInfo: |
92 |
mtypes = {} |
mtypes = {} |
93 |
for i in range(0, len(media)/6): |
for i in range(0, len(media)/6): |
94 |
(name, w, h, weight, color, type) = media[i*6:(i+1)*6] |
(name, w, h, weight, color, type) = media[i*6:(i+1)*6] |
95 |
print "Docmedia '%(name)s' %(w)s %(h)s %(weight)s %(color)s %(type)s" \ |
if dbg: |
96 |
|
print "Docmedia '%(name)s' %(w)s %(h)s %(weight)s %(color)s %(type)s" \ |
97 |
% locals() |
% locals() |
98 |
mtypes[name] = (float(w),float(h)) |
mtypes[name] = (float(w),float(h)) |
99 |
|
|