27
27
28
28
# -------------------------------------------------------------------------
29
29
#
30
- # Python libraries
30
+ # Python modules
31
31
#
32
32
# -------------------------------------------------------------------------
33
- import re
34
- import time
35
- from operator import itemgetter
36
33
import logging
37
34
38
35
# -------------------------------------------------------------------------
39
36
#
40
- # Gramps libraries
37
+ # Gramps modules
41
38
#
42
39
# -------------------------------------------------------------------------
43
- from ..db .dbconst import DBLOGNAME
44
40
from ..const import GRAMPS_LOCALE as glocale
45
-
46
- _ = glocale .translation .gettext
47
- from ..lib .childreftype import ChildRefType
41
+ from ..db .dbconst import DBLOGNAME
48
42
from ..lib .childref import ChildRef
43
+ from ..lib .childreftype import ChildRefType
44
+ from .exceptions import DbTransactionCancel
49
45
from .txn import DbTxn
50
- from .exceptions import DbTransactionCancel , DbException
46
+
47
+ _ = glocale .translation .gettext
51
48
52
49
_LOG = logging .getLogger (DBLOGNAME )
53
50
51
+
54
52
# -------------------------------------------------------------------------
55
53
#
56
- # Gramps libraries
54
+ # DbReadBase class
57
55
#
58
56
# -------------------------------------------------------------------------
59
-
60
-
61
57
class DbReadBase :
62
58
"""
63
59
Gramps database object. This object is a base class for all
@@ -377,7 +373,7 @@ def get_tag_cursor(self):
377
373
"""
378
374
raise NotImplementedError
379
375
380
- def get_citation_from_gramps_id (self , val ):
376
+ def get_citation_from_gramps_id (self , gramps_id ):
381
377
"""
382
378
Find a Citation in the database from the passed Gramps ID.
383
379
@@ -388,7 +384,7 @@ def get_citation_from_gramps_id(self, val):
388
384
"""
389
385
raise NotImplementedError
390
386
391
- def get_event_from_gramps_id (self , val ):
387
+ def get_event_from_gramps_id (self , gramps_id ):
392
388
"""
393
389
Find an Event in the database from the passed Gramps ID.
394
390
@@ -399,7 +395,7 @@ def get_event_from_gramps_id(self, val):
399
395
"""
400
396
raise NotImplementedError
401
397
402
- def get_family_from_gramps_id (self , val ):
398
+ def get_family_from_gramps_id (self , gramps_id ):
403
399
"""
404
400
Find a Family in the database from the passed Gramps ID.
405
401
@@ -410,7 +406,7 @@ def get_family_from_gramps_id(self, val):
410
406
"""
411
407
raise NotImplementedError
412
408
413
- def get_media_from_gramps_id (self , val ):
409
+ def get_media_from_gramps_id (self , gramps_id ):
414
410
"""
415
411
Find a Media in the database from the passed Gramps ID.
416
412
@@ -421,7 +417,7 @@ def get_media_from_gramps_id(self, val):
421
417
"""
422
418
raise NotImplementedError
423
419
424
- def get_note_from_gramps_id (self , val ):
420
+ def get_note_from_gramps_id (self , gramps_id ):
425
421
"""
426
422
Find a Note in the database from the passed Gramps ID.
427
423
@@ -432,7 +428,7 @@ def get_note_from_gramps_id(self, val):
432
428
"""
433
429
raise NotImplementedError
434
430
435
- def get_person_from_gramps_id (self , val ):
431
+ def get_person_from_gramps_id (self , gramps_id ):
436
432
"""
437
433
Find a Person in the database from the passed Gramps ID.
438
434
@@ -443,7 +439,7 @@ def get_person_from_gramps_id(self, val):
443
439
"""
444
440
raise NotImplementedError
445
441
446
- def get_place_from_gramps_id (self , val ):
442
+ def get_place_from_gramps_id (self , gramps_id ):
447
443
"""
448
444
Find a Place in the database from the passed Gramps ID.
449
445
@@ -454,7 +450,7 @@ def get_place_from_gramps_id(self, val):
454
450
"""
455
451
raise NotImplementedError
456
452
457
- def get_repository_from_gramps_id (self , val ):
453
+ def get_repository_from_gramps_id (self , gramps_id ):
458
454
"""
459
455
Find a Repository in the database from the passed Gramps ID.
460
456
@@ -465,7 +461,7 @@ def get_repository_from_gramps_id(self, val):
465
461
"""
466
462
raise NotImplementedError
467
463
468
- def get_source_from_gramps_id (self , val ):
464
+ def get_source_from_gramps_id (self , gramps_id ):
469
465
"""
470
466
Find a Source in the database from the passed Gramps ID.
471
467
@@ -1267,7 +1263,7 @@ def iter_tag_handles(self):
1267
1263
1268
1264
def load (
1269
1265
self ,
1270
- name ,
1266
+ directory ,
1271
1267
callback ,
1272
1268
mode = None ,
1273
1269
force_schema_upgrade = False ,
@@ -1400,7 +1396,7 @@ def set_source_id_prefix(self, val):
1400
1396
"""
1401
1397
raise NotImplementedError
1402
1398
1403
- def set_mediapath (self , path ):
1399
+ def set_mediapath (self , mediapath ):
1404
1400
"""
1405
1401
Set the default media path for database.
1406
1402
"""
@@ -1469,6 +1465,11 @@ def method(self, fmt, *args):
1469
1465
return getattr (self , fmt % tuple ([arg .lower () for arg in args ]), None )
1470
1466
1471
1467
1468
+ # -------------------------------------------------------------------------
1469
+ #
1470
+ # DbWriteBase class
1471
+ #
1472
+ # -------------------------------------------------------------------------
1472
1473
class DbWriteBase (DbReadBase ):
1473
1474
"""
1474
1475
Gramps database object. This object is a base class for all
@@ -1485,7 +1486,7 @@ def __init__(self):
1485
1486
"""
1486
1487
DbReadBase .__init__ (self )
1487
1488
1488
- def add_citation (self , event , transaction , set_gid = True ):
1489
+ def add_citation (self , citation , transaction , set_gid = True ):
1489
1490
"""
1490
1491
Add an Citation to the database, assigning internal IDs if they have
1491
1492
not already been defined.
@@ -1512,7 +1513,7 @@ def add_family(self, family, transaction, set_gid=True):
1512
1513
"""
1513
1514
raise NotImplementedError
1514
1515
1515
- def add_media (self , obj , transaction , set_gid = True ):
1516
+ def add_media (self , media , transaction , set_gid = True ):
1516
1517
"""
1517
1518
Add a Media to the database, assigning internal IDs if they have
1518
1519
not already been defined.
@@ -1521,7 +1522,7 @@ def add_media(self, obj, transaction, set_gid=True):
1521
1522
"""
1522
1523
raise NotImplementedError
1523
1524
1524
- def add_note (self , obj , transaction , set_gid = True ):
1525
+ def add_note (self , note , transaction , set_gid = True ):
1525
1526
"""
1526
1527
Add a Note to the database, assigning internal IDs if they have
1527
1528
not already been defined.
@@ -1548,7 +1549,7 @@ def add_place(self, place, transaction, set_gid=True):
1548
1549
"""
1549
1550
raise NotImplementedError
1550
1551
1551
- def add_repository (self , obj , transaction , set_gid = True ):
1552
+ def add_repository (self , repository , transaction , set_gid = True ):
1552
1553
"""
1553
1554
Add a Repository to the database, assigning internal IDs if they have
1554
1555
not already been defined.
@@ -1579,7 +1580,7 @@ def add_to_surname_list(self, person, batch_transaction, name):
1579
1580
"""
1580
1581
raise NotImplementedError
1581
1582
1582
- def commit_citation (self , event , transaction , change_time = None ):
1583
+ def commit_citation (self , citation , transaction , change_time = None ):
1583
1584
"""
1584
1585
Commit the specified Event to the database, storing the changes as
1585
1586
part of the transaction.
@@ -1600,7 +1601,7 @@ def commit_family(self, family, transaction, change_time=None):
1600
1601
"""
1601
1602
raise NotImplementedError
1602
1603
1603
- def commit_media (self , obj , transaction , change_time = None ):
1604
+ def commit_media (self , media , transaction , change_time = None ):
1604
1605
"""
1605
1606
Commit the specified Media to the database, storing the changes
1606
1607
as part of the transaction.
@@ -1820,9 +1821,9 @@ def add_child_to_family(
1820
1821
child .add_parent_family_handle (family .handle )
1821
1822
1822
1823
if trans is None :
1823
- with DbTxn (_ ("Add child to family" ), self ) as trans :
1824
- self .commit_family (family , trans )
1825
- self .commit_person (child , trans )
1824
+ with DbTxn (_ ("Add child to family" ), self ) as transaction :
1825
+ self .commit_family (family , transaction )
1826
+ self .commit_person (child , transaction )
1826
1827
else :
1827
1828
self .commit_family (family , trans )
1828
1829
self .commit_person (child , trans )
@@ -1833,8 +1834,10 @@ def remove_child_from_family(self, person_handle, family_handle, trans=None):
1833
1834
it becomes empty.
1834
1835
"""
1835
1836
if trans is None :
1836
- with DbTxn (_ ("Remove child from family" ), self ) as trans :
1837
- self .__remove_child_from_family (person_handle , family_handle , trans )
1837
+ with DbTxn (_ ("Remove child from family" ), self ) as transaction :
1838
+ self .__remove_child_from_family (
1839
+ person_handle , family_handle , transaction
1840
+ )
1838
1841
else :
1839
1842
self .__remove_child_from_family (person_handle , family_handle , trans )
1840
1843
trans .set_description (_ ("Remove child from family" ))
@@ -1916,8 +1919,8 @@ def remove_family_relationships(self, family_handle, trans=None):
1916
1919
Remove a family and its relationships.
1917
1920
"""
1918
1921
if trans is None :
1919
- with DbTxn (_ ("Remove Family" ), self ) as trans :
1920
- self .__remove_family_relationships (family_handle , trans )
1922
+ with DbTxn (_ ("Remove Family" ), self ) as transaction :
1923
+ self .__remove_family_relationships (family_handle , transaction )
1921
1924
else :
1922
1925
self .__remove_family_relationships (family_handle , trans )
1923
1926
trans .set_description (_ ("Remove Family" ))
@@ -1939,11 +1942,11 @@ def remove_parent_from_family(self, person_handle, family_handle, trans=None):
1939
1942
deleting the family if it becomes empty.
1940
1943
"""
1941
1944
if trans is None :
1942
- with DbTxn ("" , self ) as trans :
1945
+ with DbTxn ("" , self ) as transaction :
1943
1946
msg = self .__remove_parent_from_family (
1944
- person_handle , family_handle , trans
1947
+ person_handle , family_handle , transaction
1945
1948
)
1946
- trans .set_description (msg )
1949
+ transaction .set_description (msg )
1947
1950
else :
1948
1951
msg = self .__remove_parent_from_family (person_handle , family_handle , trans )
1949
1952
trans .set_description (msg )
0 commit comments