2008-02-22 Raphael Ackermann <raphael.ackermann@gmail.com>

* src/FilterEditor/_EditRule.py
    * src/Filters/Rules/_HasAttributeBase.py
    * src/Filters/Rules/Family/_MatchesFilter.py
    * src/Filters/Rules/Event/_MatchesFilter.py
    * src/Filters/Rules/Event/_MatchesSourceFilter.py
    * src/Filters/Rules/Event/_HasType.py
    * src/Filters/Rules/Event/_MatchesPersonFilter.py
    * src/Filters/Rules/_HasTextMatchingRegexpOf.py
    * src/Filters/Rules/_HasReferenceCountBase.py
    * src/Filters/Rules/_HasNoteSubstrBase.py
    * src/Filters/Rules/__init__.py
    * src/Filters/Rules/_HasGrampsId.py
    * src/Filters/Rules/_RegExpIdBase.py
    * src/Filters/Rules/_IsPrivate.py
    * src/Filters/Rules/_Rule.py
    * src/Filters/Rules/_HasMarkerBase.py
    * src/Filters/Rules/_HasEventBase.py
    * src/Filters/Rules/Note/_MatchesFilter.py
    * src/Filters/Rules/Person/_MatchesFilter.py
    * src/Filters/Rules/Person/_MatchesEventFilter.py
    * src/Filters/Rules/MediaObject/_MatchesFilter.py
    * src/Filters/Rules/_HasTextMatchingSubstringOf.py
    * src/Filters/Rules/_Everything.py
    * src/Filters/Rules/_MatchesFilterBase.py
    * src/Filters/Rules/_HasNoteRegexBase.py
    * src/DateHandler/_DateUtils.py
    pylint and doc fixes.

svn: r10094
This commit is contained in:
Raphael Ackermann
2008-02-22 10:50:06 +00:00
parent 19dd787311
commit f3db8c0e75
27 changed files with 222 additions and 174 deletions

View File

@@ -1,3 +1,33 @@
2008-02-22 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/FilterEditor/_EditRule.py
* src/Filters/Rules/_HasAttributeBase.py
* src/Filters/Rules/Family/_MatchesFilter.py
* src/Filters/Rules/Event/_MatchesFilter.py
* src/Filters/Rules/Event/_MatchesSourceFilter.py
* src/Filters/Rules/Event/_HasType.py
* src/Filters/Rules/Event/_MatchesPersonFilter.py
* src/Filters/Rules/_HasTextMatchingRegexpOf.py
* src/Filters/Rules/_HasReferenceCountBase.py
* src/Filters/Rules/_HasNoteSubstrBase.py
* src/Filters/Rules/__init__.py
* src/Filters/Rules/_HasGrampsId.py
* src/Filters/Rules/_RegExpIdBase.py
* src/Filters/Rules/_IsPrivate.py
* src/Filters/Rules/_Rule.py
* src/Filters/Rules/_HasMarkerBase.py
* src/Filters/Rules/_HasEventBase.py
* src/Filters/Rules/Note/_MatchesFilter.py
* src/Filters/Rules/Person/_MatchesFilter.py
* src/Filters/Rules/Person/_MatchesEventFilter.py
* src/Filters/Rules/MediaObject/_MatchesFilter.py
* src/Filters/Rules/_HasTextMatchingSubstringOf.py
* src/Filters/Rules/_Everything.py
* src/Filters/Rules/_MatchesFilterBase.py
* src/Filters/Rules/_HasNoteRegexBase.py
* src/DateHandler/_DateUtils.py
pylint and doc fixes.
2008-02-20 Frederik De Richter <frederik.de.richter@pandora.be>
* src/Merge/_MergePerson.py
* src/Merge/_MergeSource.py

View File

