Replace UNITYPE with str

This commit is contained in:
Nick Hall 2015-03-14 22:33:55 +00:00
parent beab7892e5
commit c9fd339289
30 changed files with 136 additions and 142 deletions

View File

@ -57,7 +57,7 @@ _ = glocale.translation.gettext
from gramps.gen.db import DbBsddb from gramps.gen.db import DbBsddb
from gramps.gen.plug import BasePluginManager from gramps.gen.plug import BasePluginManager
from gramps.gen.config import config 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 # constants

View File

@ -51,10 +51,9 @@ WINDOWS = ["Windows", "win32"]
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
UNITYPE = str
cuni = str cuni = str
def conv_to_unicode(x, y='utf8'): 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 # handle in database is bytes, while internally Gramps wants unicode for py3
handle2internal = lambda x: conv_to_unicode(x, 'utf-8') handle2internal = lambda x: conv_to_unicode(x, 'utf-8')

View File

@ -1028,7 +1028,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
person = self.get_person_from_handle(handle) person = self.get_person_from_handle(handle)
#self.genderStats.uncount_person (person) #self.genderStats.uncount_person (person)
#self.remove_from_surname_list(person) #self.remove_from_surname_list(person)
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
if transaction.batch: if transaction.batch:
with BSDDBTxn(self.env, self.person_map) as txn: with BSDDBTxn(self.env, self.person_map) as txn:
@ -1126,7 +1126,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
if self.readonly or not handle: if self.readonly or not handle:
return return
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
if transaction.batch: if transaction.batch:
with BSDDBTxn(self.env, data_map) as txn: 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' 'which is partly bytecode, this is not allowed.\n'
'Key is %s') % str(key)) 'Key is %s') % str(key))
key = str(key) key = str(key)
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
if not self.readonly: if not self.readonly:
if not transaction.batch: if not transaction.batch:

View File

@ -73,7 +73,7 @@ from ..utils.cast import conv_dbstr_to_unicode
from . import (BsddbBaseCursor, DbReadBase) from . import (BsddbBaseCursor, DbReadBase)
from ..utils.id import create_id from ..utils.id import create_id
from ..errors import DbError 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 from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
@ -105,7 +105,7 @@ def find_byte_surname(key, data):
""" """
surn = __index_surname(data[3][5]) surn = __index_surname(data[3][5])
# in python 3 we work with unicode internally, but need byte function sometimes # 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.encode('utf-8')
return surn return surn
@ -676,7 +676,7 @@ class DbBsddbRead(DbReadBase, Callback):
return gid return gid
def get_from_handle(self, handle, class_type, data_map): def get_from_handle(self, handle, class_type, data_map):
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
data = data_map.get(handle) data = data_map.get(handle)
if data: if data:
@ -797,7 +797,7 @@ class DbBsddbRead(DbReadBase, Callback):
def __get_obj_from_gramps_id(self, val, tbl, class_, prim_tbl): def __get_obj_from_gramps_id(self, val, tbl, class_, prim_tbl):
if isinstance(tbl, dict): if isinstance(tbl, dict):
return None ## trying to get object too early return None ## trying to get object too early
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
try: try:
data = tbl.get(val, txn=self.txn) data = tbl.get(val, txn=self.txn)
@ -914,7 +914,7 @@ class DbBsddbRead(DbReadBase, Callback):
Return the default grouping name for a surname. Return the default grouping name for a surname.
Return type is a unicode object Return type is a unicode object
""" """
if isinstance(surname, UNITYPE): if isinstance(surname, str):
surname = surname.encode('utf-8') surname = surname.encode('utf-8')
return conv_dbstr_to_unicode(self.name_group.get(surname, surname)) 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 # The use of has_key seems allright because there is no write lock
# on the name_group table when this is called. # on the name_group table when this is called.
if isinstance(name, UNITYPE): if isinstance(name, str):
name = name.encode('utf-8') name = name.encode('utf-8')
return name in self.name_group return name in self.name_group
@ -1264,7 +1264,7 @@ class DbBsddbRead(DbReadBase, Callback):
} }
table = key2table[obj_key] table = key2table[obj_key]
if isinstance(gramps_id, UNITYPE): if isinstance(gramps_id, str):
gramps_id = gramps_id.encode('utf-8') gramps_id = gramps_id.encode('utf-8')
return table.get(gramps_id, txn=self.txn) is not None return table.get(gramps_id, txn=self.txn) is not None
@ -1650,7 +1650,7 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
if table is None: if table is None:
return None ## trying to get object too early return None ## trying to get object too early
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
try: try:
return table.get(handle, txn=self.txn) return table.get(handle, txn=self.txn)
@ -1692,7 +1692,7 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
Helper function for has_<object>_handle methods Helper function for has_<object>_handle methods
""" """
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
try: try:
return table.get(handle, txn=self.txn) is not None 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) return self.__has_handle(self.tag_map, handle)
def __sortbyperson_key(self, handle): def __sortbyperson_key(self, handle):
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
return glocale.sort_key(find_surname(handle, return glocale.sort_key(find_surname(handle,
self.person_map.get(handle))) self.person_map.get(handle)))
def __sortbyplace(self, first, second): def __sortbyplace(self, first, second):
if isinstance(first, UNITYPE): if isinstance(first, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, UNITYPE): if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
return glocale.strcoll(self.place_map.get(first)[2], return glocale.strcoll(self.place_map.get(first)[2],
self.place_map.get(second)[2]) self.place_map.get(second)[2])
def __sortbyplace_key(self, place): def __sortbyplace_key(self, place):
if isinstance(place, UNITYPE): if isinstance(place, str):
place = place.encode('utf-8') place = place.encode('utf-8')
return glocale.sort_key(self.place_map.get(place)[2]) return glocale.sort_key(self.place_map.get(place)[2])
def __sortbysource(self, first, second): def __sortbysource(self, first, second):
if isinstance(first, UNITYPE): if isinstance(first, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, UNITYPE): if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
source1 = cuni(self.source_map[first][2]) source1 = cuni(self.source_map[first][2])
source2 = cuni(self.source_map[second][2]) source2 = cuni(self.source_map[second][2])
return glocale.strcoll(source1, source2) return glocale.strcoll(source1, source2)
def __sortbysource_key(self, key): def __sortbysource_key(self, key):
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
source = cuni(self.source_map[key][2]) source = cuni(self.source_map[key][2])
return glocale.sort_key(source) return glocale.sort_key(source)
def __sortbycitation(self, first, second): def __sortbycitation(self, first, second):
if isinstance(first, UNITYPE): if isinstance(first, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, UNITYPE): if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
citation1 = cuni(self.citation_map[first][3]) citation1 = cuni(self.citation_map[first][3])
citation2 = cuni(self.citation_map[second][3]) citation2 = cuni(self.citation_map[second][3])
return glocale.strcoll(citation1, citation2) return glocale.strcoll(citation1, citation2)
def __sortbycitation_key(self, key): def __sortbycitation_key(self, key):
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
citation = cuni(self.citation_map[key][3]) citation = cuni(self.citation_map[key][3])
return glocale.sort_key(citation) return glocale.sort_key(citation)
def __sortbymedia(self, first, second): def __sortbymedia(self, first, second):
if isinstance(first, UNITYPE): if isinstance(first, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, UNITYPE): if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
media1 = self.media_map[first][4] media1 = self.media_map[first][4]
media2 = self.media_map[second][4] media2 = self.media_map[second][4]
return glocale.strcoll(media1, media2) return glocale.strcoll(media1, media2)
def __sortbymedia_key(self, key): def __sortbymedia_key(self, key):
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
media = self.media_map[key][4] media = self.media_map[key][4]
return glocale.sort_key(media) return glocale.sort_key(media)
def __sortbytag(self, first, second): def __sortbytag(self, first, second):
if isinstance(first, UNITYPE): if isinstance(first, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, UNITYPE): if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
tag1 = self.tag_map[first][1] tag1 = self.tag_map[first][1]
tag2 = self.tag_map[second][1] tag2 = self.tag_map[second][1]
return glocale.strcoll(tag1, tag2) return glocale.strcoll(tag1, tag2)
def __sortbytag_key(self, key): def __sortbytag_key(self, key):
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
tag = self.tag_map[key][1] tag = self.tag_map[key][1]
return glocale.sort_key(tag) return glocale.sort_key(tag)

