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):
"""
Set the default media path for database, path should be utf-8.
Set the default media path for database.
"""
raise NotImplementedError

View File

@ -526,7 +526,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -670,7 +670,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -782,7 +782,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -829,7 +829,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -887,7 +887,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -907,7 +907,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -916,7 +916,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -925,7 +925,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -934,7 +934,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -943,7 +943,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -952,7 +952,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -961,7 +961,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -970,7 +970,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -979,7 +979,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -988,7 +988,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -1026,7 +1026,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -1097,7 +1097,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -1155,7 +1155,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -1193,7 +1193,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
if not self.db_is_open:
LOG.warning("database is closed")
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):
"""
@ -1611,7 +1611,7 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
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:
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):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle is None:
raise HandleError('Handle is None')
if not handle:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -64,8 +64,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_person_from_handle(handle)
return self.cache_handle[handle]
@ -75,8 +73,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_event_from_handle(handle)
return self.cache_handle[handle]
@ -86,8 +82,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_family_from_handle(handle)
return self.cache_handle[handle]
@ -97,8 +91,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_repository_from_handle(handle)
return self.cache_handle[handle]
@ -108,8 +100,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_place_from_handle(handle)
return self.cache_handle[handle]
@ -119,8 +109,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_place_from_handle(handle)
return self.cache_handle[handle]
@ -130,8 +118,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_citation_from_handle(handle)
return self.cache_handle[handle]
@ -141,8 +127,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_source_from_handle(handle)
return self.cache_handle[handle]
@ -152,8 +136,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_note_from_handle(handle)
return self.cache_handle[handle]
@ -163,8 +145,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_media_from_handle(handle)
return self.cache_handle[handle]
@ -174,8 +154,6 @@ class CacheProxyDb:
Gets item from cache if it exists. Converts
handles to string, for uniformity.
"""
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
if handle not in self.cache_handle:
self.cache_handle[handle] = self.db.get_tag_from_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.
If no such Person exists, None is returned.
"""
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.plist:
person = self.db.get_person_from_handle(handle)
if person is None:
@ -117,23 +115,15 @@ class FilterProxyDb(ProxyDbBase):
return None
def include_person(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.plist
def include_family(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.flist
def include_event(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.elist
def include_note(self, handle):
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
return handle in self.nlist
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.
If no such Event exists, None is returned.
"""
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.elist:
event = self.db.get_event_from_handle(handle)
# Filter all notes out
@ -227,8 +215,6 @@ class FilterProxyDb(ProxyDbBase):
Finds a Family in the database from the passed Gramps ID.
If no such Family exists, None is returned.
"""
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.flist:
family = self.db.get_family_from_handle(handle)
if family is None:
@ -295,8 +281,6 @@ class FilterProxyDb(ProxyDbBase):
Finds a Note in the database from the passed Gramps ID.
If no such Note exists, None is returned.
"""
if isinstance(handle, bytes):
handle = str(handle, 'utf-8')
if handle in self.nlist:
return self.db.get_note_from_handle(handle)
else:

View File

