conduit r1412 - in trunk: . conduit/modules/iPodModule
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1412 - in trunk: . conduit/modules/iPodModule
- Date: Fri, 4 Apr 2008 22:54:51 +0100 (BST)
Author: jstowers
Date: Fri Apr 4 22:54:51 2008
New Revision: 1412
URL: http://svn.gnome.org/viewvc/conduit?rev=1412&view=rev
Log:
2008-04-05 John Stowers <john stowers gmail com>
* conduit/modules/iPodModule/iPodModule.py: Add an encoding
declaration to the note. Fixes #510101 (tumi st gmail com)
Modified:
trunk/ChangeLog
trunk/conduit/modules/iPodModule/iPodModule.py
Modified: trunk/conduit/modules/iPodModule/iPodModule.py
==============================================================================
--- trunk/conduit/modules/iPodModule/iPodModule.py (original)
+++ trunk/conduit/modules/iPodModule/iPodModule.py Fri Apr 4 22:54:51 2008
@@ -150,6 +150,10 @@
_in_type_ = "note"
_out_type_ = "note"
_icon_ = "tomboy"
+
+ # datatypes.Note doesn't care about encoding,
+ # lets be naive and assume that all notes are utf-8
+ ENCODING_DECLARATION = '<?xml encoding="utf-8"?>'
def __init__(self, *args):
IPodBase.__init__(self, *args)
@@ -184,7 +188,8 @@
#the UID for notes from the ipod is the filename
n = Note.Note(
title=uid,
- contents=noteFile.get_contents_as_text(),
+ contents=noteFile.get_contents_as_text().replace(
+ self.ENCODING_DECLARATION, '', 1),
)
n.set_UID(uid)
n.set_mtime(noteFile.get_mtime())
@@ -195,10 +200,15 @@
"""
Save a simple iPod note in /Notes
If the note has raw then also save that in shadowdir
- uid is the note title
+ uid is the note title.
"""
- #the normal note viewed by the ipod
- ipodnote = Utils.new_tempfile(note.get_contents())
+ # the normal note viewed by the iPod
+ # inject an encoding declaration if it is missing.
+ contents = note.get_contents()
+ if not self.ENCODING_DECLARATION in contents:
+ contents = ''.join([self.ENCODING_DECLARATION, contents])
+ ipodnote = Utils.new_tempfile(contents)
+
ipodnote.transfer(os.path.join(self.dataDir,uid), overwrite=True)
ipodnote.set_mtime(note.get_mtime())
ipodnote.set_UID(uid)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]