diff --git a/gramps/gen/simple/_simpletable.py b/gramps/gen/simple/_simpletable.py
index 4ea730117..d22ad0289 100644
--- a/gramps/gen/simple/_simpletable.py
+++ b/gramps/gen/simple/_simpletable.py
@@ -165,7 +165,7 @@ class SimpleTable(object):
if (self._link_col == col or link is None):
link = ('Date', item)
elif isinstance(item, Span):
- text = str(item)
+ text = unicode(item)
retval.append(text)
self.row_sort_val(col, item)
elif isinstance(item, list): # [text, "PersonList", handle, ...]
@@ -238,7 +238,7 @@ class SimpleTable(object):
else:
doc.start_link("/%s/%s" %
(obj_type.lower(), handle))
- doc.write_text(str(col), 'Normal')
+ doc.write_text(unicode(col), 'Normal')
if obj_type and handle:
doc.stop_link()
doc.end_cell()
diff --git a/gramps/webapp/grampsdb/models.py b/gramps/webapp/grampsdb/models.py
index 73045e434..dec33bae5 100644
--- a/gramps/webapp/grampsdb/models.py
+++ b/gramps/webapp/grampsdb/models.py
@@ -106,7 +106,7 @@ class mGrampsType(models.Model):
name = models.CharField(max_length=40)
def __unicode__(self):
- return str(self.name)
+ return unicode(self.name)
def get_default_type(self):
""" return a tuple default (val,name) """
@@ -178,10 +178,10 @@ class EventType(mGrampsType):
val = models.IntegerField('event type', choices=_DATAMAP, blank=False)
def get_url(self):
- return "/event/?search=type%%3D%s" % self.name
+ return u"/event/?search=type%%3D%s" % self.name
def get_link(self):
- return "%s" % (self.get_url(), self.name)
+ return u"%s" % (self.get_url(), self.name)
class FamilyRelType(mGrampsType):
@@ -403,7 +403,7 @@ class Config(models.Model):
value = models.TextField('value')
def __unicode__(self):
- return str(self.setting)
+ return unicode(self.setting)
class Tag(models.Model):
handle = models.CharField(max_length=19, unique=True)
@@ -418,13 +418,13 @@ class Tag(models.Model):
priority = models.IntegerField('priority', blank=True, null=True)
def __unicode__(self):
- return str(self.name)
+ return unicode(self.name)
def get_url(self):
- return "/tag/%s" % self.handle
+ return u"/tag/%s" % self.handle
def get_link(self):
- return "%s" % (self.get_url(), self.name)
+ return u"%s" % (self.get_url(), self.name)
# Just the following have tag lists:
# ---------------------------------
@@ -454,11 +454,11 @@ class PrimaryObject(models.Model):
cache = models.TextField(blank=True, null=True)
def __unicode__(self):
- return "%s: %s" % (self.__class__.__name__,
+ return u"%s: %s" % (self.__class__.__name__,
self.gramps_id)
def get_url(self):
- return "/%s/%s" % (self.__class__.__name__.lower(),
+ return u"/%s/%s" % (self.__class__.__name__.lower(),
self.handle)
class MyFamilies(models.Model):
@@ -510,7 +510,7 @@ class Person(PrimaryObject):
return ""
def __unicode__(self):
- return "%s [%s]" % (self.get_primary_name(), self.gramps_id)
+ return u"%s [%s]" % (self.get_primary_name(), self.gramps_id)
def make_tag_list(self):
return tuple()
@@ -546,7 +546,7 @@ class Family(PrimaryObject):
def __unicode__(self):
father = self.father.get_primary_name() if self.father else "No father"
mother = self.mother.get_primary_name() if self.mother else "No mother"
- return str("%s and %s" % (father, mother))
+ return u"%s and %s" % (father, mother)
class Citation(DateObject, PrimaryObject):
confidence = models.IntegerField(blank=True, null=True)
@@ -557,7 +557,7 @@ class Citation(DateObject, PrimaryObject):
object_id_field="object_id")
def __unicode__(self):
- return "[%s] (%s, %s) to %s" % (self.gramps_id,
+ return u"[%s] (%s, %s) to %s" % (self.gramps_id,
self.confidence,
self.page,
self.source)
@@ -572,7 +572,7 @@ class Source(PrimaryObject):
abbrev = models.CharField("Abbreviation", max_length=50, blank=True, null=True)
def __unicode__(self):
- return "[%s] %s" % (self.gramps_id,
+ return u"[%s] %s" % (self.gramps_id,
self.title)
# Other keys here:
@@ -587,7 +587,7 @@ class Event(DateObject, PrimaryObject):
object_id_field="object_id")
def __unicode__(self):
- return "[%s] (%s) %s" % (self.gramps_id,
+ return u"[%s] (%s) %s" % (self.gramps_id,
self.event_type,
self.description)
@@ -601,7 +601,7 @@ class Repository(PrimaryObject):
#url_list = models.ManyToManyField('Url', null=True, blank=True)
def __unicode__(self):
- return "[%s] %s" % (self.gramps_id, self.name)
+ return u"[%s] %s" % (self.gramps_id, self.name)
# Others keys here:
# .address_set
@@ -615,10 +615,10 @@ class Place(PrimaryObject):
#url_list = models.ManyToManyField('Url', null=True, blank=True)
def get_selection_string(self):
- return "%s [%s]" % (self.title, self.gramps_id)
+ return u"%s [%s]" % (self.title, self.gramps_id)
def __unicode__(self):
- return str(self.title)
+ return unicode(self.title)
# Others keys here:
# .url_set
@@ -638,7 +638,7 @@ class Media(DateObject, PrimaryObject):
return tuple()
def __unicode__(self):
- return str(self.desc)
+ return unicode(self.desc)
class Note(PrimaryObject):
note_type = models.ForeignKey('NoteType', verbose_name="Type")
@@ -653,7 +653,7 @@ class Note(PrimaryObject):
return tuple()
def __unicode__(self):
- return str(self.gramps_id)
+ return unicode(self.gramps_id)
#---------------------------------------------------------------------------
#
@@ -691,11 +691,11 @@ class Surname(models.Model):
order = models.PositiveIntegerField()
def __unicode__(self):
- return "%s" % self.surname
+ return unicode(self.surname)
def get_url(self):
# /person/handle/name/1/surname/2
- return "/person/%s/name/%s/surname/%s" % (self.name.person.handle,
+ return u"/person/%s/name/%s/surname/%s" % (self.name.person.handle,
self.name.order,
self.order)
@@ -726,15 +726,14 @@ class Name(DateObject, SecondaryObject):
surname = self.surname_set.get(primary=True)
except:
surname = "[No primary surname]"
- return "%s, %s" % (surname,
- self.first_name)
+ return u"%s, %s" % (surname, self.first_name)
def get_selection_string(self):
try:
surname = self.surname_set.get(primary=True)
except:
surname = "[No primary surname]"
- return "%s, %s [%s]" % (surname, self.first_name, self.person.gramps_id)
+ return u"%s, %s [%s]" % (surname, self.first_name, self.person.gramps_id)
@staticmethod
def get_dummy():
@@ -758,7 +757,7 @@ class Name(DateObject, SecondaryObject):
def get_url(self):
# /person/handle/name/1
- return "/person/%s/name/%s" % (self.person.handle, self.order)
+ return u"/person/%s/name/%s" % (self.person.handle, self.order)
class Lds(DateObject, SecondaryObject):
"""
@@ -890,7 +889,7 @@ class BaseRef(models.Model):
# /person/3536453463/reference/event/2
ref_by = self.object_type.model_class().objects.get(id=self.object_id)
ref_to = self.get_reference_to()
- return "/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
+ return u"/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
ref_by.handle,
ref_to.__class__.__name__.lower(),
self.order)
@@ -900,7 +899,7 @@ class Log(BaseRef):
cache = models.TextField(blank=True, null=True)
def __unicode__(self):
- return "%s: %s on %s by %s" % (self.log_type,
+ return u"%s: %s on %s by %s" % (self.log_type,
self.referenced_by,
self.last_changed,
self.last_changed_by)
@@ -912,14 +911,14 @@ class NoteRef(BaseRef):
return self.ref_object
def __unicode__(self):
- return "NoteRef to " + str(self.ref_object)
+ return u"NoteRef to " + unicode(self.ref_object)
class EventRef(BaseRef):
ref_object = models.ForeignKey('Event')
role_type = models.ForeignKey('EventRoleType')
def __unicode__(self):
- return str(self.ref_object)
+ return unicode(self.ref_object)
def get_reference_to(self):
return self.ref_object
@@ -928,7 +927,7 @@ class EventRef(BaseRef):
# /person/3536453463/reference/event/2
ref_by = self.object_type.model_class().objects.get(id=self.object_id)
ref_to = self.ref_object
- return "/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
+ return u"/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
ref_by.handle,
ref_to.__class__.__name__.lower(),
self.order)
@@ -942,7 +941,7 @@ class RepositoryRef(BaseRef):
return self.ref_object
def __unicode__(self):
- return "RepositoryRef to " + str(self.ref_object)
+ return u"RepositoryRef to " + unicode(self.ref_object)
class PersonRef(BaseRef):
ref_object = models.ForeignKey('Person')
@@ -952,13 +951,13 @@ class PersonRef(BaseRef):
return self.ref_object
def __unicode__(self):
- return "PersonRef to " + str(self.ref_object)
+ return u"PersonRef to " + unicode(self.ref_object)
class CitationRef(BaseRef):
citation = models.ForeignKey('Citation')
def __unicode__(self):
- return "CitationRef to " + str(self.citation)
+ return u"CitationRef to " + unicode(self.citation)
def get_reference_to(self):
return self.citation
@@ -975,10 +974,10 @@ class ChildRef(BaseRef):
def get_url(self):
# FIXME: go to child reference
- return "/person/%s" % self.ref_object.handle
+ return u"/person/%s" % self.ref_object.handle
def __unicode__(self):
- return "ChildRef to " + str(self.ref_object)
+ return u"ChildRef to " + unicode(self.ref_object)
class MediaRef(BaseRef):
x1 = models.IntegerField()
@@ -991,7 +990,7 @@ class MediaRef(BaseRef):
return self.ref_object
def __unicode__(self):
- return "MediaRef to " + str(self.ref_object)
+ return u"MediaRef to " + unicode(self.ref_object)
class Report(models.Model):
gramps_id = models.TextField(blank=True, null=True)
@@ -1001,7 +1000,7 @@ class Report(models.Model):
options = models.TextField(blank=True, null=True)
def __unicode__(self):
- return str(self.name)
+ return unicode(self.name)
class Result(models.Model):
name = models.TextField(blank=True, null=True)
@@ -1011,7 +1010,7 @@ class Result(models.Model):
status = models.TextField(blank=True, null=True)
def __unicode__(self):
- return str(self.name)
+ return unicode(self.name)
TABLES = [
("abstract", mGrampsType),
diff --git a/gramps/webapp/utils.py b/gramps/webapp/utils.py
index d1f1e6462..c0fb87e77 100644
--- a/gramps/webapp/utils.py
+++ b/gramps/webapp/utils.py
@@ -145,7 +145,7 @@ def get_person_from_handle(db, handle):
print("error in get_person_from_handle:", file=sys.stderr)
import sys, traceback
cla, exc, trbk = sys.exc_info()
- print(_("Error") + (" : %s %s" %(cla, exc)), file=sys.stderr)
+ print(_("Error") + (u" : %s %s" %(cla, exc)), file=sys.stderr)
traceback.print_exc()
return None
@@ -250,18 +250,18 @@ class Table(object):
self.table.set_link_col(links)
def get_html(self):
- retval = ""
+ retval = u""
# The HTML writer escapes data:
self.table.write(self.doc, self.column_widths) # forces to htmllist
# FIXME: do once, or once per table?
self.doc.doc.build_style_declaration(self.id) # can pass id, for whole
# FIXME: don't want to repeat this, unless diff for each table:
- retval += "" % self.doc.doc.style_declaration
+ retval += u"" % self.doc.doc.style_declaration
# We have a couple of HTML bits that we want to unescape:
- return retval + str(self.doc.doc.htmllist[0]).replace(" ", " ")
+ return retval + unicode(self.doc.doc.htmllist[0]).replace(" ", " ")
def build_args(**kwargs):
- retval = ""
+ retval = u""
first = True
for key in kwargs:
if kwargs[key] is not "":
@@ -270,7 +270,7 @@ def build_args(**kwargs):
first = False
else:
retval += "&"
- retval += "%s=%s" % (key, kwargs[key])
+ retval += u"%s=%s" % (key, kwargs[key])
return retval
def build_search(request):
@@ -280,8 +280,8 @@ def build_search(request):
def make_button(text, url, *args):
newargs = []
- kwargs = ""
- last = ""
+ kwargs = u""
+ last = u""
for arg in args:
if isinstance(arg, STRTYPE) and arg.startswith("?"):
kwargs = arg
@@ -296,7 +296,7 @@ def make_button(text, url, *args):
if text[0] in "+$-?x" or text in ["x", "^", "v", "<", "<<", ">", ">>"]:
return mark_safe(make_image_button(text, url, kwargs, last))
else:
- return mark_safe("""""" %
+ return mark_safe(u"""""" %
(text, url, kwargs, last))
def make_image_button(text, url, kwargs, last):
@@ -369,10 +369,10 @@ def make_image_button2(button, text, url, kwargs="", last=""):
filename = "/images/scalable/add-parent-existing-family.svg"
elif button == "add spouse to new family":
filename = "/images/scalable/gramps-parents.svg"
- return """""" % (text, text, filename, url, kwargs, last)
+ return u"""
""" % (text, text, filename, url, kwargs, last)
def event_table(obj, user, act, url, args):
- retval = ""
+ retval = u""
has_data = False
cssid = "tab-events"
table = Table("event_table")
@@ -400,18 +400,18 @@ def event_table(obj, user, act, url, args):
djevent.gramps_id,
display_date(djevent),
get_title(djevent.place),
- str(event_ref.role_type))
+ unicode(event_ref.role_type))
links.append(('URL', event_ref.get_url()))
has_data = True
count += 1
table.links(links)
- retval += """
No such name order = %s
" % order + retval += u"No such name order = %s
" % order if has_data: - retval += """ \n""" % cssid + retval += u""" \n""" % cssid return retval def citation_table(obj, user, act, url=None, *args): # FIXME: how can citation_table and source_table both be on same # page? This causes problems with form names, tab names, etc. - retval = "" + retval = u"" has_data = False cssid = "tab-sources" table = Table("citation_table") @@ -556,8 +556,8 @@ def citation_table(obj, user, act, url=None, *args): citation_ref.citation.handle) table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "", citation.gramps_id, - str(citation.confidence), - str(citation.page), + unicode(citation.confidence), + unicode(citation.page), ) links.append(('URL', citation_ref.get_url())) has_data = True @@ -577,16 +577,16 @@ def citation_table(obj, user, act, url=None, *args): count = 1 for citation_ref in citation_refs: item = obj.__class__.__name__.lower() - retval = retval.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/citationref/%d" % (item, obj.handle, count))) - retval = retval.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/citationref/%d" % (item, obj.handle, count))) - retval = retval.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/citationref/%d" % (item, obj.handle, count))) + retval = retval.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/citationref/%d" % (item, obj.handle, count))) + retval = retval.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/citationref/%d" % (item, obj.handle, count))) + retval = retval.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/citationref/%d" % (item, obj.handle, count))) count += 1 if has_data: - retval += """ \n""" % cssid + retval += u""" \n""" % cssid return retval def repository_table(obj, user, act, url=None, *args): - retval = "" + retval = u"" has_data = False cssid = "tab-repositories" table = Table("repository_table") @@ -617,7 +617,7 @@ def repository_table(obj, user, act, url=None, *args): repository.gramps_id, repository.name, repo_ref.call_number, - str(repository.repository_type), + unicode(repository.repository_type), ) has_data = True count += 1 @@ -627,17 +627,17 @@ def repository_table(obj, user, act, url=None, *args): count = 1 for repo_ref in refs: item = obj.__class__.__name__.lower() - text = text.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/repositoryref/%d" % (item, obj.handle, count))) - text = text.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/repositoryref/%d" % (item, obj.handle, count))) - text = text.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/repositoryref/%d" % (item, obj.handle, count))) + text = text.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/repositoryref/%d" % (item, obj.handle, count))) + text = text.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/repositoryref/%d" % (item, obj.handle, count))) + text = text.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/repositoryref/%d" % (item, obj.handle, count))) count += 1 retval += text if has_data: - retval += """ \n""" % cssid + retval += u""" \n""" % cssid return retval def note_table(obj, user, act, url=None, *args): - retval = "" + retval = u"" has_data = False cssid = "tab-notes" table = Table("note_table") @@ -657,7 +657,7 @@ def note_table(obj, user, act, url=None, *args): note = note_ref.ref_object table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "", note.gramps_id, - str(note.note_type), + unicode(note.note_type), note.text[:50] ) links.append(('URL', note_ref.get_url())) @@ -678,17 +678,17 @@ def note_table(obj, user, act, url=None, *args): count = 1 for note_ref in note_refs: item = obj.__class__.__name__.lower() - text = text.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/noteref/%d" % (item, obj.handle, count))) - text = text.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/noteref/%d" % (item, obj.handle, count))) - text = text.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/noteref/%d" % (item, obj.handle, count))) + text = text.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/noteref/%d" % (item, obj.handle, count))) + text = text.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/noteref/%d" % (item, obj.handle, count))) + text = text.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/noteref/%d" % (item, obj.handle, count))) count += 1 retval += text if has_data: - retval += """ \n""" % cssid + retval += u""" \n""" % cssid return retval def data_table(obj, user, act, url=None, *args): - retval = "" + retval = u"" has_data = False cssid = "tab-data" table = Table("data_table") @@ -729,9 +729,9 @@ def data_table(obj, user, act, url=None, *args): text = text.replace("}}", """""") count = 1 for repo_ref in refs: - text = text.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/attribute/%d" % (item_class, obj.handle, count))) - text = text.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/attribute/%d" % (item_class, obj.handle, count))) - text = text.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/attribute/%d" % (item_class, obj.handle, count))) + text = text.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/attribute/%d" % (item_class, obj.handle, count))) + text = text.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/attribute/%d" % (item_class, obj.handle, count))) + text = text.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/attribute/%d" % (item_class, obj.handle, count))) count += 1 retval += text if has_data: @@ -739,7 +739,7 @@ def data_table(obj, user, act, url=None, *args): return retval def attribute_table(obj, user, act, url=None, *args): - retval = "" + retval = u"" has_data = False cssid = "tab-attributes" table = Table("attribute_table") @@ -766,7 +766,7 @@ def attribute_table(obj, user, act, url=None, *args): return retval def address_table(obj, user, act, url=None, *args): - retval = "" + retval = u"" has_data = False cssid = "tab-addresses" table = Table("address_table") @@ -797,7 +797,7 @@ def address_table(obj, user, act, url=None, *args): return retval def media_table(obj, user, act, url=None, *args): - retval = "" + retval = u"" has_data = False cssid = "tab-media" table = Table("media_table") @@ -813,7 +813,7 @@ def media_table(obj, user, act, url=None, *args): media = table.db.get_object_from_handle( media_ref.ref_object.handle) table.row(table.db.get_object_from_handle(media.handle), - str(media_ref.ref_object.desc), + unicode(media_ref.ref_object.desc), media_ref.ref_object.path) has_data = True retval += """