@ -58,7 +58,7 @@ class ProxyCursor:
def __iter__(self):
for handle in self.get_handles():
yield bytes(handle, "utf-8"), self.get_raw(handle)
yield handle, self.get_raw(handle)
class ProxyMap:
"""
@ -75,7 +75,7 @@ class ProxyMap:
def keys(self):
""" return the keys """
return [bytes(key, "utf-8") for key in self.get_keys()]
return self.get_keys()
class ProxyDbBase(DbReadBase):
"""
@ -207,7 +207,7 @@ class ProxyDbBase(DbReadBase):
if (self.db is not None) and self.db.is_open():
proxied = set(self.iter_person_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:
return []
@ -219,7 +219,7 @@ class ProxyDbBase(DbReadBase):
if (self.db is not None) and self.db.is_open():
proxied = set(self.iter_family_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:
return []

View File

@ -212,9 +212,6 @@ class SidebarFilter(DbGUIElement):
if self.dbstate.is_open():
for handle in self.dbstate.db.get_tag_handles(sort_handles=True):
tag = self.dbstate.db.get_tag_from_handle(handle)
# for python3 this returns a byte object, so conversion needed
if not isinstance(handle, str):
handle = handle.decode('utf-8')
self.__tag_list.append((tag.get_name(), handle))
self.on_tags_changed([item[0] for item in self.__tag_list])

View File

@ -310,10 +310,7 @@ class FlatNodeMap:
:type path: integer
:return handle: unicode form of the handle
"""
handle = self._index2hndl[self.real_index(path)][1]
if not isinstance(handle, str):
handle = handle.decode('utf-8')
return handle
return self._index2hndl[self.real_index(path)][1]
def iter_next(self, iter):
"""
@ -567,7 +564,7 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
# use cursor as a context manager
with self.gen_cursor() as cursor:
#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]
srt_keys.sort()
return srt_keys
@ -796,12 +793,7 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
val = self._get_value(handle, col)
#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):
#print 'do_iter_previous'

View File

@ -168,9 +168,6 @@ class PeopleBaseModel(BaseModel):
cached, name = self.get_cached_value(handle, "SORT_NAME")
if not cached:
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)
return name
@ -179,9 +176,6 @@ class PeopleBaseModel(BaseModel):
cached, name = self.get_cached_value(handle, "NAME")
if not cached:
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)
return name
@ -629,8 +623,6 @@ class PersonTreeModel(PeopleBaseModel, TreeBaseModel):
name_data = data[COLUMN_NAME]
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)
#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)
with gen_cursor() as 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()
self.__total += 1
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.
"""
node = self.get_node_from_iter(iter)
handle = node.handle
if handle and not isinstance(handle, str):
handle = handle.decode('utf-8')
return handle
return node.handle
# 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:
# Header rows dont get the foreground color set
if col == self.color_column():
#color must not be utf-8
return "#000000000000"
# Return the node name for the first column
@ -917,14 +910,10 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
# return values for 'data' row, calling a function
# according to column_defs table
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:
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):
"""

View File

@ -111,11 +111,7 @@ class BsddbBaseCursor:
_flags | flags | (db.DB_RMW if self._update else 0),
**kwargs)
try:
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 (data[0].decode('utf-8'), loads(data[1])) if data else None
return get

View File

