]>
Dogcows Code - chaz/openbox/blob - tools/themeupdate/themeupdate.py
13 inp
= sys
.stdin
.readline(1).strip()
14 if inp
== 'y' or inp
== '': return True
15 if inp
== 'n': return False
18 key
= line
[:line
.find(':')].strip()
19 value
= line
[line
.find(':') + 1:].strip()
20 if not (key
and value
):
24 def find_key(data
, keysubstr
):
29 key
, value
= getkeyval(l
)
31 if key
.find(keysubstr
) != -1:
36 def simple_replace(data
):
38 pairs
['window.focus.font'] = 'window.label.focus.font'
39 pairs
['window.unfocus.font'] = 'window.label.unfocus.font'
40 pairs
['window.justify'] = 'window.label.justify'
41 pairs
['menu.frame.disableColor'] = 'menu.disabled.textColor'
42 pairs
['style.'] = 'info.'
43 pairs
['menu.frame'] = 'menu.items'
44 pairs
['menu.hilite'] = 'menu.selected'
45 pairs
['.picColor'] = '.imageColor'
47 for k
in pairs
.keys():
49 i
, key
, nul
= find_key(data
, k
);
51 newl
= data
[i
].replace(k
, pairs
[k
])
52 out('Updating "' + key
+
53 '" to "' + key
.replace(k
, pairs
[k
]) + '"\n')
60 invalid
.append('toolbar')
61 invalid
.append('rootCommand')
62 invalid
.append('menu.frame.justify')
65 i
, key
, nul
= find_key(data
, inv
)
67 out(key
+ ' is no longer supported.\nRemove (Y/n)? ')
69 out('Removing "' + key
+ '"\n')
75 i
, nul
, nul
= find_key(data
, 'window.button.pressed')
77 out('The window.button.pressed option has been replaced by ' +
78 'window.button.pressed.focus and ' +
79 'window.button.pressed.unfocus.\nUpdate (Y/n)? ')
81 out('Removing "window.button.pressed"\n')
83 out('Adding "window.button.pressed.unfocus"\n')
84 data
.insert(i
, l
.replace('window.button.pressed',
85 'window.button.pressed.unfocus'))
86 out('Adding "window.button.pressed.focus"\n')
87 data
.insert(i
, l
.replace('window.button.pressed',
88 'window.button.pressed.focus'))
91 i
, nul
, nul
= find_key(data
, 'window.font')
93 out('You appear to specify fonts using the old X fonts ' +
94 'syntax.\nShall I remove all fonts from the theme (Y/n)? ')
99 i
, key
= key_find(data
, '.font')
102 out('Removing "' + key
+ '"\n')
106 i
, nul
, nul
= find_key(data
, '.xft.')
108 out('You appear to specify fonts using the old Xft fonts ' +
109 'syntax.\nShall I update these to the new syntax (Y/n)? ')
114 fonts
['window'] = 'window.label.focus.font'
115 fonts
['menu.items'] = 'menu.items.font'
116 fonts
['menu.title'] = 'menu.title.font'
117 for f
in fonts
.keys():
118 li
, nul
, flags
= find_key(data
, f
+ '.xft.flags')
120 li
, nul
, flags
= find_key(data
, '*.xft.flags')
122 out('Removing ' + f
+ '.xft.flags\n')
124 oi
, nul
, offset
= find_key(data
, f
+ '.xft.shadow.offset')
126 oi
, nul
, offset
= find_key(data
, '*.xft.shadow.offset')
128 out('Removing ' + f
+ '.xft.shadow.offset\n')
130 ti
, nul
, tint
= find_key(data
, f
+ '.xft.shadow.tint')
132 ti
, nul
, tint
= find_key(data
, '*.xft.shadow.tint')
134 out('Removing ' + f
+ '.xft.shadow.tint\n')
136 fi
, nul
, face
= find_key(data
, f
+ '.xft.font')
138 fi
, nul
, face
= find_key(data
, '*.xft.font')
139 if fi
>= 0: fi
= len(data
) - 1
141 out('Removing ' + f
+ '.xft.font\n')
147 if flags
.find('bold'):
149 if flags
.find('shadow'):
152 s
= s
+ ':shadowoffset=' + offset
154 s
= s
+ ':shadowtint=' + tint
155 out('Adding ' + fonts
[f
] + '\n')
156 data
.insert(fi
, fonts
[f
] + ': ' + s
)
158 for stars
in ('*.xft.flags', '*.xft.shadow.offset' ,
159 '*.xft.shadow.tint', '*.xft.font'):
160 i
, key
, nul
= find_key(data
, stars
)
162 out('Removing ' + key
+ '\n')
179 print 'Usage: ' + sys
.argv
[0] + ' /path/to/themerc > newthemerc'
184 file = open(sys
.argv
[1])
188 print 'Unable to open file "' + sys
.argv
[1] + '"'
192 data
= file.readlines()
193 for i
in range(len(data
)):
194 data
[i
] = data
[i
].strip()
This page took 0.048921 seconds and 4 git commands to generate.