Convert handle type to str in the database API (#405)

The mixed type of handles has been a constant source of bugs.
Converting them all to str in the database API should make
maintenance easier. The key to BSDDB tables must still be bytes
in the database layer.
This commit is contained in:
Nick Hall 2017-05-30 00:19:42 +01:00 committed by GitHub
parent 83d24ed681
commit 352d6fc558
28 changed files with 503 additions and 725 deletions

View File

@ -1385,7 +1385,7 @@ class DbReadBase:
def set_mediapath(self, path): def set_mediapath(self, path):
""" """
Set the default media path for database, path should be utf-8. Set the default media path for database.
""" """
raise NotImplementedError raise NotImplementedError

View File

@ -526,7 +526,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_family_handles(self, sort_handles=False): def get_family_handles(self, sort_handles=False):
""" """
@ -670,7 +670,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_note_handles(self): def get_note_handles(self):
""" """
@ -782,7 +782,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_person_attribute_types(self): def get_person_attribute_types(self):
""" """
@ -829,7 +829,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_person_handles(self, sort_handles=False): def get_person_handles(self, sort_handles=False):
""" """
@ -887,7 +887,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_place_handles(self, sort_handles=False): def get_place_handles(self, sort_handles=False):
""" """
@ -907,7 +907,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_family_data(self, handle): def get_raw_family_data(self, handle):
""" """
@ -916,7 +916,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_note_data(self, handle): def get_raw_note_data(self, handle):
""" """
@ -925,7 +925,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_media_data(self, handle): def get_raw_media_data(self, handle):
""" """
@ -934,7 +934,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_person_data(self, handle): def get_raw_person_data(self, handle):
""" """
@ -943,7 +943,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_place_data(self, handle): def get_raw_place_data(self, handle):
""" """
@ -952,7 +952,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_repository_data(self, handle): def get_raw_repository_data(self, handle):
""" """
@ -961,7 +961,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_source_data(self, handle): def get_raw_source_data(self, handle):
""" """
@ -970,7 +970,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_citation_data(self, handle): def get_raw_citation_data(self, handle):
""" """
@ -979,7 +979,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_raw_tag_data(self, handle): def get_raw_tag_data(self, handle):
""" """
@ -988,7 +988,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_repo_bookmarks(self): def get_repo_bookmarks(self):
""" """
@ -1026,7 +1026,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_repository_handles(self): def get_repository_handles(self):
""" """
@ -1097,7 +1097,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_source_handles(self, sort_handles=False): def get_source_handles(self, sort_handles=False):
""" """
@ -1155,7 +1155,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_citation_handles(self, sort_handles=False): def get_citation_handles(self, sort_handles=False):
""" """
@ -1193,7 +1193,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle) LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError('Handle %s not found' % handle.encode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_tag_from_name(self, val): def get_tag_from_name(self, val):
""" """
@ -1611,7 +1611,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
def set_mediapath(self, path): def set_mediapath(self, path):
""" """
Set the default media path for database, path should be utf-8. Set the default media path for database.
""" """
if not self.db_is_open: if not self.db_is_open:
LOG.warning("database is closed") LOG.warning("database is closed")

View File

@ -1285,8 +1285,6 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
################################################################ ################################################################
def _get_from_handle(self, obj_key, obj_class, handle): def _get_from_handle(self, obj_key, obj_class, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle is None: if handle is None:
raise HandleError('Handle is None') raise HandleError('Handle is None')
if not handle: if not handle:

View File

@ -81,7 +81,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['E0001']) rule = HasIdOf(['E0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0eb696917232725'])) set(['a5af0eb696917232725']))
def test_hasgallery(self): def test_hasgallery(self):
""" """
@ -89,7 +89,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasGallery(['0', 'greater than']) rule = HasGallery(['0', 'greater than'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb107303354a0'])) set(['a5af0ecb107303354a0']))
def test_regexpidof(self): def test_regexpidof(self):
""" """
@ -97,11 +97,11 @@ class BaseTest(unittest.TestCase):
""" """
rule = RegExpIdOf(['E000.'], use_regex=True) rule = RegExpIdOf(['E000.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'a5af0eb69cf2d3fb615', b'a5af0eb667015e355db', 'a5af0eb69cf2d3fb615', 'a5af0eb667015e355db',
b'a5af0eb6a016da2d6d1', b'a5af0eb6a405acb126c', 'a5af0eb6a016da2d6d1', 'a5af0eb6a405acb126c',
b'a5af0eb698f29568502', b'a5af0eb69b82a6cdc5a', 'a5af0eb698f29568502', 'a5af0eb69b82a6cdc5a',
b'a5af0eb69f41bfb5a6a', b'a5af0eb69c40c179441', 'a5af0eb69f41bfb5a6a', 'a5af0eb69c40c179441',
b'a5af0eb6a3229544ba2', b'a5af0eb696917232725'])) 'a5af0eb6a3229544ba2', 'a5af0eb696917232725']))
def test_hascitation(self): def test_hascitation(self):
""" """
@ -109,7 +109,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasCitation(['page 1', '', '']) rule = HasCitation(['page 1', '', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb107303354a0'])) set(['a5af0ecb107303354a0']))
def test_hasnote(self): def test_hasnote(self):
""" """
@ -117,7 +117,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNote([]) rule = HasNote([])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb11f5ac3110e'])) set(['a5af0ecb11f5ac3110e']))
def test_hasnoteregexp(self): def test_hasnoteregexp(self):
""" """
@ -125,7 +125,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNoteRegexp(['.'], use_regex=True) rule = HasNoteRegexp(['.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb11f5ac3110e'])) set(['a5af0ecb11f5ac3110e']))
def test_hasreferencecountof(self): def test_hasreferencecountof(self):
""" """
@ -133,8 +133,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasReferenceCountOf(['greater than', '1']) rule = HasReferenceCountOf(['greater than', '1'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'cc8205d86fc4e9706a5', b'a5af0ed60de7a612b9e', 'cc8205d86fc4e9706a5', 'a5af0ed60de7a612b9e',
b'cc820604ef05cb67907'])) 'cc820604ef05cb67907']))
def test_hassourcecount(self): def test_hassourcecount(self):
""" """
@ -142,7 +142,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceCount(['1', 'greater than']) rule = HasSourceCount(['1', 'greater than'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb107303354a0'])) set(['a5af0ecb107303354a0']))
def test_eventprivate(self): def test_eventprivate(self):
""" """
@ -157,7 +157,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = MatchesSourceConfidence(['2']) rule = MatchesSourceConfidence(['2'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb107303354a0'])) set(['a5af0ecb107303354a0']))
def test_hasattribute(self): def test_hasattribute(self):
""" """
@ -165,7 +165,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasAttribute(['Cause', '']) rule = HasAttribute(['Cause', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a5af0ecb11f5ac3110e'])) set(['a5af0ecb11f5ac3110e']))
def test_hasdata(self): def test_hasdata(self):
""" """
@ -173,8 +173,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasData(['Burial', 'before 1800', 'USA', '']) rule = HasData(['Burial', 'before 1800', 'USA', ''])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'a5af0ed4211095487d2', b'a5af0ed36793c1d3e05', 'a5af0ed4211095487d2', 'a5af0ed36793c1d3e05',
b'a5af0ecfcc16ce7a96a'])) 'a5af0ecfcc16ce7a96a']))
def test_changedsince(self): def test_changedsince(self):
""" """
@ -182,8 +182,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = ChangedSince(['2011-01-01', '2014-01-01']) rule = ChangedSince(['2011-01-01', '2014-01-01'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'a5af0ecb107303354a0', b'a5af0ecb11f5ac3110e', 'a5af0ecb107303354a0', 'a5af0ecb11f5ac3110e',
b'a5af0ed5df832ee65c1'])) 'a5af0ed5df832ee65c1']))
def test_hastag(self): def test_hastag(self):
""" """

View File

@ -83,7 +83,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasGallery(['0', 'greater than']) rule = HasGallery(['0', 'greater than'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hasidof(self): def test_hasidof(self):
""" """
@ -91,7 +91,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['F0001']) rule = HasIdOf(['F0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'48TJQCGNNIR5SJRCAK'])) set(['48TJQCGNNIR5SJRCAK']))
def test_haslds(self): def test_haslds(self):
""" """
@ -99,7 +99,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasLDS(['0', 'greater than']) rule = HasLDS(['0', 'greater than'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hasnote(self): def test_hasnote(self):
""" """
@ -107,7 +107,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNote([]) rule = HasNote([])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_regexpidof(self): def test_regexpidof(self):
""" """
@ -115,11 +115,11 @@ class BaseTest(unittest.TestCase):
""" """
rule = RegExpIdOf(['F000.'], use_regex=True) rule = RegExpIdOf(['F000.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'LOTJQC78O5B4WQGJRP', b'UPTJQC4VPCABZUDB75', 'LOTJQC78O5B4WQGJRP', 'UPTJQC4VPCABZUDB75',
b'NBTJQCIX49EKOCIHBP', b'C9UJQCF6ETBTV2MRRV', 'NBTJQCIX49EKOCIHBP', 'C9UJQCF6ETBTV2MRRV',
b'74UJQCKV8R4NBNHCB', b'4BTJQCL4CHNA5OUTKF', '74UJQCKV8R4NBNHCB', '4BTJQCL4CHNA5OUTKF',
b'48TJQCGNNIR5SJRCAK', b'4YTJQCTEH7PQUU4AD', '48TJQCGNNIR5SJRCAK', '4YTJQCTEH7PQUU4AD',
b'MTTJQC05LKVFFLN01A', b'd5839c123c034ef82ab', 'MTTJQC05LKVFFLN01A', 'd5839c123c034ef82ab',
])) ]))
def test_hasnoteregexp(self): def test_hasnoteregexp(self):
@ -128,7 +128,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNoteRegexp(['.'], use_regex=True) rule = HasNoteRegexp(['.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hasreferencecountof(self): def test_hasreferencecountof(self):
""" """
@ -136,10 +136,10 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasReferenceCountOf(['greater than', '12']) rule = HasReferenceCountOf(['greater than', '12'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'29IKQCMUNFTIBV653N', b'8OUJQCUVZ0XML7BQLF', b'UPTJQC4VPCABZUDB75', '29IKQCMUNFTIBV653N', '8OUJQCUVZ0XML7BQLF', 'UPTJQC4VPCABZUDB75',
b'9NWJQCJGLXUR3AQSFJ', b'5G2KQCGBTS86UVSRG5', b'WG2KQCSY9LEFDFQHMN', '9NWJQCJGLXUR3AQSFJ', '5G2KQCGBTS86UVSRG5', 'WG2KQCSY9LEFDFQHMN',
b'MTTJQC05LKVFFLN01A', b'C2VJQC71TNHO7RBBMX', b'QIDKQCJQ37SIUQ3UFU', 'MTTJQC05LKVFFLN01A', 'C2VJQC71TNHO7RBBMX', 'QIDKQCJQ37SIUQ3UFU',
b'DV4KQCX9OBVQ74H77F'])) 'DV4KQCX9OBVQ74H77F']))
def test_hassourcecount(self): def test_hassourcecount(self):
""" """
@ -147,7 +147,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceCount(['1', 'greater than']) rule = HasSourceCount(['1', 'greater than'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hassourceof(self): def test_hassourceof(self):
""" """
@ -155,7 +155,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceOf(['S0001']) rule = HasSourceOf(['S0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hascitation(self): def test_hascitation(self):
""" """
@ -163,7 +163,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasCitation(['page 10', '', '2']) rule = HasCitation(['page 10', '', '2'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_familyprivate(self): def test_familyprivate(self):
""" """
@ -178,8 +178,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasEvent(['Marriage', 'before 1900', 'USA', '', 'Garner']) rule = HasEvent(['Marriage', 'before 1900', 'USA', '', 'Garner'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'KSFKQCP4V0YXGM1LR9', b'8ZFKQC3FRSHACOJBOU', b'3XFKQCE7QUDJ99AVNV', 'KSFKQCP4V0YXGM1LR9', '8ZFKQC3FRSHACOJBOU', '3XFKQCE7QUDJ99AVNV',
b'OVFKQC51DX0OQUV3JB', b'9OUJQCBOHW9UEK9CNV'])) 'OVFKQC51DX0OQUV3JB', '9OUJQCBOHW9UEK9CNV']))
def test_hasattribute(self): def test_hasattribute(self):
""" """
@ -187,7 +187,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasAttribute(['Number of Children', '']) rule = HasAttribute(['Number of Children', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_isbookmarked(self): def test_isbookmarked(self):
""" """
@ -195,7 +195,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsBookmarked([]) rule = IsBookmarked([])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_matchessourceconfidence(self): def test_matchessourceconfidence(self):
""" """
@ -211,7 +211,7 @@ class BaseTest(unittest.TestCase):
rule = FatherHasNameOf(['', '', 'Dr.', '', '', '', '', '', '', '', rule = FatherHasNameOf(['', '', 'Dr.', '', '', '', '', '', '', '',
'']) ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_fatherhasidof(self): def test_fatherhasidof(self):
""" """
@ -219,7 +219,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = FatherHasIdOf(['I0106']) rule = FatherHasIdOf(['I0106'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'8OUJQCUVZ0XML7BQLF'])) set(['8OUJQCUVZ0XML7BQLF']))
def test_motherhasnameof(self): def test_motherhasnameof(self):
""" """
@ -228,8 +228,8 @@ class BaseTest(unittest.TestCase):
rule = MotherHasNameOf(['', 'Alvarado', '', '', '', '', '', '', '', '', rule = MotherHasNameOf(['', 'Alvarado', '', '', '', '', '', '', '', '',
'']) ''])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'EM3KQC48HFLA02TF8D', b'K9NKQCBG105ECXZ48D', 'EM3KQC48HFLA02TF8D', 'K9NKQCBG105ECXZ48D',
b'2QMKQC5YWNAWZMG6VO', b'6JUJQCCAXGENRX990K'])) '2QMKQC5YWNAWZMG6VO', '6JUJQCCAXGENRX990K']))
def test_motherhasidof(self): def test_motherhasidof(self):
""" """
@ -237,7 +237,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = MotherHasIdOf(['I0107']) rule = MotherHasIdOf(['I0107'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'8OUJQCUVZ0XML7BQLF'])) set(['8OUJQCUVZ0XML7BQLF']))
def test_childhasnameof(self): def test_childhasnameof(self):
""" """
@ -246,9 +246,9 @@ class BaseTest(unittest.TestCase):
rule = ChildHasNameOf(['Eugene', '', '', '', '', '', '', '', '', '', rule = ChildHasNameOf(['Eugene', '', '', '', '', '', '', '', '', '',
'']) ''])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'D1YJQCGLEIBPPLNL4B', b'5GTJQCXVYVAIQTBVKA', b'I42KQCM3S926FMJ91O', 'D1YJQCGLEIBPPLNL4B', '5GTJQCXVYVAIQTBVKA', 'I42KQCM3S926FMJ91O',
b'7CTJQCFJVBQSY076A6', b'9OUJQCBOHW9UEK9CNV', b'9IXJQCX18AHUFPQHEZ', '7CTJQCFJVBQSY076A6', '9OUJQCBOHW9UEK9CNV', '9IXJQCX18AHUFPQHEZ',
b'9NWJQCJGLXUR3AQSFJ'])) '9NWJQCJGLXUR3AQSFJ']))
def test_childhasidof(self): def test_childhasidof(self):
""" """
@ -256,7 +256,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = ChildHasIdOf(['I0001']) rule = ChildHasIdOf(['I0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'48TJQCGNNIR5SJRCAK'])) set(['48TJQCGNNIR5SJRCAK']))
def test_changedsince(self): def test_changedsince(self):
""" """
@ -264,7 +264,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = ChangedSince(['2008-01-01', '2014-01-01']) rule = ChangedSince(['2008-01-01', '2014-01-01'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hastag(self): def test_hastag(self):
""" """
@ -272,7 +272,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasTag(['ToDo']) rule = HasTag(['ToDo'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'9OUJQCBOHW9UEK9CNV'])) set(['9OUJQCBOHW9UEK9CNV']))
def test_hastwins(self): def test_hastwins(self):
""" """
@ -280,8 +280,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasTwins([]) rule = HasTwins([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'SD6KQC7LB8MYGA7F5W', b'8OUJQCUVZ0XML7BQLF', b'1BVJQCNTFAGS8273LJ', 'SD6KQC7LB8MYGA7F5W', '8OUJQCUVZ0XML7BQLF', '1BVJQCNTFAGS8273LJ',
b'5IUJQCRJY47YQ8PU7N', b'ZLUJQCPDV93OR8KHB7', b'4U2KQCBXG2VTPH6U1F', '5IUJQCRJY47YQ8PU7N', 'ZLUJQCPDV93OR8KHB7', '4U2KQCBXG2VTPH6U1F',
])) ]))
def test_isancestorof(self): def test_isancestorof(self):
@ -290,10 +290,10 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsAncestorOf(['F0031', '0']) rule = IsAncestorOf(['F0031', '0'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'4AXJQC96KTN3WGPTVE', b'1RUJQCYX9QL1V45YLD', b'5GTJQCXVYVAIQTBVKA', '4AXJQC96KTN3WGPTVE', '1RUJQCYX9QL1V45YLD', '5GTJQCXVYVAIQTBVKA',
b'X3WJQCSF48F6809142', b'NSVJQC89IHEEBIPDP2', b'9OUJQCBOHW9UEK9CNV', 'X3WJQCSF48F6809142', 'NSVJQC89IHEEBIPDP2', '9OUJQCBOHW9UEK9CNV',
b'1RUJQCCL9MVRYLMTBO', b'RRVJQC5A8DDHQFPRDL', b'0SUJQCOS78AXGWP8QR', '1RUJQCCL9MVRYLMTBO', 'RRVJQC5A8DDHQFPRDL', '0SUJQCOS78AXGWP8QR',
b'57WJQCTBJKR5QYPS6K', b'8OUJQCUVZ0XML7BQLF', b'7PUJQC4PPS4EDIVMYE' '57WJQCTBJKR5QYPS6K', '8OUJQCUVZ0XML7BQLF', '7PUJQC4PPS4EDIVMYE'
])) ]))
def test_isdescendantof(self): def test_isdescendantof(self):
@ -302,11 +302,11 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsDescendantOf(['F0031', '0']) rule = IsDescendantOf(['F0031', '0'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'SFXJQCLE8PIG7PH38J', b'UCXJQCC5HS8VXDKWBM', b'IIEKQCRX89WYBHKB7R', 'SFXJQCLE8PIG7PH38J', 'UCXJQCC5HS8VXDKWBM', 'IIEKQCRX89WYBHKB7R',
b'XDXJQCMWU5EIV8XCRF', b'7BXJQCU22OCA4HN38A', b'3FXJQCR749H2H7G321', 'XDXJQCMWU5EIV8XCRF', '7BXJQCU22OCA4HN38A', '3FXJQCR749H2H7G321',
b'IEXJQCFUN95VENI6BO', b'4FXJQC7656WDQ3HJGW', b'FLEKQCRVG3O1UA9YUB', 'IEXJQCFUN95VENI6BO', '4FXJQC7656WDQ3HJGW', 'FLEKQCRVG3O1UA9YUB',
b'BCXJQC9AQ0DBXCVLEQ', b'9SEKQCAAWRUCIO7A0M', b'DDXJQCVT5X72TOXP0C', 'BCXJQC9AQ0DBXCVLEQ', '9SEKQCAAWRUCIO7A0M', 'DDXJQCVT5X72TOXP0C',
b'CGXJQC515QL9RLPQTU', b'XGXJQCNVZH2PWRMVAH', b'RBXJQCUYMQR2KRMDFY' 'CGXJQC515QL9RLPQTU', 'XGXJQCNVZH2PWRMVAH', 'RBXJQCUYMQR2KRMDFY'
])) ]))

