* src/Utils.py: handle missing/invalid encoding

* src/DisplayModels/_BaseModel.py: handle None vs. 0


svn: r7997
This commit is contained in:
Don Allingham 2007-01-27 23:08:08 +00:00
parent 89428da95e
commit b5aa6154b3
5 changed files with 20 additions and 9 deletions

View File

@ -1,4 +1,6 @@
2007-01-27 Don Allingham <don@gramps-project.org>
* src/Utils.py: handle missing/invalid encoding
* src/DisplayModels/_BaseModel.py: handle None vs. 0
* src/Editors/_EditPerson.py (EditPerson._image_button_press): check
for window already being open (#882)

View File

@ -12,7 +12,7 @@ AC_CONFIG_MACRO_DIR([m4])
GNOME_DOC_INIT
dnl RELEASE=0.SVN$(svnversion -n .)
RELEASE=0rc1
RELEASE=1
VERSIONSTRING=$VERSION
if test x"$RELEASE" != "x"

View File

@ -162,7 +162,7 @@ class BaseModel(gtk.GenericTreeModel):
i += 1
index = self.indexlist.get(handle)
if index:
if index != None:
node = self.get_iter(index)
self.row_inserted(index, node)

View File

@ -298,7 +298,8 @@ class PersonNavView(BookMarkView):
self.other_action = gtk.ActionGroup(self.title + '/PersonOther')
self.other_action.add_actions([
('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), None, None, self.set_default_person),
('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), None,
None, self.set_default_person),
])
self.add_action_group(self.back_action)

View File

@ -110,9 +110,10 @@ def fix_encoding(value):
try:
return unicode(value)
except:
codeset = locale.getpreferredencoding()
if codeset == 'UTF-8':
codeset = 'latin1'
try:
codeset = locale.getpreferredencoding()
except:
codeset = "UTF-8"
return unicode(value,codeset)
else:
return value
@ -291,9 +292,16 @@ def find_file( filename):
pass
# Build list of alternate encodings
encodings = [sys.getfilesystemencoding(), locale.getpreferredencoding(),
'UTF-8', 'ISO-8859-1']
encodings = list(set(encodings))
encodings = set()
for enc in [sys.getfilesystemencoding, locale.getpreferredencoding]:
try:
encodings.add(enc)
except:
pass
encodings.add('UTF-8')
encodings.add('ISO-8859-1')
for enc in encodings:
try:
fname = filename.encode(enc)