@ -108,14 +108,11 @@ def find_byte_surname(key, data):
"""
surn = __index_surname(data[3][5])
# in python 3 we work with unicode internally, but need byte function sometimes
if isinstance(surn, str):
return surn.encode('utf-8')
return surn
return surn.encode('utf-8')
def find_fullname(key, data):
"""
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][4] -> primary given
@ -140,7 +137,6 @@ def find_fullname(key, data):
def find_surname(key, data):
"""
Creating a surname from raw data of a person, to use for sort and index
returns a byte string
"""
# data[3][5] -> surname_list
return __index_surname(data[3][5])
@ -148,7 +144,6 @@ def find_surname(key, data):
def find_surname_name(key, data):
"""
Creating a surname from raw name, to use for sort and index
returns a byte string
"""
return __index_surname(data[5])
@ -156,7 +151,6 @@ def __index_surname(surn_list):
"""
All non pa/matronymic surnames are used in indexing.
pa/matronymic not as they change for every generation!
returns a byte string
"""
if surn_list:
surn = " ".join([x[0] for x in surn_list if not (x[3][0] in [
@ -196,11 +190,10 @@ class DbBsddbTreeCursor(BsddbBaseCursor):
Iterator
"""
_n = self.next_dup
to_do = [b'']
to_do = ['']
while to_do:
key = to_do.pop()
key = key.encode('utf-8') if not isinstance(key, bytes) else key
data = self.set(key)
data = self.set(key.encode('utf-8'))
while data:
### FIXME: this is a dirty hack that works without no
### 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
"""
index = prefix % map_index
#in bytes
bindex = index.encode('utf-8')
while trans.get(bindex, txn=self.txn) is not None:
while trans.get(index.encode('utf-8'), txn=self.txn) is not None:
map_index += 1
index = prefix % map_index
bindex = index.encode('utf-8')
map_index += 1
return (map_index, index)
@ -720,14 +710,12 @@ class DbBsddbRead(DbReadBase, Callback):
return gid
def _get_from_handle(self, handle, class_type, data_map):
if isinstance(handle, str):
handle = handle.encode('utf-8')
data = data_map.get(handle)
data = data_map.get(handle.encode('utf-8'))
if data:
newobj = class_type()
newobj.unserialize(data)
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):
"""
@ -812,10 +800,10 @@ class DbBsddbRead(DbReadBase, Callback):
def __get_obj_from_gramps_id(self, val, tbl, class_, prim_tbl):
if isinstance(tbl, dict):
return None ## trying to get object too early
if isinstance(val, str):
val = val.encode('utf-8')
if val is None:
return None
try:
data = tbl.get(val, txn=self.txn)
data = tbl.get(val.encode('utf-8'), txn=self.txn)
if data is not None:
obj = class_()
### 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 type is a unicode object
"""
if isinstance(surname, str):
key = surname.encode('utf-8')
else:
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
key = surname.encode('utf-8')
return self.name_group.get(key, surname)
def get_name_group_keys(self):
"""
@ -951,8 +932,7 @@ class DbBsddbRead(DbReadBase, Callback):
"""
# The use of has_key seems allright because there is no write lock
# on the name_group table when this is called.
if isinstance(name, str):
name = name.encode('utf-8')
name = name.encode('utf-8')
return name in self.name_group
def get_number_of_records(self, table):
@ -1036,12 +1016,10 @@ class DbBsddbRead(DbReadBase, Callback):
return True
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):
"""
@ -1049,9 +1027,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
handle_list = self._all_handles(self.person_map)
@ -1066,9 +1041,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
@ -1084,9 +1056,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
handle_list = self._all_handles(self.source_map)
@ -1101,9 +1070,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
handle_list = self._all_handles(self.citation_map)
@ -1118,9 +1084,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
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
database.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
"""
if self.db_is_open:
return self._all_handles(self.event_map)
@ -1147,9 +1107,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
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
the database.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
"""
if self.db_is_open:
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
database.
.. warning:: For speed the keys are directly returned, so on python3
bytestrings are returned!
"""
if self.db_is_open:
return self._all_handles(self.note_map)
@ -1188,9 +1139,6 @@ class DbBsddbRead(DbReadBase, Callback):
the database.
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:
handle_list = self._all_handles(self.tag_map)
@ -1206,7 +1154,7 @@ class DbBsddbRead(DbReadBase, Callback):
def g(self):
with curs_(self) as cursor:
for key, data in cursor:
yield key.decode('utf-8')
yield key
return g
# Use closure to define iterators for each primary object type
@ -1279,8 +1227,7 @@ class DbBsddbRead(DbReadBase, Callback):
}
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
def find_initial_person(self):
@ -1293,7 +1240,7 @@ class DbBsddbRead(DbReadBase, Callback):
@staticmethod
def _validated_id_prefix(val, default):
if isinstance(val, str) and val:
if val:
try:
str_ = val % 1
except TypeError: # missing conversion specifier
@ -1649,10 +1596,8 @@ class DbBsddbRead(DbReadBase, Callback):
"""
if table is None:
return None ## trying to get object too early
if isinstance(handle, str):
handle = handle.encode('utf-8')
try:
return table.get(handle, txn=self.txn)
return table.get(handle.encode('utf-8'), txn=self.txn)
except DBERRS as msg:
self.__log_error()
raise DbError(msg)
@ -1691,10 +1636,10 @@ class DbBsddbRead(DbReadBase, Callback):
"""
Helper function for has_<object>_handle methods
"""
if isinstance(handle, str):
handle = handle.encode('utf-8')
if handle is None:
return False
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:
self.__log_error()
raise DbError(msg)
@ -1763,8 +1708,9 @@ class DbBsddbRead(DbReadBase, Callback):
"""
Helper function for has_<object>_gramps_id methods
"""
if isinstance(gramps_id, str):
gramps_id = gramps_id.encode('utf-8')
if gramps_id is None:
return False
gramps_id = gramps_id.encode('utf-8')
try:
return id_map.get(gramps_id, txn=self.txn) is not None
except DBERRS as msg:
@ -1826,104 +1772,85 @@ class DbBsddbRead(DbReadBase, Callback):
return self.__has_gramps_id(self.cid_trans, gramps_id)
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,
self.person_map.get(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)
data2 = data[2]
if isinstance(data2, str):
data2 = data2.encode('utf-8')
data3 = data[3]
if isinstance(data3, str):
data3 = data3.encode('utf-8')
if data2: # father handle
data2 = data2.encode('utf-8')
return glocale.sort_key(find_fullname(data2,
self.person_map.get(data2)))
elif data3: # mother handle
data3 = data3.encode('utf-8')
return glocale.sort_key(find_fullname(data3,
self.person_map.get(data3)))
return ''
def __sortbyplace(self, first, second):
if isinstance(first, str):
first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8')
first = first.encode('utf-8')
second = second.encode('utf-8')
return glocale.strcoll(self.place_map.get(first)[2],
self.place_map.get(second)[2])
def __sortbyplace_key(self, place):
if isinstance(place, str):
place = place.encode('utf-8')
place = place.encode('utf-8')
return glocale.sort_key(self.place_map.get(place)[2])
def __sortbysource(self, first, second):
if isinstance(first, str):
first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8')
first = first.encode('utf-8')
second = second.encode('utf-8')
source1 = str(self.source_map[first][2])
source2 = str(self.source_map[second][2])
return glocale.strcoll(source1, source2)
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])
return glocale.sort_key(source)
def __sortbycitation(self, first, second):
if isinstance(first, str):
first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8')
first = first.encode('utf-8')
second = second.encode('utf-8')
citation1 = str(self.citation_map[first][3])
citation2 = str(self.citation_map[second][3])
return glocale.strcoll(citation1, citation2)
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])
return glocale.sort_key(citation)
def __sortbymedia(self, first, second):
if isinstance(first, str):
first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8')
first = first.encode('utf-8')
second = second.encode('utf-8')
media1 = self.media_map[first][4]
media2 = self.media_map[second][4]
return glocale.strcoll(media1, media2)
def __sortbymedia_key(self, key):
if isinstance(key, str):
key = key.encode('utf-8')
key = key.encode('utf-8')
media = self.media_map[key][4]
return glocale.sort_key(media)
def __sortbytag(self, first, second):
if isinstance(first, str):
first = first.encode('utf-8')
if isinstance(second, str):
second = second.encode('utf-8')
first = first.encode('utf-8')
second = second.encode('utf-8')
tag1 = self.tag_map[first][1]
tag2 = self.tag_map[second][1]
return glocale.strcoll(tag1, tag2)
def __sortbytag_key(self, key):
if isinstance(key, str):
key = key.encode('utf-8')
key = key.encode('utf-8')
tag = self.tag_map[key][1]
return glocale.sort_key(tag)
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):
self.metadata[b'mediapath'] = path

View File

@ -203,14 +203,14 @@ class CursorTest(unittest.TestCase):
def test_treecursor(self):
#fill with data
the_txn = self.env.txn_begin()
data = [(b'1', 'countryA', '' ),
(b'2', 'localityA', '1' ),
(b'3', 'localityB', '1' ),
(b'4', 'countryB', '' ),
(b'5', 'streetA', '2' ),
(b'6', 'countryB', '' )]
data = [('1', 'countryA', '' ),
('2', 'localityA', '1' ),
('3', 'localityB', '1' ),
('4', 'countryB', '' ),
('5', 'streetA', '2' ),
('6', 'countryB', '' )]
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()
cursor_txn = self.env.txn_begin()

View File

@ -139,7 +139,7 @@ def find_idmap(key, data):
returns a byte string
"""
val = data[1]
if isinstance(val, str):
if val is not None:
val = val.encode('utf-8')
return val
@ -148,9 +148,7 @@ def find_parent(key, data):
val = data[5][0][0]
else:
val = ''
if isinstance(val, str):
val = val.encode('utf-8')
return val
return val.encode('utf-8')
# Secondary database key lookups for reference_map table
# reference_map data values are of the form:
@ -162,18 +160,14 @@ def find_primary_handle(key, data):
returns byte string
"""
val = (data)[0][1]
if isinstance(val, str):
val = val.encode('utf-8')
return val
return val.encode('utf-8')
def find_referenced_handle(key, data):
""" return handle for association of indexes
returns byte string
"""
val = (data)[1][1]
if isinstance(val, str):
val = val.encode('utf-8')
return val
return val.encode('utf-8')
#-------------------------------------------------------------------------
#
@ -344,9 +338,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
@catch_db_error
def set_default_person_handle(self, handle):
"""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:
# Start transaction
with BSDDBTxn(self.env, self.metadata) as txn:
@ -370,7 +361,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
return None
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:
# Start transaction
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.
"""
if isinstance(handle, str):
handle = handle.encode('utf-8')
parent_cur = self.get_place_parent_cursor()
try:
ret = parent_cur.set(handle)
ret = parent_cur.set(handle.encode('utf-8'))
except:
ret = None
@ -1017,14 +1006,12 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
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
# that include a reference to the object we are looking for.
referenced_cur = self._get_reference_map_referenced_cursor()
try:
ret = referenced_cur.set(handle)
ret = referenced_cur.set(handle.encode('utf-8'))
except:
ret = None
@ -1103,11 +1090,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
handle = obj.handle
existing_references = set()
primary_cur = self._get_reference_map_primary_cursor()
key = handle.encode('utf-8')
try:
if isinstance(handle, str):
key = handle.encode('utf-8')
else:
key = handle
ret = primary_cur.set(key)
except:
ret = None
@ -1164,8 +1148,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
'which is partly bytecode, this is not allowed.\n'
'Key is %s') % str(key))
key = str(key)
if isinstance(key, str):
key = key.encode('utf-8')
key = key.encode('utf-8')
if not self.readonly:
if not transaction.batch:
old_data = self.reference_map.get(key, txn=txn)
@ -1181,8 +1164,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if isinstance(key, tuple):
#create a string key
key = str(key)
if isinstance(key, str):
key = key.encode('utf-8')
key = key.encode('utf-8')
if self.readonly or not key:
return
@ -1540,8 +1522,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if self.readonly or not handle:
return
if isinstance(handle, str):
handle = handle.encode('utf-8')
handle = handle.encode('utf-8')
if transaction.batch:
with BSDDBTxn(self.env, data_map) as txn:
self._delete_primary_from_reference_map(handle, transaction,
@ -1565,8 +1546,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
person = self.get_person_from_handle(handle)
self.genderStats.uncount_person (person)
self.remove_from_surname_list(person)
if isinstance(handle, str):
handle = handle.encode('utf-8')
handle = handle.encode('utf-8')
if transaction.batch:
with BSDDBTxn(self.env, self.person_map) as txn:
self._delete_primary_from_reference_map(handle, transaction,
@ -1702,13 +1682,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
If not then we need to remove the name from the list.
The function must be overridden in the derived class.
"""
name = find_surname_name(person.handle,
person.get_primary_name().serialize())
if isinstance(name, str):
uname = name
name = name.encode('utf-8')
else:
uname = str(name)
uname = find_surname_name(person.handle,
person.get_primary_name().serialize())
name = uname.encode('utf-8')
try:
cursor = self.surnames.cursor(txn=self.txn)
cursor_position = cursor.set(name)
@ -1736,8 +1712,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
obj.change = int(change_time or time.time())
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)
@ -1969,18 +1944,16 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
transaction, change_time)
def get_from_handle(self, handle, class_type, data_map):
if isinstance(handle, str):
handle = handle.encode('utf-8')
if handle is None:
raise HandleError('Handle is None')
if not handle:
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:
newobj = class_type()
newobj.unserialize(data)
return newobj
raise HandleError('Handle %s not found' % handle.decode('utf-8'))
raise HandleError('Handle %s not found' % handle)
@catch_db_error
def transaction_begin(self, transaction):

