diff options
Diffstat (limited to 'src/jarabe/frame/clipboard.py')
-rw-r--r-- | src/jarabe/frame/clipboard.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py index 3b9f745..be2b902 100644 --- a/src/jarabe/frame/clipboard.py +++ b/src/jarabe/frame/clipboard.py @@ -26,6 +26,10 @@ from sugar import mime from jarabe.frame.clipboardobject import ClipboardObject, Format + +_instance = None + + class Clipboard(gobject.GObject): __gsignals__ = { @@ -34,7 +38,7 @@ class Clipboard(gobject.GObject): 'object-deleted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([int])), 'object-state-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([object])) + ([object])), } def __init__(self): @@ -69,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) @@ -82,9 +86,9 @@ class Clipboard(gobject.GObject): def set_object_percent(self, object_id, percent): cb_object = self._objects[object_id] if percent < 0 or percent > 100: - raise ValueError("invalid percentage") + raise ValueError('invalid percentage') if cb_object.get_percent() > percent: - raise ValueError("invalid percentage; less than current percent") + raise ValueError('invalid percentage; less than current percent') if cb_object.get_percent() == percent: # ignore setting same percentage return @@ -126,21 +130,21 @@ class Clipboard(gobject.GObject): def _copy_file(self, original_uri): uri = urlparse.urlparse(original_uri) - path_, file_name = os.path.split(uri.path) + path = uri.path # pylint: disable=E1101 + directory_, file_name = os.path.split(path) root, ext = os.path.splitext(file_name) if not ext or ext == '.': - mime_type = mime.get_for_file(uri.path) + mime_type = mime.get_for_file(path) ext = '.' + mime.get_primary_extension(mime_type) f_, new_file_path = tempfile.mkstemp(ext, root) del f_ - shutil.copyfile(uri.path, new_file_path) + shutil.copyfile(path, new_file_path) os.chmod(new_file_path, 0644) return 'file://' + new_file_path -_instance = None def get_instance(): global _instance |