]>
Dogcows Code - chaz/openbox/blob - tools/themeupdate/themeupdate.py
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
['style.'] = 'info.'
45 pairs
['menu.frame'] = 'menu.items'
46 pairs
['menu.hilite'] = 'menu.selected'
47 pairs
['.picColor'] = '.imageColor'
49 for k
in pairs
.keys():
51 i
, key
, nul
= find_key(data
, k
);
53 newl
= data
[i
].replace(k
, pairs
[k
])
54 out('Updating "' + key
+
55 '" to "' + key
.replace(k
, pairs
[k
]) + '"\n')
62 invalid
.append('toolbar')
63 invalid
.append('rootCommand')
64 invalid
.append('menu.frame.justify')
67 i
, key
, nul
= find_key(data
, inv
)
69 out(key
+ ' is no longer supported.\nRemove (Y/n)? ')
71 out('Removing "' + key
+ '"\n')
77 i
, nul
, nul
= find_key(data
, 'window.button.pressed', True)
79 out('The window.button.pressed option has been replaced by ' +
80 'window.button.pressed.focus and ' +
81 'window.button.pressed.unfocus.\nUpdate (Y/n)? ')
84 out('Removing "window.button.pressed"\n')
86 out('Adding "window.button.pressed.unfocus"\n')
87 data
.insert(i
, l
.replace('window.button.pressed',
88 'window.button.pressed.unfocus'))
89 out('Adding "window.button.pressed.focus"\n')
90 data
.insert(i
, l
.replace('window.button.pressed',
91 'window.button.pressed.focus'))
94 i
, nul
, nul
= find_key(data
, 'window.font')
96 out('You appear to specify fonts using the old X fonts ' +
97 'syntax.\nShall I remove all fonts from the theme (Y/n)? ')
102 i
, key
= key_find(data
, '.font')
105 out('Removing "' + key
+ '"\n')
109 i
, nul
, nul
= find_key(data
, '.xft.')
111 out('You appear to specify fonts using the old Xft fonts ' +
112 'syntax.\nShall I update these to the new syntax (Y/n)? ')
117 fonts
['window'] = 'window.label.focus.font'
118 fonts
['menu.items'] = 'menu.items.font'
119 fonts
['menu.title'] = 'menu.title.font'
120 for f
in fonts
.keys():
121 li
, nul
, flags
= find_key(data
, f
+ '.xft.flags')
123 li
, nul
, flags
= find_key(data
, '*.xft.flags')
125 out('Removing ' + f
+ '.xft.flags\n')
127 oi
, nul
, offset
= find_key(data
, f
+ '.xft.shadow.offset')
129 oi
, nul
, offset
= find_key(data
, '*.xft.shadow.offset')
131 out('Removing ' + f
+ '.xft.shadow.offset\n')
133 ti
, nul
, tint
= find_key(data
, f
+ '.xft.shadow.tint')
135 ti
, nul
, tint
= find_key(data
, '*.xft.shadow.tint')
137 out('Removing ' + f
+ '.xft.shadow.tint\n')
139 fi
, nul
, face
= find_key(data
, f
+ '.xft.font')
141 fi
, nul
, face
= find_key(data
, '*.xft.font')
142 if fi
>= 0: fi
= len(data
) - 1
144 out('Removing ' + f
+ '.xft.font\n')
150 if flags
.find('bold'):
152 if flags
.find('shadow'):
155 s
= s
+ ':shadowoffset=' + offset
157 s
= s
+ ':shadowtint=' + tint
158 out('Adding ' + fonts
[f
] + '\n')
159 data
.insert(fi
, fonts
[f
] + ': ' + s
)
161 for stars
in ('*.xft.flags', '*.xft.shadow.offset' ,
162 '*.xft.shadow.tint', '*.xft.font'):
163 i
, key
, nul
= find_key(data
, stars
)
165 out('Removing ' + key
+ '\n')
168 def warn_missing(data
):
169 need
= ('window.button.hover.focus', 'window.button.hover.unfocus',
172 i
, nul
, nul
= find_key(data
, n
)
174 out('The ' + n
+ ' value was not found in the theme, but it '
175 'can optionally be set.\n')
177 def err_missing(data
):
178 need
= ('window.button.disabled.focus', 'window.button.disabled.unfocus',
179 'window.frame.focusColor', 'window.frame.unfocusColor')
181 i
, nul
, nul
= find_key(data
, n
)
183 out('*** ERROR *** The ' + n
+ ' value was not found in the '
184 'theme, but it is required to be set.\n')
190 print 'Usage: ' + sys
.argv
[0] + ' /path/to/themerc > newthemerc'
195 file = open(sys
.argv
[1])
199 print 'Unable to open file "' + sys
.argv
[1] + '"'
203 data
= file.readlines()
204 for i
in range(len(data
)):
205 data
[i
] = data
[i
].strip()
This page took 0.047018 seconds and 4 git commands to generate.