2
# This module is part of the spambayes project, which is Copyright 2003
3
# The Python Software Foundation and is covered by the Python Software
5
__author__="Adam Walker"
7
Converts an .rc windows resource source file into a python source file
8
with the same basic public interface as the rcparser module.
13
def convert(inputFilename = None, outputFilename = None):
14
"""See the module doc string"""
15
if inputFilename is None:
16
inputFilename = "dialogs.rc"
17
if outputFilename is None:
18
outputFilename = "test.py"
19
rcp = rcparser.ParseDialogs(inputFilename)
20
in_stat = os.stat(inputFilename)
22
out = open(outputFilename, "wt")
23
out.write("#%s\n" % outputFilename)
24
out.write("#This is a generated file. Please edit %s instead.\n" % inputFilename)
25
out.write("_rc_size_=%d\n_rc_mtime_=%d\n" % (in_stat[stat.ST_SIZE], in_stat[stat.ST_MTIME]))
26
out.write("class FakeParser:\n")
27
out.write("\tdialogs = "+repr(rcp.dialogs)+"\n")
28
out.write("\tids = "+repr(rcp.ids)+"\n")
29
out.write("\tnames = "+repr(rcp.names)+"\n")
30
out.write("\tbitmaps = "+repr(rcp.bitmaps)+"\n")
31
out.write("def ParseDialogs(s):\n")
32
out.write("\treturn FakeParser()\n")
35
if __name__=="__main__":
37
convert(sys.argv[1], sys.argv[2])