View File

@ -74,7 +74,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['O0000']) rule = HasIdOf(['O0000'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'b39fe1cfc1305ac4a21'])) set(['b39fe1cfc1305ac4a21']))
def test_regexpidof(self): def test_regexpidof(self):
""" """
@ -82,9 +82,9 @@ class BaseTest(unittest.TestCase):
""" """
rule = RegExpIdOf(['O000.'], use_regex=True) rule = RegExpIdOf(['O000.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'F0QIGQFT275JFJ75E8', b'78V2GQX2FKNSYQ3OHE', 'F0QIGQFT275JFJ75E8', '78V2GQX2FKNSYQ3OHE',
b'b39fe1cfc1305ac4a21', b'F8JYGQFL2PKLSYH79X', 'b39fe1cfc1305ac4a21', 'F8JYGQFL2PKLSYH79X',
b'B1AUFQV7H8R9NR4SZM'])) 'B1AUFQV7H8R9NR4SZM']))
def test_hascitation(self): def test_hascitation(self):
""" """
@ -92,7 +92,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasCitation(['page 21', '', '']) rule = HasCitation(['page 21', '', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'B1AUFQV7H8R9NR4SZM'])) set(['B1AUFQV7H8R9NR4SZM']))
def test_hasnoteregexp(self): def test_hasnoteregexp(self):
""" """
@ -114,7 +114,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasReferenceCountOf(['greater than', '1']) rule = HasReferenceCountOf(['greater than', '1'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'238CGQ939HG18SS5MG', b'b39fe1cfc1305ac4a21'])) '238CGQ939HG18SS5MG', 'b39fe1cfc1305ac4a21']))
def test_hassourcecount(self): def test_hassourcecount(self):
""" """
@ -122,7 +122,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceCount(['1', 'equal to']) rule = HasSourceCount(['1', 'equal to'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'B1AUFQV7H8R9NR4SZM'])) set(['B1AUFQV7H8R9NR4SZM']))
def test_hassourceof(self): def test_hassourceof(self):
""" """
@ -130,7 +130,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceOf(['S0001']) rule = HasSourceOf(['S0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'B1AUFQV7H8R9NR4SZM'])) set(['B1AUFQV7H8R9NR4SZM']))
def test_mediaprivate(self): def test_mediaprivate(self):
""" """
@ -145,7 +145,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = MatchesSourceConfidence(['2']) rule = MatchesSourceConfidence(['2'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'B1AUFQV7H8R9NR4SZM'])) set(['B1AUFQV7H8R9NR4SZM']))
def test_hasmedia(self): def test_hasmedia(self):
""" """
@ -153,7 +153,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasMedia(['mannschaft', 'image/jpeg', '.jpg', '1897']) rule = HasMedia(['mannschaft', 'image/jpeg', '.jpg', '1897'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'238CGQ939HG18SS5MG'])) set(['238CGQ939HG18SS5MG']))
def test_hasattribute(self): def test_hasattribute(self):
""" """
@ -161,7 +161,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasAttribute(['Description', '']) rule = HasAttribute(['Description', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'B1AUFQV7H8R9NR4SZM'])) set(['B1AUFQV7H8R9NR4SZM']))
def test_changedsince(self): def test_changedsince(self):
""" """
@ -169,8 +169,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = ChangedSince(['2010-01-01', '2016-01-01']) rule = ChangedSince(['2010-01-01', '2016-01-01'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'b39fe1cfc1305ac4a21', b'B1AUFQV7H8R9NR4SZM', 'b39fe1cfc1305ac4a21', 'B1AUFQV7H8R9NR4SZM',
b'238CGQ939HG18SS5MG', b'F0QIGQFT275JFJ75E8'])) '238CGQ939HG18SS5MG', 'F0QIGQFT275JFJ75E8']))
def test_hastag(self): def test_hastag(self):
""" """
@ -178,7 +178,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasTag(['ToDo']) rule = HasTag(['ToDo'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'238CGQ939HG18SS5MG'])) set(['238CGQ939HG18SS5MG']))
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -72,7 +72,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['N0001']) rule = HasIdOf(['N0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'ac380498bac48eedee8'])) set(['ac380498bac48eedee8']))
def test_regexpidof(self): def test_regexpidof(self):
""" """
@ -80,11 +80,11 @@ class BaseTest(unittest.TestCase):
""" """
rule = RegExpIdOf(['N000.'], use_regex=True) rule = RegExpIdOf(['N000.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'ac380498c020c7bcdc7', b'ac3804a842b21358c97', 'ac380498c020c7bcdc7', 'ac3804a842b21358c97',
b'ae13613d581506d040892f88a21', b'ac3804a8405171ef666', 'ae13613d581506d040892f88a21', 'ac3804a8405171ef666',
b'ac3804a1d747a39822c', b'ac3804aac6b762b75a5', 'ac3804a1d747a39822c', 'ac3804aac6b762b75a5',
b'ac380498bac48eedee8', b'ac3804a1d66258b8e13', 'ac380498bac48eedee8', 'ac3804a1d66258b8e13',
b'ac380498bc46102e1e8', b'b39fe2e143d1e599450'])) 'ac380498bc46102e1e8', 'b39fe2e143d1e599450']))
def test_hasnote(self): def test_hasnote(self):
""" """
@ -92,7 +92,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNote(['note', 'Person Note']) rule = HasNote(['note', 'Person Note'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'b39ff11d8912173cded', b'b39ff01f75c1f76859a'])) 'b39ff11d8912173cded', 'b39ff01f75c1f76859a']))
def test_matchesregexpof(self): def test_matchesregexpof(self):
""" """
@ -100,8 +100,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = MatchesRegexpOf(['^This'], use_regex=True) rule = MatchesRegexpOf(['^This'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'b39ff11d8912173cded', b'c140d4c29520c92055c', 'b39ff11d8912173cded', 'c140d4c29520c92055c',
b'b39ff01f75c1f76859a'])) 'b39ff01f75c1f76859a']))
def test_hasreferencecountof(self): def test_hasreferencecountof(self):
""" """
@ -109,7 +109,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasReferenceCountOf(['greater than', '1']) rule = HasReferenceCountOf(['greater than', '1'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'c140d4c29520c92055c'])) set(['c140d4c29520c92055c']))
def test_noteprivate(self): def test_noteprivate(self):
""" """
@ -124,9 +124,9 @@ class BaseTest(unittest.TestCase):
""" """
rule = ChangedSince(['2010-01-01', '2016-01-01']) rule = ChangedSince(['2010-01-01', '2016-01-01'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'c140d4c29520c92055c', b'd0436bcc69d6bba278bff5bc7db', 'c140d4c29520c92055c', 'd0436bcc69d6bba278bff5bc7db',
b'b39fe2e143d1e599450', b'd0436bba4ec328d3b631259a4ee', 'b39fe2e143d1e599450', 'd0436bba4ec328d3b631259a4ee',
b'd0436be64ac277b615b79b34e72'])) 'd0436be64ac277b615b79b34e72']))
def test_hastag(self): def test_hastag(self):
""" """
@ -134,7 +134,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasTag(['ToDo']) rule = HasTag(['ToDo'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'b39ff01f75c1f76859a', b'b39fe2e143d1e599450'])) 'b39ff01f75c1f76859a', 'b39fe2e143d1e599450']))
def test_hastype(self): def test_hastype(self):
""" """
@ -142,8 +142,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasType(['Person Note']) rule = HasType(['Person Note'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'ac380498c020c7bcdc7', b'b39ff11d8912173cded', 'ac380498c020c7bcdc7', 'b39ff11d8912173cded',
b'b39ff01f75c1f76859a'])) 'b39ff01f75c1f76859a']))
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -68,31 +68,31 @@ class BaseTest(unittest.TestCase):
""" """
rule = Disconnected([]) rule = Disconnected([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'0PBKQCXHLAEIB46ZIA', b'QEVJQC04YO01UAWJ2N', b'UT0KQCMN7PC9XURRXJ', '0PBKQCXHLAEIB46ZIA', 'QEVJQC04YO01UAWJ2N', 'UT0KQCMN7PC9XURRXJ',
b'MZAKQCKAQLIQYWP5IW', b'Y7BKQC9CUXWQLGLPQM', b'OBBKQC8NJM5UYBO849', 'MZAKQCKAQLIQYWP5IW', 'Y7BKQC9CUXWQLGLPQM', 'OBBKQC8NJM5UYBO849',
b'NPBKQCKEF0G7T4H312', b'423KQCGLT8UISDUM1Q', b'8S0KQCNORIWDL0X8SB', 'NPBKQCKEF0G7T4H312', '423KQCGLT8UISDUM1Q', '8S0KQCNORIWDL0X8SB',
b'AP5KQC0LBXPM727OWB', b'AREKQC0VPBHNZ5R3IO', b'KU0KQCJ0RUTJTIUKSA', 'AP5KQC0LBXPM727OWB', 'AREKQC0VPBHNZ5R3IO', 'KU0KQCJ0RUTJTIUKSA',
b'VC4KQC7L7KKH9RLHXN', b'0P3KQCRSIVL1A4VJ19', b'PK6KQCGEL4PTE720BL', 'VC4KQC7L7KKH9RLHXN', '0P3KQCRSIVL1A4VJ19', 'PK6KQCGEL4PTE720BL',
b'YIKKQCSD2Z85UHJ8LX', b'KY8KQCMIH2HUUGLA3R', b'RD7KQCQ24B1N3OEC5X', 'YIKKQCSD2Z85UHJ8LX', 'KY8KQCMIH2HUUGLA3R', 'RD7KQCQ24B1N3OEC5X',
b'NV0KQC7SIEH3SVDPP1', b'KIKKQCU2CJ543TLM5J', b'AT0KQC4P3MMUCHI3BK', 'NV0KQC7SIEH3SVDPP1', 'KIKKQCU2CJ543TLM5J', 'AT0KQC4P3MMUCHI3BK',
b'J6BKQC1PMNBAYSLM9U', b'IXXJQCLKOUAJ5RSQY4', b'U4ZJQC5VR0QBIE8DU', 'J6BKQC1PMNBAYSLM9U', 'IXXJQCLKOUAJ5RSQY4', 'U4ZJQC5VR0QBIE8DU',
b'F7BKQC4NXO9R7XOG2W', b'7U0KQC6PGZBNQATNOT', b'78AKQCI05U36T3E82O', 'F7BKQC4NXO9R7XOG2W', '7U0KQC6PGZBNQATNOT', '78AKQCI05U36T3E82O',
b'H1GKQCWOUJHFSHXABA', b'ZWGKQCRFZAPC5PYJZ1', b'EZ0KQCF3LSM9PRSG0K', 'H1GKQCWOUJHFSHXABA', 'ZWGKQCRFZAPC5PYJZ1', 'EZ0KQCF3LSM9PRSG0K',
b'FHKKQC963NGSY18ZDZ', b'FJ9KQCRJ3RGHNBWW4S', b'S2EKQC9F4UR4R71IC3', 'FHKKQC963NGSY18ZDZ', 'FJ9KQCRJ3RGHNBWW4S', 'S2EKQC9F4UR4R71IC3',
b'1XBKQCX019BKJ0M9IH', b'Z62KQC706L0B0WTN3Q', b'O7EKQCEVZ7FBEWMNWE', '1XBKQCX019BKJ0M9IH', 'Z62KQC706L0B0WTN3Q', 'O7EKQCEVZ7FBEWMNWE',
b'XY8KQCULFPN4SR915Q', b'WQDKQCEULSD5G9XNFI', b'2Z0KQCSWKVFG7RPFD8', 'XY8KQCULFPN4SR915Q', 'WQDKQCEULSD5G9XNFI', '2Z0KQCSWKVFG7RPFD8',
b'26BKQC0SJIJOH02H2A', b'262KQCH2RQKN0CBRLF', b'P5ZJQCMKO7EYV4HFCL', '26BKQC0SJIJOH02H2A', '262KQCH2RQKN0CBRLF', 'P5ZJQCMKO7EYV4HFCL',
b'KXBKQC52JO3AP4GMLF', b'9IFKQC60JTDBV57N6S', b'TQ0KQCZ8LA7X9DIEAN', 'KXBKQC52JO3AP4GMLF', '9IFKQC60JTDBV57N6S', 'TQ0KQCZ8LA7X9DIEAN',
b'BAXJQCORQA5Q46FCDG', b'VR0KQC7LVANO83AL35', b'75CKQC4T617U2E5T5Y', 'BAXJQCORQA5Q46FCDG', 'VR0KQC7LVANO83AL35', '75CKQC4T617U2E5T5Y',
b'LCTKQCZU3F94CEFSOM', b'WJYJQCPNJJI5JN07SD', b'3N6KQC6BE5EIXTRMDL', 'LCTKQCZU3F94CEFSOM', 'WJYJQCPNJJI5JN07SD', '3N6KQC6BE5EIXTRMDL',
b'CM5KQCD57I15GKLAMB', b'cccbffffd3e69819cd8', 'CM5KQCD57I15GKLAMB', 'cccbffffd3e69819cd8',
b'BJKKQCVDA66528PDAU', b'QS0KQCLMIZFI8ZDLM3', b'UW0KQCRHBIYMA8LPZD', 'BJKKQCVDA66528PDAU', 'QS0KQCLMIZFI8ZDLM3', 'UW0KQCRHBIYMA8LPZD',
b'GJ7KQC7APJSAMHEK5Q', b'711KQCDXOQWB3KDWEP', b'PY0KQC77AJ3457A6C2', 'GJ7KQC7APJSAMHEK5Q', '711KQCDXOQWB3KDWEP', 'PY0KQC77AJ3457A6C2',
b'WZ0KQCYVMEJHDR4MV2', b'28EKQCQGM6NLLWFRG7', b'E33KQCRREJALRA715H', 'WZ0KQCYVMEJHDR4MV2', '28EKQCQGM6NLLWFRG7', 'E33KQCRREJALRA715H',
b'8HKKQCTEJAOBVH410L', b'IO6KQC70PMBQUDNB3L', b'1YBKQCWRBNB433NEMH', '8HKKQCTEJAOBVH410L', 'IO6KQC70PMBQUDNB3L', '1YBKQCWRBNB433NEMH',
b'M01KQCF7KUWCDY67JD', b'CR0KQCOMV2QPPC90IF', b'85ZJQCMG38N7Q2WKIK', 'M01KQCF7KUWCDY67JD', 'CR0KQCOMV2QPPC90IF', '85ZJQCMG38N7Q2WKIK',
b'I9GKQCERACL8UZF2PY', b'BY0KQCOZUK47R2JZDE', b'7W0KQCYDMD4LTSY5JL', 'I9GKQCERACL8UZF2PY', 'BY0KQCOZUK47R2JZDE', '7W0KQCYDMD4LTSY5JL',
b'A0YJQC3HONEKD1JCPK', b'd5839c13b0541b7b8e6', 'A0YJQC3HONEKD1JCPK', 'd5839c13b0541b7b8e6',
])) ]))
def test_everyone(self): def test_everyone(self):
@ -117,7 +117,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasAlternateName([]) rule = HasAlternateName([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'46WJQCIOLQ0KOX2XCC', b'GNUJQCL9MD64AM56OH', '46WJQCIOLQ0KOX2XCC', 'GNUJQCL9MD64AM56OH',
])) ]))
def test_commonancestor_empty(self): def test_commonancestor_empty(self):
@ -134,7 +134,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasCommonAncestorWith(['I0000']) rule = HasCommonAncestorWith(['I0000'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'd5839c1237765987724' 'd5839c1237765987724'
])) ]))
def test_commonancestor_irregular(self): def test_commonancestor_irregular(self):
@ -151,39 +151,39 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasCommonAncestorWith(['I0044']) rule = HasCommonAncestorWith(['I0044'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'GNUJQCL9MD64AM56OH', b'SOFKQCBYAO18OWC0CS', b'EMEKQC02EOUF8H0SHM', 'GNUJQCL9MD64AM56OH', 'SOFKQCBYAO18OWC0CS', 'EMEKQC02EOUF8H0SHM',
b'3EXJQCVWOSQFGLYB6H', b'EMTJQCQU6TL4WAVSE4', b'QUEKQCZL61S8BJJ388', '3EXJQCVWOSQFGLYB6H', 'EMTJQCQU6TL4WAVSE4', 'QUEKQCZL61S8BJJ388',
b'MKEKQCSBQGAVHAPCQT', b'MUFKQCMXUJ07MCDUNI', b'DBXJQCJCEZMO17WZ89', 'MKEKQCSBQGAVHAPCQT', 'MUFKQCMXUJ07MCDUNI', 'DBXJQCJCEZMO17WZ89',
b'ORFKQC4KLWEGTGR19L', b'MG5KQC6ZKSVO4A63G2', b'N26KQCF3ASHMZ0HEW6', 'ORFKQC4KLWEGTGR19L', 'MG5KQC6ZKSVO4A63G2', 'N26KQCF3ASHMZ0HEW6',
b'GNWJQC9NLVF2MZLHU9', b'ZFXJQCHAD8SLZZ7KRP', b'44WJQCLCQIPZUB0UH', 'GNWJQC9NLVF2MZLHU9', 'ZFXJQCHAD8SLZZ7KRP', '44WJQCLCQIPZUB0UH',
b'B8TJQC53HJXOGXK8F7', b'D3WJQCCGV58IP8PNHZ', b'3LEKQCRF3FD2E1H73I', 'B8TJQC53HJXOGXK8F7', 'D3WJQCCGV58IP8PNHZ', '3LEKQCRF3FD2E1H73I',
b'F06KQCZY1I4H4IFZM', b'VMTJQC49IGKLG2EQ5', b'9BXKQC1PVLPYFMD6IX', 'F06KQCZY1I4H4IFZM', 'VMTJQC49IGKLG2EQ5', '9BXKQC1PVLPYFMD6IX',
b'H1DKQC4YGZ5A61FGS', b'1GWJQCGOOZ8FJW3YK9', b'S16KQCX8XUO3EEL85N', 'H1DKQC4YGZ5A61FGS', '1GWJQCGOOZ8FJW3YK9', 'S16KQCX8XUO3EEL85N',
b'OREKQCF34YE89RL8S6', b'RU5KQCQTPC9SJ5Q1JN', b'GYFKQCPH8Q0JDN94GR', 'OREKQCF34YE89RL8S6', 'RU5KQCQTPC9SJ5Q1JN', 'GYFKQCPH8Q0JDN94GR',
b'9QFKQC54ET79K2SD57', b'MLEKQCH64557K610VR', b'AWFKQCJELLUWDY2PD3', '9QFKQC54ET79K2SD57', 'MLEKQCH64557K610VR', 'AWFKQCJELLUWDY2PD3',
b'ZDWJQC7TMS2AWAVF2Y', b'VJFKQCFO7WESWPNKHE', b'LV5KQCJCCR0S3DN5WW', 'ZDWJQC7TMS2AWAVF2Y', 'VJFKQCFO7WESWPNKHE', 'LV5KQCJCCR0S3DN5WW',
b'CDTJQCVTVX7CNMY9YU', b'OX5KQCKE3I94MEPDC', b'JF5KQC2L6ABI0MVD3E', 'CDTJQCVTVX7CNMY9YU', 'OX5KQCKE3I94MEPDC', 'JF5KQC2L6ABI0MVD3E',
b'CH5KQCIEXSN1J5UEHB', b'4JEKQC22K5UTH9QHCU', b'EPFKQCETTDTEL3PYIR', 'CH5KQCIEXSN1J5UEHB', '4JEKQC22K5UTH9QHCU', 'EPFKQCETTDTEL3PYIR',
b'D16KQCIZS56HVPW6DA', b'2TEKQCTSCRL4Z2AUHE', b'3WEKQCHXRH61E3CIKB', 'D16KQCIZS56HVPW6DA', '2TEKQCTSCRL4Z2AUHE', '3WEKQCHXRH61E3CIKB',
b'TDTJQCGYRS2RCCGQN3', b'SMWJQCXQ6I2GEXSPK9', b'PXFKQCXEHJX3W1Q1IV', 'TDTJQCGYRS2RCCGQN3', 'SMWJQCXQ6I2GEXSPK9', 'PXFKQCXEHJX3W1Q1IV',
b'Q9TJQCXDL1599L2B2Z', b'BFXJQCF1JBOXPRW2OS', b'6TFKQCUTO94WB2NHN', 'Q9TJQCXDL1599L2B2Z', 'BFXJQCF1JBOXPRW2OS', '6TFKQCUTO94WB2NHN',
b'FNEKQCO239QSNK0R78', b'3RFKQCNKMX9HVLNSLW', b'W2DKQCV4H3EZUJ35DX', 'FNEKQCO239QSNK0R78', '3RFKQCNKMX9HVLNSLW', 'W2DKQCV4H3EZUJ35DX',
b'5IEKQCN37EFBK9EBUD', b'LW5KQCXSXRC2XV3T3D', b'ZNEKQCULV911DIXBK3', '5IEKQCN37EFBK9EBUD', 'LW5KQCXSXRC2XV3T3D', 'ZNEKQCULV911DIXBK3',
b'35WJQC1B7T7NPV8OLV', b'MPEKQC6TIP3SP1YF7I', b'DMFKQC5MHGYC6503F2', '35WJQC1B7T7NPV8OLV', 'MPEKQC6TIP3SP1YF7I', 'DMFKQC5MHGYC6503F2',
b'3KEKQC45RL87D4ZG86', b'KLTJQC70XVZJSPQ43U', b'LVEKQCP09W7JNFDAFC', '3KEKQC45RL87D4ZG86', 'KLTJQC70XVZJSPQ43U', 'LVEKQCP09W7JNFDAFC',
b'DPUJQCUYKKDPT78JJV', b'JDXJQCR5L0NTR21SQA', b'UAXJQC6HC354V7Q6JA', 'DPUJQCUYKKDPT78JJV', 'JDXJQCR5L0NTR21SQA', 'UAXJQC6HC354V7Q6JA',
b'XBXJQCS4QY316ZGHRN', b'HCXJQCRKB4K65V1C07', b'66TJQC6CC7ZWL9YZ64', 'XBXJQCS4QY316ZGHRN', 'HCXJQCRKB4K65V1C07', '66TJQC6CC7ZWL9YZ64',
b'XNFKQC6DN59LACS9IU', b'LL5KQCG687Y165GL5P', b'7X5KQC9ABK4T6AW7QF', 'XNFKQC6DN59LACS9IU', 'LL5KQCG687Y165GL5P', '7X5KQC9ABK4T6AW7QF',
b'HKTJQCIJD8RK9RJFO1', b'1LTJQCYQI1DXBLG6Z', b'0FWJQCLYEP736P3YZK', 'HKTJQCIJD8RK9RJFO1', '1LTJQCYQI1DXBLG6Z', '0FWJQCLYEP736P3YZK',
b'0DXJQC1T8P3CQKZIUO', b'ISEKQC97YI74A9VKWC', b'KGXJQCBQ39ON9VB37T', '0DXJQC1T8P3CQKZIUO', 'ISEKQC97YI74A9VKWC', 'KGXJQCBQ39ON9VB37T',
b'BZ5KQCD4KFI3BTIMZU', b'0HEKQCLINMQS4RB7B8', b'BBTJQCNT6N1H4X6TL4', 'BZ5KQCD4KFI3BTIMZU', '0HEKQCLINMQS4RB7B8', 'BBTJQCNT6N1H4X6TL4',
b'COFKQCUXC2H4G3QBYT', b'DI5KQC3CLKWQI3I0CC', b'T8TJQCWWI8RY57YNTQ', 'COFKQCUXC2H4G3QBYT', 'DI5KQC3CLKWQI3I0CC', 'T8TJQCWWI8RY57YNTQ',
b'46WJQCIOLQ0KOX2XCC', b'OEXJQCQJHF2BLSAAIS', b'GNFKQCH8AFJRJO9V4Y', '46WJQCIOLQ0KOX2XCC', 'OEXJQCQJHF2BLSAAIS', 'GNFKQCH8AFJRJO9V4Y',
b'8LFKQCQWXTJQJR4CXV', b'IGWJQCSVT8NXTFXOFJ', b'3PEKQC8ZDCYTSSIKZ9', '8LFKQCQWXTJQJR4CXV', 'IGWJQCSVT8NXTFXOFJ', '3PEKQC8ZDCYTSSIKZ9',
b'5UEKQC8N8NEPSWU1QQ', b'NK5KQC1MAOU2BP35ZV', b'UZFKQCIHVT44DC9KGH', '5UEKQC8N8NEPSWU1QQ', 'NK5KQC1MAOU2BP35ZV', 'UZFKQCIHVT44DC9KGH',
b'JJ5KQC83DT7VDMUYRQ', b'626KQC7C08H3UTM38E', b'XIFKQCLQOY645QTGP7', 'JJ5KQC83DT7VDMUYRQ', '626KQC7C08H3UTM38E', 'XIFKQCLQOY645QTGP7',
b'HEWJQCWQQ3K4BNRLIO', b'HDWJQCT361VOV2PQLP', b'XFKKQCGA4DVECEB48E', 'HEWJQCWQQ3K4BNRLIO', 'HDWJQCT361VOV2PQLP', 'XFKKQCGA4DVECEB48E',
b'KWEKQCTNIIV9BROFFG', 'KWEKQCTNIIV9BROFFG',
])) ]))
def test_hasnickname(self): def test_hasnickname(self):
@ -192,8 +192,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNickname([]) rule = HasNickname([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'cc8205d883763f02abd', b'GNUJQCL9MD64AM56OH', 'cc8205d883763f02abd', 'GNUJQCL9MD64AM56OH',
b'Q8HKQC3VMRM1M6M7ES', 'Q8HKQC3VMRM1M6M7ES',
])) ]))
def test_hasunknowngender(self): def test_hasunknowngender(self):
@ -202,13 +202,13 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasUnknownGender([]) rule = HasUnknownGender([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'OJOKQC83Y1EDBIMLJ6', b'8BHKQCFK9UZFRJYC2Y', b'PGFKQC1TUQMXFAMLMB', 'OJOKQC83Y1EDBIMLJ6', '8BHKQCFK9UZFRJYC2Y', 'PGFKQC1TUQMXFAMLMB',
b'IHOKQCECRZYQDKW6KF', b'8HKKQCTEJAOBVH410L', b'AGFKQCO358R18LNJYV', 'IHOKQCECRZYQDKW6KF', '8HKKQCTEJAOBVH410L', 'AGFKQCO358R18LNJYV',
b'1ENKQCBPFZTAQJSP4O', b'NUWKQCO7TVAOH0CHLV', b'P5IKQC88STY3FNTFZ3', '1ENKQCBPFZTAQJSP4O', 'NUWKQCO7TVAOH0CHLV', 'P5IKQC88STY3FNTFZ3',
b'7GXKQCMVFU8WR1LKZL', b'LGXKQCJ5OP6MKF9QLN', b'XNFKQC6DN59LACS9IU', '7GXKQCMVFU8WR1LKZL', 'LGXKQCJ5OP6MKF9QLN', 'XNFKQC6DN59LACS9IU',
b'7IOKQC1NVGUI1E55CQ', b'57PKQCFAWY7AM3JS4M', b'BNXKQCEBXC1RCOGJNF', '7IOKQC1NVGUI1E55CQ', '57PKQCFAWY7AM3JS4M', 'BNXKQCEBXC1RCOGJNF',
b'TFFKQC1RMG8RRADKDH', b'FHKKQC963NGSY18ZDZ', b'WMXKQCDUJ4JKQQYCR7', 'TFFKQC1RMG8RRADKDH', 'FHKKQC963NGSY18ZDZ', 'WMXKQCDUJ4JKQQYCR7',
b'PBHKQCHOAGTECRKT9L', b'OFXKQC8W0N3N6JP6YQ', 'PBHKQCHOAGTECRKT9L', 'OFXKQC8W0N3N6JP6YQ',
])) ]))
def test_hassourceof_empty(self): def test_hassourceof_empty(self):
@ -218,25 +218,25 @@ class BaseTest(unittest.TestCase):
# when run with an empty string finds people with no sourc citations # when run with an empty string finds people with no sourc citations
rule = HasSourceOf(['']) rule = HasSourceOf([''])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'cc82060512042f67e2c', b'cc8205d87831c772e87', 'cc82060512042f67e2c', 'cc8205d87831c772e87',
b'cc82060516c6c141500', b'cc8205d87fd529000ff', 'cc82060516c6c141500', 'cc8205d87fd529000ff',
b'cc82060504445ab6deb', b'cc8205d887376aacba2', 'cc82060504445ab6deb', 'cc8205d887376aacba2',
b'cccbffffd3e69819cd8', b'cc8205d87c20350420b', 'cccbffffd3e69819cd8', 'cc8205d87c20350420b',
b'cc8206050e541f79f92', b'cc8205d883763f02abd', 'cc8206050e541f79f92', 'cc8205d883763f02abd',
b'cc8206050980ea622d0', b'cc8205d872f532ab14e', 'cc8206050980ea622d0', 'cc8205d872f532ab14e',
b'd5839c132b11d9e3632', b'd583a5ba0d50afbbaaf', 'd5839c132b11d9e3632', 'd583a5ba0d50afbbaaf',
b'd5839c1352c64b924d9', b'd583a5b9fc864e3bf4e', 'd5839c1352c64b924d9', 'd583a5b9fc864e3bf4e',
b'd583a5ba1bd083ce4c2', b'd583a5b9df71bceb48c', 'd583a5ba1bd083ce4c2', 'd583a5b9df71bceb48c',
b'd583a5b9ced473a7e6a', b'd583a5ba2bc7b9d1388', 'd583a5b9ced473a7e6a', 'd583a5ba2bc7b9d1388',
b'd5839c12fec09785f6a', b'd5839c1237765987724', 'd5839c12fec09785f6a', 'd5839c1237765987724',
b'd5839c137b3640ad776', b'd5839c126d11a754f46', 'd5839c137b3640ad776', 'd5839c126d11a754f46',
b'd5839c12d3b4d5e619b', b'd5839c13380462b246f', 'd5839c12d3b4d5e619b', 'd5839c13380462b246f',
b'd5839c12e9e08301ce2', b'd5839c1366b21411fb4', 'd5839c12e9e08301ce2', 'd5839c1366b21411fb4',
b'd5839c13a282b51dd0d', b'd5839c12ac91650a72b', 'd5839c13a282b51dd0d', 'd5839c12ac91650a72b',
b'd583a5b9edf6cb5d8d5', b'd583a5ba4be3acdd312', 'd583a5b9edf6cb5d8d5', 'd583a5ba4be3acdd312',
b'd5839c131d560e06bac', b'd5839c13b0541b7b8e6', 'd5839c131d560e06bac', 'd5839c13b0541b7b8e6',
b'd5839c1388e3ab6c87c', b'd583a5ba5ca6b698463', 'd5839c1388e3ab6c87c', 'd583a5ba5ca6b698463',
b'd583a5ba3bc48c2002c', b'd583a5b90777391ea9a', 'd583a5ba3bc48c2002c', 'd583a5b90777391ea9a',
])) ]))
def test_hassourceof_nonmatching(self): def test_hassourceof_nonmatching(self):
@ -261,7 +261,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceOf(['S0000']) rule = HasSourceOf(['S0000'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'GNUJQCL9MD64AM56OH', 'GNUJQCL9MD64AM56OH',
])) ]))
@ -271,7 +271,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HaveAltFamilies([]) rule = HaveAltFamilies([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'CH5KQCIEXSN1J5UEHB', b'MG5KQC6ZKSVO4A63G2', 'CH5KQCIEXSN1J5UEHB', 'MG5KQC6ZKSVO4A63G2',
])) ]))
def test_havechildren(self): def test_havechildren(self):
@ -288,36 +288,36 @@ class BaseTest(unittest.TestCase):
""" """
rule = IncompleteNames([]) rule = IncompleteNames([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'IHOKQCECRZYQDKW6KF', b'cc82060504445ab6deb', 'IHOKQCECRZYQDKW6KF', 'cc82060504445ab6deb',
b'LCXKQCQZH5EH56NTCD', b'cc8205d87831c772e87', 'LCXKQCQZH5EH56NTCD', 'cc8205d87831c772e87',
b'3RFKQCNKMX9HVLNSLW', b'cc8205d87fd529000ff', '3RFKQCNKMX9HVLNSLW', 'cc8205d87fd529000ff',
b'B1UKQCBR49WB3134PN', b'0TTKQCXXY59OCDPLV3', 'B1UKQCBR49WB3134PN', '0TTKQCXXY59OCDPLV3',
b'F3UKQC7ZV3EYVWTZ8O', b'1MXKQCJ2BR43910ZYX', 'F3UKQC7ZV3EYVWTZ8O', '1MXKQCJ2BR43910ZYX',
b'cc8206050e541f79f92', b'FHKKQC963NGSY18ZDZ', 'cc8206050e541f79f92', 'FHKKQC963NGSY18ZDZ',
b'R5HKQCIEPOY1DMQOWX', b'ZHMKQC50PFVAPI8PZ6', b'T4UKQCYGECXGVNBWMY', 'R5HKQCIEPOY1DMQOWX', 'ZHMKQC50PFVAPI8PZ6', 'T4UKQCYGECXGVNBWMY',
b'cc82060516c6c141500', b'UPWKQCYVFH7RZOSZ29', 'cc82060516c6c141500', 'UPWKQCYVFH7RZOSZ29',
b'2AMKQCE67YOH3TBVYI', b'2CUKQCFDVN3EZE2E4C', b'7IOKQC1NVGUI1E55CQ', '2AMKQCE67YOH3TBVYI', '2CUKQCFDVN3EZE2E4C', '7IOKQC1NVGUI1E55CQ',
b'KSTKQC018GNA7HDCAS', b'WIVKQC4Q4FCQJT5M63', b'A4YKQCRYSI5FT5T38', 'KSTKQC018GNA7HDCAS', 'WIVKQC4Q4FCQJT5M63', 'A4YKQCRYSI5FT5T38',
b'BUNKQCO4HZHZP70F3K', b'YRTKQCNDP343OD5OQJ', b'7VEKQCV05EDK0625KI', 'BUNKQCO4HZHZP70F3K', 'YRTKQCNDP343OD5OQJ', '7VEKQCV05EDK0625KI',
b'cc8205d872f532ab14e', b'TPXKQCEGL04KHGMO2X', 'cc8205d872f532ab14e', 'TPXKQCEGL04KHGMO2X',
b'L9LKQCQ8KJRKHM4D2E', b'8QXKQCHJ2EUC7OV8EQ', b'W0XKQCKSFWWJWQ2OSN', 'L9LKQCQ8KJRKHM4D2E', '8QXKQCHJ2EUC7OV8EQ', 'W0XKQCKSFWWJWQ2OSN',
b'I6QKQCFRDTV2LDC8M2', b'XTUKQC7WCIVA5F0NC4', b'F4UKQCPK572VWU2YZQ', 'I6QKQCFRDTV2LDC8M2', 'XTUKQC7WCIVA5F0NC4', 'F4UKQCPK572VWU2YZQ',
b'JKDKQCF4ND92A088J2', b'COFKQCUXC2H4G3QBYT', b'BNXKQCEBXC1RCOGJNF', 'JKDKQCF4ND92A088J2', 'COFKQCUXC2H4G3QBYT', 'BNXKQCEBXC1RCOGJNF',
b'Q42KQCKJZGS4IZWHF5', b'P5IKQC88STY3FNTFZ3', b'7CXKQC59NSZFXIG1UE', 'Q42KQCKJZGS4IZWHF5', 'P5IKQC88STY3FNTFZ3', '7CXKQC59NSZFXIG1UE',
b'cc8205d87c20350420b', b'FQUKQCWEHOAWUP4QWS', 'cc8205d87c20350420b', 'FQUKQCWEHOAWUP4QWS',
b'3YTKQCK2W63W0MQBJE', b'8HKKQCTEJAOBVH410L', b'HLQKQC0BJIZL0V4EK4', '3YTKQCK2W63W0MQBJE', '8HKKQCTEJAOBVH410L', 'HLQKQC0BJIZL0V4EK4',
b'B0UKQC9A54F1GUB7NR', b'EPXKQCQRZP2PNPN7BE', 'B0UKQC9A54F1GUB7NR', 'EPXKQCQRZP2PNPN7BE',
b'cc82060512042f67e2c', b'XZLKQCRQA9EHPBNZPT', 'cc82060512042f67e2c', 'XZLKQCRQA9EHPBNZPT',
b'OQXKQC2Y5FVH9PK0JL', b'AXLKQC0YTFAWQ234YD', b'OFXKQC8W0N3N6JP6YQ', 'OQXKQC2Y5FVH9PK0JL', 'AXLKQC0YTFAWQ234YD', 'OFXKQC8W0N3N6JP6YQ',
b'MWUKQCD2ZSCECQOCLG', b'1ENKQCBPFZTAQJSP4O', b'N7XKQCYD3VSCSZREGJ', 'MWUKQCD2ZSCECQOCLG', '1ENKQCBPFZTAQJSP4O', 'N7XKQCYD3VSCSZREGJ',
b'2LQKQC62GJUQCJIOK8', b'QXXKQC9PT5FWNT140K', b'VAXKQC19HIFPX61J28', '2LQKQC62GJUQCJIOK8', 'QXXKQC9PT5FWNT140K', 'VAXKQC19HIFPX61J28',
b'0PXKQCJ9S1M3NNASET', b'K8XKQCDSVLSK422A3K', b'52UKQCFYXMFTKIGNBS', '0PXKQCJ9S1M3NNASET', 'K8XKQCDSVLSK422A3K', '52UKQCFYXMFTKIGNBS',
b'7GXKQCMVFU8WR1LKZL', b'4UMKQCF07KL2K92CI5', b'LGXKQCJ5OP6MKF9QLN', '7GXKQCMVFU8WR1LKZL', '4UMKQCF07KL2K92CI5', 'LGXKQCJ5OP6MKF9QLN',
b'FZTKQCSTPIQ3C9JC46', b'WMXKQCDUJ4JKQQYCR7', b'R6UKQC939L9FV62UGE', 'FZTKQCSTPIQ3C9JC46', 'WMXKQCDUJ4JKQQYCR7', 'R6UKQC939L9FV62UGE',
b'OIUKQCBHUWDGL7DNTI', b'FRTKQC3G6JBJAR2ZPX', b'PIEKQCKUL6OAMS8Q9R', 'OIUKQCBHUWDGL7DNTI', 'FRTKQC3G6JBJAR2ZPX', 'PIEKQCKUL6OAMS8Q9R',
b'cc8205d887376aacba2', b'LGMKQCQP5M5L18FVTN', 'cc8205d887376aacba2', 'LGMKQCQP5M5L18FVTN',
b'8HUKQCRV8B3J2LLQ3B', b'LOUKQC45HUN532HOOM', '8HUKQCRV8B3J2LLQ3B', 'LOUKQC45HUN532HOOM',
b'cc8205d883763f02abd', b'TBXKQC7OHIN28PVCS3', 'cc8205d883763f02abd', 'TBXKQC7OHIN28PVCS3',
])) ]))
def test_isbookmarked(self): def test_isbookmarked(self):
@ -326,7 +326,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsBookmarked([]) rule = IsBookmarked([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'35WJQC1B7T7NPV8OLV', b'AWFKQCJELLUWDY2PD3', b'Q8HKQC3VMRM1M6M7ES', '35WJQC1B7T7NPV8OLV', 'AWFKQCJELLUWDY2PD3', 'Q8HKQC3VMRM1M6M7ES',
])) ]))
def test_dupancestor_empty(self): def test_dupancestor_empty(self):
@ -359,7 +359,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsDuplicatedAncestorOf(['I1631']) rule = IsDuplicatedAncestorOf(['I1631'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'I3VJQCUY5I6UR92507', b'D4VJQC09STQCWD393E', 'I3VJQCUY5I6UR92507', 'D4VJQC09STQCWD393E',
])) ]))
def test_isrelatedwith_empty(self): def test_isrelatedwith_empty(self):
@ -376,7 +376,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsRelatedWith(['I0000']) rule = IsRelatedWith(['I0000'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'd5839c1237765987724', b'd5839c126d11a754f46', 'd5839c1237765987724', 'd5839c126d11a754f46',
])) ]))
def test_isrelatedwith_irregular(self): def test_isrelatedwith_irregular(self):
@ -393,24 +393,24 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsRelatedWith(['I1844']) rule = IsRelatedWith(['I1844'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'HWTKQCSM28EI6WFDHP', b'T4UKQCYGECXGVNBWMY', b'YOTKQCEX2PLG03LZQS', 'HWTKQCSM28EI6WFDHP', 'T4UKQCYGECXGVNBWMY', 'YOTKQCEX2PLG03LZQS',
b'X8UKQCIDY21QIQBDVI', b'F3UKQC7ZV3EYVWTZ8O', b'0TTKQCXXY59OCDPLV3', 'X8UKQCIDY21QIQBDVI', 'F3UKQC7ZV3EYVWTZ8O', '0TTKQCXXY59OCDPLV3',
b'EVTKQCHV2E2PODFD7C', b'BBUKQC5GPRPDJHJAWU', b'FRTKQC3G6JBJAR2ZPX', 'EVTKQCHV2E2PODFD7C', 'BBUKQC5GPRPDJHJAWU', 'FRTKQC3G6JBJAR2ZPX',
b'NDTKQCN95VFLGJ21L', b'SFTKQC26EJ2BYQCRIA', b'MYTKQCVCFOFM32H9GB', 'NDTKQCN95VFLGJ21L', 'SFTKQC26EJ2BYQCRIA', 'MYTKQCVCFOFM32H9GB',
b'B0UKQC9A54F1GUB7NR', b'PTTKQCYN0JR3ZZJNWR', b'F4UKQCPK572VWU2YZQ', 'B0UKQC9A54F1GUB7NR', 'PTTKQCYN0JR3ZZJNWR', 'F4UKQCPK572VWU2YZQ',
b'LLTKQCX39KCXFSX0U4', b'IXTKQC1BAU1F1WNXKB', b'3YTKQCK2W63W0MQBJE', 'LLTKQCX39KCXFSX0U4', 'IXTKQC1BAU1F1WNXKB', '3YTKQCK2W63W0MQBJE',
b'TQTKQCO897BNA1H93B', b'DOTKQCP1MG3VC8D7V2', b'3NTKQCZKLMIM6HYFE1', 'TQTKQCO897BNA1H93B', 'DOTKQCP1MG3VC8D7V2', '3NTKQCZKLMIM6HYFE1',
b'WUTKQCVQCUPFFOGUT8', b'GETKQCPRC2W5YDUYM6', b'YRTKQCNDP343OD5OQJ', 'WUTKQCVQCUPFFOGUT8', 'GETKQCPRC2W5YDUYM6', 'YRTKQCNDP343OD5OQJ',
b'U0UKQCBZS0R6WW7LBS', b'J2UKQC897I42M9VHDD', b'7MTKQC1QNE4H5RF35S', 'U0UKQCBZS0R6WW7LBS', 'J2UKQC897I42M9VHDD', '7MTKQC1QNE4H5RF35S',
b'5FTKQCKT9SDZ8TB03C', b'O1UKQCJD5YHDRW887V', b'EUTKQCFATXRU431YY6', '5FTKQCKT9SDZ8TB03C', 'O1UKQCJD5YHDRW887V', 'EUTKQCFATXRU431YY6',
b'UHTKQCORH3NTZ0FYL3', b'2CUKQCFDVN3EZE2E4C', b'RNTKQCMLGRRKQVKDPR', 'UHTKQCORH3NTZ0FYL3', '2CUKQCFDVN3EZE2E4C', 'RNTKQCMLGRRKQVKDPR',
b'CGTKQC4WO8W3WSQRCX', b'WAUKQCOQ91QCJZWQ9U', b'FZTKQCSTPIQ3C9JC46', 'CGTKQC4WO8W3WSQRCX', 'WAUKQCOQ91QCJZWQ9U', 'FZTKQCSTPIQ3C9JC46',
b'AHTKQCM2YFRW3AGSRL', b'WBTKQCC775IAAGIWZD', b'8KTKQC407A8CN5O68H', 'AHTKQCM2YFRW3AGSRL', 'WBTKQCC775IAAGIWZD', '8KTKQC407A8CN5O68H',
b'8QTKQCN8ZKY5OWWJZF', b'UKTKQCSL3AUJIWTD2A', b'HAUKQCM3GYGVTREGZS', '8QTKQCN8ZKY5OWWJZF', 'UKTKQCSL3AUJIWTD2A', 'HAUKQCM3GYGVTREGZS',
b'52UKQCFYXMFTKIGNBS', b'U3UKQCO30PWAK6JQBA', b'R6UKQC939L9FV62UGE', '52UKQCFYXMFTKIGNBS', 'U3UKQCO30PWAK6JQBA', 'R6UKQC939L9FV62UGE',
b'TZTKQCR39A060AQ63C', b'X9UKQCFELSDAQ2TDP1', b'B1UKQCBR49WB3134PN', 'TZTKQCR39A060AQ63C', 'X9UKQCFELSDAQ2TDP1', 'B1UKQCBR49WB3134PN',
b'KSTKQC018GNA7HDCAS', b'FJTKQCJCMAHJOA9NHI', b'HITKQCWJSCZX2AN6NP', 'KSTKQC018GNA7HDCAS', 'FJTKQCJCMAHJOA9NHI', 'HITKQCWJSCZX2AN6NP',
b'WVTKQCZC91I63LHEE7', b'0DTKQC6KBOS69LQJ35', 'WVTKQCZC91I63LHEE7', '0DTKQC6KBOS69LQJ35',
])) ]))
def test_hasidof_empty(self): def test_hasidof_empty(self):
@ -427,7 +427,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['I0000']) rule = HasIdOf(['I0000'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'd5839c1237765987724' 'd5839c1237765987724'
])) ]))
def test_hasidof_irregular(self): def test_hasidof_irregular(self):
@ -444,7 +444,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['I0044']) rule = HasIdOf(['I0044'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'GNUJQCL9MD64AM56OH', 'GNUJQCL9MD64AM56OH',
])) ]))
def test_isdefaultperson(self): def test_isdefaultperson(self):
@ -453,7 +453,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsDefaultPerson([]) rule = IsDefaultPerson([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'GNUJQCL9MD64AM56OH', 'GNUJQCL9MD64AM56OH',
])) ]))
def test_isfemale(self): def test_isfemale(self):
@ -486,24 +486,24 @@ class BaseTest(unittest.TestCase):
""" """
rule = MultipleMarriages([]) rule = MultipleMarriages([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'R1VKQCJWNP24VN7BO', b'ZTVJQCTSMI85EGMXFM', b'ENTJQCZXQV1IRKJXUL', 'R1VKQCJWNP24VN7BO', 'ZTVJQCTSMI85EGMXFM', 'ENTJQCZXQV1IRKJXUL',
b'44WJQCLCQIPZUB0UH', b'SMWJQCXQ6I2GEXSPK9', b'DN3KQC1URTED410L3R', '44WJQCLCQIPZUB0UH', 'SMWJQCXQ6I2GEXSPK9', 'DN3KQC1URTED410L3R',
b'5FYJQC86G8EZ0L4E4B', b'5F4KQCJRU8ZKL6SILT', b'0YNKQC5U4EQGVNUZD8', '5FYJQC86G8EZ0L4E4B', '5F4KQCJRU8ZKL6SILT', '0YNKQC5U4EQGVNUZD8',
b'YRYJQCE3RF4U8A59UB', b'APWKQCI6YXAXBLC33I', b'XSKKQC6GGKLAYANWAF', 'YRYJQCE3RF4U8A59UB', 'APWKQCI6YXAXBLC33I', 'XSKKQC6GGKLAYANWAF',
b'0FQKQCOQD0VRVJPTSD', b'B3UJQCZHDXII99AWW4', '0FQKQCOQD0VRVJPTSD', 'B3UJQCZHDXII99AWW4',
b'cc8205d872f532ab14e', b'SS1KQCWWF9488Q330U', 'cc8205d872f532ab14e', 'SS1KQCWWF9488Q330U',
b'OCYJQCS8YT7JO8KIMO', b'I6HKQCQF72V2N56JQ5', b'6YWJQC86FBVN0J6JS', 'OCYJQCS8YT7JO8KIMO', 'I6HKQCQF72V2N56JQ5', '6YWJQC86FBVN0J6JS',
b'KYNKQCVA6FE65ONFIQ', b'SHAKQCNY5IXO30GUAB', b'O5XKQC3V6BPJI13J24', 'KYNKQCVA6FE65ONFIQ', 'SHAKQCNY5IXO30GUAB', 'O5XKQC3V6BPJI13J24',
b'ZN7KQC3RLB82EXF1QF', b'CIYJQCF3UK12DL0S2Y', b'H3XJQCFJ4FP4U2WGZC', 'ZN7KQC3RLB82EXF1QF', 'CIYJQCF3UK12DL0S2Y', 'H3XJQCFJ4FP4U2WGZC',
b'cc82060504445ab6deb', b'4E4KQC1K4XUEX29IJO', 'cc82060504445ab6deb', '4E4KQC1K4XUEX29IJO',
b'0XVJQCJUNJY40WDSMA', b'1WUJQCHNH76G6YD3A', b'IH3KQCM1VZPRKLBLK7', '0XVJQCJUNJY40WDSMA', '1WUJQCHNH76G6YD3A', 'IH3KQCM1VZPRKLBLK7',
b'242KQCBALBOD8ZK5VI', b'8G4KQCS6C1AOM6ZGR3', b'I1EKQCGGDSUD8ILUW4', '242KQCBALBOD8ZK5VI', '8G4KQCS6C1AOM6ZGR3', 'I1EKQCGGDSUD8ILUW4',
b'X8BKQCSFF4AET5MY23', b'RJWJQCN1XKXRN5KMCP', b'ZWNKQC9DAZ3C6UHUAV', 'X8BKQCSFF4AET5MY23', 'RJWJQCN1XKXRN5KMCP', 'ZWNKQC9DAZ3C6UHUAV',
b'9QUJQCCSWRZNSAPCR', b'HI0KQCG9TGT5AAIPU', b'DI4KQC3S1AO27VWOLN', '9QUJQCCSWRZNSAPCR', 'HI0KQCG9TGT5AAIPU', 'DI4KQC3S1AO27VWOLN',
b'QBDKQCH2IU6N8IXMFE', b'DK2KQCJYW14VXUJ85', b'117KQCBB32RMTTV4G6', 'QBDKQCH2IU6N8IXMFE', 'DK2KQCJYW14VXUJ85', '117KQCBB32RMTTV4G6',
b'0QLKQCFTQMNVGCV4GM', b'D2OKQCGDNPT3BH4WH', b'CAYJQCKOL49OF7XWB3', '0QLKQCFTQMNVGCV4GM', 'D2OKQCGDNPT3BH4WH', 'CAYJQCKOL49OF7XWB3',
b'ZQGKQCGHS67Q4IMHEG', b'OEXJQCQJHF2BLSAAIS', b'UKYJQC70LIZQ11BP89', 'ZQGKQCGHS67Q4IMHEG', 'OEXJQCQJHF2BLSAAIS', 'UKYJQC70LIZQ11BP89',
b'FF2KQCRBSPCG1QY97', b'L6EKQCO8QYL2UO2MQO', 'FF2KQCRBSPCG1QY97', 'L6EKQCO8QYL2UO2MQO',
])) ]))
def test_nevermarried(self): def test_nevermarried(self):
@ -560,8 +560,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = RelationshipPathBetweenBookmarks([]) rule = RelationshipPathBetweenBookmarks([])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'44WJQCLCQIPZUB0UH', b'35WJQC1B7T7NPV8OLV', b'AWFKQCJELLUWDY2PD3', '44WJQCLCQIPZUB0UH', '35WJQC1B7T7NPV8OLV', 'AWFKQCJELLUWDY2PD3',
b'D3WJQCCGV58IP8PNHZ', b'Q8HKQC3VMRM1M6M7ES', 'D3WJQCCGV58IP8PNHZ', 'Q8HKQC3VMRM1M6M7ES',
])) ]))
def test_hassoundexname(self): def test_hassoundexname(self):
@ -578,7 +578,7 @@ class BaseTest(unittest.TestCase):
rule = HasNameOf(['Lewis', 'Garner', 'Dr.', 'Sr', 'Anderson', rule = HasNameOf(['Lewis', 'Garner', 'Dr.', 'Sr', 'Anderson',
'Big Louie', 'von', 'Zieliński', None, None, None]) 'Big Louie', 'von', 'Zieliński', None, None, None])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'GNUJQCL9MD64AM56OH'])) 'GNUJQCL9MD64AM56OH']))
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -77,7 +77,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasCitation(['page 23', '', '']) rule = HasCitation(['page 23', '', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'YNUJQC8YM5EGRG868J'])) set(['YNUJQC8YM5EGRG868J']))
def test_hasgallery(self): def test_hasgallery(self):
""" """
@ -85,7 +85,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasGallery(['0', 'greater than']) rule = HasGallery(['0', 'greater than'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'YNUJQC8YM5EGRG868J'])) set(['YNUJQC8YM5EGRG868J']))
def test_hasidof(self): def test_hasidof(self):
""" """
@ -93,7 +93,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['P0001']) rule = HasIdOf(['P0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'c96587262e91149933fcea5f20a'])) set(['c96587262e91149933fcea5f20a']))
def test_regexpidof(self): def test_regexpidof(self):
""" """
@ -101,11 +101,11 @@ class BaseTest(unittest.TestCase):
""" """
rule = RegExpIdOf(['P000.'], use_regex=True) rule = RegExpIdOf(['P000.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'c96587262e91149933fcea5f20a', b'c96587262ff262aaac31f6db7af', 'c96587262e91149933fcea5f20a', 'c96587262ff262aaac31f6db7af',
b'c96587262f24c33ab2420276737', b'c96587262e566596a225682bf53', 'c96587262f24c33ab2420276737', 'c96587262e566596a225682bf53',
b'c9658726302661576894508202d', b'c96587262f8329d37b252e1b9e5', 'c9658726302661576894508202d', 'c96587262f8329d37b252e1b9e5',
b'c965872630664f33485fc18e75', b'c96587262fb7dbb954077cb1286', 'c965872630664f33485fc18e75', 'c96587262fb7dbb954077cb1286',
b'c96587262f4a44183c65ff1e52', b'c96587262ed43fdb37bf04bdb7f', 'c96587262f4a44183c65ff1e52', 'c96587262ed43fdb37bf04bdb7f',
])) ]))
def test_hasnote(self): def test_hasnote(self):
@ -128,9 +128,9 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasReferenceCountOf(['greater than', '35']) rule = HasReferenceCountOf(['greater than', '35'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'c96587262e566596a225682bf53', b'MATJQCJYH8ULRIRYTH', 'c96587262e566596a225682bf53', 'MATJQCJYH8ULRIRYTH',
b'5HTJQCSB91P69HY731', b'4ECKQCWCLO5YIHXEXC', '5HTJQCSB91P69HY731', '4ECKQCWCLO5YIHXEXC',
b'c965872630a68ebd32322c4a30a'])) 'c965872630a68ebd32322c4a30a']))
def test_hassourcecount(self): def test_hassourcecount(self):
""" """
@ -138,7 +138,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceCount(['1', 'equal to']) rule = HasSourceCount(['1', 'equal to'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'YNUJQC8YM5EGRG868J'])) set(['YNUJQC8YM5EGRG868J']))
def test_hassourceof(self): def test_hassourceof(self):
""" """
@ -146,7 +146,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasSourceOf(['S0001']) rule = HasSourceOf(['S0001'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'YNUJQC8YM5EGRG868J'])) set(['YNUJQC8YM5EGRG868J']))
def test_placeprivate(self): def test_placeprivate(self):
""" """
@ -161,7 +161,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = MatchesSourceConfidence(['2']) rule = MatchesSourceConfidence(['2'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'YNUJQC8YM5EGRG868J'])) set(['YNUJQC8YM5EGRG868J']))
def test_hasdata(self): def test_hasdata(self):
""" """
@ -169,7 +169,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasData(['Albany', 'County', '']) rule = HasData(['Albany', 'County', ''])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'c9658726d602acadb74e330116a'])) set(['c9658726d602acadb74e330116a']))
def test_hasnolatorlon(self): def test_hasnolatorlon(self):
""" """
@ -184,8 +184,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = InLatLonNeighborhood(['30N', '90W', '2', '2']) rule = InLatLonNeighborhood(['30N', '90W', '2', '2'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'C6WJQC0GDYP3HZDPR3', b'N88LQCRB363ES5WJ83', 'C6WJQC0GDYP3HZDPR3', 'N88LQCRB363ES5WJ83',
b'03EKQCC2KTNLHFLDRJ', b'M9VKQCJV91X0M12J8'])) '03EKQCC2KTNLHFLDRJ', 'M9VKQCJV91X0M12J8']))
def test_changedsince(self): def test_changedsince(self):
""" """
@ -207,8 +207,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasTitle(['Albany']) rule = HasTitle(['Albany'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'51VJQCXUP61H9JRL66', b'9XBKQCE1LZ7PMJE56G', '51VJQCXUP61H9JRL66', '9XBKQCE1LZ7PMJE56G',
b'c9658726d602acadb74e330116a', b'P9MKQCT08Z3YBJV5UB'])) 'c9658726d602acadb74e330116a', 'P9MKQCT08Z3YBJV5UB']))
def test_isenclosedby(self): def test_isenclosedby(self):
""" """
@ -216,9 +216,9 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsEnclosedBy(['P0001', '0']) rule = IsEnclosedBy(['P0001', '0'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'EAFKQCR0ED5QWL87EO', b'S22LQCLUZM135LVKRL', b'VDUJQCFP24ZV3O4ID2', 'EAFKQCR0ED5QWL87EO', 'S22LQCLUZM135LVKRL', 'VDUJQCFP24ZV3O4ID2',
b'V6ALQCZZFN996CO4D', b'OC6LQCXMKP6NUVYQD8', b'CUUKQC6BY5LAZXLXC6', 'V6ALQCZZFN996CO4D', 'OC6LQCXMKP6NUVYQD8', 'CUUKQC6BY5LAZXLXC6',
b'PTFKQCKPHO2VC5SYKS', b'PHUJQCJ9R4XQO5Y0WS'])) 'PTFKQCKPHO2VC5SYKS', 'PHUJQCJ9R4XQO5Y0WS']))
def test_withinarea(self): def test_withinarea(self):
""" """
@ -226,8 +226,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = WithinArea(['P1339', 100, 0]) rule = WithinArea(['P1339', 100, 0])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'KJUJQCY580EB77WIVO', b'TLVJQC4FD2CD9OYAXU', b'TE4KQCL9FDYA4PB6VW', 'KJUJQCY580EB77WIVO', 'TLVJQC4FD2CD9OYAXU', 'TE4KQCL9FDYA4PB6VW',
b'W9GLQCSRJIQ9N2TGDF'])) 'W9GLQCSRJIQ9N2TGDF']))
def test_isenclosedby_inclusive(self): def test_isenclosedby_inclusive(self):
""" """
@ -235,10 +235,10 @@ class BaseTest(unittest.TestCase):
""" """
rule = IsEnclosedBy(['P0001', '1']) rule = IsEnclosedBy(['P0001', '1'])
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'c96587262e91149933fcea5f20a', b'EAFKQCR0ED5QWL87EO', 'c96587262e91149933fcea5f20a', 'EAFKQCR0ED5QWL87EO',
b'S22LQCLUZM135LVKRL', b'VDUJQCFP24ZV3O4ID2', b'V6ALQCZZFN996CO4D', 'S22LQCLUZM135LVKRL', 'VDUJQCFP24ZV3O4ID2', 'V6ALQCZZFN996CO4D',
b'OC6LQCXMKP6NUVYQD8', b'CUUKQC6BY5LAZXLXC6', b'PTFKQCKPHO2VC5SYKS', 'OC6LQCXMKP6NUVYQD8', 'CUUKQC6BY5LAZXLXC6', 'PTFKQCKPHO2VC5SYKS',
b'PHUJQCJ9R4XQO5Y0WS'])) 'PHUJQCJ9R4XQO5Y0WS']))
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -72,7 +72,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasIdOf(['R0000']) rule = HasIdOf(['R0000'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'b39fe38593f3f8c4f12'])) set(['b39fe38593f3f8c4f12']))
def test_regexpidof(self): def test_regexpidof(self):
""" """
@ -80,8 +80,8 @@ class BaseTest(unittest.TestCase):
""" """
rule = RegExpIdOf(['R000.'], use_regex=True) rule = RegExpIdOf(['R000.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'a701ead12841521cd4d', b'a701e99f93e5434f6f3', 'a701ead12841521cd4d', 'a701e99f93e5434f6f3',
b'b39fe38593f3f8c4f12'])) 'b39fe38593f3f8c4f12']))
def test_hasnoteregexp(self): def test_hasnoteregexp(self):
""" """
@ -89,7 +89,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasNoteRegexp(['.'], use_regex=True) rule = HasNoteRegexp(['.'], use_regex=True)
self.assertEqual(self.filter_with_rule(rule), set([ self.assertEqual(self.filter_with_rule(rule), set([
b'a701ead12841521cd4d', b'b39fe38593f3f8c4f12'])) 'a701ead12841521cd4d', 'b39fe38593f3f8c4f12']))
def test_hasreferencecountof(self): def test_hasreferencecountof(self):
""" """
@ -97,7 +97,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = HasReferenceCountOf(['greater than', '1']) rule = HasReferenceCountOf(['greater than', '1'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a701e99f93e5434f6f3'])) set(['a701e99f93e5434f6f3']))
def test_repoprivate(self): def test_repoprivate(self):
""" """
@ -112,7 +112,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = ChangedSince(['2010-01-01', '2016-01-01']) rule = ChangedSince(['2010-01-01', '2016-01-01'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a701e99f93e5434f6f3'])) set(['a701e99f93e5434f6f3']))
def test_matchesnamesubstringof(self): def test_matchesnamesubstringof(self):
""" """
@ -120,7 +120,7 @@ class BaseTest(unittest.TestCase):
""" """
rule = MatchesNameSubstringOf(['Martha']) rule = MatchesNameSubstringOf(['Martha'])
self.assertEqual(self.filter_with_rule(rule), self.assertEqual(self.filter_with_rule(rule),
set([b'a701ead12841521cd4d'])) set(['a701ead12841521cd4d']))
def test_hastag(self): def test_hastag(self):
""" """

View File

@ -64,8 +64,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_person_from_handle(handle) self.cache_handle[handle] = self.db.get_person_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -75,8 +73,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_event_from_handle(handle) self.cache_handle[handle] = self.db.get_event_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -86,8 +82,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_family_from_handle(handle) self.cache_handle[handle] = self.db.get_family_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -97,8 +91,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_repository_from_handle(handle) self.cache_handle[handle] = self.db.get_repository_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -108,8 +100,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_place_from_handle(handle) self.cache_handle[handle] = self.db.get_place_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -119,8 +109,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_place_from_handle(handle) self.cache_handle[handle] = self.db.get_place_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -130,8 +118,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_citation_from_handle(handle) self.cache_handle[handle] = self.db.get_citation_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -141,8 +127,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_source_from_handle(handle) self.cache_handle[handle] = self.db.get_source_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -152,8 +136,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_note_from_handle(handle) self.cache_handle[handle] = self.db.get_note_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -163,8 +145,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_media_from_handle(handle) self.cache_handle[handle] = self.db.get_media_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]
@ -174,8 +154,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts Gets item from cache if it exists. Converts
handles to string, for uniformity. handles to string, for uniformity.
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle: if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_tag_from_handle(handle) self.cache_handle[handle] = self.db.get_tag_from_handle(handle)
return self.cache_handle[handle] return self.cache_handle[handle]

View File

@ -78,8 +78,6 @@ class FilterProxyDb(ProxyDbBase):
Finds a Person in the database from the passed Gramps ID. Finds a Person in the database from the passed Gramps ID.
If no such Person exists, None is returned. If no such Person exists, None is returned.
""" """
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.plist: if handle in self.plist:
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
if person is None: if person is None:
@ -117,23 +115,15 @@ class FilterProxyDb(ProxyDbBase):
return None return None
def include_person(self, handle): def include_person(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.plist return handle in self.plist
def include_family(self, handle): def include_family(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.flist return handle in self.flist
def include_event(self, handle): def include_event(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.elist return handle in self.elist
def include_note(self, handle): def include_note(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.nlist return handle in self.nlist
def get_source_from_handle(self, handle): def get_source_from_handle(self, handle):
@ -212,8 +202,6 @@ class FilterProxyDb(ProxyDbBase):
Finds a Event in the database from the passed Gramps ID. Finds a Event in the database from the passed Gramps ID.
If no such Event exists, None is returned. If no such Event exists, None is returned.
""" """
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.elist: if handle in self.elist:
event = self.db.get_event_from_handle(handle) event = self.db.get_event_from_handle(handle)
# Filter all notes out # Filter all notes out
@ -227,8 +215,6 @@ class FilterProxyDb(ProxyDbBase):
Finds a Family in the database from the passed Gramps ID. Finds a Family in the database from the passed Gramps ID.
If no such Family exists, None is returned. If no such Family exists, None is returned.
""" """
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.flist: if handle in self.flist:
family = self.db.get_family_from_handle(handle) family = self.db.get_family_from_handle(handle)
if family is None: if family is None:
@ -295,8 +281,6 @@ class FilterProxyDb(ProxyDbBase):
Finds a Note in the database from the passed Gramps ID. Finds a Note in the database from the passed Gramps ID.
If no such Note exists, None is returned. If no such Note exists, None is returned.
""" """
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.nlist: if handle in self.nlist:
return self.db.get_note_from_handle(handle) return self.db.get_note_from_handle(handle)
else: else:

View File

@ -58,7 +58,7 @@ class ProxyCursor:
def __iter__(self): def __iter__(self):
for handle in self.get_handles(): for handle in self.get_handles():
yield bytes(handle, "utf-8"), self.get_raw(handle) yield handle, self.get_raw(handle)
class ProxyMap: class ProxyMap:
""" """
@ -75,7 +75,7 @@ class ProxyMap:
def keys(self): def keys(self):
""" return the keys """ """ return the keys """
return [bytes(key, "utf-8") for key in self.get_keys()] return self.get_keys()
class ProxyDbBase(DbReadBase): class ProxyDbBase(DbReadBase):
""" """
@ -207,7 +207,7 @@ class ProxyDbBase(DbReadBase):
if (self.db is not None) and self.db.is_open(): if (self.db is not None) and self.db.is_open():
proxied = set(self.iter_person_handles()) proxied = set(self.iter_person_handles())
all = self.basedb.get_person_handles(sort_handles=sort_handles) all = self.basedb.get_person_handles(sort_handles=sort_handles)
return [hdl for hdl in all if str(hdl, 'utf-8') in proxied] return [hdl for hdl in all if hdl in proxied]
else: else:
return [] return []
@ -219,7 +219,7 @@ class ProxyDbBase(DbReadBase):
if (self.db is not None) and self.db.is_open(): if (self.db is not None) and self.db.is_open():
proxied = set(self.iter_family_handles()) proxied = set(self.iter_family_handles())
all = self.basedb.get_family_handles(sort_handles=sort_handles) all = self.basedb.get_family_handles(sort_handles=sort_handles)
return [hdl for hdl in all if str(hdl, 'utf-8') in proxied] return [hdl for hdl in all if hdl in proxied]
else: else:
return [] return []

View File

@ -212,9 +212,6 @@ class SidebarFilter(DbGUIElement):
if self.dbstate.is_open(): if self.dbstate.is_open():
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
if not isinstance(handle, str):
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

@ -310,10 +310,7 @@ class FlatNodeMap:
:type path: integer :type path: integer
:return handle: unicode form of the handle :return handle: unicode form of the handle
""" """
handle = self._index2hndl[self.real_index(path)][1] return self._index2hndl[self.real_index(path)][1]
if not isinstance(handle, str):
handle = handle.decode('utf-8')
return handle
def iter_next(self, iter): def iter_next(self, iter):
""" """
@ -567,7 +564,7 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
# use cursor as a context manager # use cursor as a context manager
with self.gen_cursor() as cursor: with self.gen_cursor() as cursor:
#loop over database and store the sort field, and the handle #loop over database and store the sort field, and the handle
srt_keys=[(self.sort_func(data), key.decode('utf8')) srt_keys=[(self.sort_func(data), key)
for key, data in cursor] for key, data in cursor]
srt_keys.sort() srt_keys.sort()
return srt_keys return srt_keys
@ -796,11 +793,6 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
val = self._get_value(handle, col) val = self._get_value(handle, col)
#print 'val is', val, type(val) #print 'val is', val, type(val)
#GTK 3 should convert unicode objects automatically, but this
# gives wrong column values, so we convert for python 2.7
if not isinstance(val, str):
return val.encode('utf-8')
else:
return val return val
def do_iter_previous(self, iter): def do_iter_previous(self, iter):

View File

@ -168,9 +168,6 @@ class PeopleBaseModel(BaseModel):
cached, name = self.get_cached_value(handle, "SORT_NAME") cached, name = self.get_cached_value(handle, "SORT_NAME")
if not cached: if not cached:
name = name_displayer.raw_sorted_name(data[COLUMN_NAME]) name = name_displayer.raw_sorted_name(data[COLUMN_NAME])
# internally we work with utf-8
if not isinstance(name, str):
name = name.decode('utf-8')
self.set_cached_value(handle, "SORT_NAME", name) self.set_cached_value(handle, "SORT_NAME", name)
return name return name
@ -179,9 +176,6 @@ class PeopleBaseModel(BaseModel):
cached, name = self.get_cached_value(handle, "NAME") cached, name = self.get_cached_value(handle, "NAME")
if not cached: if not cached:
name = name_displayer.raw_display_name(data[COLUMN_NAME]) name = name_displayer.raw_display_name(data[COLUMN_NAME])
# internally we work with utf-8 for python 2.7
if not isinstance(name, str):
name = name.encode('utf-8')
self.set_cached_value(handle, "NAME", name) self.set_cached_value(handle, "NAME", name)
return name return name
@ -629,8 +623,6 @@ 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, str):
# group_name = group_name.encode('utf-8')
sort_key = self.sort_func(data) sort_key = self.sort_func(data)
#if group_name not in self.group_list: #if group_name not in self.group_list:

View File

@ -537,9 +537,6 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
pmon.add_op(status) pmon.add_op(status)
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
if not isinstance(handle, str):
handle = handle.decode('utf-8')
status.heartbeat() status.heartbeat()
self.__total += 1 self.__total += 1
if not (handle in skip or (dfilter and not if not (handle in skip or (dfilter and not
@ -865,10 +862,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
not correspond to a gramps object. not correspond to a gramps object.
""" """
node = self.get_node_from_iter(iter) node = self.get_node_from_iter(iter)
handle = node.handle return node.handle
if handle and not isinstance(handle, str):
handle = handle.decode('utf-8')
return handle
# The following implement the public interface of Gtk.TreeModel # The following implement the public interface of Gtk.TreeModel
@ -904,7 +898,6 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
if node.handle is None: if node.handle is None:
# Header rows dont get the foreground color set # Header rows dont get the foreground color set
if col == self.color_column(): if col == self.color_column():
#color must not be utf-8
return "#000000000000" return "#000000000000"
# Return the node name for the first column # Return the node name for the first column
@ -917,13 +910,9 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
# return values for 'data' row, calling a function # return values for 'data' row, calling a function
# according to column_defs table # according to column_defs table
val = self._get_value(node.handle, col, node.secondary) val = self._get_value(node.handle, col, node.secondary)
#GTK 3 should convert unicode objects automatically, but this
# gives wrong column values, so convert for python 2.7
if val is None: if val is None:
return '' return ''
elif not isinstance(val, str):
return val.decode('utf-8')
else:
return val return val
def _get_value(self, handle, col, secondary=False, store_cache=True): def _get_value(self, handle, col, secondary=False, store_cache=True):

View File

@ -111,11 +111,7 @@ class BsddbBaseCursor:
_flags | flags | (db.DB_RMW if self._update else 0), _flags | flags | (db.DB_RMW if self._update else 0),
**kwargs) **kwargs)
try: return (data[0].decode('utf-8'), loads(data[1])) if data else None
return (data[0], loads(data[1])) if data else None
except UnicodeDecodeError:
#we need to assume we opened data in python3 saved in python2
return (data[0], loads(data[1], encoding='utf-8')) if data else None
return get return get

View File

@ -108,14 +108,11 @@ 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, str):
return surn.encode('utf-8') return surn.encode('utf-8')
return surn
def find_fullname(key, data): def find_fullname(key, data):
""" """
Creating a fullname from raw data of a person, to use for sort and index Creating a fullname from raw data of a person, to use for sort and index
returns a byte string
""" """
# data[3] -> primary_name # data[3] -> primary_name
# data[3][4] -> primary given # data[3][4] -> primary given
@ -140,7 +137,6 @@ def find_fullname(key, data):
def find_surname(key, data): def find_surname(key, data):
""" """
Creating a surname from raw data of a person, to use for sort and index Creating a surname from raw data of a person, to use for sort and index
returns a byte string
""" """
# data[3][5] -> surname_list # data[3][5] -> surname_list
return __index_surname(data[3][5]) return __index_surname(data[3][5])
@ -148,7 +144,6 @@ def find_surname(key, data):
def find_surname_name(key, data): def find_surname_name(key, data):
""" """
Creating a surname from raw name, to use for sort and index Creating a surname from raw name, to use for sort and index
returns a byte string
""" """
return __index_surname(data[5]) return __index_surname(data[5])
@ -156,7 +151,6 @@ def __index_surname(surn_list):
""" """
All non pa/matronymic surnames are used in indexing. All non pa/matronymic surnames are used in indexing.
pa/matronymic not as they change for every generation! pa/matronymic not as they change for every generation!
returns a byte string
""" """
if surn_list: if surn_list:
surn = " ".join([x[0] for x in surn_list if not (x[3][0] in [ surn = " ".join([x[0] for x in surn_list if not (x[3][0] in [
@ -196,11 +190,10 @@ class DbBsddbTreeCursor(BsddbBaseCursor):
Iterator Iterator
""" """
_n = self.next_dup _n = self.next_dup
to_do = [b''] to_do = ['']
while to_do: while to_do:
key = to_do.pop() key = to_do.pop()
key = key.encode('utf-8') if not isinstance(key, bytes) else key data = self.set(key.encode('utf-8'))
data = self.set(key)
while data: while data:
### FIXME: this is a dirty hack that works without no ### FIXME: this is a dirty hack that works without no
### sensible explanation. For some reason, for a readonly ### sensible explanation. For some reason, for a readonly
@ -629,12 +622,9 @@ class DbBsddbRead(DbReadBase, Callback):
Helper function for find_next_<object>_gramps_id methods Helper function for find_next_<object>_gramps_id methods
""" """
index = prefix % map_index index = prefix % map_index
#in bytes while trans.get(index.encode('utf-8'), txn=self.txn) is not None:
bindex = index.encode('utf-8')
while trans.get(bindex, txn=self.txn) is not None:
map_index += 1 map_index += 1
index = prefix % map_index index = prefix % map_index
bindex = index.encode('utf-8')
map_index += 1 map_index += 1
return (map_index, index) return (map_index, index)
@ -720,14 +710,12 @@ 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, str): data = data_map.get(handle.encode('utf-8'))
handle = handle.encode('utf-8')
data = data_map.get(handle)
if data: if data:
newobj = class_type() newobj = class_type()
newobj.unserialize(data) newobj.unserialize(data)
return newobj return newobj
raise HandleError('Handle %s not found' % handle.decode('utf-8')) raise HandleError('Handle %s not found' % handle)
def get_person_from_handle(self, handle): def get_person_from_handle(self, handle):
""" """
@ -812,10 +800,10 @@ 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, str): if val is None:
val = val.encode('utf-8') return None
try: try:
data = tbl.get(val, txn=self.txn) data = tbl.get(val.encode('utf-8'), txn=self.txn)
if data is not None: if data is not None:
obj = class_() obj = class_()
### FIXME: this is a dirty hack that works without no ### FIXME: this is a dirty hack that works without no
@ -929,15 +917,8 @@ 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, str):
key = surname.encode('utf-8') key = surname.encode('utf-8')
else: return self.name_group.get(key, surname)
key = surname
name_group = self.name_group.get(key, surname)
if isinstance(name_group, bytes):
return name_group.decode("utf-8")
else:
return name_group
def get_name_group_keys(self): def get_name_group_keys(self):
""" """
@ -951,7 +932,6 @@ 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, str):
name = name.encode('utf-8') name = name.encode('utf-8')
return name in self.name_group return name in self.name_group
@ -1036,12 +1016,10 @@ class DbBsddbRead(DbReadBase, Callback):
return True return True
def _all_handles(self, table): def _all_handles(self, table):
""" return all the keys of a database table
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
return table.keys(txn=self.txn) Return all the keys of a database table
"""
return [key.decode('utf-8') for key in table.keys(txn=self.txn)]
def get_person_handles(self, sort_handles=False): def get_person_handles(self, sort_handles=False):
""" """
@ -1049,9 +1027,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by surnames. If sort_handles is True, the list is sorted by surnames.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
handle_list = self._all_handles(self.person_map) handle_list = self._all_handles(self.person_map)
@ -1066,9 +1041,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by Place title. If sort_handles is True, the list is sorted by Place title.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
@ -1084,9 +1056,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by Source title. If sort_handles is True, the list is sorted by Source title.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
handle_list = self._all_handles(self.source_map) handle_list = self._all_handles(self.source_map)
@ -1101,9 +1070,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by Citation Volume/Page. If sort_handles is True, the list is sorted by Citation Volume/Page.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
handle_list = self._all_handles(self.citation_map) handle_list = self._all_handles(self.citation_map)
@ -1118,9 +1084,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by title. If sort_handles is True, the list is sorted by title.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
handle_list = self._all_handles(self.media_map) handle_list = self._all_handles(self.media_map)
@ -1133,9 +1096,6 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
Return a list of database handles, one handle for each Event in the Return a list of database handles, one handle for each Event in the
database. database.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
return self._all_handles(self.event_map) return self._all_handles(self.event_map)
@ -1147,9 +1107,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by surnames. If sort_handles is True, the list is sorted by surnames.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
handle_list = self._all_handles(self.family_map) handle_list = self._all_handles(self.family_map)
@ -1162,9 +1119,6 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
Return a list of database handles, one handle for each Repository in Return a list of database handles, one handle for each Repository in
the database. the database.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
return self._all_handles(self.repository_map) return self._all_handles(self.repository_map)
@ -1174,9 +1128,6 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
Return a list of database handles, one handle for each Note in the Return a list of database handles, one handle for each Note in the
database. database.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
return self._all_handles(self.note_map) return self._all_handles(self.note_map)
@ -1188,9 +1139,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database. the database.
If sort_handles is True, the list is sorted by Tag name. If sort_handles is True, the list is sorted by Tag name.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
""" """
if self.db_is_open: if self.db_is_open:
handle_list = self._all_handles(self.tag_map) handle_list = self._all_handles(self.tag_map)
@ -1206,7 +1154,7 @@ class DbBsddbRead(DbReadBase, Callback):
def g(self): def g(self):
with curs_(self) as cursor: with curs_(self) as cursor:
for key, data in cursor: for key, data in cursor:
yield key.decode('utf-8') yield key
return g return g
# Use closure to define iterators for each primary object type # Use closure to define iterators for each primary object type
@ -1279,7 +1227,6 @@ class DbBsddbRead(DbReadBase, Callback):
} }
table = key2table[obj_key] table = key2table[obj_key]
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
@ -1293,7 +1240,7 @@ class DbBsddbRead(DbReadBase, Callback):
@staticmethod @staticmethod
def _validated_id_prefix(val, default): def _validated_id_prefix(val, default):
if isinstance(val, str) and val: if val:
try: try:
str_ = val % 1 str_ = val % 1
except TypeError: # missing conversion specifier except TypeError: # missing conversion specifier
@ -1649,10 +1596,8 @@ 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, str):
handle = handle.encode('utf-8')
try: try:
return table.get(handle, txn=self.txn) return table.get(handle.encode('utf-8'), txn=self.txn)
except DBERRS as msg: except DBERRS as msg:
self.__log_error() self.__log_error()
raise DbError(msg) raise DbError(msg)
@ -1691,10 +1636,10 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
Helper function for has_<object>_handle methods Helper function for has_<object>_handle methods
""" """
if isinstance(handle, str): if handle is None:
handle = handle.encode('utf-8') return False
try: try:
return table.get(handle, txn=self.txn) is not None return table.get(handle.encode('utf-8'), txn=self.txn) is not None
except DBERRS as msg: except DBERRS as msg:
self.__log_error() self.__log_error()
raise DbError(msg) raise DbError(msg)
@ -1763,7 +1708,8 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
Helper function for has_<object>_gramps_id methods Helper function for has_<object>_gramps_id methods
""" """
if isinstance(gramps_id, str): if gramps_id is None:
return False
gramps_id = gramps_id.encode('utf-8') gramps_id = gramps_id.encode('utf-8')
try: try:
return id_map.get(gramps_id, txn=self.txn) is not None return id_map.get(gramps_id, txn=self.txn) is not None
@ -1826,104 +1772,85 @@ class DbBsddbRead(DbReadBase, Callback):
return self.__has_gramps_id(self.cid_trans, gramps_id) return self.__has_gramps_id(self.cid_trans, gramps_id)
def __sortbyperson_key(self, handle): def __sortbyperson_key(self, handle):
if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
return glocale.sort_key(find_fullname(handle, return glocale.sort_key(find_fullname(handle,
self.person_map.get(handle))) self.person_map.get(handle)))
def __sortbyfamily_key(self, handle): def __sortbyfamily_key(self, handle):
if isinstance(handle, str):
handle = handle.encode('utf-8') handle = handle.encode('utf-8')
data = self.family_map.get(handle) data = self.family_map.get(handle)
data2 = data[2] data2 = data[2]
if isinstance(data2, str):
data2 = data2.encode('utf-8')
data3 = data[3] data3 = data[3]
if isinstance(data3, str):
data3 = data3.encode('utf-8')
if data2: # father handle if data2: # father handle
data2 = data2.encode('utf-8')
return glocale.sort_key(find_fullname(data2, return glocale.sort_key(find_fullname(data2,
self.person_map.get(data2))) self.person_map.get(data2)))
elif data3: # mother handle elif data3: # mother handle
data3 = data3.encode('utf-8')
return glocale.sort_key(find_fullname(data3, return glocale.sort_key(find_fullname(data3,
self.person_map.get(data3))) self.person_map.get(data3)))
return '' return ''
def __sortbyplace(self, first, second): def __sortbyplace(self, first, second):
if isinstance(first, str):
first = first.encode('utf-8') first = first.encode('utf-8')
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, 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, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
source1 = str(self.source_map[first][2]) source1 = str(self.source_map[first][2])
source2 = str(self.source_map[second][2]) source2 = str(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, str):
key = key.encode('utf-8') key = key.encode('utf-8')
source = str(self.source_map[key][2]) source = str(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, str):
first = first.encode('utf-8') first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8') second = second.encode('utf-8')
citation1 = str(self.citation_map[first][3]) citation1 = str(self.citation_map[first][3])
citation2 = str(self.citation_map[second][3]) citation2 = str(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, str):
key = key.encode('utf-8') key = key.encode('utf-8')
citation = str(self.citation_map[key][3]) citation = str(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, str):
first = first.encode('utf-8') first = first.encode('utf-8')
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, 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, str):
first = first.encode('utf-8') first = first.encode('utf-8')
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, 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)
def set_mediapath(self, path): def set_mediapath(self, path):
"""Set the default media path for database, path should be utf-8.""" """Set the default media path for database."""
if (self.metadata is not None) and (not self.readonly): if (self.metadata is not None) and (not self.readonly):
self.metadata[b'mediapath'] = path self.metadata[b'mediapath'] = path

View File

@ -203,14 +203,14 @@ class CursorTest(unittest.TestCase):
def test_treecursor(self): def test_treecursor(self):
#fill with data #fill with data
the_txn = self.env.txn_begin() the_txn = self.env.txn_begin()
data = [(b'1', 'countryA', '' ), data = [('1', 'countryA', '' ),
(b'2', 'localityA', '1' ), ('2', 'localityA', '1' ),
(b'3', 'localityB', '1' ), ('3', 'localityB', '1' ),
(b'4', 'countryB', '' ), ('4', 'countryB', '' ),
(b'5', 'streetA', '2' ), ('5', 'streetA', '2' ),
(b'6', 'countryB', '' )] ('6', 'countryB', '' )]
for d in data: for d in data:
self.place_map.put(d[0], d, txn=the_txn) self.place_map.put(d[0].encode('utf-8'), d, txn=the_txn)
the_txn.commit() the_txn.commit()
cursor_txn = self.env.txn_begin() cursor_txn = self.env.txn_begin()

View File

@ -139,7 +139,7 @@ def find_idmap(key, data):
returns a byte string returns a byte string
""" """
val = data[1] val = data[1]
if isinstance(val, str): if val is not None:
val = val.encode('utf-8') val = val.encode('utf-8')
return val return val
@ -148,9 +148,7 @@ def find_parent(key, data):
val = data[5][0][0] val = data[5][0][0]
else: else:
val = '' val = ''
if isinstance(val, str): return val.encode('utf-8')
val = val.encode('utf-8')
return val
# Secondary database key lookups for reference_map table # Secondary database key lookups for reference_map table
# reference_map data values are of the form: # reference_map data values are of the form:
@ -162,18 +160,14 @@ def find_primary_handle(key, data):
returns byte string returns byte string
""" """
val = (data)[0][1] val = (data)[0][1]
if isinstance(val, str): return val.encode('utf-8')
val = val.encode('utf-8')
return val
def find_referenced_handle(key, data): def find_referenced_handle(key, data):
""" return handle for association of indexes """ return handle for association of indexes
returns byte string returns byte string
""" """
val = (data)[1][1] val = (data)[1][1]
if isinstance(val, str): return val.encode('utf-8')
val = val.encode('utf-8')
return val
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -344,9 +338,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
@catch_db_error @catch_db_error
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!
if isinstance(handle, str):
handle = handle.encode('utf-8')
if not self.readonly: if not self.readonly:
# Start transaction # Start transaction
with BSDDBTxn(self.env, self.metadata) as txn: with BSDDBTxn(self.env, self.metadata) as txn:
@ -370,7 +361,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
return None return None
def set_mediapath(self, path): def set_mediapath(self, path):
"""Set the default media path for database, path should be utf-8.""" """Set the default media path for database."""
if self.metadata and not self.readonly: if self.metadata and not self.readonly:
# Start transaction # Start transaction
with BSDDBTxn(self.env, self.metadata) as txn: with BSDDBTxn(self.env, self.metadata) as txn:
@ -973,12 +964,10 @@ 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, str):
handle = handle.encode('utf-8')
parent_cur = self.get_place_parent_cursor() parent_cur = self.get_place_parent_cursor()
try: try:
ret = parent_cur.set(handle) ret = parent_cur.set(handle.encode('utf-8'))
except: except:
ret = None ret = None
@ -1017,14 +1006,12 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
result_list = list(find_backlink_handles(handle)) result_list = list(find_backlink_handles(handle))
""" """
if isinstance(handle, str):
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.
referenced_cur = self._get_reference_map_referenced_cursor() referenced_cur = self._get_reference_map_referenced_cursor()
try: try:
ret = referenced_cur.set(handle) ret = referenced_cur.set(handle.encode('utf-8'))
except: except:
ret = None ret = None
@ -1103,11 +1090,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
handle = obj.handle handle = obj.handle
existing_references = set() existing_references = set()
primary_cur = self._get_reference_map_primary_cursor() primary_cur = self._get_reference_map_primary_cursor()
try:
if isinstance(handle, str):
key = handle.encode('utf-8') key = handle.encode('utf-8')
else: try:
key = handle
ret = primary_cur.set(key) ret = primary_cur.set(key)
except: except:
ret = None ret = None
@ -1164,7 +1148,6 @@ 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, 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:
@ -1181,7 +1164,6 @@ 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, 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
@ -1540,7 +1522,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if self.readonly or not handle: if self.readonly or not handle:
return return
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:
@ -1565,7 +1546,6 @@ 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, 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:
@ -1702,13 +1682,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
If not then we need to remove the name from the list. If not then we need to remove the name from the list.
The function must be overridden in the derived class. The function must be overridden in the derived class.
""" """
name = find_surname_name(person.handle, uname = find_surname_name(person.handle,
person.get_primary_name().serialize()) person.get_primary_name().serialize())
if isinstance(name, str): name = uname.encode('utf-8')
uname = name
name = name.encode('utf-8')
else:
uname = str(name)
try: try:
cursor = self.surnames.cursor(txn=self.txn) cursor = self.surnames.cursor(txn=self.txn)
cursor_position = cursor.set(name) cursor_position = cursor.set(name)
@ -1736,7 +1712,6 @@ 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, 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)
@ -1969,18 +1944,16 @@ 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, str):
handle = handle.encode('utf-8')
if handle is None: if handle is None:
raise HandleError('Handle is None') raise HandleError('Handle is None')
if not handle: if not handle:
raise HandleError('Handle is empty') raise HandleError('Handle is empty')
data = data_map.get(handle, txn=self.txn) data = data_map.get(handle.encode('utf-8'), txn=self.txn)
if data: if data:
newobj = class_type() newobj = class_type()
newobj.unserialize(data) newobj.unserialize(data)
return newobj return newobj
raise HandleError('Handle %s not found' % handle.decode('utf-8')) raise HandleError('Handle %s not found' % handle)
@catch_db_error @catch_db_error
def transaction_begin(self, transaction): def transaction_begin(self, transaction):

View File

@ -423,7 +423,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle FROM person") self.dbapi.execute("SELECT handle FROM person")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_family_handles(self, sort_handles=False): def get_family_handles(self, sort_handles=False):
""" """
@ -452,7 +452,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle FROM family") self.dbapi.execute("SELECT handle FROM family")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_event_handles(self): def get_event_handles(self):
""" """
@ -461,7 +461,7 @@ class DBAPI(DbGeneric):
""" """
self.dbapi.execute("SELECT handle FROM event") self.dbapi.execute("SELECT handle FROM event")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_citation_handles(self, sort_handles=False): def get_citation_handles(self, sort_handles=False):
""" """
@ -476,7 +476,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle FROM citation") self.dbapi.execute("SELECT handle FROM citation")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_source_handles(self, sort_handles=False): def get_source_handles(self, sort_handles=False):
""" """
@ -491,7 +491,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle from source") self.dbapi.execute("SELECT handle from source")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_place_handles(self, sort_handles=False): def get_place_handles(self, sort_handles=False):
""" """
@ -506,7 +506,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle FROM place") self.dbapi.execute("SELECT handle FROM place")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_repository_handles(self): def get_repository_handles(self):
""" """
@ -515,7 +515,7 @@ class DBAPI(DbGeneric):
""" """
self.dbapi.execute("SELECT handle FROM repository") self.dbapi.execute("SELECT handle FROM repository")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_media_handles(self, sort_handles=False): def get_media_handles(self, sort_handles=False):
""" """
@ -530,7 +530,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle FROM media") self.dbapi.execute("SELECT handle FROM media")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_note_handles(self): def get_note_handles(self):
""" """
@ -539,7 +539,7 @@ class DBAPI(DbGeneric):
""" """
self.dbapi.execute("SELECT handle FROM note") self.dbapi.execute("SELECT handle FROM note")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_tag_handles(self, sort_handles=False): def get_tag_handles(self, sort_handles=False):
""" """
@ -554,7 +554,7 @@ class DBAPI(DbGeneric):
else: else:
self.dbapi.execute("SELECT handle FROM tag") self.dbapi.execute("SELECT handle FROM tag")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
return [bytes(row[0], "utf-8") for row in rows] return [row[0] for row in rows]
def get_tag_from_name(self, name): def get_tag_from_name(self, name):
""" """
@ -678,8 +678,6 @@ class DBAPI(DbGeneric):
transaction.add(REFERENCE_KEY, TXNDEL, key, old_data, None) transaction.add(REFERENCE_KEY, TXNDEL, key, old_data, None)
def _do_remove(self, handle, transaction, obj_key): def _do_remove(self, handle, transaction, obj_key):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if self.readonly or not handle: if self.readonly or not handle:
return return
if self.has_handle(obj_key, handle): if self.has_handle(obj_key, handle):
@ -707,8 +705,6 @@ class DBAPI(DbGeneric):
result_list = list(find_backlink_handles(handle)) result_list = list(find_backlink_handles(handle))
""" """
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
self.dbapi.execute("SELECT obj_class, obj_handle " self.dbapi.execute("SELECT obj_class, obj_handle "
"FROM reference " "FROM reference "
"WHERE ref_handle = ?", "WHERE ref_handle = ?",
@ -755,7 +751,7 @@ class DBAPI(DbGeneric):
rows = cursor.fetchmany() rows = cursor.fetchmany()
while rows: while rows:
for row in rows: for row in rows:
yield (row[0].encode('utf8'), pickle.loads(row[1])) yield (row[0], pickle.loads(row[1]))
rows = cursor.fetchmany() rows = cursor.fetchmany()
def _iter_raw_place_tree_data(self): def _iter_raw_place_tree_data(self):
@ -770,7 +766,7 @@ class DBAPI(DbGeneric):
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
for row in rows: for row in rows:
to_do.append(row[0]) to_do.append(row[0])
yield (row[0].encode('utf8'), pickle.loads(row[1])) yield (row[0], pickle.loads(row[1]))
def reindex_reference_map(self, callback): def reindex_reference_map(self, callback):
""" """
@ -821,8 +817,6 @@ class DBAPI(DbGeneric):
self.genderStats = GenderStats(gstats) self.genderStats = GenderStats(gstats)
def has_handle(self, obj_key, handle): def has_handle(self, obj_key, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
table = KEY_TO_NAME_MAP[obj_key] table = KEY_TO_NAME_MAP[obj_key]
sql = "SELECT 1 FROM %s WHERE handle = ?" % table sql = "SELECT 1 FROM %s WHERE handle = ?" % table
self.dbapi.execute(sql, [handle]) self.dbapi.execute(sql, [handle])
@ -842,8 +836,6 @@ class DBAPI(DbGeneric):
return [row[0] for row in rows] return [row[0] for row in rows]
def get_raw_data(self, obj_key, handle): def get_raw_data(self, obj_key, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
table = KEY_TO_NAME_MAP[obj_key] table = KEY_TO_NAME_MAP[obj_key]
sql = "SELECT blob_data FROM %s WHERE handle = ?" % table sql = "SELECT blob_data FROM %s WHERE handle = ?" % table
self.dbapi.execute(sql, [handle]) self.dbapi.execute(sql, [handle])

View File

@ -152,7 +152,7 @@ class DbRandomTest(unittest.TestCase):
handles = handles_func() handles = handles_func()
self.assertEqual(len(handles), number_func()) self.assertEqual(len(handles), number_func())
for handle in handles: for handle in handles:
self.assertIn(handle.decode('utf8'), self.handles[obj_type]) self.assertIn(handle, self.handles[obj_type])
def test_get_person_handles(self): def test_get_person_handles(self):
self.__get_handles_test('Person', self.__get_handles_test('Person',
@ -312,7 +312,7 @@ class DbRandomTest(unittest.TestCase):
for handle in handles_func(): for handle in handles_func():
person = get_func(handle) person = get_func(handle)
self.assertIsInstance(person, obj_class) self.assertIsInstance(person, obj_class)
self.assertEqual(person.handle, handle.decode('utf8')) self.assertEqual(person.handle, handle)
def test_get_person_from_handle(self): def test_get_person_from_handle(self):
self.__get_from_handle_test(Person, self.__get_from_handle_test(Person,

View File

@ -763,7 +763,7 @@ class ProgenParser(UpdateCallback):
# create a new Person # create a new Person
gramps_id = self.dbase.id2user_format("I%05d" % progen_id) gramps_id = self.dbase.id2user_format("I%05d" % progen_id)
# make sure that gramps_id are bytes ... # make sure that gramps_id are bytes ...
if self.dbase.has_person_gramps_id(gramps_id.encode('utf-8')): if self.dbase.has_person_gramps_id(gramps_id):
gramps_id = self.dbase.find_next_person_gramps_id() gramps_id = self.dbase.find_next_person_gramps_id()
intid = _find_from_handle(progen_id, self.gid2id) intid = _find_from_handle(progen_id, self.gid2id)
person.set_handle(intid) person.set_handle(intid)
@ -783,7 +783,7 @@ class ProgenParser(UpdateCallback):
# create a new Family # create a new Family
gramps_id = self.dbase.fid2user_format("F%04d" % progen_id) gramps_id = self.dbase.fid2user_format("F%04d" % progen_id)
# make sure that gramps_id are bytes ... # make sure that gramps_id are bytes ...
if self.dbase.has_family_gramps_id(gramps_id.encode('utf-8')): if self.dbase.has_family_gramps_id(gramps_id):
gramps_id = self.dbase.find_next_family_gramps_id() gramps_id = self.dbase.find_next_family_gramps_id()
intid = _find_from_handle(progen_id, self.fid2id) intid = _find_from_handle(progen_id, self.fid2id)
family.set_handle(intid) family.set_handle(intid)
@ -1063,7 +1063,7 @@ class ProgenParser(UpdateCallback):
# Hmmm. Just use the plain text. # Hmmm. Just use the plain text.
LOG.warning(_("Date did not match: '%(text)s' (%(msg)s)"), \ LOG.warning(_("Date did not match: '%(text)s' (%(msg)s)"), \
{'text' : date_text.encode('utf-8'), 'msg' : diag_msg or ''}) {'text' : date_text, 'msg' : diag_msg or ''})
date.set_as_text(date_text) date.set_as_text(date_text)
return date return date
@ -1197,9 +1197,7 @@ class ProgenParser(UpdateCallback):
self.__add_tag('Person', person) self.__add_tag('Person', person)
# create diagnose message # create diagnose message
diag_msg = "%s: %s %s" % (person.gramps_id, diag_msg = "%s: %s %s" % (person.gramps_id, first_name, sur_name)
first_name.encode('utf-8'),
sur_name.encode('utf-8'))
# prcesss F25 Birth Date # prcesss F25 Birth Date
birth_date = self.__create_date_from_text \ birth_date = self.__create_date_from_text \

View File

@ -1627,11 +1627,10 @@ class IdFinder:
@rtype: str @rtype: str
""" """
index = self.prefix % self.index index = self.prefix % self.index
# self.ids contains 'bytes' data while index in self.ids:
while index.encode('utf-8') in self.ids:
self.index += 1 self.index += 1
index = self.prefix % self.index index = self.prefix % self.index
self.ids.add(index.encode('utf-8')) self.ids.add(index)
self.index += 1 self.index += 1
return index return index

View File

@ -357,8 +357,7 @@ class CheckIntegrity:
logging.info('Looking for duplicate spouses') logging.info('Looking for duplicate spouses')
previous_errors = len(self.duplicate_links) previous_errors = len(self.duplicate_links)
for bhandle in self.db.get_person_handles(): for handle in self.db.get_person_handles():
handle = bhandle.decode('utf-8')
pers = self.db.get_person_from_handle(handle) pers = self.db.get_person_from_handle(handle)
splist = pers.get_family_handle_list() splist = pers.get_family_handle_list()
if len(splist) != len(set(splist)): if len(splist) != len(set(splist)):
@ -379,8 +378,7 @@ class CheckIntegrity:
self.db.get_number_of_media()) self.db.get_number_of_media())
logging.info('Looking for character encoding errors') logging.info('Looking for character encoding errors')
error_count = 0 error_count = 0
for bhandle in self.db.get_media_handles(): for handle in self.db.get_media_handles():
handle = bhandle.decode('utf-8')
data = self.db.get_raw_media_data(handle) data = self.db.get_raw_media_data(handle)
if not isinstance(data[2], str) or not isinstance(data[4], str): if not isinstance(data[2], str) or not isinstance(data[4], str):
obj = self.db.get_media_from_handle(handle) obj = self.db.get_media_from_handle(handle)
@ -420,8 +418,7 @@ class CheckIntegrity:
self.db.get_number_of_notes()) self.db.get_number_of_notes())
logging.info('Looking for ctrl characters in notes') logging.info('Looking for ctrl characters in notes')
error_count = 0 error_count = 0
for bhandle in self.db.get_note_handles(): for handle in self.db.get_note_handles():
handle = bhandle.decode('utf-8')
note = self.db.get_note_from_handle(handle) note = self.db.get_note_from_handle(handle)
stext = note.get_styledtext() stext = note.get_styledtext()
old_text = str(stext) old_text = str(stext)
@ -447,8 +444,7 @@ class CheckIntegrity:
self.progress.set_pass(_('Looking for bad alternate place names'), self.progress.set_pass(_('Looking for bad alternate place names'),
self.db.get_number_of_places()) self.db.get_number_of_places())
logging.info('Looking for bad alternate place names') logging.info('Looking for bad alternate place names')
for bhandle in self.db.get_place_handles(): for handle in self.db.get_place_handles():
handle = bhandle.decode('utf-8')
place = self.db.get_place_from_handle(handle) place = self.db.get_place_from_handle(handle)
fixed_alt_names = [] fixed_alt_names = []
fixup = False fixup = False
@ -480,8 +476,7 @@ class CheckIntegrity:
logging.info('Looking for broken family links') logging.info('Looking for broken family links')
previous_errors = len(self.broken_parent_links + self.broken_links) previous_errors = len(self.broken_parent_links + self.broken_links)
for bfamily_handle in fhandle_list: for family_handle in fhandle_list:
family_handle = bfamily_handle.decode('utf-8')
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
@ -612,8 +607,7 @@ class CheckIntegrity:
self.progress.step() self.progress.step()
# Check persons membership in referenced families # Check persons membership in referenced families
for bperson_handle in self.db.get_person_handles(): for person_handle in self.db.get_person_handles():
person_handle = bperson_handle.decode('utf-8')
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
phandle_list = person.get_parent_family_handle_list() phandle_list = person.get_parent_family_handle_list()
@ -778,8 +772,7 @@ class CheckIntegrity:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
for bobjectid in self.db.get_media_handles(): for objectid in self.db.get_media_handles():
objectid = bobjectid.decode('utf-8')
obj = self.db.get_media_from_handle(objectid) obj = self.db.get_media_from_handle(objectid)
photo_name = media_path_full(self.db, obj.get_path()) photo_name = media_path_full(self.db, obj.get_path())
photo_desc = obj.get_description() photo_desc = obj.get_description()
@ -985,8 +978,7 @@ class CheckIntegrity:
len(fhandle_list)) len(fhandle_list))
logging.info('Looking for empty families') logging.info('Looking for empty families')
previous_errors = len(self.empty_family) previous_errors = len(self.empty_family)
for bfamily_handle in fhandle_list: for family_handle in fhandle_list:
family_handle = bfamily_handle.decode('utf-8')
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
@ -1022,8 +1014,7 @@ class CheckIntegrity:
logging.info('Looking for broken parent relationships') logging.info('Looking for broken parent relationships')
previous_errors = len(self.fam_rel) previous_errors = len(self.fam_rel)
for bfamily_handle in fhandle_list: for family_handle in fhandle_list:
family_handle = bfamily_handle.decode('utf-8')
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
@ -1062,8 +1053,7 @@ class CheckIntegrity:
self.db.get_number_of_families()) self.db.get_number_of_families())
logging.info('Looking for event problems') logging.info('Looking for event problems')
for bkey in self.db.get_person_handles(sort_handles=False): for key in self.db.get_person_handles(sort_handles=False):
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(key) person = self.db.get_person_from_handle(key)
@ -1184,8 +1174,7 @@ class CheckIntegrity:
self.db.commit_person(person, self.trans) self.db.commit_person(person, self.trans)
self.invalid_events.add(key) self.invalid_events.add(key)
for bkey in self.db.get_family_handles(): for key in self.db.get_family_handles():
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(key) family = self.db.get_family_from_handle(key)
if family.get_event_ref_list(): if family.get_event_ref_list():
@ -1234,8 +1223,7 @@ class CheckIntegrity:
len(plist)) len(plist))
logging.info('Looking for person reference problems') logging.info('Looking for person reference problems')
for bkey in plist: for key in plist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
none_handle = False none_handle = False
newlist = [] newlist = []
@ -1268,8 +1256,7 @@ class CheckIntegrity:
len(plist)) len(plist))
logging.info('Looking for family reference problems') logging.info('Looking for family reference problems')
for bkey in plist: for key in plist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(key) person = self.db.get_person_from_handle(key)
for ordinance in person.get_lds_ord_list(): for ordinance in person.get_lds_ord_list():
@ -1295,8 +1282,7 @@ class CheckIntegrity:
len(slist)) len(slist))
logging.info('Looking for repository reference problems') logging.info('Looking for repository reference problems')
for bkey in slist: for key in slist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
none_handle = False none_handle = False
newlist = [] newlist = []
@ -1331,8 +1317,7 @@ class CheckIntegrity:
len(elist) + len(plist) + len(flist) + len(llist)) len(elist) + len(plist) + len(flist) + len(llist))
logging.info('Looking for place reference problems') logging.info('Looking for place reference problems')
for bkey in llist: for key in llist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
none_handle = False none_handle = False
newlist = [] newlist = []
@ -1360,8 +1345,7 @@ class CheckIntegrity:
self.db.commit_place(place, self.trans) self.db.commit_place(place, self.trans)
# check persons -> the LdsOrd references a place # check persons -> the LdsOrd references a place
for bkey in plist: for key in plist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(key) person = self.db.get_person_from_handle(key)
for ordinance in person.lds_ord_list: for ordinance in person.lds_ord_list:
@ -1383,8 +1367,7 @@ class CheckIntegrity:
'hand': place_handle}) 'hand': place_handle})
self.invalid_place_references.add(key) self.invalid_place_references.add(key)
# check families -> the LdsOrd references a place # check families -> the LdsOrd references a place
for bkey in flist: for key in flist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(key) family = self.db.get_family_from_handle(key)
for ordinance in family.lds_ord_list: for ordinance in family.lds_ord_list:
@ -1404,8 +1387,7 @@ class CheckIntegrity:
'hand': place_handle}) 'hand': place_handle})
self.invalid_place_references.add(key) self.invalid_place_references.add(key)
# check events # check events
for bkey in elist: for key in elist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
event = self.db.get_event_from_handle(key) event = self.db.get_event_from_handle(key)
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
@ -1429,8 +1411,7 @@ class CheckIntegrity:
def check_citation_references(self): def check_citation_references(self):
'''Looking for citation reference problems''' '''Looking for citation reference problems'''
known_handles = [key.decode('utf-8') for key in known_handles = self.db.get_citation_handles()
self.db.get_citation_handles()]
total = ( total = (
self.db.get_number_of_people() + self.db.get_number_of_people() +
@ -1447,9 +1428,9 @@ class CheckIntegrity:
total) total)
logging.info('Looking for citation reference problems') logging.info('Looking for citation reference problems')
for bhandle in self.db.get_person_handles(): for handle in self.db.get_person_handles():
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(bhandle) person = self.db.get_person_from_handle(handle)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1461,9 +1442,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.get_family_handles(): for handle in self.db.get_family_handles():
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(bhandle) family = self.db.get_family_from_handle(handle)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1475,9 +1456,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.get_place_handles(): for handle in self.db.get_place_handles():
self.progress.step() self.progress.step()
place = self.db.get_place_from_handle(bhandle) place = self.db.get_place_from_handle(handle)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1489,9 +1470,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.get_citation_handles(): for handle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
citation = self.db.get_citation_from_handle(bhandle) citation = self.db.get_citation_from_handle(handle)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1503,9 +1484,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.get_repository_handles(): for handle in self.db.get_repository_handles():
self.progress.step() self.progress.step()
repository = self.db.get_repository_from_handle(bhandle) repository = self.db.get_repository_from_handle(handle)
handle_list = repository.get_referenced_handles_recursively() handle_list = repository.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1518,9 +1499,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.get_media_handles(): for handle in self.db.get_media_handles():
self.progress.step() self.progress.step()
obj = self.db.get_media_from_handle(bhandle) obj = self.db.get_media_from_handle(handle)
handle_list = obj.get_referenced_handles_recursively() handle_list = obj.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1532,9 +1513,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.get_event_handles(): for handle in self.db.get_event_handles():
self.progress.step() self.progress.step()
event = self.db.get_event_from_handle(bhandle) event = self.db.get_event_from_handle(handle)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1565,8 +1546,7 @@ class CheckIntegrity:
len(clist)) len(clist))
logging.info('Looking for source reference problems') logging.info('Looking for source reference problems')
for bkey in clist: for key in clist:
key = bkey.decode('utf-8')
self.progress.step() self.progress.step()
citation = self.db.get_citation_from_handle(key) citation = self.db.get_citation_from_handle(key)
source_handle = citation.get_reference_handle() source_handle = citation.get_reference_handle()
@ -1593,8 +1573,7 @@ class CheckIntegrity:
def check_media_references(self): def check_media_references(self):
'''Looking for media object reference problems''' '''Looking for media object reference problems'''
known_handles = [key.decode('utf-8') for key in known_handles = self.db.get_media_handles(False)
self.db.get_media_handles(False)]
total = ( total = (
self.db.get_number_of_people() + self.db.get_number_of_people() +
@ -1609,9 +1588,9 @@ class CheckIntegrity:
'problems'), total) 'problems'), total)
logging.info('Looking for media object reference problems') logging.info('Looking for media object reference problems')
for bhandle in self.db.get_person_handles(): for handle in self.db.get_person_handles():
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(bhandle) person = self.db.get_person_from_handle(handle)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1623,9 +1602,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.get_family_handles(): for handle in self.db.get_family_handles():
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(bhandle) family = self.db.get_family_from_handle(handle)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1637,9 +1616,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.get_place_handles(): for handle in self.db.get_place_handles():
self.progress.step() self.progress.step()
place = self.db.get_place_from_handle(bhandle) place = self.db.get_place_from_handle(handle)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1651,9 +1630,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.get_event_handles(): for handle in self.db.get_event_handles():
self.progress.step() self.progress.step()
event = self.db.get_event_from_handle(bhandle) event = self.db.get_event_from_handle(handle)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1665,9 +1644,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.get_citation_handles(): for handle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
citation = self.db.get_citation_from_handle(bhandle) citation = self.db.get_citation_from_handle(handle)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1679,9 +1658,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.get_source_handles(): for handle in self.db.get_source_handles():
self.progress.step() self.progress.step()
source = self.db.get_source_from_handle(bhandle) source = self.db.get_source_from_handle(handle)
handle_list = source.get_referenced_handles_recursively() handle_list = source.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1716,8 +1695,7 @@ class CheckIntegrity:
if missing_references: if missing_references:
self.db.add_note(self.explanation, self.trans, set_gid=True) self.db.add_note(self.explanation, self.trans, set_gid=True)
known_handles = [key.decode('utf-8') for key in known_handles = self.db.get_note_handles()
self.db.get_note_handles()]
total = (self.db.get_number_of_people() + total = (self.db.get_number_of_people() +
self.db.get_number_of_families() + self.db.get_number_of_families() +
@ -1732,9 +1710,9 @@ class CheckIntegrity:
total) total)
logging.info('Looking for note reference problems') logging.info('Looking for note reference problems')
for bhandle in self.db.get_person_handles(): for handle in self.db.get_person_handles():
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(bhandle) person = self.db.get_person_from_handle(handle)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1746,9 +1724,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_family_handles(): for handle in self.db.get_family_handles():
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(bhandle) family = self.db.get_family_from_handle(handle)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1760,9 +1738,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_place_handles(): for handle in self.db.get_place_handles():
self.progress.step() self.progress.step()
place = self.db.get_place_from_handle(bhandle) place = self.db.get_place_from_handle(handle)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1774,9 +1752,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_citation_handles(): for handle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
citation = self.db.get_citation_from_handle(bhandle) citation = self.db.get_citation_from_handle(handle)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1788,9 +1766,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_source_handles(): for handle in self.db.get_source_handles():
self.progress.step() self.progress.step()
source = self.db.get_source_from_handle(bhandle) source = self.db.get_source_from_handle(handle)
handle_list = source.get_referenced_handles_recursively() handle_list = source.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1802,9 +1780,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_media_handles(): for handle in self.db.get_media_handles():
self.progress.step() self.progress.step()
obj = self.db.get_media_from_handle(bhandle) obj = self.db.get_media_from_handle(handle)
handle_list = obj.get_referenced_handles_recursively() handle_list = obj.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1816,9 +1794,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_event_handles(): for handle in self.db.get_event_handles():
self.progress.step() self.progress.step()
event = self.db.get_event_from_handle(bhandle) event = self.db.get_event_from_handle(handle)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1830,9 +1808,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.get_repository_handles(): for handle in self.db.get_repository_handles():
self.progress.step() self.progress.step()
repo = self.db.get_repository_from_handle(bhandle) repo = self.db.get_repository_from_handle(handle)
handle_list = repo.get_referenced_handles_recursively() handle_list = repo.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1858,9 +1836,8 @@ class CheckIntegrity:
''' fix media checksums ''' ''' fix media checksums '''
self.progress.set_pass(_('Updating checksums on media'), self.progress.set_pass(_('Updating checksums on media'),
len(self.db.get_media_handles())) len(self.db.get_media_handles()))
for bobjectid in self.db.get_media_handles(): for objectid in self.db.get_media_handles():
self.progress.step() self.progress.step()
objectid = bobjectid.decode('utf-8')
obj = self.db.get_media_from_handle(objectid) obj = self.db.get_media_from_handle(objectid)
full_path = media_path_full(self.db, obj.get_path()) full_path = media_path_full(self.db, obj.get_path())
new_checksum = create_checksum(full_path) new_checksum = create_checksum(full_path)
@ -1871,8 +1848,7 @@ class CheckIntegrity:
def check_tag_references(self): def check_tag_references(self):
'''Looking for tag reference problems''' '''Looking for tag reference problems'''
known_handles = [key.decode('utf-8') for key in known_handles = self.db.get_tag_handles()
self.db.get_tag_handles()]
total = (self.db.get_number_of_people() + total = (self.db.get_number_of_people() +
self.db.get_number_of_families() + self.db.get_number_of_families() +
@ -1888,9 +1864,9 @@ class CheckIntegrity:
total) total)
logging.info('Looking for tag reference problems') logging.info('Looking for tag reference problems')
for bhandle in self.db.get_person_handles(): for handle in self.db.get_person_handles():
self.progress.step() self.progress.step()
person = self.db.get_person_from_handle(bhandle) person = self.db.get_person_from_handle(handle)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1902,9 +1878,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_family_handles(): for handle in self.db.get_family_handles():
self.progress.step() self.progress.step()
family = self.db.get_family_from_handle(bhandle) family = self.db.get_family_from_handle(handle)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1916,9 +1892,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_media_handles(): for handle in self.db.get_media_handles():
self.progress.step() self.progress.step()
obj = self.db.get_media_from_handle(bhandle) obj = self.db.get_media_from_handle(handle)
handle_list = obj.get_referenced_handles_recursively() handle_list = obj.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1930,9 +1906,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_note_handles(): for handle in self.db.get_note_handles():
self.progress.step() self.progress.step()
note = self.db.get_note_from_handle(bhandle) note = self.db.get_note_from_handle(handle)
handle_list = note.get_referenced_handles_recursively() handle_list = note.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1944,9 +1920,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_event_handles(): for handle in self.db.get_event_handles():
self.progress.step() self.progress.step()
event = self.db.get_event_from_handle(bhandle) event = self.db.get_event_from_handle(handle)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1958,9 +1934,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_citation_handles(): for handle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
citation = self.db.get_citation_from_handle(bhandle) citation = self.db.get_citation_from_handle(handle)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1972,9 +1948,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_source_handles(): for handle in self.db.get_source_handles():
self.progress.step() self.progress.step()
source = self.db.get_source_from_handle(bhandle) source = self.db.get_source_from_handle(handle)
handle_list = source.get_referenced_handles_recursively() handle_list = source.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1986,9 +1962,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_place_handles(): for handle in self.db.get_place_handles():
self.progress.step() self.progress.step()
place = self.db.get_place_from_handle(bhandle) place = self.db.get_place_from_handle(handle)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -2000,9 +1976,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.get_repository_handles(): for handle in self.db.get_repository_handles():
self.progress.step() self.progress.step()
repository = self.db.get_repository_from_handle(bhandle) repository = self.db.get_repository_from_handle(handle)
handle_list = repository.get_referenced_handles_recursively() handle_list = repository.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':

