Skip to content

Commit d7e1750

Browse files
committed
Merge pull request #1481 from cdhorn/ch-pylint-gen-lib
2 parents 0790612 + 21285a3 commit d7e1750

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1949
-1124
lines changed

gramps/gen/lib/address.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,29 @@
3131
# Gramps modules
3232
#
3333
# -------------------------------------------------------------------------
34-
from .secondaryobj import SecondaryObject
35-
from .privacybase import PrivacyBase
34+
from ..const import GRAMPS_LOCALE as glocale
3635
from .citationbase import CitationBase
37-
from .notebase import NoteBase
36+
from .const import DIFFERENT, EQUAL, IDENTICAL
3837
from .datebase import DateBase
3938
from .locationbase import LocationBase
40-
from .const import IDENTICAL, EQUAL, DIFFERENT
41-
from ..const import GRAMPS_LOCALE as glocale
39+
from .notebase import NoteBase
40+
from .privacybase import PrivacyBase
41+
from .secondaryobj import SecondaryObject
4242

4343
_ = glocale.translation.gettext
4444

4545

4646
# -------------------------------------------------------------------------
4747
#
48-
# Address for Person/Repository
48+
# Address
4949
#
5050
# -------------------------------------------------------------------------
5151
class Address(
5252
SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase, LocationBase
5353
):
54-
"""Provide address information."""
54+
"""
55+
Provides address information.
56+
"""
5557

5658
def __init__(self, source=None):
5759
"""
@@ -96,6 +98,7 @@ def get_schema(cls):
9698
:returns: Returns a dict containing the schema.
9799
:rtype: dict
98100
"""
101+
# pylint: disable=import-outside-toplevel
99102
from .date import Date
100103

101104
return {
@@ -194,11 +197,9 @@ def is_equivalent(self, other):
194197
or self.get_date_object() != other.get_date_object()
195198
):
196199
return DIFFERENT
197-
else:
198-
if self.is_equal(other):
199-
return IDENTICAL
200-
else:
201-
return EQUAL
200+
if self.is_equal(other):
201+
return IDENTICAL
202+
return EQUAL
202203

203204
def merge(self, acquisition):
204205
"""

gramps/gen/lib/addressbase.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
#
3030
# -------------------------------------------------------------------------
3131
from .address import Address
32-
from .const import IDENTICAL, EQUAL
32+
from .const import EQUAL, IDENTICAL
3333

3434

3535
# -------------------------------------------------------------------------
3636
#
37-
# AddressBase classes
37+
# AddressBase
3838
#
3939
# -------------------------------------------------------------------------
4040
class AddressBase:
@@ -79,7 +79,8 @@ def add_address(self, address):
7979

8080
def remove_address(self, address):
8181
"""
82-
Remove the specified :class:`~.address.Address` instance from the address list.
82+
Remove the specified :class:`~.address.Address` instance from the
83+
address list.
8384
8485
If the instance does not exist in the list, the operation has
8586
no effect.
@@ -95,8 +96,7 @@ def remove_address(self, address):
9596
if address in self.address_list:
9697
self.address_list.remove(address)
9798
return True
98-
else:
99-
return False
99+
return False
100100

101101
def get_address_list(self):
102102
"""
@@ -133,7 +133,7 @@ def _merge_address_list(self, acquisition):
133133
equi = address.is_equivalent(addendum)
134134
if equi == IDENTICAL:
135135
break
136-
elif equi == EQUAL:
136+
if equi == EQUAL:
137137
address.merge(addendum)
138138
break
139139
else:

gramps/gen/lib/attrbase.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
#
3030
# -------------------------------------------------------------------------
3131
from .attribute import Attribute, AttributeRoot
32+
from .const import EQUAL, IDENTICAL
3233
from .srcattribute import SrcAttribute
33-
from .const import IDENTICAL, EQUAL
3434

3535

3636
# -------------------------------------------------------------------------
3737
#
38-
# AttributeRootBase class
38+
# AttributeRootBase
3939
#
4040
# -------------------------------------------------------------------------
4141
class AttributeRootBase:
@@ -104,8 +104,7 @@ def remove_attribute(self, attribute):
104104
if attribute in self.attribute_list:
105105
self.attribute_list.remove(attribute)
106106
return True
107-
else:
108-
return False
107+
return False
109108

110109
def get_attribute_list(self):
111110
"""
@@ -142,16 +141,34 @@ def _merge_attribute_list(self, acquisition):
142141
equi = attr.is_equivalent(addendum)
143142
if equi == IDENTICAL:
144143
break
145-
elif equi == EQUAL:
144+
if equi == EQUAL:
146145
attr.merge(addendum)
147146
break
148147
else:
149148
self.attribute_list.append(addendum)
150149

