Remove remaining conv_to_unicode calls
This commit is contained in:
parent
7f3cdb6d71
commit
8dffe6639b
@ -68,7 +68,6 @@ LOG = logging.getLogger(".gramps.gen")
|
||||
#-------------------------------------------------------------------------
|
||||
from ..const import ARABIC_COMMA, ARABIC_SEMICOLON, GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from ..constfunc import conv_to_unicode
|
||||
from ..lib.name import Name
|
||||
from ..lib.nameorigintype import NameOriginType
|
||||
|
||||
@ -1005,7 +1004,6 @@ class NameDisplay(object):
|
||||
d_keys.sort(key=_make_cmp_key, reverse=True) # reverse on length and by ikeyword
|
||||
for (code, ikeyword) in d_keys:
|
||||
exp, keyword, ikeyword = d[code]
|
||||
#ikeyword = unicode(ikeyword, "utf8")
|
||||
format_str = format_str.replace(ikeyword, "%"+ code)
|
||||
format_str = format_str.replace(ikeyword.title(), "%"+ code)
|
||||
format_str = format_str.replace(ikeyword.upper(), "%"+ code.upper())
|
||||
@ -1022,8 +1020,6 @@ class NameDisplay(object):
|
||||
# if in double quotes, just use % codes
|
||||
for (code, keyword) in d_keys:
|
||||
exp, keyword, ikeyword = d[code]
|
||||
if not isinstance(keyword, str):
|
||||
keyword = conv_to_unicode(keyword, "utf-8")
|
||||
format_str = format_str.replace(keyword, "%"+ code)
|
||||
format_str = format_str.replace(keyword.title(), "%"+ code)
|
||||
format_str = format_str.replace(keyword.upper(), "%"+ code.upper())
|
||||
|
@ -53,7 +53,7 @@ from ..utils.configmanager import safe_eval
|
||||
from ..config import config
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from ..constfunc import conv_to_unicode, mac
|
||||
from ..constfunc import mac
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -382,9 +382,8 @@ def load_addon_file(path, callback=None):
|
||||
gpr_files = set([os.path.split(os.path.join(USER_PLUGINS, name))[0]
|
||||
for name in good_gpr])
|
||||
for gpr_file in gpr_files:
|
||||
u_gpr_file = conv_to_unicode(gpr_file)
|
||||
if callback:
|
||||
callback(" " + (_("Registered '%s'") % u_gpr_file) + "\n")
|
||||
callback(" " + (_("Registered '%s'") % gpr_file) + "\n")
|
||||
registered_count += 1
|
||||
file_obj.close()
|
||||
if registered_count:
|
||||
|
@ -43,7 +43,6 @@ import tempfile
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..constfunc import conv_to_unicode
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -274,7 +273,6 @@ def resize_to_jpeg_buffer(source, size, crop=None):
|
||||
|
||||
scaled = img.scale_simple(int(size[0]), int(size[1]), GdkPixbuf.InterpType.BILINEAR)
|
||||
os.close(filed)
|
||||
dest = conv_to_unicode(dest, None)
|
||||
scaled.savev(dest, "jpeg", "", "")
|
||||
ofile = open(dest, mode='rb')
|
||||
data = ofile.read()
|
||||
|
@ -76,8 +76,7 @@ from gramps.gen.utils.cast import conv_dbstr_to_unicode
|
||||
from gramps.gen.utils.id import create_id
|
||||
from gramps.gen.updatecallback import UpdateCallback
|
||||
from gramps.gen.errors import DbError
|
||||
from gramps.gen.constfunc import (win, conv_to_unicode, handle2internal,
|
||||
get_env_var)
|
||||
from gramps.gen.constfunc import win, handle2internal, get_env_var
|
||||
from gramps.gen.const import HOME_DIR, GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -1809,8 +1808,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
"""
|
||||
if batch_transaction:
|
||||
return
|
||||
name = conv_to_unicode(find_surname_name(person.handle,
|
||||
person.get_primary_name().serialize()), 'utf-8')
|
||||
name = find_surname_name(person.handle,
|
||||
person.get_primary_name().serialize())
|
||||
i = bisect.bisect(self.surname_list, name)
|
||||
if 0 < i <= len(self.surname_list):
|
||||
if self.surname_list[i-1] != name:
|
||||
|
@ -61,7 +61,7 @@ from gramps.gen.lib import Date, Person
|
||||
from gramps.gen.updatecallback import UpdateCallback
|
||||
from gramps.gen.db.exceptions import DbWriteFailure
|
||||
from gramps.version import VERSION
|
||||
from gramps.gen.constfunc import win, conv_to_unicode
|
||||
from gramps.gen.constfunc import win
|
||||
from gramps.gui.plug.export import WriterOptionBox
|
||||
import gramps.plugins.lib.libgrampsxml as libgrampsxml
|
||||
|
||||
@ -438,11 +438,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.g.write(' priority="%d"' % tag.get_priority())
|
||||
self.g.write('/>\n')
|
||||
|
||||
def fix(self,line):
|
||||
try:
|
||||
l = str(line)
|
||||
except:
|
||||
l = conv_to_unicode(str(line), errors='replace')
|
||||
def fix(self, line):
|
||||
l = l.strip().translate(strip_dict)
|
||||
return escxml(l)
|
||||
|
||||
|
@ -48,7 +48,6 @@ from functools import partial
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from gramps.gen.plug.menu import (BooleanOption, EnumeratedListOption,
|
||||
FilterOption, PersonOption, ColorOption)
|
||||
from gramps.gen.plug.report import Report
|
||||
@ -193,8 +192,7 @@ class RelGraphReport(Report):
|
||||
children
|
||||
"""
|
||||
# Hash people in a dictionary for faster inclusion checking
|
||||
person_dict = dict([conv_to_unicode(handle, 'utf-8'), 1]
|
||||
for handle in self.person_handles)
|
||||
person_dict = dict([handle, 1] for handle in self.person_handles)
|
||||
|
||||
for person_handle in self.person_handles:
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
@ -204,7 +202,7 @@ class RelGraphReport(Report):
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
for child_ref in family.get_child_ref_list():
|
||||
if child_ref.ref == conv_to_unicode(person_handle, 'utf-8'):
|
||||
if child_ref.ref == person_handle:
|
||||
frel = child_ref.frel
|
||||
mrel = child_ref.mrel
|
||||
break
|
||||
@ -265,7 +263,7 @@ class RelGraphReport(Report):
|
||||
(shape, style, color, fill) = self.get_gender_style(person)
|
||||
url = ""
|
||||
if self.includeurl:
|
||||
h = conv_to_unicode(person_handle, 'utf-8')
|
||||
h = person_handle
|
||||
dirpath = "ppl/%s/%s" % (h[-1], h[-2])
|
||||
dirpath = dirpath.lower()
|
||||
url = "%s/%s.html" % (dirpath, h)
|
||||
|
@ -53,7 +53,6 @@ from gramps.gen.lib import (Attribute, AttributeType, ChildRef, Citation,
|
||||
Family, FamilyRelType, Name, NameType, Note, Person, PersonRef,
|
||||
Place, Source, LdsOrd)
|
||||
from gramps.gen.db import DbTxn
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from html.entities import name2codepoint
|
||||
|
||||
_date_parse = re.compile('([kmes~?<>]+)?([0-9/]+)([J|H|F])?(\.\.)?([0-9/]+)?([J|H|F])?')
|
||||
@ -180,7 +179,7 @@ class GeneWebParser(object):
|
||||
line = self.f.readline()
|
||||
|
||||
try:
|
||||
line = conv_to_unicode(line)
|
||||
line = line.decode('utf-8')
|
||||
except GrampsImportError as err:
|
||||
self.errmsg(str(err))
|
||||
|
||||
@ -188,7 +187,7 @@ class GeneWebParser(object):
|
||||
try:
|
||||
line = str(line.strip())
|
||||
except UnicodeDecodeError:
|
||||
line = conv_to_unicode(line.strip(), self.encoding)
|
||||
line = line.decode(self.encoding).strip()
|
||||
else:
|
||||
line = None
|
||||
return line
|
||||
|
@ -44,7 +44,6 @@ import re
|
||||
# Gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from gramps.gen.plug.docgen import (BaseDoc, TextDoc, DrawDoc, ParagraphStyle,
|
||||
TableCellStyle, SOLID, FONT_SANS_SERIF, FONT_SERIF,
|
||||
FONT_MONOSPACE, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT)
|
||||
@ -501,7 +500,7 @@ class GtkDocParagraph(GtkDocBaseElement):
|
||||
Internal method to allow for splitting of paragraphs
|
||||
"""
|
||||
if not isinstance(plaintext, str):
|
||||
self._plaintext = conv_to_unicode(plaintext, 'utf-8')
|
||||
self._plaintext = plaintext.decode('utf-8')
|
||||
else:
|
||||
self._plaintext = plaintext
|
||||
|
||||
|
@ -71,7 +71,7 @@ from gramps.gui.plug import tool
|
||||
from gramps.gui.dialog import OkDialog, MissingMediaDialog
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gui.glade import Glade
|
||||
from gramps.gen.constfunc import handle2internal, conv_to_unicode
|
||||
from gramps.gen.constfunc import handle2internal
|
||||
|
||||
# table for handling control chars in notes.
|
||||
# All except 09, 0A, 0D are replaced with space.
|
||||
@ -356,17 +356,17 @@ class CheckIntegrity(object):
|
||||
data = self.db.media_map[bhandle]
|
||||
if not isinstance(data[2], str) or not isinstance(data[4], str):
|
||||
obj = self.db.get_object_from_handle(handle)
|
||||
obj.path = conv_to_unicode(obj.path, None)
|
||||
obj.desc = conv_to_unicode(obj.desc, None)
|
||||
self.db.commit_media_object(obj, self.trans)
|
||||
if not isinstance(data[2], str):
|
||||
obj.path = obj.path.decode('utf-8')
|
||||
logging.warning(' FAIL: encoding error on media object '
|
||||
'"%(gid)s" path "%(path)s"' %
|
||||
{'gid' : obj.gramps_id, 'path' : obj.path})
|
||||
if not isinstance(data[4], str):
|
||||
obj.desc = obj.desc.decode('utf-8')
|
||||
logging.warning(' FAIL: encoding error on media object '
|
||||
'"%(gid)s" description "%(desc)s"' %
|
||||
{'gid' : obj.gramps_id, 'desc' : obj.desc})
|
||||
self.db.commit_media_object(obj, self.trans)
|
||||
error_count += 1
|
||||
# Once we are here, fix the mime string if not str
|
||||
if not isinstance(data[3], str):
|
||||
|
@ -46,7 +46,6 @@ from django.db import transaction
|
||||
import gramps.webapp.grampsdb.models as models
|
||||
from gramps.gen.lib import Name
|
||||
from gramps.gen.utils.id import create_id
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
|
||||
# To get a django person from a django database:
|
||||
# djperson = dji.Person.get(handle='djhgsdh324hjg234hj24')
|
||||
@ -454,7 +453,7 @@ class DjangoInterface(object):
|
||||
date = self.get_date(media)
|
||||
return (str(media.handle),
|
||||
media.gramps_id,
|
||||
conv_to_unicode(media.path, None),
|
||||
media.path,
|
||||
str(media.mime),
|
||||
str(media.desc),
|
||||
media.checksum,
|
||||
|
Loading…
Reference in New Issue
Block a user