Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-08-19 08:06:31 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-08-19 08:06:31 (GMT)
commitd57bb1b20aa123821d1008432620fb316645e34b (patch)
treea1a93f991bbd3ca84be89006b9a427768574d7bf /src
parent48fce2af17dedbb28213a1e3f935615b1d67d500 (diff)
Bunch of pylint fixes
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/frame/clipboard.py18
-rw-r--r--src/jarabe/frame/clipboardmenu.py12
-rw-r--r--src/jarabe/frame/clipboardobject.py20
-rw-r--r--src/jarabe/frame/clipboardtray.py4
-rw-r--r--src/jarabe/journal/listview.py26
-rw-r--r--src/jarabe/journal/misc.py3
-rw-r--r--src/jarabe/journal/model.py8
-rw-r--r--src/jarabe/journal/objectchooser.py6
-rw-r--r--src/jarabe/model/bundleregistry.py4
9 files changed, 47 insertions, 54 deletions
diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
index 0e3e125..d18dd44 100644
--- a/src/jarabe/frame/clipboard.py
+++ b/src/jarabe/frame/clipboard.py
@@ -59,9 +59,9 @@ class Clipboard(gobject.GObject):
cb_object = self._objects[object_id]
if format_type == 'XdndDirectSave0':
- format = Format('text/uri-list', data + '\r\n', on_disk)
- format.owns_disk_data = True
- cb_object.add_format(format)
+ format_ = Format('text/uri-list', data + '\r\n', on_disk)
+ format_.owns_disk_data = True
+ cb_object.add_format(format_)
elif on_disk and cb_object.get_percent() == 100:
new_uri = self._copy_file(data)
cb_object.add_format(Format(format_type, new_uri, on_disk))
@@ -98,10 +98,10 @@ class Clipboard(gobject.GObject):
def _process_object(self, cb_object):
formats = cb_object.get_formats()
- for format_name, format in formats.iteritems():
- if format.is_on_disk() and not format.owns_disk_data:
- new_uri = self._copy_file(format.get_data())
- format.set_data(new_uri)
+ for format_name, format_ in formats.iteritems():
+ if format_.is_on_disk() and not format_.owns_disk_data:
+ new_uri = self._copy_file(format_.get_data())
+ format_.set_data(new_uri)
# Add a text/plain format to objects that are text but lack it
if 'text/plain' not in formats.keys():
@@ -121,8 +121,8 @@ class Clipboard(gobject.GObject):
def get_object_data(self, object_id, format_type):
logging.debug('Clipboard.get_object_data')
cb_object = self._objects[object_id]
- format = cb_object.get_formats()[format_type]
- return format
+ format_ = cb_object.get_formats()[format_type]
+ return format_
def _copy_file(self, original_uri):
uri = urlparse.urlparse(original_uri)
diff --git a/src/jarabe/frame/clipboardmenu.py b/src/jarabe/frame/clipboardmenu.py
index d1d4105..8a8ba11 100644
--- a/src/jarabe/frame/clipboardmenu.py
+++ b/src/jarabe/frame/clipboardmenu.py
@@ -204,26 +204,26 @@ class ClipboardMenu(Palette):
def _copy_to_journal(self):
formats = self._cb_object.get_formats().keys()
most_significant_mime_type = mime.choose_most_significant(formats)
- format = self._cb_object.get_formats()[most_significant_mime_type]
+ format_ = self._cb_object.get_formats()[most_significant_mime_type]
transfer_ownership = False
if most_significant_mime_type == 'text/uri-list':
- uris = mime.split_uri_list(format.get_data())
+ uris = mime.split_uri_list(format_.get_data())
if len(uris) == 1 and uris[0].startswith('file://'):
file_path = urlparse.urlparse(uris[0]).path
transfer_ownership = False
mime_type = mime.get_for_file(file_path)
else:
- file_path = self._write_to_temp_file(format.get_data())
+ file_path = self._write_to_temp_file(format_.get_data())
transfer_ownership = True
mime_type = 'text/uri-list'
else:
- if format.is_on_disk():
- file_path = urlparse.urlparse(format.get_data()).path
+ if format_.is_on_disk():
+ file_path = urlparse.urlparse(format_.get_data()).path
transfer_ownership = False
mime_type = mime.get_for_file(file_path)
else:
- file_path = self._write_to_temp_file(format.get_data())
+ file_path = self._write_to_temp_file(format_.get_data())
transfer_ownership = True
sniffed_mime_type = mime.get_for_file(file_path)
if sniffed_mime_type == 'application/octet-stream':
diff --git a/src/jarabe/frame/clipboardobject.py b/src/jarabe/frame/clipboardobject.py
index 38da151..91fa1e6 100644
--- a/src/jarabe/frame/clipboardobject.py
+++ b/src/jarabe/frame/clipboardobject.py
@@ -33,8 +33,8 @@ class ClipboardObject(object):
self._formats = {}
def destroy(self):
- for format in self._formats.itervalues():
- format.destroy()
+ for format_ in self._formats.itervalues():
+ format_.destroy()
def get_id(self):
return self._id
@@ -91,8 +91,8 @@ class ClipboardObject(object):
def set_percent(self, percent):
self._percent = percent
- def add_format(self, format):
- self._formats[format.get_type()] = format
+ def add_format(self, format_):
+ self._formats[format_.get_type()] = format_
def get_formats(self):
return self._formats
@@ -101,18 +101,18 @@ class ClipboardObject(object):
if not self._formats:
return ''
- format = mime.choose_most_significant(self._formats.keys())
- if format == 'text/uri-list':
+ format_ = mime.choose_most_significant(self._formats.keys())
+ if format_ == 'text/uri-list':
data = self._formats['text/uri-list'].get_data()
uri = urlparse.urlparse(mime.split_uri_list(data)[0], 'file')
if uri.scheme == 'file':
if os.path.exists(uri.path):
- format = mime.get_for_file(uri.path)
+ format_ = mime.get_for_file(uri.path)
else:
- format = mime.get_from_file_name(uri.path)
- logging.debug('Choosed %r!' % format)
+ format_ = mime.get_from_file_name(uri.path)
+ logging.debug('Choosed %r!' % format_)
- return format
+ return format_
class Format(object):
diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py
index 40f0a32..a387328 100644
--- a/src/jarabe/frame/clipboardtray.py
+++ b/src/jarabe/frame/clipboardtray.py
@@ -153,7 +153,7 @@ class ClipboardTray(tray.VTray):
if 'XdndDirectSave0' in context.targets:
window = context.source_window
- prop_type, format, filename = \
+ prop_type, format_, filename = \
window.property_get('XdndDirectSave0','text/plain')
# FIXME query the clipboard service for a filename?
@@ -165,7 +165,7 @@ class ClipboardTray(tray.VTray):
dest_uri = 'file://' + os.path.join(base_dir, dest_filename)
- window.property_change('XdndDirectSave0', prop_type, format,
+ window.property_change('XdndDirectSave0', prop_type, format_,
gtk.gdk.PROP_MODE_REPLACE, dest_uri)
widget.drag_get_data(context, 'XdndDirectSave0', time)
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 5e20577..332edc9 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -15,8 +15,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import logging
-import traceback
-import sys
from gettext import gettext as _
import time
@@ -50,14 +48,14 @@ class TreeView(gtk.TreeView):
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.
- model = self.get_model()
- if model is not None:
- model.view_is_resizing = True
+ tree_model = self.get_model()
+ if tree_model is not None:
+ tree_model.view_is_resizing = True
try:
gtk.TreeView.do_size_request(self, requisition)
finally:
- if model is not None:
- model.view_is_resizing = False
+ if tree_model is not None:
+ tree_model.view_is_resizing = False
class BaseListView(gtk.Bin):
__gtype_name__ = 'JournalBaseListView'
@@ -93,6 +91,7 @@ class BaseListView(gtk.Bin):
self.cell_title = None
self.cell_icon = None
self._title_column = None
+ self.date_column = None
self._add_columns()
self.tree_view.enable_model_drag_source(gtk.gdk.BUTTON1_MASK,
@@ -137,7 +136,8 @@ class BaseListView(gtk.Bin):
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, 'xo-color', ListModel.COLUMN_ICON_COLOR)
+ column.add_attribute(self.cell_icon, 'xo-color',
+ ListModel.COLUMN_ICON_COLOR)
self.tree_view.append_column(column)
self.cell_title = gtk.CellRendererText()
@@ -234,7 +234,7 @@ class BaseListView(gtk.Bin):
context = widget.get_pango_context()
layout = pango.Layout(context)
layout.set_text(text)
- width, height = layout.get_size()
+ width, height_ = layout.get_size()
return pango.PIXELS(width)
def do_size_allocate(self, allocation):
@@ -289,14 +289,14 @@ class BaseListView(gtk.Bin):
self._model.connect('progress', self.__model_progress_cb)
self._model.setup()
- def __model_ready_cb(self, model):
+ def __model_ready_cb(self, tree_model):
self._stop_progress_bar()
# Cannot set it up earlier because will try to access the model and it
# needs to be ready.
self.tree_view.set_model(self._model)
- if len(model) == 0:
+ if len(tree_model) == 0:
if self._is_query_empty():
self._show_message(MESSAGE_EMPTY_JOURNAL)
else:
@@ -564,8 +564,8 @@ class CellRendererBuddy(CellRendererIcon):
self._model_column_index = column_index
def create_palette(self):
- model = self.tree_view.get_model()
- row = model[self.props.palette_invoker.path]
+ tree_model = self.tree_view.get_model()
+ row = tree_model[self.props.palette_invoker.path]
if row[self._model_column_index] is not None:
nick, xo_color = row[self._model_column_index]
diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
index b29b744..5a9feb0 100644
--- a/src/jarabe/journal/misc.py
+++ b/src/jarabe/journal/misc.py
@@ -17,7 +17,6 @@
import logging
import time
import traceback
-import sys
import os
from gettext import gettext as _
@@ -69,7 +68,7 @@ def get_icon_name(metadata):
try:
bundle = ActivityBundle(file_path)
file_name = bundle.get_icon()
- except:
+ except Exception:
logging.warning('Could not read bundle:\n' + \
traceback.format_exc())
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 7517d78..e710464 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -119,7 +119,7 @@ class BaseResultSet(object):
self._position = position
def read(self):
- #logging.debug('ResultSet.read position: %r' % self._position)
+ logging.debug('ResultSet.read position: %r' % self._position)
if self._position == -1:
self.seek(0)
@@ -149,7 +149,7 @@ class BaseResultSet(object):
query['offset'] = offset
entries, self._total_count = self.find(query)
- self._cache.remove_all(self._cache._array)
+ self._cache.remove_all(self._cache)
self._cache.append_all(entries)
self._offset = offset
@@ -195,8 +195,8 @@ class BaseResultSet(object):
objects_excess = len(self._cache) - cache_limit
if objects_excess > 0:
self._cache.remove_all(self._cache[-objects_excess:])
- #else:
- # logging.debug('cache hit and no need to grow the cache')
+ else:
+ logging.debug('cache hit and no need to grow the cache')
return self._cache[self._position - self._offset]
diff --git a/src/jarabe/journal/objectchooser.py b/src/jarabe/journal/objectchooser.py
index 827f228..32bfbb3 100644
--- a/src/jarabe/journal/objectchooser.py
+++ b/src/jarabe/journal/objectchooser.py
@@ -19,7 +19,6 @@ import logging
import gobject
import gtk
-import hippo
import wnck
from sugar.graphics import style
@@ -181,11 +180,6 @@ class ChooserListView(BaseListView):
self.tree_view.connect('button-release-event',
self.__button_release_event_cb)
- def create_entry(self):
- entry = ChooserCollapsedEntry()
- entry.connect('entry-activated', self.__entry_activated_cb)
- return entry
-
def __entry_activated_cb(self, entry):
self.emit('entry-activated', entry)
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index 4e5b2f0..3e5e586 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -184,10 +184,10 @@ class BundleRegistry(gobject.GObject):
bundle_dir = os.path.join(path, f)
if os.path.isdir(bundle_dir):
bundles[bundle_dir] = os.stat(bundle_dir).st_mtime
- except Exception, e:
+ except Exception:
logging.error('Error while processing installed activity ' \
'bundle %s:\n%s' % \
- (folder, traceback.format_exc()))
+ (bundle_dir, traceback.format_exc()))
bundle_dirs = bundles.keys()
bundle_dirs.sort(lambda d1, d2: cmp(bundles[d1], bundles[d2]))