View File

@ -23,7 +23,6 @@ import os
import tempfile import tempfile
import shutil import shutil
from ...constfunc import UNITYPE
from bsddb3 import dbshelve, db from bsddb3 import dbshelve, db
from ..read import DbBsddbTreeCursor from ..read import DbBsddbTreeCursor
@ -91,7 +90,7 @@ class CursorTest(unittest.TestCase):
def find_surname(key,data): def find_surname(key,data):
val = data.surname val = data.surname
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val
@ -115,7 +114,7 @@ class CursorTest(unittest.TestCase):
def find_placeref(key,data): def find_placeref(key,data):
val = data[2] val = data[2]
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val

View File

@ -51,7 +51,7 @@ _ = glocale.translation.gettext
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..constfunc import conv_to_unicode, handle2internal, win, UNITYPE from ..constfunc import conv_to_unicode, handle2internal, win
from .dbconst import * from .dbconst import *
from . import BSDDBTxn from . import BSDDBTxn
from ..errors import DbError from ..errors import DbError

View File

@ -41,7 +41,7 @@ from bsddb3 import db
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..const import GRAMPS_LOCALE as glocale from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from ..constfunc import cuni, UNITYPE, handle2internal from ..constfunc import cuni, handle2internal
from ..lib.markertype import MarkerType from ..lib.markertype import MarkerType
from ..lib.nameorigintype import NameOriginType from ..lib.nameorigintype import NameOriginType
from ..lib.place import Place from ..lib.place import Place
@ -111,7 +111,7 @@ def gramps_upgrade_17(self):
new_event = new_event[:11] + [[]] + new_event[11:] new_event = new_event[:11] + [[]] + new_event[11:]
new_event = tuple(new_event) new_event = tuple(new_event)
with BSDDBTxn(self.env, self.event_map) as txn: with BSDDBTxn(self.env, self.event_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_event) txn.put(handle, new_event)
self.update() self.update()
@ -181,7 +181,7 @@ def gramps_upgrade_17(self):
new_place[6:12] + [[]] + new_place[12:] new_place[6:12] + [[]] + new_place[12:]
new_place = tuple(new_place) new_place = tuple(new_place)
with BSDDBTxn(self.env, self.place_map) as txn: with BSDDBTxn(self.env, self.place_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_place) txn.put(handle, new_place)
self.update() self.update()
@ -196,7 +196,7 @@ def gramps_upgrade_17(self):
new_repository = new_repository[:8] + [[]] + new_repository[8:] new_repository = new_repository[:8] + [[]] + new_repository[8:]
new_repository = tuple(new_repository) new_repository = tuple(new_repository)
with BSDDBTxn(self.env, self.repository_map) as txn: with BSDDBTxn(self.env, self.repository_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_repository) txn.put(handle, new_repository)
self.update() self.update()
@ -211,7 +211,7 @@ def gramps_upgrade_17(self):
new_source = new_source[:11] + [[]] + new_source[11:] new_source = new_source[:11] + [[]] + new_source[11:]
new_source = tuple(new_source) new_source = tuple(new_source)
with BSDDBTxn(self.env, self.source_map) as txn: with BSDDBTxn(self.env, self.source_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_source) txn.put(handle, new_source)
self.update() self.update()
@ -226,7 +226,7 @@ def gramps_upgrade_17(self):
new_citation = new_citation[:10] + [[]] + new_citation[10:] new_citation = new_citation[:10] + [[]] + new_citation[10:]
new_citation = tuple(new_citation) new_citation = tuple(new_citation)
with BSDDBTxn(self.env, self.citation_map) as txn: with BSDDBTxn(self.env, self.citation_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_citation) txn.put(handle, new_citation)
self.update() self.update()
@ -244,7 +244,7 @@ def gramps_upgrade_17(self):
notelist, medialist, abbrev, change, srcattributelist, reporef_list, notelist, medialist, abbrev, change, srcattributelist, reporef_list,
taglist, private) taglist, private)
with BSDDBTxn(self.env, self.source_map) as txn: with BSDDBTxn(self.env, self.source_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_source) txn.put(handle, new_source)
self.update() self.update()
@ -257,7 +257,7 @@ def gramps_upgrade_17(self):
new_citation = (handle, gramps_id, datelist, page, confidence, source_handle, new_citation = (handle, gramps_id, datelist, page, confidence, source_handle,
notelist, medialist, srcattributelist, change, taglist, private) notelist, medialist, srcattributelist, change, taglist, private)
with BSDDBTxn(self.env, self.citation_map) as txn: with BSDDBTxn(self.env, self.citation_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_citation) txn.put(handle, new_citation)
self.update() self.update()
@ -281,7 +281,7 @@ def gramps_upgrade_17(self):
new_media = new_media[:5] + [checksum] + new_media[5:] new_media = new_media[:5] + [checksum] + new_media[5:]
new_media = tuple(new_media) new_media = tuple(new_media)
with BSDDBTxn(self.env, self.media_map) as txn: with BSDDBTxn(self.env, self.media_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_media) txn.put(handle, new_media)
self.update() self.update()
@ -312,7 +312,7 @@ def add_place(self, name, level, parent, title):
placeref.ref = handle2internal(parent) placeref.ref = handle2internal(parent)
place.set_placeref_list([placeref]) place.set_placeref_list([placeref])
with BSDDBTxn(self.env, self.place_map) as txn: with BSDDBTxn(self.env, self.place_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, place.serialize()) txn.put(handle, place.serialize())
return handle return handle
@ -441,7 +441,7 @@ def gramps_upgrade_16(self):
private, person_ref_list) private, person_ref_list)
LOG.debug(" upgrade new_person %s" % [new_person]) LOG.debug(" upgrade new_person %s" % [new_person])
with BSDDBTxn(self.env, self.person_map) as txn: with BSDDBTxn(self.env, self.person_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_person) txn.put(handle, new_person)
self.update() self.update()
@ -475,7 +475,7 @@ def gramps_upgrade_16(self):
change, date, tag_list, private) change, date, tag_list, private)
LOG.debug(" upgrade new_media %s" % [new_media]) LOG.debug(" upgrade new_media %s" % [new_media])
with BSDDBTxn(self.env, self.media_map) as txn: with BSDDBTxn(self.env, self.media_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_media) txn.put(handle, new_media)
self.update() self.update()
@ -514,7 +514,7 @@ def gramps_upgrade_16(self):
change, private) change, private)
LOG.debug(" upgrade new_place %s" % [new_place]) LOG.debug(" upgrade new_place %s" % [new_place])
with BSDDBTxn(self.env, self.place_map) as txn: with BSDDBTxn(self.env, self.place_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_place) txn.put(handle, new_place)
self.update() self.update()
@ -566,7 +566,7 @@ def gramps_upgrade_16(self):
note_list, change, tag_list, private) note_list, change, tag_list, private)
LOG.debug(" upgrade new_family %s" % [new_family]) LOG.debug(" upgrade new_family %s" % [new_family])
with BSDDBTxn(self.env, self.family_map) as txn: with BSDDBTxn(self.env, self.family_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_family) txn.put(handle, new_family)
self.update() self.update()
@ -607,7 +607,7 @@ def gramps_upgrade_16(self):
change, private) change, private)
LOG.debug(" upgrade new_event %s" % [new_event]) LOG.debug(" upgrade new_event %s" % [new_event])
with BSDDBTxn(self.env, self.event_map) as txn: with BSDDBTxn(self.env, self.event_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_event) txn.put(handle, new_event)
self.update() self.update()
@ -638,7 +638,7 @@ def gramps_upgrade_16(self):
address_list, urls, change, private) address_list, urls, change, private)
LOG.debug(" upgrade new_repository %s" % [new_repository]) LOG.debug(" upgrade new_repository %s" % [new_repository])
with BSDDBTxn(self.env, self.repository_map) as txn: with BSDDBTxn(self.env, self.repository_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_repository) txn.put(handle, new_repository)
self.update() self.update()
@ -673,7 +673,7 @@ def gramps_upgrade_16(self):
private) private)
LOG.debug(" upgrade new_source %s" % [new_source]) LOG.debug(" upgrade new_source %s" % [new_source])
with BSDDBTxn(self.env, self.source_map) as txn: with BSDDBTxn(self.env, self.source_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_source) txn.put(handle, new_source)
self.update() self.update()
@ -883,7 +883,7 @@ def convert_source_list_to_citation_list_16(self, source_list):
new_data_map, new_change, private) new_data_map, new_change, private)
citation_list.append((new_handle)) citation_list.append((new_handle))
with BSDDBTxn(self.env, self.citation_map) as txn: 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') new_handle = new_handle.encode('utf-8')
txn.put(new_handle, new_citation) txn.put(new_handle, new_citation)
self.cmap_index += 1 self.cmap_index += 1
@ -966,7 +966,7 @@ def gramps_upgrade_15(self):
) )
with BSDDBTxn(self.env, self.person_map) as txn: with BSDDBTxn(self.env, self.person_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_person) txn.put(handle, new_person)
self.update() self.update()
@ -991,7 +991,7 @@ def gramps_upgrade_15(self):
new_family[13] = [] new_family[13] = []
new_family = tuple(new_family) new_family = tuple(new_family)
with BSDDBTxn(self.env, self.family_map) as txn: with BSDDBTxn(self.env, self.family_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_family) txn.put(handle, new_family)
self.update() self.update()
@ -1010,7 +1010,7 @@ def gramps_upgrade_15(self):
new_note[6] = [] new_note[6] = []
new_note = tuple(new_note) new_note = tuple(new_note)
with BSDDBTxn(self.env, self.note_map) as txn: with BSDDBTxn(self.env, self.note_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_note) txn.put(handle, new_note)
self.update() self.update()
@ -1025,7 +1025,7 @@ def gramps_upgrade_15(self):
new_media[10] = [] new_media[10] = []
new_media = tuple(new_media) new_media = tuple(new_media)
with BSDDBTxn(self.env, self.media_map) as txn: with BSDDBTxn(self.env, self.media_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_media) txn.put(handle, new_media)
self.update() self.update()
@ -1041,7 +1041,7 @@ def gramps_upgrade_15(self):
#new_event[11] = [] #new_event[11] = []
new_event = tuple(new_event) new_event = tuple(new_event)
with BSDDBTxn(self.env, self.event_map) as txn: with BSDDBTxn(self.env, self.event_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_event) txn.put(handle, new_event)
self.update() self.update()
@ -1059,7 +1059,7 @@ def gramps_upgrade_15(self):
new_place = new_place[:12] + new_place[13:] new_place = new_place[:12] + new_place[13:]
new_place = tuple(new_place) new_place = tuple(new_place)
with BSDDBTxn(self.env, self.place_map) as txn: with BSDDBTxn(self.env, self.place_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_place) txn.put(handle, new_place)
self.update() self.update()
@ -1074,7 +1074,7 @@ def gramps_upgrade_15(self):
new_source = new_source[:11] + new_source[12:] new_source = new_source[:11] + new_source[12:]
new_source = tuple(new_source) new_source = tuple(new_source)
with BSDDBTxn(self.env, self.source_map) as txn: with BSDDBTxn(self.env, self.source_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_source) txn.put(handle, new_source)
self.update() self.update()
@ -1090,7 +1090,7 @@ def gramps_upgrade_15(self):
new_repository[5] = list(map(convert_address, new_repository[5])) new_repository[5] = list(map(convert_address, new_repository[5]))
new_repository = tuple(new_repository) new_repository = tuple(new_repository)
with BSDDBTxn(self.env, self.repository_map) as txn: with BSDDBTxn(self.env, self.repository_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_repository) txn.put(handle, new_repository)
self.update() self.update()
@ -1114,7 +1114,7 @@ def convert_marker(self, marker_field):
tag.set_name(tag_name) tag.set_name(tag_name)
tag.set_priority(len(self.tags)) tag.set_priority(len(self.tags))
with BSDDBTxn(self.env, self.tag_map) as txn: with BSDDBTxn(self.env, self.tag_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, tag.serialize()) txn.put(handle, tag.serialize())
self.tags[tag_name] = handle self.tags[tag_name] = handle
@ -1182,7 +1182,7 @@ def gramps_upgrade_14(self):
new_note = (handle, gramps_id, styled_text, format, note_type, new_note = (handle, gramps_id, styled_text, format, note_type,
change, marker, private) change, marker, private)
with BSDDBTxn(self.env, self.note_map) as txn: with BSDDBTxn(self.env, self.note_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_note) txn.put(handle, new_note)
self.update() self.update()
@ -1204,7 +1204,7 @@ def gramps_upgrade_14(self):
description, place, new_source_list, note_list, description, place, new_source_list, note_list,
new_media_list, new_attribute_list, change,marker,private) new_media_list, new_attribute_list, change,marker,private)
with BSDDBTxn(self.env, self.event_map) as txn: with BSDDBTxn(self.env, self.event_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_event) txn.put(handle, new_event)
self.update() self.update()
@ -1288,7 +1288,7 @@ def gramps_upgrade_14(self):
) )
with BSDDBTxn(self.env, self.person_map) as txn: with BSDDBTxn(self.env, self.person_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_person) txn.put(handle, new_person)
self.update() self.update()
@ -1322,7 +1322,7 @@ def gramps_upgrade_14(self):
change, marker, private) change, marker, private)
with BSDDBTxn(self.env, self.family_map) as txn: with BSDDBTxn(self.env, self.family_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_family) txn.put(handle, new_family)
self.update() self.update()
@ -1349,7 +1349,7 @@ def gramps_upgrade_14(self):
new_address_list, urls, change, marker, private) new_address_list, urls, change, marker, private)
with BSDDBTxn(self.env, self.repository_map) as txn: with BSDDBTxn(self.env, self.repository_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_repository) txn.put(handle, new_repository)
self.update() self.update()
@ -1369,7 +1369,7 @@ def gramps_upgrade_14(self):
new_date, marker, private) new_date, marker, private)
with BSDDBTxn(self.env, self.media_map) as txn: with BSDDBTxn(self.env, self.media_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_media) txn.put(handle, new_media)
self.update() self.update()
@ -1389,7 +1389,7 @@ def gramps_upgrade_14(self):
new_source_list, note_list, change, marker, private) new_source_list, note_list, change, marker, private)
with BSDDBTxn(self.env, self.place_map) as txn: with BSDDBTxn(self.env, self.place_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_place) txn.put(handle, new_place)
self.update() self.update()
@ -1410,7 +1410,7 @@ def gramps_upgrade_14(self):
marker, private) marker, private)
with BSDDBTxn(self.env, self.source_map) as txn: with BSDDBTxn(self.env, self.source_map) as txn:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
txn.put(handle, new_source) txn.put(handle, new_source)
self.update() self.update()

