style cleanup: prefer ' for strings

Tomeu prefers ' for strings, so let's use it wherever we don't have a good
reason to use ".

Reviewed-by: James Cameron <quozl@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
CC: Aleksey Lim <alsroot@member.fsf.org>
master
Sascha Silbe 14 years ago
parent 5f13fcfc84
commit 7acfbd070f

@ -21,7 +21,7 @@ box.pack_start(text_view)
def echo(button, label): def echo(button, label):
if not button.props.active: if not button.props.active:
return return
text_view.props.buffer.props.text += "\n" + label text_view.props.buffer.props.text += '\n' + label
# RadioMenuButton # RadioMenuButton

@ -88,9 +88,9 @@ from sugar.activity.widgets import ActivityToolbox
_ = lambda msg: gettext.dgettext('sugar-toolkit', msg) _ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
SCOPE_PRIVATE = "private" SCOPE_PRIVATE = 'private'
SCOPE_INVITE_ONLY = "invite" # shouldn't be shown in UI, it's implicit SCOPE_INVITE_ONLY = 'invite' # shouldn't be shown in UI, it's implicit
SCOPE_NEIGHBORHOOD = "public" SCOPE_NEIGHBORHOOD = 'public'
J_DBUS_SERVICE = 'org.laptop.Journal' J_DBUS_SERVICE = 'org.laptop.Journal'
J_DBUS_PATH = '/org/laptop/Journal' J_DBUS_PATH = '/org/laptop/Journal'
@ -269,7 +269,7 @@ class Activity(Window, gtk.Container):
# but they get truncated anyway so if more characters # but they get truncated anyway so if more characters
# are supported in the future we will get a better view # are supported in the future we will get a better view
# of the processes # of the processes
proc_title = "%s <%s>" % (get_bundle_name(), handle.activity_id) proc_title = '%s <%s>' % (get_bundle_name(), handle.activity_id)
util.set_proc_title(proc_title) util.set_proc_title(proc_title)
self.connect('realize', self.__realize_cb) self.connect('realize', self.__realize_cb)
@ -362,16 +362,16 @@ class Activity(Window, gtk.Container):
def _set_up_sharing(self, mesh_instance, share_scope): def _set_up_sharing(self, mesh_instance, share_scope):
# handle activity share/join # handle activity share/join
logging.debug("*** Act %s, mesh instance %r, scope %s", logging.debug('*** Act %s, mesh instance %r, scope %s',
self._activity_id, mesh_instance, share_scope) self._activity_id, mesh_instance, share_scope)
if mesh_instance is not None: if mesh_instance is not None:
# There's already an instance on the mesh, join it # There's already an instance on the mesh, join it
logging.debug("*** Act %s joining existing mesh instance %r", logging.debug('*** Act %s joining existing mesh instance %r',
self._activity_id, mesh_instance) self._activity_id, mesh_instance)
self.shared_activity = mesh_instance self.shared_activity = mesh_instance
self.shared_activity.connect('notify::private', self.shared_activity.connect('notify::private',
self.__privacy_changed_cb) self.__privacy_changed_cb)
self._join_id = self.shared_activity.connect("joined", self._join_id = self.shared_activity.connect('joined',
self.__joined_cb) self.__joined_cb)
if not self.shared_activity.props.joined: if not self.shared_activity.props.joined:
self.shared_activity.join() self.shared_activity.join()
@ -778,7 +778,7 @@ class Activity(Window, gtk.Container):
its 'private' property. its 'private' property.
""" """
if self.shared_activity and self.shared_activity.props.joined: if self.shared_activity and self.shared_activity.props.joined:
raise RuntimeError("Activity %s already shared." % raise RuntimeError('Activity %s already shared.' %
self._activity_id) self._activity_id)
verb = private and 'private' or 'public' verb = private and 'private' or 'public'
logging.debug('Requesting %s share of activity %s.', verb, logging.debug('Requesting %s share of activity %s.', verb,
@ -880,7 +880,7 @@ class Activity(Window, gtk.Container):
"""Returns the jobject metadata or None if there is no jobject. """Returns the jobject metadata or None if there is no jobject.
Activities can set metadata in write_file() using: Activities can set metadata in write_file() using:
self.metadata['MyKey'] = "Something" self.metadata['MyKey'] = 'Something'
and retrieve metadata in read_file() using: and retrieve metadata in read_file() using:
self.metadata.get('MyKey', 'aDefaultValue') self.metadata.get('MyKey', 'aDefaultValue')
@ -976,7 +976,7 @@ def get_activity_root():
if os.environ.get('SUGAR_ACTIVITY_ROOT'): if os.environ.get('SUGAR_ACTIVITY_ROOT'):
return os.environ['SUGAR_ACTIVITY_ROOT'] return os.environ['SUGAR_ACTIVITY_ROOT']
else: else:
raise RuntimeError("No SUGAR_ACTIVITY_ROOT set.") raise RuntimeError('No SUGAR_ACTIVITY_ROOT set.')
def show_object_in_journal(object_id): def show_object_in_journal(object_id):

@ -40,16 +40,16 @@ import tempfile
import subprocess import subprocess
import pwd import pwd
_SHELL_SERVICE = "org.laptop.Shell" _SHELL_SERVICE = 'org.laptop.Shell'
_SHELL_PATH = "/org/laptop/Shell" _SHELL_PATH = '/org/laptop/Shell'
_SHELL_IFACE = "org.laptop.Shell" _SHELL_IFACE = 'org.laptop.Shell'
_ACTIVITY_FACTORY_INTERFACE = "org.laptop.ActivityFactory" _ACTIVITY_FACTORY_INTERFACE = 'org.laptop.ActivityFactory'
# helper method to close all filedescriptors # helper method to close all filedescriptors
# borrowed from subprocess.py # borrowed from subprocess.py
try: try:
MAXFD = os.sysconf("SC_OPEN_MAX") MAXFD = os.sysconf('SC_OPEN_MAX')
except ValueError: except ValueError:
MAXFD = 256 MAXFD = 256
@ -284,7 +284,7 @@ class ActivityCreationHandler(gobject.GObject):
self._handle.activity_id, self._service_name) self._handle.activity_id, self._service_name)
def _create_error_handler(self, err): def _create_error_handler(self, err):
logging.error("Couldn't create activity %s (%s): %s", logging.error('Couldn't create activity %s (%s): %s',
self._handle.activity_id, self._service_name, err) self._handle.activity_id, self._service_name, err)
self._shell.NotifyLaunchFailure( self._shell.NotifyLaunchFailure(
self._handle.activity_id, reply_handler=self._no_reply_handler, self._handle.activity_id, reply_handler=self._no_reply_handler,
@ -293,7 +293,7 @@ class ActivityCreationHandler(gobject.GObject):
def _find_object_reply_handler(self, jobjects, count): def _find_object_reply_handler(self, jobjects, count):
if count > 0: if count > 0:
if count > 1: if count > 1:
logging.debug("Multiple objects has the same activity_id.") logging.debug('Multiple objects has the same activity_id.')
self._handle.object_id = jobjects[0]['uid'] self._handle.object_id = jobjects[0]['uid']
self._launch_activity() self._launch_activity()

@ -25,9 +25,9 @@ import dbus
import dbus.service import dbus.service
_ACTIVITY_SERVICE_NAME = "org.laptop.Activity" _ACTIVITY_SERVICE_NAME = 'org.laptop.Activity'
_ACTIVITY_SERVICE_PATH = "/org/laptop/Activity" _ACTIVITY_SERVICE_PATH = '/org/laptop/Activity'
_ACTIVITY_INTERFACE = "org.laptop.Activity" _ACTIVITY_INTERFACE = 'org.laptop.Activity'
class ActivityService(dbus.service.Object): class ActivityService(dbus.service.Object):

@ -108,7 +108,7 @@ class Builder(object):
po_dir = os.path.join(self.config.source_dir, 'po') po_dir = os.path.join(self.config.source_dir, 'po')
if not self.config.bundle.is_dir(po_dir): if not self.config.bundle.is_dir(po_dir):
logging.warn("Missing po/ dir, cannot build_locale") logging.warn('Missing po/ dir, cannot build_locale')
return return
locale_dir = os.path.join(self.config.source_dir, 'locale') locale_dir = os.path.join(self.config.source_dir, 'locale')
@ -128,8 +128,8 @@ class Builder(object):
if not os.path.isdir(mo_path): if not os.path.isdir(mo_path):
os.makedirs(mo_path) os.makedirs(mo_path)
mo_file = os.path.join(mo_path, "%s.mo" % self.config.bundle_id) mo_file = os.path.join(mo_path, '%s.mo' % self.config.bundle_id)
args = ["msgfmt", "--output-file=%s" % mo_file, file_name] args = ['msgfmt', '--output-file=%s' % mo_file, file_name]
retcode = subprocess.call(args) retcode = subprocess.call(args)
if retcode: if retcode:
print 'ERROR - msgfmt failed with return code %i.' % retcode print 'ERROR - msgfmt failed with return code %i.' % retcode
@ -170,9 +170,9 @@ class Builder(object):
for path in self.check_manifest(): for path in self.check_manifest():
manifest.append(path) manifest.append(path)
f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb") f = open(os.path.join(self.config.source_dir, 'MANIFEST'), 'wb')
for line in manifest: for line in manifest:
f.write(line + "\n") f.write(line + '\n')
class Packager(object): class Packager(object):
@ -399,7 +399,7 @@ def print_commands():
for name, func in globals().items(): for name, func in globals().items():
if name.startswith('cmd_'): if name.startswith('cmd_'):
print "%-20s %s" % (name.replace('cmd_', ''), func.__doc__) print '%-20s %s' % (name.replace('cmd_', ''), func.__doc__)
print '\n(Type "./setup.py <command> --help" for help about a ' \ print '\n(Type "./setup.py <command> --help" for help about a ' \
'particular command\'s options.' 'particular command\'s options.'
@ -407,7 +407,7 @@ def print_commands():
def start(bundle_name=None): def start(bundle_name=None):
if bundle_name: if bundle_name:
logging.warn("bundle_name deprecated, now comes from activity.info") logging.warn('bundle_name deprecated, now comes from activity.info')
parser = OptionParser(usage='[action] [options]') parser = OptionParser(usage='[action] [options]')
parser.disable_interspersed_args() parser.disable_interspersed_args()

@ -118,7 +118,7 @@ def get_locale_path(bundle_id):
candidate_dirs[os.environ['SUGAR_LOCALEDIR']] = 2 candidate_dirs[os.environ['SUGAR_LOCALEDIR']] = 2
gconf_client = gconf.client_get_default() gconf_client = gconf.client_get_default()
package_dir = gconf_client.get_string("/desktop/sugar/i18n/langpackdir") package_dir = gconf_client.get_string('/desktop/sugar/i18n/langpackdir')
if package_dir is not None and package_dir is not '': if package_dir is not None and package_dir is not '':
candidate_dirs[package_dir] = 1 candidate_dirs[package_dir] = 1

@ -56,7 +56,7 @@ class SingleProcess(dbus.service.Object):
object_path = get_single_process_path(name_service) object_path = get_single_process_path(name_service)
dbus.service.Object.__init__(self, bus_name, object_path) dbus.service.Object.__init__(self, bus_name, object_path)
@dbus.service.method("org.laptop.SingleProcess", in_signature="a{sv}") @dbus.service.method('org.laptop.SingleProcess', in_signature='a{sv}')
def create(self, handle_dict): def create(self, handle_dict):
handle = activityhandle.create_from_dict(handle_dict) handle = activityhandle.create_from_dict(handle_dict)
create_activity_instance(self.constructor, handle) create_activity_instance(self.constructor, handle)
@ -64,14 +64,14 @@ class SingleProcess(dbus.service.Object):
def main(): def main():
parser = OptionParser() parser = OptionParser()
parser.add_option("-b", "--bundle-id", dest="bundle_id", parser.add_option('-b', '--bundle-id', dest='bundle_id',
help="identifier of the activity bundle") help='identifier of the activity bundle')
parser.add_option("-a", "--activity-id", dest="activity_id", parser.add_option('-a', '--activity-id', dest='activity_id',
help="identifier of the activity instance") help='identifier of the activity instance')
parser.add_option("-o", "--object-id", dest="object_id", parser.add_option('-o', '--object-id', dest='object_id',
help="identifier of the associated datastore object") help='identifier of the associated datastore object')
parser.add_option("-u", "--uri", dest="uri", parser.add_option('-u', '--uri', dest='uri',
help="URI to load") help='URI to load')
parser.add_option('-s', '--single-process', dest='single_process', parser.add_option('-s', '--single-process', dest='single_process',
action='store_true', action='store_true',
help='start all the instances in the same process') help='start all the instances in the same process')

@ -87,9 +87,9 @@ class ActivityBundle(Bundle):
"activity startup.") "activity startup.")
def _raw_manifest(self): def _raw_manifest(self):
f = self.get_file("MANIFEST") f = self.get_file('MANIFEST')
if not f: if not f:
logging.warning("Activity directory lacks a MANIFEST file.") logging.warning('Activity directory lacks a MANIFEST file.')
return [] return []
ret = [line.strip() for line in f.readlines()] ret = [line.strip() for line in f.readlines()]
@ -108,7 +108,7 @@ class ActivityBundle(Bundle):
lines = self._raw_manifest() lines = self._raw_manifest()
# Remove trailing newlines, they do not help keep absolute position. # Remove trailing newlines, they do not help keep absolute position.
while lines and lines[-1] == "": while lines and lines[-1] == '':
lines = lines[:-1] lines = lines[:-1]
for num, line in enumerate(lines): for num, line in enumerate(lines):
@ -117,20 +117,20 @@ class ActivityBundle(Bundle):
# Remove duplicates # Remove duplicates
if line in lines[0:num]: if line in lines[0:num]:
lines[num] = "" lines[num] = ''
logging.warning('Bundle %s: duplicate entry in MANIFEST: %s', logging.warning('Bundle %s: duplicate entry in MANIFEST: %s',
self._name, line) self._name, line)
continue continue
# Remove MANIFEST # Remove MANIFEST
if line == "MANIFEST": if line == 'MANIFEST':
lines[num] = "" lines[num] = ''
logging.warning('Bundle %s: MANIFEST includes itself: %s', logging.warning('Bundle %s: MANIFEST includes itself: %s',
self._name, line) self._name, line)
# Remove invalid files # Remove invalid files
if not self.is_file(line): if not self.is_file(line):
lines[num] = "" lines[num] = ''
logging.warning('Bundle %s: invalid entry in MANIFEST: %s', logging.warning('Bundle %s: invalid entry in MANIFEST: %s',
self._name, line) self._name, line)
@ -328,7 +328,7 @@ class ActivityBundle(Bundle):
for path in paths: for path in paths:
if path in manifestfiles: if path in manifestfiles:
manifestfiles.remove(path) manifestfiles.remove(path)
elif path != "MANIFEST": elif path != 'MANIFEST':
logging.warning('Bundle %s: %s not in MANIFEST', self._name, logging.warning('Bundle %s: %s not in MANIFEST', self._name,
path) path)
if strict_manifest: if strict_manifest:
@ -336,7 +336,7 @@ class ActivityBundle(Bundle):
# Is anything in MANIFEST left over after accounting for all files? # Is anything in MANIFEST left over after accounting for all files?
if manifestfiles: if manifestfiles:
err = ("Bundle %s: files in MANIFEST not included: %s" % err = ('Bundle %s: files in MANIFEST not included: %s' %
(self._name, str(manifestfiles))) (self._name, str(manifestfiles)))
if strict_manifest: if strict_manifest:
raise MalformedBundleException(err) raise MalformedBundleException(err)