View File

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

View File

@ -152,7 +152,7 @@ class DbRandomTest(unittest.TestCase):
handles = handles_func()
self.assertEqual(len(handles), number_func())
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):
self.__get_handles_test('Person',
@ -312,7 +312,7 @@ class DbRandomTest(unittest.TestCase):
for handle in handles_func():
person = get_func(handle)
self.assertIsInstance(person, obj_class)
self.assertEqual(person.handle, handle.decode('utf8'))
self.assertEqual(person.handle, handle)
def test_get_person_from_handle(self):
self.__get_from_handle_test(Person,

View File

@ -763,7 +763,7 @@ class ProgenParser(UpdateCallback):
# create a new Person
gramps_id = self.dbase.id2user_format("I%05d" % progen_id)
# 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()
intid = _find_from_handle(progen_id, self.gid2id)
person.set_handle(intid)
@ -783,7 +783,7 @@ class ProgenParser(UpdateCallback):
# create a new Family
gramps_id = self.dbase.fid2user_format("F%04d" % progen_id)
# 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()
intid = _find_from_handle(progen_id, self.fid2id)
family.set_handle(intid)
@ -1063,7 +1063,7 @@ class ProgenParser(UpdateCallback):
# Hmmm. Just use the plain text.
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)
return date
@ -1197,9 +1197,7 @@ class ProgenParser(UpdateCallback):
self.__add_tag('Person', person)
# create diagnose message
diag_msg = "%s: %s %s" % (person.gramps_id,
first_name.encode('utf-8'),
sur_name.encode('utf-8'))
diag_msg = "%s: %s %s" % (person.gramps_id, first_name, sur_name)
# prcesss F25 Birth Date
birth_date = self.__create_date_from_text \

View File

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

View File

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

View File

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

View File

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