View File

@ -80,7 +80,7 @@ from ..utils.cast import conv_dbstr_to_unicode
from ..utils.id import create_id from ..utils.id import create_id
from ..updatecallback import UpdateCallback from ..updatecallback import UpdateCallback
from ..errors import DbError 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) get_env_var)
from ..const import HOME_DIR, GRAMPS_LOCALE as glocale from ..const import HOME_DIR, GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
@ -177,7 +177,7 @@ def find_idmap(key, data):
returns a byte string returns a byte string
""" """
val = data[1] val = data[1]
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val
@ -186,7 +186,7 @@ def find_parent(key, data):
val = data[5][0][0] val = data[5][0][0]
else: else:
val = '' val = ''
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val
@ -200,7 +200,7 @@ def find_primary_handle(key, data):
returns byte string returns byte string
""" """
val = (data)[0][1] val = (data)[0][1]
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val
@ -209,7 +209,7 @@ def find_referenced_handle(key, data):
returns byte string returns byte string
""" """
val = (data)[1][1] val = (data)[1][1]
if isinstance(val, UNITYPE): if isinstance(val, str):
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val
@ -494,7 +494,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
def set_default_person_handle(self, handle): def set_default_person_handle(self, handle):
"""Set the default Person to the passed instance.""" """Set the default Person to the passed instance."""
#we store a byte string! #we store a byte string!
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
if not self.readonly: if not self.readonly:
# Start transaction # Start transaction
@ -1111,7 +1111,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
""" """
Find all child places having the given place as the primary parent. 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') handle = handle.encode('utf-8')
parent_cur = self.get_place_parent_cursor() parent_cur = self.get_place_parent_cursor()
@ -1155,7 +1155,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
result_list = list(find_backlink_handles(handle)) result_list = list(find_backlink_handles(handle))
""" """
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
# Use the secondary index to locate all the reference_map entries # Use the secondary index to locate all the reference_map entries
# that include a reference to the object we are looking for. # that include a reference to the object we are looking for.
@ -1242,7 +1242,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
existing_references = set() existing_references = set()
primary_cur = self.get_reference_map_primary_cursor() primary_cur = self.get_reference_map_primary_cursor()
try: try:
if isinstance(handle, UNITYPE): if isinstance(handle, str):
key = handle.encode('utf-8') key = handle.encode('utf-8')
else: else:
key = handle key = handle
@ -1302,7 +1302,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
'which is partly bytecode, this is not allowed.\n' 'which is partly bytecode, this is not allowed.\n'
'Key is %s') % str(key)) 'Key is %s') % str(key))
key = str(key) key = str(key)
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
if not self.readonly: if not self.readonly:
if not transaction.batch: if not transaction.batch:
@ -1319,7 +1319,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if isinstance(key, tuple): if isinstance(key, tuple):
#create a string key #create a string key
key = str(key) key = str(key)
if isinstance(key, UNITYPE): if isinstance(key, str):
key = key.encode('utf-8') key = key.encode('utf-8')
if self.readonly or not key: if self.readonly or not key:
return return
@ -1686,7 +1686,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if self.readonly or not handle: if self.readonly or not handle:
return return
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
if transaction.batch: if transaction.batch:
with BSDDBTxn(self.env, data_map) as txn: with BSDDBTxn(self.env, data_map) as txn:
@ -1711,7 +1711,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
person = self.get_person_from_handle(handle) person = self.get_person_from_handle(handle)
self.genderStats.uncount_person (person) self.genderStats.uncount_person (person)
self.remove_from_surname_list(person) self.remove_from_surname_list(person)
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
if transaction.batch: if transaction.batch:
with BSDDBTxn(self.env, self.person_map) as txn: 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()) obj.change = int(change_time or time.time())
handle = obj.handle handle = obj.handle
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
self.update_reference_map(obj, transaction, self.txn) self.update_reference_map(obj, transaction, self.txn)
@ -2131,7 +2131,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
transaction, change_time) transaction, change_time)
def get_from_handle(self, handle, class_type, data_map): def get_from_handle(self, handle, class_type, data_map):
if isinstance(handle, UNITYPE): if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
try: try:
data = data_map.get(handle, txn=self.txn) data = data_map.get(handle, txn=self.txn)

