Remove redundant str conversion in tree models
This commit is contained in:
parent
4c22713a1a
commit
8c66825e84
@ -109,13 +109,13 @@ class CitationBaseModel(object):
|
||||
return ''
|
||||
|
||||
def citation_id(self, data):
|
||||
return str(data[COLUMN_ID])
|
||||
return data[COLUMN_ID]
|
||||
|
||||
def citation_page(self, data):
|
||||
return str(data[COLUMN_PAGE])
|
||||
return data[COLUMN_PAGE]
|
||||
|
||||
def citation_confidence(self, data):
|
||||
return str(_(conf_strings[data[COLUMN_CONFIDENCE]]))
|
||||
return _(conf_strings[data[COLUMN_CONFIDENCE]])
|
||||
|
||||
def citation_private(self, data):
|
||||
if data[COLUMN_PRIV]:
|
||||
@ -164,7 +164,7 @@ class CitationBaseModel(object):
|
||||
if not cached:
|
||||
try:
|
||||
source = self.db.get_source_from_handle(source_handle)
|
||||
value = str(source.get_title())
|
||||
value = source.get_title()
|
||||
except:
|
||||
value = ''
|
||||
self.set_cached_value(source_handle, "SRC_TITLE", value)
|
||||
@ -176,7 +176,7 @@ class CitationBaseModel(object):
|
||||
if not cached:
|
||||
try:
|
||||
source = self.db.get_source_from_handle(source_handle)
|
||||
value = str(source.gramps_id)
|
||||
value = source.gramps_id
|
||||
except:
|
||||
value = ''
|
||||
self.set_cached_value(source_handle, "SRC_ID", value)
|
||||
@ -188,7 +188,7 @@ class CitationBaseModel(object):
|
||||
if not cached:
|
||||
try:
|
||||
source = self.db.get_source_from_handle(source_handle)
|
||||
value = str(source.get_author())
|
||||
value = source.get_author()
|
||||
except:
|
||||
value = ''
|
||||
self.set_cached_value(source_handle, "SRC_AUTH", value)
|
||||
@ -200,7 +200,7 @@ class CitationBaseModel(object):
|
||||
if not cached:
|
||||
try:
|
||||
source = self.db.get_source_from_handle(source_handle)
|
||||
value = str(source.get_abbreviation())
|
||||
value = source.get_abbreviation()
|
||||
except:
|
||||
value = ''
|
||||
self.set_cached_value(source_handle, "SRC_ABBR", value)
|
||||
@ -212,7 +212,7 @@ class CitationBaseModel(object):
|
||||
if not cached:
|
||||
try:
|
||||
source = self.db.get_source_from_handle(source_handle)
|
||||
value = str(source.get_publication_info())
|
||||
value = source.get_publication_info()
|
||||
except:
|
||||
value = ''
|
||||
self.set_cached_value(source_handle, "SRC_PINFO", value)
|
||||
@ -262,19 +262,19 @@ class CitationBaseModel(object):
|
||||
# Fields access when 'data' is a Source
|
||||
|
||||
def source_src_title(self, data):
|
||||
return str(data[COLUMN2_TITLE])
|
||||
return data[COLUMN2_TITLE]
|
||||
|
||||
def source_src_id(self, data):
|
||||
return str(data[COLUMN2_ID])
|
||||
return data[COLUMN2_ID]
|
||||
|
||||
def source_src_auth(self, data):
|
||||
return str(data[COLUMN2_AUTHOR])
|
||||
return data[COLUMN2_AUTHOR]
|
||||
|
||||
def source_src_abbr(self, data):
|
||||
return str(data[COLUMN2_ABBREV])
|
||||
return data[COLUMN2_ABBREV]
|
||||
|
||||
def source_src_pinfo(self, data):
|
||||
return str(data[COLUMN2_PUBINFO])
|
||||
return data[COLUMN2_PUBINFO]
|
||||
|
||||
def source_src_private(self, data):
|
||||
if data[COLUMN2_PRIV]:
|
||||
|
@ -150,7 +150,7 @@ class EventModel(FlatBaseModel):
|
||||
return str(EventType(data[COLUMN_TYPE]))
|
||||
|
||||
def column_id(self,data):
|
||||
return str(data[COLUMN_ID])
|
||||
return data[COLUMN_ID]
|
||||
|
||||
def column_date(self,data):
|
||||
if data[COLUMN_DATE]:
|
||||
|
@ -188,7 +188,7 @@ class FamilyModel(FlatBaseModel):
|
||||
return value
|
||||
|
||||
def column_id(self, data):
|
||||
return str(data[1])
|
||||
return data[1]
|
||||
|
||||
def column_private(self, data):
|
||||
if data[14]:
|
||||
|
@ -43,7 +43,6 @@ from gi.repository import Gtk
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.datehandler import displayer, format_time
|
||||
from gramps.gen.lib import Date, MediaObject
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from .flatbasemodel import FlatBaseModel
|
||||
|
||||
@ -106,40 +105,26 @@ class MediaModel(FlatBaseModel):
|
||||
return len(self.fmap)+1
|
||||
|
||||
def column_description(self, data):
|
||||
descr = data[4]
|
||||
if isinstance(descr, str):
|
||||
return descr
|
||||
try:
|
||||
return str(descr)
|
||||
except:
|
||||
return conv_to_unicode(descr, 'latin1')
|
||||
return data[4]
|
||||
|
||||
def column_path(self, data):
|
||||
path = data[2]
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
try:
|
||||
return str(path)
|
||||
except:
|
||||
return str(path.encode('iso-8859-1'))
|
||||
return data[2]
|
||||
|
||||
def column_mime(self, data):
|
||||
mime = data[3]
|
||||
if mime and isinstance(mime, str):
|
||||
return mime
|
||||
if mime:
|
||||
return str(mime)
|
||||
return mime
|
||||
else:
|
||||
return _('Note')
|
||||
|
||||
def column_id(self,data):
|
||||
return str(data[1])
|
||||
return data[1]
|
||||
|
||||
def column_date(self,data):
|
||||
if data[10]:
|
||||
date = Date()
|
||||
date.unserialize(data[10])
|
||||
return str(displayer.display(date))
|
||||
return displayer.display(date)
|
||||
return ''
|
||||
|
||||
def sort_date(self,data):
|
||||
|
@ -101,7 +101,7 @@ class NoteModel(FlatBaseModel):
|
||||
|
||||
def column_id(self, data):
|
||||
"""Return the id of the Note."""
|
||||
return str(data[Note.POS_ID])
|
||||
return data[Note.POS_ID]
|
||||
|
||||
def column_type(self, data):
|
||||
"""Return the type of the Note in readable format."""
|
||||
@ -111,9 +111,7 @@ class NoteModel(FlatBaseModel):
|
||||
|
||||
def column_preview(self, data):
|
||||
"""Return a shortend version of the Note's text."""
|
||||
#data is the encoding in the database, make it a unicode object
|
||||
#for universal work
|
||||
note = str(data[Note.POS_TEXT][StyledText.POS_TEXT])
|
||||
note = data[Note.POS_TEXT][StyledText.POS_TEXT]
|
||||
note = " ".join(note.split())
|
||||
if len(note) > 80:
|
||||
return note[:80] + "..."
|
||||
|
@ -126,7 +126,7 @@ class PlaceBaseModel(object):
|
||||
return value
|
||||
|
||||
def column_name(self, data):
|
||||
return str(data[6][0])
|
||||
return data[6][0]
|
||||
|
||||
def column_longitude(self, data):
|
||||
if not data[3]:
|
||||
@ -161,13 +161,13 @@ class PlaceBaseModel(object):
|
||||
return value
|
||||
|
||||
def column_id(self, data):
|
||||
return str(data[1])
|
||||
return data[1]
|
||||
|
||||
def column_type(self, data):
|
||||
return str(PlaceType(data[8]))
|
||||
|
||||
def column_code(self, data):
|
||||
return str(data[9])
|
||||
return data[9]
|
||||
|
||||
def column_private(self, data):
|
||||
if data[17]:
|
||||
|
@ -117,13 +117,13 @@ class RepositoryModel(FlatBaseModel):
|
||||
return len(self.fmap)+1
|
||||
|
||||
def column_id(self,data):
|
||||
return str(data[1])
|
||||
return data[1]
|
||||
|
||||
def column_type(self,data):
|
||||
return str(RepositoryType(data[2]))
|
||||
|
||||
def column_name(self,data):
|
||||
return str(data[3])
|
||||
return data[3]
|
||||
|
||||
def column_city(self,data):
|
||||
try:
|
||||
@ -201,7 +201,7 @@ class RepositoryModel(FlatBaseModel):
|
||||
url = Url()
|
||||
url.unserialize(i)
|
||||
if url.get_type() == UrlType.EMAIL:
|
||||
return str(url.path)
|
||||
return url.path
|
||||
return ''
|
||||
|
||||
def column_search_url(self,data):
|
||||
@ -210,7 +210,7 @@ class RepositoryModel(FlatBaseModel):
|
||||
url = Url()
|
||||
url.unserialize(i)
|
||||
if url.get_type() == UrlType.WEB_SEARCH:
|
||||
return str(url.path)
|
||||
return url.path
|
||||
return ''
|
||||
|
||||
def column_home_url(self,data):
|
||||
@ -219,7 +219,7 @@ class RepositoryModel(FlatBaseModel):
|
||||
url = Url()
|
||||
url.unserialize(i)
|
||||
if url.get_type() == UrlType.WEB_HOME:
|
||||
return str(url.path)
|
||||
return url.path
|
||||
return ""
|
||||
|
||||
def column_private(self, data):
|
||||
|
@ -99,19 +99,19 @@ class SourceModel(FlatBaseModel):
|
||||
return len(self.fmap)+1
|
||||
|
||||
def column_title(self,data):
|
||||
return str(data[2])
|
||||
return data[2]
|
||||
|
||||
def column_author(self,data):
|
||||
return str(data[3])
|
||||
return data[3]
|
||||
|
||||
def column_abbrev(self,data):
|
||||
return str(data[7])
|
||||
return data[7]
|
||||
|
||||
def column_id(self,data):
|
||||
return str(data[1])
|
||||
return data[1]
|
||||
|
||||
def column_pubinfo(self,data):
|
||||
return str(data[4])
|
||||
return data[4]
|
||||
|
||||
def column_private(self, data):
|
||||
if data[12]:
|
||||
|
Loading…
Reference in New Issue
Block a user