Skip to content

Commit 9325608

Browse files
cdhornNick-Hall
authored andcommitted
Pylint cleanups for gen/db/*.py
1 parent 780177c commit 9325608

File tree

6 files changed

+290
-265
lines changed

6 files changed

+290
-265
lines changed

gramps/gen/db/base.py

+43-40
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,33 @@
2727

2828
# -------------------------------------------------------------------------
2929
#
30-
# Python libraries
30+
# Python modules
3131
#
3232
# -------------------------------------------------------------------------
33-
import re
34-
import time
35-
from operator import itemgetter
3633
import logging
3734

3835
# -------------------------------------------------------------------------
3936
#
40-
# Gramps libraries
37+
# Gramps modules
4138
#
4239
# -------------------------------------------------------------------------
43-
from ..db.dbconst import DBLOGNAME
4440
from ..const import GRAMPS_LOCALE as glocale
45-
46-
_ = glocale.translation.gettext
47-
from ..lib.childreftype import ChildRefType
41+
from ..db.dbconst import DBLOGNAME
4842
from ..lib.childref import ChildRef
43+
from ..lib.childreftype import ChildRefType
44+
from .exceptions import DbTransactionCancel
4945
from .txn import DbTxn
50-
from .exceptions import DbTransactionCancel, DbException
46+
47+
_ = glocale.translation.gettext
5148

5249
_LOG = logging.getLogger(DBLOGNAME)
5350

51+
5452
# -------------------------------------------------------------------------
5553
#
56-
# Gramps libraries
54+
# DbReadBase class
5755
#
5856
# -------------------------------------------------------------------------
59-
60-
6157
class DbReadBase:
6258
"""
6359
Gramps database object. This object is a base class for all
@@ -377,7 +373,7 @@ def get_tag_cursor(self):
377373
"""
378374
raise NotImplementedError
379375

380-
def get_citation_from_gramps_id(self, val):
376+
def get_citation_from_gramps_id(self, gramps_id):
381377
"""
382378
Find a Citation in the database from the passed Gramps ID.
383379
@@ -388,7 +384,7 @@ def get_citation_from_gramps_id(self, val):
388384
"""
389385
raise NotImplementedError
390386

391-
def get_event_from_gramps_id(self, val):
387+
def get_event_from_gramps_id(self, gramps_id):
392388
"""
393389
Find an Event in the database from the passed Gramps ID.
394390
@@ -399,7 +395,7 @@ def get_event_from_gramps_id(self, val):
399395
"""
400396
raise NotImplementedError
401397

402-
def get_family_from_gramps_id(self, val):
398+
def get_family_from_gramps_id(self, gramps_id):
403399
"""
404400
Find a Family in the database from the passed Gramps ID.
405401
@@ -410,7 +406,7 @@ def get_family_from_gramps_id(self, val):
410406
"""
411407
raise NotImplementedError
412408

413-
def get_media_from_gramps_id(self, val):
409+
def get_media_from_gramps_id(self, gramps_id):
414410
"""
415411
Find a Media in the database from the passed Gramps ID.
416412
@@ -421,7 +417,7 @@ def get_media_from_gramps_id(self, val):
421417
"""
422418
raise NotImplementedError
423419

424-
def get_note_from_gramps_id(self, val):
420+
def get_note_from_gramps_id(self, gramps_id):
425421
"""
426422
Find a Note in the database from the passed Gramps ID.
427423
@@ -432,7 +428,7 @@ def get_note_from_gramps_id(self, val):
432428
"""
433429
raise NotImplementedError
434430

435-
def get_person_from_gramps_id(self, val):
431+
def get_person_from_gramps_id(self, gramps_id):
436432
"""
437433
Find a Person in the database from the passed Gramps ID.
438434
@@ -443,7 +439,7 @@ def get_person_from_gramps_id(self, val):
443439
"""
444440
raise NotImplementedError
445441

446-
def get_place_from_gramps_id(self, val):
442+
def get_place_from_gramps_id(self, gramps_id):
447443
"""
448444
Find a Place in the database from the passed Gramps ID.
449445
@@ -454,7 +450,7 @@ def get_place_from_gramps_id(self, val):
454450
"""
455451
raise NotImplementedError
456452

457-
def get_repository_from_gramps_id(self, val):
453+
def get_repository_from_gramps_id(self, gramps_id):
458454
"""
459455
Find a Repository in the database from the passed Gramps ID.
460456
@@ -465,7 +461,7 @@ def get_repository_from_gramps_id(self, val):
465461
"""
466462
raise NotImplementedError
467463

468-
def get_source_from_gramps_id(self, val):
464+
def get_source_from_gramps_id(self, gramps_id):
469465
"""
470466
Find a Source in the database from the passed Gramps ID.
471467
@@ -1267,7 +1263,7 @@ def iter_tag_handles(self):
12671263

12681264
def load(
12691265
self,
1270-
name,
1266+
directory,
12711267
callback,
12721268
mode=None,
12731269
force_schema_upgrade=False,
@@ -1400,7 +1396,7 @@ def set_source_id_prefix(self, val):
14001396
"""
14011397
raise NotImplementedError
14021398

1403-
def set_mediapath(self, path):
1399+
def set_mediapath(self, mediapath):
14041400
"""
14051401
Set the default media path for database.
14061402
"""
@@ -1469,6 +1465,11 @@ def method(self, fmt, *args):
14691465
return getattr(self, fmt % tuple([arg.lower() for arg in args]), None)
14701466

14711467

1468+
# -------------------------------------------------------------------------
1469+
#
1470+
# DbWriteBase class
1471+
#
1472+
# -------------------------------------------------------------------------
14721473
class DbWriteBase(DbReadBase):
14731474
"""
14741475
Gramps database object. This object is a base class for all
@@ -1485,7 +1486,7 @@ def __init__(self):
14851486
"""
14861487
DbReadBase.__init__(self)
14871488

1488-
def add_citation(self, event, transaction, set_gid=True):
1489+
def add_citation(self, citation, transaction, set_gid=True):
14891490
"""
14901491
Add an Citation to the database, assigning internal IDs if they have
14911492
not already been defined.
@@ -1512,7 +1513,7 @@ def add_family(self, family, transaction, set_gid=True):
15121513
"""
15131514
raise NotImplementedError
15141515

1515-
def add_media(self, obj, transaction, set_gid=True):
1516+
def add_media(self, media, transaction, set_gid=True):
15161517
"""
15171518
Add a Media to the database, assigning internal IDs if they have
15181519
not already been defined.
@@ -1521,7 +1522,7 @@ def add_media(self, obj, transaction, set_gid=True):
15211522
"""
15221523
raise NotImplementedError
15231524

1524-
def add_note(self, obj, transaction, set_gid=True):
1525+
def add_note(self, note, transaction, set_gid=True):
15251526
"""
15261527
Add a Note to the database, assigning internal IDs if they have
15271528
not already been defined.
@@ -1548,7 +1549,7 @@ def add_place(self, place, transaction, set_gid=True):
15481549
"""
15491550
raise NotImplementedError
15501551

1551-
def add_repository(self, obj, transaction, set_gid=True):
1552+
def add_repository(self, repository, transaction, set_gid=True):
15521553
"""
15531554
Add a Repository to the database, assigning internal IDs if they have
15541555
not already been defined.
@@ -1579,7 +1580,7 @@ def add_to_surname_list(self, person, batch_transaction, name):
15791580
"""
15801581
raise NotImplementedError
15811582

1582-
def commit_citation(self, event, transaction, change_time=None):
1583+
def commit_citation(self, citation, transaction, change_time=None):
15831584
"""
15841585
Commit the specified Event to the database, storing the changes as
15851586
part of the transaction.
@@ -1600,7 +1601,7 @@ def commit_family(self, family, transaction, change_time=None):
16001601
"""
16011602
raise NotImplementedError
16021603

1603-
def commit_media(self, obj, transaction, change_time=None):
1604+
def commit_media(self, media, transaction, change_time=None):
16041605
"""
16051606
Commit the specified Media to the database, storing the changes
16061607
as part of the transaction.
@@ -1820,9 +1821,9 @@ def add_child_to_family(
18201821
child.add_parent_family_handle(family.handle)
18211822

18221823
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)
18261827
else:
18271828
self.commit_family(family, trans)
18281829
self.commit_person(child, trans)
@@ -1833,8 +1834,10 @@ def remove_child_from_family(self, person_handle, family_handle, trans=None):
18331834
it becomes empty.
18341835
"""
18351836
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+
)
18381841
else:
18391842
self.__remove_child_from_family(person_handle, family_handle, trans)
18401843
trans.set_description(_("Remove child from family"))
@@ -1916,8 +1919,8 @@ def remove_family_relationships(self, family_handle, trans=None):
19161919
Remove a family and its relationships.
19171920
"""
19181921
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)
19211924
else:
19221925
self.__remove_family_relationships(family_handle, trans)
19231926
trans.set_description(_("Remove Family"))
@@ -1939,11 +1942,11 @@ def remove_parent_from_family(self, person_handle, family_handle, trans=None):
19391942
deleting the family if it becomes empty.
19401943
"""
19411944
if trans is None:
1942-
with DbTxn("", self) as trans:
1945+
with DbTxn("", self) as transaction:
19431946
msg = self.__remove_parent_from_family(
1944-
person_handle, family_handle, trans
1947+
person_handle, family_handle, transaction
19451948
)
1946-
trans.set_description(msg)
1949+
transaction.set_description(msg)
19471950
else:
19481951
msg = self.__remove_parent_from_family(person_handle, family_handle, trans)
19491952
trans.set_description(msg)

0 commit comments

Comments
 (0)