View File

@ -68,7 +68,7 @@ LOG = logging.getLogger(".gramps.gen")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..const import ARABIC_COMMA, ARABIC_SEMICOLON, GRAMPS_LOCALE as glocale from ..const import ARABIC_COMMA, ARABIC_SEMICOLON, GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = 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.name import Name
from ..lib.nameorigintype import NameOriginType from ..lib.nameorigintype import NameOriginType
@ -1022,7 +1022,7 @@ class NameDisplay(object):
# if in double quotes, just use % codes # if in double quotes, just use % codes
for (code, keyword) in d_keys: for (code, keyword) in d_keys:
exp, keyword, ikeyword = d[code] exp, keyword, ikeyword = d[code]
if not isinstance(keyword, UNITYPE): if not isinstance(keyword, str):
keyword = conv_to_unicode(keyword, "utf-8") keyword = conv_to_unicode(keyword, "utf-8")
format_str = format_str.replace(keyword, "%"+ code) format_str = format_str.replace(keyword, "%"+ code)
format_str = format_str.replace(keyword.title(), "%"+ code) format_str = format_str.replace(keyword.title(), "%"+ code)

View File

@ -18,8 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
from gramps.gen.constfunc import UNITYPE
class HandleClass(str): class HandleClass(str):
def __init__(self, handle): def __init__(self, handle):
super(HandleClass, self).__init__() super(HandleClass, self).__init__()

