~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to openerp-outlook-plugin/dialogs/resources/rc2py.py

  • Committer: pap(openerp)
  • Date: 2010-01-11 13:58:16 UTC
  • Revision ID: pap@tinyerp.co.in-20100111135816-oxe0n3xsst2me3vu
[ADD]:added new module openerp-outlook-plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# rc2py.py
 
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
 
4
# Foundation license.
 
5
__author__="Adam Walker"
 
6
__doc__=""""
 
7
Converts an .rc windows resource source file into a python source file
 
8
with the same basic public interface as the rcparser module.
 
9
"""
 
10
import sys, os, stat
 
11
import rcparser
 
12
 
 
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)
 
21
 
 
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")
 
33
    out.close()
 
34
 
 
35
if __name__=="__main__":
 
36
    if len(sys.argv)>1:
 
37
        convert(sys.argv[1], sys.argv[2])
 
38
    else:
 
39
        convert()