[Avida-cvs] [Avida2-svn] r75 - trunk/source/python/AvidaGui2

baerb at myxo.css.msu.edu baerb at myxo.css.msu.edu
Fri Mar 25 11:38:59 PST 2005


Author: baerb
Date: 2005-03-25 14:38:59 -0500 (Fri, 25 Mar 2005)
New Revision: 75

Added:
   trunk/source/python/AvidaGui2/checkuic.py
Log:
Created a utility program that will check all the .ui files and find ones that
are newer than their equivalent *.py files.  The program will than offer the
user a chance to create the .py file.

User may need to change the command line to reflect the location of the pyuic
program.



Added: trunk/source/python/AvidaGui2/checkuic.py
===================================================================
--- trunk/source/python/AvidaGui2/checkuic.py	2005-03-25 19:31:57 UTC (rev 74)
+++ trunk/source/python/AvidaGui2/checkuic.py	2005-03-25 19:38:59 UTC (rev 75)
@@ -0,0 +1,63 @@
+import os, time, re
+py_dict = {}
+dir_listing = os.listdir('.')
+for file in dir_listing:
+  if file.endswith('View.py'):
+    py_dict['./' + file] = 0
+for file in dir_listing:
+  if file.endswith('.ui'):
+    if re.compile('junk').search(file,1):
+      print "============== " + file + " =============="
+    ui_name = './' + file
+    ui_stat = os.stat(ui_name)
+    py_name = ui_name.replace(".ui",".py")
+    if py_dict.has_key(py_name):
+      py_dict[py_name] = 1
+
+      # run pyuic and check the existing .py file against the newly
+      # created .py file
+
+      # print "******** " + py_name + " *******"
+      # os.system("pyuic " + ui_name + " > pyuic.tmp")
+      # os.system("diff -w " + py_name + " pyuic.tmp > diff.tmp")
+      # diff_file = open("diff.tmp")
+      # lines = diff_file.readlines()
+      # diff_file.close()
+      # for line in lines:
+        # showline = True
+        # if re.compile("# Created:").search(line, 1):
+          # showline = False
+        # if re.compile("# Form implementation generated").search(line, 1):
+          # showline = False
+        # if re.compile("The PyQt User Interface Compiler").search(line, 1):
+          # showline = False
+        # if showline:
+          # print line
+
+      # see if the .ui file is new than the .py file and
+      # offer to run pyuic
+
+      py_stat = os.stat(py_name)
+      time_diff = ui_stat.st_mtime - py_stat.st_mtime
+      if time_diff > 0:
+        print ui_name + ' ' + time.ctime(ui_stat.st_mtime)
+        print py_name + ' ' + time.ctime(py_stat.st_mtime)
+        command =  "pyuic " + ui_name + " > " + py_name
+        response = raw_input(command + "? (y/n)  ")
+        response = response.upper()
+        response = response.strip()
+        if response.startswith('Y'):
+          os.system(command)
+    else:
+      print "No file " + py_name + " exists"
+      command =  "pyuic " + ui_name + " > " + py_name
+      response = raw_input(command + "? (y/n)  ")
+      response = response.upper()
+      response = response.strip()
+      if response.startswith('Y'):
+        os.system(command)
+
+for py_name in py_dict.keys():
+  if py_dict[py_name] == 0:
+    ui_name = py_name.replace(".py", ".ui")
+    print ui_name + " not found"




More information about the Avida-cvs mailing list