Primary object pylint improvements

This commit is contained in:
Nick Hall
2015-12-31 23:06:16 +00:00
parent e82148677d
commit 307f236771
10 changed files with 180 additions and 144 deletions

View File

@@ -30,7 +30,6 @@ Citation object for Gramps.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import logging import logging
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -46,6 +45,8 @@ from .attrbase import SrcAttributeBase
from .citationbase import IndirectCitationBase from .citationbase import IndirectCitationBase
from .handle import Handle from .handle import Handle
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Citation class # Citation class

View File

@@ -30,7 +30,6 @@ Event object for Gramps.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import logging import logging
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -48,6 +47,8 @@ from .tagbase import TagBase
from .eventtype import EventType from .eventtype import EventType
from .handle import Handle from .handle import Handle
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Event class # Event class
@@ -84,8 +85,8 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
PlaceBase.__init__(self, source) PlaceBase.__init__(self, source)
if source: if source:
self.__description = source.__description self.__description = source.description
self.__type = EventType(source.__type) self.__type = EventType(source.type)
else: else:
self.__description = "" self.__description = ""
self.__type = EventType() self.__type = EventType()
@@ -349,9 +350,9 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
if other is None: if other is None:
other = Event(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.place or other.place) and (self.place != other.place)) or \
self.__description != other.__description \ self.__description != other.description \
or self.private != other.private or \ or self.private != other.private or \
(not self.get_date_object().is_equal(other.get_date_object())) or \ (not self.get_date_object().is_equal(other.get_date_object())) or \
len(self.get_citation_list()) != \ len(self.get_citation_list()) != \
@@ -360,9 +361,9 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
index = 0 index = 0
olist = other.get_citation_list() 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 # see comment in srefs_are_equal in gen/plug/report/_bibliography.py
if a != olist[index]: if handle != olist[index]:
return False return False
index += 1 index += 1
@@ -401,7 +402,8 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
:rtype: tuple :rtype: tuple
""" """
return self.__type 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): def set_description(self, description):
""" """
@@ -422,5 +424,6 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
:rtype: str :rtype: str
""" """
return self.__description 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')

View File

@@ -32,7 +32,6 @@ Family object for Gramps.
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from warnings import warn from warnings import warn
import logging import logging
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -52,6 +51,8 @@ from .familyreltype import FamilyRelType
from .const import IDENTICAL, EQUAL, DIFFERENT from .const import IDENTICAL, EQUAL, DIFFERENT
from .handle import Handle from .handle import Handle
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Family class # Family class
@@ -173,16 +174,27 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
default = Family() default = Family()
return (Handle.from_struct(struct.get("handle", default.handle)), return (Handle.from_struct(struct.get("handle", default.handle)),
struct.get("gramps_id", default.gramps_id), struct.get("gramps_id", default.gramps_id),
Handle.from_struct(struct.get("father_handle", default.father_handle)), Handle.from_struct(struct.get("father_handle",
Handle.from_struct(struct.get("mother_handle", default.mother_handle)), default.father_handle)),
[ChildRef.from_struct(cr) for cr in struct.get("child_ref_list", default.child_ref_list)], 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", {})), FamilyRelType.from_struct(struct.get("type", {})),
[EventRef.from_struct(er) for er in struct.get("event_ref_list", default.event_ref_list)], [EventRef.from_struct(er)
MediaBase.from_struct(struct.get("media_list", default.media_list)), for er in struct.get("event_ref_list",
AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), default.event_ref_list)],
LdsOrdBase.from_struct(struct.get("lds_ord_list", default.lds_ord_list)), MediaBase.from_struct(struct.get("media_list",
CitationBase.from_struct(struct.get("citation_list", default.citation_list)), default.media_list)),
NoteBase.from_struct(struct.get("note_list", default.note_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), struct.get("change", default.change),
TagBase.from_struct(struct.get("tag_list", default.tag_list)), TagBase.from_struct(struct.get("tag_list", default.tag_list)),
struct.get("private", default.private)) struct.get("private", default.private))
@@ -255,9 +267,9 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
if self.mother_handle in handle_list: if self.mother_handle in handle_list:
self.mother_handle = None self.mother_handle = None
elif classname == 'Place': elif classname == 'Place':
for x in self.lds_ord_list: for lds_ord in self.lds_ord_list:
if x.place in handle_list: if lds_ord.place in handle_list:
x.place = None lds_ord.place = None
def _replace_handle_reference(self, classname, old_handle, new_handle): 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: if self.mother_handle == old_handle:
self.mother_handle = new_handle self.mother_handle = new_handle
elif classname == 'Place': elif classname == 'Place':
for x in self.lds_ord_list: for lds_ord in self.lds_ord_list:
if x.place == old_handle: if lds_ord.place == old_handle:
x.place = new_handle lds_ord.place = new_handle
def get_text_data_list(self): def get_text_data_list(self):
""" """

View File

@@ -33,7 +33,6 @@ Media object for Gramps.
import os import os
from urllib.parse import urlparse from urllib.parse import urlparse
import logging import logging
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -48,6 +47,8 @@ from .attrbase import AttributeBase
from .tagbase import TagBase from .tagbase import TagBase
from .handle import Handle from .handle import Handle
LOG = logging.getLogger(".citation")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# MediaObject class # MediaObject class

View File