View File

@ -291,8 +291,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
for handle, data in cursor: for handle, data in cursor:
if not any(h for h in fbh(handle)): if not any(h for h in fbh(handle)):
if handle not in todo_list and handle not in link_list: if handle not in todo_list and handle not in link_list:
self.add_results((the_type, handle.decode('utf-8'), self.add_results((the_type, handle, data))
data))
self.update() self.update()
self.reset() self.reset()

View File

@ -5226,12 +5226,8 @@ class MediaPages(BasePage):
# add unused media # add unused media
media_list = self.r_db.get_media_handles() media_list = self.r_db.get_media_handles()
for media_ref in media_list: for media_ref in media_list:
if isinstance(media_ref, bytes): if media_ref not in self.report.obj_dict[Media]:
media_handle = media_ref.decode("utf-8") unused_media_handles.append(media_ref)
else:
media_handle = media_ref
if media_handle not in self.report.obj_dict[Media]:
unused_media_handles.append(media_handle)
unused_media_handles = sorted( unused_media_handles = sorted(
unused_media_handles, unused_media_handles,
key=lambda x: sort_by_desc_and_gid( key=lambda x: sort_by_desc_and_gid(
@ -5677,12 +5673,8 @@ class ThumbnailPreviewPage(BasePage):
media_list = self.r_db.get_media_handles() media_list = self.r_db.get_media_handles()
unused_media_handles = [] unused_media_handles = []
for media_ref in media_list: for media_ref in media_list:
if isinstance(media_ref, bytes): if media_ref not in self.report.obj_dict[Media]:
media_handle = media_ref.decode("utf-8") self.photo_keys.append(media_ref)
else:
media_handle = media_ref
if media_handle not in self.report.obj_dict[Media]:
self.photo_keys.append(media_handle)
media_list = [] media_list = []
for person_handle in self.photo_keys: for person_handle in self.photo_keys:
@ -8706,10 +8698,6 @@ class NavWebReport(Report):
_('Constructing list of other objects...'), _('Constructing list of other objects...'),
sum(1 for _ in ind_list)) as step: sum(1 for _ in ind_list)) as step:
for handle in ind_list: 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, str):
handle = handle.decode('utf-8')
step() step()
self._add_person(handle, "", "") self._add_person(handle, "", "")