From: Fred L. D. <fd...@us...> - 2001-12-15 04:55:02
|
Update of /cvsroot/grail/grail/src/ancillary In directory usw-pr-cvs1:/tmp/cvs-serv6925/ancillary Modified Files: PrefsPanels.py Log Message: Convert to re, string methods. Index: PrefsPanels.py =================================================================== RCS file: /cvsroot/grail/grail/src/ancillary/PrefsPanels.py,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -r2.37 -r2.38 *** PrefsPanels.py 1999/03/18 23:15:52 2.37 --- PrefsPanels.py 2001/12/15 04:54:59 2.38 *************** *** 21,25 **** import tktools import grailutil ! import string, regex, regsub from types import StringType --- 21,25 ---- import tktools import grailutil ! import re from types import StringType *************** *** 36,40 **** os.path.expanduser("~/.grail/prefspanels")] ! modname_matcher = regex.compile("^\(.*\)Panel.py[c]?$") # Framework --- 36,41 ---- os.path.expanduser("~/.grail/prefspanels")] ! modname_match = re.compile( ! "^(.*)Panel.py%c?$" % (__debug__ and 'c' or 'o')).match # Framework *************** *** 544,548 **** self.panels[nm] = [modnm, clnm, moddir, None] raworder = self.app.prefs.Get('preferences', 'panel-order') ! order = string.split(raworder) keys = self.panels.keys() ordered = [] --- 545,549 ---- self.panels[nm] = [modnm, clnm, moddir, None] raworder = self.app.prefs.Get('preferences', 'panel-order') ! order = raworder.split() keys = self.panels.keys() ordered = [] *************** *** 579,587 **** pass for entry in entries: ! if modname_matcher.match(entry) != -1: ! name = regsub.gsub("_", " ", modname_matcher.group(1)) ! class_name = regsub.gsub("_", "", ! modname_matcher.group(1)) ! got[name] = ((string.strip(name), class_name, entry, dir)) return got.values() --- 580,588 ---- pass for entry in entries: ! m = modname_match(entry) ! if m: ! name = m.group(1).replace("_", " ") ! class_name = m.group(1).replace("_", "") ! got[name] = ((name.strip(), class_name, entry, dir)) return got.values() *************** *** 605,614 **** sys.path.insert(0, entry[2]) try: ! modnm = entry[0][:string.index(entry[0], '.')] mod = __import__(modnm) if reload: reload(mod) ! class_name = (regsub.gsub(" ", "", name) ! + PANEL_CLASS_NAME_SUFFIX) # Instantiate it: entry[3] = getattr(mod, class_name)(name, self.app) --- 606,614 ---- sys.path.insert(0, entry[2]) try: ! modnm = entry[0][:entry[0].index('.')] mod = __import__(modnm) if reload: reload(mod) ! class_name = name.replace(" ", "") + PANEL_CLASS_NAME_SUFFIX # Instantiate it: entry[3] = getattr(mod, class_name)(name, self.app) |