@ -103,7 +103,7 @@ class Bundle(object):
if ext != self._unzipped_extension: if ext != self._unzipped_extension:
raise MalformedBundleException( raise MalformedBundleException(
'All files in the bundle must be inside a single ' + 'All files in the bundle must be inside a single ' +
'directory whose name ends with "%s"' % 'directory whose name ends with %r' %
self._unzipped_extension) self._unzipped_extension)
for file_name in file_names: for file_name in file_names:
@ -118,7 +118,7 @@ class Bundle(object):
if self._zip_file is None: if self._zip_file is None:
path = os.path.join(self._path, filename) path = os.path.join(self._path, filename)
try: try:
f = open(path, "rb") f = open(path, 'rb')
except IOError: except IOError:
return None return None
else: else:

@ -97,7 +97,7 @@ class ContentBundle(Bundle):
self._l10n = False self._l10n = False
else: else:
raise MalformedBundleException( raise MalformedBundleException(
'Content bundle %s has invalid l10n key "%s"' % 'Content bundle %s has invalid l10n key %r' %
(self._path, l10n)) (self._path, l10n))
else: else:
raise MalformedBundleException( raise MalformedBundleException(
@ -196,7 +196,7 @@ class ContentBundle(Bundle):
return os.path.join(self.get_root_dir(), self._activity_start) return os.path.join(self.get_root_dir(), self._activity_start)
def get_start_uri(self): def get_start_uri(self):
return "file://" + urllib.pathname2url(self.get_start_path()) return 'file://' + urllib.pathname2url(self.get_start_path())
def get_bundle_id(self): def get_bundle_id(self):
# TODO treat ContentBundle in special way # TODO treat ContentBundle in special way

@ -35,9 +35,9 @@ from sugar import env
from sugar import mime from sugar import mime
from sugar import dispatch from sugar import dispatch
DS_DBUS_SERVICE = "org.laptop.sugar.DataStore" DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore'
DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore" DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore'
DS_DBUS_PATH = "/org/laptop/sugar/DataStore" DS_DBUS_PATH = '/org/laptop/sugar/DataStore'
_data_store = None _data_store = None
@ -316,8 +316,8 @@ def create():
def _update_ds_entry(uid, properties, filename, transfer_ownership=False, def _update_ds_entry(uid, properties, filename, transfer_ownership=False,
reply_handler=None, error_handler=None, timeout=-1): reply_handler=None, error_handler=None, timeout=-1):
debug_properties = properties.copy() debug_properties = properties.copy()
if "preview" in debug_properties: if 'preview' in debug_properties:
debug_properties["preview"] = "<omitted>" debug_properties['preview'] = '<omitted>'
logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename, logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename,
debug_properties, transfer_ownership) debug_properties, transfer_ownership)
if reply_handler and error_handler: if reply_handler and error_handler:

@ -34,7 +34,7 @@ def get_profile_path(path=None):
try: try:
os.makedirs(base, 0770) os.makedirs(base, 0770)
except OSError: except OSError:
print "Could not create user directory." print 'Could not create user directory.'
if path != None: if path != None:
return os.path.join(base, path) return os.path.join(base, path)

@ -145,7 +145,7 @@ class Alert(gtk.EventBox):
if pspec.name == 'title': if pspec.name == 'title':
if self._title != value: if self._title != value:
self._title = value self._title = value
self._title_label.set_markup("<b>" + self._title + "</b>") self._title_label.set_markup('<b>' + self._title + '</b>')
elif pspec.name == 'msg': elif pspec.name == 'msg':
if self._msg != value: if self._msg != value:
self._msg = value self._msg = value

@ -65,7 +65,7 @@ class ComboBox(gtk.ComboBox):
width, height = gtk.icon_size_lookup(size) width, height = gtk.icon_size_lookup(size)
info = icon_theme.lookup_icon(name, max(width, height), 0) info = icon_theme.lookup_icon(name, max(width, height), 0)
if not info: if not info:
raise ValueError("Icon '" + name + "' not found.") raise ValueError('Icon %r not found.' % name)
fname = info.get_filename() fname = info.get_filename()
del info del info
return fname return fname

