[Spambayes-checkins] spambayes/Outlook2000/dialogs/resources rc2py.py, NONE, 1.1.2.1 rcparser.py, 1.1.2.5, 1.1.2.6

Adam Walker xenogeist at users.sourceforge.net
Fri Aug 8 22:38:29 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs/resources
In directory sc8-pr-cvs1:/tmp/cvs-serv31059/Outlook2000/dialogs/resources

Modified Files:
      Tag: outlook-dialog-branch
	rcparser.py 
Added Files:
      Tag: outlook-dialog-branch
	rc2py.py 
Log Message:
added a utility to generate a py file from an rc file. Not sure how to put this in the binary build process. Changed the dialogs member of rcparser to the dialog tuples. The tuples are created when reading the rc file now instead of requiring a seperate function call.

--- NEW FILE: rc2py.py ---
# rc2py.py
__author__="Adam Walker"
__doc__=""""
Converts an .rc windows resource source file into a python source file
with the same basic public interface as the rcparser module.
"""
import sys, os
import rcparser

def convert(inputFilename = None, outputFilename = None):
    """See the module doc string"""
    if inputFilename is None:
        inputFilename = "dialogs.rc"
    if outputFilename is None:
        outputFilename = "test.py"
    rcp = rcparser.ParseDialogs(inputFilename)

    out = open("test.py", "wt")
    out.write("#%s\n" % outputFilename)
    out.write("#This is a generated file. Please edit %s instead.\n" % inputFilename)
    out.write("class FakeParser(object):\n")
    out.write("\tdialogs = "+repr(rcp.dialogs)+"\n")
    out.write("\tids = "+repr(rcp.ids)+"\n")
    out.write("\tnames = "+repr(rcp.names)+"\n")
    out.write("def ParseDialogs(s):\n")
    out.write("\treturn FakeParser()\n")
    out.close()

if __name__=="__main__":
    if len(sys.argv)>1:
        convert(sys.argv[1], sys.argv[2])
    else:
        convert()

Index: rcparser.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/resources/Attic/rcparser.py,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** rcparser.py	9 Aug 2003 03:08:09 -0000	1.1.2.5
--- rcparser.py	9 Aug 2003 04:38:27 -0000	1.1.2.6
***************
*** 96,99 ****
--- 96,100 ----
      next_id = 1001
      dialogs = {}
+     _dialogs = {}
      debugEnabled = False;
      token = ""
***************
*** 157,161 ****
          dlg = DialogDef(name,self.addId(name))
          assert len(dlg.controls)==0
!         self.dialogs[name] = dlg
          extras = []
          self.getToken()
--- 158,162 ----
          dlg = DialogDef(name,self.addId(name))
          assert len(dlg.controls)==0
!         self._dialogs[name] = dlg
          extras = []
          self.getToken()
***************
*** 188,191 ****
--- 189,193 ----
              else:
                  break
+         self.dialogs[name] = dlg.createDialogTemplate()
      
      def dialogStyle(self, dlg):





More information about the Spambayes-checkins mailing list