View File

@ -41,7 +41,7 @@ LOG = logging.getLogger(".")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..const import GRAMPS_LOCALE as glocale from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from ..constfunc import conv_to_unicode, UNITYPE from ..constfunc import conv_to_unicode
#strings in database are utf-8 #strings in database are utf-8
conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8') conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8')

View File

@ -42,7 +42,7 @@ LOG = logging.getLogger(".gen.utils.file")
# Gramps modules # 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 from ..const import TEMP_DIR, USER_HOME, GRAMPS_LOCALE as glocale
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -45,7 +45,7 @@ from urllib.parse import urlparse
import logging import logging
LOG = logging.getLogger(".DbManager") 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(): if win():
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0 _RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
if _RCS_FOUND and "TZ" not in os.environ: if _RCS_FOUND and "TZ" not in os.environ:
@ -848,7 +848,7 @@ def find_revisions(name):
get_next = False get_next = False
if os.path.isfile(name): if os.path.isfile(name):
for line in proc.stdout: for line in proc.stdout:
if not isinstance(line, UNITYPE): if not isinstance(line, str):
# we assume utf-8 ... # we assume utf-8 ...
line = line.decode('utf-8') line = line.decode('utf-8')
match = rev.match(line) match = rev.match(line)

View File

@ -63,7 +63,7 @@ from .managedwindow import GrampsWindowManager
from gramps.gen.relationship import get_relationship_calculator from gramps.gen.relationship import get_relationship_calculator
from .glade import Glade from .glade import Glade
from gramps.gen.utils.db import navigation_label 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 from .widgets.progressdialog import ProgressMonitor, GtkProgressDialog
DISABLED = -1 DISABLED = -1
@ -80,7 +80,7 @@ class History(Callback):
""" """
__signals__ = { __signals__ = {
'active-changed' : (UNITYPE, ), 'active-changed' : (str, ),
'mru-changed' : (list, ) 'mru-changed' : (list, )
} }
@ -136,7 +136,7 @@ class History(Callback):
self.emit('mru-changed', (self.mru, )) self.emit('mru-changed', (self.mru, ))
if self.history: if self.history:
newact = self.history[self.index] newact = self.history[self.index]
if not isinstance(newact, UNITYPE): if not isinstance(newact, str):
newact = cuni(newact) newact = cuni(newact)
self.emit('active-changed', (newact,)) self.emit('active-changed', (newact,))
@ -154,7 +154,7 @@ class History(Callback):
self.index += 1 self.index += 1
if self.history: if self.history:
newact = self.history[self.index] newact = self.history[self.index]
if not isinstance(newact, UNITYPE): if not isinstance(newact, str):
newact = cuni(newact) newact = cuni(newact)
self.emit('active-changed', (newact,)) self.emit('active-changed', (newact,))
@ -169,7 +169,7 @@ class History(Callback):
self.mru.append(handle) self.mru.append(handle)
self.emit('mru-changed', (self.mru, )) self.emit('mru-changed', (self.mru, ))
newact = self.history[self.index] newact = self.history[self.index]
if not isinstance(newact, UNITYPE): if not isinstance(newact, str):
newact = cuni(newact) newact = cuni(newact)
self.emit('active-changed', (newact,)) self.emit('active-changed', (newact,))
return newact return newact
@ -186,7 +186,7 @@ class History(Callback):
self.mru.append(handle) self.mru.append(handle)
self.emit('mru-changed', (self.mru, )) self.emit('mru-changed', (self.mru, ))
newact = self.history[self.index] newact = self.history[self.index]
if not isinstance(newact, UNITYPE): if not isinstance(newact, str):
newact = cuni(newact) newact = cuni(newact)
self.emit('active-changed', (newact,)) self.emit('active-changed', (newact,))
return newact return newact
@ -369,7 +369,7 @@ class DisplayState(Callback):
__signals__ = { __signals__ = {
'filters-changed' : (str, ), 'filters-changed' : (str, ),
'filter-name-changed' : (str, UNITYPE, UNITYPE), 'filter-name-changed' : (str, str, str),
'nameformat-changed' : None, 'nameformat-changed' : None,
'grampletbar-close-changed' : None, 'grampletbar-close-changed' : None,
'update-available' : (list, ), 'update-available' : (list, ),

View File

@ -29,7 +29,6 @@ from gi.repository import Pango
from ... import widgets from ... import widgets
from ...dbguielement import DbGUIElement from ...dbguielement import DbGUIElement
from gramps.gen.config import config from gramps.gen.config import config
from gramps.gen.constfunc import UNITYPE
_RETURN = Gdk.keyval_from_name("Return") _RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter") _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): for handle in self.dbstate.db.get_tag_handles(sort_handles=True):
tag = self.dbstate.db.get_tag_from_handle(handle) tag = self.dbstate.db.get_tag_from_handle(handle)
# for python3 this returns a byte object, so conversion needed # 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') handle = handle.decode('utf-8')
self.__tag_list.append((tag.get_name(), handle)) self.__tag_list.append((tag.get_name(), handle))
self.on_tags_changed([item[0] for item in self.__tag_list]) self.on_tags_changed([item[0] for item in self.__tag_list])

View File

@ -56,7 +56,7 @@ from gramps.gen.config import config
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from ..filters import SearchBar from ..filters import SearchBar
from ..widgets.menuitem import add_menuitem 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.const import CUSTOM_FILTERS
from gramps.gen.utils.debug import profile from gramps.gen.utils.debug import profile
from gramps.gen.utils.string import data_recover_msg from gramps.gen.utils.string import data_recover_msg

View File

@ -71,7 +71,7 @@ from gi.repository import Gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.filters import SearchFilter, ExactSearchFilter 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 from gramps.gen.const import GRAMPS_LOCALE as glocale
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -311,7 +311,7 @@ class FlatNodeMap(object):
:return handle: unicode form of the handle :return handle: unicode form of the handle
""" """
handle = self._index2hndl[self.real_index(path)][1] handle = self._index2hndl[self.real_index(path)][1]
if not isinstance(handle, UNITYPE): if not isinstance(handle, str):
handle = handle.decode('utf-8') handle = handle.decode('utf-8')
return handle return handle

View File

@ -43,7 +43,7 @@ from gi.repository import Gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.datehandler import displayer, format_time from gramps.gen.datehandler import displayer, format_time
from gramps.gen.lib import Date, MediaObject 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 gramps.gen.const import GRAMPS_LOCALE as glocale
from .flatbasemodel import FlatBaseModel from .flatbasemodel import FlatBaseModel
@ -107,7 +107,7 @@ class MediaModel(FlatBaseModel):
def column_description(self, data): def column_description(self, data):
descr = data[4] descr = data[4]
if isinstance(descr, UNITYPE): if isinstance(descr, str):
return descr return descr
try: try:
return cuni(descr) return cuni(descr)
@ -116,7 +116,7 @@ class MediaModel(FlatBaseModel):
def column_path(self, data): def column_path(self, data):
path = data[2] path = data[2]
if isinstance(path, UNITYPE): if isinstance(path, str):
return path return path
try: try:
return cuni(path) return cuni(path)
@ -125,7 +125,7 @@ class MediaModel(FlatBaseModel):
def column_mime(self, data): def column_mime(self, data):
mime = data[3] mime = data[3]
if mime and isinstance(mime, UNITYPE): if mime and isinstance(mime, str):
return mime return mime
if mime: if mime:
return cuni(mime) return cuni(mime)

View File

@ -63,7 +63,7 @@ from .lru import LRU
from .flatbasemodel import FlatBaseModel from .flatbasemodel import FlatBaseModel
from .treebasemodel import TreeBaseModel from .treebasemodel import TreeBaseModel
from gramps.gen.config import config 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 from gramps.gen.const import GRAMPS_LOCALE as glocale
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -202,7 +202,7 @@ class PeopleBaseModel(object):
def sort_name(self, data): def sort_name(self, data):
name = name_displayer.raw_sorted_name(data[COLUMN_NAME]) name = name_displayer.raw_sorted_name(data[COLUMN_NAME])
# internally we work with utf-8 # internally we work with utf-8
if not isinstance(name, UNITYPE): if not isinstance(name, str):
name = name.decode('utf-8') name = name.decode('utf-8')
return name return name
@ -592,7 +592,7 @@ class PersonTreeModel(PeopleBaseModel, TreeBaseModel):
name_data = data[COLUMN_NAME] name_data = data[COLUMN_NAME]
group_name = ngn(self.db, name_data) group_name = ngn(self.db, name_data)
#if isinstance(group_name, UNITYPE): #if isinstance(group_name, str):
# group_name = group_name.encode('utf-8') # group_name = group_name.encode('utf-8')
sort_key = self.sort_func(data) sort_key = self.sort_func(data)

View File

@ -53,7 +53,7 @@ from gi.repository import Gtk
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
import gramps.gui.widgets.progressdialog as progressdlg 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 .lru import LRU
from bisect import bisect_right from bisect import bisect_right
from gramps.gen.filters import SearchFilter, ExactSearchFilter from gramps.gen.filters import SearchFilter, ExactSearchFilter
@ -554,7 +554,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
with gen_cursor() as cursor: with gen_cursor() as cursor:
for handle, data in cursor: for handle, data in cursor:
# for python3 this returns a byte object, so conversion needed # 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') handle = handle.decode('utf-8')
status.heartbeat() status.heartbeat()
if status.should_cancel(): if status.should_cancel():
@ -610,7 +610,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
def beat(key): def beat(key):
status_ppl.heartbeat() status_ppl.heartbeat()
# for python3 this returns a byte object, so conversion needed # 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') key = key.decode('utf-8')
return key return key
@ -897,7 +897,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
""" """
node = self.get_node_from_iter(iter) node = self.get_node_from_iter(iter)
handle = node.handle handle = node.handle
if handle and not isinstance(handle, UNITYPE): if handle and not isinstance(handle, str):
handle = handle.decode('utf-8') handle = handle.decode('utf-8')
return handle return handle

View File

@ -48,7 +48,7 @@ from gi.repository import Gtk
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.constfunc import conv_to_unicode, UNITYPE from gramps.gen.constfunc import conv_to_unicode
from .undoablebuffer import Stack from .undoablebuffer import Stack
class UndoableInsertEntry(object): class UndoableInsertEntry(object):
@ -57,7 +57,7 @@ class UndoableInsertEntry(object):
self.offset = position self.offset = position
self.text = str(text) self.text = str(text)
#unicode char can have length > 1 as it points in the buffer #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') text = conv_to_unicode(text, 'utf-8')
charlength = len(text) charlength = len(text)
self.length = charlength self.length = charlength

View File

@ -52,7 +52,7 @@ from gi.repository import Pango
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.errors import MaskError, ValidationError, WindowActiveError 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 from .undoableentry import UndoableEntry
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -402,7 +402,7 @@ class MaskedEntry(UndoableEntry):
for validator in self._mask_validators[start:end]: for validator in self._mask_validators[start:end]:
if isinstance(validator, int): if isinstance(validator, int):
s += ' ' s += ' '
elif isinstance(validator, UNITYPE): elif isinstance(validator, str):
s += validator s += validator
else: else:
raise AssertionError raise AssertionError
@ -593,7 +593,7 @@ class MaskedEntry(UndoableEntry):
if isinstance(validator, int): if isinstance(validator, int):
if not INPUT_CHAR_MAP[validator](text): if not INPUT_CHAR_MAP[validator](text):
return False return False
if isinstance(validator, UNITYPE): if isinstance(validator, str):
if validator == text: if validator == text:
return True return True
return False return False

View File

@ -63,7 +63,7 @@ from gramps.gen.const import ROOT_DIR
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = 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() changed = QtCore.Signal()
#make Model.Column.property available in QML #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): class DetViewSumModel(QtCore.QAbstractListModel):
""" """

View File

@ -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.cli.clidbman import CLIDbManager, NAME_FILE, time_val
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = 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.__dbman.rename_database(self.__path_namefile, name)
self.changed_name.emit() self.changed_name.emit()
name = QtCore.Property(UNITYPE, _name, _set_name, notify=changed_name) name = QtCore.Property(str, _name, _set_name, notify=changed_name)
path = QtCore.Property(UNITYPE, _path, notify=changed) path = QtCore.Property(str, _path, notify=changed)
last_access = QtCore.Property(UNITYPE, _last_access, notify=changed) last_access = QtCore.Property(str, _last_access, notify=changed)
use_icon = QtCore.Property(bool, _use_icon, 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): class FamTreeListModel(QtCore.QAbstractListModel):
""" """

View File

@ -53,7 +53,7 @@ from PySide import QtOpenGL
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import ROOT_DIR 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.gui.views.treemodels import conv_unicode_tosrtkey
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
@ -88,7 +88,7 @@ class QMLPerson(QtCore.QObject):
dummychanged = QtCore.Signal() dummychanged = QtCore.Signal()
#make Model.Column.property available in QML #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): class QMLPersonListModel(QtCore.QAbstractListModel):
""" """

View File

@ -44,7 +44,7 @@ import re
# Gramps modules # 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, from gramps.gen.plug.docgen import (BaseDoc, TextDoc, DrawDoc, ParagraphStyle,
TableCellStyle, SOLID, FONT_SANS_SERIF, FONT_SERIF, TableCellStyle, SOLID, FONT_SANS_SERIF, FONT_SERIF,
FONT_MONOSPACE, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT) FONT_MONOSPACE, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT)
@ -500,7 +500,7 @@ class GtkDocParagraph(GtkDocBaseElement):
""" """
Internal method to allow for splitting of paragraphs 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') self._plaintext = conv_to_unicode(plaintext, 'utf-8')
else: else:
self._plaintext = plaintext self._plaintext = plaintext

