def reloadSettings(self): '''ShadowController.reloadSettings.''' c = self.c self.shadow_subdir = c.config.getString('shadow_subdir') or '.leo_shadow' self.shadow_prefix = c.config.getString('shadow_prefix') or '' self.shadow_in_home_dir = c.config.getBool('shadow_in_home_dir', default=False) self.shadow_subdir = g.os_path_normpath(self.shadow_subdir)
def make_stub_file(self, p): '''Make a stub file in ~/stubs for the @<file> node at p.''' import ast assert p.isAnyAtFileNode() c = self.c fn = p.anyAtFileNodeName() if not fn.endswith('.py'): g.es_print('not a python file', fn) return abs_fn = g.fullPath(c, p) if not g.os_path_exists(abs_fn): g.es_print('not found', abs_fn) return if g.os_path_exists(self.output_directory): base_fn = g.os_path_basename(fn) out_fn = g.os_path_finalize_join(self.output_directory, base_fn) else: g.es_print('not found', self.output_directory) return out_fn = out_fn[:-3] + '.pyi' out_fn = g.os_path_normpath(out_fn) self.output_fn = out_fn # compatibility with stand-alone script s = open(abs_fn).read() node = ast.parse(s, filename=fn, mode='exec') # Make the traverser *after* creating output_fn and output_directory ivars. x = self.msf.StubTraverser(controller=self) x.output_fn = self.output_fn x.output_directory = self.output_directory x.trace_matches = self.trace_matches x.trace_patterns = self.trace_patterns x.trace_reduce = self.trace_reduce x.trace_visitors = self.trace_visitors x.run(node)
def OLD_parse_opml_file(self, inputFileName): if not inputFileName or not inputFileName.endswith(".opml"): return None c = self.c path = g.os_path_normpath(g.os_path_join(g.app.loadDir, inputFileName)) try: f = open(path) except IOError: g.trace("can not open %s" % path) return None try: try: node = None parser = xml.sax.make_parser() # Do not include external general entities. # The actual feature name is "http://xml.org/sax/features/external-general-entities" parser.setFeature(xml.sax.handler.feature_external_ges, 0) handler = SaxContentHandler(c, inputFileName) parser.setContentHandler(handler) parser.parse(f) node = handler.getNode() except xml.sax.SAXParseException: g.error("Error parsing %s" % (inputFileName)) g.es_exception() return None except Exception: g.error("Unexpected exception parsing %s" % (inputFileName)) g.es_exception() return None finally: f.close() return node
def profile_leo(): """ Gather and print statistics about Leo. @ To gather statistics, do the following in a console window: python profileLeo.py <list of .leo files> > profile.txt """ # Work around a Python distro bug: can fail on Ubuntu. try: import pstats except ImportError: g.es_print('can not import pstats: this is a Python distro bug') g.es_print( 'https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/123755' ) g.es_print('try installing pstats yourself') return import cProfile as profile import leo.core.leoGlobals as g import os theDir = os.getcwd() # On Windows, name must be a plain string. name = str(g.os_path_normpath(g.os_path_join(theDir, 'leoProfile'))) # This is a binary file. print(f"profiling binary stats to {name}") profile.run('import leo ; leo.run()', name) p = pstats.Stats(name) p.strip_dirs() p.sort_stats('tottime') p.print_stats(200)
def parse_opml_file(self, fn): c = self.c if not fn or not fn.endswith('.opml'): return g.trace('bad file name: %s' % repr(fn)) c = self.c path = g.os_path_normpath(g.os_path_join(g.app.loadDir, fn)) try: f = open(path, 'rb') s = f.read() # type(s) is bytes for Python 3.x. s = self.cleanSaxInputString(s) except IOError: return g.trace('can not open %s' % path) # pylint:disable=catching-non-exception try: theFile = BytesIO(s) parser = xml.sax.make_parser() parser.setFeature(xml.sax.handler.feature_external_ges, 1) # Do not include external general entities. # The actual feature name is "http://xml.org/sax/features/external-general-entities" parser.setFeature(xml.sax.handler.feature_external_pes, 0) handler = SaxContentHandler(c, fn) parser.setContentHandler(handler) parser.parse(theFile) # expat does not support parseString sax_node = handler.getNode() except xml.sax.SAXParseException: g.error('error parsing', fn) g.es_exception() sax_node = None except Exception: g.error('unexpected exception parsing', fn) g.es_exception() sax_node = None return sax_node
def profile_leo(): """Gather and print statistics about Leo""" # Work around a Python distro bug: can fail on Ubuntu. try: import pstats except ImportError: g.es_print('can not import pstats: this is a Python distro bug') g.es_print( 'https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/123755' ) g.es_print('try installing pstats yourself') return import cProfile as profile import leo.core.leoGlobals as g import os theDir = os.getcwd() # On Windows, name must be a plain string. An apparent cProfile bug. name = str(g.os_path_normpath(g.os_path_join(theDir, 'leoProfile.txt'))) print('profiling to %s' % name) profile.run('import leo ; leo.run()', name) p = pstats.Stats(name) p.strip_dirs() # p.sort_stats('module','calls','time','name') p.sort_stats('cumulative', 'time') #reFiles='leoAtFile.py:|leoFileCommands.py:|leoGlobals.py|leoNodes.py:' #p.print_stats(reFiles) p.print_stats()
def open_index(self, idx_dir): global index_error_given if os.path.exists(idx_dir): try: return open_dir(idx_dir) except ValueError: if not index_error_given: index_error_given = True g.es_print('bigdash.py: exception in whoosh.open_dir') g.es_print('please remove this directory:', g.os_path_normpath(idx_dir)) return None # Doesn't work: open_dir apparently leaves resources open, # so shutil.rmtree(idx_dir) fails. # g.es_print('re-creating', repr(idx_dir)) # try: # import shutil # shutil.rmtree(idx_dir) # os.mkdir(idx_dir) # self.create() # return open_dir(idx_dir) # except Exception as why: # g.es_print(why) # return None else: try: os.mkdir(idx_dir) self.create() return open_dir(idx_dir) except Exception: g.es_exception() return None
def profile_leo(): """Gather and print statistics about Leo""" # Work around a Python distro bug: can fail on Ubuntu. try: import pstats except ImportError: g.es_print('can not import pstats: this is a Python distro bug') g.es_print('https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/123755') g.es_print('try installing pstats yourself') return import cProfile as profile import leo.core.leoGlobals as g import os theDir = os.getcwd() # On Windows, name must be a plain string. An apparent cProfile bug. name = str(g.os_path_normpath(g.os_path_join(theDir, 'leoProfile.txt'))) print('profiling to %s' % name) profile.run('import leo ; leo.run()', name) p = pstats.Stats(name) p.strip_dirs() # p.sort_stats('module','calls','time','name') p.sort_stats('cumulative', 'time') #reFiles='leoAtFile.py:|leoFileCommands.py:|leoGlobals.py|leoNodes.py:' #p.print_stats(reFiles) p.print_stats()
def reloadSettings(self): """ShadowController.reloadSettings.""" c = self.c self.shadow_subdir = c.config.getString('shadow-subdir') or '.leo_shadow' self.shadow_prefix = c.config.getString('shadow-prefix') or '' self.shadow_in_home_dir = c.config.getBool('shadow-in-home-dir', default=False) self.shadow_subdir = g.os_path_normpath(self.shadow_subdir)
def profile_leo(): """ Gather and print statistics about Leo. @ To gather statistics, do the following in a console window: python profileLeo.py <list of .leo files> > profile.txt """ # Work around a Python distro bug: can fail on Ubuntu. try: import pstats except ImportError: g.es_print('can not import pstats: this is a Python distro bug') g.es_print('https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/123755') g.es_print('try installing pstats yourself') return import cProfile as profile import leo.core.leoGlobals as g import os theDir = os.getcwd() # On Windows, name must be a plain string. name = str(g.os_path_normpath(g.os_path_join(theDir, 'leoProfile'))) # This is a binary file. print('profiling binary stats to %s' % name) profile.run('import leo ; leo.run()', name) p = pstats.Stats(name) p.strip_dirs() p.sort_stats('tottime') p.print_stats(200)
def fixdefault (self,libN,libname): if libname == 'default': libname = 'default/library.dbm' if libname.find('default') != -1: pluginspath = g.os_path_join(g.app.loadDir,'../',"plugins") libname = g.os_path_normpath(g.os_path_abspath( libname.replace('default',pluginspath,1))) # setattr(libconfig,libN,libname) elif libname.find('~') != -1: libname = g.os_path_normpath(g.os_path_abspath( libname.replace('~',g.app.homeDir,1))) # setattr(libconfig,libN,libname) return libname
def __init__(self, c, trace=False, trace_writers=False): '''Ctor for ShadowController class.''' self.c = c # Opcode dispatch dict. self.dispatch_dict = { 'delete': self.op_delete, 'equal': self.op_equal, 'insert': self.op_insert, 'replace': self.op_replace, } # File encoding. self.encoding = c.config.default_derived_file_encoding # Configuration... self.shadow_subdir = c.config.getString( 'shadow_subdir') or '.leo_shadow' self.shadow_prefix = c.config.getString('shadow_prefix') or '' self.shadow_in_home_dir = c.config.getBool('shadow_in_home_dir', default=False) self.shadow_subdir = g.os_path_normpath(self.shadow_subdir) # Error handling... self.errors = 0 self.last_error = '' # The last error message, regardless of whether it was actually shown. self.trace = False # Support for goto-line. self.line_mapping = []
def fixdefault(self, libN, libname): if libname == 'default': libname = 'default/library.dbm' if libname.find('default') != -1: pluginspath = g.os_path_join(g.app.loadDir, '../', "plugins") libname = g.os_path_normpath( g.os_path_abspath(libname.replace('default', pluginspath, 1))) # setattr(libconfig,libN,libname) elif libname.find('~') != -1: libname = g.os_path_normpath( g.os_path_abspath(libname.replace('~', g.app.homeDir, 1))) # setattr(libconfig,libN,libname) return libname
def loadIcons(self, p, clear=False): com = self.c.editCommands allIcons = com.getIconList(p) icons = [i for i in allIcons if 'cleoIcon' not in i] if clear: iterations = [] else: iterations = [True, False] for which in iterations: if which == (self.icon_order == 'pri-first'): pri = self.getat(p.v, 'priority') if pri: pri = int(pri) if pri in self.priorities: iconDir = g.os_path_abspath( g.os_path_normpath( g.os_path_join(g.app.loadDir,"..","Icons"))) com.appendImageDictToList(icons, iconDir, g.os_path_join('cleo',self.priorities[pri]['icon']), 2, on='vnode', cleoIcon='1', where=self.icon_location) # Icon location defaults to 'beforeIcon' unless cleo_icon_location global defined. # Example: @strings[beforeIcon,beforeHeadline] cleo_icon_location = beforeHeadline com.setIconList(p, icons) else: prog = self.getat(p.v, 'progress') if prog is not '': prog = int(prog) use = prog//10*10 use = 'prg%03d.png' % use iconDir = g.os_path_abspath( g.os_path_normpath( g.os_path_join(g.app.loadDir,"..","Icons"))) com.appendImageDictToList(icons, iconDir, g.os_path_join('cleo',use), 2, on='vnode', cleoIcon='1', where=self.prog_location) com.setIconList(p, icons) if len(allIcons) != len(icons): # something to add / remove com.setIconList(p, icons)
def add_words_from_dict(self, kind, fn, words): '''For use by DefaultWrapper.''' trace = False and not g.unitTesting if trace: g.es_print('%6s words in %6s dictionary: %s' % ( len(words or []), kind, g.os_path_normpath(fn))) for word in words or []: self.words.add(word) self.words.add(word.lower())
def _getpath(self, p): c = self.c dict = c.scanAllDirectives(p) d = dict.get("path") if p.isAnyAtFileNode(): filename = p.anyAtFileNodeName() filename = g.os_path_join(d, filename) if filename: d = g.os_path_dirname(filename) return '' if d is None else g.os_path_normpath(d)
def test_c_scanAtPathDirectives(self): c, p = self.c, self.c.p child = p.insertAfter() child.h = '@path one' grand = child.insertAsLastChild() grand.h = '@path two' great = grand.insertAsLastChild() great.h = 'xyz' aList = g.get_directives_dict_list(great) path = c.scanAtPathDirectives(aList) endpath = g.os_path_normpath('one/two') assert path.endswith(endpath), f"expected '{endpath}' got '{path}'"
def getImage(path, iconBasePath=None): """Use PIL to get an image suitable for displaying in menus.""" iconBasePath = iconBasePath or defaultIconBasePath if not (Image and ImageTk): return None path = g.os_path_normpath(path) try: return iconCache[path] except KeyError: pass iconpath = g.os_path_join(iconBasePath, path) try: return iconCache[iconpath] except KeyError: pass try: image = Image.open(path) except: image = None if not image: try: image = Image.open(iconpath) except: image = None if not image: return None try: image = ImageTk.PhotoImage(image) except: image = None if not image or not image.height() >0: g.es('Bad Icon: %s' % path) return None iconCache[path] = image return image
def test_c_scanAtPathDirectives_same_name_subdirs(self): c = self.c # p2 = p.firstChild().firstChild().firstChild() p = c.p child = p.insertAfter() child.h = '@path again' grand = child.insertAsLastChild() grand.h = '@path again' great = grand.insertAsLastChild() great.h = 'xyz' aList = g.get_directives_dict_list(great) path = c.scanAtPathDirectives(aList) endpath = g.os_path_normpath('again/again') self.assertTrue(path and path.endswith(endpath))
def __init__ (self,c): self.c = c c.cleo = self self.donePriority = 100 self.menuicons = {} # menu icon cache self.recentIcons = [] #X self.smiley = None self.redrawLevels = 0 self.iconDir = g.os_path_abspath( g.os_path_normpath( g.os_path_join(g.app.loadDir,"..","Icons"))) #@+<< set / read default values >> #@+node:tbrown.20090119215428.12: *4* << set / read default values >> self.time_name = 'days' if c.config.getString('todo_time_name'): self.time_name = c.config.getString('todo_time_name') self.icon_location = 'beforeHeadline' if c.config.getString('todo_icon_location'): self.icon_location = c.config.getString('todo_icon_location') self.prog_location = 'beforeHeadline' if c.config.getString('todo_prog_location'): self.prog_location = c.config.getString('todo_prog_location') self.icon_order = 'pri-first' if c.config.getString('todo_icon_order'): self.icon_order = c.config.getString('todo_icon_order') #@-<< set / read default values >> self.handlers = [ ("close-frame",self.close), ('select3', self.updateUI), ('save2', self.loadAllIcons), ] # chdir so the Icons can be located owd = os.getcwd() os.chdir(os.path.split(__file__)[0]) self.ui = cleoQtUI(self) os.chdir(owd) for i in self.handlers: g.registerHandler(i[0], i[1]) self.loadAllIcons()
def show_info(self): if self.main_fn: g.es_print('Default spell checker') table = ( ('main', self.main_fn), ('user', self.user_fn), ) else: g.es_print('\nSpell checking has been disabled.') g.es_print('To enable, put a main dictionary at:') g.es_print('~/.leo/main_spelling_dict.txt') table = (('user', self.user_fn), ) for kind, fn in table: g.es_print('%s dictionary: %s' % (kind, g.os_path_normpath(fn) if fn else 'None'))
def _getpath (self,p): c = self.c dict = c.scanAllDirectives(p) d = dict.get("path") if p.isAnyAtFileNode(): filename = p.anyAtFileNodeName() filename = g.os_path_join(d,filename) if filename: d = g.os_path_dirname(filename) if d is None: return "" else: return g.os_path_normpath(d)
def show_info(self): if self.main_fn: g.es_print('Default spell checker') table = ( ('main', self.main_fn), ('user', self.user_fn), ) else: g.es_print('\nSpell checking has been disabled.') g.es_print('To enable, put a main dictionary at:') g.es_print('~/.leo/main_spelling_dict.txt') table = ( ('user', self.user_fn), ) for kind, fn in table: g.es_print('%s dictionary: %s' % ( kind, g.os_path_normpath(fn) if fn else 'None'))
def parse_opml_file(self, fn): c = self.c if not fn or not fn.endswith(".opml"): return g.trace("bad file name: %s" % repr(fn)) c = self.c path = g.os_path_normpath(g.os_path_join(g.app.loadDir, fn)) try: f = open(path, "rb") s = f.read() # type(s) is bytes for Python 3.x. s = self.cleanSaxInputString(s) except IOError: return g.trace("can not open %s" % path) try: if g.isPython3: theFile = BytesIO(s) else: theFile = cStringIO.StringIO(s) parser = xml.sax.make_parser() parser.setFeature(xml.sax.handler.feature_external_ges, 1) # Do not include external general entities. # The actual feature name is "http://xml.org/sax/features/external-general-entities" parser.setFeature(xml.sax.handler.feature_external_pes, 0) handler = SaxContentHandler(c, fn) parser.setContentHandler(handler) parser.parse(theFile) # expat does not support parseString sax_node = handler.getNode() except xml.sax.SAXParseException: g.error("error parsing", fn) g.es_exception() sax_node = None except Exception: g.error("unexpected exception parsing", fn) g.es_exception() sax_node = None return sax_node
def __init__ (self,c,trace=False,trace_writers=False): self.c = c # File encoding. self.encoding = c.config.default_derived_file_encoding # 2011/09/08 # Configuration... self.shadow_subdir = c.config.getString('shadow_subdir') or '.leo_shadow' self.shadow_prefix = c.config.getString('shadow_prefix') or '' self.shadow_in_home_dir = c.config.getBool('shadow_in_home_dir',default=False) # Munch shadow_subdir self.shadow_subdir = g.os_path_normpath(self.shadow_subdir) # Error handling... self.errors = 0 self.last_error = '' # The last error message, regardless of whether it was actually shown. # Support for goto-line. self.line_mapping = []
def OLD_parse_opml_file(self, inputFileName): if not inputFileName or not inputFileName.endswith('.opml'): return None c = self.c path = g.os_path_normpath( g.os_path_join(g.app.loadDir, inputFileName)) try: f = open(path) except IOError: g.trace('can not open %s' % path) return None try: # pylint:disable=catching-non-exception try: node = None parser = xml.sax.make_parser() # Do not include external general entities. # The actual feature name is "http://xml.org/sax/features/external-general-entities" parser.setFeature(xml.sax.handler.feature_external_ges, 0) handler = SaxContentHandler(c, inputFileName) parser.setContentHandler(handler) parser.parse(f) node = handler.getNode() except xml.sax.SAXParseException: g.error('Error parsing %s' % (inputFileName)) g.es_exception() node = None except Exception: g.error('Unexpected exception parsing %s' % (inputFileName)) g.es_exception() node = None finally: f.close() return node
def menuicon(self, pri, progress=False): """return icon from cache, placing it there if needed""" if progress: prog = pri pri = 'prog-%d'%pri if pri not in self.menuicons: if progress: fn = 'prg%03d.png' % prog else: fn = self.priorities[pri]["icon"] iconDir = g.os_path_abspath( g.os_path_normpath( g.os_path_join(g.app.loadDir,"..","Icons"))) fn = g.os_path_join(iconDir,'cleo',fn) self.menuicons[pri] = QtGui.QIcon(fn) return self.menuicons[pri]
def loadIcons(self, p): com = self.c.editCommands allIcons = com.getIconList(p) icons = [i for i in allIcons if 'cleoIcon' not in i] pri = self.getat(p.v, 'priority') if pri: pri = int(pri) if pri in self.priorities: cleo_icon_path = self.c.config.getString('cleo_icon_path') if not cleo_icon_path: cleo_icon_path = 'cleo' # relative to leo Icons dir iconDir = g.os_path_abspath( g.os_path_normpath( g.os_path_join(g.app.loadDir,"..","Icons"))) com.appendImageDictToList(icons, iconDir, g.os_path_join(cleo_icon_path,self.priorities[pri]['icon']), 2, on='vnode', cleoIcon='1', where=self.icon_location) # Icon location defaults to 'beforeIcon' unless cleo_icon_location global defined. # Example: @strings[beforeIcon,beforeHeadline] cleo_icon_location = beforeHeadline # Note: 'beforeBox' and 'afterHeadline' collide with other elements on the line. com.setIconList(p, icons) else: if len(allIcons) != len(icons): # something to remove com.setIconList(p, icons)
def __init__ (self,c,trace=False,trace_writers=False): '''Ctor for ShadowController class.''' self.c = c # Opcode dispatch dict. self.dispatch_dict = { 'delete': self.op_delete, 'equal': self.op_equal, 'insert': self.op_insert, 'replace': self.op_replace, } # File encoding. self.encoding = c.config.default_derived_file_encoding # Configuration... self.shadow_subdir = c.config.getString('shadow_subdir') or '.leo_shadow' self.shadow_prefix = c.config.getString('shadow_prefix') or '' self.shadow_in_home_dir = c.config.getBool('shadow_in_home_dir',default=False) self.shadow_subdir = g.os_path_normpath(self.shadow_subdir) # Error handling... self.errors = 0 self.last_error = '' # The last error message, regardless of whether it was actually shown. self.trace = False # Support for goto-line. self.line_mapping = []
def finalize(self, fn): '''Finalize and regularize a filename.''' return g.os_path_normpath( g.os_path_abspath(g.os_path_expanduser(fn)))
def compare_directories(self, path1, path2): # Ignore everything except the directory name. dir1 = g.os_path_dirname(path1) dir2 = g.os_path_dirname(path2) dir1 = g.os_path_normpath(dir1) dir2 = g.os_path_normpath(dir2) if dir1 == dir2: return self.show("Please pick distinct directories.") try: list1 = os.listdir(dir1) except Exception: return self.show("invalid directory:" + dir1) try: list2 = os.listdir(dir2) except Exception: return self.show("invalid directory:" + dir2) if self.outputFileName: self.openOutputFile() ok = self.outputFileName is None or self.outputFile if not ok: return None # Create files and files2, the lists of files to be compared. files1 = [] files2 = [] for f in list1: junk, ext = g.os_path_splitext(f) if self.limitToExtension: if ext == self.limitToExtension: files1.append(f) else: files1.append(f) for f in list2: junk, ext = g.os_path_splitext(f) if self.limitToExtension: if ext == self.limitToExtension: files2.append(f) else: files2.append(f) # Compare the files and set the yes, no and missing lists. yes = []; no = []; missing1 = []; missing2 = [] for f1 in files1: head, f2 = g.os_path_split(f1) if f2 in files2: try: name1 = g.os_path_join(dir1, f1) name2 = g.os_path_join(dir2, f2) val = filecmp.cmp(name1, name2, 0) if val: yes.append(f1) else: no.append(f1) except Exception: self.show("exception in filecmp.cmp") g.es_exception() missing1.append(f1) else: missing1.append(f1) for f2 in files2: head, f1 = g.os_path_split(f2) if f1 not in files1: missing2.append(f1) # Print the results. for kind, files in ( ("----- matches --------", yes), ("----- mismatches -----", no), ("----- not found 1 ------", missing1), ("----- not found 2 ------", missing2), ): self.show(kind) for f in files: self.show(f) if self.outputFile: self.outputFile.close() self.outputFile = None return None # To keep pychecker happy.
def finalize(self, fn): '''Finalize and regularize a filename.''' return g.os_path_normpath(g.os_path_abspath(g.os_path_expanduser(fn)))
def compare_directories(self, path1, path2): # Ignore everything except the directory name. dir1 = g.os_path_dirname(path1) dir2 = g.os_path_dirname(path2) dir1 = g.os_path_normpath(dir1) dir2 = g.os_path_normpath(dir2) if dir1 == dir2: return self.show("Please pick distinct directories.") try: list1 = os.listdir(dir1) except: return self.show("invalid directory:" + dir1) try: list2 = os.listdir(dir2) except: return self.show("invalid directory:" + dir2) if self.outputFileName: self.openOutputFile() ok = self.outputFileName == None or self.outputFile if not ok: return None # Create files and files2, the lists of files to be compared. files1 = [] files2 = [] for f in list1: junk, ext = g.os_path_splitext(f) if self.limitToExtension: if ext == self.limitToExtension: files1.append(f) else: files1.append(f) for f in list2: junk, ext = g.os_path_splitext(f) if self.limitToExtension: if ext == self.limitToExtension: files2.append(f) else: files2.append(f) # Compare the files and set the yes, no and missing lists. yes = [] no = [] missing1 = [] missing2 = [] for f1 in files1: head, f2 = g.os_path_split(f1) if f2 in files2: try: name1 = g.os_path_join(dir1, f1) name2 = g.os_path_join(dir2, f2) val = filecmp.cmp(name1, name2, 0) if val: yes.append(f1) else: no.append(f1) except: self.show("exception in filecmp.cmp") g.es_exception() missing1.append(f1) else: missing1.append(f1) for f2 in files2: head, f1 = g.os_path_split(f2) if f1 not in files1: missing2.append(f1) # Print the results. for kind, files in ( ("----- matches --------", yes), ("----- mismatches -----", no), ("----- not found 1 ------", missing1), ("----- not found 2 ------", missing2), ): self.show(kind) for f in files: self.show(f) if self.outputFile: self.outputFile.close() self.outputFile = None return None # To keep pychecker happy.