diff options
Diffstat (limited to 'show_cleanup.py')
-rw-r--r-- | show_cleanup.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/show_cleanup.py b/show_cleanup.py new file mode 100644 index 0000000..0e25657 --- /dev/null +++ b/show_cleanup.py | |||
@@ -0,0 +1,92 @@ | |||
1 | """ | ||
2 | Avolites Pearl Expert Show File Cleanup Program | ||
3 | for The Chapel in Akron | ||
4 | by Mike Crute (mcrute@gmail.com) | ||
5 | on February 20, 2008 | ||
6 | |||
7 | This is a simple GUI program that allows for the cleanup of Avolites Pearl | ||
8 | Expert show files in the new (directory-based) format. It requires a recent | ||
9 | version of Python (originally designed for 2.6) and a copy of wxPython. | ||
10 | |||
11 | The file is split into two parts, first is the Show File API that provides | ||
12 | very basic searching and interperation of the show files on disk. The | ||
13 | second part is all of the GUI code that renders the interface. The API code | ||
14 | has no dependency on the GUI code. | ||
15 | """ | ||
16 | |||
17 | import os | ||
18 | import wx | ||
19 | from xml.etree import ElementTree | ||
20 | |||
21 | |||
22 | ###################################################################### | ||
23 | # Core Functionality/API | ||
24 | ###################################################################### | ||
25 | class AvoShow(object): | ||
26 | name = None | ||
27 | file_name = None | ||
28 | date = None | ||
29 | time = None | ||
30 | |||
31 | |||
32 | def list_show_files(directory): | ||
33 | """ | ||
34 | Get a list of all the show files in a given directory. | ||
35 | """ | ||
36 | shows = [] | ||
37 | |||
38 | for item in os.listdir(directory): | ||
39 | if item.startswith('PEXP'): | ||
40 | shows.append('%(directory)s/%(item)s/pexpshw.xml' % locals()) | ||
41 | |||
42 | return shows | ||
43 | |||
44 | |||
45 | def get_show_catalog(show_files): | ||
46 | """ | ||
47 | Get a catalog of show objects indexed by name of the show. | ||
48 | """ | ||
49 | catalog = {} | ||
50 | |||
51 | for show_file in show_files: | ||
52 | xml = ElementTree.fromstring(open(show_file).read()) | ||
53 | |||
54 | this_show = AvoShow() | ||
55 | this_show.name = xml.find('Name').text | ||
56 | this_show.date = xml.find('Date').text | ||
57 | this_show.time = xml.find('Time').text | ||
58 | |||
59 | if this_show.name in catalog: | ||
60 | catalog[this_show.name].append(this_show) | ||
61 | else: | ||
62 | catalog[this_show.name] = [this_show] | ||
63 | |||
64 | return catalog | ||
65 | |||
66 | |||
67 | ###################################################################### | ||
68 | # GUI Code | ||
69 | ###################################################################### | ||
70 | class CleanupPanel(wx.Panel): | ||
71 | pass | ||
72 | |||
73 | |||
74 | class CleanupInterface(wx.Frame): | ||
75 | |||
76 | def __init__(self, *args, **kwargs): | ||
77 | kwargs['title'] = 'Avolites Show Cleanup' | ||
78 | wx.Frame.__init__(self, None, *args, **kwargs) | ||
79 | |||
80 | |||
81 | def gui_main(): | ||
82 | application = wx.App() | ||
83 | interface = CleanupInterface() | ||
84 | interface.Show() | ||
85 | appplication.MainLoop() | ||
86 | |||
87 | |||
88 | ###################################################################### | ||
89 | # "main" Method | ||
90 | ###################################################################### | ||
91 | if __name__ == '__main__': | ||
92 | gui_main() | ||