151150

151+
# -------------------------------------------------------------------------
152+
#
153+
# AttributeBase
154+
#
155+
# -------------------------------------------------------------------------
152156
class AttributeBase(AttributeRootBase):
157+
"""
158+
Base class for an Attribute list.
159+
"""
160+
153161
_CLASS = Attribute
154162

155163

164+
# -------------------------------------------------------------------------
165+
#
166+
# SrcAttributeBase
167+
#
168+
# -------------------------------------------------------------------------
156169
class SrcAttributeBase(AttributeRootBase):
170+
"""
171+
Base class for a SrcAttribute list.
172+
"""
173+
157174
_CLASS = SrcAttribute

gramps/gen/lib/attribute.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
# Gramps modules
3131
#
3232
# -------------------------------------------------------------------------
33-
from .secondaryobj import SecondaryObject
34-
from .privacybase import PrivacyBase
33+
from ..const import GRAMPS_LOCALE as glocale
34+
from .attrtype import AttributeType
3535
from .citationbase import CitationBase
36+
from .const import DIFFERENT, EQUAL, IDENTICAL
3637
from .notebase import NoteBase
37-
from .attrtype import AttributeType
38-
from .const import IDENTICAL, EQUAL, DIFFERENT
39-
from ..const import GRAMPS_LOCALE as glocale
38+
from .privacybase import PrivacyBase
39+
from .secondaryobj import SecondaryObject
4040

4141
_ = glocale.translation.gettext
4242

@@ -150,11 +150,9 @@ def is_equivalent(self, other):
150150
"""
151151
if self.type != other.type or self.value != other.value:
152152
return DIFFERENT
153-
else:
154-
if self.is_equal(other):
155-
return IDENTICAL
156-
else:
157-
return EQUAL
153+
if self.is_equal(other):
154+
return IDENTICAL
155+
return EQUAL
158156

159157
def merge(self, acquisition):
160158
"""
@@ -190,6 +188,10 @@ def get_value(self):
190188
#
191189
# -------------------------------------------------------------------------
192190
class Attribute(AttributeRoot, CitationBase, NoteBase):
191+
"""
192+
An attribute class that supports citation and note annotations.
193+
"""
194+
193195
def __init__(self, source=None):
194196
"""
195197
Create a new Attribute object, copying from the source if provided.

gramps/gen/lib/attrtype.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
# Gramps modules
2929
#
3030
# -------------------------------------------------------------------------
31-
from .grampstype import GrampsType
3231
from ..const import GRAMPS_LOCALE as glocale
32+
from .grampstype import GrampsType
3333

3434
_ = glocale.translation.gettext
3535

@@ -39,7 +39,16 @@ def _T_(value, context=""): # enable deferred translations
3939
return "%s\x04%s" % (context, value) if context else value
4040

4141

42+
# -------------------------------------------------------------------------
43+
#
44+
# AttributeType
45+
#
46+
# -------------------------------------------------------------------------
4247
class AttributeType(GrampsType):
48+
"""
49+
Class describing the type of an attribute.
50+
"""
51+
4352
UNKNOWN = -1
4453
CUSTOM = 0
4554
CASTE = 1
@@ -92,7 +101,6 @@ def type2base(self):
92101
"""
93102
if self.value == self.CUSTOM:
94103
return str(self)
95-
elif self._BASEMAP[self.value + 1]: # UNKNOWN is before CUSTOM, sigh
104+
if self._BASEMAP[self.value + 1]: # UNKNOWN is before CUSTOM, sigh
96105
return self._BASEMAP[self.value + 1][1]
97-
else:
98-
return self.UNKNOWN
106+
return self.UNKNOWN

