Merge lp:~bellini666/kiwi/test_pyflakes_pep8 into lp:~jdahlin-deactivatedaccount/kiwi/master
- test_pyflakes_pep8
- Merge into master
Proposed by
Thiago Bellini
Status: | Merged |
---|---|
Merged at revision: | 1810 |
Proposed branch: | lp:~bellini666/kiwi/test_pyflakes_pep8 |
Merge into: | lp:~jdahlin-deactivatedaccount/kiwi/master |
Diff against target: |
4879 lines (+838/-279) 96 files modified
.bzrignore (+1/-0) Makefile (+9/-0) kiwi/accessor.py (+65/-51) kiwi/argcheck.py (+5/-1) kiwi/component.py (+8/-5) kiwi/controllers.py (+3/-2) kiwi/currency.py (+4/-2) kiwi/datatypes.py (+35/-4) kiwi/db/query.py (+1/-0) kiwi/db/sqlobj.py (+3/-0) kiwi/db/stormintegration.py (+3/-2) kiwi/decorators.py (+2/-0) kiwi/desktopparser.py (+4/-0) kiwi/dist.py (+8/-2) kiwi/enums.py (+6/-1) kiwi/environ.py (+6/-2) kiwi/i18n/i18n.py (+13/-4) kiwi/i18n/msgfmt.py (+11/-16) kiwi/interfaces.py (+5/-0) kiwi/log.py (+9/-0) kiwi/model.py (+7/-9) kiwi/python.py (+12/-1) kiwi/tasklet.py (+6/-2) kiwi/ui/builderloader.py (+1/-0) kiwi/ui/comboboxentry.py (+2/-0) kiwi/ui/comboentry.py (+9/-8) kiwi/ui/dateentry.py (+7/-3) kiwi/ui/delegates.py (+4/-2) kiwi/ui/dialogs.py (+18/-4) kiwi/ui/entry.py (+36/-36) kiwi/ui/entrycompletion.py (+9/-7) kiwi/ui/gadgets.py (+11/-1) kiwi/ui/gaxmlloader.py (+1/-0) kiwi/ui/hyperlink.py (+1/-0) kiwi/ui/libgladeloader.py (+1/-0) kiwi/ui/objectlist.py (+7/-6) kiwi/ui/pixbufutils.py (+1/-1) kiwi/ui/proxy.py (+6/-3) kiwi/ui/proxywidget.py (+3/-1) kiwi/ui/search.py (+7/-9) kiwi/ui/test/common.py (+1/-0) kiwi/ui/test/main.py (+3/-0) kiwi/ui/test/recorder.py (+25/-0) kiwi/ui/test/runner.py (+8/-2) kiwi/ui/tooltip.py (+2/-1) kiwi/ui/views.py (+12/-7) kiwi/ui/widgets/button.py (+1/-1) kiwi/ui/widgets/checkbutton.py (+5/-1) kiwi/ui/widgets/colorbutton.py (+1/-0) kiwi/ui/widgets/combo.py (+3/-4) kiwi/ui/widgets/combobox.py (+2/-0) kiwi/ui/widgets/contextmenu.py (+2/-2) kiwi/ui/widgets/entry.py (+7/-0) kiwi/ui/widgets/filechooser.py (+6/-0) kiwi/ui/widgets/fontbutton.py (+1/-1) kiwi/ui/widgets/label.py (+8/-4) kiwi/ui/widgets/list.py (+1/-1) kiwi/ui/widgets/radiobutton.py (+3/-0) kiwi/ui/widgets/scale.py (+2/-1) kiwi/ui/widgets/spinbutton.py (+3/-0) kiwi/ui/widgets/textview.py (+3/-0) kiwi/utils.py (+10/-1) kiwiwidgets.py (+3/-0) setup.py (+1/-1) tests/Proxies/CheckButton.py (+10/-2) tests/Proxies/Entry.py (+21/-5) tests/Proxies/NoModel.py (+5/-1) tests/Proxies/None.py (+3/-0) tests/Proxies/OptionMenu.py (+11/-4) tests/Proxies/RadioGroup.py (+7/-2) tests/Proxies/Separator.py (+3/-0) tests/Proxies/Text.py (+8/-2) tests/test_BaseView.py (+7/-1) tests/test_CheckButton.py (+1/-0) tests/test_ComboBox.py (+5/-0) tests/test_Delegate.py (+13/-3) tests/test_Entry.py (+1/-0) tests/test_Label.py (+1/-0) tests/test_ObjectList.py (+8/-2) tests/test_Scale.py (+1/-0) tests/test_SpinButton.py (+1/-0) tests/test_argcheck.py (+3/-2) tests/test_comboentry.py (+3/-1) tests/test_component.py (+17/-8) tests/test_datatypes.py (+12/-5) tests/test_dateentry.py (+1/-0) tests/test_desktopparser.py (+1/-0) tests/test_log.py (+1/-1) tests/test_masks.py (+19/-17) tests/test_pep8.py (+50/-0) tests/test_proxy.py (+5/-4) tests/test_pyflakes.py (+81/-0) tests/test_python.py (+4/-0) tests/test_tasklet.py (+9/-4) tests/test_ui.py (+4/-3) tests/utils.py (+59/-0) |
To merge this branch: | bzr merge lp:~bellini666/kiwi/test_pyflakes_pep8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Johan Dahlin | Pending | ||
Review via email: mp+104772@code.launchpad.net |
Commit message
Description of the change
Testes de pyflakes e pep8.
To post a comment you must log in.
- 1813. By Thiago Bellini
-
Allow running tests from 'make'. Add shorcuts for pyflakes/pep8
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2011-07-11 02:58:54 +0000 |
3 | +++ .bzrignore 2012-05-04 16:37:18 +0000 |
4 | @@ -1,3 +1,4 @@ |
5 | +_trial_temp |
6 | locale |
7 | build |
8 | locale/es_CL |
9 | |
10 | === modified file 'Makefile' |
11 | --- Makefile 2012-02-10 19:37:37 +0000 |
12 | +++ Makefile 2012-05-04 16:37:18 +0000 |
13 | @@ -41,6 +41,15 @@ |
14 | ssh johan@master.gnome.org ftpadmin install $(TARBALL) |
15 | scp dist/kiwi-$(VERSION).win32.exe johan@master.gnome.org:/ftp/pub/GNOME/binaries/win32/kiwi/ |
16 | |
17 | +check: |
18 | + trial tests |
19 | + |
20 | +pyflakes: |
21 | + trial tests.test_pyflakes |
22 | + |
23 | +pep8: |
24 | + trial tests.test_pep8 |
25 | + |
26 | include async.mk |
27 | |
28 | .PHONY: bdist upload-release |
29 | |
30 | === modified file 'kiwi/accessor.py' |
31 | --- kiwi/accessor.py 2006-12-07 14:19:20 +0000 |
32 | +++ kiwi/accessor.py 2012-05-04 16:37:18 +0000 |
33 | @@ -40,6 +40,7 @@ |
34 | |
35 | log = Logger('kiwi.accessor') |
36 | |
37 | + |
38 | def get_default_getter(model, attr_name, cache): |
39 | """Obtains from model a callable through which attr_name can be |
40 | retrieved. This callable is an accessor named get_foo, where |
41 | @@ -55,6 +56,7 @@ |
42 | else: |
43 | return (model, attr_name) |
44 | |
45 | + |
46 | def get_default_setter(model, attr_name, cache): |
47 | """Obtains from model a callable through which attr_name can be |
48 | set. This callable is an accessor named set_foo, where |
49 | @@ -99,8 +101,10 @@ |
50 | _ksetattr_cache = {} |
51 | _ksetattr_wref = {} |
52 | |
53 | + |
54 | class CacheControl(object): |
55 | __slots__ = ['key', 'cacheable'] |
56 | + |
57 | def __init__(self, key): |
58 | self.key = key |
59 | self.cacheable = 1 |
60 | @@ -110,21 +114,24 @@ |
61 | |
62 | def invalidate(self): |
63 | key = self.key |
64 | - if _kgetattr_cache.has_key(key): |
65 | + if key in _kgetattr_cache: |
66 | del _kgetattr_cache[key] |
67 | - if _ksetattr_cache.has_key(key): |
68 | + if key in _ksetattr_cache: |
69 | del _ksetattr_cache[key] |
70 | |
71 | + |
72 | class _AttrUnset: |
73 | # indicates an unset value since None needs to be used |
74 | pass |
75 | |
76 | + |
77 | class DefaultValue(Exception): |
78 | """ |
79 | This can be raised in kgetattr accessors to indicate that the default |
80 | value should be used |
81 | """ |
82 | |
83 | + |
84 | def kgetattr_guard(wref): |
85 | try: |
86 | key = _kgetattr_wref[id(wref)][0] |
87 | @@ -134,6 +141,7 @@ |
88 | # This path is used only when the program terminates. |
89 | pass |
90 | |
91 | + |
92 | def ksetattr_guard(wref): |
93 | try: |
94 | key = _ksetattr_wref[id(wref)][0] |
95 | @@ -143,6 +151,7 @@ |
96 | # This path is used only when the program terminates. |
97 | pass |
98 | |
99 | + |
100 | # 1. Break up attr_name into parts |
101 | # 2. Loop around main lookup code for each part: |
102 | # 2.1. Try and get accessor tuple out of cache |
103 | @@ -152,30 +161,31 @@ |
104 | # Use value as obj in next iteration |
105 | # 3. Return value |
106 | |
107 | -def kgetattr(model, |
108 | - attr_name, |
109 | - default=_AttrUnset, |
110 | - flat=0, |
111 | - # bind to local variables for speed: |
112 | - ref=weakref.ref, |
113 | - TupleType=types.TupleType, |
114 | - MethodType=types.MethodType, |
115 | - split=string.split, |
116 | - kgetattr_guard=kgetattr_guard, |
117 | - getattr=getattr, |
118 | - dummycache=CacheControl((None,None)), |
119 | - # constants: |
120 | - # access opcodes: |
121 | - LAMBDA_ACCESS = 0, |
122 | - METHOD_ACCESS = 1, |
123 | - TUPLE_ACCESS = 2, |
124 | - NWR_METHOD_ACCESS = 3, |
125 | - NWR_TUPLE_ACCESS = 4, |
126 | - # FAST tuples do not store the object, as the input object |
127 | - # is also the accesses object. |
128 | - FAST_METHOD_ACCESS = 5, |
129 | - FAST_TUPLE_ACCESS = 6, |
130 | - ): |
131 | +def kgetattr( |
132 | + model, |
133 | + attr_name, |
134 | + default=_AttrUnset, |
135 | + flat=0, |
136 | + # bind to local variables for speed: |
137 | + ref=weakref.ref, |
138 | + TupleType=types.TupleType, |
139 | + MethodType=types.MethodType, |
140 | + split=string.split, |
141 | + kgetattr_guard=kgetattr_guard, |
142 | + getattr=getattr, |
143 | + dummycache=CacheControl((None, None)), |
144 | + # constants: |
145 | + # access opcodes: |
146 | + LAMBDA_ACCESS=0, |
147 | + METHOD_ACCESS=1, |
148 | + TUPLE_ACCESS=2, |
149 | + NWR_METHOD_ACCESS=3, |
150 | + NWR_TUPLE_ACCESS=4, |
151 | + # FAST tuples do not store the object, as the input object |
152 | + # is also the accesses object. |
153 | + FAST_METHOD_ACCESS=5, |
154 | + FAST_TUPLE_ACCESS=6, |
155 | + ): |
156 | """Returns the value associated with the attribute in model |
157 | named by attr_name. If default is provided and model does not |
158 | have an attribute called attr_name, the default value is |
159 | @@ -284,7 +294,7 @@ |
160 | # store a hard reference. |
161 | _kgetattr_cache[key] = (obj, icode, data1, data2) |
162 | else: |
163 | - if _kgetattr_cache.has_key(key): |
164 | + if key in _kgetattr_cache: |
165 | del _kgetattr_cache[key] |
166 | |
167 | # 2.3. Use accessor tuple to grab value |
168 | @@ -324,6 +334,7 @@ |
169 | # 3. Return value |
170 | return obj |
171 | |
172 | + |
173 | # A general algo for ksetattr: |
174 | # |
175 | # 1. Use attr_name to kgetattr the target object, and get the real attribute |
176 | @@ -331,28 +342,29 @@ |
177 | # 3. If not there, generate accessor tuple and store it |
178 | # 4. Set value to target object's attribute |
179 | |
180 | -def ksetattr(model, |
181 | - attr_name, |
182 | - value, |
183 | - flat=0, |
184 | - |
185 | - # bind to local variables for speed: |
186 | - ref=weakref.ref, |
187 | - TupleType=types.TupleType, |
188 | - MethodType=types.MethodType, |
189 | - ksetattr_guard=ksetattr_guard, |
190 | - getattr=getattr, |
191 | - dummycache=CacheControl((None,None)), |
192 | - |
193 | - # constants: |
194 | - LAMBDA_ACCESS = 0, |
195 | - METHOD_ACCESS = 1, |
196 | - TUPLE_ACCESS = 2, |
197 | - NWR_METHOD_ACCESS = 3, |
198 | - NWR_TUPLE_ACCESS = 4, |
199 | - FAST_METHOD_ACCESS = 5, |
200 | - FAST_TUPLE_ACCESS = 6, |
201 | - ): |
202 | +def ksetattr( |
203 | + model, |
204 | + attr_name, |
205 | + value, |
206 | + flat=0, |
207 | + |
208 | + # bind to local variables for speed: |
209 | + ref=weakref.ref, |
210 | + TupleType=types.TupleType, |
211 | + MethodType=types.MethodType, |
212 | + ksetattr_guard=ksetattr_guard, |
213 | + getattr=getattr, |
214 | + dummycache=CacheControl((None, None)), |
215 | + |
216 | + # constants: |
217 | + LAMBDA_ACCESS=0, |
218 | + METHOD_ACCESS=1, |
219 | + TUPLE_ACCESS=2, |
220 | + NWR_METHOD_ACCESS=3, |
221 | + NWR_TUPLE_ACCESS=4, |
222 | + FAST_METHOD_ACCESS=5, |
223 | + FAST_TUPLE_ACCESS=6, |
224 | + ): |
225 | """Set the value associated with the attribute in model |
226 | named by attr_name. If flat=1 is specified, no dot path parsing will |
227 | be done.""" |
228 | @@ -367,7 +379,7 @@ |
229 | lastdot = string.rfind(attr_name, ".") |
230 | if lastdot != -1: |
231 | model = kgetattr(model, attr_name[:lastdot]) |
232 | - attr_name = attr_name[lastdot+1:] |
233 | + attr_name = attr_name[lastdot + 1:] |
234 | |
235 | # At this point we only have a flat attribute and the right model. |
236 | key = (id(model), attr_name) |
237 | @@ -446,7 +458,7 @@ |
238 | # it's not weakref-able, store a hard reference. |
239 | _ksetattr_cache[key] = (model, icode, data1, data2) |
240 | else: |
241 | - if _ksetattr_cache.has_key(key): |
242 | + if key in _ksetattr_cache: |
243 | del _ksetattr_cache.has_key[key] |
244 | |
245 | if icode == FAST_TUPLE_ACCESS: |
246 | @@ -466,6 +478,7 @@ |
247 | else: |
248 | raise AssertionError("Unknown tuple type in _ksetattr_cache") |
249 | |
250 | + |
251 | def enable_attr_cache(): |
252 | """Enables the use of the kgetattr cache when using Python |
253 | versions that do not support weakrefs (1.5.x and earlier). Be |
254 | @@ -477,6 +490,7 @@ |
255 | _kgetattr_wref = {} |
256 | _ksetattr_wref = {} |
257 | |
258 | + |
259 | def clear_attr_cache(): |
260 | """Clears the kgetattr cache. It must be called repeatedly to |
261 | avoid memory leaks in Python 2.0 and earlier.""" |
262 | |
263 | === modified file 'kiwi/argcheck.py' |
264 | --- kiwi/argcheck.py 2012-04-10 18:14:36 +0000 |
265 | +++ kiwi/argcheck.py 2012-05-04 16:37:18 +0000 |
266 | @@ -30,17 +30,22 @@ |
267 | |
268 | from kiwi.datatypes import number as number_type |
269 | |
270 | +_NoValue = object() |
271 | + |
272 | + |
273 | class CustomType(type): |
274 | @classmethod |
275 | def value_check(mcs, name, value): |
276 | pass |
277 | |
278 | + |
279 | class number(CustomType): |
280 | """ |
281 | Custom type that verifies that the type is a number (eg float or int) |
282 | """ |
283 | type = number_type |
284 | |
285 | + |
286 | class percent(CustomType): |
287 | """ |
288 | Custom type that verifies that the value is a percentage |
289 | @@ -52,7 +57,6 @@ |
290 | if (value < 0) or (value > 100): |
291 | raise ValueError("%s must be between 0 and 100" % name) |
292 | |
293 | -_NoValue = object() |
294 | |
295 | class argcheck(object): |
296 | """ |
297 | |
298 | === modified file 'kiwi/component.py' |
299 | --- kiwi/component.py 2012-04-10 18:14:36 +0000 |
300 | +++ kiwi/component.py 2012-05-04 16:37:18 +0000 |
301 | @@ -40,11 +40,10 @@ |
302 | return True |
303 | return False |
304 | |
305 | - |
306 | class Attribute(object): |
307 | def __init__(self, __name__, __doc__=''): |
308 | - self.__name__=__name__ |
309 | - self.__doc__=__doc__ |
310 | + self.__name__ = __name__ |
311 | + self.__doc__ = __doc__ |
312 | |
313 | def implements(iface): |
314 | frame = sys._getframe(1) |
315 | @@ -53,9 +52,11 @@ |
316 | finally: |
317 | del frame |
318 | |
319 | + |
320 | class AlreadyImplementedError(Exception): |
321 | """Called when a utility already exists.""" |
322 | |
323 | + |
324 | class _UtilityHandler(object): |
325 | def __init__(self): |
326 | self._utilities = {} |
327 | @@ -97,6 +98,7 @@ |
328 | def clean(self): |
329 | self._utilities = {} |
330 | |
331 | + |
332 | def provide_utility(iface, utility, replace=False): |
333 | """ |
334 | Set the utility for the named interface. If the utility is already |
335 | @@ -107,6 +109,7 @@ |
336 | """ |
337 | utilities.provide(iface, utility, replace) |
338 | |
339 | + |
340 | def get_utility(iface, default=ValueUnset): |
341 | """ |
342 | Get the utility for the named interface. If the utility is not |
343 | @@ -120,6 +123,7 @@ |
344 | |
345 | return utilities.get(iface, default) |
346 | |
347 | + |
348 | def remove_utility(iface): |
349 | """ |
350 | Remove the utility provided for an interface |
351 | @@ -132,6 +136,5 @@ |
352 | |
353 | return utilities.remove(iface) |
354 | |
355 | + |
356 | utilities = _UtilityHandler() |
357 | - |
358 | - |
359 | |
360 | === modified file 'kiwi/controllers.py' |
361 | --- kiwi/controllers.py 2007-03-22 13:20:25 +0000 |
362 | +++ kiwi/controllers.py 2012-05-04 16:37:18 +0000 |
363 | @@ -26,6 +26,7 @@ |
364 | |
365 | """Holds the base controller class for the Kiwi Framework""" |
366 | |
367 | + |
368 | class BaseController: |
369 | """ |
370 | A generic controller that can be attached to any View |
371 | @@ -36,6 +37,7 @@ |
372 | holds the UI implementation itself (widgets, layout, etc.) |
373 | """ |
374 | view = None |
375 | + |
376 | def __init__(self, view=None, keyactions=None): |
377 | """ |
378 | Creates a new controller, and attaches itself to a view. The |
379 | @@ -53,7 +55,7 @@ |
380 | |
381 | if not view and not self.view: |
382 | raise AssertionError( |
383 | - "Need a view to create controller, found None" ) |
384 | + "Need a view to create controller, found None") |
385 | else: |
386 | self.set_view(view) |
387 | |
388 | @@ -92,7 +94,6 @@ |
389 | if func: |
390 | return func() |
391 | |
392 | - |
393 | # |
394 | # Accessors |
395 | # |
396 | |
397 | === modified file 'kiwi/currency.py' |
398 | --- kiwi/currency.py 2012-03-12 20:54:34 +0000 |
399 | +++ kiwi/currency.py 2012-05-04 16:37:18 +0000 |
400 | @@ -32,6 +32,7 @@ |
401 | |
402 | _ = lambda m: gettext.dgettext('kiwi', m) |
403 | |
404 | + |
405 | class currency(Decimal): |
406 | """ |
407 | A datatype representing currency, used together with the list and |
408 | @@ -128,8 +129,8 @@ |
409 | if frac_digits == 127: |
410 | frac_digits = 2 |
411 | |
412 | - format = '%%.%sf' % (frac_digits+1) |
413 | - dec_part = (format % value)[-(frac_digits+1):-1] |
414 | + format = '%%.%sf' % (frac_digits + 1) |
415 | + dec_part = (format % value)[-(frac_digits + 1):-1] |
416 | |
417 | mon_decimal_point = conv.get('mon_decimal_point', '.') |
418 | currency += mon_decimal_point + dec_part |
419 | @@ -160,6 +161,7 @@ |
420 | |
421 | _DecimalConverter = type(converter.get_converter(Decimal)) |
422 | |
423 | + |
424 | class _CurrencyConverter(_DecimalConverter): |
425 | type = currency |
426 | name = _('Currency') |
427 | |
428 | === modified file 'kiwi/datatypes.py' |
429 | --- kiwi/datatypes.py 2012-03-12 20:54:34 +0000 |
430 | +++ kiwi/datatypes.py 2012-05-04 16:37:18 +0000 |
431 | @@ -54,21 +54,25 @@ |
432 | Decimal, InvalidOperation # pyflakes |
433 | except: |
434 | HAVE_DECIMAL = False |
435 | + |
436 | class Decimal(float): |
437 | pass |
438 | + |
439 | InvalidOperation = ValueError |
440 | |
441 | if sys.platform == 'win32': |
442 | try: |
443 | import ctypes |
444 | + |
445 | def GetLocaleInfo(value): |
446 | s = ctypes.create_string_buffer("\000" * 255) |
447 | ctypes.windll.kernel32.GetLocaleInfoA(0, value, s, 255) |
448 | return str(s.value) |
449 | except ImportError: |
450 | - def GetLocaleInfo(value): |
451 | + def _GetLocaleInfo(value): |
452 | raise Exception( |
453 | "ctypes is required for datetime types on win32") |
454 | + GetLocaleInfo = _GetLocaleInfo |
455 | |
456 | __all__ = ['ValidationError', 'lformat', 'converter', 'format_price'] |
457 | |
458 | @@ -76,9 +80,11 @@ |
459 | |
460 | number = (int, float, long, Decimal) |
461 | |
462 | + |
463 | class ValidationError(Exception): |
464 | pass |
465 | |
466 | + |
467 | class ConverterRegistry: |
468 | def __init__(self): |
469 | self._converters = {} |
470 | @@ -99,7 +105,7 @@ |
471 | self._converters[str(c.type)] = c |
472 | self._converters[c.type.__name__] = c |
473 | return c |
474 | - |
475 | + |
476 | def remove(self, converter_type): |
477 | """ |
478 | Removes converter_type from the registry |
479 | @@ -195,6 +201,7 @@ |
480 | # Global converter, can be accessed from outside |
481 | converter = ConverterRegistry() |
482 | |
483 | + |
484 | class BaseConverter(object): |
485 | """ |
486 | Abstract converter used by all datatypes |
487 | @@ -237,6 +244,7 @@ |
488 | """ |
489 | return None |
490 | |
491 | + |
492 | class _StringConverter(BaseConverter): |
493 | type = str |
494 | name = _('String') |
495 | @@ -251,6 +259,7 @@ |
496 | |
497 | converter.add(_StringConverter) |
498 | |
499 | + |
500 | class _UnicodeConverter(BaseConverter): |
501 | type = unicode |
502 | name = _('Unicode') |
503 | @@ -265,6 +274,7 @@ |
504 | |
505 | converter.add(_UnicodeConverter) |
506 | |
507 | + |
508 | class _IntConverter(BaseConverter): |
509 | type = int |
510 | name = _('Integer') |
511 | @@ -294,11 +304,14 @@ |
512 | |
513 | converter.add(_IntConverter) |
514 | |
515 | + |
516 | class _LongConverter(_IntConverter): |
517 | type = long |
518 | name = _('Long') |
519 | + |
520 | converter.add(_LongConverter) |
521 | |
522 | + |
523 | class _BoolConverter(BaseConverter): |
524 | type = bool |
525 | name = _('Boolean') |
526 | @@ -321,6 +334,7 @@ |
527 | |
528 | converter.add(_BoolConverter) |
529 | |
530 | + |
531 | class _FloatConverter(BaseConverter): |
532 | type = float |
533 | name = _('Float') |
534 | @@ -373,10 +387,12 @@ |
535 | |
536 | converter.add(_FloatConverter) |
537 | |
538 | + |
539 | class _DecimalConverter(_FloatConverter): |
540 | type = Decimal |
541 | name = _('Decimal') |
542 | align = Alignment.RIGHT |
543 | + |
544 | def from_string(self, value, filter=True): |
545 | if value == '': |
546 | return ValueUnset |
547 | @@ -414,7 +430,7 @@ |
548 | # a tuple, which holds in the first position the |
549 | # mask characters and in the second position |
550 | # a "human-readable" format, used for outputting user |
551 | -# messages (see method _BaseDateTimeConverter.convert_format) |
552 | +# messages (see method _BaseDateTimeConverter.convert_format) |
553 | DATE_MASK_TABLE = { |
554 | '%m': ('00', _('mm')), |
555 | '%y': ('00', _('yy')), |
556 | @@ -428,6 +444,7 @@ |
557 | '%r': ('00:00:00 LL', _('hh:mm:ss LL')), |
558 | } |
559 | |
560 | + |
561 | class _BaseDateTimeConverter(BaseConverter): |
562 | """ |
563 | Abstract class for converting datatime objects to and from strings |
564 | @@ -563,6 +580,7 @@ |
565 | type = datetime.time |
566 | name = _('Time') |
567 | date_format = '%X' |
568 | + |
569 | def get_lang_constant_win32(self): |
570 | return [LOCALE_STIMEFORMAT] |
571 | |
572 | @@ -572,12 +590,15 @@ |
573 | def from_dateinfo(self, dateinfo): |
574 | # hour, minute, second |
575 | return datetime.time(*dateinfo[3:6]) |
576 | + |
577 | converter.add(_TimeConverter) |
578 | |
579 | + |
580 | class _DateTimeConverter(_BaseDateTimeConverter): |
581 | type = datetime.datetime |
582 | name = _('Date and Time') |
583 | date_format = '%c' |
584 | + |
585 | def get_lang_constant_win32(self): |
586 | return [LOCALE_SSHORTDATE, LOCALE_STIMEFORMAT] |
587 | |
588 | @@ -587,12 +608,15 @@ |
589 | def from_dateinfo(self, dateinfo): |
590 | # year, month, day, hour, minute, second |
591 | return datetime.datetime(*dateinfo[:6]) |
592 | + |
593 | converter.add(_DateTimeConverter) |
594 | |
595 | + |
596 | class _DateConverter(_BaseDateTimeConverter): |
597 | type = datetime.date |
598 | name = _('Date') |
599 | date_format = '%x' |
600 | + |
601 | def get_lang_constant_win32(self): |
602 | return [LOCALE_SSHORTDATE] |
603 | |
604 | @@ -602,16 +626,20 @@ |
605 | def from_dateinfo(self, dateinfo): |
606 | # year, month, day |
607 | return datetime.date(*dateinfo[:3]) |
608 | + |
609 | converter.add(_DateConverter) |
610 | |
611 | + |
612 | class _ObjectConverter(BaseConverter): |
613 | type = object |
614 | name = _('Object') |
615 | |
616 | as_string = None |
617 | from_string = None |
618 | + |
619 | converter.add(_ObjectConverter) |
620 | |
621 | + |
622 | class _EnumConverter(BaseConverter): |
623 | type = enum |
624 | name = _('Enum') |
625 | @@ -632,10 +660,12 @@ |
626 | |
627 | converter.add(_EnumConverter) |
628 | |
629 | + |
630 | def lformat(format, value): |
631 | """Like locale.format but with grouping enabled""" |
632 | return locale.format(format, value, 1) |
633 | |
634 | + |
635 | def get_localeconv(): |
636 | conv = locale.localeconv() |
637 | |
638 | @@ -661,6 +691,7 @@ |
639 | |
640 | return conv |
641 | |
642 | + |
643 | def filter_locale(value, monetary=False): |
644 | """ |
645 | Removes the locale specific data from the value string. |
646 | @@ -682,7 +713,7 @@ |
647 | th_sep_count = value.count(thousands_sep) |
648 | if th_sep_count and decimal_points: |
649 | decimal_point_pos = value.index(decimal_point) |
650 | - if thousands_sep in value[decimal_point_pos+1:]: |
651 | + if thousands_sep in value[decimal_point_pos + 1:]: |
652 | raise ValidationError(_("You have a thousand separator to the " |
653 | "right of the decimal point")) |
654 | check_value = value[:decimal_point_pos] |
655 | |
656 | === modified file 'kiwi/db/query.py' |
657 | --- kiwi/db/query.py 2012-02-10 19:37:37 +0000 |
658 | +++ kiwi/db/query.py 2012-05-04 16:37:18 +0000 |
659 | @@ -27,6 +27,7 @@ |
660 | # Query building |
661 | # |
662 | |
663 | + |
664 | class QueryState(object): |
665 | def __init__(self, search_filter): |
666 | """ |
667 | |
668 | === modified file 'kiwi/db/sqlobj.py' |
669 | --- kiwi/db/sqlobj.py 2012-02-10 19:37:37 +0000 |
670 | +++ kiwi/db/sqlobj.py 2012-05-04 16:37:18 +0000 |
671 | @@ -33,12 +33,15 @@ |
672 | NumberIntervalQueryState |
673 | from kiwi.interfaces import ISearchFilter |
674 | |
675 | + |
676 | class _FTI(SQLExpression): |
677 | def __init__(self, q): |
678 | self.q = q |
679 | + |
680 | def __sqlrepr__(self, db): |
681 | return self.q |
682 | |
683 | + |
684 | class SQLObjectQueryExecuter(QueryExecuter): |
685 | def __init__(self, conn=None): |
686 | QueryExecuter.__init__(self) |
687 | |
688 | === modified file 'kiwi/db/stormintegration.py' |
689 | --- kiwi/db/stormintegration.py 2012-02-10 19:37:37 +0000 |
690 | +++ kiwi/db/stormintegration.py 2012-05-04 16:37:18 +0000 |
691 | @@ -34,7 +34,9 @@ |
692 | NumberIntervalQueryState |
693 | from kiwi.interfaces import ISearchFilter |
694 | |
695 | -# FIXME: make this usable outside of stoqlib |
696 | +# FIXME: make this usable outside of stoqlib |
697 | + |
698 | + |
699 | class StormQueryExecuter(QueryExecuter): |
700 | """Execute queries from a storm database""" |
701 | |
702 | @@ -202,4 +204,3 @@ |
703 | queries.append(table_field <= state.end) |
704 | if queries: |
705 | return And(*queries) |
706 | - |
707 | |
708 | === modified file 'kiwi/decorators.py' |
709 | --- kiwi/decorators.py 2012-02-10 19:37:37 +0000 |
710 | +++ kiwi/decorators.py 2012-05-04 16:37:18 +0000 |
711 | @@ -25,6 +25,7 @@ |
712 | |
713 | from kiwi.log import kiwi_log |
714 | |
715 | + |
716 | class deprecated(object): |
717 | """ |
718 | I am a decorator which prints a deprecation warning each |
719 | @@ -57,6 +58,7 @@ |
720 | raise |
721 | return wrapper |
722 | |
723 | + |
724 | class signal_block(object): |
725 | """ |
726 | A decorator to be used on :class:`kiwi.ui.views.SlaveView` methods. |
727 | |
728 | === modified file 'kiwi/desktopparser.py' |
729 | --- kiwi/desktopparser.py 2012-02-10 19:37:37 +0000 |
730 | +++ kiwi/desktopparser.py 2012-05-04 16:37:18 +0000 |
731 | @@ -30,21 +30,25 @@ |
732 | |
733 | # Private |
734 | |
735 | + |
736 | def _localize(option, locale): |
737 | if locale: |
738 | option = option + '[%s]' % locale |
739 | return option |
740 | |
741 | + |
742 | def _tobool(s): |
743 | if s == 'true': |
744 | return True |
745 | return False |
746 | |
747 | + |
748 | def _frombool(s): |
749 | if s: |
750 | return 'true' |
751 | return 'false' |
752 | |
753 | + |
754 | class DesktopParser(ConfigParser): |
755 | """ |
756 | A DesktopParser for GNOME/KDE .desktop files. |
757 | |
758 | === modified file 'kiwi/dist.py' |
759 | --- kiwi/dist.py 2012-02-21 14:02:07 +0000 |
760 | +++ kiwi/dist.py 2012-05-04 16:37:18 +0000 |
761 | @@ -38,6 +38,7 @@ |
762 | |
763 | from setuptools import setup as DS_setup |
764 | |
765 | + |
766 | class _VariableExtender: |
767 | def __init__(self, distribution): |
768 | install = distribution.get_command_obj('install') |
769 | @@ -85,6 +86,7 @@ |
770 | string = string.replace('$' + name, var) |
771 | return string |
772 | |
773 | + |
774 | class KiwiInstallLib(install_lib): |
775 | # Overridable by subclass |
776 | resources = {} |
777 | @@ -175,6 +177,7 @@ |
778 | # Backwards compat |
779 | TemplateInstallLib = KiwiInstallLib |
780 | |
781 | + |
782 | class KiwiInstallData(install_data): |
783 | def run(self): |
784 | self.varext = _VariableExtender(self.distribution) |
785 | @@ -225,6 +228,7 @@ |
786 | site = 'dist-packages' |
787 | return os.path.join(libdir, site, *dirs) |
788 | |
789 | + |
790 | def listfiles(*dirs): |
791 | """ |
792 | Lists all files in directories and optionally uses basic shell |
793 | @@ -245,6 +249,7 @@ |
794 | for filename in os.listdir(abspath) |
795 | if filename[0] != '.' and fnmatch(filename, pattern)] |
796 | |
797 | + |
798 | def compile_po_files(domain, dirname='locale'): |
799 | """ |
800 | Compiles po files to mo files. |
801 | @@ -277,6 +282,7 @@ |
802 | |
803 | return data_files |
804 | |
805 | + |
806 | def listpackages(root, exclude=None): |
807 | """Recursivly list all packages in directory root |
808 | Optionally exclude can be specified which is a string |
809 | @@ -308,6 +314,7 @@ |
810 | |
811 | return packages |
812 | |
813 | + |
814 | def setup(**kwargs): |
815 | """ |
816 | A drop in replacement for distutils.core.setup which |
817 | @@ -329,7 +336,7 @@ |
818 | def run_install(self): |
819 | name = kwargs.get('name') |
820 | if name: |
821 | - self.data_files.extend(compile_po_files(name)) |
822 | + self.data_files.extend(compile_po_files(name)) |
823 | KiwiInstallData.run(self) |
824 | |
825 | varext = _VariableExtender(self.distribution) |
826 | @@ -356,7 +363,6 @@ |
827 | info('installing template %s' % target_file) |
828 | open(target_file, 'w').write(data) |
829 | |
830 | - |
831 | # distutils uses old style classes |
832 | InstallData = new.classobj('InstallData', (KiwiInstallData,), |
833 | dict(run=run_install)) |
834 | |
835 | === modified file 'kiwi/enums.py' |
836 | --- kiwi/enums.py 2008-05-08 16:47:26 +0000 |
837 | +++ kiwi/enums.py 2012-05-04 16:37:18 +0000 |
838 | @@ -23,22 +23,27 @@ |
839 | |
840 | from kiwi.python import enum |
841 | |
842 | + |
843 | class ComboColumn(enum): |
844 | (LABEL, |
845 | DATA) = range(2) |
846 | |
847 | + |
848 | class ComboMode(enum): |
849 | (UNKNOWN, |
850 | STRING, |
851 | DATA) = range(3) |
852 | |
853 | + |
854 | class Alignment(enum): |
855 | (LEFT, |
856 | RIGHT) = range(2) |
857 | |
858 | + |
859 | class Direction(enum): |
860 | (LEFT, RIGHT) = (1, -1) |
861 | |
862 | + |
863 | class ListType(enum): |
864 | """ |
865 | - NORMAL: Add, Remove, Edit |
866 | @@ -55,6 +60,7 @@ |
867 | UNADDABLE, |
868 | UNEDITABLE) = range(6) |
869 | |
870 | + |
871 | class SearchFilterPosition(enum): |
872 | """ |
873 | An enum used to indicate where a search filter should be added to |
874 | @@ -65,4 +71,3 @@ |
875 | """ |
876 | (TOP, |
877 | BOTTOM) = range(2) |
878 | - |
879 | |
880 | === modified file 'kiwi/environ.py' |
881 | --- kiwi/environ.py 2012-03-01 18:40:15 +0000 |
882 | +++ kiwi/environ.py 2012-05-04 16:37:18 +0000 |
883 | @@ -42,6 +42,7 @@ |
884 | |
885 | EnvironmentError = EnvironmentError |
886 | |
887 | + |
888 | # From http://tinyurl.com/77ukj |
889 | def _is_frozen(): |
890 | "Helper function to check if we're frozen in a py2exe'd file" |
891 | @@ -49,6 +50,7 @@ |
892 | hasattr(sys, "importers") # old py2exe |
893 | or imp.is_frozen("__main__")) # tools/freeze |
894 | |
895 | + |
896 | class Environment: |
897 | """Environment control |
898 | |
899 | @@ -171,6 +173,7 @@ |
900 | |
901 | epydoc = property(_get_epydoc) |
902 | |
903 | + |
904 | class Library(Environment): |
905 | """A Library is a local environment object, it's a subclass of the |
906 | Environment class. |
907 | @@ -379,12 +382,13 @@ |
908 | fp = open(revision) |
909 | except IOError, e: |
910 | if e.errno != errno.ENOENT: |
911 | - raise |
912 | + raise |
913 | else: |
914 | return fp.read().split()[0] |
915 | else: |
916 | return str(self.module.revision) |
917 | |
918 | + |
919 | class Application(Library): |
920 | """Application extends a :class:`Library`. It's meant to be used |
921 | by applications |
922 | @@ -438,7 +442,7 @@ |
923 | """ |
924 | Library.enable_translation(self, domain, localedir) |
925 | old_domain = gettext.textdomain() |
926 | - if old_domain != 'messages': |
927 | + if old_domain != 'messages': |
928 | log.warn('overriding default domain, was %s' % old_domain) |
929 | |
930 | self.set_application_domain(domain) |
931 | |
932 | === modified file 'kiwi/i18n/i18n.py' |
933 | --- kiwi/i18n/i18n.py 2011-07-05 22:05:42 +0000 |
934 | +++ kiwi/i18n/i18n.py 2012-05-04 16:37:18 +0000 |
935 | @@ -35,6 +35,7 @@ |
936 | # will be generate from it, see update_po() |
937 | POTFILES = 'POTFILES.list' |
938 | |
939 | + |
940 | def check_directory(root): |
941 | po_dir = os.path.join(root, 'po') |
942 | if not os.path.exists(po_dir): |
943 | @@ -47,12 +48,14 @@ |
944 | if not os.path.isdir(po_dir): |
945 | raise SystemExit("locale must be a directory") |
946 | |
947 | + |
948 | def check_pot_file(root, package): |
949 | pot_file = os.path.join(root, 'po', '%s.pot' % package) |
950 | if not os.path.exists(pot_file): |
951 | raise SystemExit("Need a pot file, run --update first") |
952 | return pot_file |
953 | |
954 | + |
955 | def get_translatable_files(root): |
956 | pofiles = os.path.join(root, 'po', POTFILES) |
957 | if not os.path.exists(pofiles): |
958 | @@ -66,9 +69,11 @@ |
959 | filelist.process_template_line(line) |
960 | return sorted(filelist.files) |
961 | |
962 | + |
963 | def list_languages(root): |
964 | return [os.path.basename(po_file[:-3]) |
965 | - for po_file in listfiles(root, 'po', '*.po')] |
966 | + for po_file in listfiles(root, 'po', '*.po')] |
967 | + |
968 | |
969 | def update_po(root, package): |
970 | update_pot(root, package) |
971 | @@ -88,6 +93,7 @@ |
972 | |
973 | os.chdir(old) |
974 | |
975 | + |
976 | def update_pot(root, package): |
977 | files = get_translatable_files(root) |
978 | potfiles_in = os.path.join(root, 'po', 'POTFILES.in') |
979 | @@ -105,7 +111,6 @@ |
980 | fd.write(filename + '\n') |
981 | fd.close() |
982 | |
983 | - |
984 | old = os.getcwd() |
985 | os.chdir(os.path.join(root, 'po')) |
986 | |
987 | @@ -124,6 +129,7 @@ |
988 | |
989 | os.unlink(potfiles_in) |
990 | |
991 | + |
992 | def _clean_rml(data): |
993 | fixed = '' |
994 | while data: |
995 | @@ -137,9 +143,10 @@ |
996 | if end_pos == -1: |
997 | end_pos = data.find('/>') |
998 | assert end_pos != -1 |
999 | - data = data[end_pos+2:] |
1000 | + data = data[end_pos + 2:] |
1001 | return fixed |
1002 | |
1003 | + |
1004 | def _extract_rml_files(root): |
1005 | files = [] |
1006 | for rml_file in sorted(findall(root)): |
1007 | @@ -153,7 +160,7 @@ |
1008 | if os.path.exists(extracted): |
1009 | os.unlink(extracted) |
1010 | open(extracted, 'w').write(data) |
1011 | - extracted = extracted[len(root)+1:] |
1012 | + extracted = extracted[len(root) + 1:] |
1013 | cmd = 'intltool-extract -q --type=gettext/xml %s' % extracted |
1014 | res = os.system(cmd) |
1015 | if res != 0: |
1016 | @@ -162,6 +169,7 @@ |
1017 | files.append(extracted + '.h') |
1018 | return files |
1019 | |
1020 | + |
1021 | def compile_po_files(root, package): |
1022 | if os.system('msgfmt 2> /dev/null') != 256: |
1023 | print 'msgfmt could not be found, disabling translations' |
1024 | @@ -178,6 +186,7 @@ |
1025 | os.makedirs(directory) |
1026 | os.system('msgfmt %s -o %s' % (po_file, mo)) |
1027 | |
1028 | + |
1029 | def main(args): |
1030 | parser = OptionParser() |
1031 | parser.add_option('-a', '--add', |
1032 | |
1033 | === modified file 'kiwi/i18n/msgfmt.py' |
1034 | --- kiwi/i18n/msgfmt.py 2005-11-21 16:39:32 +0000 |
1035 | +++ kiwi/i18n/msgfmt.py 2012-05-04 16:37:18 +0000 |
1036 | @@ -36,7 +36,6 @@ |
1037 | MESSAGES = {} |
1038 | |
1039 | |
1040 | - |
1041 | |
1042 | def usage(code, msg=''): |
1043 | print >> sys.stderr, doc |
1044 | if msg: |
1045 | @@ -44,7 +43,6 @@ |
1046 | sys.exit(code) |
1047 | |
1048 | |
1049 | - |
1050 | |
1051 | def add(id, str, fuzzy): |
1052 | "Add a non-fuzzy translation to the dictionary." |
1053 | global MESSAGES |
1054 | @@ -52,7 +50,6 @@ |
1055 | MESSAGES[id] = str |
1056 | |
1057 | |
1058 | - |
1059 | |
1060 | def generate(): |
1061 | "Return the generated output." |
1062 | global MESSAGES |
1063 | @@ -71,7 +68,7 @@ |
1064 | # The header is 7 32-bit unsigned integers. We don't use hash tables, so |
1065 | # the keys start right after the index tables. |
1066 | # translated string. |
1067 | - keystart = 7*4+16*len(keys) |
1068 | + keystart = (7 * 4) + (16 * len(keys)) |
1069 | # and the values start after the keys |
1070 | valuestart = keystart + len(ids) |
1071 | koffsets = [] |
1072 | @@ -79,23 +76,22 @@ |
1073 | # The string table first has the list of keys, then the list of values. |
1074 | # Each entry has first the size of the string, then the file offset. |
1075 | for o1, l1, o2, l2 in offsets: |
1076 | - koffsets += [l1, o1+keystart] |
1077 | - voffsets += [l2, o2+valuestart] |
1078 | + koffsets += [l1, o1 + keystart] |
1079 | + voffsets += [l2, o2 + valuestart] |
1080 | offsets = koffsets + voffsets |
1081 | output = struct.pack("Iiiiiii", |
1082 | - 0x950412deL, # Magic |
1083 | - 0, # Version |
1084 | - len(keys), # # of entries |
1085 | - 7*4, # start of key index |
1086 | - 7*4+len(keys)*8, # start of value index |
1087 | - 0, 0) # size and offset of hash table |
1088 | + 0x950412deL, # Magic |
1089 | + 0, # Version |
1090 | + len(keys), # # of entries |
1091 | + 7 * 4, # start of key index |
1092 | + 7 * 4 + len(keys) * 8, # start of value index |
1093 | + 0, 0) # size and offset of hash table |
1094 | output += array.array("i", offsets).tostring() |
1095 | output += ids |
1096 | output += strs |
1097 | return output |
1098 | |
1099 | |
1100 | - |
1101 | |
1102 | def make(filename, outfile): |
1103 | ID = 1 |
1104 | STR = 2 |
1105 | @@ -167,12 +163,11 @@ |
1106 | output = generate() |
1107 | |
1108 | try: |
1109 | - open(outfile,"wb").write(output) |
1110 | - except IOError,msg: |
1111 | + open(outfile, "wb").write(output) |
1112 | + except IOError, msg: |
1113 | print >> sys.stderr, msg |
1114 | |
1115 | |
1116 | - |
1117 | |
1118 | def main(): |
1119 | try: |
1120 | opts, args = getopt.getopt(sys.argv[1:], 'hVo:', |
1121 | |
1122 | === modified file 'kiwi/interfaces.py' |
1123 | --- kiwi/interfaces.py 2012-02-10 19:37:37 +0000 |
1124 | +++ kiwi/interfaces.py 2012-05-04 16:37:18 +0000 |
1125 | @@ -26,6 +26,7 @@ |
1126 | |
1127 | from kiwi.component import Interface |
1128 | |
1129 | + |
1130 | class IProxyWidget(Interface): |
1131 | """ |
1132 | IProxyWidget is a widget that can be attached to a proxy. |
1133 | @@ -52,6 +53,7 @@ |
1134 | """ |
1135 | pass |
1136 | |
1137 | + |
1138 | class IValidatableProxyWidget(IProxyWidget): |
1139 | """ |
1140 | IValidatableProxyWidget extends IProxyWidget with validation support |
1141 | @@ -72,6 +74,7 @@ |
1142 | def validate(force=False): |
1143 | pass |
1144 | |
1145 | + |
1146 | class IEasyCombo(Interface): |
1147 | |
1148 | def prefill(itemdata, sort=False): |
1149 | @@ -152,6 +155,7 @@ |
1150 | def get_model_items(): |
1151 | pass |
1152 | |
1153 | + |
1154 | class AbstractGladeAdaptor(Interface): |
1155 | """Abstract class that define the functionality an class that handle |
1156 | glade files should provide.""" |
1157 | @@ -174,6 +178,7 @@ |
1158 | values of dic |
1159 | """ |
1160 | |
1161 | + |
1162 | class ISearchFilter(Interface): |
1163 | |
1164 | def get_state(): |
1165 | |
1166 | === modified file 'kiwi/log.py' |
1167 | --- kiwi/log.py 2012-02-10 19:37:37 +0000 |
1168 | +++ kiwi/log.py 2012-05-04 16:37:18 +0000 |
1169 | @@ -70,21 +70,25 @@ |
1170 | _console = None |
1171 | _filter = None |
1172 | |
1173 | + |
1174 | class LogError(Exception): |
1175 | pass |
1176 | |
1177 | + |
1178 | class Logger(object): |
1179 | # Backwards compatibility, we should probably replace the callsites |
1180 | # with import logging; logging.getLogger(name) |
1181 | def __new__(self, name): |
1182 | return logging.getLogger(name) |
1183 | |
1184 | + |
1185 | class _Logger(logging.Logger): |
1186 | def __call__(self, message, *args, **kwargs): |
1187 | self.info(message, *args, **kwargs) |
1188 | |
1189 | logging.setLoggerClass(_Logger) |
1190 | |
1191 | + |
1192 | class ReversedGlobalFilter(logging.Filter): |
1193 | """ |
1194 | It's like a reversed filter, the default behavior |
1195 | @@ -106,6 +110,7 @@ |
1196 | |
1197 | return False |
1198 | |
1199 | + |
1200 | def set_log_file(filename, mask=None): |
1201 | """ |
1202 | Set the filename used for logging. |
1203 | @@ -127,6 +132,7 @@ |
1204 | |
1205 | return file_handler.stream |
1206 | |
1207 | + |
1208 | def set_log_level(name, level): |
1209 | """ |
1210 | Set the log level. |
1211 | @@ -137,6 +143,7 @@ |
1212 | global _filter |
1213 | _filter.add_filter(name, level) |
1214 | |
1215 | + |
1216 | def _read_log_levels(console_filter): |
1217 | log_levels = {} |
1218 | # bootstrap issue, cannot depend on kiwi.environ |
1219 | @@ -163,6 +170,7 @@ |
1220 | |
1221 | console_filter.add_filter(name, level) |
1222 | |
1223 | + |
1224 | def _create_console(): |
1225 | global _filter, _console |
1226 | |
1227 | @@ -184,6 +192,7 @@ |
1228 | _filter = console_filter |
1229 | _console = console |
1230 | |
1231 | + |
1232 | def update_logger(): |
1233 | _create_console() |
1234 | |
1235 | |
1236 | === modified file 'kiwi/model.py' |
1237 | --- kiwi/model.py 2012-04-10 18:14:36 +0000 |
1238 | +++ kiwi/model.py 2012-05-04 16:37:18 +0000 |
1239 | @@ -37,6 +37,7 @@ |
1240 | # attributes are changed, it notifies any proxies of the change. |
1241 | # |
1242 | |
1243 | + |
1244 | class Model: |
1245 | """ |
1246 | The Model is a mixin to be used by domain classes when attached to |
1247 | @@ -86,13 +87,13 @@ |
1248 | |
1249 | # XXX: should use weakref if possible, and if not, warn of leaks |
1250 | proxies = self._v_proxies |
1251 | - if not proxies.has_key(attr): |
1252 | + if not attr in proxies: |
1253 | proxies[attr] = [proxy] |
1254 | else: |
1255 | if proxy in proxies[attr]: |
1256 | - raise AssertionError, ("Tried to attach proxy %s " |
1257 | - "twice to attribute `%s'." |
1258 | - % ( proxy, attr )) |
1259 | + raise AssertionError("Tried to attach proxy %s " |
1260 | + "twice to attribute `%s'." % |
1261 | + (proxy, attr)) |
1262 | proxies[attr].append(proxy) |
1263 | |
1264 | def unregister_proxy_for_attribute(self, attr, proxy): |
1265 | @@ -100,7 +101,7 @@ |
1266 | if not hasattr(self, "_v_proxies"): |
1267 | self.ensure_init() |
1268 | proxies = self._v_proxies |
1269 | - if proxies.has_key(attr) and proxy in proxies[attr]: |
1270 | + if attr in proxies and proxy in proxies[attr]: |
1271 | # Only one listener per attribute per proxy, so remove() |
1272 | # works |
1273 | proxies[attr].remove(proxy) |
1274 | @@ -157,12 +158,9 @@ |
1275 | if not hasattr(self, "_v_proxies"): |
1276 | self.ensure_init() |
1277 | |
1278 | - if self._v_autonotify and self._v_proxies.has_key(attr): |
1279 | + if self._v_autonotify and attr in self._v_proxies: |
1280 | self.notify_proxies(attr) |
1281 | |
1282 | -# |
1283 | -# A sample model that pickles itself into a file |
1284 | -# |
1285 | |
1286 | class PickledModel(Model): |
1287 | """ |
1288 | |
1289 | === modified file 'kiwi/python.py' |
1290 | --- kiwi/python.py 2012-04-10 18:14:36 +0000 |
1291 | +++ kiwi/python.py 2012-05-04 16:37:18 +0000 |
1292 | @@ -28,12 +28,14 @@ |
1293 | |
1294 | __all__ = ['ClassInittableMetaType', 'ClassInittableObject'] |
1295 | |
1296 | + |
1297 | class ClassInittableMetaType(type): |
1298 | # pylint fails to understand this is a metaclass |
1299 | def __init__(self, name, bases, namespace): |
1300 | type.__init__(self, name, bases, namespace) |
1301 | self.__class_init__(namespace) |
1302 | |
1303 | + |
1304 | class ClassInittableObject(object): |
1305 | """ |
1306 | I am an object which will call a classmethod called |
1307 | @@ -98,7 +100,7 @@ |
1308 | raise TypeError("'target' is a reserved attribute") |
1309 | |
1310 | for attribute in ns['attributes']: |
1311 | - setattr(cls, attribute, _ForwardedProperty(attribute)) |
1312 | + setattr(cls, attribute, _ForwardedProperty(attribute)) |
1313 | |
1314 | def __init__(self, target): |
1315 | """ |
1316 | @@ -146,6 +148,7 @@ |
1317 | |
1318 | return obj |
1319 | |
1320 | + |
1321 | class Settable: |
1322 | """ |
1323 | A mixin class for syntactic sugar. Lets you assign attributes by |
1324 | @@ -172,6 +175,7 @@ |
1325 | ', '.join( |
1326 | ['%s=%r' % (attr, getattr(self, attr)) for attr in self._attrs])) |
1327 | |
1328 | + |
1329 | def qual(klass): |
1330 | """ |
1331 | Convert a class to a string representation, which is the name of the module |
1332 | @@ -181,6 +185,7 @@ |
1333 | """ |
1334 | return klass.__module__ + '.' + klass.__name__ |
1335 | |
1336 | + |
1337 | def clamp(x, low, high): |
1338 | """ |
1339 | Ensures that x is between the limits set by low and high. |
1340 | @@ -197,6 +202,7 @@ |
1341 | |
1342 | return min(max(x, low), high) |
1343 | |
1344 | + |
1345 | def slicerange(slice, limit): |
1346 | """Takes a slice object and returns a range iterator |
1347 | |
1348 | @@ -209,6 +215,7 @@ |
1349 | |
1350 | _no_deprecation = False |
1351 | |
1352 | + |
1353 | def deprecationwarn(msg, stacklevel=2): |
1354 | """ |
1355 | Prints a deprecation warning |
1356 | @@ -219,6 +226,7 @@ |
1357 | |
1358 | warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel) |
1359 | |
1360 | + |
1361 | def disabledeprecationcall(func, *args, **kwargs): |
1362 | """ |
1363 | Disables all deprecation warnings during the function call to func |
1364 | @@ -230,6 +238,7 @@ |
1365 | _no_deprecation = old |
1366 | return retval |
1367 | |
1368 | + |
1369 | class enum(int): |
1370 | """ |
1371 | enum is an enumered type implementation in python. |
1372 | @@ -298,6 +307,7 @@ |
1373 | self.__class__.__name__, self.name) |
1374 | __repr__ = __str__ |
1375 | |
1376 | + |
1377 | def all(seq): |
1378 | """ |
1379 | Predict used to check if all items in a seq are True. |
1380 | @@ -308,6 +318,7 @@ |
1381 | return False |
1382 | return True |
1383 | |
1384 | + |
1385 | def any(seq): |
1386 | """ |
1387 | Predict used to check if any item in a seq are True. |
1388 | |
1389 | === modified file 'kiwi/tasklet.py' |
1390 | --- kiwi/tasklet.py 2012-02-10 19:37:37 +0000 |
1391 | +++ kiwi/tasklet.py 2012-05-04 16:37:18 +0000 |
1392 | @@ -188,6 +188,7 @@ |
1393 | |
1394 | _event = None |
1395 | |
1396 | + |
1397 | class task(object): |
1398 | """A decorator that modifies a tasklet function to avoid the need |
1399 | to call C{tasklet.run(func())} or C{tasklet.Tasklet(func())}. |
1400 | @@ -200,6 +201,7 @@ |
1401 | def __call__(self, *args, **kwargs): |
1402 | return Tasklet(self._func(*args, **kwargs)) |
1403 | |
1404 | + |
1405 | def get_event(): |
1406 | """ |
1407 | Return the last event that caused the current tasklet to regain control. |
1408 | @@ -214,6 +216,7 @@ |
1409 | _event = None |
1410 | return event |
1411 | |
1412 | + |
1413 | def run(gen): |
1414 | """Start running a generator as a :class:`Tasklet`. |
1415 | |
1416 | @@ -426,6 +429,7 @@ |
1417 | self._id = None |
1418 | return retval |
1419 | |
1420 | + |
1421 | class WaitForIdle(WaitCondition): |
1422 | '''An object that waits for the main loop to become idle''' |
1423 | |
1424 | @@ -507,6 +511,7 @@ |
1425 | self._idle_id = None |
1426 | return False |
1427 | |
1428 | + |
1429 | class WaitForSignal(WaitCondition): |
1430 | '''An object that waits for a signal emission''' |
1431 | |
1432 | @@ -811,7 +816,7 @@ |
1433 | return None |
1434 | else: |
1435 | self.state = Tasklet.STATE_SUSPENDED |
1436 | - assert gen_value is not None |
1437 | + assert gen_value is not None |
1438 | if __debug__: |
1439 | if had_event and _event is not None: |
1440 | warnings.warn("Tasklet %s forgot to read an event!" % self) |
1441 | @@ -892,7 +897,6 @@ |
1442 | return self._message_queue.pop(idx) |
1443 | return None |
1444 | |
1445 | - |
1446 | def _update_wait_conditions(self, old_wait_list): |
1447 | '''disarm wait conditions removed and arm new wait conditions''' |
1448 | |
1449 | |
1450 | === modified file 'kiwi/ui/builderloader.py' |
1451 | --- kiwi/ui/builderloader.py 2012-02-21 20:25:01 +0000 |
1452 | +++ kiwi/ui/builderloader.py 2012-05-04 16:37:18 +0000 |
1453 | @@ -56,6 +56,7 @@ |
1454 | |
1455 | log = Logger('builderloader') |
1456 | |
1457 | + |
1458 | class BuilderWidgetTree: |
1459 | def __init__(self, view, gladefile=None, domain=None, data=None): |
1460 | self._view = view |
1461 | |
1462 | === modified file 'kiwi/ui/comboboxentry.py' |
1463 | --- kiwi/ui/comboboxentry.py 2012-02-10 19:37:37 +0000 |
1464 | +++ kiwi/ui/comboboxentry.py 2012-05-04 16:37:18 +0000 |
1465 | @@ -31,6 +31,7 @@ |
1466 | from kiwi.python import deprecationwarn |
1467 | from kiwi.ui.entry import KiwiEntry |
1468 | |
1469 | + |
1470 | class BaseComboBoxEntry(gtk.ComboBox): |
1471 | def __init__(self, model=None, text_column=-1): |
1472 | deprecationwarn( |
1473 | @@ -110,6 +111,7 @@ |
1474 | |
1475 | gobject.type_register(BaseComboBoxEntry) |
1476 | |
1477 | + |
1478 | def test(): |
1479 | win = gtk.Window() |
1480 | win.connect('delete-event', gtk.main_quit) |
1481 | |
1482 | === modified file 'kiwi/ui/comboentry.py' |
1483 | --- kiwi/ui/comboentry.py 2012-03-15 17:58:30 +0000 |
1484 | +++ kiwi/ui/comboentry.py 2012-05-04 16:37:18 +0000 |
1485 | @@ -41,6 +41,7 @@ |
1486 | |
1487 | class _ComboEntryPopup(gtk.Window): |
1488 | gsignal('text-selected', str) |
1489 | + |
1490 | def __init__(self, comboentry): |
1491 | gtk.Window.__init__(self, gtk.WINDOW_POPUP) |
1492 | self.add_events(gdk.BUTTON_PRESS_MASK) |
1493 | @@ -255,7 +256,7 @@ |
1494 | if gdk.keyboard_grab(window, True, activate_time) == 0: |
1495 | return True |
1496 | else: |
1497 | - window.pointer_ungrab(activate_time); |
1498 | + window.pointer_ungrab(activate_time) |
1499 | return False |
1500 | return False |
1501 | |
1502 | @@ -268,7 +269,7 @@ |
1503 | |
1504 | allocation = widget.get_allocation() |
1505 | |
1506 | - window = widget.get_window() |
1507 | + window = widget.get_window() |
1508 | # Gtk+ 3.x |
1509 | if hasattr(window, 'get_root_coords'): |
1510 | x = 0 |
1511 | @@ -321,7 +322,7 @@ |
1512 | y - monitor.y): |
1513 | y += allocation.height |
1514 | height = monitor.y + monitor.height - y |
1515 | - else : |
1516 | + else: |
1517 | height = y - monitor.y |
1518 | y = monitor.y |
1519 | |
1520 | @@ -358,10 +359,10 @@ |
1521 | # testcase |
1522 | tmodel = model.get_model() |
1523 | if tmodel.iter_is_valid(treeiter): |
1524 | - # revert back to the unfiltered model so we can select |
1525 | - # the right object |
1526 | - self._treeview.set_model(tmodel) |
1527 | - self._selection = self._treeview.get_selection() |
1528 | + # revert back to the unfiltered model so we can select |
1529 | + # the right object |
1530 | + self._treeview.set_model(tmodel) |
1531 | + self._selection = self._treeview.get_selection() |
1532 | else: |
1533 | treeiter = model.convert_child_iter_to_iter(treeiter) |
1534 | self._selection.select_iter(treeiter) |
1535 | @@ -371,6 +372,7 @@ |
1536 | |
1537 | type_register(_ComboEntryPopup) |
1538 | |
1539 | + |
1540 | class ComboEntry(gtk.VBox): |
1541 | |
1542 | implements(IEasyCombo) |
1543 | @@ -596,7 +598,6 @@ |
1544 | """ |
1545 | return self._popup.get_selected_iter() |
1546 | |
1547 | - |
1548 | def get_mode(self): |
1549 | return self.mode |
1550 | |
1551 | |
1552 | === modified file 'kiwi/ui/dateentry.py' |
1553 | --- kiwi/ui/dateentry.py 2012-04-03 16:29:49 +0000 |
1554 | +++ kiwi/ui/dateentry.py 2012-05-04 16:37:18 +0000 |
1555 | @@ -39,8 +39,10 @@ |
1556 | |
1557 | date_converter = converter.get_converter(datetime.date) |
1558 | |
1559 | + |
1560 | class _DateEntryPopup(gtk.Window): |
1561 | gsignal('date-selected', object) |
1562 | + |
1563 | def __init__(self, dateentry): |
1564 | gtk.Window.__init__(self, gtk.WINDOW_POPUP) |
1565 | self.add_events(gdk.BUTTON_PRESS_MASK) |
1566 | @@ -179,7 +181,7 @@ |
1567 | if gdk.keyboard_grab(window, True, activate_time) == 0: |
1568 | return True |
1569 | else: |
1570 | - window.get_display().pointer_ungrab(activate_time); |
1571 | + window.get_display().pointer_ungrab(activate_time) |
1572 | return False |
1573 | return False |
1574 | |
1575 | @@ -192,7 +194,7 @@ |
1576 | # We need to fetch the coordinates of the entry window |
1577 | # since comboentry itself does not have a window |
1578 | allocation = widget.get_allocation() |
1579 | - window = widget.get_window() |
1580 | + window = widget.get_window() |
1581 | # Gtk+ 3.x |
1582 | if hasattr(window, 'get_root_coords'): |
1583 | x = 0 |
1584 | @@ -231,7 +233,7 @@ |
1585 | y - monitor.y): |
1586 | y += allocation.height |
1587 | height = monitor.y + monitor.height - y |
1588 | - else : |
1589 | + else: |
1590 | height = y - monitor.y |
1591 | y = monitor.y |
1592 | |
1593 | @@ -306,6 +308,7 @@ |
1594 | self.calendar.clear_marks() |
1595 | self.calendar.mark_day(date.day) |
1596 | |
1597 | + |
1598 | class DateEntry(gtk.HBox): |
1599 | """I am an entry which you can input a date on. |
1600 | In addition to an gtk.Entry I also contain a button |
1601 | @@ -314,6 +317,7 @@ |
1602 | """ |
1603 | gsignal('changed') |
1604 | gsignal('activate') |
1605 | + |
1606 | def __init__(self): |
1607 | gtk.HBox.__init__(self) |
1608 | |
1609 | |
1610 | === modified file 'kiwi/ui/delegates.py' |
1611 | --- kiwi/ui/delegates.py 2012-02-10 19:37:37 +0000 |
1612 | +++ kiwi/ui/delegates.py 2012-05-04 16:37:18 +0000 |
1613 | @@ -29,6 +29,7 @@ |
1614 | from kiwi.controllers import BaseController |
1615 | from kiwi.python import deprecationwarn |
1616 | |
1617 | + |
1618 | class Delegate(BaseView, BaseController): |
1619 | """A class that combines view and controller functionality into a |
1620 | single package. The Delegate class possesses a top-level window. |
1621 | @@ -54,6 +55,7 @@ |
1622 | delete_handler=delete_handler) |
1623 | BaseController.__init__(self, view=self, keyactions=keyactions) |
1624 | |
1625 | + |
1626 | class GladeDelegate(BaseView, BaseController): |
1627 | """A class that combines view and controller functionality into a |
1628 | single package. The Delegate class possesses a top-level window. |
1629 | @@ -72,6 +74,7 @@ |
1630 | delete_handler=delete_handler) |
1631 | BaseController.__init__(self, view=self, keyactions=keyactions) |
1632 | |
1633 | + |
1634 | class SlaveDelegate(SlaveView, BaseController): |
1635 | """A class that combines view and controller functionality into a |
1636 | single package. It does not possess a top-level window, but is instead |
1637 | @@ -92,6 +95,7 @@ |
1638 | toplevel_name) |
1639 | BaseController.__init__(self, view=self, keyactions=keyactions) |
1640 | |
1641 | + |
1642 | class GladeSlaveDelegate(SlaveView, BaseController): |
1643 | """A class that combines view and controller functionality into a |
1644 | single package. It does not possess a top-level window, but is instead |
1645 | @@ -191,5 +195,3 @@ |
1646 | |
1647 | def update(self, attribute): |
1648 | self.proxy.update(attribute) |
1649 | - |
1650 | - |
1651 | |
1652 | === modified file 'kiwi/ui/dialogs.py' |
1653 | --- kiwi/ui/dialogs.py 2012-03-14 16:36:10 +0000 |
1654 | +++ kiwi/ui/dialogs.py 2012-05-04 16:37:18 +0000 |
1655 | @@ -33,10 +33,10 @@ |
1656 | |
1657 | _IMAGE_TYPES = { |
1658 | gtk.MESSAGE_INFO: gtk.STOCK_DIALOG_INFO, |
1659 | - gtk.MESSAGE_WARNING : gtk.STOCK_DIALOG_WARNING, |
1660 | - gtk.MESSAGE_QUESTION : gtk.STOCK_DIALOG_QUESTION, |
1661 | - gtk.MESSAGE_ERROR : gtk.STOCK_DIALOG_ERROR, |
1662 | -} |
1663 | + gtk.MESSAGE_WARNING: gtk.STOCK_DIALOG_WARNING, |
1664 | + gtk.MESSAGE_QUESTION: gtk.STOCK_DIALOG_QUESTION, |
1665 | + gtk.MESSAGE_ERROR: gtk.STOCK_DIALOG_ERROR, |
1666 | + } |
1667 | |
1668 | _BUTTON_TYPES = { |
1669 | gtk.BUTTONS_NONE: (), |
1670 | @@ -49,6 +49,7 @@ |
1671 | gtk.STOCK_OK, gtk.RESPONSE_OK) |
1672 | } |
1673 | |
1674 | + |
1675 | class HIGAlertDialog(gtk.Dialog): |
1676 | def __init__(self, parent, flags, |
1677 | type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE): |
1678 | @@ -128,6 +129,7 @@ |
1679 | widget.show() |
1680 | self._expander.show() |
1681 | |
1682 | + |
1683 | class BaseDialog(gtk.Dialog): |
1684 | def __init__(self, parent=None, title='', flags=0, buttons=()): |
1685 | if parent and not isinstance(parent, (gtk.Window, gtk.Dialog)): |
1686 | @@ -143,6 +145,7 @@ |
1687 | self.set_has_separator(False) |
1688 | self.vbox.set_spacing(6) |
1689 | |
1690 | + |
1691 | def messagedialog(dialog_type, short, long=None, parent=None, |
1692 | buttons=gtk.BUTTONS_OK, default=-1): |
1693 | """Create and show a MessageDialog. |
1694 | @@ -210,6 +213,7 @@ |
1695 | d.destroy() |
1696 | return response |
1697 | |
1698 | + |
1699 | def _simple(type, short, long=None, parent=None, buttons=gtk.BUTTONS_OK, |
1700 | default=-1): |
1701 | if buttons == gtk.BUTTONS_OK: |
1702 | @@ -218,23 +222,28 @@ |
1703 | parent=parent, buttons=buttons, |
1704 | default=default) |
1705 | |
1706 | + |
1707 | def error(short, long=None, parent=None, buttons=gtk.BUTTONS_OK, default=-1): |
1708 | return _simple(gtk.MESSAGE_ERROR, short, long, parent=parent, |
1709 | buttons=buttons, default=default) |
1710 | |
1711 | + |
1712 | def info(short, long=None, parent=None, buttons=gtk.BUTTONS_OK, default=-1): |
1713 | return _simple(gtk.MESSAGE_INFO, short, long, parent=parent, |
1714 | buttons=buttons, default=default) |
1715 | |
1716 | + |
1717 | def warning(short, long=None, parent=None, buttons=gtk.BUTTONS_OK, default=-1): |
1718 | return _simple(gtk.MESSAGE_WARNING, short, long, parent=parent, |
1719 | buttons=buttons, default=default) |
1720 | |
1721 | + |
1722 | def yesno(text, parent=None, default=gtk.RESPONSE_YES, |
1723 | buttons=gtk.BUTTONS_YES_NO): |
1724 | return messagedialog(gtk.MESSAGE_WARNING, text, None, parent, |
1725 | buttons=buttons, default=default) |
1726 | |
1727 | + |
1728 | def open(title='', parent=None, patterns=None, folder=None, filter=None, |
1729 | with_file_chooser=False): |
1730 | """Displays an open dialog. |
1731 | @@ -294,6 +303,7 @@ |
1732 | filechooser.destroy() |
1733 | return |
1734 | |
1735 | + |
1736 | def selectfolder(title='', parent=None, folder=None): |
1737 | """Displays a select folder dialog. |
1738 | :param title: the title of the folder, defaults to 'Select folder' |
1739 | @@ -332,6 +342,7 @@ |
1740 | filechooser.destroy() |
1741 | return |
1742 | |
1743 | + |
1744 | def ask_overwrite(filename, parent=None): |
1745 | submsg1 = _('A file named "%s" already exists') % os.path.abspath(filename) |
1746 | submsg2 = _('Do you wish to replace it with the current one?') |
1747 | @@ -344,6 +355,7 @@ |
1748 | gtk.RESPONSE_YES))) |
1749 | return result == gtk.RESPONSE_YES |
1750 | |
1751 | + |
1752 | def save(title='', parent=None, current_name='', folder=None): |
1753 | """Displays a save dialog.""" |
1754 | filechooser = gtk.FileChooserDialog(title or _('Save'), |
1755 | @@ -374,6 +386,7 @@ |
1756 | filechooser.destroy() |
1757 | return path |
1758 | |
1759 | + |
1760 | def password(primary='', secondary='', parent=None): |
1761 | """ |
1762 | Shows a password dialog and returns the password entered in the dialog |
1763 | @@ -424,6 +437,7 @@ |
1764 | d.destroy() |
1765 | return password |
1766 | |
1767 | + |
1768 | def _test(): |
1769 | yesno('Kill?', default=gtk.RESPONSE_NO) |
1770 | |
1771 | |
1772 | === modified file 'kiwi/ui/entry.py' |
1773 | --- kiwi/ui/entry.py 2012-02-10 19:37:37 +0000 |
1774 | +++ kiwi/ui/entry.py 2012-05-04 16:37:18 +0000 |
1775 | @@ -134,10 +134,10 @@ |
1776 | # C - Alpha, optional |
1777 | |
1778 | INPUT_CHAR_MAP = { |
1779 | - INPUT_ASCII_LETTER: lambda text: text in string.ascii_letters, |
1780 | - INPUT_ALPHA: unicode.isalpha, |
1781 | - INPUT_ALPHANUMERIC: unicode.isalnum, |
1782 | - INPUT_DIGIT: unicode.isdigit, |
1783 | + INPUT_ASCII_LETTER: lambda text: text in string.ascii_letters, |
1784 | + INPUT_ALPHA: unicode.isalpha, |
1785 | + INPUT_ALPHANUMERIC: unicode.isalnum, |
1786 | + INPUT_DIGIT: unicode.isdigit, |
1787 | } |
1788 | |
1789 | |
1790 | @@ -150,6 +150,7 @@ |
1791 | |
1792 | _ = lambda msg: gettext.dgettext('kiwi', msg) |
1793 | |
1794 | + |
1795 | class KiwiEntry(gtk.Entry): |
1796 | """ |
1797 | The KiwiEntry is a Entry subclass with the following additions: |
1798 | @@ -235,7 +236,7 @@ |
1799 | try: |
1800 | self.set_mask(value) |
1801 | return self.get_mask() |
1802 | - except MaskError, e: |
1803 | + except MaskError: |
1804 | pass |
1805 | mask = gobject.property(getter=_get_mask, |
1806 | setter=_set_mask, |
1807 | @@ -265,7 +266,6 @@ |
1808 | |
1809 | self._really_delete_text(0, -1) |
1810 | if not self._mask: |
1811 | - new_text = text |
1812 | self._really_insert_text(text, 0) |
1813 | return |
1814 | |
1815 | @@ -292,7 +292,7 @@ |
1816 | to_insert[pos] = t |
1817 | |
1818 | self._really_insert_text(''.join(to_insert), 0) |
1819 | - self.set_position(pos+1) |
1820 | + self.set_position(pos + 1) |
1821 | |
1822 | # Mask & Fields |
1823 | |
1824 | @@ -327,7 +327,6 @@ |
1825 | |
1826 | mask = unicode(mask) |
1827 | input_length = len(mask) |
1828 | - lenght = 0 |
1829 | pos = 0 |
1830 | field_begin = 0 |
1831 | field_end = 0 |
1832 | @@ -429,7 +428,7 @@ |
1833 | def _get_field_ideal_pos(self, field): |
1834 | start, end = self._mask_fields[field] |
1835 | text = self.get_field_text(field) |
1836 | - pos = start+len(text) |
1837 | + pos = start + len(text) |
1838 | return pos |
1839 | |
1840 | def get_field(self): |
1841 | @@ -446,7 +445,6 @@ |
1842 | self.set_position(pos) |
1843 | |
1844 | if select: |
1845 | - field_text = self.get_field_text(field) |
1846 | start, end = self._mask_fields[field] |
1847 | self.select_region(start, pos) |
1848 | |
1849 | @@ -492,7 +490,7 @@ |
1850 | # Otherwise, when shifting right, the char will be |
1851 | # prepended. |
1852 | next_pos = self._get_next_non_static_char_pos(i, direction, |
1853 | - positions-1) |
1854 | + positions - 1) |
1855 | |
1856 | # If its outside the bounds of the region, ignore it. |
1857 | if not start <= next_pos <= end: |
1858 | @@ -512,9 +510,9 @@ |
1859 | else: |
1860 | # Keep the static char where it is. |
1861 | if direction == Direction.LEFT: |
1862 | - new_text = new_text + text[i] |
1863 | + new_text = new_text + text[i] |
1864 | else: |
1865 | - new_text = text[i] + new_text |
1866 | + new_text = text[i] + new_text |
1867 | i += direction |
1868 | |
1869 | return new_text |
1870 | @@ -528,7 +526,7 @@ |
1871 | """ |
1872 | text = self.get_text() |
1873 | validators = self._mask_validators |
1874 | - i = pos+direction+skip |
1875 | + i = pos + direction + skip |
1876 | while 0 <= i < len(text): |
1877 | if isinstance(validators[i], int): |
1878 | return i |
1879 | @@ -765,7 +763,7 @@ |
1880 | # position after that static char. |
1881 | if (self._confirms_to_mask(pos, new) and |
1882 | not isinstance(validators[pos], int)): |
1883 | - return pos+1 |
1884 | + return pos + 1 |
1885 | |
1886 | # If does not confirms to mask: |
1887 | # - Check if the char the user just tried to enter appers later. |
1888 | @@ -773,7 +771,7 @@ |
1889 | if not self._confirms_to_mask(pos, new): |
1890 | field = self._appers_later(new, pos) |
1891 | if field is not False: |
1892 | - pos = self.get_field_pos(field+1) |
1893 | + pos = self.get_field_pos(field + 1) |
1894 | if pos is not None: |
1895 | gobject.idle_add(self.set_position, pos) |
1896 | return pos |
1897 | @@ -793,7 +791,6 @@ |
1898 | and the new text. |
1899 | """ |
1900 | field = self._get_field_at_pos(pos) |
1901 | - length = len(new) |
1902 | new_pos = pos |
1903 | start, end = self._mask_fields[field] |
1904 | |
1905 | @@ -803,16 +800,17 @@ |
1906 | text[end:]) |
1907 | |
1908 | # Overwrite Right |
1909 | -# new_text = (text[:pos] + new + |
1910 | -# text[pos+length:end]+ |
1911 | -# text[end:]) |
1912 | - new_pos = pos+1 |
1913 | + #length = len(new) |
1914 | + #new_text = (text[:pos] + new + |
1915 | + # text[pos+length:end]+ |
1916 | + # text[end:]) |
1917 | + new_pos = pos + 1 |
1918 | gobject.idle_add(self.set_position, new_pos) |
1919 | |
1920 | # If the field is full, jump to the next field |
1921 | - if len(self.get_field_text(field)) == self.get_field_length(field)-1: |
1922 | - gobject.idle_add(self.set_field, field+1, True) |
1923 | - self.set_field(field+1) |
1924 | + if len(self.get_field_text(field)) == self.get_field_length(field) - 1: |
1925 | + gobject.idle_add(self.set_field, field + 1, True) |
1926 | + self.set_field(field + 1) |
1927 | |
1928 | return new_pos, new_text |
1929 | |
1930 | @@ -830,8 +828,8 @@ |
1931 | else: |
1932 | self._icon_pos = gtk.POS_LEFT |
1933 | |
1934 | - |
1935 | # Callbacks |
1936 | + |
1937 | def _on_insert_text(self, editable, new, length, position): |
1938 | if not self._mask or self._block_insert: |
1939 | return |
1940 | @@ -867,16 +865,16 @@ |
1941 | if (0 < start < len(self._mask_validators) |
1942 | and not isinstance(self._mask_validators[start], int) |
1943 | and pos != start): |
1944 | - self._on_delete_text(editable, start-1, start) |
1945 | + self._on_delete_text(editable, start - 1, start) |
1946 | return |
1947 | |
1948 | # we just tried to delete, stop the selection. |
1949 | self._selecting = False |
1950 | |
1951 | - field = self._get_field_at_pos(end-1) |
1952 | + field = self._get_field_at_pos(end - 1) |
1953 | # Outside a field. Cannot delete. |
1954 | if field is None: |
1955 | - self.set_position(end-1) |
1956 | + self.set_position(end - 1) |
1957 | return |
1958 | _start, _end = self._mask_fields[field] |
1959 | |
1960 | @@ -890,16 +888,16 @@ |
1961 | # Shift Left |
1962 | new_text = (text[:start] + |
1963 | self._shift_text(start, _end, Direction.LEFT, |
1964 | - end-start) + |
1965 | + end - start) + |
1966 | text[_end:]) |
1967 | |
1968 | # Overwrite Left |
1969 | -# empty_mask = self.get_empty_mask() |
1970 | -# new_text = (text[:_start] + |
1971 | -# text[_start:start] + |
1972 | -# empty_mask[start:start+(end-start)] + |
1973 | -# text[start+(end-start):_end] + |
1974 | -# text[_end:]) |
1975 | + #empty_mask = self.get_empty_mask() |
1976 | + #new_text = (text[:_start] + |
1977 | + # text[_start:start] + |
1978 | + # empty_mask[start:start+(end-start)] + |
1979 | + # text[start+(end-start):_end] + |
1980 | + # text[_end:]) |
1981 | |
1982 | new_pos = start |
1983 | |
1984 | @@ -942,7 +940,7 @@ |
1985 | return False |
1986 | |
1987 | if field < 0: |
1988 | - field = len(self._mask_fields)-1 |
1989 | + field = len(self._mask_fields) - 1 |
1990 | |
1991 | # grab_focus changes the selection, so we need to grab_focus before |
1992 | # making the selection. |
1993 | @@ -1153,9 +1151,11 @@ |
1994 | |
1995 | type_register(KiwiEntry) |
1996 | |
1997 | + |
1998 | def main(args): |
1999 | win = gtk.Window() |
2000 | win.set_title('gtk.Entry subclass') |
2001 | + |
2002 | def cb(window, event): |
2003 | print 'fields', widget.get_field_text() |
2004 | gtk.main_quit() |
2005 | |
2006 | === modified file 'kiwi/ui/entrycompletion.py' |
2007 | --- kiwi/ui/entrycompletion.py 2012-03-15 17:58:30 +0000 |
2008 | +++ kiwi/ui/entrycompletion.py 2012-05-04 16:37:18 +0000 |
2009 | @@ -31,6 +31,7 @@ |
2010 | COMPLETION_TIMEOUT = 300 |
2011 | PAGE_INCREMENT = 14 |
2012 | |
2013 | + |
2014 | class KiwiEntryCompletion(gtk.EntryCompletion): |
2015 | def __init__(self): |
2016 | gtk.EntryCompletion.__init__(self) |
2017 | @@ -51,6 +52,7 @@ |
2018 | self._selected_index = -1 |
2019 | |
2020 | gsignal('match-selected', 'override') |
2021 | + |
2022 | def do_match_selected(self, model, iter): |
2023 | self._entry.set_text(model[iter][0]) |
2024 | return True |
2025 | @@ -149,14 +151,14 @@ |
2026 | if keyval == keysyms.Up or keyval == keysyms.KP_Up: |
2027 | index -= 1 |
2028 | if index < -1: |
2029 | - index = matches -1 |
2030 | + index = matches - 1 |
2031 | |
2032 | self._select_item(index) |
2033 | return True |
2034 | |
2035 | elif keyval == keysyms.Down or keyval == keysyms.KP_Down: |
2036 | index += 1 |
2037 | - if index > matches-1: |
2038 | + if index > matches - 1: |
2039 | index = -1 |
2040 | |
2041 | self._select_item(index) |
2042 | @@ -164,7 +166,7 @@ |
2043 | |
2044 | elif keyval == keysyms.Page_Up: |
2045 | if index < 0: |
2046 | - index = matches-1 |
2047 | + index = matches - 1 |
2048 | elif index > 0 and index - PAGE_INCREMENT < 0: |
2049 | index = 0 |
2050 | else: |
2051 | @@ -179,8 +181,8 @@ |
2052 | elif keyval == keysyms.Page_Down: |
2053 | if index < 0: |
2054 | index = 0 |
2055 | - elif index < matches-1 and index + PAGE_INCREMENT > matches - 1: |
2056 | - index = matches -1 |
2057 | + elif index < matches - 1 and index + PAGE_INCREMENT > matches - 1: |
2058 | + index = matches - 1 |
2059 | else: |
2060 | index += PAGE_INCREMENT |
2061 | |
2062 | @@ -221,7 +223,7 @@ |
2063 | if gdk.keyboard_grab(window, True, activate_time) == 0: |
2064 | return True |
2065 | else: |
2066 | - window.get_display().pointer_ungrab(activate_time); |
2067 | + window.get_display().pointer_ungrab(activate_time) |
2068 | return False |
2069 | return False |
2070 | |
2071 | @@ -240,7 +242,7 @@ |
2072 | self._filter_model.refilter() |
2073 | self._treeview.set_model(self._filter_model) |
2074 | if self._treeview.flags() & gtk.REALIZED: |
2075 | - self._treeview.scroll_to_point(0,0) |
2076 | + self._treeview.scroll_to_point(0, 0) |
2077 | |
2078 | def set_entry(self, entry): |
2079 | self._entry = entry |
2080 | |
2081 | === modified file 'kiwi/ui/gadgets.py' |
2082 | --- kiwi/ui/gadgets.py 2012-02-21 14:01:42 +0000 |
2083 | +++ kiwi/ui/gadgets.py 2012-05-04 16:37:18 +0000 |
2084 | @@ -37,12 +37,14 @@ |
2085 | from kiwi.utils import gsignal, type_register |
2086 | from kiwi.ui.pixbufutils import pixbuf_from_string |
2087 | |
2088 | + |
2089 | def gdk_color_to_string(color): |
2090 | """Convert a color to a #AABBCC string""" |
2091 | return "#%02X%02X%02X" % (int(color.red) >> 8, |
2092 | int(color.green) >> 8, |
2093 | int(color.blue) >> 8) |
2094 | |
2095 | + |
2096 | def set_foreground(widget, color, state=gtk.STATE_NORMAL): |
2097 | """ |
2098 | Set the foreground color of a widget: |
2099 | @@ -53,12 +55,14 @@ |
2100 | """ |
2101 | widget.modify_fg(state, gdk.color_parse(color)) |
2102 | |
2103 | + |
2104 | def get_foreground(widget, state=gtk.STATE_NORMAL): |
2105 | """Return the foreground color of the widget as a string""" |
2106 | style = widget.get_style() |
2107 | color = style.fg[state] |
2108 | return gdk_color_to_string(color) |
2109 | |
2110 | + |
2111 | def set_background(widget, color, state=gtk.STATE_NORMAL): |
2112 | """ |
2113 | Set the background color of a widget: |
2114 | @@ -72,12 +76,14 @@ |
2115 | else: |
2116 | widget.modify_bg(state, gdk.color_parse(color)) |
2117 | |
2118 | + |
2119 | def get_background(widget, state=gtk.STATE_NORMAL): |
2120 | """Return the background color of the widget as a string""" |
2121 | style = widget.get_style() |
2122 | color = style.bg[state] |
2123 | return gdk_color_to_string(color) |
2124 | |
2125 | + |
2126 | def quit_if_last(*args): |
2127 | windows = [toplevel |
2128 | for toplevel in gtk.window_list_toplevels() |
2129 | @@ -85,14 +91,17 @@ |
2130 | if len(windows) == 1: |
2131 | gtk.main_quit() |
2132 | |
2133 | + |
2134 | def _select_notebook_tab(widget, event, notebook): |
2135 | val = event.keyval - 48 |
2136 | if event.state & gdk.MOD1_MASK and 1 <= val <= 9: |
2137 | - notebook.set_current_page(val-1) |
2138 | + notebook.set_current_page(val - 1) |
2139 | + |
2140 | |
2141 | def register_notebook_shortcuts(dialog, notebook): |
2142 | dialog.toplevel.connect('key-press-event', _select_notebook_tab, notebook) |
2143 | |
2144 | + |
2145 | class FadeOut(gobject.GObject): |
2146 | """I am a helper class to draw the fading effect of the background |
2147 | Call my methods start() and stop() to control the fading. |
2148 | @@ -199,6 +208,7 @@ |
2149 | |
2150 | _pixbuf_cache = {} |
2151 | |
2152 | + |
2153 | # Based on code from BillReminder by Og Maciel and |
2154 | # http://cairographics.org/cookbook/roundedrectangles/ |
2155 | |
2156 | |
2157 | === modified file 'kiwi/ui/gaxmlloader.py' |
2158 | --- kiwi/ui/gaxmlloader.py 2007-05-29 14:16:15 +0000 |
2159 | +++ kiwi/ui/gaxmlloader.py 2012-05-04 16:37:18 +0000 |
2160 | @@ -27,6 +27,7 @@ |
2161 | |
2162 | log = Logger('gaxmlparser') |
2163 | |
2164 | + |
2165 | class GAXMLWidgetTree(object): |
2166 | def __init__(self, view, gladefile, domain=None): |
2167 | self._view = view |
2168 | |
2169 | === modified file 'kiwi/ui/hyperlink.py' |
2170 | --- kiwi/ui/hyperlink.py 2012-02-10 19:37:37 +0000 |
2171 | +++ kiwi/ui/hyperlink.py 2012-05-04 16:37:18 +0000 |
2172 | @@ -34,6 +34,7 @@ |
2173 | |
2174 | import gobject |
2175 | |
2176 | + |
2177 | class HyperLink(gtk.EventBox): |
2178 | __gtype_name__ = 'HyperLink' |
2179 | """ |
2180 | |
2181 | === modified file 'kiwi/ui/libgladeloader.py' |
2182 | --- kiwi/ui/libgladeloader.py 2006-09-11 17:11:15 +0000 |
2183 | +++ kiwi/ui/libgladeloader.py 2012-05-04 16:37:18 +0000 |
2184 | @@ -27,6 +27,7 @@ |
2185 | |
2186 | log = Logger('libgladeloader') |
2187 | |
2188 | + |
2189 | class LibgladeWidgetTree(XML): |
2190 | def __init__(self, view, gladefile, domain=None): |
2191 | self._view = view |
2192 | |
2193 | === modified file 'kiwi/ui/objectlist.py' |
2194 | --- kiwi/ui/objectlist.py 2012-03-29 18:02:10 +0000 |
2195 | +++ kiwi/ui/objectlist.py 2012-05-04 16:37:18 +0000 |
2196 | @@ -49,12 +49,14 @@ |
2197 | |
2198 | log = Logger('objectlist') |
2199 | |
2200 | + |
2201 | def str2enum(value_name, enum_class): |
2202 | "converts a string to a enum" |
2203 | for _, _enum in enum_class.__enum_values__.items(): |
2204 | if value_name in (_enum.value_name, _enum.value_nick): |
2205 | return _enum |
2206 | |
2207 | + |
2208 | def str2bool(value, from_string=converter.from_string): |
2209 | "converts a boolean to a enum" |
2210 | return from_string(bool, value) |
2211 | @@ -162,7 +164,7 @@ |
2212 | visible = gobject.property(type=bool, default=True) |
2213 | justify = gobject.property(type=gtk.Justification, default=gtk.JUSTIFY_LEFT) |
2214 | format = gobject.property(type=str) |
2215 | - width = gobject.property(type=int, maximum=2**16) |
2216 | + width = gobject.property(type=int, maximum=2 ** 16) |
2217 | sorted = gobject.property(type=bool, default=False) |
2218 | order = gobject.property(type=gtk.SortType, default=gtk.SORT_ASCENDING) |
2219 | expand = gobject.property(type=bool, default=False) |
2220 | @@ -664,7 +666,6 @@ |
2221 | renderer.set_property('digits', digits) |
2222 | |
2223 | |
2224 | - |
2225 | class SequentialColumn(Column): |
2226 | """I am a column which will display a sequence of numbers, which |
2227 | represent the row number. The value is independent of the data in |
2228 | @@ -696,6 +697,7 @@ |
2229 | raise TypeError("%r does not support parameter %s" % |
2230 | (renderer, renderer_prop)) |
2231 | |
2232 | + |
2233 | class SearchColumn(Column): |
2234 | """ |
2235 | I am a column that should be used in conjunction with |
2236 | @@ -725,7 +727,6 @@ |
2237 | Column.__init__(self, attribute, title, data_type, **kwargs) |
2238 | |
2239 | |
2240 | - |
2241 | class ColoredColumn(Column): |
2242 | """ |
2243 | I am a column which can colorize the text of columns under |
2244 | @@ -779,6 +780,7 @@ |
2245 | |
2246 | renderer.set_property('foreground-gdk', color) |
2247 | |
2248 | + |
2249 | class _ContextMenu(gtk.Menu): |
2250 | |
2251 | """ |
2252 | @@ -868,6 +870,7 @@ |
2253 | |
2254 | _marker = object() |
2255 | |
2256 | + |
2257 | class ObjectList(gtk.HBox): |
2258 | """ |
2259 | An enhanced version of GtkTreeView, which provides pythonic wrappers |
2260 | @@ -1230,7 +1233,6 @@ |
2261 | default=gtk.SELECTION_BROWSE, |
2262 | nick="SelectionMode") |
2263 | |
2264 | - |
2265 | # Columns handling |
2266 | |
2267 | def _load(self, instances, clear): |
2268 | @@ -1498,7 +1500,6 @@ |
2269 | if item: |
2270 | self.emit('double-click', item) |
2271 | |
2272 | - |
2273 | def _on_treeview__source_drag_data_get(self, treeview, context, |
2274 | selection, info, timestamp): |
2275 | item = self.get_selected() |
2276 | @@ -1696,7 +1697,6 @@ |
2277 | if not objid in self._iters: |
2278 | raise ValueError("instance %r is not in the list" % instance) |
2279 | |
2280 | - |
2281 | if select: |
2282 | prev = self.get_previous(instance) |
2283 | rv = self._remove(objid) |
2284 | @@ -2236,6 +2236,7 @@ |
2285 | |
2286 | type_register(ObjectTree) |
2287 | |
2288 | + |
2289 | class ListLabel(gtk.HBox): |
2290 | """I am a subclass of a GtkHBox which you can use if you want |
2291 | to vertically align a label with a column |
2292 | |
2293 | === modified file 'kiwi/ui/pixbufutils.py' |
2294 | --- kiwi/ui/pixbufutils.py 2012-02-24 16:19:39 +0000 |
2295 | +++ kiwi/ui/pixbufutils.py 2012-05-04 16:37:18 +0000 |
2296 | @@ -21,9 +21,9 @@ |
2297 | # Author(s): Johan Dahlin <jdahlin@async.com.br> |
2298 | # |
2299 | |
2300 | - |
2301 | from gtk import gdk |
2302 | |
2303 | + |
2304 | def pixbuf_from_string(pixbuf_data, format='png', width=None, height=None): |
2305 | loader = gdk.PixbufLoader(format) |
2306 | loader.write(pixbuf_data) |
2307 | |
2308 | === modified file 'kiwi/ui/proxy.py' |
2309 | --- kiwi/ui/proxy.py 2012-02-10 19:37:37 +0000 |
2310 | +++ kiwi/ui/proxy.py 2012-05-04 16:37:18 +0000 |
2311 | @@ -38,10 +38,12 @@ |
2312 | from kiwi.interfaces import IProxyWidget, IValidatableProxyWidget |
2313 | from kiwi.log import Logger |
2314 | |
2315 | +log = Logger('proxy') |
2316 | + |
2317 | + |
2318 | class ProxyError(Exception): |
2319 | pass |
2320 | |
2321 | -log = Logger('proxy') |
2322 | |
2323 | def block_widget(widget): |
2324 | """Blocks the signal handler of the 'content-changed' signal on widget""" |
2325 | @@ -49,17 +51,20 @@ |
2326 | if connection_id: |
2327 | widget.handler_block(connection_id) |
2328 | |
2329 | + |
2330 | def unblock_widget(widget): |
2331 | """Unblocks the signal handler of the 'content-changed' signal on widget""" |
2332 | connection_id = widget.get_data('content-changed-id') |
2333 | if connection_id: |
2334 | widget.handler_unblock(connection_id) |
2335 | |
2336 | + |
2337 | def _get_widget_data_type(widget): |
2338 | data_type = widget.get_property('data-type') |
2339 | c = converter.get_converter(data_type) |
2340 | return c.type |
2341 | |
2342 | + |
2343 | class Proxy: |
2344 | """ A Proxy is a class that 'attaches' an instance to an interface's |
2345 | widgets, and transparently manipulates that instance's attributes as |
2346 | @@ -301,7 +306,6 @@ |
2347 | % (attribute, self, |
2348 | self._model_attributes.keys())) |
2349 | |
2350 | - |
2351 | # The type of value should match the data-type property. The two |
2352 | # exceptions to this rule are ValueUnset and None |
2353 | if not (value is ValueUnset or value is None): |
2354 | @@ -392,4 +396,3 @@ |
2355 | def new_model(self, model, relax_type=False): |
2356 | self.set_model(model) |
2357 | new_model = deprecated('set_model', log)(new_model) |
2358 | - |
2359 | |
2360 | === modified file 'kiwi/ui/proxywidget.py' |
2361 | --- kiwi/ui/proxywidget.py 2012-05-02 14:43:32 +0000 |
2362 | +++ kiwi/ui/proxywidget.py 2012-05-04 16:37:18 +0000 |
2363 | @@ -46,6 +46,7 @@ |
2364 | |
2365 | _ = lambda m: gettext.dgettext('kiwi', m) |
2366 | |
2367 | + |
2368 | class _PixbufConverter(BaseConverter): |
2369 | type = gdk.Pixbuf |
2370 | name = 'Pixbuf' |
2371 | @@ -161,7 +162,7 @@ |
2372 | conv = converter.get_converter(str) |
2373 | |
2374 | return conv.as_string(data, format=self._data_format, |
2375 | - **self._converter_options.get(conv.type,{})) |
2376 | + **self._converter_options.get(conv.type, {})) |
2377 | |
2378 | def _from_string(self, data): |
2379 | """Convert a string to the data type of the widget |
2380 | @@ -190,6 +191,7 @@ |
2381 | |
2382 | _error_icon = None |
2383 | |
2384 | + |
2385 | def _load_error_icon(): |
2386 | global _error_icon |
2387 | if _error_icon is None: |
2388 | |
2389 | === modified file 'kiwi/ui/search.py' |
2390 | --- kiwi/ui/search.py 2012-04-10 19:23:10 +0000 |
2391 | +++ kiwi/ui/search.py 2012-05-04 16:37:18 +0000 |
2392 | @@ -73,6 +73,7 @@ |
2393 | :rtype: datetime.date tuple |
2394 | """ |
2395 | |
2396 | + |
2397 | class Any(DateSearchOption): |
2398 | name = _('Any') |
2399 | |
2400 | @@ -160,6 +161,7 @@ |
2401 | :returns: start, end |
2402 | """ |
2403 | |
2404 | + |
2405 | class Between(NumberSearchOption): |
2406 | name = _('Between') |
2407 | numbers = 2 |
2408 | @@ -285,6 +287,7 @@ |
2409 | Can be customized through add_option. |
2410 | """ |
2411 | __gtype_name__ = 'DateSearchFilter' |
2412 | + |
2413 | class Type(enum): |
2414 | (USER_DAY, |
2415 | USER_INTERVAL) = range(100, 102) |
2416 | @@ -366,7 +369,7 @@ |
2417 | _(u'to'), end_date.strftime('%x'),) |
2418 | |
2419 | else: |
2420 | - desc += start_date.strftime('%x') |
2421 | + desc += start_date.strftime('%x') |
2422 | if desc: |
2423 | return '%s %s' % (self.get_title_label().get_text(), desc,) |
2424 | |
2425 | @@ -404,7 +407,6 @@ |
2426 | dict(name=name, date=date)) |
2427 | self.add_option(option_type, position=position) |
2428 | |
2429 | - |
2430 | def add_option_fixed_interval(self, name, start, end, position=-2): |
2431 | """ |
2432 | Adds a fixed option interval, eg one for which the dates are not |
2433 | @@ -732,6 +734,7 @@ |
2434 | |
2435 | gobject.type_register(HintedEntry) |
2436 | |
2437 | + |
2438 | class StringSearchFilter(SearchFilter): |
2439 | """ |
2440 | - a label |
2441 | @@ -879,7 +882,7 @@ |
2442 | |
2443 | self.start = gtk.SpinButton(climb_rate=1.0) |
2444 | self.start.get_adjustment().step_increment = 1.0 |
2445 | - self.start.set_range(-sys.maxint-1, sys.maxint) |
2446 | + self.start.set_range(-sys.maxint - 1, sys.maxint) |
2447 | self.pack_start(self.start, False, False, 6) |
2448 | self.start.show() |
2449 | self.start.connect_after('activate', self._on_entry__activate) |
2450 | @@ -890,7 +893,7 @@ |
2451 | |
2452 | self.end = gtk.SpinButton(climb_rate=1.0) |
2453 | self.end.get_adjustment().step_increment = 1.0 |
2454 | - self.end.set_range(-sys.maxint-1, sys.maxint) |
2455 | + self.end.set_range(-sys.maxint - 1, sys.maxint) |
2456 | self.pack_start(self.end, False, False, 6) |
2457 | self.end.show() |
2458 | self.end.connect_after('activate', self._on_entry__activate) |
2459 | @@ -928,7 +931,6 @@ |
2460 | self.and_label.show() |
2461 | self.end.show() |
2462 | |
2463 | - |
2464 | # |
2465 | # Callbacks |
2466 | # |
2467 | @@ -1085,7 +1087,6 @@ |
2468 | |
2469 | self._create_ui() |
2470 | |
2471 | - |
2472 | # |
2473 | # GObject |
2474 | # |
2475 | @@ -1124,7 +1125,6 @@ |
2476 | else: |
2477 | raise AssertionError(pspec.name) |
2478 | |
2479 | - |
2480 | # |
2481 | # Public API |
2482 | # |
2483 | @@ -1138,7 +1138,6 @@ |
2484 | :param columns: |
2485 | :param callback: |
2486 | """ |
2487 | - |
2488 | if not isinstance(search_filter, SearchFilter): |
2489 | raise TypeError("search_filter must be a SearchFilter subclass, " |
2490 | "not %r" % (search_filter,)) |
2491 | @@ -1351,7 +1350,6 @@ |
2492 | continue |
2493 | search_filter.set_state(**filter_state) |
2494 | |
2495 | - |
2496 | # |
2497 | # Callbacks |
2498 | # |
2499 | |
2500 | === modified file 'kiwi/ui/test/common.py' |
2501 | --- kiwi/ui/test/common.py 2012-03-13 20:18:46 +0000 |
2502 | +++ kiwi/ui/test/common.py 2012-05-04 16:37:18 +0000 |
2503 | @@ -41,6 +41,7 @@ |
2504 | except ImportError: |
2505 | event_handler_set = None |
2506 | |
2507 | + |
2508 | class WidgetIntrospecter(gobject.GObject): |
2509 | gsignal('window-added', object, str, object) |
2510 | gsignal('window-removed', object, str) |
2511 | |
2512 | === modified file 'kiwi/ui/test/main.py' |
2513 | --- kiwi/ui/test/main.py 2006-11-21 16:21:07 +0000 |
2514 | +++ kiwi/ui/test/main.py 2012-05-04 16:37:18 +0000 |
2515 | @@ -27,17 +27,20 @@ |
2516 | |
2517 | from kiwi.log import set_log_level |
2518 | |
2519 | + |
2520 | def _play(options, filename, args): |
2521 | from kiwi.ui.test.runner import play_file |
2522 | |
2523 | play_file(filename, options.command, args) |
2524 | |
2525 | + |
2526 | def _record(options, filename, args): |
2527 | from kiwi.ui.test.recorder import Recorder |
2528 | |
2529 | recorder = Recorder(filename) |
2530 | recorder.execute(args) |
2531 | |
2532 | + |
2533 | def main(args): |
2534 | parser = optparse.OptionParser() |
2535 | parser.add_option('', '--command', action="store", |
2536 | |
2537 | === modified file 'kiwi/ui/test/recorder.py' |
2538 | --- kiwi/ui/test/recorder.py 2012-04-10 18:14:36 +0000 |
2539 | +++ kiwi/ui/test/recorder.py 2012-05-04 16:37:18 +0000 |
2540 | @@ -59,6 +59,7 @@ |
2541 | |
2542 | log = Logger('recorder') |
2543 | |
2544 | + |
2545 | def register_event_type(event_type): |
2546 | """ |
2547 | Add an event type to a list of event types. |
2548 | @@ -69,6 +70,7 @@ |
2549 | raise AssertionError("event %s already registered" % event_type) |
2550 | _events.append(event_type) |
2551 | |
2552 | + |
2553 | def get_event_types(): |
2554 | """ |
2555 | Returns the collection of event types. |
2556 | @@ -76,9 +78,11 @@ |
2557 | """ |
2558 | return _events |
2559 | |
2560 | + |
2561 | class SkipEvent(Exception): |
2562 | pass |
2563 | |
2564 | + |
2565 | class Event(object): |
2566 | """ |
2567 | Event is a base class for all events. |
2568 | @@ -87,6 +91,7 @@ |
2569 | automatically attach events to objects when they appear |
2570 | """ |
2571 | object_type = None |
2572 | + |
2573 | def __init__(self, object, name=None): |
2574 | """ |
2575 | Create a new Event object. |
2576 | @@ -125,6 +130,7 @@ |
2577 | """ |
2578 | pass |
2579 | |
2580 | + |
2581 | class SignalEvent(Event): |
2582 | """ |
2583 | A SignalEvent is an :class:`Event` which is tied to a GObject signal, |
2584 | @@ -134,6 +140,7 @@ |
2585 | :cvar signal_name: signal to listen to |
2586 | """ |
2587 | signal_name = None |
2588 | + |
2589 | def __init__(self, object, name, args): |
2590 | """ |
2591 | Create a new SignalEvent object. |
2592 | @@ -155,6 +162,7 @@ |
2593 | """ |
2594 | object.connect(signal_name, cb, cls, object) |
2595 | |
2596 | + |
2597 | # |
2598 | # Special Events |
2599 | # |
2600 | @@ -165,6 +173,7 @@ |
2601 | window manager. |
2602 | """ |
2603 | |
2604 | + |
2605 | # |
2606 | # Signal Events |
2607 | # |
2608 | @@ -179,8 +188,10 @@ |
2609 | |
2610 | def serialize(self): |
2611 | return '%s.activate()' % self.name |
2612 | + |
2613 | register_event_type(MenuItemActivateEvent) |
2614 | |
2615 | + |
2616 | class ImageMenuItemButtonReleaseEvent(SignalEvent): |
2617 | """ |
2618 | This event represents a click on a normal menu entry |
2619 | @@ -204,8 +215,10 @@ |
2620 | |
2621 | def serialize(self): |
2622 | return '%s.activate()' % self.name |
2623 | + |
2624 | register_event_type(ImageMenuItemButtonReleaseEvent) |
2625 | |
2626 | + |
2627 | class ToolButtonReleaseEvent(SignalEvent): |
2628 | """ |
2629 | This event represents a click on a normal toolbar button |
2630 | @@ -216,8 +229,10 @@ |
2631 | |
2632 | def serialize(self): |
2633 | return '%s.activate()' % self.name |
2634 | + |
2635 | register_event_type(ToolButtonReleaseEvent) |
2636 | |
2637 | + |
2638 | class EntrySetTextEvent(SignalEvent): |
2639 | """ |
2640 | This event represents a content modification of a GtkEntry. |
2641 | @@ -233,8 +248,10 @@ |
2642 | |
2643 | def serialize(self): |
2644 | return '%s.set_text("%s")' % (self.name, self.text) |
2645 | + |
2646 | register_event_type(EntrySetTextEvent) |
2647 | |
2648 | + |
2649 | class EntryActivateEvent(SignalEvent): |
2650 | """ |
2651 | This event represents an activate event for a GtkEntry, eg when |
2652 | @@ -246,8 +263,10 @@ |
2653 | |
2654 | def serialize(self): |
2655 | return '%s.activate()' % (self.name) |
2656 | + |
2657 | register_event_type(EntryActivateEvent) |
2658 | |
2659 | + |
2660 | # Also works for Toggle, Radio and Check |
2661 | class ButtonClickedEvent(SignalEvent): |
2662 | """ |
2663 | @@ -260,8 +279,10 @@ |
2664 | |
2665 | def serialize(self): |
2666 | return '%s.clicked()' % self.name |
2667 | + |
2668 | register_event_type(ButtonClickedEvent) |
2669 | |
2670 | + |
2671 | # Kiwi widget support |
2672 | class ObjectListSelectionChanged(SignalEvent): |
2673 | """ |
2674 | @@ -272,6 +293,7 @@ |
2675 | """ |
2676 | object_type = ObjectList |
2677 | signal_name = 'changed' |
2678 | + |
2679 | def __init__(self, objectlist, name, args): |
2680 | self._objectlist = objectlist |
2681 | SignalEvent.__init__(self, objectlist, name=objectlist.get_name(), |
2682 | @@ -305,8 +327,10 @@ |
2683 | |
2684 | def serialize(self): |
2685 | return '%s.select_paths(%s)' % (self.name, self.rows) |
2686 | + |
2687 | register_event_type(ObjectListSelectionChanged) |
2688 | |
2689 | + |
2690 | class ObjectListDoubleClick(SignalEvent): |
2691 | """ |
2692 | This event represents a double click on a row in objectlist |
2693 | @@ -350,6 +374,7 @@ |
2694 | |
2695 | # register_event_type(KiwiComboBoxChangedEvent) |
2696 | |
2697 | + |
2698 | class Recorder(WidgetIntrospecter): |
2699 | """ |
2700 | Recorder takes care of attaching events to widgets, when the appear, |
2701 | |
2702 | === modified file 'kiwi/ui/test/runner.py' |
2703 | --- kiwi/ui/test/runner.py 2012-02-10 19:37:37 +0000 |
2704 | +++ kiwi/ui/test/runner.py 2012-05-04 16:37:18 +0000 |
2705 | @@ -39,12 +39,15 @@ |
2706 | |
2707 | log = Logger('kiwi.ui.test.player') |
2708 | |
2709 | + |
2710 | class NotReadyYet(Exception): |
2711 | pass |
2712 | |
2713 | + |
2714 | class MissingWidget(KeyError): |
2715 | pass |
2716 | |
2717 | + |
2718 | class MagicWindowWrapper(object): |
2719 | def __init__(self, window, ns): |
2720 | self.window = window |
2721 | @@ -58,6 +61,7 @@ |
2722 | raise MissingWidget(attr) |
2723 | return self.ns[attr] |
2724 | |
2725 | + |
2726 | # Override some StringIO methods. |
2727 | class _SpoofOut(StringIO): |
2728 | def getvalue(self): |
2729 | @@ -73,11 +77,12 @@ |
2730 | del self.softspace |
2731 | return result |
2732 | |
2733 | - def truncate(self, size=None): |
2734 | + def truncate(self, size=None): |
2735 | StringIO.truncate(self, size) |
2736 | if hasattr(self, "softspace"): |
2737 | del self.softspace |
2738 | |
2739 | + |
2740 | class Runner(object): |
2741 | """ |
2742 | Create a new Runner object. |
2743 | @@ -228,6 +233,7 @@ |
2744 | |
2745 | runner = None |
2746 | |
2747 | + |
2748 | def play_file(script, filename=None, args=None): |
2749 | """ |
2750 | Run an script. |
2751 | @@ -249,7 +255,7 @@ |
2752 | # run: .... |
2753 | pos = data.find('run:') |
2754 | if pos != -1: |
2755 | - rest = data[pos+5:] |
2756 | + rest = data[pos + 5:] |
2757 | # run: foo --arg |
2758 | if ' ' in rest: |
2759 | filename, args = rest.split(' ', 1) |
2760 | |
2761 | === modified file 'kiwi/ui/tooltip.py' |
2762 | --- kiwi/ui/tooltip.py 2011-07-04 19:41:22 +0000 |
2763 | +++ kiwi/ui/tooltip.py 2012-05-04 16:37:18 +0000 |
2764 | @@ -31,6 +31,7 @@ |
2765 | DEFAULT_DELAY = 500 |
2766 | BORDER_WIDTH = 4 |
2767 | |
2768 | + |
2769 | class Tooltip(gtk.Window): |
2770 | def __init__(self, widget): |
2771 | gtk.Window.__init__(self, gtk.WINDOW_POPUP) |
2772 | @@ -69,7 +70,7 @@ |
2773 | monitor = screen.get_monitor_geometry(monitor_num) |
2774 | |
2775 | if (x + w) > monitor.x + monitor.width: |
2776 | - x -= (x + w) - (monitor.x + monitor.width); |
2777 | + x -= (x + w) - (monitor.x + monitor.width) |
2778 | elif x < monitor.x: |
2779 | x = monitor.x |
2780 | |
2781 | |
2782 | === modified file 'kiwi/ui/views.py' |
2783 | --- kiwi/ui/views.py 2012-04-26 19:12:42 +0000 |
2784 | +++ kiwi/ui/views.py 2012-05-04 16:37:18 +0000 |
2785 | @@ -87,6 +87,7 @@ |
2786 | |
2787 | method_regex = re.compile(r'^(on|after)_(\w+)__(\w+)$') |
2788 | |
2789 | + |
2790 | class SignalBroker(object): |
2791 | def __init__(self, view, controller): |
2792 | methods = controller._get_all_methods() |
2793 | @@ -136,7 +137,7 @@ |
2794 | signal_id = widget.connect_after(signal, methods[fname]) |
2795 | else: |
2796 | raise AssertionError |
2797 | - except TypeError, e: |
2798 | + except TypeError: |
2799 | raise TypeError("Widget %s doesn't provide a signal %s" % ( |
2800 | widget.__class__, signal)) |
2801 | self._autoconnected.setdefault(widget, []).append(( |
2802 | @@ -165,6 +166,7 @@ |
2803 | for signal in signals: |
2804 | widget.disconnect(signal[1]) |
2805 | |
2806 | + |
2807 | class GladeSignalBroker(SignalBroker): |
2808 | def _do_connections(self, view, methods): |
2809 | super(GladeSignalBroker, self)._do_connections(view, methods) |
2810 | @@ -477,7 +479,7 @@ |
2811 | |
2812 | if top_widget: |
2813 | allocation = widget.allocation |
2814 | - top_allocation = getattr(top_widget, 'allocation', None) |
2815 | + top_allocation = getattr(top_widget, 'allocation', None) |
2816 | assert top_allocation != None |
2817 | if (top_allocation[0] + top_allocation[1] > |
2818 | allocation[0] + allocation[1]): |
2819 | @@ -533,8 +535,8 @@ |
2820 | |
2821 | if name in self.slaves: |
2822 | # XXX: TypeError |
2823 | - log.warn("A slave with name %s is already attached to %r" % ( |
2824 | - name, self)) |
2825 | + log.warn("A slave with name %s is already attached to %r" % ( |
2826 | + name, self)) |
2827 | self.slaves[name] = slave |
2828 | |
2829 | if not isinstance(slave, SlaveView): |
2830 | @@ -681,8 +683,6 @@ |
2831 | def get_slave(self, holder): |
2832 | return self.slaves.get(holder) |
2833 | |
2834 | - |
2835 | - |
2836 | # |
2837 | # Signal connection |
2838 | # |
2839 | @@ -864,6 +864,7 @@ |
2840 | |
2841 | type_register(SlaveView) |
2842 | |
2843 | + |
2844 | class BaseView(SlaveView): |
2845 | """A view with a toplevel window.""" |
2846 | |
2847 | @@ -988,10 +989,12 @@ |
2848 | |
2849 | _glade_loader_func = None |
2850 | |
2851 | + |
2852 | def set_glade_loader_func(func): |
2853 | global _glade_loader_func |
2854 | _glade_loader_func = func |
2855 | |
2856 | + |
2857 | def _get_libglade(): |
2858 | try: |
2859 | from kiwi.ui.libgladeloader import LibgladeWidgetTree |
2860 | @@ -999,6 +1002,7 @@ |
2861 | return |
2862 | return LibgladeWidgetTree |
2863 | |
2864 | + |
2865 | def _get_gaxml(): |
2866 | try: |
2867 | from kiwi.ui.gaxmlloader import GAXMLWidgetTree |
2868 | @@ -1006,6 +1010,7 @@ |
2869 | return |
2870 | return GAXMLWidgetTree |
2871 | |
2872 | + |
2873 | def _get_builder(): |
2874 | try: |
2875 | from kiwi.ui.builderloader import BuilderWidgetTree |
2876 | @@ -1013,6 +1018,7 @@ |
2877 | return |
2878 | return BuilderWidgetTree |
2879 | |
2880 | + |
2881 | def _open_glade(view, gladefile, domain): |
2882 | if not gladefile: |
2883 | raise ValueError("A gladefile wasn't provided.") |
2884 | @@ -1033,7 +1039,6 @@ |
2885 | except EnvironmentError: |
2886 | gladefile = environ.find_resource("glade", filename + '.ui') |
2887 | |
2888 | - |
2889 | fp = open(gladefile) |
2890 | sniff = fp.read(200) |
2891 | fp.close() |
2892 | |
2893 | === modified file 'kiwi/ui/widgets/button.py' |
2894 | --- kiwi/ui/widgets/button.py 2011-06-24 20:16:58 +0000 |
2895 | +++ kiwi/ui/widgets/button.py 2012-05-04 16:37:18 +0000 |
2896 | @@ -34,6 +34,7 @@ |
2897 | from kiwi.ui.proxywidget import ProxyWidgetMixin |
2898 | from kiwi.utils import gsignal |
2899 | |
2900 | + |
2901 | class ProxyButton(gtk.Button, ProxyWidgetMixin): |
2902 | """ |
2903 | A ProxyButton is a Button subclass which is implementing the features |
2904 | @@ -98,4 +99,3 @@ |
2905 | self.set_label(text) |
2906 | |
2907 | self.emit('content-changed') |
2908 | - |
2909 | |
2910 | === modified file 'kiwi/ui/widgets/checkbutton.py' |
2911 | --- kiwi/ui/widgets/checkbutton.py 2011-06-24 20:16:58 +0000 |
2912 | +++ kiwi/ui/widgets/checkbutton.py 2012-05-04 16:37:18 +0000 |
2913 | @@ -34,6 +34,7 @@ |
2914 | from kiwi.ui.proxywidget import ProxyWidgetMixin |
2915 | from kiwi.utils import gsignal, type_register |
2916 | |
2917 | + |
2918 | class ProxyCheckButton(gtk.CheckButton, ProxyWidgetMixin): |
2919 | __gtype_name__ = 'ProxyCheckButton' |
2920 | |
2921 | @@ -57,6 +58,7 @@ |
2922 | self.props.data_type = bool |
2923 | |
2924 | gsignal('toggled', 'override') |
2925 | + |
2926 | def do_toggled(self): |
2927 | self.emit('content-changed') |
2928 | self.chain() |
2929 | @@ -66,16 +68,18 @@ |
2930 | |
2931 | def update(self, data): |
2932 | if data is None or data is ValueUnset: |
2933 | - self.set_active(False); |
2934 | + self.set_active(False) |
2935 | return |
2936 | |
2937 | # No conversion to string needed, we only accept bool |
2938 | self.set_active(data) |
2939 | |
2940 | + |
2941 | class CheckButton(ProxyCheckButton): |
2942 | def __init__(self): |
2943 | deprecationwarn( |
2944 | 'CheckButton is deprecated, use ProxyCheckButton instead', |
2945 | stacklevel=3) |
2946 | ProxyCheckButton.__init__(self) |
2947 | + |
2948 | type_register(CheckButton) |
2949 | |
2950 | === modified file 'kiwi/ui/widgets/colorbutton.py' |
2951 | --- kiwi/ui/widgets/colorbutton.py 2011-06-24 20:16:58 +0000 |
2952 | +++ kiwi/ui/widgets/colorbutton.py 2012-05-04 16:37:18 +0000 |
2953 | @@ -42,6 +42,7 @@ |
2954 | gtk.ColorButton.__init__(self, color) |
2955 | |
2956 | gsignal('color-set', 'override') |
2957 | + |
2958 | def do_color_set(self): |
2959 | self.emit('content-changed') |
2960 | self.chain() |
2961 | |
2962 | === modified file 'kiwi/ui/widgets/combo.py' |
2963 | --- kiwi/ui/widgets/combo.py 2012-05-02 17:00:01 +0000 |
2964 | +++ kiwi/ui/widgets/combo.py 2012-05-04 16:37:18 +0000 |
2965 | @@ -54,6 +54,7 @@ |
2966 | from kiwi.ui.widgets.entry import ProxyEntry |
2967 | from kiwi.utils import gsignal |
2968 | |
2969 | + |
2970 | class _EasyComboBoxHelper(object): |
2971 | |
2972 | implements(IEasyCombo) |
2973 | @@ -191,7 +192,6 @@ |
2974 | raise AssertionError |
2975 | |
2976 | def select(self, data): |
2977 | - mode = self.mode |
2978 | if self.mode == ComboMode.STRING: |
2979 | self.select_item_by_label(data) |
2980 | elif self.mode == ComboMode.DATA: |
2981 | @@ -310,7 +310,6 @@ |
2982 | def _on__changed(self, combo): |
2983 | self.emit('content-changed') |
2984 | |
2985 | - |
2986 | def set_color_attribute(self, value): |
2987 | self._color_attribute = value |
2988 | |
2989 | @@ -444,6 +443,7 @@ |
2990 | """ |
2991 | return self._helper.get_selected() |
2992 | |
2993 | + |
2994 | class ProxyComboBoxEntry(BaseComboBoxEntry, |
2995 | ValidatableProxyWidgetMixin): |
2996 | allowed_data_types = (basestring, object) + number |
2997 | @@ -486,7 +486,6 @@ |
2998 | self.set_events(gtk.gdk.KEY_RELEASE_MASK) |
2999 | self.connect("key-release-event", self._on__key_release_event) |
3000 | |
3001 | - |
3002 | def __nonzero__(self): |
3003 | return True |
3004 | |
3005 | @@ -510,7 +509,6 @@ |
3006 | type=bool, default=True, |
3007 | nick="Editable") |
3008 | |
3009 | - |
3010 | # Private |
3011 | |
3012 | def _update_selection(self, text=None): |
3013 | @@ -668,6 +666,7 @@ |
3014 | |
3015 | self._helper.set_mode(self, mode) |
3016 | |
3017 | + |
3018 | class ProxyComboEntry(ComboEntry, ValidatableProxyWidgetMixin): |
3019 | __gtype_name__ = 'ProxyComboEntry' |
3020 | allowed_data_types = (basestring, object) + number |
3021 | |
3022 | === modified file 'kiwi/ui/widgets/combobox.py' |
3023 | --- kiwi/ui/widgets/combobox.py 2006-08-29 18:19:55 +0000 |
3024 | +++ kiwi/ui/widgets/combobox.py 2012-05-04 16:37:18 +0000 |
3025 | @@ -30,8 +30,10 @@ |
3026 | from kiwi.ui.widgets.combo import ProxyComboBox |
3027 | from kiwi.ui.widgets.combo import ProxyComboBoxEntry |
3028 | |
3029 | + |
3030 | class ComboBox(ProxyComboBox): |
3031 | pass |
3032 | |
3033 | + |
3034 | class ComboBoxEntry(ProxyComboBoxEntry): |
3035 | pass |
3036 | |
3037 | === modified file 'kiwi/ui/widgets/contextmenu.py' |
3038 | --- kiwi/ui/widgets/contextmenu.py 2012-03-02 19:03:26 +0000 |
3039 | +++ kiwi/ui/widgets/contextmenu.py 2012-05-04 16:37:18 +0000 |
3040 | @@ -26,6 +26,7 @@ |
3041 | |
3042 | from kiwi.utils import gsignal |
3043 | |
3044 | + |
3045 | class ContextMenuItem(gtk.ImageMenuItem): |
3046 | gsignal('can-disable', retval=bool) |
3047 | |
3048 | @@ -66,6 +67,7 @@ |
3049 | |
3050 | gobject.type_register(ContextMenuItem) |
3051 | |
3052 | + |
3053 | class ContextMenu(gtk.Menu): |
3054 | |
3055 | def append_separator(self): |
3056 | @@ -83,5 +85,3 @@ |
3057 | |
3058 | can_select = not menu_item.emit('can-disable') |
3059 | menu_item.set_sensitive(can_select) |
3060 | - |
3061 | - |
3062 | |
3063 | === modified file 'kiwi/ui/widgets/entry.py' |
3064 | --- kiwi/ui/widgets/entry.py 2012-05-02 15:21:42 +0000 |
3065 | +++ kiwi/ui/widgets/entry.py 2012-05-04 16:37:18 +0000 |
3066 | @@ -41,12 +41,14 @@ |
3067 | VALIDATION_ICON_WIDTH |
3068 | from kiwi.utils import gsignal, type_register |
3069 | |
3070 | + |
3071 | class ProxyEntryMeta(gobject.GObjectMeta): |
3072 | def __call__(self, *args, **kwargs): |
3073 | rv = super(ProxyEntryMeta, self).__call__(*args, **kwargs) |
3074 | rv.__post_init__() |
3075 | return rv |
3076 | |
3077 | + |
3078 | class ProxyEntry(KiwiEntry, ValidatableProxyWidgetMixin): |
3079 | """The Kiwi Entry widget has many special features that extend the basic |
3080 | gtk entry. |
3081 | @@ -94,6 +96,7 @@ |
3082 | |
3083 | # Virtual methods |
3084 | gsignal('changed', 'override') |
3085 | + |
3086 | def do_changed(self): |
3087 | if self._block_changed: |
3088 | self.emit_stop_by_name('changed') |
3089 | @@ -216,13 +219,16 @@ |
3090 | |
3091 | type_register(ProxyEntry) |
3092 | |
3093 | + |
3094 | class Entry(ProxyEntry): |
3095 | def __init__(self, data_type=None): |
3096 | deprecationwarn('Entry is deprecated, use ProxyEntry instead', |
3097 | stacklevel=3) |
3098 | ProxyEntry.__init__(self, data_type) |
3099 | + |
3100 | type_register(Entry) |
3101 | |
3102 | + |
3103 | class ProxyDateEntry(DateEntry, ValidatableProxyWidgetMixin): |
3104 | __gtype_name__ = 'ProxyDateEntry' |
3105 | |
3106 | @@ -261,6 +267,7 @@ |
3107 | + int(icon_width / char_width)) |
3108 | |
3109 | gsignal('changed', 'override') |
3110 | + |
3111 | def do_changed(self): |
3112 | self.chain() |
3113 | self.emit('content-changed') |
3114 | |
3115 | === modified file 'kiwi/ui/widgets/filechooser.py' |
3116 | --- kiwi/ui/widgets/filechooser.py 2012-02-10 19:37:37 +0000 |
3117 | +++ kiwi/ui/widgets/filechooser.py 2012-05-04 16:37:18 +0000 |
3118 | @@ -29,12 +29,14 @@ |
3119 | from kiwi.ui.proxywidget import ProxyWidgetMixin |
3120 | from kiwi.utils import gsignal |
3121 | |
3122 | + |
3123 | class _FileChooserMixin(object): |
3124 | """Mixin to use common methods of the FileChooser interface""" |
3125 | |
3126 | allowed_data_types = basestring, |
3127 | |
3128 | gsignal('selection_changed', 'override') |
3129 | + |
3130 | def do_selection_changed(self): |
3131 | self.emit('content-changed') |
3132 | self.chain() |
3133 | @@ -47,9 +49,11 @@ |
3134 | return |
3135 | self.set_filename(data) |
3136 | |
3137 | + |
3138 | class ProxyFileChooserWidget(_FileChooserMixin, gtk.FileChooserWidget, |
3139 | ProxyWidgetMixin): |
3140 | __gtype_name__ = 'ProxyFileChooserWidget' |
3141 | + |
3142 | def __init__(self, action=gtk.FILE_CHOOSER_ACTION_OPEN, backend=None): |
3143 | """ |
3144 | Create a new ProxyFileChooserWidget object. |
3145 | @@ -60,9 +64,11 @@ |
3146 | self.props.data_type = str |
3147 | gtk.FileChooserWidget.__init__(self, action=action, backend=backend) |
3148 | |
3149 | + |
3150 | class ProxyFileChooserButton(_FileChooserMixin, gtk.FileChooserButton, |
3151 | ProxyWidgetMixin): |
3152 | __gtype_name__ = 'ProxyFileChooserButton' |
3153 | + |
3154 | def __init__(self, title=None, backend=None, dialog=None): |
3155 | """ |
3156 | Create a new ProxyFileChooserButton object. |
3157 | |
3158 | === modified file 'kiwi/ui/widgets/fontbutton.py' |
3159 | --- kiwi/ui/widgets/fontbutton.py 2011-06-24 20:16:58 +0000 |
3160 | +++ kiwi/ui/widgets/fontbutton.py 2012-05-04 16:37:18 +0000 |
3161 | @@ -32,6 +32,7 @@ |
3162 | self.props.data_type = str |
3163 | |
3164 | gsignal('font-set', 'override') |
3165 | + |
3166 | def do_font_set(self): |
3167 | self.emit('content-changed') |
3168 | self.chain() |
3169 | @@ -43,4 +44,3 @@ |
3170 | self.set_font_name(data) |
3171 | |
3172 | type_register(ProxyFontButton) |
3173 | - |
3174 | |
3175 | === modified file 'kiwi/ui/widgets/label.py' |
3176 | --- kiwi/ui/widgets/label.py 2012-04-10 18:14:36 +0000 |
3177 | +++ kiwi/ui/widgets/label.py 2012-05-04 16:37:18 +0000 |
3178 | @@ -38,6 +38,7 @@ |
3179 | from kiwi.ui.proxywidget import ProxyWidgetMixin |
3180 | from kiwi.utils import gsignal, type_register |
3181 | |
3182 | + |
3183 | class ProxyLabel(gtk.Label, ProxyWidgetMixin): |
3184 | __gtype_name__ = 'ProxyLabel' |
3185 | model_attribute = gobject.property(type=str, blurb='Model attribute') |
3186 | @@ -59,10 +60,10 @@ |
3187 | ProxyWidgetMixin.__init__(self) |
3188 | self.props.data_type = data_type |
3189 | self.set_use_markup(True) |
3190 | - self._attr_dic = { "style": None, |
3191 | - "weight": None, |
3192 | - "size": None, |
3193 | - "underline": None } |
3194 | + self._attr_dic = {"style": None, |
3195 | + "weight": None, |
3196 | + "size": None, |
3197 | + "underline": None} |
3198 | self._size_list = ('xx-small', 'x-small', |
3199 | 'small', 'medium', |
3200 | 'large', 'x-large', |
3201 | @@ -186,12 +187,15 @@ |
3202 | |
3203 | def set_color(self, color): |
3204 | set_foreground(self, color) |
3205 | + |
3206 | type_register(ProxyLabel) |
3207 | |
3208 | + |
3209 | class Label(ProxyLabel): |
3210 | def __init__(self, label='', data_type=None): |
3211 | deprecationwarn( |
3212 | 'Label is deprecated, use ProxyLabel instead', |
3213 | stacklevel=3) |
3214 | ProxyLabel.__init__(self, label=label, data_type=data_type) |
3215 | + |
3216 | type_register(Label) |
3217 | |
3218 | === modified file 'kiwi/ui/widgets/list.py' |
3219 | --- kiwi/ui/widgets/list.py 2006-03-22 14:39:56 +0000 |
3220 | +++ kiwi/ui/widgets/list.py 2012-05-04 16:37:18 +0000 |
3221 | @@ -34,6 +34,7 @@ |
3222 | # pyflakes |
3223 | Column, SequentialColumn, ColoredColumn, ListLabel, SummaryLabel |
3224 | |
3225 | + |
3226 | class List(ObjectList): |
3227 | def __init__(self, columns=[], |
3228 | instance_list=None, |
3229 | @@ -59,4 +60,3 @@ |
3230 | def select_instance(self, *args, **kwargs): |
3231 | return self.select(*args, **kwargs) |
3232 | select_instance = deprecated('select', log)(select_instance) |
3233 | - |
3234 | |
3235 | === modified file 'kiwi/ui/widgets/radiobutton.py' |
3236 | --- kiwi/ui/widgets/radiobutton.py 2012-02-10 19:37:37 +0000 |
3237 | +++ kiwi/ui/widgets/radiobutton.py 2012-05-04 16:37:18 +0000 |
3238 | @@ -34,6 +34,7 @@ |
3239 | from kiwi.utils import gsignal, type_register |
3240 | from kiwi.ui.proxywidget import ProxyWidgetMixin |
3241 | |
3242 | + |
3243 | class ProxyRadioButton(gtk.RadioButton, ProxyWidgetMixin): |
3244 | __gtype_name__ = 'ProxyRadioButton' |
3245 | allowed_data_types = object, |
3246 | @@ -94,10 +95,12 @@ |
3247 | if rb.get_property('data-value') == data: |
3248 | rb.set_active(True) |
3249 | |
3250 | + |
3251 | class RadioButton(ProxyRadioButton): |
3252 | def __init__(self): |
3253 | deprecationwarn( |
3254 | 'RadioButton is deprecated, use ProxyRadioButton instead', |
3255 | stacklevel=3) |
3256 | ProxyRadioButton.__init__(self) |
3257 | + |
3258 | type_register(RadioButton) |
3259 | |
3260 | === modified file 'kiwi/ui/widgets/scale.py' |
3261 | --- kiwi/ui/widgets/scale.py 2011-06-24 20:16:58 +0000 |
3262 | +++ kiwi/ui/widgets/scale.py 2012-05-04 16:37:18 +0000 |
3263 | @@ -31,13 +31,14 @@ |
3264 | from kiwi.ui.proxywidget import ProxyWidgetMixin |
3265 | from kiwi.utils import gsignal, type_register |
3266 | |
3267 | + |
3268 | class _ProxyScale: |
3269 | - |
3270 | # changed allowed data types because scales can only |
3271 | # accept float values |
3272 | allowed_data_types = float, |
3273 | |
3274 | gsignal('value_changed', 'override') |
3275 | + |
3276 | def do_value_changed(self): |
3277 | self.emit('content-changed') |
3278 | self.chain() |
3279 | |
3280 | === modified file 'kiwi/ui/widgets/spinbutton.py' |
3281 | --- kiwi/ui/widgets/spinbutton.py 2012-05-02 17:00:01 +0000 |
3282 | +++ kiwi/ui/widgets/spinbutton.py 2012-05-04 16:37:18 +0000 |
3283 | @@ -36,6 +36,7 @@ |
3284 | from kiwi.ui.proxywidget import ProxyWidgetMixin, ValidatableProxyWidgetMixin |
3285 | from kiwi.utils import gsignal, type_register |
3286 | |
3287 | + |
3288 | class ProxySpinButton(gtk.SpinButton, ValidatableProxyWidgetMixin): |
3289 | """ |
3290 | A SpinButton subclass which adds supports for the Kiwi Framework. |
3291 | @@ -66,6 +67,7 @@ |
3292 | self.set_property('xalign', 1.0) |
3293 | |
3294 | gsignal('changed', 'override') |
3295 | + |
3296 | def do_changed(self): |
3297 | """Called when the content of the spinbutton changes. |
3298 | """ |
3299 | @@ -112,4 +114,5 @@ |
3300 | 'SpinButton is deprecated, use ProxySpinButton instead', |
3301 | stacklevel=3) |
3302 | ProxySpinButton.__init__(self) |
3303 | + |
3304 | type_register(SpinButton) |
3305 | |
3306 | === modified file 'kiwi/ui/widgets/textview.py' |
3307 | --- kiwi/ui/widgets/textview.py 2011-06-24 20:16:58 +0000 |
3308 | +++ kiwi/ui/widgets/textview.py 2012-05-04 16:37:18 +0000 |
3309 | @@ -36,6 +36,7 @@ |
3310 | from kiwi.ui.proxywidget import ValidatableProxyWidgetMixin |
3311 | from kiwi.utils import gsignal, type_register |
3312 | |
3313 | + |
3314 | class ProxyTextView(gtk.TextView, ValidatableProxyWidgetMixin): |
3315 | __gtype_name__ = 'ProxyTextView' |
3316 | data_value = gobject.property(type=str, nick='Data Value') |
3317 | @@ -49,6 +50,7 @@ |
3318 | gsignal('validation-changed', bool) |
3319 | gsignal('validate', object, retval=object) |
3320 | allowed_data_types = (basestring, datetime.date) + number |
3321 | + |
3322 | def __init__(self): |
3323 | self._is_unset = True |
3324 | gtk.TextView.__init__(self) |
3325 | @@ -86,6 +88,7 @@ |
3326 | |
3327 | self._textbuffer.set_text(text) |
3328 | |
3329 | + |
3330 | class TextView(ProxyTextView): |
3331 | def __init__(self): |
3332 | deprecationwarn( |
3333 | |
3334 | === modified file 'kiwi/utils.py' |
3335 | --- kiwi/utils.py 2012-02-10 19:37:37 +0000 |
3336 | +++ kiwi/utils.py 2012-05-04 16:37:18 +0000 |
3337 | @@ -33,21 +33,27 @@ |
3338 | |
3339 | gprop = gobject.propertyhelper.property |
3340 | parent_type_from_parent = gprop._type_from_python |
3341 | +parent_get_pspec_args = gprop.get_pspec_args |
3342 | + |
3343 | + |
3344 | def _type_from_python(self, type_): |
3345 | if issubclass(type_, gobject.GEnum): |
3346 | return type_.__gtype__ |
3347 | else: |
3348 | return parent_type_from_parent(self, type_) |
3349 | + |
3350 | gprop._type_from_python = _type_from_python |
3351 | |
3352 | -parent_get_pspec_args = gprop.get_pspec_args |
3353 | + |
3354 | def _get_pspec_args(self): |
3355 | if gobject.type_is_a(self.type, gobject.GEnum): |
3356 | return (self.type, self.nick, self.blurb, self.default, self.flags) |
3357 | else: |
3358 | return parent_get_pspec_args(self) |
3359 | + |
3360 | gprop.get_pspec_args = _get_pspec_args |
3361 | |
3362 | + |
3363 | def list_properties(gtype, parent=True): |
3364 | """ |
3365 | Return a list of all properties for GType gtype, excluding |
3366 | @@ -63,6 +69,7 @@ |
3367 | return [pspec for pspec in pspecs |
3368 | if pspec not in parent_pspecs] |
3369 | |
3370 | + |
3371 | def type_register(gtype): |
3372 | """Register the type, but only if it's not already registered |
3373 | :param gtype: the class to register |
3374 | @@ -77,6 +84,7 @@ |
3375 | |
3376 | return True |
3377 | |
3378 | + |
3379 | def gsignal(name, *args, **kwargs): |
3380 | """ |
3381 | Add a GObject signal to the current object. |
3382 | @@ -123,6 +131,7 @@ |
3383 | |
3384 | dict[name] = (flags, retval, args) |
3385 | |
3386 | + |
3387 | def quote(msg): |
3388 | """ |
3389 | Similar to urllib.quote but for glibs GMarkup |
3390 | |
3391 | === modified file 'kiwiwidgets.py' |
3392 | --- kiwiwidgets.py 2012-02-21 11:59:22 +0000 |
3393 | +++ kiwiwidgets.py 2012-05-04 16:37:18 +0000 |
3394 | @@ -29,6 +29,7 @@ |
3395 | ProxyTextView |
3396 | ProxyButton |
3397 | |
3398 | + |
3399 | def _get_icon_path(): |
3400 | dirname = os.path.dirname(__file__) |
3401 | if not os.path.exists(os.path.join(dirname, '.svn')): |
3402 | @@ -39,6 +40,7 @@ |
3403 | 'resources', 'kiwiwidgets') |
3404 | return os.path.abspath(icondir) |
3405 | |
3406 | + |
3407 | def _register_icons(): |
3408 | icondir = _get_icon_path() |
3409 | for filename in glob.glob(os.path.join(icondir, '*.png')): |
3410 | @@ -49,4 +51,5 @@ |
3411 | 22, |
3412 | gtk.gdk.pixbuf_new_from_file(filename)) |
3413 | |
3414 | + |
3415 | _register_icons() |
3416 | |
3417 | === modified file 'setup.py' |
3418 | --- setup.py 2012-02-21 12:27:11 +0000 |
3419 | +++ setup.py 2012-05-04 16:37:18 +0000 |
3420 | @@ -17,7 +17,7 @@ |
3421 | import sys |
3422 | |
3423 | from kiwi import kiwi_version |
3424 | -from kiwi.dist import setup, listfiles, listpackages, get_site_packages_dir |
3425 | +from kiwi.dist import setup, listfiles, listpackages |
3426 | |
3427 | |
3428 | ext_modules = [] |
3429 | |
3430 | === modified file 'tests/Proxies/CheckButton.py' |
3431 | --- tests/Proxies/CheckButton.py 2006-03-10 19:10:55 +0000 |
3432 | +++ tests/Proxies/CheckButton.py 2012-05-04 16:37:18 +0000 |
3433 | @@ -10,12 +10,15 @@ |
3434 | from Kiwi.Proxies import Proxy |
3435 | from Kiwi.Models import Model |
3436 | |
3437 | + |
3438 | class Foo(Model): |
3439 | A = 1 |
3440 | B = 0 |
3441 | |
3442 | + |
3443 | class CheckProxy(Proxy): |
3444 | widgets = [":B", ":A"] |
3445 | + |
3446 | def __init__(self, model): |
3447 | self._build() |
3448 | Proxy.__init__(self, model, delete_handler=gtk.mainquit) |
3449 | @@ -30,6 +33,7 @@ |
3450 | vbox.add(self.B) |
3451 | self.win.add(vbox) |
3452 | |
3453 | + |
3454 | class ToggleProxy(CheckProxy): |
3455 | def _build(self): |
3456 | self.win = gtk.Window() |
3457 | @@ -48,7 +52,9 @@ |
3458 | c.B.clicked() |
3459 | assert f.A == 0, f.A |
3460 | assert f.B == 1, f.B |
3461 | -if DEBUG: c.show_all_and_loop() ; print f.__dict__ |
3462 | +if DEBUG: |
3463 | + c.show_all_and_loop() |
3464 | + print f.__dict__ |
3465 | print "CheckButton OK" |
3466 | |
3467 | f = Foo() |
3468 | @@ -59,5 +65,7 @@ |
3469 | c.B.clicked() |
3470 | assert f.A == 0, f.A |
3471 | assert f.B == 1, f.B |
3472 | -if DEBUG: c.show_all_and_loop(); print f.__dict__ |
3473 | +if DEBUG: |
3474 | + c.show_all_and_loop() |
3475 | + print f.__dict__ |
3476 | print "ToggleButton OK" |
3477 | |
3478 | === modified file 'tests/Proxies/Entry.py' |
3479 | --- tests/Proxies/Entry.py 2006-03-10 19:10:55 +0000 |
3480 | +++ tests/Proxies/Entry.py 2012-05-04 16:37:18 +0000 |
3481 | @@ -1,5 +1,6 @@ |
3482 | #!/usr/bin/env python |
3483 | -import sys, pprint |
3484 | +import pprint |
3485 | +import sys |
3486 | sys.path.insert(0, "../..") |
3487 | |
3488 | DEBUG = 0 |
3489 | @@ -12,6 +13,7 @@ |
3490 | from Kiwi.Proxies import Proxy |
3491 | from Kiwi.Models import Model |
3492 | |
3493 | + |
3494 | class Foo(Model): |
3495 | A = "Alphabet" |
3496 | B = "Beetroot" |
3497 | @@ -22,6 +24,7 @@ |
3498 | G = 30 |
3499 | # H unset |
3500 | |
3501 | + |
3502 | class NumberFoo(Model): |
3503 | A = 1 |
3504 | B = 2 |
3505 | @@ -32,8 +35,10 @@ |
3506 | G = 6 |
3507 | # H unset |
3508 | |
3509 | + |
3510 | class EntryProxy(Proxy): |
3511 | widgets = [":B", ":A", ":C", ":D", ":E", ":F", ":G", ":H"] |
3512 | + |
3513 | def __init__(self, model, flag=0): |
3514 | self._build() |
3515 | self.set_numeric("C") |
3516 | @@ -71,6 +76,7 @@ |
3517 | self.vbox = vbox |
3518 | self.win.add(vbox) |
3519 | |
3520 | + |
3521 | class ComboProxy(EntryProxy): |
3522 | def _build(self): |
3523 | self.win = gtk.Window() |
3524 | @@ -99,6 +105,7 @@ |
3525 | vbox.add(self.H) |
3526 | self.win.add(vbox) |
3527 | |
3528 | + |
3529 | class LabelProxy(EntryProxy): |
3530 | def _build(self): |
3531 | self.win = gtk.Window() |
3532 | @@ -122,6 +129,7 @@ |
3533 | vbox.add(self.H) |
3534 | self.win.add(vbox) |
3535 | |
3536 | + |
3537 | class SpinProxy(EntryProxy): |
3538 | def _build(self): |
3539 | self.win = gtk.Window() |
3540 | @@ -183,7 +191,9 @@ |
3541 | t = c.G.get_text() |
3542 | assert t == "30,420", t |
3543 | assert f.G == 30.42 |
3544 | -if DEBUG: c.show_all_and_loop() ; pprint.pprint(f.__dict__) |
3545 | +if DEBUG: |
3546 | + c.show_all_and_loop() |
3547 | + pprint.pprint(f.__dict__) |
3548 | print "Entry OK" |
3549 | |
3550 | f = Foo() |
3551 | @@ -209,7 +219,9 @@ |
3552 | assert f.D == "barney", f.D |
3553 | t = c.G.entry.get_text() |
3554 | assert t == "30,420", t |
3555 | -if DEBUG: c.show_all_and_loop() ; pprint.pprint(f.__dict__) |
3556 | +if DEBUG: |
3557 | + c.show_all_and_loop() |
3558 | + pprint.pprint(f.__dict__) |
3559 | print "Combo OK" |
3560 | |
3561 | f = Foo() |
3562 | @@ -243,7 +255,9 @@ |
3563 | assert c.D.get() == "barney", f.D |
3564 | t = c.G.get_text() |
3565 | assert t == "30,420", t |
3566 | -if DEBUG: c.show_all_and_loop() ; pprint.pprint(f.__dict__) |
3567 | +if DEBUG: |
3568 | + c.show_all_and_loop() |
3569 | + pprint.pprint(f.__dict__) |
3570 | print "Label OK" |
3571 | |
3572 | f = NumberFoo() |
3573 | @@ -254,7 +268,9 @@ |
3574 | pass |
3575 | f.flush_proxies() |
3576 | c = SpinProxy(f, 1) |
3577 | -if DEBUG: c.show_all_and_loop() ; pprint.pprint(f.__dict__) |
3578 | +if DEBUG: |
3579 | + c.show_all_and_loop() |
3580 | + pprint.pprint(f.__dict__) |
3581 | assert f.A == 0, f.A |
3582 | assert f.B == 0, f.B |
3583 | assert f.C == 0 |
3584 | |
3585 | === modified file 'tests/Proxies/NoModel.py' |
3586 | --- tests/Proxies/NoModel.py 2006-03-10 19:10:55 +0000 |
3587 | +++ tests/Proxies/NoModel.py 2012-05-04 16:37:18 +0000 |
3588 | @@ -4,7 +4,8 @@ |
3589 | # Tests creating a Proxy with no initial model, and then adding one later |
3590 | # |
3591 | |
3592 | -import sys, pprint |
3593 | +import pprint |
3594 | +import sys |
3595 | sys.path.insert(0, "../..") |
3596 | |
3597 | DEBUG = 0 |
3598 | @@ -15,11 +16,14 @@ |
3599 | from Kiwi.Proxies import Proxy |
3600 | from Kiwi.Models import Model |
3601 | |
3602 | + |
3603 | class Foo(Model): |
3604 | pass |
3605 | |
3606 | + |
3607 | class XProxy(Proxy): |
3608 | widgets = [":A"] |
3609 | + |
3610 | def __init__(self, model=None, flag=0): |
3611 | self._build() |
3612 | self.set_numeric("A") |
3613 | |
3614 | === modified file 'tests/Proxies/None.py' |
3615 | --- tests/Proxies/None.py 2006-03-10 19:10:55 +0000 |
3616 | +++ tests/Proxies/None.py 2012-05-04 16:37:18 +0000 |
3617 | @@ -16,11 +16,14 @@ |
3618 | from Kiwi.Proxies import Proxy |
3619 | from Kiwi.Models import Model |
3620 | |
3621 | + |
3622 | class Foo(Model): |
3623 | pass |
3624 | |
3625 | + |
3626 | class NoProxy(Proxy): |
3627 | widgets = [":A"] |
3628 | + |
3629 | def __init__(self, model, flag=0): |
3630 | self._build() |
3631 | Proxy.__init__(self, model, delete_handler=gtk.mainquit) |
3632 | |
3633 | === modified file 'tests/Proxies/OptionMenu.py' |
3634 | --- tests/Proxies/OptionMenu.py 2006-03-10 19:10:55 +0000 |
3635 | +++ tests/Proxies/OptionMenu.py 2012-05-04 16:37:18 +0000 |
3636 | @@ -1,5 +1,6 @@ |
3637 | #!/usr/bin/env python |
3638 | -import sys, pprint |
3639 | +import pprint |
3640 | +import sys |
3641 | sys.path.insert(0, "../..") |
3642 | |
3643 | DEBUG = 0 |
3644 | @@ -12,9 +13,11 @@ |
3645 | #from Kiwi.Menu import OptionMenu |
3646 | from gtk import OptionMenu |
3647 | |
3648 | + |
3649 | def prefill(args): |
3650 | print "ARGS", args |
3651 | |
3652 | + |
3653 | class Foo(Model): |
3654 | A = "Run" |
3655 | B = "Hide" |
3656 | @@ -23,8 +26,10 @@ |
3657 | E = 666 # Run |
3658 | # No F - Play |
3659 | |
3660 | + |
3661 | class CheckProxy(Proxy): |
3662 | widgets = [":A", ":B", ":C", ":D", ":E", ":F"] |
3663 | + |
3664 | def __init__(self, model): |
3665 | self._build() |
3666 | Proxy.__init__(self, model, delete_handler=gtk.mainquit) |
3667 | @@ -41,9 +46,9 @@ |
3668 | self.D = OptionMenu() |
3669 | self.D.prefill(["Play", "Hide", "Run"]) |
3670 | self.E = OptionMenu() |
3671 | - self.E.prefill([("Play", 111), ("Hide", 222) , ("Run", 666)]) |
3672 | + self.E.prefill([("Play", 111), ("Hide", 222), ("Run", 666)]) |
3673 | self.F = OptionMenu() |
3674 | - self.F.prefill([("Play", 111), ("Hide", 222) , ("Run", 666)]) |
3675 | + self.F.prefill([("Play", 111), ("Hide", 222), ("Run", 666)]) |
3676 | vbox = gtk.VBox() |
3677 | vbox.add(self.A) |
3678 | vbox.add(self.B) |
3679 | @@ -73,5 +78,7 @@ |
3680 | except ValueError: |
3681 | # XXX: set value back to normal. See Model.__setattr__ |
3682 | f.E = 222 |
3683 | -if DEBUG: c.show_all_and_loop() ; pprint.pprint(f.__dict__) |
3684 | +if DEBUG: |
3685 | + c.show_all_and_loop() |
3686 | + pprint.pprint(f.__dict__) |
3687 | print "OptionMenu OK" |
3688 | |
3689 | === modified file 'tests/Proxies/RadioGroup.py' |
3690 | --- tests/Proxies/RadioGroup.py 2006-03-10 19:10:55 +0000 |
3691 | +++ tests/Proxies/RadioGroup.py 2012-05-04 16:37:18 +0000 |
3692 | @@ -1,5 +1,6 @@ |
3693 | #!/usr/bin/env python |
3694 | -import sys, pprint |
3695 | +import pprint |
3696 | +import sys |
3697 | sys.path.insert(0, "../..") |
3698 | |
3699 | DEBUG = 0 |
3700 | @@ -10,6 +11,7 @@ |
3701 | from Kiwi.Proxies import Proxy |
3702 | from Kiwi.Models import Model |
3703 | |
3704 | + |
3705 | class Foo(Model): |
3706 | A = "Play" |
3707 | B = 222 |
3708 | @@ -18,6 +20,7 @@ |
3709 | E = None # Run |
3710 | # No F - Play |
3711 | |
3712 | + |
3713 | class RadioProxy(Proxy): |
3714 | def __init__(self, model): |
3715 | self._build() |
3716 | @@ -99,5 +102,7 @@ |
3717 | assert f.A == "Run", f.A |
3718 | f.E = None |
3719 | assert f.E == 111, f.E |
3720 | -if DEBUG: c.show_all_and_loop(); pprint.pprint(f.__dict__) |
3721 | +if DEBUG: |
3722 | + c.show_all_and_loop() |
3723 | + pprint.pprint(f.__dict__) |
3724 | print 'RadioButton OK' |
3725 | |
3726 | === modified file 'tests/Proxies/Separator.py' |
3727 | --- tests/Proxies/Separator.py 2005-06-28 18:34:30 +0000 |
3728 | +++ tests/Proxies/Separator.py 2012-05-04 16:37:18 +0000 |
3729 | @@ -11,11 +11,14 @@ |
3730 | from Kiwi.Proxies import Proxy |
3731 | from Kiwi.Models import Model |
3732 | |
3733 | + |
3734 | class Foo(Model): |
3735 | A = 10.10 |
3736 | |
3737 | + |
3738 | class EntryProxy(Proxy): |
3739 | widgets = [":A"] |
3740 | + |
3741 | def __init__(self, model): |
3742 | self.set_numeric("A") |
3743 | self._build() |
3744 | |
3745 | === modified file 'tests/Proxies/Text.py' |
3746 | --- tests/Proxies/Text.py 2006-03-10 19:10:55 +0000 |
3747 | +++ tests/Proxies/Text.py 2012-05-04 16:37:18 +0000 |
3748 | @@ -1,5 +1,6 @@ |
3749 | #!/usr/bin/env python |
3750 | -import sys, pprint |
3751 | +import pprint |
3752 | +import sys |
3753 | sys.path.insert(0, "../..") |
3754 | |
3755 | DEBUG = 0 |
3756 | @@ -12,6 +13,7 @@ |
3757 | from Kiwi.Proxies import Proxy |
3758 | from Kiwi.FrameWork import Model |
3759 | |
3760 | + |
3761 | class Foo(Model): |
3762 | A = "Alphabet" |
3763 | B = "Beetroot" |
3764 | @@ -21,8 +23,10 @@ |
3765 | # F unset |
3766 | G = 30.42 |
3767 | |
3768 | + |
3769 | class TextProxy(Proxy): |
3770 | widgets = [":A", ":B", ":C", ":D", ":E", ":F", ":G"] |
3771 | + |
3772 | def __init__(self, model, flag=0): |
3773 | self._build() |
3774 | self.set_numeric("C") |
3775 | @@ -88,5 +92,7 @@ |
3776 | assert f.D == "barney", f.D |
3777 | t = c.G.get_chars(0, c.G.get_length()) |
3778 | assert t == "30.420", t |
3779 | -if DEBUG: c.show_all_and_loop() ; pprint.pprint(f.__dict__) |
3780 | +if DEBUG: |
3781 | + c.show_all_and_loop() |
3782 | + pprint.pprint(f.__dict__) |
3783 | print "Text OK" |
3784 | |
3785 | === modified file 'tests/test_BaseView.py' |
3786 | --- tests/test_BaseView.py 2006-10-05 14:33:18 +0000 |
3787 | +++ tests/test_BaseView.py 2012-05-04 16:37:18 +0000 |
3788 | @@ -10,8 +10,10 @@ |
3789 | set_background, get_background |
3790 | from kiwi.ui.views import BaseView |
3791 | |
3792 | + |
3793 | class FooView(BaseView): |
3794 | - widgets = [ "vbox", "label" ] |
3795 | + widgets = ["vbox", "label"] |
3796 | + |
3797 | def __init__(self): |
3798 | self.build_ui() |
3799 | BaseView.__init__(self, toplevel_name='win') |
3800 | @@ -29,6 +31,7 @@ |
3801 | self.vbox = vbox |
3802 | return vbox |
3803 | |
3804 | + |
3805 | class FooController(BaseController): |
3806 | def __init__(self, view): |
3807 | keyactions = { |
3808 | @@ -46,6 +49,7 @@ |
3809 | # This is subclassed |
3810 | self.view.label.set_text("Good click!") |
3811 | |
3812 | + |
3813 | class Bar(BaseView, BaseController): |
3814 | def __init__(self): |
3815 | self.win = gtk.Window() |
3816 | @@ -56,6 +60,7 @@ |
3817 | set_foreground(self.label, "#CC99FF") |
3818 | set_background(self.win, "#001100") |
3819 | |
3820 | + |
3821 | # these classes are bad and should trigger exceptions |
3822 | |
3823 | class NoWinFoo(BaseView, BaseController): |
3824 | @@ -76,6 +81,7 @@ |
3825 | def on_noogie__haxored(self, *args): |
3826 | print "I AM NOT A NUMBER I AM A FREE MAN" |
3827 | |
3828 | + |
3829 | class BaseViewTest(unittest.TestCase): |
3830 | |
3831 | def setUp(self): |
3832 | |
3833 | === modified file 'tests/test_CheckButton.py' |
3834 | --- tests/test_CheckButton.py 2011-06-24 20:16:58 +0000 |
3835 | +++ tests/test_CheckButton.py 2012-05-04 16:37:18 +0000 |
3836 | @@ -3,6 +3,7 @@ |
3837 | |
3838 | from kiwi.ui.widgets.checkbutton import ProxyCheckButton |
3839 | |
3840 | + |
3841 | class CheckButtonTest(unittest.TestCase): |
3842 | def testForBool(self): |
3843 | myChkBtn = ProxyCheckButton() |
3844 | |
3845 | === modified file 'tests/test_ComboBox.py' |
3846 | --- tests/test_ComboBox.py 2007-01-29 18:20:43 +0000 |
3847 | +++ tests/test_ComboBox.py 2012-05-04 16:37:18 +0000 |
3848 | @@ -5,6 +5,7 @@ |
3849 | from kiwi.ui.proxy import Proxy |
3850 | from kiwi.ui.widgets.combobox import ProxyComboBox, ProxyComboBoxEntry |
3851 | |
3852 | + |
3853 | class TestComboBox(unittest.TestCase): |
3854 | def setUp(self): |
3855 | self.combo = ProxyComboBox() |
3856 | @@ -74,6 +75,7 @@ |
3857 | self.combo.clear() |
3858 | self.assertEqual(map(list, self.combo.get_model()), []) |
3859 | |
3860 | + |
3861 | class FakeView: |
3862 | def handler_block(self, widget): |
3863 | pass |
3864 | @@ -81,6 +83,7 @@ |
3865 | def handler_unblock(self, widget): |
3866 | pass |
3867 | |
3868 | + |
3869 | class BaseModelTest: |
3870 | def setUp(self): |
3871 | self.model = Settable(attr=0) |
3872 | @@ -105,9 +108,11 @@ |
3873 | self.combo.select_item_by_label('foo') |
3874 | self.assertEqual(self.model.attr, 0) |
3875 | |
3876 | + |
3877 | class ComboModelTest(BaseModelTest, unittest.TestCase): |
3878 | type = ProxyComboBox |
3879 | |
3880 | + |
3881 | class ComboEntryModelTest(BaseModelTest, unittest.TestCase): |
3882 | type = ProxyComboBoxEntry |
3883 | |
3884 | |
3885 | === modified file 'tests/test_Delegate.py' |
3886 | --- tests/test_Delegate.py 2006-09-05 22:52:29 +0000 |
3887 | +++ tests/test_Delegate.py 2012-05-04 16:37:18 +0000 |
3888 | @@ -5,10 +5,12 @@ |
3889 | from kiwi.ui.delegates import Delegate, GladeDelegate |
3890 | from utils import refresh_gui |
3891 | |
3892 | + |
3893 | class A: |
3894 | def on_foo__clicked(self, *args): |
3895 | self.x = "FOO in A" |
3896 | |
3897 | + |
3898 | class B: |
3899 | def on_foo__clicked(self, *args): |
3900 | self.x = "FOO in B" |
3901 | @@ -16,20 +18,25 @@ |
3902 | def on_bar__clicked(self, *args): |
3903 | self.y = "BAR in B" |
3904 | |
3905 | + |
3906 | class C: |
3907 | def on_foo__clicked(self, *args): |
3908 | self.x = "FOO in C" |
3909 | |
3910 | -class X(A,B,C): |
3911 | + |
3912 | +class X(A, B, C): |
3913 | def on_foo__clicked(self, *args): |
3914 | self.x = "FOO in X" |
3915 | |
3916 | + |
3917 | class Y: |
3918 | def on_foo__clicked(self, *args): |
3919 | self.x = "FOO in Y" |
3920 | |
3921 | -class Foo(X,Y,Delegate): |
3922 | - widget = ["foo"] |
3923 | + |
3924 | +class Foo(X, Y, Delegate): |
3925 | + widget = ["foo"] |
3926 | + |
3927 | def __init__(self): |
3928 | self.win = gtk.Window() |
3929 | self.foo = gtk.Button("CLICK ME AND BE HAPPY") |
3930 | @@ -48,6 +55,7 @@ |
3931 | def on_bar__clicked(self, *args): |
3932 | self.y = "BAR in B" |
3933 | |
3934 | + |
3935 | class ClickCounter(Delegate): |
3936 | """In this delegate we count the number of clicks we do""" |
3937 | def __init__(self): |
3938 | @@ -62,6 +70,7 @@ |
3939 | def on_button__clicked(self, *args): |
3940 | self.clicks += 1 |
3941 | |
3942 | + |
3943 | class GladeClickCounter(GladeDelegate): |
3944 | def __init__(self): |
3945 | GladeDelegate.__init__(self, gladefile="simple_button", |
3946 | @@ -72,6 +81,7 @@ |
3947 | def on_button__clicked(self, *args): |
3948 | self.clicks += 1 |
3949 | |
3950 | + |
3951 | class DelegateTest(unittest.TestCase): |
3952 | def testButtons(self): |
3953 | f = Foo() |
3954 | |
3955 | === modified file 'tests/test_Entry.py' |
3956 | --- tests/test_Entry.py 2008-06-05 21:34:47 +0000 |
3957 | +++ tests/test_Entry.py 2012-05-04 16:37:18 +0000 |
3958 | @@ -10,6 +10,7 @@ |
3959 | from kiwi.ui.entry import KiwiEntry |
3960 | from kiwi.ui.widgets.entry import ProxyEntry |
3961 | |
3962 | + |
3963 | class EntryTest(unittest.TestCase): |
3964 | def testModel(self): |
3965 | entry = ProxyEntry() |
3966 | |
3967 | === modified file 'tests/test_Label.py' |
3968 | --- tests/test_Label.py 2006-03-23 21:15:31 +0000 |
3969 | +++ tests/test_Label.py 2012-05-04 16:37:18 +0000 |
3970 | @@ -3,6 +3,7 @@ |
3971 | |
3972 | from kiwi.ui.widgets.label import ProxyLabel |
3973 | |
3974 | + |
3975 | class LabelTest(unittest.TestCase): |
3976 | def testAttr(self): |
3977 | label = ProxyLabel() |
3978 | |
3979 | === modified file 'tests/test_ObjectList.py' |
3980 | --- tests/test_ObjectList.py 2011-11-23 17:50:39 +0000 |
3981 | +++ tests/test_ObjectList.py 2012-05-04 16:37:18 +0000 |
3982 | @@ -9,6 +9,7 @@ |
3983 | |
3984 | from utils import refresh_gui |
3985 | |
3986 | + |
3987 | class Person: |
3988 | def __init__(self, name, age): |
3989 | self.name, self.age = name, age |
3990 | @@ -18,6 +19,7 @@ |
3991 | Person('Kiko', 28), Person('Salgado', 25), |
3992 | Person('Lorenzo', 26), Person('Henrique', 21)) |
3993 | |
3994 | + |
3995 | class ColumnTests(unittest.TestCase): |
3996 | |
3997 | def setUp(self): |
3998 | @@ -51,6 +53,7 @@ |
3999 | column = gobject.new(Column, attribute='foo') |
4000 | self.assertEquals(column.attribute, "foo") |
4001 | |
4002 | + |
4003 | class DataTests(unittest.TestCase): |
4004 | """In all this tests we use the same configuration for a list""" |
4005 | def setUp(self): |
4006 | @@ -132,7 +135,6 @@ |
4007 | |
4008 | self.assertEqual(len(self.list), 0) |
4009 | |
4010 | - |
4011 | def testUpdatingOneInstance(self): |
4012 | global persons |
4013 | |
4014 | @@ -154,7 +156,6 @@ |
4015 | new_person = Person('Nando', 32) |
4016 | self.assertRaises(ValueError, self.list.update, new_person) |
4017 | |
4018 | - |
4019 | def testContains(self): |
4020 | global persons |
4021 | |
4022 | @@ -173,6 +174,7 @@ |
4023 | self.list.remove(first) |
4024 | self.assertRaises(ValueError, self.list.select, first) |
4025 | |
4026 | + |
4027 | class TreeDataTests(unittest.TestCase): |
4028 | def setUp(self): |
4029 | self.win = gtk.Window() |
4030 | @@ -218,6 +220,7 @@ |
4031 | test_descendants = self.tree.get_descendants(child2) |
4032 | self.assertEqual(test_descendants, []) |
4033 | |
4034 | + |
4035 | class TestSignals(unittest.TestCase): |
4036 | def setUp(self): |
4037 | self.klist = ObjectList() |
4038 | @@ -265,6 +268,7 @@ |
4039 | self.assertEqual(self.selected, None) |
4040 | self.assertRaises(ValueError, self.klist.select, 2) |
4041 | |
4042 | + |
4043 | class ConstructorTest(unittest.TestCase): |
4044 | def testInvalidArguments(self): |
4045 | self.assertRaises(TypeError, ObjectList, columns='') |
4046 | @@ -287,6 +291,7 @@ |
4047 | olist = gobject.new(ObjectList) |
4048 | self.assertTrue(isinstance(olist, ObjectList)) |
4049 | |
4050 | + |
4051 | class MethodTest(unittest.TestCase): |
4052 | def setUp(self): |
4053 | self.klist = ObjectList([Column('name', sorted=True)], |
4054 | @@ -399,6 +404,7 @@ |
4055 | self.assertEqual(self.klist[1].name, 'three') |
4056 | self.assertEqual(self.klist[2].name, 'one') |
4057 | |
4058 | + |
4059 | class BooleanDataTests(unittest.TestCase): |
4060 | def setUp(self): |
4061 | self.list = ObjectList([Column('value', data_type=bool, radio=True, |
4062 | |
4063 | === modified file 'tests/test_Scale.py' |
4064 | --- tests/test_Scale.py 2008-06-05 21:34:47 +0000 |
4065 | +++ tests/test_Scale.py 2012-05-04 16:37:18 +0000 |
4066 | @@ -3,6 +3,7 @@ |
4067 | |
4068 | from kiwi.ui.widgets.scale import ProxyHScale, ProxyVScale |
4069 | |
4070 | + |
4071 | class ScaleTest(unittest.TestCase): |
4072 | def testFloat(self): |
4073 | vscale = ProxyVScale() |
4074 | |
4075 | === modified file 'tests/test_SpinButton.py' |
4076 | --- tests/test_SpinButton.py 2008-06-05 21:34:47 +0000 |
4077 | +++ tests/test_SpinButton.py 2012-05-04 16:37:18 +0000 |
4078 | @@ -3,6 +3,7 @@ |
4079 | |
4080 | from kiwi.ui.widgets.spinbutton import ProxySpinButton |
4081 | |
4082 | + |
4083 | class SpinButtonTest(unittest.TestCase): |
4084 | def testForIntFloat(self): |
4085 | mySpinBtn = ProxySpinButton() |
4086 | |
4087 | === modified file 'tests/test_argcheck.py' |
4088 | --- tests/test_argcheck.py 2006-06-05 14:34:48 +0000 |
4089 | +++ tests/test_argcheck.py 2012-05-04 16:37:18 +0000 |
4090 | @@ -4,6 +4,7 @@ |
4091 | from kiwi.argcheck import argcheck, number, percent |
4092 | from kiwi.datatypes import Decimal |
4093 | |
4094 | + |
4095 | class ArgTest(unittest.TestCase): |
4096 | def testOneArg(self): |
4097 | f = argcheck(str)(lambda s: None) |
4098 | @@ -120,7 +121,6 @@ |
4099 | self.assertRaises(TypeError, func_none2, s='boogie', |
4100 | date=None, date2=True) |
4101 | |
4102 | - |
4103 | def testNumber(self): |
4104 | def func(n): |
4105 | return n |
4106 | @@ -149,6 +149,7 @@ |
4107 | |
4108 | def testDisable(self): |
4109 | argcheck.disable() |
4110 | + |
4111 | def func(s): |
4112 | pass |
4113 | func = argcheck(str)(func) |
4114 | @@ -158,7 +159,7 @@ |
4115 | def testErrorHandling(self): |
4116 | self.assertRaises(TypeError, argcheck(str), True) |
4117 | self.assertRaises(TypeError, argcheck(int), lambda **x: None) |
4118 | - self.assertRaises(TypeError, argcheck(int), lambda : None) |
4119 | + self.assertRaises(TypeError, argcheck(int), lambda: None) |
4120 | self.assertRaises(TypeError, argcheck(int), lambda x='str': None) |
4121 | |
4122 | if __name__ == '__main__': |
4123 | |
4124 | === modified file 'tests/test_comboentry.py' |
4125 | --- tests/test_comboentry.py 2006-08-29 18:19:55 +0000 |
4126 | +++ tests/test_comboentry.py 2012-05-04 16:37:18 +0000 |
4127 | @@ -6,6 +6,7 @@ |
4128 | from kiwi.ui.comboentry import ComboEntry |
4129 | from kiwi.ui.widgets.combo import ProxyComboEntry |
4130 | |
4131 | + |
4132 | class TestComboEntry(unittest.TestCase): |
4133 | def setUp(self): |
4134 | self.called = False |
4135 | @@ -32,6 +33,7 @@ |
4136 | entry.entry.emit('activate') |
4137 | self.assertEqual(self.called, True) |
4138 | |
4139 | + |
4140 | class TestProxyComboEntry(unittest.TestCase): |
4141 | def testSelectItemByLabel(self): |
4142 | entry = ProxyComboEntry() |
4143 | @@ -101,7 +103,7 @@ |
4144 | entry = ProxyComboEntry() |
4145 | self.assertEqual(entry.get_mode(), ComboMode.UNKNOWN) |
4146 | entry.prefill(['one', 'two']) |
4147 | - self.assertEqual(entry.get_mode(), ComboMode.STRING) |
4148 | + self.assertEqual(entry.get_mode(), ComboMode.STRING) |
4149 | |
4150 | if __name__ == '__main__': |
4151 | unittest.main() |
4152 | |
4153 | === modified file 'tests/test_component.py' |
4154 | --- tests/test_component.py 2006-10-31 14:46:30 +0000 |
4155 | +++ tests/test_component.py 2012-05-04 16:37:18 +0000 |
4156 | @@ -3,11 +3,12 @@ |
4157 | from kiwi.component import AlreadyImplementedError, Interface, \ |
4158 | get_utility, provide_utility, remove_utility, implements, utilities |
4159 | |
4160 | +o = object() |
4161 | + |
4162 | + |
4163 | class IBanana(Interface): |
4164 | pass |
4165 | |
4166 | -class Obj(object): pass |
4167 | -o = Obj() |
4168 | |
4169 | class TestUtilities(unittest.TestCase): |
4170 | def tearDown(self): |
4171 | @@ -53,12 +54,12 @@ |
4172 | def testImplements(self): |
4173 | class I1(Interface): |
4174 | pass |
4175 | + |
4176 | class C(object): |
4177 | implements(I1) |
4178 | + |
4179 | c = C() |
4180 | - class X(object): |
4181 | - pass |
4182 | - x = X() |
4183 | + x = object() |
4184 | self.assertEqual(I1.providedBy(x), False) |
4185 | #self.assertEqual(I1.providedBy(C), False) |
4186 | self.assertEqual(I1.providedBy(c), True) |
4187 | @@ -66,12 +67,16 @@ |
4188 | def testInterfaceSub(self): |
4189 | class I1(Interface): |
4190 | pass |
4191 | + |
4192 | class I2(I1): |
4193 | pass |
4194 | + |
4195 | class C(object): |
4196 | implements(I2) |
4197 | + |
4198 | class D(object): |
4199 | implements(I1) |
4200 | + |
4201 | c = C() |
4202 | self.assertEqual(I1.providedBy(c), True) |
4203 | self.assertEqual(I2.providedBy(c), True) |
4204 | @@ -87,12 +92,12 @@ |
4205 | |
4206 | class I1(Interface): |
4207 | pass |
4208 | + |
4209 | class C(object): |
4210 | implements(I1) |
4211 | + |
4212 | c = C() |
4213 | - class X(object): |
4214 | - pass |
4215 | - x = X() |
4216 | + x = object() |
4217 | self.assertEqual(I1.providedBy(x), False) |
4218 | self.assertEqual(I1.providedBy(C), False) |
4219 | self.assertEqual(I1.providedBy(c), True) |
4220 | @@ -105,12 +110,16 @@ |
4221 | |
4222 | class I1(Interface): |
4223 | pass |
4224 | + |
4225 | class I2(I1): |
4226 | pass |
4227 | + |
4228 | class C(object): |
4229 | implements(I2) |
4230 | + |
4231 | class D(object): |
4232 | implements(I1) |
4233 | + |
4234 | c = C() |
4235 | self.assertEqual(I1.providedBy(c), True) |
4236 | self.assertEqual(I2.providedBy(c), True) |
4237 | |
4238 | === modified file 'tests/test_datatypes.py' |
4239 | --- tests/test_datatypes.py 2012-03-12 20:54:34 +0000 |
4240 | +++ tests/test_datatypes.py 2012-05-04 16:37:18 +0000 |
4241 | @@ -2,9 +2,6 @@ |
4242 | import datetime |
4243 | import locale |
4244 | import unittest |
4245 | -import sys |
4246 | - |
4247 | -from gtk import gdk |
4248 | |
4249 | from kiwi.datatypes import converter, ValidationError, ValueUnset, \ |
4250 | Decimal, BaseConverter |
4251 | @@ -15,19 +12,23 @@ |
4252 | from kiwi.ui import proxywidget |
4253 | proxywidget # pyflakes |
4254 | |
4255 | +fake = type('fake', (object,), {}) |
4256 | + |
4257 | + |
4258 | def set_locale(category, name): |
4259 | # set the date format to the spanish one |
4260 | try: |
4261 | - rv = locale.setlocale(category, name) |
4262 | + locale.setlocale(category, name) |
4263 | except locale.Error: |
4264 | print 'skipping %s, locale not available' % name |
4265 | return False |
4266 | return True |
4267 | |
4268 | -fake = type('fake', (object,), {}) |
4269 | + |
4270 | class FakeConverter(BaseConverter): |
4271 | type = fake |
4272 | |
4273 | + |
4274 | class RegistryTest(unittest.TestCase): |
4275 | def testAdd(self): |
4276 | self.assertRaises(TypeError, converter.add, object) |
4277 | @@ -53,6 +54,7 @@ |
4278 | conv = converter.get_converter(object) |
4279 | self.assertTrue(conv in converters) |
4280 | |
4281 | + |
4282 | class BoolTest(unittest.TestCase): |
4283 | def setUp(self): |
4284 | self.conv = converter.get_converter(bool) |
4285 | @@ -70,6 +72,7 @@ |
4286 | # you are not supposed to pass something that is not a string |
4287 | self.assertRaises(AttributeError, self.conv.from_string, None) |
4288 | |
4289 | + |
4290 | class DateTest(unittest.TestCase): |
4291 | def setUp(self): |
4292 | set_locale(locale.LC_TIME, 'C') |
4293 | @@ -217,6 +220,7 @@ |
4294 | recoverd_var = cPickle.loads(pickled_var) |
4295 | self.assertEqual(recoverd_var.format(), '$12,123.45') |
4296 | |
4297 | + |
4298 | class UnicodeTest(unittest.TestCase): |
4299 | def setUp(self): |
4300 | self.conv = converter.get_converter(unicode) |
4301 | @@ -230,6 +234,7 @@ |
4302 | self.assertEqual(self.conv.as_string(u'foobar'), 'foobar') |
4303 | self.assertEqual(self.conv.as_string(u'\xe4'), '\xc3\xa4') |
4304 | |
4305 | + |
4306 | class IntTest(unittest.TestCase): |
4307 | def setUp(self): |
4308 | self.conv = converter.get_converter(int) |
4309 | @@ -251,6 +256,7 @@ |
4310 | |
4311 | self.assertEqual(self.conv.as_string(123456789), '123456789') |
4312 | |
4313 | + |
4314 | class FloatTest(unittest.TestCase): |
4315 | def setUp(self): |
4316 | self.conv = converter.get_converter(float) |
4317 | @@ -376,6 +382,7 @@ |
4318 | self.assertEqual(self.conv.as_string(Decimal('10000000.0')), |
4319 | '10 000 000,0') |
4320 | |
4321 | + |
4322 | class EnumTest(unittest.TestCase): |
4323 | def testSimple(self): |
4324 | class status(enum): |
4325 | |
4326 | === modified file 'tests/test_dateentry.py' |
4327 | --- tests/test_dateentry.py 2006-08-03 13:51:40 +0000 |
4328 | +++ tests/test_dateentry.py 2012-05-04 16:37:18 +0000 |
4329 | @@ -3,6 +3,7 @@ |
4330 | |
4331 | from kiwi.ui.dateentry import DateEntry |
4332 | |
4333 | + |
4334 | class TestDateEntry(unittest.TestCase): |
4335 | def setUp(self): |
4336 | self.date = datetime.date.today() |
4337 | |
4338 | === modified file 'tests/test_desktopparser.py' |
4339 | --- tests/test_desktopparser.py 2006-03-27 13:23:13 +0000 |
4340 | +++ tests/test_desktopparser.py 2012-05-04 16:37:18 +0000 |
4341 | @@ -12,6 +12,7 @@ |
4342 | Categories=GNOME;Application;AudioVideo |
4343 | """ |
4344 | |
4345 | + |
4346 | class TestTotem(unittest.TestCase): |
4347 | def setUp(self): |
4348 | self.parser = DesktopParser() |
4349 | |
4350 | === modified file 'tests/test_log.py' |
4351 | --- tests/test_log.py 2007-01-29 18:22:25 +0000 |
4352 | +++ tests/test_log.py 2012-05-04 16:37:18 +0000 |
4353 | @@ -7,6 +7,7 @@ |
4354 | |
4355 | from kiwi.log import Logger, set_log_file |
4356 | |
4357 | + |
4358 | class LogTest(unittest.TestCase): |
4359 | def setUp(self): |
4360 | self.filename = tempfile.mktemp() |
4361 | @@ -26,7 +27,6 @@ |
4362 | self.assertEqual(len(lines), 1) |
4363 | self.failUnless('sliff' in lines[0]) |
4364 | |
4365 | - |
4366 | def testStdErr(self): |
4367 | root = logging.getLogger() |
4368 | stream = root.handlers[0] |
4369 | |
4370 | === modified file 'tests/test_masks.py' |
4371 | --- tests/test_masks.py 2010-06-24 20:06:00 +0000 |
4372 | +++ tests/test_masks.py 2012-05-04 16:37:18 +0000 |
4373 | @@ -8,42 +8,44 @@ |
4374 | from kiwi.ui.entry import KiwiEntry |
4375 | |
4376 | SPECIAL_KEYS = { |
4377 | - '/' : 'slash', |
4378 | - '+' : 'plus', |
4379 | - '-' : 'minus', |
4380 | - '(' : 'parenleft', |
4381 | - ')' : 'parenright', |
4382 | - ' ' : 'space', |
4383 | -} |
4384 | + '/': 'slash', |
4385 | + '+': 'plus', |
4386 | + '-': 'minus', |
4387 | + '(': 'parenleft', |
4388 | + ')': 'parenright', |
4389 | + ' ': 'space', |
4390 | + } |
4391 | |
4392 | DELAY = 0.1 |
4393 | |
4394 | + |
4395 | def send_backspace(widget): |
4396 | event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) |
4397 | event.keyval = int(keysyms.BackSpace) |
4398 | event.hardware_keycode = 22 |
4399 | event.window = widget.window |
4400 | -# widget.event(event) |
4401 | + #widget.event(event) |
4402 | gtk.main_do_event(event) |
4403 | refresh_gui(DELAY) |
4404 | |
4405 | + |
4406 | def send_delete(widget): |
4407 | event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) |
4408 | event.keyval = int(keysyms.Delete) |
4409 | event.hardware_keycode = 107 |
4410 | event.window = widget.window |
4411 | gtk.main_do_event(event) |
4412 | -# widget.event(event) |
4413 | + #widget.event(event) |
4414 | refresh_gui(DELAY) |
4415 | |
4416 | |
4417 | def send_key(widget, key): |
4418 | if isinstance(key, str) and key.isdigit(): |
4419 | - key = 'KP_'+key |
4420 | + key = 'KP_' + key |
4421 | elif isinstance(key, str) and key in SPECIAL_KEYS: |
4422 | key = SPECIAL_KEYS[key] |
4423 | |
4424 | - keysym = getattr(keysyms, key) |
4425 | + keysym = getattr(keysyms, key) |
4426 | |
4427 | # Key press |
4428 | event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) |
4429 | @@ -53,17 +55,22 @@ |
4430 | |
4431 | refresh_gui(DELAY) |
4432 | |
4433 | + |
4434 | def insert_text(widget, text): |
4435 | for i in text: |
4436 | send_key(widget, i) |
4437 | |
4438 | + |
4439 | LEFT, RIGHT = -1, 1 |
4440 | + |
4441 | + |
4442 | def move(entry, direction): |
4443 | entry.emit('move-cursor', gtk.MOVEMENT_VISUAL_POSITIONS, direction, False) |
4444 | |
4445 | + |
4446 | def select(entry, start, end): |
4447 | entry.set_position(start) |
4448 | - entry.emit('move-cursor', gtk.MOVEMENT_VISUAL_POSITIONS, end-start, True) |
4449 | + entry.emit('move-cursor', gtk.MOVEMENT_VISUAL_POSITIONS, end - start, True) |
4450 | |
4451 | |
4452 | class MasksDelegate(Delegate): |
4453 | @@ -76,7 +83,6 @@ |
4454 | self.win.show_all() |
4455 | |
4456 | |
4457 | - |
4458 | class TestMasks(unittest.TestCase): |
4459 | def setUp(self): |
4460 | self.delegate = MasksDelegate() |
4461 | @@ -129,7 +135,6 @@ |
4462 | insert_text(entry, '1234567890') |
4463 | self.assertEqual(entry.get_text(), '(12) 3456-7890') |
4464 | |
4465 | - |
4466 | def testMovementTabsEmptyMask(self): |
4467 | entry = self.entry |
4468 | entry.set_mask('(00) 0000-0000') |
4469 | @@ -173,7 +178,6 @@ |
4470 | move(entry, LEFT) |
4471 | self.assertEqual(entry.get_position(), 3) |
4472 | |
4473 | - |
4474 | # Home |
4475 | entry.emit('move-cursor', gtk.MOVEMENT_DISPLAY_LINE_ENDS, -1, False) |
4476 | self.assertEqual(entry.get_position(), 1) |
4477 | @@ -220,7 +224,6 @@ |
4478 | insert_text(entry, '4') |
4479 | self.assertEqual(entry.get_text(), '(1 ) 2 3 -4 ') |
4480 | |
4481 | - |
4482 | # FIXME: Delete/Backspace does not work on windows or xvfb |
4483 | def testBackspace(self): |
4484 | if 1: |
4485 | @@ -320,4 +323,3 @@ |
4486 | |
4487 | if __name__ == '__main__': |
4488 | unittest.main() |
4489 | - |
4490 | |
4491 | === added file 'tests/test_pep8.py' |
4492 | --- tests/test_pep8.py 1970-01-01 00:00:00 +0000 |
4493 | +++ tests/test_pep8.py 2012-05-04 16:37:18 +0000 |
4494 | @@ -0,0 +1,50 @@ |
4495 | +import unittest |
4496 | + |
4497 | +import pep8 |
4498 | + |
4499 | +from utils import SourceTest |
4500 | + |
4501 | +ERRORS = [ |
4502 | + 'E111', # indentation is not a multiple of four |
4503 | + 'E112', # expected an indented block |
4504 | + 'E113', # unexpected indentation |
4505 | + 'E201', # whitespace after '{' |
4506 | + 'E202', # whitespace before ')' |
4507 | + 'E203', # whitespace before ':' |
4508 | + 'E211', # whitespace before '(' |
4509 | + 'E221', # multiple spaces before operator |
4510 | + 'E225', # missing whitespace around operator |
4511 | + 'E231', # E231 missing whitespace after ','/':' |
4512 | + 'E241', # multiple spaces after operator |
4513 | + 'E251', # no spaces around keyword / parameter equals |
4514 | + 'E262', # inline comment should start with '# ' |
4515 | + 'W291', # trailing whitespace |
4516 | + 'W292', # no newline at end of file |
4517 | + 'W293', # blank line contains whitespace |
4518 | + 'E301', # expected 1 blank line, found 0 |
4519 | + 'E302', # expected 2 blank lines, found 1 |
4520 | + 'E303', # too many blank lines |
4521 | + 'W391', # blank line at end of file |
4522 | + 'E401', # multiple imports on one line |
4523 | + 'W601', # in instead of dict.has_key |
4524 | + 'W602', # deprecated form of raising exception |
4525 | + 'W603', # '<>' is deprecated, use '!='" |
4526 | + 'W604', # backticks are deprecated, use 'repr()' |
4527 | + 'E701', # multiple statements on one line (colon) |
4528 | + 'E702', # multiple statements on one line (semicolon) |
4529 | + ] |
4530 | + |
4531 | + |
4532 | +class TestPEP8(SourceTest, unittest.TestCase): |
4533 | + """Check for pep8 problems on kiwi sources""" |
4534 | + |
4535 | + def check_filename(self, root, filename): |
4536 | + pep8.process_options([ |
4537 | + '--repeat', |
4538 | + '--select=%s' % (','.join(ERRORS), ), filename |
4539 | + ]) |
4540 | + pep8.input_file(filename) |
4541 | + result = pep8.get_count() |
4542 | + if result: |
4543 | + raise AssertionError("ERROR: %d PEP8 errors in %s" % (result, |
4544 | + filename)) |
4545 | |
4546 | === modified file 'tests/test_proxy.py' |
4547 | --- tests/test_proxy.py 2012-02-21 12:37:13 +0000 |
4548 | +++ tests/test_proxy.py 2012-05-04 16:37:18 +0000 |
4549 | @@ -1,10 +1,8 @@ |
4550 | -import sys |
4551 | import unittest |
4552 | |
4553 | from gtk import gdk |
4554 | |
4555 | from kiwi import ValueUnset |
4556 | -from kiwi.datatypes import converter |
4557 | from kiwi.python import Settable |
4558 | from kiwi.ui.proxy import Proxy |
4559 | from kiwi.ui.widgets.button import ProxyButton |
4560 | @@ -17,6 +15,7 @@ |
4561 | from kiwi.ui.widgets.textview import ProxyTextView |
4562 | from kiwi.ui.widgets.combo import ProxyComboEntry, ProxyComboBox |
4563 | |
4564 | + |
4565 | class FakeView(object): |
4566 | def __init__(self): |
4567 | self.widgets = [] |
4568 | @@ -37,6 +36,7 @@ |
4569 | def handler_unblock(self, *args): |
4570 | pass |
4571 | |
4572 | + |
4573 | class Model(Settable): |
4574 | def __init__(self): |
4575 | Settable.__init__(self, |
4576 | @@ -52,6 +52,7 @@ |
4577 | combobox='CB1', |
4578 | button='button') |
4579 | |
4580 | + |
4581 | class TestProxy(unittest.TestCase): |
4582 | def setUp(self): |
4583 | self.view = FakeView() |
4584 | @@ -75,11 +76,11 @@ |
4585 | self.view.vscale.get_adjustment().upper = 250 |
4586 | |
4587 | self.comboentry = self.view.add('comboentry', str, ProxyComboEntry) |
4588 | - self.comboentry.prefill(['CE1','CE2','CE3']) |
4589 | + self.comboentry.prefill(['CE1', 'CE2', 'CE3']) |
4590 | self.comboentry.show() |
4591 | |
4592 | self.combobox = self.view.add('combobox', str, ProxyComboBox) |
4593 | - self.combobox.prefill(['CB1','CB2','CB3']) |
4594 | + self.combobox.prefill(['CB1', 'CB2', 'CB3']) |
4595 | self.combobox.show() |
4596 | |
4597 | self.model = Model() |
4598 | |
4599 | === added file 'tests/test_pyflakes.py' |
4600 | --- tests/test_pyflakes.py 1970-01-01 00:00:00 +0000 |
4601 | +++ tests/test_pyflakes.py 2012-05-04 16:37:18 +0000 |
4602 | @@ -0,0 +1,81 @@ |
4603 | +import _ast |
4604 | +import compiler |
4605 | +import sys |
4606 | +import unittest |
4607 | + |
4608 | +import pyflakes |
4609 | + |
4610 | +from utils import SourceTest |
4611 | + |
4612 | + |
4613 | +class TestPyflakes(SourceTest, unittest.TestCase): |
4614 | + """Check for pyflakes problems on kiwi sources""" |
4615 | + |
4616 | + def setUp(self): |
4617 | + self.checker = __import__('pyflakes.checker').checker |
4618 | + |
4619 | + def check_filename(self, root, filename): |
4620 | + warnings = [] |
4621 | + msgs = [] |
4622 | + result = 0 |
4623 | + try: |
4624 | + fd = file(filename, 'U') |
4625 | + try: |
4626 | + result = self._check(fd.read(), filename, warnings) |
4627 | + finally: |
4628 | + fd.close() |
4629 | + except IOError, msg: |
4630 | + print >> sys.stderr, "%s: %s" % (filename, msg.args[1]) |
4631 | + result = 1 |
4632 | + |
4633 | + warnings.sort(lambda a, b: cmp(a.lineno, b.lineno)) |
4634 | + for warning in warnings: |
4635 | + msg = str(warning).replace(root, '') |
4636 | + print msg |
4637 | + msgs.append(msg) |
4638 | + if result: |
4639 | + raise AssertionError("%d warnings:\n%s\n" % (len(msgs), |
4640 | + '\n'.join(msgs))) |
4641 | + |
4642 | + # stolen from pyflakes |
4643 | + def _check(self, codeString, filename, warnings): |
4644 | + try: |
4645 | + if pyflakes.__version__ == '0.4.0': |
4646 | + compile(codeString, filename, "exec") |
4647 | + tree = compiler.parse(codeString) |
4648 | + else: |
4649 | + tree = compile(codeString, |
4650 | + filename, "exec", _ast.PyCF_ONLY_AST) |
4651 | + except (SyntaxError, IndentationError), value: |
4652 | + msg = value.args[0] |
4653 | + |
4654 | + (lineno, offset, text) = value.lineno, value.offset, value.text |
4655 | + |
4656 | + # If there's an encoding problem with the file, the text is None. |
4657 | + if text is None: |
4658 | + # Avoid using msg, since for the only known case, it contains a |
4659 | + # bogus message that claims the encoding the file declared was |
4660 | + # unknown. |
4661 | + print >> sys.stderr, "%s: problem decoding source" % (filename) |
4662 | + else: |
4663 | + line = text.splitlines()[-1] |
4664 | + |
4665 | + if offset is not None: |
4666 | + offset = offset - (len(text) - len(line)) |
4667 | + |
4668 | + print >> sys.stderr, '%s:%d: %s' % (filename, lineno, msg) |
4669 | + print >> sys.stderr, line |
4670 | + |
4671 | + if offset is not None: |
4672 | + print >> sys.stderr, " " * offset, "^" |
4673 | + |
4674 | + return 1 |
4675 | + except UnicodeError, msg: |
4676 | + print >> sys.stderr, 'encoding error at %r: %s' % (filename, msg) |
4677 | + return 1 |
4678 | + else: |
4679 | + # Okay, it's syntactically valid. Now parse it into an ast |
4680 | + # and check it. |
4681 | + w = self.checker.Checker(tree, filename) |
4682 | + warnings.extend(w.messages) |
4683 | + return len(warnings) |
4684 | |
4685 | === modified file 'tests/test_python.py' |
4686 | --- tests/test_python.py 2007-05-21 19:10:59 +0000 |
4687 | +++ tests/test_python.py 2012-05-04 16:37:18 +0000 |
4688 | @@ -2,6 +2,7 @@ |
4689 | |
4690 | from kiwi.python import AttributeForwarder, slicerange, enum |
4691 | |
4692 | + |
4693 | class SliceTest(unittest.TestCase): |
4694 | def genlist(self, limit, start, stop=None, step=None): |
4695 | if stop == None: |
4696 | @@ -27,12 +28,15 @@ |
4697 | def testStartStopStep(self): |
4698 | self.assertEqual(self.genlist(10, 0, 10, 2), range(10)[0:10:2]) |
4699 | |
4700 | + |
4701 | class Status(enum): |
4702 | OPEN, CLOSE = range(2) |
4703 | |
4704 | + |
4705 | class Color(enum): |
4706 | RED, GREEN, BLUE = range(3) |
4707 | |
4708 | + |
4709 | class EnumTest(unittest.TestCase): |
4710 | def testEnums(self): |
4711 | self.failUnless(issubclass(enum, int)) |
4712 | |
4713 | === modified file 'tests/test_tasklet.py' |
4714 | --- tests/test_tasklet.py 2007-06-09 14:53:52 +0000 |
4715 | +++ tests/test_tasklet.py 2012-05-04 16:37:18 +0000 |
4716 | @@ -10,8 +10,9 @@ |
4717 | |
4718 | |
4719 | class C(gobject.GObject): |
4720 | - __gsignals__ = { 'my-signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, |
4721 | - (gobject.TYPE_INT,)) } |
4722 | + __gsignals__ = {'my-signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, |
4723 | + (gobject.TYPE_INT,))} |
4724 | + |
4725 | def do_my_signal(self, arg): |
4726 | self.arg = arg |
4727 | |
4728 | @@ -75,7 +76,9 @@ |
4729 | self.assertEqual(task.return_value, "return-val") |
4730 | ## check that elapsed time aproximately 100 ms second, give or take 50 ms |
4731 | ## (glib doesn't guarantee precise timing) |
4732 | - self.assert_(math.fabs((t2 - t1) - 0.1) < 0.05, "elapsed time was %f, expected 0.1" % ((t2 - t1),)) |
4733 | + self.assert_(math.fabs((t2 - t1) - 0.1) < 0.05, "elapsed time was %f, expected 0.1" % |
4734 | + ((t2 - t1),)) |
4735 | + |
4736 | |
4737 | class TestMessages(unittest.TestCase): |
4738 | def testPing(self): |
4739 | @@ -96,6 +99,7 @@ |
4740 | self.assertEqual(task.state, tasklet.Tasklet.STATE_ZOMBIE) |
4741 | self.assertEqual(task.return_value, 123) |
4742 | |
4743 | + |
4744 | class TestIO(unittest.TestCase): |
4745 | def testPipe(self): |
4746 | # |
4747 | @@ -134,7 +138,7 @@ |
4748 | write_chan.set_flags(gobject.IO_FLAG_NONBLOCK) |
4749 | write_chan.set_encoding(None) |
4750 | write_chan.set_buffered(False) |
4751 | - writer = tasklet.run(pipe_writer(write_chan, chr(123))) |
4752 | + tasklet.run(pipe_writer(write_chan, chr(123))) |
4753 | |
4754 | mainloop = gobject.MainLoop() |
4755 | reader.add_join_callback(lambda task, retval: mainloop.quit()) |
4756 | @@ -143,6 +147,7 @@ |
4757 | self.assertEqual(reader.state, tasklet.Tasklet.STATE_ZOMBIE) |
4758 | self.assertEqual(reader.return_value, chr(123)) |
4759 | |
4760 | + |
4761 | class TestCallback(unittest.TestCase): |
4762 | def testCallback(self): |
4763 | |
4764 | |
4765 | === modified file 'tests/test_ui.py' |
4766 | --- tests/test_ui.py 2007-07-16 13:10:22 +0000 |
4767 | +++ tests/test_ui.py 2012-05-04 16:37:18 +0000 |
4768 | @@ -3,13 +3,16 @@ |
4769 | import sys |
4770 | import unittest |
4771 | |
4772 | + |
4773 | def setup(self, rootdir): |
4774 | self._dir = os.getcwd() |
4775 | os.chdir(rootdir) |
4776 | |
4777 | + |
4778 | def teardown(self): |
4779 | os.chdir(self._dir) |
4780 | |
4781 | + |
4782 | def test_filename(rootdir, filename): |
4783 | cmd = '%s %s -v %s' % (sys.executable, |
4784 | os.path.join(rootdir, 'bin', 'kiwi-ui-test'), |
4785 | @@ -20,6 +23,7 @@ |
4786 | if status != 0: |
4787 | raise AssertionError("UI Test %s failed" % filename) |
4788 | |
4789 | + |
4790 | def create(): |
4791 | testdir = os.path.dirname(__file__) |
4792 | uidir = os.path.join(testdir, 'ui') |
4793 | @@ -33,8 +37,6 @@ |
4794 | continue |
4795 | name = 'test_' + filename[:-7] |
4796 | |
4797 | - full = os.path.join(uidir, filename) |
4798 | - |
4799 | func = lambda self, filename=filename: test_filename(rootdir, filename) |
4800 | try: |
4801 | func.__name__ = name |
4802 | @@ -46,4 +48,3 @@ |
4803 | # Disable UI tests on win32, they do not quite work yet. |
4804 | if sys.platform != 'win32': |
4805 | TestUI = create() |
4806 | - |
4807 | |
4808 | === modified file 'tests/utils.py' |
4809 | --- tests/utils.py 2006-06-09 13:49:55 +0000 |
4810 | +++ tests/utils.py 2012-05-04 16:37:18 +0000 |
4811 | @@ -1,3 +1,4 @@ |
4812 | +import fnmatch |
4813 | import os |
4814 | import sys |
4815 | import time |
4816 | @@ -10,6 +11,7 @@ |
4817 | |
4818 | import gtk |
4819 | |
4820 | + |
4821 | def refresh_gui(delay=0): |
4822 | while gtk.events_pending(): |
4823 | gtk.main_iteration_do(block=False) |
4824 | @@ -21,3 +23,60 @@ |
4825 | |
4826 | from kiwi.environ import environ |
4827 | environ.add_resource('glade', dir) |
4828 | + |
4829 | +from kiwi.python import ClassInittableObject |
4830 | + |
4831 | +import kiwi |
4832 | + |
4833 | + |
4834 | +def _list_recursively(directory, pattern): |
4835 | + matches = [] |
4836 | + for root, dirnames, filenames in os.walk(directory): |
4837 | + for filename in fnmatch.filter(filenames, pattern): |
4838 | + # skip backup files |
4839 | + if (filename.startswith('.#') or |
4840 | + filename.endswith('~')): |
4841 | + continue |
4842 | + matches.append(os.path.join(root, filename)) |
4843 | + |
4844 | + return matches |
4845 | + |
4846 | + |
4847 | +def _get_kiwi_sources(root): |
4848 | + for dirpath in ['kiwi', 'tests']: |
4849 | + path = os.path.join(root, dirpath) |
4850 | + for fname in _list_recursively(path, '*.py'): |
4851 | + if fname.endswith('__init__.py'): |
4852 | + continue |
4853 | + yield fname |
4854 | + |
4855 | + for module in ['setup', 'kiwiwidgets']: |
4856 | + yield os.path.join(root, module + '.py') |
4857 | + |
4858 | + |
4859 | +class SourceTest(ClassInittableObject): |
4860 | + @classmethod |
4861 | + def __class_init__(cls, namespace): |
4862 | + root = os.path.dirname(os.path.dirname(kiwi.__file__)) + '/' |
4863 | + cls.root = root |
4864 | + for filename in _get_kiwi_sources(root): |
4865 | + testname = filename[len(root):] |
4866 | + |
4867 | + if not cls.filename_filter(testname): |
4868 | + continue |
4869 | + |
4870 | + testname = testname[:-3].replace('/', '_') |
4871 | + name = 'test_%s' % (testname, ) |
4872 | + func = lambda s, r=root, f=filename: s.check_filename(r, f) |
4873 | + func.__name__ = name |
4874 | + setattr(cls, name, func) |
4875 | + |
4876 | + @classmethod |
4877 | + def filename_filter(cls, filename): |
4878 | + if cls.__name__ == 'SourceTest': |
4879 | + return False |
4880 | + else: |
4881 | + return True |
4882 | + |
4883 | + def check_filename(self, root, filename): |
4884 | + pass |