""" Avolites Pearl Expert Show File Cleanup Program for The Chapel in Akron by Mike Crute (mcrute@gmail.com) on February 20, 2008 This is a simple GUI program that allows for the cleanup of Avolites Pearl Expert show files in the new (directory-based) format. It requires a recent version of Python (originally designed for 2.6) and a copy of wxPython. The file is split into two parts, first is the Show File API that provides very basic searching and interperation of the show files on disk. The second part is all of the GUI code that renders the interface. The API code has no dependency on the GUI code. """ import os import wx from xml.etree import ElementTree ###################################################################### # Core Functionality/API ###################################################################### class AvoShow(object): name = None file_name = None date = None time = None def list_show_files(directory): """ Get a list of all the show files in a given directory. """ shows = [] for item in os.listdir(directory): if item.startswith('PEXP'): shows.append('%(directory)s/%(item)s/pexpshw.xml' % locals()) return shows def get_show_catalog(show_files): """ Get a catalog of show objects indexed by name of the show. """ catalog = {} for show_file in show_files: xml = ElementTree.fromstring(open(show_file).read()) this_show = AvoShow() this_show.name = xml.find('Name').text this_show.date = xml.find('Date').text this_show.time = xml.find('Time').text if this_show.name in catalog: catalog[this_show.name].append(this_show) else: catalog[this_show.name] = [this_show] return catalog ###################################################################### # GUI Code ###################################################################### class CleanupPanel(wx.Panel): pass class CleanupInterface(wx.Frame): def __init__(self, *args, **kwargs): kwargs['title'] = 'Avolites Show Cleanup' wx.Frame.__init__(self, None, *args, **kwargs) def gui_main(): application = wx.App() interface = CleanupInterface() interface.Show() appplication.MainLoop() ###################################################################### # "main" Method ###################################################################### if __name__ == '__main__': gui_main()