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>
This commit is contained in:
parent
5f13fcfc84
commit
7acfbd070f
@ -21,7 +21,7 @@ box.pack_start(text_view)
|
||||
def echo(button, label):
|
||||
if not button.props.active:
|
||||
return
|
||||
text_view.props.buffer.props.text += "\n" + label
|
||||
text_view.props.buffer.props.text += '\n' + label
|
||||
|
||||
# RadioMenuButton
|
||||
|
||||
|
@ -88,9 +88,9 @@ from sugar.activity.widgets import ActivityToolbox
|
||||
|
||||
_ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
|
||||
|
||||
SCOPE_PRIVATE = "private"
|
||||
SCOPE_INVITE_ONLY = "invite" # shouldn't be shown in UI, it's implicit
|
||||
SCOPE_NEIGHBORHOOD = "public"
|
||||
SCOPE_PRIVATE = 'private'
|
||||
SCOPE_INVITE_ONLY = 'invite' # shouldn't be shown in UI, it's implicit
|
||||
SCOPE_NEIGHBORHOOD = 'public'
|
||||
|
||||
J_DBUS_SERVICE = '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
|
||||
# are supported in the future we will get a better view
|
||||
# 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)
|
||||
|
||||
self.connect('realize', self.__realize_cb)
|
||||
@ -362,16 +362,16 @@ class Activity(Window, gtk.Container):
|
||||
|
||||
def _set_up_sharing(self, mesh_instance, share_scope):
|
||||
# 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)
|
||||
if mesh_instance is not None:
|
||||
# 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.shared_activity = mesh_instance
|
||||
self.shared_activity.connect('notify::private',
|
||||
self.__privacy_changed_cb)
|
||||
self._join_id = self.shared_activity.connect("joined",
|
||||
self._join_id = self.shared_activity.connect('joined',
|
||||
self.__joined_cb)
|
||||
if not self.shared_activity.props.joined:
|
||||
self.shared_activity.join()
|
||||
@ -778,7 +778,7 @@ class Activity(Window, gtk.Container):
|
||||
its 'private' property.
|
||||
"""
|
||||
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)
|
||||
verb = private and 'private' or 'public'
|
||||
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.
|
||||
|
||||
Activities can set metadata in write_file() using:
|
||||
self.metadata['MyKey'] = "Something"
|
||||
self.metadata['MyKey'] = 'Something'
|
||||
|
||||
and retrieve metadata in read_file() using:
|
||||
self.metadata.get('MyKey', 'aDefaultValue')
|
||||
@ -976,7 +976,7 @@ def get_activity_root():
|
||||
if os.environ.get('SUGAR_ACTIVITY_ROOT'):
|
||||
return os.environ['SUGAR_ACTIVITY_ROOT']
|
||||
else:
|
||||
raise RuntimeError("No SUGAR_ACTIVITY_ROOT set.")
|
||||
raise RuntimeError('No SUGAR_ACTIVITY_ROOT set.')
|
||||
|
||||
|
||||
def show_object_in_journal(object_id):
|
||||
|
@ -40,16 +40,16 @@ import tempfile
|
||||
import subprocess
|
||||
import pwd
|
||||
|
||||
_SHELL_SERVICE = "org.laptop.Shell"
|
||||
_SHELL_PATH = "/org/laptop/Shell"
|
||||
_SHELL_IFACE = "org.laptop.Shell"
|
||||
_SHELL_SERVICE = 'org.laptop.Shell'
|
||||
_SHELL_PATH = '/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
|
||||
# borrowed from subprocess.py
|
||||
try:
|
||||
MAXFD = os.sysconf("SC_OPEN_MAX")
|
||||
MAXFD = os.sysconf('SC_OPEN_MAX')
|
||||
except ValueError:
|
||||
MAXFD = 256
|
||||
|
||||
@ -284,7 +284,7 @@ class ActivityCreationHandler(gobject.GObject):
|
||||
self._handle.activity_id, self._service_name)
|
||||
|
||||
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._shell.NotifyLaunchFailure(
|
||||
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):
|
||||
if count > 0:
|
||||
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._launch_activity()
|
||||
|
||||
|
@ -25,9 +25,9 @@ import dbus
|
||||
import dbus.service
|
||||
|
||||
|
||||
_ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
|
||||
_ACTIVITY_SERVICE_PATH = "/org/laptop/Activity"
|
||||
_ACTIVITY_INTERFACE = "org.laptop.Activity"
|
||||
_ACTIVITY_SERVICE_NAME = 'org.laptop.Activity'
|
||||
_ACTIVITY_SERVICE_PATH = '/org/laptop/Activity'
|
||||
_ACTIVITY_INTERFACE = 'org.laptop.Activity'
|
||||
|
||||
|
||||
class ActivityService(dbus.service.Object):
|
||||
|
@ -108,7 +108,7 @@ class Builder(object):
|
||||
po_dir = os.path.join(self.config.source_dir, 'po')
|
||||
|
||||
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
|
||||
|
||||
locale_dir = os.path.join(self.config.source_dir, 'locale')
|
||||
@ -128,8 +128,8 @@ class Builder(object):
|
||||
if not os.path.isdir(mo_path):
|
||||
os.makedirs(mo_path)
|
||||
|
||||
mo_file = os.path.join(mo_path, "%s.mo" % self.config.bundle_id)
|
||||
args = ["msgfmt", "--output-file=%s" % mo_file, file_name]
|
||||
mo_file = os.path.join(mo_path, '%s.mo' % self.config.bundle_id)
|
||||
args = ['msgfmt', '--output-file=%s' % mo_file, file_name]
|
||||
retcode = subprocess.call(args)
|
||||
if retcode:
|
||||
print 'ERROR - msgfmt failed with return code %i.' % retcode
|
||||
@ -170,9 +170,9 @@ class Builder(object):
|
||||
for path in self.check_manifest():
|
||||
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:
|
||||
f.write(line + "\n")
|
||||
f.write(line + '\n')
|
||||
|
||||
|
||||
class Packager(object):
|
||||
@ -399,7 +399,7 @@ def print_commands():
|
||||
|
||||
for name, func in globals().items():
|
||||
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 ' \
|
||||
'particular command\'s options.'
|
||||
@ -407,7 +407,7 @@ def print_commands():
|
||||
|
||||
def start(bundle_name=None):
|
||||
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.disable_interspersed_args()
|
||||
|
@ -118,7 +118,7 @@ def get_locale_path(bundle_id):
|
||||
candidate_dirs[os.environ['SUGAR_LOCALEDIR']] = 2
|
||||
|
||||
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 '':
|
||||
candidate_dirs[package_dir] = 1
|
||||
|
||||
|
@ -56,7 +56,7 @@ class SingleProcess(dbus.service.Object):
|
||||
object_path = get_single_process_path(name_service)
|
||||
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):
|
||||
handle = activityhandle.create_from_dict(handle_dict)
|
||||
create_activity_instance(self.constructor, handle)
|
||||
@ -64,14 +64,14 @@ class SingleProcess(dbus.service.Object):
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
parser.add_option("-b", "--bundle-id", dest="bundle_id",
|
||||
help="identifier of the activity bundle")
|
||||
parser.add_option("-a", "--activity-id", dest="activity_id",
|
||||
help="identifier of the activity instance")
|
||||
parser.add_option("-o", "--object-id", dest="object_id",
|
||||
help="identifier of the associated datastore object")
|
||||
parser.add_option("-u", "--uri", dest="uri",
|
||||
help="URI to load")
|
||||
parser.add_option('-b', '--bundle-id', dest='bundle_id',
|
||||
help='identifier of the activity bundle')
|
||||
parser.add_option('-a', '--activity-id', dest='activity_id',
|
||||
help='identifier of the activity instance')
|
||||
parser.add_option('-o', '--object-id', dest='object_id',
|
||||
help='identifier of the associated datastore object')
|
||||
parser.add_option('-u', '--uri', dest='uri',
|
||||
help='URI to load')
|
||||
parser.add_option('-s', '--single-process', dest='single_process',
|
||||
action='store_true',
|
||||
help='start all the instances in the same process')
|
||||
|
@ -87,9 +87,9 @@ class ActivityBundle(Bundle):
|
||||
"activity startup.")
|
||||
|
||||
def _raw_manifest(self):
|
||||
f = self.get_file("MANIFEST")
|
||||
f = self.get_file('MANIFEST')
|
||||
if not f:
|
||||
logging.warning("Activity directory lacks a MANIFEST file.")
|
||||
logging.warning('Activity directory lacks a MANIFEST file.')
|
||||
return []
|
||||
|
||||
ret = [line.strip() for line in f.readlines()]
|
||||
@ -108,7 +108,7 @@ class ActivityBundle(Bundle):
|
||||
lines = self._raw_manifest()
|
||||
|
||||
# Remove trailing newlines, they do not help keep absolute position.
|
||||
while lines and lines[-1] == "":
|
||||
while lines and lines[-1] == '':
|
||||
lines = lines[:-1]
|
||||
|
||||
for num, line in enumerate(lines):
|
||||
@ -117,20 +117,20 @@ class ActivityBundle(Bundle):
|
||||
|
||||
# Remove duplicates
|
||||
if line in lines[0:num]:
|
||||
lines[num] = ""
|
||||
lines[num] = ''
|
||||
logging.warning('Bundle %s: duplicate entry in MANIFEST: %s',
|
||||
self._name, line)
|
||||
continue
|
||||
|
||||
# Remove MANIFEST
|
||||
if line == "MANIFEST":
|
||||
lines[num] = ""
|
||||
if line == 'MANIFEST':
|
||||
lines[num] = ''
|
||||
logging.warning('Bundle %s: MANIFEST includes itself: %s',
|
||||
self._name, line)
|
||||
|
||||
# Remove invalid files
|
||||
if not self.is_file(line):
|
||||
lines[num] = ""
|
||||
lines[num] = ''
|
||||
logging.warning('Bundle %s: invalid entry in MANIFEST: %s',
|
||||
self._name, line)
|
||||
|
||||
@ -328,7 +328,7 @@ class ActivityBundle(Bundle):
|
||||
for path in paths:
|
||||
if path in manifestfiles:
|
||||
manifestfiles.remove(path)
|
||||
elif path != "MANIFEST":
|
||||
elif path != 'MANIFEST':
|
||||
logging.warning('Bundle %s: %s not in MANIFEST', self._name,
|
||||
path)
|
||||
if strict_manifest:
|
||||
@ -336,7 +336,7 @@ class ActivityBundle(Bundle):
|
||||
|
||||
# Is anything in MANIFEST left over after accounting for all files?
|
||||
if manifestfiles:
|
||||
err = ("Bundle %s: files in MANIFEST not included: %s" %
|
||||
err = ('Bundle %s: files in MANIFEST not included: %s' %
|
||||
(self._name, str(manifestfiles)))
|
||||
if strict_manifest:
|
||||
raise MalformedBundleException(err)
|
||||
|
@ -103,7 +103,7 @@ class Bundle(object):
|
||||
if ext != self._unzipped_extension:
|
||||
raise MalformedBundleException(
|
||||
'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)
|
||||
|
||||
for file_name in file_names:
|
||||
@ -118,7 +118,7 @@ class Bundle(object):
|
||||
if self._zip_file is None:
|
||||
path = os.path.join(self._path, filename)
|
||||
try:
|
||||
f = open(path, "rb")
|
||||
f = open(path, 'rb')
|
||||
except IOError:
|
||||
return None
|
||||
else:
|
||||
|
@ -97,7 +97,7 @@ class ContentBundle(Bundle):
|
||||
self._l10n = False
|
||||
else:
|
||||
raise MalformedBundleException(
|
||||
'Content bundle %s has invalid l10n key "%s"' %
|
||||
'Content bundle %s has invalid l10n key %r' %
|
||||
(self._path, l10n))
|
||||
else:
|
||||
raise MalformedBundleException(
|
||||
@ -196,7 +196,7 @@ class ContentBundle(Bundle):
|
||||
return os.path.join(self.get_root_dir(), self._activity_start)
|
||||
|
||||
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):
|
||||
# TODO treat ContentBundle in special way
|
||||
|
@ -35,9 +35,9 @@ from sugar import env
|
||||
from sugar import mime
|
||||
from sugar import dispatch
|
||||
|
||||
DS_DBUS_SERVICE = "org.laptop.sugar.DataStore"
|
||||
DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore"
|
||||
DS_DBUS_PATH = "/org/laptop/sugar/DataStore"
|
||||
DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore'
|
||||
DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore'
|
||||
DS_DBUS_PATH = '/org/laptop/sugar/DataStore'
|
||||
|
||||
_data_store = None
|
||||
|
||||
@ -316,8 +316,8 @@ def create():
|
||||
def _update_ds_entry(uid, properties, filename, transfer_ownership=False,
|
||||
reply_handler=None, error_handler=None, timeout=-1):
|
||||
debug_properties = properties.copy()
|
||||
if "preview" in debug_properties:
|
||||
debug_properties["preview"] = "<omitted>"
|
||||
if 'preview' in debug_properties:
|
||||
debug_properties['preview'] = '<omitted>'
|
||||
logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename,
|
||||
debug_properties, transfer_ownership)
|
||||
if reply_handler and error_handler:
|
||||
|
@ -34,7 +34,7 @@ def get_profile_path(path=None):
|
||||
try:
|
||||
os.makedirs(base, 0770)
|
||||
except OSError:
|
||||
print "Could not create user directory."
|
||||
print 'Could not create user directory.'
|
||||
|
||||
if path != None:
|
||||
return os.path.join(base, path)
|
||||
|
@ -145,7 +145,7 @@ class Alert(gtk.EventBox):
|
||||
if pspec.name == 'title':
|
||||
if 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':
|
||||
if self._msg != value:
|
||||
self._msg = value
|
||||
|
@ -65,7 +65,7 @@ class ComboBox(gtk.ComboBox):
|
||||
width, height = gtk.icon_size_lookup(size)
|
||||
info = icon_theme.lookup_icon(name, max(width, height), 0)
|
||||
if not info:
|
||||
raise ValueError("Icon '" + name + "' not found.")
|
||||
raise ValueError('Icon %r not found.' % name)
|
||||
fname = info.get_filename()
|
||||
del info
|
||||
return fname
|
||||
|
@ -247,7 +247,7 @@ class _IconBuffer(object):
|
||||
# -- 2007-12-14 Benjamin Berg
|
||||
pixbuf = widget.style.render_icon(icon_source, widget.get_direction(),
|
||||
gtk.STATE_INSENSITIVE, -1, widget,
|
||||
"sugar-icon")
|
||||
'sugar-icon')
|
||||
|
||||
return pixbuf
|
||||
|
||||
|
@ -68,8 +68,8 @@ class ObjectChooser(object):
|
||||
self._bus = dbus.SessionBus(mainloop=self._main_loop)
|
||||
self._bus.add_signal_receiver(
|
||||
self.__name_owner_changed_cb,
|
||||
signal_name="NameOwnerChanged",
|
||||
dbus_interface="org.freedesktop.DBus",
|
||||
signal_name='NameOwnerChanged',
|
||||
dbus_interface='org.freedesktop.DBus',
|
||||
arg0=J_DBUS_SERVICE)
|
||||
|
||||
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.add_accel_group(accel_group)
|
||||
|
||||
self.set_group_id("default")
|
||||
self.set_group_id('default')
|
||||
|
||||
self.connect('show', self.__show_cb)
|
||||
self.connect('hide', self.__hide_cb)
|
||||
@ -279,12 +279,12 @@ class PaletteWindow(gtk.Window):
|
||||
|
||||
if gap:
|
||||
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,
|
||||
gap[0], gap[1], gap[2])
|
||||
else:
|
||||
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)
|
||||
|
||||
# Fall trough to the container expose handler.
|
||||
@ -740,14 +740,14 @@ class WidgetInvoker(Invoker):
|
||||
if gap:
|
||||
wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_IN, event.area, self._widget,
|
||||
"palette-invoker", x, y,
|
||||
'palette-invoker', x, y,
|
||||
self._widget.allocation.width,
|
||||
self._widget.allocation.height,
|
||||
gap[0], gap[1], gap[2])
|
||||
else:
|
||||
wstyle.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_IN, event.area, self._widget,
|
||||
"palette-invoker", x, y,
|
||||
'palette-invoker', x, y,
|
||||
self._widget.allocation.width,
|
||||
self._widget.allocation.height)
|
||||
|
||||
|
@ -175,7 +175,7 @@ class RadioToolButton(gtk.RadioToolButton):
|
||||
elif child.state == gtk.STATE_PRELIGHT:
|
||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
child, "toolbutton-prelight",
|
||||
child, 'toolbutton-prelight',
|
||||
allocation.x, allocation.y,
|
||||
allocation.width, allocation.height)
|
||||
|
||||
|
@ -28,7 +28,7 @@ from sugar.graphics.palette import Palette, ToolInvoker
|
||||
|
||||
class ToggleToolButton(gtk.ToggleToolButton):
|
||||
|
||||
__gtype_name__ = "SugarToggleToolButton"
|
||||
__gtype_name__ = 'SugarToggleToolButton'
|
||||
|
||||
def __init__(self, named_icon=None):
|
||||
gtk.ToggleToolButton.__init__(self)
|
||||
@ -82,7 +82,7 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
||||
elif child.state == gtk.STATE_PRELIGHT:
|
||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
child, "toolbutton-prelight",
|
||||
child, 'toolbutton-prelight',
|
||||
allocation.x, allocation.y,
|
||||
allocation.width, allocation.height)
|
||||
|
||||
|
@ -59,7 +59,7 @@ def setup_accelerator(tool_button):
|
||||
|
||||
class ToolButton(gtk.ToolButton):
|
||||
|
||||
__gtype_name__ = "SugarToolButton"
|
||||
__gtype_name__ = 'SugarToolButton'
|
||||
|
||||
def __init__(self, icon_name=None, **kwargs):
|
||||
self._accelerator = None
|
||||
@ -151,7 +151,7 @@ class ToolButton(gtk.ToolButton):
|
||||
elif child.state == gtk.STATE_PRELIGHT:
|
||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
child, "toolbutton-prelight",
|
||||
child, 'toolbutton-prelight',
|
||||
allocation.x, allocation.y,
|
||||
allocation.width, allocation.height)
|
||||
|
||||
|
@ -396,7 +396,7 @@ class TrayButton(ToolButton):
|
||||
|
||||
class _IconWidget(gtk.EventBox):
|
||||
|
||||
__gtype_name__ = "SugarTrayIconWidget"
|
||||
__gtype_name__ = 'SugarTrayIconWidget'
|
||||
|
||||
def __init__(self, icon_name=None, xo_color=None):
|
||||
gtk.EventBox.__init__(self)
|
||||
@ -422,7 +422,7 @@ class _IconWidget(gtk.EventBox):
|
||||
|
||||
class TrayIcon(gtk.ToolItem):
|
||||
|
||||
__gtype_name__ = "SugarTrayIcon"
|
||||
__gtype_name__ = 'SugarTrayIcon'
|
||||
|
||||
def __init__(self, icon_name=None, xo_color=None):
|
||||
gtk.ToolItem.__init__(self)
|
||||
|
@ -261,7 +261,7 @@ class XoColor:
|
||||
return '%s,%s' % (self.stroke, self.fill)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
@ -147,12 +147,12 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
"""
|
||||
path = self.translate_path(self.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
|
||||
|
||||
f = None
|
||||
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)
|
||||
if os.path.exists(index):
|
||||
path = index
|
||||
@ -166,12 +166,12 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
# transmitted *less* than the content-length!
|
||||
f = open(path, 'rb')
|
||||
except IOError:
|
||||
self.send_error(404, "File not found")
|
||||
self.send_error(404, 'File not found')
|
||||
return None
|
||||
self.send_response(200)
|
||||
self.send_header("Content-type", ctype)
|
||||
self.send_header("Content-Length", str(os.fstat(f.fileno())[6]))
|
||||
self.send_header("Content-Disposition", 'attachment; filename="%s"' %
|
||||
self.send_header('Content-type', ctype)
|
||||
self.send_header('Content-Length', str(os.fstat(f.fileno())[6]))
|
||||
self.send_header('Content-Disposition', 'attachment; filename="%s"' %
|
||||
os.path.basename(path))
|
||||
self.end_headers()
|
||||
return f
|
||||
@ -209,8 +209,8 @@ class GlibURLDownloader(gobject.GObject):
|
||||
self._outf = None
|
||||
self._fname = None
|
||||
if destfd and not destfile:
|
||||
raise ValueError("Must provide destination file too when" \
|
||||
"specifying file descriptor")
|
||||
raise ValueError('Must provide destination file too when'
|
||||
' specifying file descriptor')
|
||||
if destfile:
|
||||
self._suggested_fname = os.path.basename(destfile)
|
||||
self._fname = os.path.abspath(os.path.expanduser(destfile))
|
||||
@ -238,15 +238,15 @@ class GlibURLDownloader(gobject.GObject):
|
||||
|
||||
def cancel(self):
|
||||
if self._srcid == 0:
|
||||
raise RuntimeError("Download already canceled or stopped")
|
||||
raise RuntimeError('Download already canceled or stopped')
|
||||
self.cleanup(remove=True)
|
||||
|
||||
def _get_filename_from_headers(self, headers):
|
||||
if 'Content-Disposition' not in headers:
|
||||
return None
|
||||
|
||||
ftag = "filename="
|
||||
data = headers["Content-Disposition"]
|
||||
ftag = 'filename='
|
||||
data = headers['Content-Disposition']
|
||||
fidx = data.find(ftag)
|
||||
if fidx < 0:
|
||||
return None
|
||||
@ -260,7 +260,7 @@ class GlibURLDownloader(gobject.GObject):
|
||||
def _read_next_chunk(self, source, condition):
|
||||
if condition & gobject.IO_ERR:
|
||||
self.cleanup(remove=True)
|
||||
self.emit("error", "Error downloading file.")
|
||||
self.emit('error', 'Error downloading file.')
|
||||
return False
|
||||
elif not (condition & gobject.IO_IN):
|
||||
# shouldn't get here, but...
|
||||
@ -274,19 +274,19 @@ class GlibURLDownloader(gobject.GObject):
|
||||
# error writing data to file?
|
||||
if count < len(data):
|
||||
self.cleanup(remove=True)
|
||||
self.emit("error", "Error writing to download file.")
|
||||
self.emit('error', 'Error writing to download file.')
|
||||
return False
|
||||
|
||||
self.emit("progress", self._written)
|
||||
self.emit('progress', self._written)
|
||||
|
||||
# done?
|
||||
if len(data) < self.CHUNK_SIZE:
|
||||
self.cleanup()
|
||||
self.emit("finished", self._fname, self._suggested_fname)
|
||||
self.emit('finished', self._fname, self._suggested_fname)
|
||||
return False
|
||||
except Exception, err:
|
||||
self.cleanup(remove=True)
|
||||
self.emit("error", "Error downloading file: %s" % err)
|
||||
self.emit('error', 'Error downloading file: %r' % err)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -180,7 +180,7 @@ class Activity(gobject.GObject):
|
||||
def do_get_property(self, pspec):
|
||||
"""Retrieve a particular property from our property dictionary"""
|
||||
|
||||
if pspec.name == "joined":
|
||||
if pspec.name == 'joined':
|
||||
return self._joined
|
||||
|
||||
if self._get_properties_call is not None:
|
||||
@ -188,17 +188,17 @@ class Activity(gobject.GObject):
|
||||
'wants property %s', self, pspec.name)
|
||||
self._get_properties_call.block()
|
||||
|
||||
if pspec.name == "id":
|
||||
if pspec.name == 'id':
|
||||
return self._id
|
||||
elif pspec.name == "name":
|
||||
elif pspec.name == 'name':
|
||||
return self._name
|
||||
elif pspec.name == "color":
|
||||
elif pspec.name == 'color':
|
||||
return self._color
|
||||
elif pspec.name == "type":
|
||||
elif pspec.name == 'type':
|
||||
return self._type
|
||||
elif pspec.name == "tags":
|
||||
elif pspec.name == 'tags':
|
||||
return self._tags
|
||||
elif pspec.name == "private":
|
||||
elif pspec.name == 'private':
|
||||
return self._private
|
||||
|
||||
def do_set_property(self, pspec, val):
|
||||
@ -206,16 +206,16 @@ class Activity(gobject.GObject):
|
||||
# FIXME: need an asynchronous API to set these properties,
|
||||
# particularly 'private'
|
||||
|
||||
if pspec.name == "name":
|
||||
if pspec.name == 'name':
|
||||
self._name = val
|
||||
elif pspec.name == "color":
|
||||
elif pspec.name == 'color':
|
||||
self._color = val
|
||||
elif pspec.name == "tags":
|
||||
elif pspec.name == 'tags':
|
||||
self._tags = val
|
||||
elif pspec.name == "private":
|
||||
elif pspec.name == 'private':
|
||||
self._private = val
|
||||
else:
|
||||
raise ValueError('Unknown property "%s"', pspec.name)
|
||||
raise ValueError('Unknown property %r', pspec.name)
|
||||
|
||||
self._publish_properties()
|
||||
|
||||
@ -457,7 +457,7 @@ class Activity(gobject.GObject):
|
||||
# Leaving
|
||||
def __text_channel_closed_cb(self):
|
||||
self._joined = False
|
||||
self.emit("joined", False, "left activity")
|
||||
self.emit('joined', False, 'left activity')
|
||||
|
||||
def leave(self):
|
||||
"""Leave this shared activity"""
|
||||
|
@ -244,5 +244,5 @@ class Owner(BaseBuddy):
|
||||
BaseBuddy.__init__(self)
|
||||
|
||||
client = gconf.client_get_default()
|
||||
self.props.nick = client.get_string("/desktop/sugar/user/nick")
|
||||
self.props.color = client.get_string("/desktop/sugar/user/color")
|
||||
self.props.nick = client.get_string('/desktop/sugar/user/nick')
|
||||
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():
|
||||
if not connection.connected:
|
||||
continue
|
||||
logging.debug("Calling GetActivity on %s", account_path)
|
||||
logging.debug('Calling GetActivity on %s', account_path)
|
||||
try:
|
||||
room_handle = connection.connection.GetActivity(
|
||||
activity_id,
|
||||
@ -172,12 +172,12 @@ class PresenceService(gobject.GObject):
|
||||
def __share_activity_cb(self, 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):
|
||||
"""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):
|
||||
if properties is None:
|
||||
|
@ -69,8 +69,8 @@ class Profile(object):
|
||||
|
||||
def is_valid(self):
|
||||
client = gconf.client_get_default()
|
||||
nick = client.get_string("/desktop/sugar/user/nick")
|
||||
color = client.get_string("/desktop/sugar/user/color")
|
||||
nick = client.get_string('/desktop/sugar/user/nick')
|
||||
color = client.get_string('/desktop/sugar/user/color')
|
||||
|
||||
return nick is not '' and \
|
||||
color is not '' and \
|
||||
@ -84,21 +84,21 @@ class Profile(object):
|
||||
return None
|
||||
|
||||
try:
|
||||
f = open(key_path, "r")
|
||||
f = open(key_path, 'r')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
except IOError:
|
||||
logging.exception('Error reading public key')
|
||||
return None
|
||||
|
||||
magic = "ssh-dss "
|
||||
magic = 'ssh-dss '
|
||||
for l in lines:
|
||||
l = l.strip()
|
||||
if not l.startswith(magic):
|
||||
continue
|
||||
return l[len(magic):]
|
||||
else:
|
||||
logging.error("Error parsing public key.")
|
||||
logging.error('Error parsing public key.')
|
||||
return None
|
||||
|
||||
def _hash_private_key(self):
|
||||
@ -108,7 +108,7 @@ class Profile(object):
|
||||
return None
|
||||
|
||||
try:
|
||||
f = open(key_path, "r")
|
||||
f = open(key_path, 'r')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
except IOError:
|
||||
@ -120,15 +120,15 @@ class Profile(object):
|
||||
end_found = False
|
||||
for l in lines:
|
||||
l = l.strip()
|
||||
if l.startswith("-----BEGIN DSA PRIVATE KEY-----"):
|
||||
if l.startswith('-----BEGIN DSA PRIVATE KEY-----'):
|
||||
begin_found = True
|
||||
continue
|
||||
if l.startswith("-----END DSA PRIVATE KEY-----"):
|
||||
if l.startswith('-----END DSA PRIVATE KEY-----'):
|
||||
end_found = True
|
||||
continue
|
||||
key += l
|
||||
if not (len(key) and begin_found and end_found):
|
||||
logging.error("Error parsing public key.")
|
||||
logging.error('Error parsing public key.')
|
||||
return None
|
||||
|
||||
# hash it
|
||||
@ -145,41 +145,41 @@ class Profile(object):
|
||||
if cp.has_option('Buddy', 'NickName'):
|
||||
name = cp.get('Buddy', 'NickName')
|
||||
# decode nickname from ascii-safe chars to unicode
|
||||
nick = name.decode("utf-8")
|
||||
client.set_string("/desktop/sugar/user/nick", nick)
|
||||
nick = name.decode('utf-8')
|
||||
client.set_string('/desktop/sugar/user/nick', nick)
|
||||
if cp.has_option('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'):
|
||||
server = cp.get('Jabber', 'Server')
|
||||
client.set_string("/desktop/sugar/collaboration/jabber_server",
|
||||
client.set_string('/desktop/sugar/collaboration/jabber_server',
|
||||
server)
|
||||
if cp.has_option('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'):
|
||||
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'):
|
||||
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'):
|
||||
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'):
|
||||
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'):
|
||||
state = cp.get('Power', 'AutomaticPM')
|
||||
if state.lower() == "true":
|
||||
client.set_bool("/desktop/sugar/power/automatic", True)
|
||||
if state.lower() == 'true':
|
||||
client.set_bool('/desktop/sugar/power/automatic', True)
|
||||
if cp.has_option('Power', 'ExtremePM'):
|
||||
state = cp.get('Power', 'ExtremePM')
|
||||
if state.lower() == "true":
|
||||
client.set_bool("/desktop/sugar/power/extreme", True)
|
||||
if state.lower() == 'true':
|
||||
client.set_bool('/desktop/sugar/power/extreme', True)
|
||||
if cp.has_option('Shell', 'FavoritesLayout'):
|
||||
layout = cp.get('Shell', 'FavoritesLayout')
|
||||
client.set_string("/desktop/sugar/desktop/favorites_layout",
|
||||
client.set_string('/desktop/sugar/desktop/favorites_layout',
|
||||
layout)
|
||||
del cp
|
||||
try:
|
||||
@ -225,12 +225,12 @@ def get_profile():
|
||||
|
||||
def get_nick_name():
|
||||
client = gconf.client_get_default()
|
||||
return client.get_string("/desktop/sugar/user/nick")
|
||||
return client.get_string('/desktop/sugar/user/nick')
|
||||
|
||||
|
||||
def get_color():
|
||||
client = gconf.client_get_default()
|
||||
color = client.get_string("/desktop/sugar/user/color")
|
||||
color = client.get_string('/desktop/sugar/user/color')
|
||||
return XoColor(color)
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ def unique_id(data=''):
|
||||
to be unique-enough, no attempt is made to make
|
||||
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))
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ class TestPalette(Test):
|
||||
class TestRunner(object):
|
||||
def run(self, test):
|
||||
window = gtk.Window()
|
||||
window.connect("destroy", lambda w: gtk.main_quit())
|
||||
window.connect('destroy', lambda w: gtk.main_quit())
|
||||
window.add(test)
|
||||
test.show()
|
||||
|
||||
|
@ -47,5 +47,5 @@ gobject.idle_add(idle_cb)
|
||||
|
||||
test.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -59,12 +59,12 @@ for d in data:
|
||||
test.pack_start(icon)
|
||||
icon.show()
|
||||
|
||||
button = gtk.Button("mec mac")
|
||||
button = gtk.Button('mec mac')
|
||||
test.pack_start(button)
|
||||
button.connect('activate', _button_activated_cb)
|
||||
button.show()
|
||||
|
||||
test.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -83,5 +83,5 @@ test.show()
|
||||
#import gobject
|
||||
#gobject.idle_add(idle_cb)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -55,5 +55,5 @@ radio.show()
|
||||
palette.set_content(box)
|
||||
box.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -34,5 +34,5 @@ text_view.props.buffer.props.text = 'Blah blah blah, blah blah blah.'
|
||||
test.pack_start(text_view)
|
||||
text_view.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -44,5 +44,5 @@ toolbar.insert(button, -1)
|
||||
button.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -61,5 +61,5 @@ vbox.show()
|
||||
|
||||
test.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -78,5 +78,5 @@ vbox.show()
|
||||
|
||||
test.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
common.main(test)
|
||||
|
@ -80,5 +80,5 @@ class TestMime(unittest.TestCase):
|
||||
self.assertEqual(mime_type, 'text/plain')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user