@ -247,7 +247,7 @@ class _IconBuffer(object):
# -- 2007-12-14 Benjamin Berg # -- 2007-12-14 Benjamin Berg
pixbuf = widget.style.render_icon(icon_source, widget.get_direction(), pixbuf = widget.style.render_icon(icon_source, widget.get_direction(),
gtk.STATE_INSENSITIVE, -1, widget, gtk.STATE_INSENSITIVE, -1, widget,
"sugar-icon") 'sugar-icon')
return pixbuf return pixbuf

@ -68,8 +68,8 @@ class ObjectChooser(object):
self._bus = dbus.SessionBus(mainloop=self._main_loop) self._bus = dbus.SessionBus(mainloop=self._main_loop)
self._bus.add_signal_receiver( self._bus.add_signal_receiver(
self.__name_owner_changed_cb, self.__name_owner_changed_cb,
signal_name="NameOwnerChanged", signal_name='NameOwnerChanged',
dbus_interface="org.freedesktop.DBus", dbus_interface='org.freedesktop.DBus',
arg0=J_DBUS_SERVICE) arg0=J_DBUS_SERVICE)
obj = self._bus.get_object(J_DBUS_SERVICE, J_DBUS_PATH) obj = self._bus.get_object(J_DBUS_SERVICE, J_DBUS_PATH)

