Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2011-10-06 14:58:53 (GMT)
committer Daniel Drake <dsd@laptop.org>2011-10-09 13:56:35 (GMT)
commit0e63a7f5eea9de7133b68cb64920bd6837fc323c (patch)
treef7f3a9a98bdb179e8d1ce81cb2e364dd324d7459
parente619c95ed6762353bbcb4bfd1fbbdf84821d2547 (diff)
Fix presence detection of keyboard layouts/options
"foo is []" is not a valid way of checking if a list is empty as this code intends. "foo" alone as a boolean operator is an equivalent length check, and also serves as a "is not None" check too. PEP8 also confirms this approach: For sequences, (strings, lists, tuples), use the fact that empty sequences are false. Signed-off-by: Daniel Drake <dsd@laptop.org> Acked-By: Sascha Silbe <silbe@activitycentral.com> Acked-by: Simon Schampijer <simon@laptop.org>
-rwxr-xr-xbin/sugar-session5
1 files changed, 2 insertions, 3 deletions
diff --git a/bin/sugar-session b/bin/sugar-session
index 4b714c3..a0ec14f 100755
--- a/bin/sugar-session
+++ b/bin/sugar-session
@@ -147,8 +147,7 @@ def setup_keyboard_cb():
layouts_list.append(layout.split('(')[0])
variants_list.append(layout.split('(')[1][:-1])
- if layouts_list is not None and layouts_list is not [] \
- and variants_list is not None and variants_list is not []:
+ if layouts_list and variants_list:
configrec.set_layouts(layouts_list)
configrec.set_variants(variants_list)
@@ -159,7 +158,7 @@ def setup_keyboard_cb():
options = gconf_client.get_list(\
'/desktop/sugar/peripherals/keyboard/options', gconf.VALUE_STRING)
- if options is not [] and options is not None:
+ if options:
configrec.set_options(options)
configrec.activate(engine)