increase pylint score of proxybase.py from 6.41 to 8.22

This commit is contained in:
Paul Franklin 2016-06-04 21:19:36 -07:00
parent 1e102a36e4
commit 84130d221f
2 changed files with 88 additions and 60 deletions

View File

@ -989,19 +989,25 @@ class DbReadBase:
"""
raise NotImplementedError
def iter_citations(self, order_by=None):
"""
Return an iterator over objects for Citations in the database
"""
raise NotImplementedError
def iter_event_handles(self):
"""
Return an iterator over handles for Events in the database
"""
raise NotImplementedError
def iter_events(self):
def iter_events(self, order_by=None):
"""
Return an iterator over objects for Events in the database
"""
raise NotImplementedError
def iter_families(self):
def iter_families(self, order_by=None):
"""
Return an iterator over objects for Families in the database
"""
@ -1019,7 +1025,7 @@ class DbReadBase:
"""
raise NotImplementedError
def iter_media(self):
def iter_media(self, order_by=None):
"""
Return an iterator over objects for Medias in the database
"""
@ -1031,13 +1037,13 @@ class DbReadBase:
"""
raise NotImplementedError
def iter_notes(self):
def iter_notes(self, order_by=None):
"""
Return an iterator over objects for Notes in the database
"""
raise NotImplementedError
def iter_people(self):
def iter_people(self, order_by=None):
"""
Return an iterator over objects for Persons in the database
"""
@ -1055,13 +1061,13 @@ class DbReadBase:
"""
raise NotImplementedError
def iter_places(self):
def iter_places(self, order_by=None):
"""
Return an iterator over objects for Places in the database
"""
raise NotImplementedError
def iter_repositories(self):
def iter_repositories(self, order_by=None):
"""
Return an iterator over objects for Repositories in the database
"""
@ -1079,7 +1085,7 @@ class DbReadBase:
"""
raise NotImplementedError
def iter_sources(self):
def iter_sources(self, order_by=None):
"""
Return an iterator over objects for Sources in the database
"""
@ -1091,7 +1097,7 @@ class DbReadBase:
"""
raise NotImplementedError
def iter_tags(self):
def iter_tags(self, order_by=None):
"""
Return an iterator over objects for Tags in the database
"""

View File