@ -165,7 +165,7 @@ class PaletteWindow(gtk.Window):
self.set_data('sugar-accel-group', accel_group) self.set_data('sugar-accel-group', accel_group)
self.add_accel_group(accel_group) self.add_accel_group(accel_group)
self.set_group_id("default") self.set_group_id('default')
self.connect('show', self.__show_cb) self.connect('show', self.__show_cb)
self.connect('hide', self.__hide_cb) self.connect('hide', self.__hide_cb)
@ -279,12 +279,12 @@ class PaletteWindow(gtk.Window):
if gap: if gap:
wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT, wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_IN, event.area, self, "palette", gtk.SHADOW_IN, event.area, self, 'palette',
0, 0, allocation.width, allocation.height, 0, 0, allocation.width, allocation.height,
gap[0], gap[1], gap[2]) gap[0], gap[1], gap[2])
else: else:
wstyle.paint_box(event.window, gtk.STATE_PRELIGHT, wstyle.paint_box(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_IN, event.area, self, "palette", gtk.SHADOW_IN, event.area, self, 'palette',
0, 0, allocation.width, allocation.height) 0, 0, allocation.width, allocation.height)
# Fall trough to the container expose handler. # Fall trough to the container expose handler.
@ -740,14 +740,14 @@ class WidgetInvoker(Invoker):
if gap: if gap:
wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT, wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_IN, event.area, self._widget, gtk.SHADOW_IN, event.area, self._widget,
"palette-invoker", x, y, 'palette-invoker', x, y,
self._widget.allocation.width, self._widget.allocation.width,
self._widget.allocation.height, self._widget.allocation.height,
gap[0], gap[1], gap[2]) gap[0], gap[1], gap[2])
else: else:
wstyle.paint_box(event.window, gtk.STATE_PRELIGHT, wstyle.paint_box(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_IN, event.area, self._widget, gtk.SHADOW_IN, event.area, self._widget,
"palette-invoker", x, y, 'palette-invoker', x, y,
self._widget.allocation.width, self._widget.allocation.width,
self._widget.allocation.height) self._widget.allocation.height)

@ -175,7 +175,7 @@ class RadioToolButton(gtk.RadioToolButton):
elif child.state == gtk.STATE_PRELIGHT: elif child.state == gtk.STATE_PRELIGHT:
child.style.paint_box(event.window, gtk.STATE_PRELIGHT, child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_NONE, event.area, gtk.SHADOW_NONE, event.area,
child, "toolbutton-prelight", child, 'toolbutton-prelight',
allocation.x, allocation.y, allocation.x, allocation.y,
allocation.width, allocation.height) allocation.width, allocation.height)

@ -28,7 +28,7 @@ from sugar.graphics.palette import Palette, ToolInvoker
class ToggleToolButton(gtk.ToggleToolButton): class ToggleToolButton(gtk.ToggleToolButton):
__gtype_name__ = "SugarToggleToolButton" __gtype_name__ = 'SugarToggleToolButton'
def __init__(self, named_icon=None): def __init__(self, named_icon=None):
gtk.ToggleToolButton.__init__(self) gtk.ToggleToolButton.__init__(self)
@ -82,7 +82,7 @@ class ToggleToolButton(gtk.ToggleToolButton):
elif child.state == gtk.STATE_PRELIGHT: elif child.state == gtk.STATE_PRELIGHT:
child.style.paint_box(event.window, gtk.STATE_PRELIGHT, child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_NONE, event.area, gtk.SHADOW_NONE, event.area,
child, "toolbutton-prelight", child, 'toolbutton-prelight',
allocation.x, allocation.y, allocation.x, allocation.y,
allocation.width, allocation.height) allocation.width, allocation.height)

@ -59,7 +59,7 @@ def setup_accelerator(tool_button):
class ToolButton(gtk.ToolButton): class ToolButton(gtk.ToolButton):
__gtype_name__ = "SugarToolButton" __gtype_name__ = 'SugarToolButton'
def __init__(self, icon_name=None, **kwargs): def __init__(self, icon_name=None, **kwargs):
self._accelerator = None self._accelerator = None
@ -151,7 +151,7 @@ class ToolButton(gtk.ToolButton):
elif child.state == gtk.STATE_PRELIGHT: elif child.state == gtk.STATE_PRELIGHT:
child.style.paint_box(event.window, gtk.STATE_PRELIGHT, child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
gtk.SHADOW_NONE, event.area, gtk.SHADOW_NONE, event.area,
child, "toolbutton-prelight", child, 'toolbutton-prelight',
allocation.x, allocation.y, allocation.x, allocation.y,
allocation.width, allocation.height) allocation.width, allocation.height)

@ -396,7 +396,7 @@ class TrayButton(ToolButton):
class _IconWidget(gtk.EventBox): class _IconWidget(gtk.EventBox):
__gtype_name__ = "SugarTrayIconWidget" __gtype_name__ = 'SugarTrayIconWidget'
def __init__(self, icon_name=None, xo_color=None): def __init__(self, icon_name=None, xo_color=None):
gtk.EventBox.__init__(self) gtk.EventBox.__init__(self)
@ -422,7 +422,7 @@ class _IconWidget(gtk.EventBox):
class TrayIcon(gtk.ToolItem): class TrayIcon(gtk.ToolItem):
__gtype_name__ = "SugarTrayIcon" __gtype_name__ = 'SugarTrayIcon'
def __init__(self, icon_name=None, xo_color=None): def __init__(self, icon_name=None, xo_color=None):
gtk.ToolItem.__init__(self) gtk.ToolItem.__init__(self)

@ -261,7 +261,7 @@ class XoColor:
return '%s,%s' % (self.stroke, self.fill) return '%s,%s' % (self.stroke, self.fill)
if __name__ == "__main__": if __name__ == '__main__':
import sys import sys
import re import re