View File

@ -132,7 +132,7 @@ from gramps.gen.db.dbconst import EVENT_KEY
from gramps.gui.dialog import WarningDialog from gramps.gui.dialog import WarningDialog
from gramps.gen.lib.const import IDENTICAL, DIFFERENT from gramps.gen.lib.const import IDENTICAL, DIFFERENT
from gramps.gen.lib import (StyledText, StyledTextTag, StyledTextTagType) 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.plugins.lib.libplaceimport import PlaceImport
from gramps.gen.display.place import displayer as place_displayer 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 # 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. # find that I0001 is in use, so we have to create a new id.
bformatted_gid = formatted_gid bformatted_gid = formatted_gid
if isinstance(bformatted_gid, UNITYPE): if isinstance(bformatted_gid, str):
bformatted_gid = bformatted_gid.encode('utf-8') bformatted_gid = bformatted_gid.encode('utf-8')
if self.trans.get(bformatted_gid) or \ if self.trans.get(bformatted_gid) or \
(formatted_gid in list(self.swap.values())): (formatted_gid in list(self.swap.values())):

View File

@ -71,7 +71,7 @@ from gramps.gui.plug import tool
from gramps.gui.dialog import OkDialog, MissingMediaDialog from gramps.gui.dialog import OkDialog, MissingMediaDialog
from gramps.gen.display.name import displayer as _nd from gramps.gen.display.name import displayer as _nd
from gramps.gui.glade import Glade 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. # table for handling control chars in notes.
# All except 09, 0A, 0D are replaced with space. # All except 09, 0A, 0D are replaced with space.
@ -344,16 +344,16 @@ class CheckIntegrity(object):
for bhandle in self.db.media_map.keys(): for bhandle in self.db.media_map.keys():
handle = handle2internal(bhandle) handle = handle2internal(bhandle)
data = self.db.media_map[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 = self.db.get_object_from_handle(handle)
obj.path = conv_to_unicode(obj.path, None) obj.path = conv_to_unicode(obj.path, None)
obj.desc = conv_to_unicode(obj.desc, None) obj.desc = conv_to_unicode(obj.desc, None)
self.db.commit_media_object(obj, self.trans) 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 ' logging.warning(' FAIL: encoding error on media object '
'"%(gid)s" path "%(path)s"' % '"%(gid)s" path "%(path)s"' %
{'gid' : obj.gramps_id, 'path' : obj.path}) {'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 ' logging.warning(' FAIL: encoding error on media object '
'"%(gid)s" description "%(desc)s"' % '"%(gid)s" description "%(desc)s"' %
{'gid' : obj.gramps_id, 'desc' : obj.desc}) {'gid' : obj.gramps_id, 'desc' : obj.desc})

