Replace UNITYPE with str
This commit is contained in:
parent
beab7892e5
commit
c9fd339289
@ -57,7 +57,7 @@ _ = glocale.translation.gettext
|
||||
from gramps.gen.db import DbBsddb
|
||||
from gramps.gen.plug import BasePluginManager
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import win, conv_to_unicode, UNITYPE
|
||||
from gramps.gen.constfunc import win, conv_to_unicode
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# constants
|
||||
|
@ -51,10 +51,9 @@ WINDOWS = ["Windows", "win32"]
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
UNITYPE = str
|
||||
cuni = str
|
||||
def conv_to_unicode(x, y='utf8'):
|
||||
return x if x is None or isinstance(x, UNITYPE) else cuni(x, y) if y else cuni(x)
|
||||
return x if x is None or isinstance(x, str) else cuni(x, y) if y else cuni(x)
|
||||
|
||||
# handle in database is bytes, while internally Gramps wants unicode for py3
|
||||
handle2internal = lambda x: conv_to_unicode(x, 'utf-8')
|
||||
|
@ -1028,7 +1028,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
person = self.get_person_from_handle(handle)
|
||||
#self.genderStats.uncount_person (person)
|
||||
#self.remove_from_surname_list(person)
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
if transaction.batch:
|
||||
with BSDDBTxn(self.env, self.person_map) as txn:
|
||||
@ -1126,7 +1126,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
if self.readonly or not handle:
|
||||
return
|
||||
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
if transaction.batch:
|
||||
with BSDDBTxn(self.env, data_map) as txn:
|
||||
@ -1189,7 +1189,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
'which is partly bytecode, this is not allowed.\n'
|
||||
'Key is %s') % str(key))
|
||||
key = str(key)
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
if not self.readonly:
|
||||
if not transaction.batch:
|
||||
|
@ -73,7 +73,7 @@ from ..utils.cast import conv_dbstr_to_unicode
|
||||
from . import (BsddbBaseCursor, DbReadBase)
|
||||
from ..utils.id import create_id
|
||||
from ..errors import DbError
|
||||
from ..constfunc import UNITYPE, cuni, handle2internal, get_env_var
|
||||
from ..constfunc import cuni, handle2internal, get_env_var
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -105,7 +105,7 @@ def find_byte_surname(key, data):
|
||||
"""
|
||||
surn = __index_surname(data[3][5])
|
||||
# in python 3 we work with unicode internally, but need byte function sometimes
|
||||
if isinstance(surn, UNITYPE):
|
||||
if isinstance(surn, str):
|
||||
return surn.encode('utf-8')
|
||||
return surn
|
||||
|
||||
@ -676,7 +676,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
return gid
|
||||
|
||||
def get_from_handle(self, handle, class_type, data_map):
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
data = data_map.get(handle)
|
||||
if data:
|
||||
@ -797,7 +797,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
def __get_obj_from_gramps_id(self, val, tbl, class_, prim_tbl):
|
||||
if isinstance(tbl, dict):
|
||||
return None ## trying to get object too early
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
try:
|
||||
data = tbl.get(val, txn=self.txn)
|
||||
@ -914,7 +914,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
Return the default grouping name for a surname.
|
||||
Return type is a unicode object
|
||||
"""
|
||||
if isinstance(surname, UNITYPE):
|
||||
if isinstance(surname, str):
|
||||
surname = surname.encode('utf-8')
|
||||
return conv_dbstr_to_unicode(self.name_group.get(surname, surname))
|
||||
|
||||
@ -930,7 +930,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
# The use of has_key seems allright because there is no write lock
|
||||
# on the name_group table when this is called.
|
||||
if isinstance(name, UNITYPE):
|
||||
if isinstance(name, str):
|
||||
name = name.encode('utf-8')
|
||||
return name in self.name_group
|
||||
|
||||
@ -1264,7 +1264,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
}
|
||||
|
||||
table = key2table[obj_key]
|
||||
if isinstance(gramps_id, UNITYPE):
|
||||
if isinstance(gramps_id, str):
|
||||
gramps_id = gramps_id.encode('utf-8')
|
||||
return table.get(gramps_id, txn=self.txn) is not None
|
||||
|
||||
@ -1650,7 +1650,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
if table is None:
|
||||
return None ## trying to get object too early
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
try:
|
||||
return table.get(handle, txn=self.txn)
|
||||
@ -1692,7 +1692,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
Helper function for has_<object>_handle methods
|
||||
"""
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
try:
|
||||
return table.get(handle, txn=self.txn) is not None
|
||||
@ -1761,80 +1761,80 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
return self.__has_handle(self.tag_map, handle)
|
||||
|
||||
def __sortbyperson_key(self, handle):
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
return glocale.sort_key(find_surname(handle,
|
||||
self.person_map.get(handle)))
|
||||
|
||||
def __sortbyplace(self, first, second):
|
||||
if isinstance(first, UNITYPE):
|
||||
if isinstance(first, str):
|
||||
first = first.encode('utf-8')
|
||||
if isinstance(second, UNITYPE):
|
||||
if isinstance(second, str):
|
||||
second = second.encode('utf-8')
|
||||
return glocale.strcoll(self.place_map.get(first)[2],
|
||||
self.place_map.get(second)[2])
|
||||
|
||||
def __sortbyplace_key(self, place):
|
||||
if isinstance(place, UNITYPE):
|
||||
if isinstance(place, str):
|
||||
place = place.encode('utf-8')
|
||||
return glocale.sort_key(self.place_map.get(place)[2])
|
||||
|
||||
def __sortbysource(self, first, second):
|
||||
if isinstance(first, UNITYPE):
|
||||
if isinstance(first, str):
|
||||
first = first.encode('utf-8')
|
||||
if isinstance(second, UNITYPE):
|
||||
if isinstance(second, str):
|
||||
second = second.encode('utf-8')
|
||||
source1 = cuni(self.source_map[first][2])
|
||||
source2 = cuni(self.source_map[second][2])
|
||||
return glocale.strcoll(source1, source2)
|
||||
|
||||
def __sortbysource_key(self, key):
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
source = cuni(self.source_map[key][2])
|
||||
return glocale.sort_key(source)
|
||||
|
||||
def __sortbycitation(self, first, second):
|
||||
if isinstance(first, UNITYPE):
|
||||
if isinstance(first, str):
|
||||
first = first.encode('utf-8')
|
||||
if isinstance(second, UNITYPE):
|
||||
if isinstance(second, str):
|
||||
second = second.encode('utf-8')
|
||||
citation1 = cuni(self.citation_map[first][3])
|
||||
citation2 = cuni(self.citation_map[second][3])
|
||||
return glocale.strcoll(citation1, citation2)
|
||||
|
||||
def __sortbycitation_key(self, key):
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
citation = cuni(self.citation_map[key][3])
|
||||
return glocale.sort_key(citation)
|
||||
|
||||
def __sortbymedia(self, first, second):
|
||||
if isinstance(first, UNITYPE):
|
||||
if isinstance(first, str):
|
||||
first = first.encode('utf-8')
|
||||
if isinstance(second, UNITYPE):
|
||||
if isinstance(second, str):
|
||||
second = second.encode('utf-8')
|
||||
media1 = self.media_map[first][4]
|
||||
media2 = self.media_map[second][4]
|
||||
return glocale.strcoll(media1, media2)
|
||||
|
||||
def __sortbymedia_key(self, key):
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
media = self.media_map[key][4]
|
||||
return glocale.sort_key(media)
|
||||
|
||||
def __sortbytag(self, first, second):
|
||||
if isinstance(first, UNITYPE):
|
||||
if isinstance(first, str):
|
||||
first = first.encode('utf-8')
|
||||
if isinstance(second, UNITYPE):
|
||||
if isinstance(second, str):
|
||||
second = second.encode('utf-8')
|
||||
tag1 = self.tag_map[first][1]
|
||||
tag2 = self.tag_map[second][1]
|
||||
return glocale.strcoll(tag1, tag2)
|
||||
|
||||
def __sortbytag_key(self, key):
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
tag = self.tag_map[key][1]
|
||||
return glocale.sort_key(tag)
|
||||
|
@ -23,7 +23,6 @@ import os
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
from ...constfunc import UNITYPE
|
||||
from bsddb3 import dbshelve, db
|
||||
|
||||
from ..read import DbBsddbTreeCursor
|
||||
@ -91,7 +90,7 @@ class CursorTest(unittest.TestCase):
|
||||
|
||||
def find_surname(key,data):
|
||||
val = data.surname
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
return val
|
||||
|
||||
@ -115,7 +114,7 @@ class CursorTest(unittest.TestCase):
|
||||
|
||||
def find_placeref(key,data):
|
||||
val = data[2]
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
return val
|
||||
|
||||
|
@ -51,7 +51,7 @@ _ = glocale.translation.gettext
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..constfunc import conv_to_unicode, handle2internal, win, UNITYPE
|
||||
from ..constfunc import conv_to_unicode, handle2internal, win
|
||||
from .dbconst import *
|
||||
from . import BSDDBTxn
|
||||
from ..errors import DbError
|
||||
|
@ -41,7 +41,7 @@ from bsddb3 import db
|
||||
#-------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import cuni, UNITYPE, handle2internal
|
||||
from ..constfunc import cuni, handle2internal
|
||||
from ..lib.markertype import MarkerType
|
||||
from ..lib.nameorigintype import NameOriginType
|
||||
from ..lib.place import Place
|
||||
@ -111,7 +111,7 @@ def gramps_upgrade_17(self):
|
||||
new_event = new_event[:11] + [[]] + new_event[11:]
|
||||
new_event = tuple(new_event)
|
||||
with BSDDBTxn(self.env, self.event_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_event)
|
||||
self.update()
|
||||
@ -181,7 +181,7 @@ def gramps_upgrade_17(self):
|
||||
new_place[6:12] + [[]] + new_place[12:]
|
||||
new_place = tuple(new_place)
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_place)
|
||||
self.update()
|
||||
@ -196,7 +196,7 @@ def gramps_upgrade_17(self):
|
||||
new_repository = new_repository[:8] + [[]] + new_repository[8:]
|
||||
new_repository = tuple(new_repository)
|
||||
with BSDDBTxn(self.env, self.repository_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_repository)
|
||||
self.update()
|
||||
@ -211,7 +211,7 @@ def gramps_upgrade_17(self):
|
||||
new_source = new_source[:11] + [[]] + new_source[11:]
|
||||
new_source = tuple(new_source)
|
||||
with BSDDBTxn(self.env, self.source_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_source)
|
||||
self.update()
|
||||
@ -226,7 +226,7 @@ def gramps_upgrade_17(self):
|
||||
new_citation = new_citation[:10] + [[]] + new_citation[10:]
|
||||
new_citation = tuple(new_citation)
|
||||
with BSDDBTxn(self.env, self.citation_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_citation)
|
||||
self.update()
|
||||
@ -244,7 +244,7 @@ def gramps_upgrade_17(self):
|
||||
notelist, medialist, abbrev, change, srcattributelist, reporef_list,
|
||||
taglist, private)
|
||||
with BSDDBTxn(self.env, self.source_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_source)
|
||||
self.update()
|
||||
@ -257,7 +257,7 @@ def gramps_upgrade_17(self):
|
||||
new_citation = (handle, gramps_id, datelist, page, confidence, source_handle,
|
||||
notelist, medialist, srcattributelist, change, taglist, private)
|
||||
with BSDDBTxn(self.env, self.citation_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_citation)
|
||||
self.update()
|
||||
@ -281,7 +281,7 @@ def gramps_upgrade_17(self):
|
||||
new_media = new_media[:5] + [checksum] + new_media[5:]
|
||||
new_media = tuple(new_media)
|
||||
with BSDDBTxn(self.env, self.media_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_media)
|
||||
self.update()
|
||||
@ -312,7 +312,7 @@ def add_place(self, name, level, parent, title):
|
||||
placeref.ref = handle2internal(parent)
|
||||
place.set_placeref_list([placeref])
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, place.serialize())
|
||||
return handle
|
||||
@ -441,7 +441,7 @@ def gramps_upgrade_16(self):
|
||||
private, person_ref_list)
|
||||
LOG.debug(" upgrade new_person %s" % [new_person])
|
||||
with BSDDBTxn(self.env, self.person_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_person)
|
||||
self.update()
|
||||
@ -475,7 +475,7 @@ def gramps_upgrade_16(self):
|
||||
change, date, tag_list, private)
|
||||
LOG.debug(" upgrade new_media %s" % [new_media])
|
||||
with BSDDBTxn(self.env, self.media_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_media)
|
||||
self.update()
|
||||
@ -514,7 +514,7 @@ def gramps_upgrade_16(self):
|
||||
change, private)
|
||||
LOG.debug(" upgrade new_place %s" % [new_place])
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_place)
|
||||
self.update()
|
||||
@ -566,7 +566,7 @@ def gramps_upgrade_16(self):
|
||||
note_list, change, tag_list, private)
|
||||
LOG.debug(" upgrade new_family %s" % [new_family])
|
||||
with BSDDBTxn(self.env, self.family_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_family)
|
||||
self.update()
|
||||
@ -607,7 +607,7 @@ def gramps_upgrade_16(self):
|
||||
change, private)
|
||||
LOG.debug(" upgrade new_event %s" % [new_event])
|
||||
with BSDDBTxn(self.env, self.event_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_event)
|
||||
self.update()
|
||||
@ -638,7 +638,7 @@ def gramps_upgrade_16(self):
|
||||
address_list, urls, change, private)
|
||||
LOG.debug(" upgrade new_repository %s" % [new_repository])
|
||||
with BSDDBTxn(self.env, self.repository_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_repository)
|
||||
self.update()
|
||||
@ -673,7 +673,7 @@ def gramps_upgrade_16(self):
|
||||
private)
|
||||
LOG.debug(" upgrade new_source %s" % [new_source])
|
||||
with BSDDBTxn(self.env, self.source_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_source)
|
||||
self.update()
|
||||
@ -883,7 +883,7 @@ def convert_source_list_to_citation_list_16(self, source_list):
|
||||
new_data_map, new_change, private)
|
||||
citation_list.append((new_handle))
|
||||
with BSDDBTxn(self.env, self.citation_map) as txn:
|
||||
if isinstance(new_handle, UNITYPE):
|
||||
if isinstance(new_handle, str):
|
||||
new_handle = new_handle.encode('utf-8')
|
||||
txn.put(new_handle, new_citation)
|
||||
self.cmap_index += 1
|
||||
@ -966,7 +966,7 @@ def gramps_upgrade_15(self):
|
||||
)
|
||||
|
||||
with BSDDBTxn(self.env, self.person_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_person)
|
||||
self.update()
|
||||
@ -991,7 +991,7 @@ def gramps_upgrade_15(self):
|
||||
new_family[13] = []
|
||||
new_family = tuple(new_family)
|
||||
with BSDDBTxn(self.env, self.family_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_family)
|
||||
self.update()
|
||||
@ -1010,7 +1010,7 @@ def gramps_upgrade_15(self):
|
||||
new_note[6] = []
|
||||
new_note = tuple(new_note)
|
||||
with BSDDBTxn(self.env, self.note_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_note)
|
||||
self.update()
|
||||
@ -1025,7 +1025,7 @@ def gramps_upgrade_15(self):
|
||||
new_media[10] = []
|
||||
new_media = tuple(new_media)
|
||||
with BSDDBTxn(self.env, self.media_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_media)
|
||||
self.update()
|
||||
@ -1041,7 +1041,7 @@ def gramps_upgrade_15(self):
|
||||
#new_event[11] = []
|
||||
new_event = tuple(new_event)
|
||||
with BSDDBTxn(self.env, self.event_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_event)
|
||||
self.update()
|
||||
@ -1059,7 +1059,7 @@ def gramps_upgrade_15(self):
|
||||
new_place = new_place[:12] + new_place[13:]
|
||||
new_place = tuple(new_place)
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_place)
|
||||
self.update()
|
||||
@ -1074,7 +1074,7 @@ def gramps_upgrade_15(self):
|
||||
new_source = new_source[:11] + new_source[12:]
|
||||
new_source = tuple(new_source)
|
||||
with BSDDBTxn(self.env, self.source_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_source)
|
||||
self.update()
|
||||
@ -1090,7 +1090,7 @@ def gramps_upgrade_15(self):
|
||||
new_repository[5] = list(map(convert_address, new_repository[5]))
|
||||
new_repository = tuple(new_repository)
|
||||
with BSDDBTxn(self.env, self.repository_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_repository)
|
||||
self.update()
|
||||
@ -1114,7 +1114,7 @@ def convert_marker(self, marker_field):
|
||||
tag.set_name(tag_name)
|
||||
tag.set_priority(len(self.tags))
|
||||
with BSDDBTxn(self.env, self.tag_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, tag.serialize())
|
||||
self.tags[tag_name] = handle
|
||||
@ -1182,7 +1182,7 @@ def gramps_upgrade_14(self):
|
||||
new_note = (handle, gramps_id, styled_text, format, note_type,
|
||||
change, marker, private)
|
||||
with BSDDBTxn(self.env, self.note_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_note)
|
||||
self.update()
|
||||
@ -1204,7 +1204,7 @@ def gramps_upgrade_14(self):
|
||||
description, place, new_source_list, note_list,
|
||||
new_media_list, new_attribute_list, change,marker,private)
|
||||
with BSDDBTxn(self.env, self.event_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_event)
|
||||
self.update()
|
||||
@ -1288,7 +1288,7 @@ def gramps_upgrade_14(self):
|
||||
)
|
||||
|
||||
with BSDDBTxn(self.env, self.person_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_person)
|
||||
self.update()
|
||||
@ -1322,7 +1322,7 @@ def gramps_upgrade_14(self):
|
||||
change, marker, private)
|
||||
|
||||
with BSDDBTxn(self.env, self.family_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_family)
|
||||
self.update()
|
||||
@ -1349,7 +1349,7 @@ def gramps_upgrade_14(self):
|
||||
new_address_list, urls, change, marker, private)
|
||||
|
||||
with BSDDBTxn(self.env, self.repository_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_repository)
|
||||
self.update()
|
||||
@ -1369,7 +1369,7 @@ def gramps_upgrade_14(self):
|
||||
new_date, marker, private)
|
||||
|
||||
with BSDDBTxn(self.env, self.media_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_media)
|
||||
self.update()
|
||||
@ -1389,7 +1389,7 @@ def gramps_upgrade_14(self):
|
||||
new_source_list, note_list, change, marker, private)
|
||||
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_place)
|
||||
self.update()
|
||||
@ -1410,7 +1410,7 @@ def gramps_upgrade_14(self):
|
||||
marker, private)
|
||||
|
||||
with BSDDBTxn(self.env, self.source_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
txn.put(handle, new_source)
|
||||
self.update()
|
||||
|
@ -80,7 +80,7 @@ from ..utils.cast import conv_dbstr_to_unicode
|
||||
from ..utils.id import create_id
|
||||
from ..updatecallback import UpdateCallback
|
||||
from ..errors import DbError
|
||||
from ..constfunc import (win, conv_to_unicode, cuni, UNITYPE, handle2internal,
|
||||
from ..constfunc import (win, conv_to_unicode, cuni, handle2internal,
|
||||
get_env_var)
|
||||
from ..const import HOME_DIR, GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
@ -177,7 +177,7 @@ def find_idmap(key, data):
|
||||
returns a byte string
|
||||
"""
|
||||
val = data[1]
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
return val
|
||||
|
||||
@ -186,7 +186,7 @@ def find_parent(key, data):
|
||||
val = data[5][0][0]
|
||||
else:
|
||||
val = ''
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
return val
|
||||
|
||||
@ -200,7 +200,7 @@ def find_primary_handle(key, data):
|
||||
returns byte string
|
||||
"""
|
||||
val = (data)[0][1]
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
return val
|
||||
|
||||
@ -209,7 +209,7 @@ def find_referenced_handle(key, data):
|
||||
returns byte string
|
||||
"""
|
||||
val = (data)[1][1]
|
||||
if isinstance(val, UNITYPE):
|
||||
if isinstance(val, str):
|
||||
val = val.encode('utf-8')
|
||||
return val
|
||||
|
||||
@ -494,7 +494,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
def set_default_person_handle(self, handle):
|
||||
"""Set the default Person to the passed instance."""
|
||||
#we store a byte string!
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
if not self.readonly:
|
||||
# Start transaction
|
||||
@ -1111,7 +1111,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
"""
|
||||
Find all child places having the given place as the primary parent.
|
||||
"""
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
parent_cur = self.get_place_parent_cursor()
|
||||
|
||||
@ -1155,7 +1155,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
|
||||
result_list = list(find_backlink_handles(handle))
|
||||
"""
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
# Use the secondary index to locate all the reference_map entries
|
||||
# that include a reference to the object we are looking for.
|
||||
@ -1242,7 +1242,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
existing_references = set()
|
||||
primary_cur = self.get_reference_map_primary_cursor()
|
||||
try:
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
key = handle.encode('utf-8')
|
||||
else:
|
||||
key = handle
|
||||
@ -1302,7 +1302,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
'which is partly bytecode, this is not allowed.\n'
|
||||
'Key is %s') % str(key))
|
||||
key = str(key)
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
if not self.readonly:
|
||||
if not transaction.batch:
|
||||
@ -1319,7 +1319,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
if isinstance(key, tuple):
|
||||
#create a string key
|
||||
key = str(key)
|
||||
if isinstance(key, UNITYPE):
|
||||
if isinstance(key, str):
|
||||
key = key.encode('utf-8')
|
||||
if self.readonly or not key:
|
||||
return
|
||||
@ -1686,7 +1686,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
if self.readonly or not handle:
|
||||
return
|
||||
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
if transaction.batch:
|
||||
with BSDDBTxn(self.env, data_map) as txn:
|
||||
@ -1711,7 +1711,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
person = self.get_person_from_handle(handle)
|
||||
self.genderStats.uncount_person (person)
|
||||
self.remove_from_surname_list(person)
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
if transaction.batch:
|
||||
with BSDDBTxn(self.env, self.person_map) as txn:
|
||||
@ -1886,7 +1886,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
|
||||
obj.change = int(change_time or time.time())
|
||||
handle = obj.handle
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
|
||||
self.update_reference_map(obj, transaction, self.txn)
|
||||
@ -2131,7 +2131,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
transaction, change_time)
|
||||
|
||||
def get_from_handle(self, handle, class_type, data_map):
|
||||
if isinstance(handle, UNITYPE):
|
||||
if isinstance(handle, str):
|
||||
handle = handle.encode('utf-8')
|
||||
try:
|
||||
data = data_map.get(handle, txn=self.txn)
|
||||
|
@ -68,7 +68,7 @@ LOG = logging.getLogger(".gramps.gen")
|
||||
#-------------------------------------------------------------------------
|
||||
from ..const import ARABIC_COMMA, ARABIC_SEMICOLON, GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from ..constfunc import cuni, conv_to_unicode, UNITYPE
|
||||
from ..constfunc import cuni, conv_to_unicode
|
||||
from ..lib.name import Name
|
||||
from ..lib.nameorigintype import NameOriginType
|
||||
|
||||
@ -1022,7 +1022,7 @@ 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, UNITYPE):
|
||||
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)
|
||||
|
@ -18,8 +18,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
from gramps.gen.constfunc import UNITYPE
|
||||
|
||||
class HandleClass(str):
|
||||
def __init__(self, handle):
|
||||
super(HandleClass, self).__init__()
|
||||
|
@ -41,7 +41,7 @@ LOG = logging.getLogger(".")
|
||||
#-------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import conv_to_unicode, UNITYPE
|
||||
from ..constfunc import conv_to_unicode
|
||||
|
||||
#strings in database are utf-8
|
||||
conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8')
|
||||
|
@ -42,7 +42,7 @@ LOG = logging.getLogger(".gen.utils.file")
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..constfunc import win, mac, cuni, conv_to_unicode, UNITYPE, get_env_var
|
||||
from ..constfunc import win, mac, cuni, conv_to_unicode, get_env_var
|
||||
from ..const import TEMP_DIR, USER_HOME, GRAMPS_LOCALE as glocale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -45,7 +45,7 @@ from urllib.parse import urlparse
|
||||
import logging
|
||||
LOG = logging.getLogger(".DbManager")
|
||||
|
||||
from gramps.gen.constfunc import win, UNITYPE, conv_to_unicode
|
||||
from gramps.gen.constfunc import win, conv_to_unicode
|
||||
if win():
|
||||
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
|
||||
if _RCS_FOUND and "TZ" not in os.environ:
|
||||
@ -848,7 +848,7 @@ def find_revisions(name):
|
||||
get_next = False
|
||||
if os.path.isfile(name):
|
||||
for line in proc.stdout:
|
||||
if not isinstance(line, UNITYPE):
|
||||
if not isinstance(line, str):
|
||||
# we assume utf-8 ...
|
||||
line = line.decode('utf-8')
|
||||
match = rev.match(line)
|
||||
|
@ -63,7 +63,7 @@ from .managedwindow import GrampsWindowManager
|
||||
from gramps.gen.relationship import get_relationship_calculator
|
||||
from .glade import Glade
|
||||
from gramps.gen.utils.db import navigation_label
|
||||
from gramps.gen.constfunc import UNITYPE, cuni
|
||||
from gramps.gen.constfunc import cuni
|
||||
from .widgets.progressdialog import ProgressMonitor, GtkProgressDialog
|
||||
|
||||
DISABLED = -1
|
||||
@ -80,7 +80,7 @@ class History(Callback):
|
||||
"""
|
||||
|
||||
__signals__ = {
|
||||
'active-changed' : (UNITYPE, ),
|
||||
'active-changed' : (str, ),
|
||||
'mru-changed' : (list, )
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ class History(Callback):
|
||||
self.emit('mru-changed', (self.mru, ))
|
||||
if self.history:
|
||||
newact = self.history[self.index]
|
||||
if not isinstance(newact, UNITYPE):
|
||||
if not isinstance(newact, str):
|
||||
newact = cuni(newact)
|
||||
self.emit('active-changed', (newact,))
|
||||
|
||||
@ -154,7 +154,7 @@ class History(Callback):
|
||||
self.index += 1
|
||||
if self.history:
|
||||
newact = self.history[self.index]
|
||||
if not isinstance(newact, UNITYPE):
|
||||
if not isinstance(newact, str):
|
||||
newact = cuni(newact)
|
||||
self.emit('active-changed', (newact,))
|
||||
|
||||
@ -169,7 +169,7 @@ class History(Callback):
|
||||
self.mru.append(handle)
|
||||
self.emit('mru-changed', (self.mru, ))
|
||||
newact = self.history[self.index]
|
||||
if not isinstance(newact, UNITYPE):
|
||||
if not isinstance(newact, str):
|
||||
newact = cuni(newact)
|
||||
self.emit('active-changed', (newact,))
|
||||
return newact
|
||||
@ -186,7 +186,7 @@ class History(Callback):
|
||||
self.mru.append(handle)
|
||||
self.emit('mru-changed', (self.mru, ))
|
||||
newact = self.history[self.index]
|
||||
if not isinstance(newact, UNITYPE):
|
||||
if not isinstance(newact, str):
|
||||
newact = cuni(newact)
|
||||
self.emit('active-changed', (newact,))
|
||||
return newact
|
||||
@ -369,7 +369,7 @@ class DisplayState(Callback):
|
||||
|
||||
__signals__ = {
|
||||
'filters-changed' : (str, ),
|
||||
'filter-name-changed' : (str, UNITYPE, UNITYPE),
|
||||
'filter-name-changed' : (str, str, str),
|
||||
'nameformat-changed' : None,
|
||||
'grampletbar-close-changed' : None,
|
||||
'update-available' : (list, ),
|
||||
|
@ -29,7 +29,6 @@ from gi.repository import Pango
|
||||
from ... import widgets
|
||||
from ...dbguielement import DbGUIElement
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import UNITYPE
|
||||
|
||||
_RETURN = Gdk.keyval_from_name("Return")
|
||||
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
|
||||
@ -210,7 +209,7 @@ class SidebarFilter(DbGUIElement):
|
||||
for handle in self.dbstate.db.get_tag_handles(sort_handles=True):
|
||||
tag = self.dbstate.db.get_tag_from_handle(handle)
|
||||
# for python3 this returns a byte object, so conversion needed
|
||||
if not isinstance(handle, UNITYPE):
|
||||
if not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
self.__tag_list.append((tag.get_name(), handle))
|
||||
self.on_tags_changed([item[0] for item in self.__tag_list])
|
||||
|
@ -56,7 +56,7 @@ from gramps.gen.config import config
|
||||
from gramps.gen.errors import WindowActiveError
|
||||
from ..filters import SearchBar
|
||||
from ..widgets.menuitem import add_menuitem
|
||||
from gramps.gen.constfunc import UNITYPE, conv_to_unicode
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from gramps.gen.const import CUSTOM_FILTERS
|
||||
from gramps.gen.utils.debug import profile
|
||||
from gramps.gen.utils.string import data_recover_msg
|
||||
|
@ -71,7 +71,7 @@ from gi.repository import Gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.filters import SearchFilter, ExactSearchFilter
|
||||
from gramps.gen.constfunc import cuni, UNITYPE, conv_to_unicode, handle2internal
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, handle2internal
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -311,7 +311,7 @@ class FlatNodeMap(object):
|
||||
:return handle: unicode form of the handle
|
||||
"""
|
||||
handle = self._index2hndl[self.real_index(path)][1]
|
||||
if not isinstance(handle, UNITYPE):
|
||||
if not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
return handle
|
||||
|
||||
|
@ -43,7 +43,7 @@ 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 cuni, conv_to_unicode, UNITYPE
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from .flatbasemodel import FlatBaseModel
|
||||
|
||||
@ -107,7 +107,7 @@ class MediaModel(FlatBaseModel):
|
||||
|
||||
def column_description(self, data):
|
||||
descr = data[4]
|
||||
if isinstance(descr, UNITYPE):
|
||||
if isinstance(descr, str):
|
||||
return descr
|
||||
try:
|
||||
return cuni(descr)
|
||||
@ -116,7 +116,7 @@ class MediaModel(FlatBaseModel):
|
||||
|
||||
def column_path(self, data):
|
||||
path = data[2]
|
||||
if isinstance(path, UNITYPE):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
try:
|
||||
return cuni(path)
|
||||
@ -125,7 +125,7 @@ class MediaModel(FlatBaseModel):
|
||||
|
||||
def column_mime(self, data):
|
||||
mime = data[3]
|
||||
if mime and isinstance(mime, UNITYPE):
|
||||
if mime and isinstance(mime, str):
|
||||
return mime
|
||||
if mime:
|
||||
return cuni(mime)
|
||||
|
@ -63,7 +63,7 @@ from .lru import LRU
|
||||
from .flatbasemodel import FlatBaseModel
|
||||
from .treebasemodel import TreeBaseModel
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import cuni, UNITYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -202,7 +202,7 @@ class PeopleBaseModel(object):
|
||||
def sort_name(self, data):
|
||||
name = name_displayer.raw_sorted_name(data[COLUMN_NAME])
|
||||
# internally we work with utf-8
|
||||
if not isinstance(name, UNITYPE):
|
||||
if not isinstance(name, str):
|
||||
name = name.decode('utf-8')
|
||||
return name
|
||||
|
||||
@ -592,7 +592,7 @@ class PersonTreeModel(PeopleBaseModel, TreeBaseModel):
|
||||
|
||||
name_data = data[COLUMN_NAME]
|
||||
group_name = ngn(self.db, name_data)
|
||||
#if isinstance(group_name, UNITYPE):
|
||||
#if isinstance(group_name, str):
|
||||
# group_name = group_name.encode('utf-8')
|
||||
sort_key = self.sort_func(data)
|
||||
|
||||
|
@ -53,7 +53,7 @@ from gi.repository import Gtk
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
import gramps.gui.widgets.progressdialog as progressdlg
|
||||
from gramps.gen.constfunc import cuni, UNITYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
from .lru import LRU
|
||||
from bisect import bisect_right
|
||||
from gramps.gen.filters import SearchFilter, ExactSearchFilter
|
||||
@ -554,7 +554,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
|
||||
with gen_cursor() as cursor:
|
||||
for handle, data in cursor:
|
||||
# for python3 this returns a byte object, so conversion needed
|
||||
if not isinstance(handle, UNITYPE):
|
||||
if not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
status.heartbeat()
|
||||
if status.should_cancel():
|
||||
@ -610,7 +610,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
|
||||
def beat(key):
|
||||
status_ppl.heartbeat()
|
||||
# for python3 this returns a byte object, so conversion needed
|
||||
if not isinstance(key, UNITYPE):
|
||||
if not isinstance(key, str):
|
||||
key = key.decode('utf-8')
|
||||
return key
|
||||
|
||||
@ -897,7 +897,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
|
||||
"""
|
||||
node = self.get_node_from_iter(iter)
|
||||
handle = node.handle
|
||||
if handle and not isinstance(handle, UNITYPE):
|
||||
if handle and not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
return handle
|
||||
|
||||
|
@ -48,7 +48,7 @@ from gi.repository import Gtk
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.constfunc import conv_to_unicode, UNITYPE
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from .undoablebuffer import Stack
|
||||
|
||||
class UndoableInsertEntry(object):
|
||||
@ -57,7 +57,7 @@ class UndoableInsertEntry(object):
|
||||
self.offset = position
|
||||
self.text = str(text)
|
||||
#unicode char can have length > 1 as it points in the buffer
|
||||
if not isinstance(text, UNITYPE):
|
||||
if not isinstance(text, str):
|
||||
text = conv_to_unicode(text, 'utf-8')
|
||||
charlength = len(text)
|
||||
self.length = charlength
|
||||
|
@ -52,7 +52,7 @@ from gi.repository import Pango
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.errors import MaskError, ValidationError, WindowActiveError
|
||||
from gramps.gen.constfunc import cuni, UNITYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
from .undoableentry import UndoableEntry
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -402,7 +402,7 @@ class MaskedEntry(UndoableEntry):
|
||||
for validator in self._mask_validators[start:end]:
|
||||
if isinstance(validator, int):
|
||||
s += ' '
|
||||
elif isinstance(validator, UNITYPE):
|
||||
elif isinstance(validator, str):
|
||||
s += validator
|
||||
else:
|
||||
raise AssertionError
|
||||
@ -593,7 +593,7 @@ class MaskedEntry(UndoableEntry):
|
||||
if isinstance(validator, int):
|
||||
if not INPUT_CHAR_MAP[validator](text):
|
||||
return False
|
||||
if isinstance(validator, UNITYPE):
|
||||
if isinstance(validator, str):
|
||||
if validator == text:
|
||||
return True
|
||||
return False
|
||||
|
@ -63,7 +63,7 @@ from gramps.gen.const import ROOT_DIR
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
from gramps.gen.constfunc import cuni, UNITYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -85,7 +85,7 @@ class DetailView(QtCore.QObject):
|
||||
changed = QtCore.Signal()
|
||||
|
||||
#make Model.Column.property available in QML
|
||||
name = QtCore.Property(UNITYPE, _name, notify=changed)
|
||||
name = QtCore.Property(str, _name, notify=changed)
|
||||
|
||||
class DetViewSumModel(QtCore.QAbstractListModel):
|
||||
"""
|
||||
|
@ -55,7 +55,7 @@ from gramps.gen.const import IMAGE_DIR, ROOT_DIR
|
||||
from gramps.cli.clidbman import CLIDbManager, NAME_FILE, time_val
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.constfunc import cuni, UNITYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -101,11 +101,11 @@ class FamTreeWrapper(QtCore.QObject):
|
||||
self.__dbman.rename_database(self.__path_namefile, name)
|
||||
self.changed_name.emit()
|
||||
|
||||
name = QtCore.Property(UNITYPE, _name, _set_name, notify=changed_name)
|
||||
path = QtCore.Property(UNITYPE, _path, notify=changed)
|
||||
last_access = QtCore.Property(UNITYPE, _last_access, notify=changed)
|
||||
name = QtCore.Property(str, _name, _set_name, notify=changed_name)
|
||||
path = QtCore.Property(str, _path, notify=changed)
|
||||
last_access = QtCore.Property(str, _last_access, notify=changed)
|
||||
use_icon = QtCore.Property(bool, _use_icon, notify=changed)
|
||||
icon = QtCore.Property(UNITYPE, _icon, notify=changed)
|
||||
icon = QtCore.Property(str, _icon, notify=changed)
|
||||
|
||||
class FamTreeListModel(QtCore.QAbstractListModel):
|
||||
"""
|
||||
|
@ -53,7 +53,7 @@ from PySide import QtOpenGL
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import ROOT_DIR
|
||||
from gramps.gen.constfunc import cuni, UNITYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
from gramps.gui.views.treemodels import conv_unicode_tosrtkey
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
@ -88,7 +88,7 @@ class QMLPerson(QtCore.QObject):
|
||||
dummychanged = QtCore.Signal()
|
||||
|
||||
#make Model.Column.property available in QML
|
||||
name = QtCore.Property(UNITYPE, _name, notify=dummychanged)
|
||||
name = QtCore.Property(str, _name, notify=dummychanged)
|
||||
|
||||
class QMLPersonListModel(QtCore.QAbstractListModel):
|
||||
"""
|
||||
|
@ -44,7 +44,7 @@ import re
|
||||
# Gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.constfunc import conv_to_unicode, UNITYPE
|
||||
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)
|
||||
@ -500,7 +500,7 @@ class GtkDocParagraph(GtkDocBaseElement):
|
||||
"""
|
||||
Internal method to allow for splitting of paragraphs
|
||||
"""
|
||||
if not isinstance(plaintext, UNITYPE):
|
||||
if not isinstance(plaintext, str):
|
||||
self._plaintext = conv_to_unicode(plaintext, 'utf-8')
|
||||
else:
|
||||
self._plaintext = plaintext
|
||||
|
@ -132,7 +132,7 @@ from gramps.gen.db.dbconst import EVENT_KEY
|
||||
from gramps.gui.dialog import WarningDialog
|
||||
from gramps.gen.lib.const import IDENTICAL, DIFFERENT
|
||||
from gramps.gen.lib import (StyledText, StyledTextTag, StyledTextTagType)
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, UNITYPE, win
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, win
|
||||
from gramps.plugins.lib.libplaceimport import PlaceImport
|
||||
from gramps.gen.display.place import displayer as place_displayer
|
||||
|
||||
@ -1737,7 +1737,7 @@ class IdMapper(object):
|
||||
# now looking for I1, it wouldn't be in self.swap, and we now
|
||||
# find that I0001 is in use, so we have to create a new id.
|
||||
bformatted_gid = formatted_gid
|
||||
if isinstance(bformatted_gid, UNITYPE):
|
||||
if isinstance(bformatted_gid, str):
|
||||
bformatted_gid = bformatted_gid.encode('utf-8')
|
||||
if self.trans.get(bformatted_gid) or \
|
||||
(formatted_gid in list(self.swap.values())):
|
||||
|
@ -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 UNITYPE, cuni, handle2internal, conv_to_unicode
|
||||
from gramps.gen.constfunc import cuni, handle2internal, conv_to_unicode
|
||||
|
||||
# table for handling control chars in notes.
|
||||
# All except 09, 0A, 0D are replaced with space.
|
||||
@ -344,16 +344,16 @@ class CheckIntegrity(object):
|
||||
for bhandle in self.db.media_map.keys():
|
||||
handle = handle2internal(bhandle)
|
||||
data = self.db.media_map[bhandle]
|
||||
if not isinstance(data[2], UNITYPE) or not isinstance(data[4], UNITYPE):
|
||||
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], UNITYPE):
|
||||
if not isinstance(data[2], str):
|
||||
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], UNITYPE):
|
||||
if not isinstance(data[4], str):
|
||||
logging.warning(' FAIL: encoding error on media object '
|
||||
'"%(gid)s" description "%(desc)s"' %
|
||||
{'gid' : obj.gramps_id, 'desc' : obj.desc})
|
||||
|
@ -55,7 +55,6 @@ from gi.repository import GObject
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import URL_MANUAL_PAGE, VERSION_DIR
|
||||
from gramps.gen.constfunc import UNITYPE
|
||||
from gramps.gen.lib import (ChildRefType, EventRoleType, EventType,
|
||||
FamilyRelType, NameType, Person)
|
||||
from gramps.gen.lib.date import Today
|
||||
@ -544,7 +543,7 @@ class VerifyResults(ManagedWindow):
|
||||
pass
|
||||
|
||||
def load_ignored(self, db_filename):
|
||||
if isinstance(db_filename, UNITYPE):
|
||||
if isinstance(db_filename, str):
|
||||
db_filename = db_filename.encode('utf-8')
|
||||
md5sum = md5(db_filename)
|
||||
## a new Gramps major version means recreating the .vfm file.
|
||||
|
@ -122,7 +122,7 @@ from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gen.utils.file import media_path_full
|
||||
from gramps.gen.utils.alive import probably_alive
|
||||
from gramps.gen.utils.db import get_source_and_citation_referents
|
||||
from gramps.gen.constfunc import win, cuni, conv_to_unicode, UNITYPE, get_curr_dir
|
||||
from gramps.gen.constfunc import win, cuni, conv_to_unicode, get_curr_dir
|
||||
from gramps.gen.config import config
|
||||
from gramps.gui.thumbnails import get_thumbnail_path, run_thumbnailer
|
||||
from gramps.gen.utils.image import image_size, resize_to_jpeg_buffer
|
||||
@ -7192,7 +7192,7 @@ class NavWebReport(Report):
|
||||
for handle in ind_list:
|
||||
# FIXME work around bug that self.database.iter under python 3
|
||||
# returns (binary) data rather than text
|
||||
if not isinstance(handle, UNITYPE):
|
||||
if not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
step()
|
||||
self._add_person(handle, "", "")
|
||||
|
Loading…
Reference in New Issue
Block a user