@@ -38,7 +38,7 @@ from DateHandler import LANG_TO_DISPLAY, LANG, parser, displayer
#--------------------------------------------------------------
def get_date_formats():
"""
Returns the lists supported formats for date parsers and displayers
Return the lists supported formats for date parsers and displayers.
"""
try:
return LANG_TO_DISPLAY[LANG].formats
@@ -53,7 +53,7 @@ def set_format(value):
def set_date(date_base, text) :
"""
Sets the date of the DateBase instance.
Set the date of the DateBase instance.
The date is parsed into a Date instance.
@@ -61,23 +61,25 @@ def set_date(date_base, text) :
@type date_base: DateBase
@param text: The text to use for the text string in date
@type text: str
"""
parser.set_date(date_base.get_date_object(), text)
def get_date(date_base) :
"""
Returns a string representation of the date of the DateBase instance.
Return a string representation of the date of the DateBase instance.
This representation is based off the default date display format
determined by the locale's DateDisplay instance.
@return: Returns a string representing the DateBase date
@rtype: str
"""
return displayer.display(date_base.get_date_object())
def get_quote_date(date_base):
"""
Returns a string representation of the date of the DateBase instance.
Return a string representation of the date of the DateBase instance.
This representation is based off the default date display format
determined by the locale's DateDisplay instance. The date is
@@ -85,5 +87,6 @@ def get_quote_date(date_base):
@return: Returns a string representing the DateBase date
@rtype: str
"""
return displayer.quote_display(date_base.get_date_object())

View File

@@ -99,16 +99,19 @@ class MyBoolean(gtk.CheckButton):
def get_text(self):
"""
This method returns the text to save. It should be the same
no matter the present locale (English or numeric types).
Return the text to save.
It should be the same no matter the present locale (English or numeric
types).
This class sets this to get_display_text, but when localization
is an issue (events/attr/etc types) then it has to be overridden.
"""
return str(int(self.get_active()))
def set_text(self, val):
"""
This method sets the selector state to display the passed value.
Set the selector state to display the passed value.
"""
is_active = bool(int(val))
self.set_active(is_active)
@@ -137,13 +140,16 @@ class MyInteger(gtk.SpinButton):
#
#-------------------------------------------------------------------------
class MyFilters(gtk.ComboBox):
"""Class to present a combobox of selectable filters
"""
Class to present a combobox of selectable filters.
"""
def __init__(self, filters, filter_name=None):
""" Construct the combobox from the entries of
the filters list.
filter_name is name of calling filter
If filter_name is given, it will be excluded from the dropdown box
"""
Construct the combobox from the entries of the filters list.
Filter_name is name of calling filter.
If filter_name is given, it will be excluded from the dropdown box.
"""
gtk.ComboBox.__init__(self)
store = gtk.ListStore(gobject.TYPE_STRING)
@@ -468,7 +474,8 @@ class EditRule(ManagedWindow.ManagedWindow):
elif v == _('Number of generations:'):
t = MyInteger(1, 32)
elif v == _('ID:'):
t = MyID(self.dbstate,self.uistate,self.track,self.namespace)
t = MyID(self.dbstate, self.uistate, self.track,
self.namespace)
elif v == _('Source ID:'):
t = MySource(self.db)
elif v == _('Filter name:'):
@@ -490,7 +497,8 @@ class EditRule(ManagedWindow.ManagedWindow):
elif v == _('Regular-Expression matching:'):
t = MyBoolean(_('Use regular expression'))
elif v == _('Include Family events:'):
t = MyBoolean(_('Also family events where person is wife/husband'))
t = MyBoolean(_('Also family events where person is '
'wife/husband'))
else:
t = MyEntry()
tlist.append(t)
@@ -503,7 +511,8 @@ class EditRule(ManagedWindow.ManagedWindow):
self.page_num = 0
self.store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
self.selection = self.rname.get_selection()
col = gtk.TreeViewColumn(_('Rule Name'),gtk.CellRendererText(),text=0)
col = gtk.TreeViewColumn(_('Rule Name'), gtk.CellRendererText(),
text=0)
self.rname.append_column(col)
self.rname.set_model(self.store)
@@ -567,15 +576,19 @@ class EditRule(ManagedWindow.ManagedWindow):
self.show()
def on_help_clicked(self, obj):
"""Display the relevant portion of GRAMPS manual"""
"""
Display the relevant portion of GRAMPS manual.
"""
GrampsDisplay.help('append-filtref')
def close_window(self, obj):
self.close()
def on_node_selected(self, obj):
"""Updates the informational display on the right hand side of
the dialog box with the description of the selected report"""
"""
Update the informational display on the right hand side of the dialog
box with the description of the selected report.
"""
store, node = self.selection.get_selected()
if node:

View File

