14 inp = sys.stdin.readline(1).strip()
15 if inp == 'y' or inp == '': return True
16 if inp == 'n': return False
19 key = line[:line.find(':')].strip()
20 value = line[line.find(':') + 1:].strip()
21 if not (key and value):
25 def find_key(data, keysubstr, exact = False):
30 key, value = getkeyval(l)
32 if (exact and key == keysubstr) or \
33 (not exact and key.find(keysubstr) != -1):
38 def simple_replace(data):
40 pairs['window.focus.font'] = 'window.label.focus.font'
41 pairs['window.unfocus.font'] = 'window.label.unfocus.font'
42 pairs['window.justify'] = 'window.label.justify'
43 pairs['menu.frame.disableColor'] = 'menu.disabled.textColor'
44 pairs['menu.frame'] = 'menu.items'
45 pairs['menu.hilite'] = 'menu.selected'
46 pairs['.picColor'] = '.imageColor'
48 for k in pairs.keys():
50 i, key, nul = find_key(data, k);
52 newl = data[i].replace(k, pairs[k])
53 out('Updating "' + key +
54 '" to "' + key.replace(k, pairs[k]) + '"\n')
61 invalid.append('toolbar')
64 i, key, nul = find_key(data, inv)
66 out(key + ' is no longer supported.\nRemove (Y/n)? ')
68 out('Removing "' + key + '"\n')
72 invalid.append('rootCommand')
73 invalid.append('menu.bullet')
74 invalid.append('menu.frame.justify')
77 i, key, nul = find_key(data, inv, True)
79 out(key + ' is no longer supported.\nRemove (Y/n)? ')
81 out('Removing "' + key + '"\n')
87 i, nul, nul = find_key(data, 'window.button.pressed', True)
89 out('The window.button.pressed option has been replaced by ' +
90 'window.button.pressed.focus and ' +
91 'window.button.pressed.unfocus.\nUpdate (Y/n)? ')
94 out('Removing "window.button.pressed"\n')
96 out('Adding "window.button.pressed.unfocus"\n')
97 data.insert(i, l.replace('window.button.pressed',
98 'window.button.pressed.unfocus'))
99 out('Adding "window.button.pressed.focus"\n')
100 data.insert(i, l.replace('window.button.pressed',
101 'window.button.pressed.focus'))
104 i, nul, nul = find_key(data, 'window.font')
106 out('You appear to specify fonts using the old X fonts ' +
107 'syntax.\nShall I remove all fonts from the theme (Y/n)? ')
112 i, key = key_find(data, '.font')
115 out('Removing "' + key + '"\n')
119 i, nul, nul = find_key(data, '.xft.')
121 out('You appear to specify fonts using the old Xft fonts ' +
122 'syntax.\nShall I update these to the new syntax (Y/n)? ')
127 fonts['window'] = 'window.label.focus.font'
128 fonts['menu.items'] = 'menu.items.font'
129 fonts['menu.title'] = 'menu.title.font'
130 for f in fonts.keys():
131 li, nul, flags = find_key(data, f + '.xft.flags')
133 li, nul, flags = find_key(data, '*.xft.flags')
135 out('Removing ' + f + '.xft.flags\n')
137 oi, nul, offset = find_key(data, f + '.xft.shadow.offset')
139 oi, nul, offset = find_key(data, '*.xft.shadow.offset')
141 out('Removing ' + f + '.xft.shadow.offset\n')
143 ti, nul, tint = find_key(data, f + '.xft.shadow.tint')
145 ti, nul, tint = find_key(data, '*.xft.shadow.tint')
147 out('Removing ' + f + '.xft.shadow.tint\n')
149 fi, nul, face = find_key(data, f + '.xft.font')
151 fi, nul, face = find_key(data, '*.xft.font')
152 if fi >= 0: fi = len(data) - 1
154 out('Removing ' + f + '.xft.font\n')
160 if flags.find('bold'):
162 if flags.find('shadow'):
165 s = s + ':shadowoffset=' + offset
167 s = s + ':shadowtint=' + tint
168 out('Adding ' + fonts[f] + '\n')
169 data.insert(fi, fonts[f] + ': ' + s)
171 for stars in ('*.xft.flags', '*.xft.shadow.offset' ,
172 '*.xft.shadow.tint', '*.xft.font'):
173 i, key, nul = find_key(data, stars)
175 out('Removing ' + key + '\n')
179 fonts = ('window.label.focus.font',
183 i, key, value = find_key(data, f, True)
185 if value.find('pixelsize') == -1:
186 out('*** ERROR *** The ' + key + ' font size is not being '
187 'specified by pixelsize. It is recommended that you use '
188 'pixelsize instead of pointsize for specifying theme '
189 'fonts. e.g. "sans:pixelsize=12"\n')
193 def warn_missing(data):
194 need = ('window.button.hover.focus', 'window.button.hover.unfocus',
197 i, nul, nul = find_key(data, n)
199 out('The ' + n + ' value was not found in the theme, but it '
200 'can optionally be set.\n')
202 def err_missing(data):
203 need = ('window.button.disabled.focus', 'window.button.disabled.unfocus',
204 'window.frame.focusColor', 'window.frame.unfocusColor')
206 i, nul, nul = find_key(data, n)
208 out('*** ERROR *** The ' + n + ' value was not found in the '
209 'theme, but it is required to be set.\n')
215 out('Usage: themupdate.py /path/to/themerc > newthemerc\n\n')
219 file = open(sys.argv[1])
223 out('Unable to open file "' + sys.argv[1] + '"\n\n')
226 data = file.readlines()
227 for i in range(len(data)):
228 data[i] = data[i].strip()