@ -147,12 +147,12 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
""" """
path = self.translate_path(self.path) path = self.translate_path(self.path)
if not path or not os.path.exists(path): if not path or not os.path.exists(path):
self.send_error(404, "File not found") self.send_error(404, 'File not found')
return None return None
f = None f = None
if os.path.isdir(path): if os.path.isdir(path):
for index in "index.html", "index.htm": for index in 'index.html', 'index.htm':
index = os.path.join(path, index) index = os.path.join(path, index)
if os.path.exists(index): if os.path.exists(index):
path = index path = index
@ -166,12 +166,12 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# transmitted *less* than the content-length! # transmitted *less* than the content-length!
f = open(path, 'rb') f = open(path, 'rb')
except IOError: except IOError:
self.send_error(404, "File not found") self.send_error(404, 'File not found')
return None return None
self.send_response(200) self.send_response(200)
self.send_header("Content-type", ctype) self.send_header('Content-type', ctype)
self.send_header("Content-Length", str(os.fstat(f.fileno())[6])) self.send_header('Content-Length', str(os.fstat(f.fileno())[6]))
self.send_header("Content-Disposition", 'attachment; filename="%s"' % self.send_header('Content-Disposition', 'attachment; filename="%s"' %
os.path.basename(path)) os.path.basename(path))
self.end_headers() self.end_headers()
return f return f
@ -209,8 +209,8 @@ class GlibURLDownloader(gobject.GObject):
self._outf = None self._outf = None
self._fname = None self._fname = None
if destfd and not destfile: if destfd and not destfile:
raise ValueError("Must provide destination file too when" \ raise ValueError('Must provide destination file too when'
"specifying file descriptor") ' specifying file descriptor')
if destfile: if destfile:
self._suggested_fname = os.path.basename(destfile) self._suggested_fname = os.path.basename(destfile)
self._fname = os.path.abspath(os.path.expanduser(destfile)) self._fname = os.path.abspath(os.path.expanduser(destfile))
@ -238,15 +238,15 @@ class GlibURLDownloader(gobject.GObject):
def cancel(self): def cancel(self):
if self._srcid == 0: if self._srcid == 0:
raise RuntimeError("Download already canceled or stopped") raise RuntimeError('Download already canceled or stopped')
self.cleanup(remove=True) self.cleanup(remove=True)
def _get_filename_from_headers(self, headers): def _get_filename_from_headers(self, headers):
if 'Content-Disposition' not in headers: if 'Content-Disposition' not in headers:
return None return None
ftag = "filename=" ftag = 'filename='
data = headers["Content-Disposition"] data = headers['Content-Disposition']
fidx = data.find(ftag) fidx = data.find(ftag)
if fidx < 0: if fidx < 0:
return None return None
@ -260,7 +260,7 @@ class GlibURLDownloader(gobject.GObject):
def _read_next_chunk(self, source, condition): def _read_next_chunk(self, source, condition):
if condition & gobject.IO_ERR: if condition & gobject.IO_ERR:
self.cleanup(remove=True) self.cleanup(remove=True)
self.emit("error", "Error downloading file.") self.emit('error', 'Error downloading file.')
return False return False
elif not (condition & gobject.IO_IN): elif not (condition & gobject.IO_IN):
# shouldn't get here, but... # shouldn't get here, but...
@ -274,19 +274,19 @@ class GlibURLDownloader(gobject.GObject):
# error writing data to file? # error writing data to file?
if count < len(data): if count < len(data):
self.cleanup(remove=True) self.cleanup(remove=True)
self.emit("error", "Error writing to download file.") self.emit('error', 'Error writing to download file.')
return False return False
self.emit("progress", self._written) self.emit('progress', self._written)
# done? # done?
if len(data) < self.CHUNK_SIZE: if len(data) < self.CHUNK_SIZE:
self.cleanup() self.cleanup()
self.emit("finished", self._fname, self._suggested_fname) self.emit('finished', self._fname, self._suggested_fname)
return False return False
except Exception, err: except Exception, err:
self.cleanup(remove=True) self.cleanup(remove=True)
self.emit("error", "Error downloading file: %s" % err) self.emit('error', 'Error downloading file: %r' % err)
return False return False
return True return True

@ -180,7 +180,7 @@ class Activity(gobject.GObject):
def do_get_property(self, pspec): def do_get_property(self, pspec):
"""Retrieve a particular property from our property dictionary""" """Retrieve a particular property from our property dictionary"""
if pspec.name == "joined": if pspec.name == 'joined':
return self._joined return self._joined
if self._get_properties_call is not None: if self._get_properties_call is not None:
@ -188,17 +188,17 @@ class Activity(gobject.GObject):
'wants property %s', self, pspec.name) 'wants property %s', self, pspec.name)
self._get_properties_call.block() self._get_properties_call.block()
if pspec.name == "id": if pspec.name == 'id':
return self._id return self._id
elif pspec.name == "name": elif pspec.name == 'name':
return self._name return self._name
elif pspec.name == "color": elif pspec.name == 'color':
return self._color return self._color
elif pspec.name == "type": elif pspec.name == 'type':
return self._type return self._type
elif pspec.name == "tags": elif pspec.name == 'tags':
return self._tags return self._tags
elif pspec.name == "private": elif pspec.name == 'private':
return self._private return self._private
def do_set_property(self, pspec, val): def do_set_property(self, pspec, val):
@ -206,16 +206,16 @@ class Activity(gobject.GObject):
# FIXME: need an asynchronous API to set these properties, # FIXME: need an asynchronous API to set these properties,
# particularly 'private' # particularly 'private'
if pspec.name == "name": if pspec.name == 'name':
self._name = val self._name = val
elif pspec.name == "color": elif pspec.name == 'color':
self._color = val self._color = val
elif pspec.name == "tags": elif pspec.name == 'tags':
self._tags = val self._tags = val
elif pspec.name == "private": elif pspec.name == 'private':
self._private = val self._private = val
else: else:
raise ValueError('Unknown property "%s"', pspec.name) raise ValueError('Unknown property %r', pspec.name)
self._publish_properties() self._publish_properties()
@ -457,7 +457,7 @@ class Activity(gobject.GObject):
# Leaving # Leaving
def __text_channel_closed_cb(self): def __text_channel_closed_cb(self):
self._joined = False self._joined = False
self.emit("joined", False, "left activity") self.emit('joined', False, 'left activity')
def leave(self): def leave(self):
"""Leave this shared activity""" """Leave this shared activity"""