@@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
from gen.lib import EventType
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -41,7 +41,7 @@ from Filters.Rules._Rule import Rule
#
#-------------------------------------------------------------------------
class HasType(Rule):
"""Rule that checks for an event of a particular type"""
"""Rule that checks for an event of a particular type."""
labels = [ _('Event type:') ]
name = _('Event with the particular type')

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
"""Rule that checks against another filter."""
name = _('Events matching the <filter>')
description = _("Matches events matched by the specified filter name")

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -45,6 +45,7 @@ class MatchesPersonFilter(MatchesFilterBase):
This is a base rule for subclassing by specific objects.
Subclasses need to define the namespace class attribute.
"""
labels = [_('Person filter name:'), _('Include Family events:')]
@@ -52,6 +53,7 @@ class MatchesPersonFilter(MatchesFilterBase):
description = _("Matches events of persons matched by the specified "
"person filter name")
category = _('General filters')
# we want to have this filter show person filters
namespace = 'Person'

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -49,6 +49,7 @@ class MatchesSourceFilter(MatchesFilterBase):
description = _("Matches events with sources that match the "
"specified source filter name")
category = _('General filters')
# we want to have this filter show source filters
namespace = 'Source'

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
"""Rule that checks against another filter."""
name = _('Families matching the <filter>')
description = _("Matches families matched by the specified filter name")

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
"""Rule that checks against another filter."""
name = _('Media objects matching the <filter>')
description = _("Matches media objects matched by the "

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
"""Rule that checks against another filter."""
name = _('Notes matching the <filter>')
description = _("Matches notes matched "

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -45,6 +45,7 @@ class MatchesEventFilter(MatchesFilterBase):
This is a base rule for subclassing by specific objects.
Subclasses need to define the namespace class attribute.
"""
labels = [_('Event filter name:')]
@@ -52,6 +53,7 @@ class MatchesEventFilter(MatchesFilterBase):
description = _("Matches persons who have events that match a certain"
" event filter")
category = _('General filters')
# we want to have this filter show event filters
namespace = 'Event'

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
"""Rule that checks against another filter."""
name = _('People matching the <filter>')
description = _("Matches people matched by the specified filter name")

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from _Rule import Rule
#
#-------------------------------------------------------------------------
class Everything(Rule):
"""Matches Everyone"""
"""Match Everyone."""
name = _('Every object')
category = _('General filters')

View File

@@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
from gen.lib import AttributeType
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -41,7 +41,9 @@ from Filters.Rules._Rule import Rule
#
#-------------------------------------------------------------------------
class HasAttributeBase(Rule):
"""Rule that checks for an object with a particular attribute"""
"""
Rule that checks for an object with a particular attribute.
"""
labels = [ _('Attribute:'), _('Value:') ]
name = _('Objects with the <attribute>')

View File

