Mercurial > code > home > repos > light9
annotate light8/sub_analyzer.py @ 90:d34a4956417a
rsn has a separate thread that receives rlslider connections from a potserver.py process,
rsn has a separate thread that receives rlslider connections from a potserver.py process,
and they work
author | drewp |
---|---|
date | Sat, 13 Jul 2002 02:57:27 +0000 |
parents | 174b35926067 |
children | a995fd1a8f03 |
rev | line source |
---|---|
0 | 1 from Subs import * |
2 from Patch import * | |
3 from types import TupleType | |
4 | |
5 from Config import patch, subs | |
6 | |
7 import re | |
8 import Patch | |
9 Patch.reload_data(0) | |
10 | |
11 subusage = {} | |
12 | |
13 # colors = 'ROGBVndcihs' | |
14 colors = 'ndcihs' | |
15 | |
16 color_chart = { | |
17 '1-01' : 'ROYd', # broadway (morning - afternoon) | |
18 '1-02' : 'i', # int. mission | |
19 '1-03' : 'R', # phone booth | |
20 '1-04' : 'RBVh', # hotbox | |
21 '1-05' : 'RBd', # off broadway | |
22 '1-06' : 'ROYd', # ext. mission | |
23 '1-07' : 'ROYn', # gambler intro, off broadway | |
24 '1-08' : 'ROBIVc', # havana, clubs | |
25 '1-09' : 'ROYBIVc', # havana, outside, night | |
26 '1-10' : 'BVn', # ext. mission, night (4am) | |
27 | |
28 '2-01' : 'RBIVh', # hotbox | |
29 '2-02' : 'RBn', # more can i wish you | |
30 '2-03' : 'GBs', # sewer (crap game) | |
31 '2-04' : 'Bn', # sue me | |
32 '2-05' : 'i', # int. mission | |
33 '2-06' : '', # marry | |
34 '2-07' : 'd', # broadway finale | |
35 } | |
36 | |
37 scene_names = { | |
38 '1-01' : 'broadway (morning to afternoon)', | |
39 '1-02' : 'int. mission', | |
40 '1-03' : 'phone booth', | |
41 '1-04' : 'hotbox', | |
42 '1-05' : 'guys and dolls (off broadway)', | |
43 '1-06' : 'ext. mission, lunch time', | |
44 '1-07' : 'gambler intro, off broadway', | |
45 '1-08' : 'havana, clubs', | |
46 '1-09' : 'havana, outside, night', | |
47 '1-10' : 'ext. mission, night (4am)', | |
48 | |
49 '2-01' : 'hotbox', | |
50 '2-02' : 'more can i wish you', | |
51 '2-03' : 'sewer (crap game)', | |
52 '2-04' : 'sue me', | |
53 '2-05' : 'rock the boat (int. mission)', | |
54 '2-06' : 'marry (trav)', | |
55 '2-07' : 'finale (broadway)', | |
56 } | |
57 | |
58 sub_to_scene = {} | |
59 | |
85
174b35926067
converts subs from dicts to tab-sep-values and back again
drewp
parents:
73
diff
changeset
|
60 # blacklist is a list of *prefixes* to light names that won't be shown |
174b35926067
converts subs from dicts to tab-sep-values and back again
drewp
parents:
73
diff
changeset
|
61 blacklist = 'god upfill red blue cyc oran sidefill'.split() |
0 | 62 blacklist.extend(['side l','side r']) |
63 | |
64 for subname, levdict in subs.items(): | |
65 if type(subname) == TupleType: | |
66 subname = subname[0] | |
67 oldname = subname | |
68 subname = re.sub(r'\*(\d-\d+)-.*', r'\1', subname) | |
69 if oldname == subname: continue | |
70 sub_to_scene[oldname] = subname | |
71 subname = oldname # restore 'em. restore 'em good. | |
72 if not levdict: | |
73 print "Warning: %s is useless (empty sub)." % subname | |
74 else: | |
75 for ch, lev in levdict.items(): | |
76 if lev: | |
77 ch = resolve_name(ch) | |
78 subusage.setdefault(ch, []) | |
79 subusage[ch].append((lev, subname)) | |
80 | |
81 def twist(l): | |
82 return [(b,a) for a,b in l] | |
83 | |
84 def format_usage(ch, usage): | |
85
174b35926067
converts subs from dicts to tab-sep-values and back again
drewp
parents:
73
diff
changeset
|
85 if max([ch.startswith(pre) for pre in blacklist]): |
174b35926067
converts subs from dicts to tab-sep-values and back again
drewp
parents:
73
diff
changeset
|
86 return |
174b35926067
converts subs from dicts to tab-sep-values and back again
drewp
parents:
73
diff
changeset
|
87 |
0 | 88 usage=twist(usage) |
89 usage.sort() | |
90 # usage.reverse() | |
91 usage=twist(usage) | |
92 print "======= %s ======= (%d uses)" % (ch, len(usage)) | |
93 if 1: | |
94 use_str = '' | |
95 for lev, sub in usage: | |
96 if lev>30: | |
97 if sub_to_scene[sub] in color_chart: | |
98 subcolors = color_chart[sub_to_scene[sub]] | |
99 col_str = '' | |
100 for c in colors: | |
101 if c in subcolors: col_str += c | |
102 else: col_str += ' ' | |
103 print col_str, | |
104 else: | |
105 print ' ' * len(colors), | |
106 scenename = scene_names.get(sub_to_scene[sub], '') | |
107 levbar="*"*(lev//5) | |
108 print ' %3d %-20s\t%-30s %s' % (lev, levbar,sub, scenename) | |
109 else: | |
110 use_str = '\n '.join(["%d\t%s" % (lev, sub) for lev, sub in usage]) | |
111 print ' ' + use_str | |
112 | |
113 subitems = subusage.items() | |
114 subitems.sort() | |
115 for ch, usage in subitems: | |
116 if 0: | |
117 usedict = {} | |
118 for lev, subname in usage: # remove duplicates | |
119 usedict[subname] = max(lev, usedict.get(subname, 0)) | |
120 | |
121 newusage = [(lev, sub) for sub, lev in usedict.items()] | |
122 | |
123 format_usage(ch, newusage) | |
124 else: | |
125 format_usage(ch, usage) |