@ -36,10 +36,8 @@ import types
#
#-------------------------------------------------------------------------
from ..db.base import DbReadBase, DbWriteBase, sort_objects
from ..lib import (MediaRef, Attribute, Address, EventRef,
Person, Name, Source, RepoRef, Media, Place, Event,
Family, ChildRef, Repository, LdsOrd, Surname, Citation,
SrcAttribute, Note, Tag)
from ..lib import (Citation, Event, Family, Media, Note, Person, Place,
Repository, Source, Tag)
class ProxyCursor:
"""
@ -76,6 +74,7 @@ class ProxyMap:
return self.get_raw(handle)
def keys(self):
""" return the keys """
return [bytes(key, "utf-8") for key in self.get_keys()]
class ProxyDbBase(DbReadBase):
@ -338,7 +337,7 @@ class ProxyDbBase(DbReadBase):
else:
return []
def get_event_handles(self, sort_handles=True):
def get_event_handles(self):
"""
Return a list of database handles, one handle for each Event in
the database.
@ -388,7 +387,7 @@ class ProxyDbBase(DbReadBase):
else:
return []
def get_repository_handles(self, sort_handles=True):
def get_repository_handles(self):
"""
Return a list of database handles, one handle for each Repository in
the database.
@ -398,7 +397,7 @@ class ProxyDbBase(DbReadBase):
else:
return []
def get_note_handles(self, sort_handles=True):
def get_note_handles(self):
"""
Return a list of database handles, one handle for each Note in
the database.
@ -480,7 +479,8 @@ class ProxyDbBase(DbReadBase):
Return an iterator over database handles, one handle for each
Repository in the database.
"""
return filter(self.include_repository, self.db.iter_repository_handles())
return filter(self.include_repository,
self.db.iter_repository_handles())
def iter_note_handles(self):
"""
@ -498,7 +498,8 @@ class ProxyDbBase(DbReadBase):
def __iter_object(self, selector, method, order_by=None):
""" Helper function to return an iterator over an object class """
retval = filter(lambda obj: ((selector is None) or selector(obj.handle)),
retval = filter(lambda obj:
((selector is None) or selector(obj.handle)),
method())
if order_by:
return sort_objects([item for item in retval], order_by, self)
@ -509,37 +510,43 @@ class ProxyDbBase(DbReadBase):
"""
Return an iterator over Person objects in the database
"""
return self.__iter_object(self.include_person, self.db.iter_people, order_by)
return self.__iter_object(self.include_person,
self.db.iter_people, order_by)
def iter_families(self, order_by=None):
"""
Return an iterator over Family objects in the database
"""
return self.__iter_object(self.include_family, self.db.iter_families, order_by)
return self.__iter_object(self.include_family,
self.db.iter_families, order_by)
def iter_events(self, order_by=None):
"""
Return an iterator over Event objects in the database
"""
return self.__iter_object(self.include_event, self.db.iter_events, order_by)
return self.__iter_object(self.include_event,
self.db.iter_events, order_by)
def iter_places(self, order_by=None):
"""
Return an iterator over Place objects in the database
"""
return self.__iter_object(self.include_place, self.db.iter_places, order_by)
return self.__iter_object(self.include_place,
self.db.iter_places, order_by)
def iter_sources(self, order_by=None):
"""
Return an iterator over Source objects in the database
"""
return self.__iter_object(self.include_source, self.db.iter_sources, order_by)
return self.__iter_object(self.include_source,
self.db.iter_sources, order_by)
def iter_citations(self, order_by=None):
"""
Return an iterator over Citation objects in the database
"""
return self.__iter_object(self.include_citation, self.db.iter_citations, order_by)
return self.__iter_object(self.include_citation,
self.db.iter_citations, order_by)
def iter_media(self, order_by=None):
"""
@ -559,13 +566,15 @@ class ProxyDbBase(DbReadBase):
"""
Return an iterator over Note objects in the database
"""
return self.__iter_object(self.include_note, self.db.iter_notes, order_by)
return self.__iter_object(self.include_note,
self.db.iter_notes, order_by)
def iter_tags(self, order_by=None):
"""
Return an iterator over Tag objects in the database
"""
return self.__iter_object(self.include_tag, self.db.iter_tags, order_by)
return self.__iter_object(self.include_tag,
self.db.iter_tags, order_by)
@staticmethod
def gfilter(predicate, obj):
@ -895,8 +904,11 @@ class ProxyDbBase(DbReadBase):
return self.db.get_name_types()
def get_origin_types(self):
"""returns a list of all custom origin types associated with Person/Surname
instances in the database"""
"""
returns a list of all custom origin types
associated with Person/Surname
instances in the database
"""
return self.db.get_origin_types()
def get_repository_types(self):
@ -910,8 +922,8 @@ class ProxyDbBase(DbReadBase):
return self.db.get_note_types()
def get_source_attribute_types(self):
"""returns a list of all Attribute types associated with Source/Citation
instances in the database"""
"""returns a list of all Attribute types associated with
Source/Citation instances in the database"""
return self.db.get_source_attribute_types()
def get_source_media_types(self):
@ -959,70 +971,80 @@ class ProxyDbBase(DbReadBase):
Returns True if the handle exists in the current Person database.
"""
return self.gfilter(self.include_person,
self.db.get_person_from_handle(handle)) is not None
self.db.get_person_from_handle(handle)
) is not None
def has_family_handle(self, handle):
"""
Returns True if the handle exists in the current Family database.
"""
return self.gfilter(self.include_family,
self.db.get_family_from_handle(handle)) is not None
self.db.get_family_from_handle(handle)
) is not None
def has_event_handle(self, handle):
"""
returns True if the handle exists in the current Event database.
"""
return self.gfilter(self.include_event,
self.db.get_event_from_handle(handle)) is not None
self.db.get_event_from_handle(handle)
) is not None
def has_source_handle(self, handle):
"""
returns True if the handle exists in the current Source database.
"""
return self.gfilter(self.include_source,
self.db.get_source_from_handle(handle)) is not None
self.db.get_source_from_handle(handle)
) is not None
def has_citation_handle(self, handle):
"""
returns True if the handle exists in the current Citation database.
"""
return self.gfilter(self.include_citation,
self.db.get_citation_from_handle(handle)) is not None
self.db.get_citation_from_handle(handle)
) is not None
def has_place_handle(self, handle):
"""
returns True if the handle exists in the current Place database.
"""
return self.gfilter(self.include_place,
self.db.get_place_from_handle(handle)) is not None
self.db.get_place_from_handle(handle)
) is not None
def has_media_handle(self, handle):
"""
returns True if the handle exists in the current Mediadatabase.
"""
return self.gfilter(self.include_media,
self.db.get_media_from_handle(handle)) is not None
self.db.get_media_from_handle(handle)
) is not None
def has_repository_handle(self, handle):
"""
returns True if the handle exists in the current Repository database.
"""
return self.gfilter(self.include_repository,
self.db.get_repository_from_handle(handle)) is not None
self.db.get_repository_from_handle(handle)
) is not None
def has_note_handle(self, handle):
"""
returns True if the handle exists in the current Note database.
"""
return self.gfilter(self.include_note,
self.db.get_note_from_handle(handle)) is not None
self.db.get_note_from_handle(handle)
) is not None
def has_tag_handle(self, handle):
"""
returns True if the handle exists in the current Tag database.
"""
return self.gfilter(self.include_tag,
self.db.get_tag_from_handle(handle)) is not None
self.db.get_tag_from_handle(handle)
) is not None
def get_mediapath(self):
"""returns the default media path of the database"""