#!/usr/bin/env python """emano - browseDirectory.py""" import os def browseDirectory(editor, directory): if not os.path.isdir(directory): msg = 'Error: %r is not a directory' % directory editor.statwin.notice(msg, 1) return files = os.listdir(directory) if directory != '/': files.append('..') files.sort() editor.itemwin.reset() for fn in files: filename = os.path.normpath(os.path.join(directory, fn)) if os.path.isfile(filename): editor.itemwin.append(fn, (editor.open, (filename,))) elif os.path.isdir(filename): args = (editor.menu.browseDirectory, (filename,)) editor.itemwin.append(fn + '/', args) editor.setFocus(editor.itemwin) editor.itemwin.draw() if __name__=="__main__": print __doc__