2 # Create 'Estr' resource from error dictionary
5 from Resources
import *
15 raise ValueError, 'String too large'
16 return chr(len(str))+str
18 def writeestr(dst
, edict
):
19 """Create Estr resource file given a dictionary of errors."""
22 FSpCreateResFile(dst
, 'RSED', 'rsrc', smAllScripts
)
23 output
= FSpOpenResFile(dst
, WRITE
)
25 for num
in edict
.keys():
26 res
= Resource(Pstring(edict
[num
]))
27 res
.AddResource('Estr', num
, '')
39 words
= string
.split(x
)
40 if x
[0] in (' ', '\t'):
42 x
= string
.join(words
)
43 lines
[-1] = lines
[-1] + ' ' + x
45 x
= string
.join(words
)
49 words
= string
.split(line
)
50 index
= eval(words
[0])
51 if dict.has_key(index
):
52 print '** Duplicate key:', index
53 x
= string
.join(words
[2:])
60 if __name__
== '__main__':
61 dict = parsefile('errors.txt')
62 writeestr('errors.rsrc', dict)