@ -244,5 +244,5 @@ class Owner(BaseBuddy):
BaseBuddy.__init__(self) BaseBuddy.__init__(self)
client = gconf.client_get_default() client = gconf.client_get_default()
self.props.nick = client.get_string("/desktop/sugar/user/nick") self.props.nick = client.get_string('/desktop/sugar/user/nick')
self.props.color = client.get_string("/desktop/sugar/user/color") self.props.color = client.get_string('/desktop/sugar/user/color')

@ -82,7 +82,7 @@ class PresenceService(gobject.GObject):
for account_path, connection in connections_per_account.items(): for account_path, connection in connections_per_account.items():
if not connection.connected: if not connection.connected:
continue continue
logging.debug("Calling GetActivity on %s", account_path) logging.debug('Calling GetActivity on %s', account_path)
try: try:
room_handle = connection.connection.GetActivity( room_handle = connection.connection.GetActivity(
activity_id, activity_id,
@ -172,12 +172,12 @@ class PresenceService(gobject.GObject):
def __share_activity_cb(self, activity): def __share_activity_cb(self, activity):
"""Finish sharing the activity """Finish sharing the activity
""" """
self.emit("activity-shared", True, activity, None) self.emit('activity-shared', True, activity, None)
def __share_activity_error_cb(self, activity, error): def __share_activity_error_cb(self, activity, error):
"""Notify with GObject event of unsuccessful sharing of activity """Notify with GObject event of unsuccessful sharing of activity
""" """
self.emit("activity-shared", False, activity, error) self.emit('activity-shared', False, activity, error)
def share_activity(self, activity, properties=None, private=True): def share_activity(self, activity, properties=None, private=True):
if properties is None: if properties is None:

@ -69,8 +69,8 @@ class Profile(object):
def is_valid(self): def is_valid(self):
client = gconf.client_get_default() client = gconf.client_get_default()
nick = client.get_string("/desktop/sugar/user/nick") nick = client.get_string('/desktop/sugar/user/nick')
color = client.get_string("/desktop/sugar/user/color") color = client.get_string('/desktop/sugar/user/color')
return nick is not '' and \ return nick is not '' and \
color is not '' and \ color is not '' and \
@ -84,21 +84,21 @@ class Profile(object):
return None return None
try: try:
f = open(key_path, "r") f = open(key_path, 'r')
lines = f.readlines() lines = f.readlines()
f.close() f.close()
except IOError: except IOError:
logging.exception('Error reading public key') logging.exception('Error reading public key')
return None return None
magic = "ssh-dss " magic = 'ssh-dss '
for l in lines: for l in lines:
l = l.strip() l = l.strip()
if not l.startswith(magic): if not l.startswith(magic):
continue continue
return l[len(magic):] return l[len(magic):]
else: else:
logging.error("Error parsing public key.") logging.error('Error parsing public key.')
return None return None
def _hash_private_key(self): def _hash_private_key(self):
@ -108,7 +108,7 @@ class Profile(object):
return None return None
try: try:
f = open(key_path, "r") f = open(key_path, 'r')
lines = f.readlines() lines = f.readlines()
f.close() f.close()
except IOError: except IOError:
@ -120,15 +120,15 @@ class Profile(object):
end_found = False end_found = False
for l in lines: for l in lines:
l = l.strip() l = l.strip()
if l.startswith("-----BEGIN DSA PRIVATE KEY-----"): if l.startswith('-----BEGIN DSA PRIVATE KEY-----'):
begin_found = True begin_found = True
continue continue
if l.startswith("-----END DSA PRIVATE KEY-----"): if l.startswith('-----END DSA PRIVATE KEY-----'):
end_found = True end_found = True
continue continue
key += l key += l
if not (len(key) and begin_found and end_found): if not (len(key) and begin_found and end_found):
logging.error("Error parsing public key.") logging.error('Error parsing public key.')
return None return None
# hash it # hash it
@ -145,41 +145,41 @@ class Profile(object):
if cp.has_option('Buddy', 'NickName'): if cp.has_option('Buddy', 'NickName'):
name = cp.get('Buddy', 'NickName') name = cp.get('Buddy', 'NickName')
# decode nickname from ascii-safe chars to unicode # decode nickname from ascii-safe chars to unicode
nick = name.decode("utf-8") nick = name.decode('utf-8')
client.set_string("/desktop/sugar/user/nick", nick) client.set_string('/desktop/sugar/user/nick', nick)
if cp.has_option('Buddy', 'Color'): if cp.has_option('Buddy', 'Color'):
color = cp.get('Buddy', 'Color') color = cp.get('Buddy', 'Color')
client.set_string("/desktop/sugar/user/color", color) client.set_string('/desktop/sugar/user/color', color)
if cp.has_option('Jabber', 'Server'): if cp.has_option('Jabber', 'Server'):
server = cp.get('Jabber', 'Server') server = cp.get('Jabber', 'Server')
client.set_string("/desktop/sugar/collaboration/jabber_server", client.set_string('/desktop/sugar/collaboration/jabber_server',
server) server)
if cp.has_option('Date', 'Timezone'): if cp.has_option('Date', 'Timezone'):
timezone = cp.get('Date', 'Timezone') timezone = cp.get('Date', 'Timezone')
client.set_string("/desktop/sugar/date/timezone", timezone) client.set_string('/desktop/sugar/date/timezone', timezone)
if cp.has_option('Frame', 'HotCorners'): if cp.has_option('Frame', 'HotCorners'):
delay = float(cp.get('Frame', 'HotCorners')) delay = float(cp.get('Frame', 'HotCorners'))
client.set_int("/desktop/sugar/frame/corner_delay", int(delay)) client.set_int('/desktop/sugar/frame/corner_delay', int(delay))
if cp.has_option('Frame', 'WarmEdges'): if cp.has_option('Frame', 'WarmEdges'):
delay = float(cp.get('Frame', 'WarmEdges')) delay = float(cp.get('Frame', 'WarmEdges'))
client.set_int("/desktop/sugar/frame/edge_delay", int(delay)) client.set_int('/desktop/sugar/frame/edge_delay', int(delay))
if cp.has_option('Server', 'Backup1'): if cp.has_option('Server', 'Backup1'):
backup1 = cp.get('Server', 'Backup1') backup1 = cp.get('Server', 'Backup1')
client.set_string("/desktop/sugar/backup_url", backup1) client.set_string('/desktop/sugar/backup_url', backup1)
if cp.has_option('Sound', 'Volume'): if cp.has_option('Sound', 'Volume'):
volume = float(cp.get('Sound', 'Volume')) volume = float(cp.get('Sound', 'Volume'))
client.set_int("/desktop/sugar/sound/volume", int(volume)) client.set_int('/desktop/sugar/sound/volume', int(volume))
if cp.has_option('Power', 'AutomaticPM'): if cp.has_option('Power', 'AutomaticPM'):
state = cp.get('Power', 'AutomaticPM') state = cp.get('Power', 'AutomaticPM')
if state.lower() == "true": if state.lower() == 'true':
client.set_bool("/desktop/sugar/power/automatic", True) client.set_bool('/desktop/sugar/power/automatic', True)
if cp.has_option('Power', 'ExtremePM'): if cp.has_option('Power', 'ExtremePM'):
state = cp.get('Power', 'ExtremePM') state = cp.get('Power', 'ExtremePM')
if state.lower() == "true": if state.lower() == 'true':
client.set_bool("/desktop/sugar/power/extreme", True) client.set_bool('/desktop/sugar/power/extreme', True)
if cp.has_option('Shell', 'FavoritesLayout'): if cp.has_option('Shell', 'FavoritesLayout'):
layout = cp.get('Shell', 'FavoritesLayout') layout = cp.get('Shell', 'FavoritesLayout')
client.set_string("/desktop/sugar/desktop/favorites_layout", client.set_string('/desktop/sugar/desktop/favorites_layout',
layout) layout)
del cp del cp
try: try:
@ -225,12 +225,12 @@ def get_profile():
def get_nick_name(): def get_nick_name():
client = gconf.client_get_default() client = gconf.client_get_default()
return client.get_string("/desktop/sugar/user/nick") return client.get_string('/desktop/sugar/user/nick')
def get_color(): def get_color():
client = gconf.client_get_default() client = gconf.client_get_default()
color = client.get_string("/desktop/sugar/user/color") color = client.get_string('/desktop/sugar/user/color')
return XoColor(color) return XoColor(color)

@ -64,7 +64,7 @@ def unique_id(data=''):
to be unique-enough, no attempt is made to make to be unique-enough, no attempt is made to make
perfectly unique values. perfectly unique values.
""" """
data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data) data_string = '%s%s%s' % (time.time(), random.randint(10000, 100000), data)
return printable_hash(sha_data(data_string)) return printable_hash(sha_data(data_string))

@ -45,7 +45,7 @@ class TestPalette(Test):
class TestRunner(object): class TestRunner(object):
def run(self, test): def run(self, test):
window = gtk.Window() window = gtk.Window()
window.connect("destroy", lambda w: gtk.main_quit()) window.connect('destroy', lambda w: gtk.main_quit())
window.add(test) window.add(test)
test.show() test.show()

@ -47,5 +47,5 @@ gobject.idle_add(idle_cb)
test.show() test.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -59,12 +59,12 @@ for d in data:
test.pack_start(icon) test.pack_start(icon)
icon.show() icon.show()
button = gtk.Button("mec mac") button = gtk.Button('mec mac')
test.pack_start(button) test.pack_start(button)
button.connect('activate', _button_activated_cb) button.connect('activate', _button_activated_cb)
button.show() button.show()
test.show() test.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -83,5 +83,5 @@ test.show()
#import gobject #import gobject
#gobject.idle_add(idle_cb) #gobject.idle_add(idle_cb)
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -55,5 +55,5 @@ radio.show()
palette.set_content(box) palette.set_content(box)
box.show() box.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -34,5 +34,5 @@ text_view.props.buffer.props.text = 'Blah blah blah, blah blah blah.'
test.pack_start(text_view) test.pack_start(text_view)
text_view.show() text_view.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -44,5 +44,5 @@ toolbar.insert(button, -1)
button.show() button.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -61,5 +61,5 @@ vbox.show()
test.show() test.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -78,5 +78,5 @@ vbox.show()
test.show() test.show()
if __name__ == "__main__": if __name__ == '__main__':
common.main(test) common.main(test)

@ -80,5 +80,5 @@ class TestMime(unittest.TestCase):
self.assertEqual(mime_type, 'text/plain') self.assertEqual(mime_type, 'text/plain')
if __name__ == "__main__": if __name__ == '__main__':
unittest.main() unittest.main()

Loading…
Cancel
Save