gramps/gen/lib/baseobj.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424

2525
# -------------------------------------------------------------------------
2626
#
27-
# Standard Python modules
27+
# Python modules
2828
#
2929
# -------------------------------------------------------------------------
30-
from abc import ABCMeta, abstractmethod
3130
import re
31+
from abc import ABCMeta, abstractmethod
3232

3333

3434
# -------------------------------------------------------------------------
3535
#
36-
# Base Object
36+
# BaseObject
3737
#
3838
# -------------------------------------------------------------------------
3939
class BaseObject(metaclass=ABCMeta):
@@ -185,7 +185,6 @@ def merge(self, acquisition):
185185
:param acquisition: The object to incorporate.
186186
:type acquisition: BaseObject
187187
"""
188-
pass
189188

190189
@classmethod
191190
def create(cls, data):

gramps/gen/lib/childref.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,32 @@
2525
"""
2626
Child Reference class for Gramps.
2727
"""
28+
2829
# -------------------------------------------------------------------------
2930
#
3031
# Gramps modules
3132
#
3233
# -------------------------------------------------------------------------
33-
from .secondaryobj import SecondaryObject
34-
from .privacybase import PrivacyBase
34+
from ..const import GRAMPS_LOCALE as glocale
35+
from .childreftype import ChildRefType
3536
from .citationbase import CitationBase
37+
from .const import DIFFERENT, EQUAL, IDENTICAL
3638
from .notebase import NoteBase
39+
from .privacybase import PrivacyBase
3740
from .refbase import RefBase
38-
from .childreftype import ChildRefType
39-
from .const import IDENTICAL, EQUAL, DIFFERENT
40-
from ..const import GRAMPS_LOCALE as glocale
41+
from .secondaryobj import SecondaryObject
4142

4243
_ = glocale.translation.gettext
4344

4445

4546
# -------------------------------------------------------------------------
4647
#
47-
# Person References for Person/Family
48+
# ChildRef
4849
#
4950
# -------------------------------------------------------------------------
5051
class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
5152
"""
52-
Person reference class.
53-
54-
This class is for keeping information about how the person relates
55-
to another person from the database, if not through family.
56-
Examples would be: godparent, friend, etc.
53+
A class for tracking information about how a child relates to their parents.
5754
"""
5855

5956
def __init__(self, source=None):
@@ -120,7 +117,11 @@ def get_schema(cls):
120117
"items": {"type": "string", "maxLength": 50},
121118
"title": _("Notes"),
122119
},
123-
"ref": {"type": "string", "maxLength": 50, "title": _("Handle")},
120+
"ref": {
121+
"type": "string",
122+
"maxLength": 50,
123+
"title": _("Handle"),
124+
},
124125
"frel": ChildRefType.get_schema(),
125126
"mrel": ChildRefType.get_schema(),
126127
},
@@ -191,11 +192,9 @@ def is_equivalent(self, other):
191192
"""
192193
if self.ref != other.ref:
193194
return DIFFERENT
194-
else:
195-
if self.is_equal(other):
196-
return IDENTICAL
197-
else:
198-
return EQUAL
195+
if self.is_equal(other):
196+
return IDENTICAL
197+
return EQUAL
199198

200199
def merge(self, acquisition):
201200
"""

gramps/gen/lib/childreftype.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@
2727
# Gramps modules
2828
#
2929
# -------------------------------------------------------------------------
30-
from .grampstype import GrampsType
3130
from ..const import GRAMPS_LOCALE as glocale
31+
from .grampstype import GrampsType
3232

3333
_ = glocale.translation.gettext
3434

3535

36+
# -------------------------------------------------------------------------
37+
#
38+
# ChildRefType
39+
#
40+
# -------------------------------------------------------------------------
3641
class ChildRefType(GrampsType):
3742
"""
3843
Provide the different ChildRef types.

0 commit comments

Comments
 (0)