Primary object pylint improvements
This commit is contained in:
@@ -30,7 +30,6 @@ Citation object for Gramps.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -46,6 +45,8 @@ from .attrbase import SrcAttributeBase
|
||||
from .citationbase import IndirectCitationBase
|
||||
from .handle import Handle
|
||||
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Citation class
|
||||
|
@@ -30,7 +30,6 @@ Event object for Gramps.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -48,6 +47,8 @@ from .tagbase import TagBase
|
||||
from .eventtype import EventType
|
||||
from .handle import Handle
|
||||
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Event class
|
||||
@@ -84,8 +85,8 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
PlaceBase.__init__(self, source)
|
||||
|
||||
if source:
|
||||
self.__description = source.__description
|
||||
self.__type = EventType(source.__type)
|
||||
self.__description = source.description
|
||||
self.__type = EventType(source.type)
|
||||
else:
|
||||
self.__description = ""
|
||||
self.__type = EventType()
|
||||
@@ -349,9 +350,9 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
if other is None:
|
||||
other = Event(None)
|
||||
|
||||
if self.__type != other.__type or \
|
||||
if self.__type != other.type or \
|
||||
((self.place or other.place) and (self.place != other.place)) or \
|
||||
self.__description != other.__description \
|
||||
self.__description != other.description \
|
||||
or self.private != other.private or \
|
||||
(not self.get_date_object().is_equal(other.get_date_object())) or \
|
||||
len(self.get_citation_list()) != \
|
||||
@@ -360,9 +361,9 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
|
||||
index = 0
|
||||
olist = other.get_citation_list()
|
||||
for a in self.get_citation_list():
|
||||
for handle in self.get_citation_list():
|
||||
# see comment in srefs_are_equal in gen/plug/report/_bibliography.py
|
||||
if a != olist[index]:
|
||||
if handle != olist[index]:
|
||||
return False
|
||||
index += 1
|
||||
|
||||
@@ -401,7 +402,8 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
:rtype: tuple
|
||||
"""
|
||||
return self.__type
|
||||
type = property(get_type, set_type, None, 'Returns or sets type of the event')
|
||||
type = property(get_type, set_type, None,
|
||||
'Returns or sets type of the event')
|
||||
|
||||
def set_description(self, description):
|
||||
"""
|
||||
@@ -422,5 +424,6 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
:rtype: str
|
||||
"""
|
||||
return self.__description
|
||||
description = property(get_description, set_description, None, 'Returns or sets description of the event')
|
||||
description = property(get_description, set_description, None,
|
||||
'Returns or sets description of the event')
|
||||
|
||||
|
@@ -32,7 +32,6 @@ Family object for Gramps.
|
||||
#-------------------------------------------------------------------------
|
||||
from warnings import warn
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -52,6 +51,8 @@ from .familyreltype import FamilyRelType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from .handle import Handle
|
||||
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Family class
|
||||
@@ -173,16 +174,27 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
default = Family()
|
||||
return (Handle.from_struct(struct.get("handle", default.handle)),
|
||||
struct.get("gramps_id", default.gramps_id),
|
||||
Handle.from_struct(struct.get("father_handle", default.father_handle)),
|
||||
Handle.from_struct(struct.get("mother_handle", default.mother_handle)),
|
||||
[ChildRef.from_struct(cr) for cr in struct.get("child_ref_list", default.child_ref_list)],
|
||||
Handle.from_struct(struct.get("father_handle",
|
||||
default.father_handle)),
|
||||
Handle.from_struct(struct.get("mother_handle",
|
||||
default.mother_handle)),
|
||||
[ChildRef.from_struct(cr)
|
||||
for cr in struct.get("child_ref_list",
|
||||
default.child_ref_list)],
|
||||
FamilyRelType.from_struct(struct.get("type", {})),
|
||||
[EventRef.from_struct(er) for er in struct.get("event_ref_list", default.event_ref_list)],
|
||||
MediaBase.from_struct(struct.get("media_list", default.media_list)),
|
||||
AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)),
|
||||
LdsOrdBase.from_struct(struct.get("lds_ord_list", default.lds_ord_list)),
|
||||
CitationBase.from_struct(struct.get("citation_list", default.citation_list)),
|
||||
NoteBase.from_struct(struct.get("note_list", default.note_list)),
|
||||
[EventRef.from_struct(er)
|
||||
for er in struct.get("event_ref_list",
|
||||
default.event_ref_list)],
|
||||
MediaBase.from_struct(struct.get("media_list",
|
||||
default.media_list)),
|
||||
AttributeBase.from_struct(struct.get("attribute_list",
|
||||
default.attribute_list)),
|
||||
LdsOrdBase.from_struct(struct.get("lds_ord_list",
|
||||
default.lds_ord_list)),
|
||||
CitationBase.from_struct(struct.get("citation_list",
|
||||
default.citation_list)),
|
||||
NoteBase.from_struct(struct.get("note_list",
|
||||
default.note_list)),
|
||||
struct.get("change", default.change),
|
||||
TagBase.from_struct(struct.get("tag_list", default.tag_list)),
|
||||
struct.get("private", default.private))
|
||||
@@ -255,9 +267,9 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
if self.mother_handle in handle_list:
|
||||
self.mother_handle = None
|
||||
elif classname == 'Place':
|
||||
for x in self.lds_ord_list:
|
||||
if x.place in handle_list:
|
||||
x.place = None
|
||||
for lds_ord in self.lds_ord_list:
|
||||
if lds_ord.place in handle_list:
|
||||
lds_ord.place = None
|
||||
|
||||
def _replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
"""
|
||||
@@ -311,9 +323,9 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
if self.mother_handle == old_handle:
|
||||
self.mother_handle = new_handle
|
||||
elif classname == 'Place':
|
||||
for x in self.lds_ord_list:
|
||||
if x.place == old_handle:
|
||||
x.place = new_handle
|
||||
for lds_ord in self.lds_ord_list:
|
||||
if lds_ord.place == old_handle:
|
||||
lds_ord.place = new_handle
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
|
@@ -33,7 +33,6 @@ Media object for Gramps.
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -48,6 +47,8 @@ from .attrbase import AttributeBase
|
||||
from .tagbase import TagBase
|
||||
from .handle import Handle
|
||||
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MediaObject class
|
||||
|
@@ -46,9 +46,9 @@ from .attrtype import AttributeType
|
||||
from .eventroletype import EventRoleType
|
||||
from .attribute import Attribute
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from .handle import Handle
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from .handle import Handle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -113,7 +113,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
return isinstance(other, Person) and self.handle == other.handle
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self == other
|
||||
return self != other
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
@@ -248,23 +248,34 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
struct.get("gramps_id", default.gramps_id),
|
||||
struct.get("gender", default.gender),
|
||||
Name.from_struct(struct.get("primary_name", {})),
|
||||
[Name.from_struct(name) for name in struct.get("alternate_names", default.alternate_names)],
|
||||
[Name.from_struct(name)
|
||||
for name in struct.get("alternate_names",
|
||||
default.alternate_names)],
|
||||
struct.get("death_ref_index", default.death_ref_index),
|
||||
struct.get("birth_ref_index", default.birth_ref_index),
|
||||
[EventRef.from_struct(er) for er in struct.get("event_ref_list", default.event_ref_list)],
|
||||
[Handle.from_struct(handle) for handle in struct.get("family_list", default.family_list)],
|
||||
[Handle.from_struct(handle) for handle in struct.get("parent_family_list", default.parent_family_list)],
|
||||
[EventRef.from_struct(er)
|
||||
for er in struct.get("event_ref_list", default.event_ref_list)],
|
||||
[Handle.from_struct(handle)
|
||||
for handle in struct.get("family_list", default.family_list)],
|
||||
[Handle.from_struct(handle)
|
||||
for handle in struct.get("parent_family_list",
|
||||
default.parent_family_list)],
|
||||
MediaBase.from_struct(struct.get("media_list", default.media_list)),
|
||||
AddressBase.from_struct(struct.get("address_list", default.address_list)),
|
||||
AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)),
|
||||
AddressBase.from_struct(struct.get("address_list",
|
||||
default.address_list)),
|
||||
AttributeBase.from_struct(struct.get("attribute_list",
|
||||
default.attribute_list)),
|
||||
UrlBase.from_struct(struct.get("urls", default.urls)),
|
||||
LdsOrdBase.from_struct(struct.get("lds_ord_list", default.lds_ord_list)),
|
||||
CitationBase.from_struct(struct.get("citation_list", default.citation_list)),
|
||||
LdsOrdBase.from_struct(struct.get("lds_ord_list",
|
||||
default.lds_ord_list)),
|
||||
CitationBase.from_struct(struct.get("citation_list",
|
||||
default.citation_list)),
|
||||
NoteBase.from_struct(struct.get("note_list", default.note_list)),
|
||||
struct.get("change", default.change),
|
||||
TagBase.from_struct(struct.get("tag_list", default.tag_list)),
|
||||
struct.get("private", default.private),
|
||||
[PersonRef.from_struct(p) for p in struct.get("person_ref_list", default.person_ref_list)]
|
||||
[PersonRef.from_struct(p)
|
||||
for p in struct.get("person_ref_list", default.person_ref_list)]
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -394,9 +405,9 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
self.event_ref_list = new_list
|
||||
|
||||
# Reset the indexes after deleting the event from even_ref_list
|
||||
if (self.birth_ref_index != -1):
|
||||
if self.birth_ref_index != -1:
|
||||
self.set_birth_ref(birth_ref)
|
||||
if (self.death_ref_index != -1):
|
||||
if self.death_ref_index != -1:
|
||||
self.set_death_ref(death_ref)
|
||||
elif classname == 'Person':
|
||||
new_list = [ref for ref in self.person_ref_list
|
||||
|
@@ -170,15 +170,20 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
struct.get("title", default.title),
|
||||
struct.get("long", default.long),
|
||||
struct.get("lat", default.lat),
|
||||
[PlaceRef.from_struct(pr) for pr in struct.get("placeref_list", default.placeref_list)],
|
||||
[PlaceRef.from_struct(pr)
|
||||
for pr in struct.get("placeref_list", default.placeref_list)],
|
||||
PlaceName.from_struct(struct.get("name", {})),
|
||||
[PlaceName.from_struct(an) for an in struct.get("alt_names", default.alt_names)],
|
||||
[PlaceName.from_struct(an)
|
||||
for an in struct.get("alt_names", default.alt_names)],
|
||||
PlaceType.from_struct(struct.get("place_type", {})),
|
||||
struct.get("code", default.code),
|
||||
[Location.from_struct(al) for al in struct.get("alt_loc", default.alt_loc)],
|
||||
[Location.from_struct(al)
|
||||
for al in struct.get("alt_loc", default.alt_loc)],
|
||||
UrlBase.from_struct(struct.get("urls", default.urls)),
|
||||
MediaBase.from_struct(struct.get("media_list", default.media_list)),
|
||||
CitationBase.from_struct(struct.get("citation_list", default.citation_list)),
|
||||
MediaBase.from_struct(struct.get("media_list",
|
||||
default.media_list)),
|
||||
CitationBase.from_struct(struct.get("citation_list",
|
||||
default.citation_list)),
|
||||
NoteBase.from_struct(struct.get("note_list", default.note_list)),
|
||||
struct.get("change", default.change),
|
||||
TagBase.from_struct(struct.get("tag_list", default.tag_list)),
|
||||
|
@@ -43,8 +43,8 @@ from .citationbase import IndirectCitationBase
|
||||
# Repository class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Repository(NoteBase, AddressBase, UrlBase,
|
||||
IndirectCitationBase, PrimaryObject):
|
||||
class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase,
|
||||
PrimaryObject):
|
||||
"""A location where collections of Sources are found."""
|
||||
|
||||
def __init__(self):
|
||||
|
@@ -128,12 +128,15 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
|
||||
struct.get("title", default.title),
|
||||
struct.get("author", default.author),
|
||||
struct.get("pubinfo", default.pubinfo),
|
||||
NoteBase.from_struct(struct.get("note_list", default.note_list)),
|
||||
MediaBase.from_struct(struct.get("media_list", default.media_list)),
|
||||
NoteBase.from_struct(struct.get("note_list",
|
||||
default.note_list)),
|
||||
MediaBase.from_struct(struct.get("media_list",
|
||||
default.media_list)),
|
||||
struct.get("abbrev", default.abbrev),
|
||||
struct.get("change", default.change),
|
||||
SrcAttributeBase.from_struct(struct.get("srcattr_list", {})),
|
||||
[RepoRef.from_struct(rr) for rr in struct.get("reporef_list", default.reporef_list)],
|
||||
[RepoRef.from_struct(rr)
|
||||
for rr in struct.get("reporef_list", default.reporef_list)],
|
||||
TagBase.from_struct(struct.get("tag_list", default.tag_list)),
|
||||
struct.get("private", default.private))
|
||||
|
||||
|
@@ -53,9 +53,9 @@ class Tag(TableObject):
|
||||
TableObject.__init__(self, source)
|
||||
|
||||
if source:
|
||||
self.__name = source.__name
|
||||
self.__color = source.__color
|
||||
self.__priority = source.__priority
|
||||
self.__name = source.name
|
||||
self.__color = source.color
|
||||
self.__priority = source.priority
|
||||
else:
|
||||
self.__name = ""
|
||||
self.__color = "#000000000000" # Black
|
||||
@@ -131,9 +131,9 @@ class Tag(TableObject):
|
||||
if other is None:
|
||||
other = Tag()
|
||||
|
||||
if self.__name != other.__name or \
|
||||
self.__color != other.__color or \
|
||||
self.__priority != other.__priority:
|
||||
if (self.__name != other.name or
|
||||
self.__color != other.color or
|
||||
self.__priority != other.priority):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
Reference in New Issue
Block a user