[Sugar-devel] [PATCH sugar 06/21] PEP8 cleanup: ensure lines are shorter than 80 characters
Sascha Silbe
sascha-pgp at silbe.org
Sat Oct 16 18:20:08 EDT 2010
This is important for Sugar because the XO has a small screen where long lines
would make the code hard to understand (because you need to constantly scroll horizontally).
Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
diff --git a/extensions/cpsection/datetime/view.py b/extensions/cpsection/datetime/view.py
index 72fdad1..9c70e9f 100644
--- a/extensions/cpsection/datetime/view.py
+++ b/extensions/cpsection/datetime/view.py
@@ -51,7 +51,8 @@ class TimeZone(SectionView):
self._entry.show()
self._scrolled_window = gtk.ScrolledWindow()
- self._scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ self._scrolled_window.set_policy(gtk.POLICY_NEVER,
+ gtk.POLICY_AUTOMATIC)
self._scrolled_window.set_shadow_type(gtk.SHADOW_IN)
self._store = gtk.ListStore(gobject.TYPE_STRING)
diff --git a/extensions/cpsection/frame/view.py b/extensions/cpsection/frame/view.py
index 5c9d473..8b4ab83 100644
--- a/extensions/cpsection/frame/view.py
+++ b/extensions/cpsection/frame/view.py
@@ -149,9 +149,9 @@ class Frame(SectionView):
self._corner_delay_is_valid = True
self._edge_delay_is_valid = True
self.needs_restart = False
- self._corner_delay_change_handler = self._corner_delay_slider.connect( \
+ self._corner_delay_change_handler = self._corner_delay_slider.connect(
'value-changed', self.__corner_delay_changed_cb)
- self._edge_delay_change_handler = self._edge_delay_slider.connect( \
+ self._edge_delay_change_handler = self._edge_delay_slider.connect(
'value-changed', self.__edge_delay_changed_cb)
def undo(self):
diff --git a/extensions/cpsection/keyboard/model.py b/extensions/cpsection/keyboard/model.py
index 82456d3..4f44aff 100644
--- a/extensions/cpsection/keyboard/model.py
+++ b/extensions/cpsection/keyboard/model.py
@@ -77,8 +77,8 @@ class KeyboardManager(object):
def get_options_group(self):
"""Return list of supported options for switching keyboard group"""
options = []
- self._configregistry.foreach_option(_GROUP_NAME, self._populate_one, \
- options)
+ self._configregistry.foreach_option(_GROUP_NAME, self._populate_one,
+ options)
options.sort()
return options
diff --git a/extensions/cpsection/keyboard/view.py b/extensions/cpsection/keyboard/view.py
index dacc092..d1d9af2 100644
--- a/extensions/cpsection/keyboard/view.py
+++ b/extensions/cpsection/keyboard/view.py
@@ -241,7 +241,8 @@ class Keyboard(SectionView):
return False
def _setup_group_switch_option(self):
- """Adds the controls for changing the group switch option of keyboard"""
+ """Adds the controls for changing the group switch option of keyboard
+ """
separator_group_option = gtk.HSeparator()
self._vbox.pack_start(separator_group_option, expand=False)
separator_group_option.show_all()
diff --git a/extensions/cpsection/language/view.py b/extensions/cpsection/language/view.py
index 1bd77f8..c56ffee 100644
--- a/extensions/cpsection/language/view.py
+++ b/extensions/cpsection/language/view.py
@@ -54,9 +54,9 @@ class Language(SectionView):
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
- explanation = gettext.gettext("Add languages in the order you prefer." \
- " If a translation is not available,"\
- " the next in the list will be used.")
+ explanation = gettext.gettext('Add languages in the order you prefer.'
+ ' If a translation is not available, the next in the list will be'
+ ' used.')
self._text = gtk.Label(explanation)
self._text.set_width_chars(100)
self._text.set_line_wrap(True)
diff --git a/extensions/cpsection/network/view.py b/extensions/cpsection/network/view.py
index 447a51d..fc3c993 100644
--- a/extensions/cpsection/network/view.py
+++ b/extensions/cpsection/network/view.py
@@ -228,7 +228,7 @@ class Network(SectionView):
if self._jabber_sid:
gobject.source_remove(self._jabber_sid)
self._jabber_sid = gobject.timeout_add(_APPLY_TIMEOUT,
- self.__jabber_timeout_cb, widget)
+ self.__jabber_timeout_cb, widget)
def __jabber_timeout_cb(self, widget):
self._jabber_sid = 0
diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
index 1e1dd92..21b0b65 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -196,14 +196,17 @@ class UpdateModel(gobject.GObject):
logging.debug('UpdateModel._cancel_checking')
total = len(bundleregistry.get_registry())
current = total - len(self._bundles_to_check)
- self.emit('progress', UpdateModel.ACTION_CHECKING, '', current, current)
+ self.emit('progress', UpdateModel.ACTION_CHECKING, '', current,
+ current)
self._bundles_to_check = None
self._cancelling = False
def _cancel_updating(self):
logging.debug('UpdateModel._cancel_updating')
- current = self._total_bundles_to_update - len(self._bundles_to_update) - 1
- self.emit('progress', UpdateModel.ACTION_UPDATING, '', current, current)
+ current = (self._total_bundles_to_update -
+ len(self._bundles_to_update) - 1)
+ self.emit('progress', UpdateModel.ACTION_UPDATING, '', current,
+ current)
if self._downloader is not None:
self._downloader.cancel()
diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
index 2bec3f0..6d5fe7c 100644
--- a/extensions/cpsection/updater/view.py
+++ b/extensions/cpsection/updater/view.py
@@ -161,7 +161,8 @@ class ActivityUpdater(SectionView):
self._model.check_updates()
def __install_button_clicked_cb(self, button):
- self._top_label.set_markup('<big>%s</big>' % _('Installing updates...'))
+ self._top_label.set_markup('<big>%s</big>' % _(
+ 'Installing updates...'))
self._model.update(self._update_box.get_bundles_to_update())
def __cancel_button_clicked_cb(self, button):
diff --git a/extensions/deviceicon/battery.py b/extensions/deviceicon/battery.py
index e947ccc..85ceb8f 100644
--- a/extensions/deviceicon/battery.py
+++ b/extensions/deviceicon/battery.py
@@ -93,7 +93,8 @@ class DeviceView(TrayIcon):
else:
status = _STATUS_FULLY_CHARGED
- self.icon.props.icon_name = get_icon_state(name, current_level, step=-5)
+ self.icon.props.icon_name = get_icon_state(name, current_level,
+ step=-5)
self.icon.props.xo_color = xo_color
self.icon.props.badge_name = badge_name
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index f3f2322..5b7696d 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -108,7 +108,8 @@ class WirelessPalette(Palette):
self._disconnect_item = MenuItem(_('Disconnect...'))
icon = Icon(icon_size=gtk.ICON_SIZE_MENU, icon_name='media-eject')
self._disconnect_item.set_image(icon)
- self._disconnect_item.connect('activate', self.__disconnect_activate_cb)
+ self._disconnect_item.connect('activate',
+ self.__disconnect_activate_cb)
self.menu.append(self._disconnect_item)
def set_connecting(self):
@@ -327,7 +328,8 @@ class GsmPalette(Palette):
def add_alert(self, error, suggestion):
self._failed_connection = True
- self._toggle_state_item.get_child().set_label(_('Try connection again'))
+ self._toggle_state_item.get_child().set_label(
+ _('Try connection again'))
title = _('Error: %s') % error
self.error_title_label.set_markup('<b>%s</b>' % title)
@@ -448,7 +450,8 @@ class WirelessDeviceView(ToolButton):
return
self._active_ap_op = active_ap_op
active_ap = self._bus.get_object(_NM_SERVICE, active_ap_op)
- props = dbus.Interface(active_ap, 'org.freedesktop.DBus.Properties')
+ props = dbus.Interface(active_ap,
+ 'org.freedesktop.DBus.Properties')
props.GetAll(_NM_ACCESSPOINT_IFACE, byte_arrays=True,
reply_handler=self.__get_all_ap_props_reply_cb,
@@ -552,7 +555,8 @@ class WirelessDeviceView(ToolButton):
self._icon.props.pulsing = True
elif state == network.DEVICE_STATE_ACTIVATED:
address = self._device_props.Get(_NM_DEVICE_IFACE, 'Ip4Address')
- self._palette.set_connected_with_frequency(self._frequency, address)
+ self._palette.set_connected_with_frequency(self._frequency,
+ address)
self._icon.props.pulsing = False
else:
self._icon.props.badge_name = None
@@ -683,7 +687,8 @@ class OlpcMeshDeviceView(ToolButton):
def __deactivate_connection(self, palette, data=None):
obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
netmgr = dbus.Interface(obj, _NM_IFACE)
- netmgr_props = dbus.Interface(netmgr, 'org.freedesktop.DBus.Properties')
+ netmgr_props = dbus.Interface(netmgr,
+ 'org.freedesktop.DBus.Properties')
active_connections_o = netmgr_props.Get(_NM_IFACE,
'ActiveConnections')
@@ -792,7 +797,8 @@ class GsmDeviceView(TrayIcon):
def __gsm_disconnect_cb(self, palette, data=None):
obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
netmgr = dbus.Interface(obj, _NM_IFACE)
- netmgr_props = dbus.Interface(netmgr, 'org.freedesktop.DBus.Properties')
+ netmgr_props = dbus.Interface(netmgr,
+ 'org.freedesktop.DBus.Properties')
active_connections_o = netmgr_props.Get(_NM_IFACE, 'ActiveConnections')
for conn_o in active_connections_o:
diff --git a/extensions/deviceicon/speaker.py b/extensions/deviceicon/speaker.py
index cb01629..595b71e 100644
--- a/extensions/deviceicon/speaker.py
+++ b/extensions/deviceicon/speaker.py
@@ -71,7 +71,8 @@ class DeviceView(TrayIcon):
xo_color = XoColor('%s,%s' % (style.COLOR_WHITE.get_svg(),
style.COLOR_WHITE.get_svg()))
- self.icon.props.icon_name = get_icon_state(name, current_level, step=-1)
+ self.icon.props.icon_name = get_icon_state(name, current_level,
+ step=-1)
self.icon.props.xo_color = xo_color
def __button_release_event_cb(self, widget, event):
diff --git a/extensions/deviceicon/touchpad.py b/extensions/deviceicon/touchpad.py
index d9521c2..b3b34f5 100644
--- a/extensions/deviceicon/touchpad.py
+++ b/extensions/deviceicon/touchpad.py
@@ -33,10 +33,14 @@ from jarabe.frame.frameinvoker import FrameWidgetInvoker
TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
TOUCHPAD_MODE_RESISTIVE = 'resistive'
TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
-STATUS_TEXT = {TOUCHPAD_MODE_CAPACITIVE: _('finger'),
- TOUCHPAD_MODE_RESISTIVE: _('stylus')}
-STATUS_ICON = {TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
- TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE}
+STATUS_TEXT = {
+ TOUCHPAD_MODE_CAPACITIVE: _('finger'),
+ TOUCHPAD_MODE_RESISTIVE: _('stylus'),
+}
+STATUS_ICON = {
+ TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
+ TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
+}
# NODE_PATH is used to communicate with the touchpad device.
NODE_PATH = '/sys/devices/platform/i8042/serio1/ptmode'
diff --git a/src/jarabe/controlpanel/gui.py b/src/jarabe/controlpanel/gui.py
index 4fa030b..2448bb4 100644
--- a/src/jarabe/controlpanel/gui.py
+++ b/src/jarabe/controlpanel/gui.py
@@ -261,11 +261,10 @@ class ControlPanel(gtk.Window):
keywords.append(item)
options[item]['keywords'] = keywords
else:
- _logger.error('There is no CLASS constant specifieds ' \
- 'in the view file \'%s\'.' % item)
+ _logger.error('There is no CLASS constant specified'
+ ' in the view file %r.', item)
except Exception:
- logging.error('Exception while loading extension:\n' + \
- ''.join(traceback.format_exception(*sys.exc_info())))
+ logging.exception('Exception while loading extension:')
return options
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index 430790e..8f15861 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -90,7 +90,8 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout):
if icon not in self.box.get_children():
raise ValueError('Child not in box.')
- if not(hasattr(icon, 'get_bundle_id') and hasattr(icon, 'get_version')):
+ if not (hasattr(icon, 'get_bundle_id') and
+ hasattr(icon, 'get_version')):
logging.debug('Not an activity icon %r', icon)
return
@@ -242,13 +243,15 @@ class RingLayout(FavoritesLayout):
self._spiral_mode = False
distance = style.MEDIUM_ICON_SIZE + style.DEFAULT_SPACING * \
_ICON_SPACING_FACTORS[_ICON_SIZES.index(style.MEDIUM_ICON_SIZE)]
- radius = max(children_count * distance / (2 * math.pi), _MINIMUM_RADIUS)
+ radius = max(children_count * distance / (2 * math.pi),
+ _MINIMUM_RADIUS)
if radius < _MAXIMUM_RADIUS:
return radius, style.MEDIUM_ICON_SIZE
distance = style.STANDARD_ICON_SIZE + style.DEFAULT_SPACING * \
_ICON_SPACING_FACTORS[_ICON_SIZES.index(style.STANDARD_ICON_SIZE)]
- radius = max(children_count * distance / (2 * math.pi), _MINIMUM_RADIUS)
+ radius = max(children_count * distance / (2 * math.pi),
+ _MINIMUM_RADIUS)
if radius < _MAXIMUM_RADIUS:
return radius, style.STANDARD_ICON_SIZE
@@ -266,8 +269,8 @@ class RingLayout(FavoritesLayout):
break
return radius, icon_size
- def _calculate_position(self, radius, icon_size, icon_index, children_count,
- sin=math.sin, cos=math.cos):
+ def _calculate_position(self, radius, icon_size, icon_index,
+ children_count, sin=math.sin, cos=math.cos):
""" Calculate an icon position on a circle or a spiral. """
width, height = self.box.get_allocation()
if self._spiral_mode:
@@ -408,7 +411,8 @@ class SunflowerLayout(RingLayout):
return None, style.STANDARD_ICON_SIZE
def adjust_index(self, i):
- """Skip floret indices which end up outside the desired bounding box."""
+ """Skip floret indices which end up outside the desired bounding box.
+ """
for idx in self.skipped_indices:
if i < idx:
break
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index 5ce3319..08bd3a0 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -175,7 +175,8 @@ class FavoritesView(hippo.Canvas):
height = allocation.height
min_w_, my_icon_width = self._my_icon.get_width_request()
- min_h_, my_icon_height = self._my_icon.get_height_request(my_icon_width)
+ min_h_, my_icon_height = self._my_icon.get_height_request(
+ my_icon_width)
x = (width - my_icon_width) / 2
y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2
self._layout.move_icon(self._my_icon, x, y, locked=True)
@@ -193,7 +194,8 @@ class FavoritesView(hippo.Canvas):
# TODO: Dnd methods. This should be merged somehow inside hippo-canvas.
def __button_press_event_cb(self, widget, event):
if event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:
- self._last_clicked_icon = self._get_icon_at_coords(event.x, event.y)
+ self._last_clicked_icon = self._get_icon_at_coords(event.x,
+ event.y)
if self._last_clicked_icon is not None:
self._pressed_button = event.button
self._press_start_x = event.x
@@ -398,8 +400,8 @@ class ActivityIcon(CanvasIcon):
error_handler=self.__get_last_activity_error_handler_cb)
def __get_last_activity_reply_handler_cb(self, entries, total_count):
- # If there's a problem with the DS index, we may get entries not related
- # to this activity.
+ # If there's a problem with the DS index, we may get entries not
+ # related to this activity.
checked_entries = []
for entry in entries:
if entry['activity'] == self.bundle_id:
@@ -624,7 +626,8 @@ class OwnerIcon(BuddyIcon):
backup_url = client.get_string('/desktop/sugar/backup_url')
if not backup_url:
self._register_menu = MenuItem(_('Register'), 'media-record')
- self._register_menu.connect('activate', self.__register_activate_cb)
+ self._register_menu.connect('activate',
+ self.__register_activate_cb)
palette.menu.append(self._register_menu)
self._register_menu.show()
diff --git a/src/jarabe/desktop/grid.py b/src/jarabe/desktop/grid.py
index 466752f..e6025ca 100644
--- a/src/jarabe/desktop/grid.py
+++ b/src/jarabe/desktop/grid.py
@@ -187,7 +187,8 @@ class Grid(_sugarext.Grid):
for c in self._children:
intersection = child_rect.intersect(self._child_rects[c])
if c != child and intersection.width > 0:
- if c not in self._locked_children and c not in self._collisions:
+ if (c not in self._locked_children and
+ c not in self._collisions):
collision_found = True
self._collisions.append(c)
diff --git a/src/jarabe/desktop/homebox.py b/src/jarabe/desktop/homebox.py
index 9833873..68e7a33 100644
--- a/src/jarabe/desktop/homebox.py
+++ b/src/jarabe/desktop/homebox.py
@@ -240,7 +240,7 @@ class HomeToolbar(gtk.Toolbar):
if self._autosearch_timer:
gobject.source_remove(self._autosearch_timer)
self._autosearch_timer = gobject.timeout_add(_AUTOSEARCH_TIMEOUT,
- self.__autosearch_timer_cb)
+ self.__autosearch_timer_cb)
def __autosearch_timer_cb(self):
self._autosearch_timer = None
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 7b1b539..99734a2 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -235,8 +235,9 @@ class DeviceObserver(gobject.GObject):
self.device = device
wireless = dbus.Interface(device, _NM_WIRELESS_IFACE)
- wireless.GetAccessPoints(reply_handler=self._get_access_points_reply_cb,
- error_handler=self._get_access_points_error_cb)
+ wireless.GetAccessPoints(
+ reply_handler=self._get_access_points_reply_cb,
+ error_handler=self._get_access_points_error_cb)
self._bus.add_signal_receiver(self.__access_point_added_cb,
signal_name='AccessPointAdded',
diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py
index 8cd6303..8c8dd9e 100644
--- a/src/jarabe/desktop/networkviews.py
+++ b/src/jarabe/desktop/networkviews.py
@@ -381,7 +381,7 @@ class WirelessNetworkView(CanvasPulsingIcon):
def create_keydialog(self, settings, response):
keydialog.create(self._name, self._flags, self._wpa_flags,
- self._rsn_flags, self._device_caps, settings, response)
+ self._rsn_flags, self._device_caps, settings, response)
def update_strength(self):
if self._active_ap is not None:
diff --git a/src/jarabe/frame/activitiestray.py b/src/jarabe/frame/activitiestray.py
index 6d4d875..1247907 100644
--- a/src/jarabe/frame/activitiestray.py
+++ b/src/jarabe/frame/activitiestray.py
@@ -208,7 +208,8 @@ class ActivitiesTray(HTray):
self._home_model = shell.get_model()
self._home_model.connect('activity-added', self.__activity_added_cb)
- self._home_model.connect('activity-removed', self.__activity_removed_cb)
+ self._home_model.connect('activity-removed',
+ self.__activity_removed_cb)
self._home_model.connect('active-activity-changed',
self.__activity_changed_cb)
self._home_model.connect('tabbing-activity-changed',
diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
index 95ae192..308ac39 100644
--- a/src/jarabe/frame/clipboard.py
+++ b/src/jarabe/frame/clipboard.py
@@ -73,7 +73,7 @@ class Clipboard(gobject.GObject):
+ ' with path at ' + new_uri)
else:
cb_object.add_format(Format(format_type, data, on_disk))
- logging.debug('Added in-memory format of type ' + format_type + '.')
+ logging.debug('Added in-memory format of type %s.', format_type)
self.emit('object-state-changed', cb_object)
diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
index 9c44408..25fc920 100644
--- a/src/jarabe/frame/clipboardicon.py
+++ b/src/jarabe/frame/clipboardicon.py
@@ -72,7 +72,8 @@ class ClipboardIcon(RadioToolButton):
def _drag_data_get_cb(self, widget, context, selection, target_type,
event_time):
- logging.debug('_drag_data_get_cb: requested target ' + selection.target)
+ logging.debug('_drag_data_get_cb: requested target %s',
+ selection.target)
data = self._cb_object.get_formats()[selection.target].get_data()
selection.set(selection.target, 8, data)
@@ -80,8 +81,8 @@ class ClipboardIcon(RadioToolButton):
logging.debug('ClipboardIcon._put_in_clipboard')
if self._cb_object.get_percent() < 100:
- raise ValueError('Object is not complete,' \
- ' cannot be put into the clipboard.')
+ raise ValueError('Object is not complete, cannot be put into the'
+ ' clipboard.')
targets = self._get_targets()
if targets:
diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py
index 155bc59..607f2cf 100644
--- a/src/jarabe/frame/clipboardtray.py
+++ b/src/jarabe/frame/clipboardtray.py
@@ -41,8 +41,8 @@ class _ContextMap(object):
def get_object_id(self, context):
"""Retrieves the object_id associated with context.
- Will release the association when this function was called as many times
- as the number of data_types that this clipboard object contains.
+ Will release the association when this function was called as many
+ times as the number of data_types that this clipboard object contains.
"""
[object_id, data_types_left] = self._context_map[context]
@@ -194,12 +194,12 @@ class ClipboardTray(tray.VTray):
if selection.data == 'S':
window = context.source_window
- prop_type, format_, dest = \
- window.property_get('XdndDirectSave0', 'text/plain')
+ prop_type, format_, dest = window.property_get(
+ 'XdndDirectSave0', 'text/plain')
clipboardservice = clipboard.get_instance()
- clipboardservice.add_object_format( \
- object_id, 'XdndDirectSave0', dest, on_disk=True)
+ clipboardservice.add_object_format(object_id,
+ 'XdndDirectSave0', dest, on_disk=True)
else:
self._add_selection(object_id, selection)
diff --git a/src/jarabe/frame/devicestray.py b/src/jarabe/frame/devicestray.py
index 1acde21..0011c7e 100644
--- a/src/jarabe/frame/devicestray.py
+++ b/src/jarabe/frame/devicestray.py
@@ -43,7 +43,8 @@ class DevicesTray(tray.HTray):
index = 0
relative_index = getattr(view, "FRAME_POSITION_RELATIVE", -1)
for item in self.get_children():
- current_relative_index = getattr(item, "FRAME_POSITION_RELATIVE", 0)
+ current_relative_index = getattr(item, 'FRAME_POSITION_RELATIVE',
+ 0)
if current_relative_index >= relative_index:
index += 1
else:
diff --git a/src/jarabe/frame/eventarea.py b/src/jarabe/frame/eventarea.py
index af6f1b6..1b06d74 100644
--- a/src/jarabe/frame/eventarea.py
+++ b/src/jarabe/frame/eventarea.py
@@ -37,7 +37,8 @@ class EventArea(gobject.GObject):
self._sids = {}
client = gconf.client_get_default()
self._edge_delay = client.get_int('/desktop/sugar/frame/edge_delay')
- self._corner_delay = client.get_int('/desktop/sugar/frame/corner_delay')
+ self._corner_delay = client.get_int(
+ '/desktop/sugar/frame/corner_delay')
right = gtk.gdk.screen_width() - 1
bottom = gtk.gdk.screen_height() - 1
diff --git a/src/jarabe/frame/frame.py b/src/jarabe/frame/frame.py
index 933729c..677bc2c 100644
--- a/src/jarabe/frame/frame.py
+++ b/src/jarabe/frame/frame.py
@@ -178,8 +178,8 @@ class Frame(object):
def _create_top_panel(self):
panel = self._create_panel(gtk.POS_TOP)
- # TODO: setting box_width and hippo.PACK_EXPAND looks like a hack to me.
- # Why hippo isn't respecting the request size of these controls?
+ # TODO: setting box_width and hippo.PACK_EXPAND looks like a hack to
+ # me. Why hippo isn't respecting the request size of these controls?
zoom_toolbar = ZoomToolbar()
panel.append(hippo.CanvasWidget(widget=zoom_toolbar,
@@ -198,7 +198,8 @@ class Frame(object):
# TODO: same issue as in _create_top_panel()
devices_tray = DevicesTray()
- panel.append(hippo.CanvasWidget(widget=devices_tray), hippo.PACK_EXPAND)
+ panel.append(hippo.CanvasWidget(widget=devices_tray),
+ hippo.PACK_EXPAND)
devices_tray.show()
return panel
diff --git a/src/jarabe/frame/notification.py b/src/jarabe/frame/notification.py
index 703cf2c..d25ada6 100644
--- a/src/jarabe/frame/notification.py
+++ b/src/jarabe/frame/notification.py
@@ -46,7 +46,8 @@ class NotificationIcon(gtk.EventBox):
self.add(self._icon)
self._icon.show()
- gobject.timeout_add_seconds(self._PULSE_TIMEOUT, self.__stop_pulsing_cb)
+ gobject.timeout_add_seconds(self._PULSE_TIMEOUT,
+ self.__stop_pulsing_cb)
self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
index 84a376f..e680dc9 100644
--- a/src/jarabe/journal/journalactivity.py
+++ b/src/jarabe/journal/journalactivity.py
@@ -85,7 +85,8 @@ class JournalActivityDBusService(dbus.service.Object):
chooser.destroy()
del chooser
- @dbus.service.method(J_DBUS_INTERFACE, in_signature='is', out_signature='s')
+ @dbus.service.method(J_DBUS_INTERFACE, in_signature='is',
+ out_signature='s')
def ChooseObject(self, parent_xid, what_filter=''):
chooser_id = uuid.uuid4().hex
if parent_xid > 0:
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index db34c05..e5803ae 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -49,8 +49,8 @@ class TreeView(gtk.TreeView):
self.set_headers_visible(False)
def do_size_request(self, requisition):
- # HACK: We tell the model that the view is just resizing so it can avoid
- # hitting both D-Bus and disk.
+ # HACK: We tell the model that the view is just resizing so it can
+ # avoid hitting both D-Bus and disk.
tree_model = self.get_model()
if tree_model is not None:
tree_model.view_is_resizing = True
@@ -82,7 +82,8 @@ class BaseListView(gtk.Bin):
self.connect('destroy', self.__destroy_cb)
self._scrolled_window = gtk.ScrolledWindow()
- self._scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ self._scrolled_window.set_policy(gtk.POLICY_NEVER,
+ gtk.POLICY_AUTOMATIC)
self.add(self._scrolled_window)
self._scrolled_window.show()
@@ -142,7 +143,8 @@ class BaseListView(gtk.Bin):
column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
column.props.fixed_width = self.cell_icon.props.width
column.pack_start(self.cell_icon)
- column.add_attribute(self.cell_icon, 'file-name', ListModel.COLUMN_ICON)
+ column.add_attribute(self.cell_icon, 'file-name',
+ ListModel.COLUMN_ICON)
column.add_attribute(self.cell_icon, 'xo-color',
ListModel.COLUMN_ICON_COLOR)
self.tree_view.append_column(column)
@@ -164,8 +166,8 @@ class BaseListView(gtk.Bin):
buddies_column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
self.tree_view.append_column(buddies_column)
- for column_index in [ListModel.COLUMN_BUDDY_1, ListModel.COLUMN_BUDDY_2,
- ListModel.COLUMN_BUDDY_3]:
+ for column_index in [ListModel.COLUMN_BUDDY_1,
+ ListModel.COLUMN_BUDDY_2, ListModel.COLUMN_BUDDY_3]:
cell_icon = CellRendererBuddy(self.tree_view,
column_index=column_index)
buddies_column.pack_start(cell_icon)
@@ -198,7 +200,8 @@ class BaseListView(gtk.Bin):
self.sort_column.props.resizable = True
self.sort_column.props.clickable = True
self.sort_column.pack_start(cell_text)
- self.sort_column.add_attribute(cell_text, 'text', ListModel.COLUMN_TIMESTAMP)
+ self.sort_column.add_attribute(cell_text, 'text',
+ ListModel.COLUMN_TIMESTAMP)
self.tree_view.append_column(self.sort_column)
def _get_width_for_string(self, text):
@@ -322,12 +325,9 @@ class BaseListView(gtk.Bin):
def _is_query_empty(self):
# FIXME: This is a hack, we shouldn't have to update this every time
# a new search term is added.
- if self._query.get('query', '') or self._query.get('mime_type', '') or \
- self._query.get('keep', '') or self._query.get('mtime', '') or \
- self._query.get('activity', ''):
- return False
- else:
- return True
+ return not (self._query.get('query') or self._query.get('mime_type') or
+ self._query.get('keep') or self._query.get('mtime') or
+ self._query.get('activity'))
def __model_progress_cb(self, tree_model):
if self._progress_bar is None:
@@ -421,7 +421,7 @@ class BaseListView(gtk.Bin):
while True:
x, y, width, height = self.tree_view.get_cell_area(path,
- self.sort_column)
+ self.sort_column)
x, y = self.tree_view.convert_tree_to_widget_coords(x, y)
self.tree_view.queue_draw_area(x, y, width, height)
if path == end_path:
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index e2fc020..a0cb430 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -38,9 +38,11 @@ DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore'
DS_DBUS_PATH = '/org/laptop/sugar/DataStore'
# Properties the journal cares about.
-PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 'creation_time', 'filesize',
- 'keep', 'buddies', 'icon-color', 'mime_type', 'progress',
- 'activity', 'mountpoint', 'activity_id', 'bundle_id']
+PROPERTIES = [
+ 'activity', 'activity_id', 'buddies', 'bundle_id', 'creation_time',
+ 'filesize', 'icon-color', 'keep', 'mime_type', 'mountpoint', 'mtime',
+ 'progress', 'timestamp', 'title', 'uid',
+]
MIN_PAGES_TO_CACHE = 3
MAX_PAGES_TO_CACHE = 5
@@ -148,7 +150,8 @@ class BaseResultSet(object):
self._cache.append_all(entries)
self._offset = offset
- elif remaining_forward_entries <= 0 and remaining_backwards_entries > 0:
+ elif (remaining_forward_entries <= 0 and
+ remaining_backwards_entries > 0):
# Add one page to the end of cache
logging.debug('appending one more page, offset: %r',
@@ -346,7 +349,8 @@ class InplaceResultSet(BaseResultSet):
add_to_list = False
if add_to_list:
- file_info = (full_path, stat, int(stat.st_mtime), stat.st_size)
+ file_info = (full_path, stat, int(stat.st_mtime),
+ stat.st_size)
self._file_list.append(file_info)
self.progress.send(self)
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
index c935625..6138ad9 100644
--- a/src/jarabe/journal/volumestoolbar.py
+++ b/src/jarabe/journal/volumestoolbar.py
@@ -64,10 +64,10 @@ class VolumesToolbar(gtk.Toolbar):
def _set_up_volumes(self):
volume_monitor = gio.volume_monitor_get()
- self._mount_added_hid = \
- volume_monitor.connect('mount-added', self.__mount_added_cb)
- self._mount_removed_hid = \
- volume_monitor.connect('mount-removed', self.__mount_removed_cb)
+ self._mount_added_hid = volume_monitor.connect('mount-added',
+ self.__mount_added_cb)
+ self._mount_removed_hid = volume_monitor.connect('mount-removed',
+ self.__mount_removed_cb)
for mount in volume_monitor.get_mounts():
self._add_button(mount)
@@ -146,8 +146,8 @@ class BaseButton(RadioToolButton):
gtk.gdk.ACTION_COPY)
self.connect('drag-data-received', self._drag_data_received_cb)
- def _drag_data_received_cb(self, widget, drag_context, x, y, selection_data,
- info, timestamp):
+ def _drag_data_received_cb(self, widget, drag_context, x, y,
+ selection_data, info, timestamp):
object_id = selection_data.data
metadata = model.get(object_id)
file_path = model.get_file(metadata['uid'])
diff --git a/src/jarabe/model/buddy.py b/src/jarabe/model/buddy.py
index dd0ad4f..f6a49bb 100644
--- a/src/jarabe/model/buddy.py
+++ b/src/jarabe/model/buddy.py
@@ -230,4 +230,5 @@ class BuddyModel(BaseBuddyModel):
def set_handle(self, handle):
self._handle = handle
- handle = gobject.property(type=object, getter=get_handle, setter=set_handle)
+ handle = gobject.property(type=object, getter=get_handle,
+ setter=set_handle)
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index bb90943..0eda7be 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -274,8 +274,7 @@ class BundleRegistry(gobject.GObject):
default_bundle = None
for bundle in self._bundles:
- if bundle.get_mime_types() and mime_type in bundle.get_mime_types():
-
+ if mime_type in (bundle.get_mime_types() or []):
if bundle.get_bundle_id() == default_bundle_id:
default_bundle = bundle
elif self.get_default_for_type(mime_type) == \
@@ -331,7 +330,8 @@ class BundleRegistry(gobject.GObject):
def set_bundle_position(self, bundle_id, version, x, y):
key = self._get_favorite_key(bundle_id, version)
if key not in self._favorite_bundles:
- raise ValueError('Bundle %s %s not favorite' % (bundle_id, version))
+ raise ValueError('Bundle %s %s not favorite' % (bundle_id,
+ version))
if self._favorite_bundles[key] is None:
self._favorite_bundles[key] = {}
diff --git a/src/jarabe/model/invites.py b/src/jarabe/model/invites.py
index e4e1e97..c690959 100644
--- a/src/jarabe/model/invites.py
+++ b/src/jarabe/model/invites.py
@@ -99,8 +99,8 @@ class ActivityInvite(object):
obj = bus.get_object(CHANNEL_DISPATCHER, self.dispatch_operation_path)
dispatch_operation = dbus.Interface(obj, CHANNEL_DISPATCH_OPERATION)
dispatch_operation.HandleWith(self._handler,
- reply_handler=self.__handle_with_reply_cb,
- error_handler=self.__handle_with_reply_cb)
+ reply_handler=self.__handle_with_reply_cb,
+ error_handler=self.__handle_with_reply_cb)
def __handle_with_reply_cb(self, error=None):
if error is not None:
@@ -203,8 +203,8 @@ class Invites(gobject.GObject):
obj = bus.get_object(CHANNEL_DISPATCHER, dispatch_operation_path)
dispatch_operation = dbus.Interface(obj, CHANNEL_DISPATCH_OPERATION)
dispatch_operation.HandleWith(handler,
- reply_handler=self.__handle_with_reply_cb,
- error_handler=self.__handle_with_reply_cb)
+ reply_handler=self.__handle_with_reply_cb,
+ error_handler=self.__handle_with_reply_cb)
def __handle_with_reply_cb(self, error=None):
if error is not None:
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index 3be7713..59ef0b0 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -107,7 +107,8 @@ class ActivityModel(gobject.GObject):
def set_bundle(self, bundle):
self._bundle = bundle
- bundle = gobject.property(type=object, getter=get_bundle, setter=set_bundle)
+ bundle = gobject.property(type=object, getter=get_bundle,
+ setter=set_bundle)
def get_name(self):
return self._name
@@ -207,7 +208,8 @@ class _Account(gobject.GObject):
'AccountPropertyChanged', self.__account_property_changed_cb)
def __error_handler_cb(self, function_name, error):
- raise RuntimeError('Error when calling %s: %s' % (function_name, error))
+ raise RuntimeError('Error when calling %s: %s' % (function_name,
+ error))
def __got_connection_cb(self, connection_path):
logging.debug('_Account.__got_connection_cb %r', connection_path)
@@ -383,7 +385,8 @@ class _Account(gobject.GObject):
logging.debug('Got handle %r with nick %r, going to update',
handle, alias)
properties = {CONNECTION_INTERFACE_ALIASING + '/alias': alias}
- self.emit('buddy-updated', self._buddy_handles[handle], properties)
+ self.emit('buddy-updated', self._buddy_handles[handle],
+ properties)
def __presences_changed_cb(self, presences):
logging.debug('_Account.__presences_changed_cb %r', presences)
@@ -577,7 +580,8 @@ class _Account(gobject.GObject):
connection.GetActivities(
handle,
- reply_handler=partial(self.__got_activities_cb, handle),
+ reply_handler=partial(self.__got_activities_cb,
+ handle),
error_handler=partial(self.__error_handler_cb,
'BuddyInfo.GetActivities'),
timeout=_QUERY_DBUS_TIMEOUT)
@@ -640,7 +644,8 @@ class Neighborhood(gobject.GObject):
self._server_account = None
client = gconf.client_get_default()
- client.add_dir('/desktop/sugar/collaboration', gconf.CLIENT_PRELOAD_NONE)
+ client.add_dir('/desktop/sugar/collaboration',
+ gconf.CLIENT_PRELOAD_NONE)
client.notify_add('/desktop/sugar/collaboration/jabber_server',
self.__jabber_server_changed_cb)
client.add_dir('/desktop/sugar/user/nick', gconf.CLIENT_PRELOAD_NONE)
@@ -737,7 +742,8 @@ class Neighborhood(gobject.GObject):
client = gconf.client_get_default()
nick = client.get_string('/desktop/sugar/user/nick')
- server = client.get_string('/desktop/sugar/collaboration/jabber_server')
+ server = client.get_string(
+ '/desktop/sugar/collaboration/jabber_server')
key_hash = get_profile().privkey_hash
params = {
@@ -762,14 +768,14 @@ class Neighborhood(gobject.GObject):
obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH)
account_manager = dbus.Interface(obj, ACCOUNT_MANAGER)
account_path = account_manager.CreateAccount('gabble', 'jabber',
- 'jabber', params,
- properties)
+ 'jabber', params, properties)
return _Account(account_path)
def _get_jabber_account_id(self):
public_key_hash = sha1(get_profile().pubkey).hexdigest()
client = gconf.client_get_default()
- server = client.get_string('/desktop/sugar/collaboration/jabber_server')
+ server = client.get_string(
+ '/desktop/sugar/collaboration/jabber_server')
return '%s@%s' % (public_key_hash, server)
def __jabber_server_changed_cb(self, client, timestamp, entry, *extra):
@@ -779,7 +785,8 @@ class Neighborhood(gobject.GObject):
account = bus.get_object(ACCOUNT_MANAGER_SERVICE,
self._server_account.object_path)
- server = client.get_string('/desktop/sugar/collaboration/jabber_server')
+ server = client.get_string(
+ '/desktop/sugar/collaboration/jabber_server')
account_id = self._get_jabber_account_id()
needs_reconnect = account.UpdateParameters({'server': server,
'account': account_id,
@@ -835,8 +842,9 @@ class Neighborhood(gobject.GObject):
return
if contact_id not in self._buddies:
- logging.debug('__buddy_updated_cb Unknown buddy with contact_id %r',
- contact_id)
+ logging.debug(
+ '__buddy_updated_cb Unknown buddy with contact_id %r',
+ contact_id)
return
buddy = self._buddies[contact_id]
@@ -922,8 +930,8 @@ class Neighborhood(gobject.GObject):
'contact_id %r', contact_id)
return
if activity_id and activity_id not in self._activities:
- logging.debug('__current_activity_updated_cb Unknown activity with '
- 'id %s', activity_id)
+ logging.debug('__current_activity_updated_cb Unknown activity with'
+ ' id %s', activity_id)
activity_id = ''
buddy = self._buddies[contact_id]
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index fa05743..8c12afc 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -554,12 +554,12 @@ class NMSettingsConnection(dbus.service.Object):
def set_connected(self):
if self._settings.connection.type == NM_CONNECTION_TYPE_GSM:
self._settings.connection.timestamp = int(time.time())
- else:
- if not self._settings.connection.autoconnect:
- self._settings.connection.autoconnect = True
- self._settings.connection.timestamp = int(time.time())
- if self._settings.connection.type == NM_CONNECTION_TYPE_802_11_WIRELESS:
- self.save()
+ elif not self._settings.connection.autoconnect:
+ self._settings.connection.autoconnect = True
+ self._settings.connection.timestamp = int(time.time())
+ if (self._settings.connection.type ==
+ NM_CONNECTION_TYPE_802_11_WIRELESS):
+ self.save()
try:
# try to flush resolver cache - SL#1940
@@ -573,7 +573,8 @@ class NMSettingsConnection(dbus.service.Object):
def set_secrets(self, secrets):
self._secrets = secrets
- if self._settings.connection.type == NM_CONNECTION_TYPE_802_11_WIRELESS:
+ if (self._settings.connection.type ==
+ NM_CONNECTION_TYPE_802_11_WIRELESS):
self.save()
def get_settings(self):
@@ -649,19 +650,22 @@ class NMSettingsConnection(dbus.service.Object):
self.path, request_new)
if self._settings.connection.type is not NM_CONNECTION_TYPE_GSM:
if request_new or self._secrets is None:
- # request_new is for example the case when the pw on the AP changes
+ # request_new is for example the case when the pw on the AP
+ # changes
response = SecretsResponse(self, reply, error)
try:
self.secrets_request.send(self, response=response)
except Exception:
- logging.exception('Error requesting the secrets via dialog')
+ logging.exception('Error requesting the secrets via'
+ ' dialog')
else:
reply(self._secrets.get_dict())
else:
if not request_new:
reply(self._secrets.get_dict())
else:
- raise Exception('The stored GSM secret has already been supplied ')
+ raise Exception('The stored GSM secret has already been'
+ ' supplied')
class AccessPoint(gobject.GObject):
@@ -789,9 +793,10 @@ def find_connection_by_ssid(ssid):
for conn_index in connections:
connection = connections[conn_index]
- if connection._settings.connection.type == NM_CONNECTION_TYPE_802_11_WIRELESS:
- if connection._settings.wireless.ssid == ssid:
- return connection
+ if (connection._settings.connection.type ==
+ NM_CONNECTION_TYPE_802_11_WIRELESS and
+ connection._settings.wireless.ssid == ssid):
+ return connection
return None
diff --git a/src/jarabe/model/notifications.py b/src/jarabe/model/notifications.py
index 47185f1..108a546 100644
--- a/src/jarabe/model/notifications.py
+++ b/src/jarabe/model/notifications.py
@@ -47,7 +47,7 @@ class NotificationService(dbus.service.Object):
hints, expire_timeout):
logging.debug('Received notification: %r', [app_name, replaces_id,
- '<app_icon>', summary, body, actions, '<hints>', expire_timeout])
+ '<app_icon>', summary, body, actions, '<hints>', expire_timeout])
if replaces_id > 0:
notification_id = replaces_id
diff --git a/src/jarabe/model/session.py b/src/jarabe/model/session.py
index 531b7a5..f5c2655 100644
--- a/src/jarabe/model/session.py
+++ b/src/jarabe/model/session.py
@@ -56,9 +56,9 @@ class SessionManager(session.SessionManager):
try:
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.Hal',
- '/org/freedesktop/Hal/devices/computer')
+ '/org/freedesktop/Hal/devices/computer')
pm = dbus.Interface(proxy,
- 'org.freedesktop.Hal.Device.SystemPowerManagement')
+ 'org.freedesktop.Hal.Device.SystemPowerManagement')
if self._logout_mode == self.MODE_SHUTDOWN:
pm.Shutdown()
@@ -79,8 +79,8 @@ class SessionManager(session.SessionManager):
pid = int(os.environ['SUGAR_EMULATOR_PID'])
os.kill(pid, signal.SIGTERM)
- # Need to call this ASAP so the atexit handlers get called before we get
- # killed by the X (dis)connection
+ # Need to call this ASAP so the atexit handlers get called before we
+ # get killed by the X (dis)connection
sys.exit()
diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
index 78a0693..7caa9ec 100644
--- a/src/jarabe/view/keyhandler.py
+++ b/src/jarabe/view/keyhandler.py
@@ -131,7 +131,7 @@ class KeyHandler(object):
def _primary_selection_cb(self, clipboard, text, user_data):
logging.debug('KeyHandler._primary_selection_cb: %r', text)
if text:
- self._get_speech_proxy().SayText(text, reply_handler=lambda: None, \
+ self._get_speech_proxy().SayText(text, reply_handler=lambda: None,
error_handler=self._on_speech_err)
def handle_say_text(self, event_time):
diff --git a/src/jarabe/view/service.py b/src/jarabe/view/service.py
index 16299de..631f1c3 100644
--- a/src/jarabe/view/service.py
+++ b/src/jarabe/view/service.py
@@ -67,9 +67,9 @@ class UIService(dbus.service.Object):
@dbus.service.method(_DBUS_SHELL_IFACE,
in_signature="s", out_signature="b")
def ActivateActivity(self, activity_id):
- """Switch to the window related to this activity_id and return a boolean
- indicating if there is a real (ie. not a launcher window) activity
- already open.
+ """Switch to the window related to this activity_id and return a
+ boolean indicating if there is a real (ie. not a launcher window)
+ activity already open.
"""
activity = self._shell_model.get_activity_by_id(activity_id)
--
1.7.1
More information about the Sugar-devel
mailing list