@@ -34,7 +34,7 @@ from gettext import gettext as _
#-------------------------------------------------------------------------
import DateHandler
from gen.lib import EventType
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -42,7 +42,7 @@ from Filters.Rules._Rule import Rule
#
#-------------------------------------------------------------------------
class HasEventBase(Rule):
"""Rule that checks for an event with a particular value"""
"""Rule that checks for an event with a particular value."""
labels = [ _('Event type:'),
@@ -79,11 +79,11 @@ class HasEventBase(Rule):
return False
if self.list[2]:
pl_id = event.get_place_handle()
if pl_id:
pl = db.get_place_from_handle(pl_id)
pn = pl.get_title()
if pn.upper().find(self.list[2].upper()) == -1:
place_id = event.get_place_handle()
if place_id:
place = db.get_place_from_handle(place_id)
place_name = place.get_title()
if place_name.upper().find(self.list[2].upper()) == -1:
return False
else:
return False

View File

@@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -40,7 +40,7 @@ from Filters.Rules._Rule import Rule
#
#-------------------------------------------------------------------------
class HasGrampsId(Rule):
"""Rule that checks for a person with a specific GRAMPS ID"""
"""Rule that checks for a person with a specific GRAMPS ID."""
labels = [ _('ID:') ]
name = _('Object with <Id>')

View File

@@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
from gen.lib import MarkerType
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -41,7 +41,7 @@ from Filters.Rules._Rule import Rule
#
#-------------------------------------------------------------------------
class HasMarkerBase(Rule):
"""Rule that checks for a person with a particular value"""
"""Rule that checks for a person with a particular value."""
labels = [ _('Marker type:')]

View File

@@ -33,13 +33,13 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "People having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteRegexBase(Rule):
"""People having notes containing <subtring>"""
"""People having notes containing <substring>."""
labels = [ _('Regular expression:')]
name = _('Objects having notes containing <regular expression>')

View File

@@ -32,17 +32,18 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "People having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteSubstrBase(Rule):
"""People having notes containing <subtring>"""
"""People having notes containing <substring>."""
labels = [ _('Substring:')]
name = _('Objects having notes containing <substring>')
description = _("Matches objects whose notes contain text matching a substring")
description = _("Matches objects whose notes contain text matching a "
"substring")
category = _('General filters')
def apply(self, db, person):

View File

@@ -32,13 +32,13 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "Objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountBase(Rule):
"""Objects with a reference count of <count>"""
"""Objects with a reference count of <count>."""
labels = [ _('Reference count must be:'), _('Reference count:')]
name = _('Objects with a reference count of <count>')
@@ -49,24 +49,24 @@ class HasReferenceCountBase(Rule):
def prepare(self, db):
# things we want to do just once, not for every handle
if self.list[0] == _('lesser than'):
self.countType = 0
self.count_type = 0
elif self.list[0] == _('greater than'):
self.countType = 2
self.count_type = 2
else:
self.countType = 1 # "equal to"
self.count_type = 1 # "equal to"
self.userSelectedCount = int(self.list[1])
def apply(self,db,object):
handle = object.get_handle()
def apply(self, db, obj):
handle = obj.get_handle()
count = 0
for item in db.find_backlink_handles(handle):
count += 1
if self.countType == 0: # "lesser than"
if self.count_type == 0: # "lesser than"
return count < self.userSelectedCount
elif self.countType == 2: # "greater than"
elif self.count_type == 2: # "greater than"
return count > self.userSelectedCount
# "equal to"
return count == self.userSelectedCount

View File

@@ -31,15 +31,14 @@
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from Filters.Rules import HasTextMatchingSubstringOf
#-------------------------------------------------------------------------
# "HasTextMatchingRegexOf"
#-------------------------------------------------------------------------
class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf):
"""This is wrapping HasTextMatchingSubstringOf to enable the regex_match
parameter.
"""
Wrap HasTextMatchingSubstringOf to enable the regex_match parameter.
"""
def __init__(self, list):
HasTextMatchingSubstringOf.__init__(self, list)

View File

@@ -32,13 +32,13 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "HasTextMatchingSubstringOf"
#-------------------------------------------------------------------------
class HasTextMatchingSubstringOf(Rule):
"""Rule that checks for string matches in any textual information"""
"""Rule that checks for string matches in any textual information."""
labels = [ _('Substring:'),
_('Case sensitive:'),

View File

@@ -32,13 +32,13 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "People marked private"
#-------------------------------------------------------------------------
class IsPrivate(Rule):
"""Objects marked private"""
"""Objects marked private."""
name = _('Objects marked private')
description = _("Matches objects that are indicated as private")

View File

@@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import Filters
from _Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -46,6 +46,7 @@ class MatchesFilterBase(Rule):
This is a base rule for subclassing by specific objects.
Subclasses need to define the namespace class attribute.
"""
labels = [_('Filter name:')]
@@ -89,8 +90,8 @@ class MatchesFilterBase(Rule):
return False
def find_filter(self):
""" helper function that can be usefull, returning the filter
selected or None
"""
Return the selected filter or None.
"""
if Filters.SystemFilters:
for filt in Filters.SystemFilters.get_filters(self.namespace):

View File

@@ -33,7 +33,7 @@ import re
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
@@ -42,8 +42,7 @@ from _Rule import Rule
#-------------------------------------------------------------------------
class RegExpIdBase(Rule):
"""
Rule that checks for an object whose GRAMPS ID
matches regular expression.
Rule that checks for an object whose GRAMPS ID matches regular expression.
"""
labels = [ _('Regular expression:') ]

View File

@@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
class Rule:
"""Base rule class"""
"""Base rule class."""
labels = []
name = ''

View File

@@ -26,19 +26,14 @@ Package providing filter rules for GRAMPS.
# Need to expose this to be available for filter plugins:
# the plugins should say: from Filters.Rules import Rule
from _Rule import Rule
from Filters.Rules._Rule import Rule
from _Everything import Everything
from _HasGrampsId import HasGrampsId
from _IsPrivate import IsPrivate
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
from Filters.Rules._Everything import Everything
from Filters.Rules._HasGrampsId import HasGrampsId
from Filters.Rules._IsPrivate import IsPrivate
from Filters.Rules._HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from Filters.Rules._HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
import Person
import Family
import Event
import Source
import Place
import MediaObject
import Repository
import Note
from Filters.Rules import (Person, Family, Event, Source, Place, MediaObject,
Repository, Note)