@@ -46,9 +46,9 @@ from .attrtype import AttributeType
from .eventroletype import EventRoleType from .eventroletype import EventRoleType
from .attribute import Attribute from .attribute import Attribute
from .const import IDENTICAL, EQUAL, DIFFERENT from .const import IDENTICAL, EQUAL, DIFFERENT
from .handle import Handle
from ..const import GRAMPS_LOCALE as glocale from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = 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 return isinstance(other, Person) and self.handle == other.handle
def __ne__(self, other): def __ne__(self, other):
return not self == other return self != other
def serialize(self): def serialize(self):
""" """
@@ -248,23 +248,34 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
struct.get("gramps_id", default.gramps_id), struct.get("gramps_id", default.gramps_id),
struct.get("gender", default.gender), struct.get("gender", default.gender),
Name.from_struct(struct.get("primary_name", {})), 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("death_ref_index", default.death_ref_index),
struct.get("birth_ref_index", default.birth_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)], [EventRef.from_struct(er)
[Handle.from_struct(handle) for handle in struct.get("family_list", default.family_list)], for er in struct.get("event_ref_list", default.event_ref_list)],
[Handle.from_struct(handle) for handle in struct.get("parent_family_list", default.parent_family_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)), MediaBase.from_struct(struct.get("media_list", default.media_list)),
AddressBase.from_struct(struct.get("address_list", default.address_list)), AddressBase.from_struct(struct.get("address_list",
AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), default.address_list)),
AttributeBase.from_struct(struct.get("attribute_list",
default.attribute_list)),
UrlBase.from_struct(struct.get("urls", default.urls)), UrlBase.from_struct(struct.get("urls", default.urls)),
LdsOrdBase.from_struct(struct.get("lds_ord_list", default.lds_ord_list)), LdsOrdBase.from_struct(struct.get("lds_ord_list",
CitationBase.from_struct(struct.get("citation_list", default.citation_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)), NoteBase.from_struct(struct.get("note_list", default.note_list)),
struct.get("change", default.change), struct.get("change", default.change),
TagBase.from_struct(struct.get("tag_list", default.tag_list)), TagBase.from_struct(struct.get("tag_list", default.tag_list)),
struct.get("private", default.private), 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 @classmethod
@@ -394,9 +405,9 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
self.event_ref_list = new_list self.event_ref_list = new_list
# Reset the indexes after deleting the event from even_ref_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) self.set_birth_ref(birth_ref)
if (self.death_ref_index != -1): if self.death_ref_index != -1:
self.set_death_ref(death_ref) self.set_death_ref(death_ref)
elif classname == 'Person': elif classname == 'Person':
new_list = [ref for ref in self.person_ref_list new_list = [ref for ref in self.person_ref_list

View File

@@ -170,15 +170,20 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
struct.get("title", default.title), struct.get("title", default.title),
struct.get("long", default.long), struct.get("long", default.long),
struct.get("lat", default.lat), 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(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", {})), PlaceType.from_struct(struct.get("place_type", {})),
struct.get("code", default.code), 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)), UrlBase.from_struct(struct.get("urls", default.urls)),
MediaBase.from_struct(struct.get("media_list", default.media_list)), MediaBase.from_struct(struct.get("media_list",
CitationBase.from_struct(struct.get("citation_list", default.citation_list)), default.media_list)),
CitationBase.from_struct(struct.get("citation_list",
default.citation_list)),
NoteBase.from_struct(struct.get("note_list", default.note_list)), NoteBase.from_struct(struct.get("note_list", default.note_list)),
struct.get("change", default.change), struct.get("change", default.change),
TagBase.from_struct(struct.get("tag_list", default.tag_list)), TagBase.from_struct(struct.get("tag_list", default.tag_list)),

View File

@@ -43,8 +43,8 @@ from .citationbase import IndirectCitationBase
# Repository class # Repository class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Repository(NoteBase, AddressBase, UrlBase, class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase,
IndirectCitationBase, PrimaryObject): PrimaryObject):
"""A location where collections of Sources are found.""" """A location where collections of Sources are found."""
def __init__(self): def __init__(self):

View File

@@ -128,12 +128,15 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
struct.get("title", default.title), struct.get("title", default.title),
struct.get("author", default.author), struct.get("author", default.author),
struct.get("pubinfo", default.pubinfo), struct.get("pubinfo", default.pubinfo),
NoteBase.from_struct(struct.get("note_list", default.note_list)), NoteBase.from_struct(struct.get("note_list",
MediaBase.from_struct(struct.get("media_list", default.media_list)), default.note_list)),
MediaBase.from_struct(struct.get("media_list",
default.media_list)),
struct.get("abbrev", default.abbrev), struct.get("abbrev", default.abbrev),
struct.get("change", default.change), struct.get("change", default.change),
SrcAttributeBase.from_struct(struct.get("srcattr_list", {})), 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)), TagBase.from_struct(struct.get("tag_list", default.tag_list)),
struct.get("private", default.private)) struct.get("private", default.private))

View File

@@ -53,9 +53,9 @@ class Tag(TableObject):
TableObject.__init__(self, source) TableObject.__init__(self, source)
if source: if source:
self.__name = source.__name self.__name = source.name
self.__color = source.__color self.__color = source.color
self.__priority = source.__priority self.__priority = source.priority
else: else:
self.__name = "" self.__name = ""
self.__color = "#000000000000" # Black self.__color = "#000000000000" # Black
@@ -131,9 +131,9 @@ class Tag(TableObject):
if other is None: if other is None:
other = Tag() other = Tag()
if self.__name != other.__name or \ if (self.__name != other.name or
self.__color != other.__color or \ self.__color != other.color or
self.__priority != other.__priority: self.__priority != other.priority):
return False return False
return True return True