View File

@ -55,7 +55,6 @@ from gi.repository import GObject
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.const import URL_MANUAL_PAGE, VERSION_DIR from gramps.gen.const import URL_MANUAL_PAGE, VERSION_DIR
from gramps.gen.constfunc import UNITYPE
from gramps.gen.lib import (ChildRefType, EventRoleType, EventType, from gramps.gen.lib import (ChildRefType, EventRoleType, EventType,
FamilyRelType, NameType, Person) FamilyRelType, NameType, Person)
from gramps.gen.lib.date import Today from gramps.gen.lib.date import Today
@ -544,7 +543,7 @@ class VerifyResults(ManagedWindow):
pass pass
def load_ignored(self, db_filename): def load_ignored(self, db_filename):
if isinstance(db_filename, UNITYPE): if isinstance(db_filename, str):
db_filename = db_filename.encode('utf-8') db_filename = db_filename.encode('utf-8')
md5sum = md5(db_filename) md5sum = md5(db_filename)
## a new Gramps major version means recreating the .vfm file. ## a new Gramps major version means recreating the .vfm file.

View 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.file import media_path_full
from gramps.gen.utils.alive import probably_alive from gramps.gen.utils.alive import probably_alive
from gramps.gen.utils.db import get_source_and_citation_referents 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.gen.config import config
from gramps.gui.thumbnails import get_thumbnail_path, run_thumbnailer from gramps.gui.thumbnails import get_thumbnail_path, run_thumbnailer
from gramps.gen.utils.image import image_size, resize_to_jpeg_buffer from gramps.gen.utils.image import image_size, resize_to_jpeg_buffer
@ -7192,7 +7192,7 @@ class NavWebReport(Report):
for handle in ind_list: for handle in ind_list:
# FIXME work around bug that self.database.iter under python 3 # FIXME work around bug that self.database.iter under python 3
# returns (binary) data rather than text # returns (binary) data rather than text
if not isinstance(handle, UNITYPE): if not isinstance(handle, str):
handle = handle.decode('utf-8') handle = handle.decode('utf-8')
step() step()
self._add_person(handle, "", "") self._add_person(handle, "", "")