summaryrefslogtreecommitdiff
path: root/show_cleanup.py
blob: 0e2565732e671b56d923c40befd0da9171a11308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
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()