* src/RelLib/_Date.py: pylint and remove import of DateHandler as not
really needed and unwanted in RelLib. svn: r8996
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2007-09-20 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
|
* src/RelLib/_Date.py: pylint and remove import of DateHandler as not
|
||||||
|
really needed and unwanted in RelLib.
|
||||||
|
|
||||||
2007-09-20 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-09-20 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/Config/_GrampsConfigKeys.py: add config keys for fuzzy date match
|
* src/Config/_GrampsConfigKeys.py: add config keys for fuzzy date match
|
||||||
* src/RelLib/_CalSdn.py: correct type in comment
|
* src/RelLib/_CalSdn.py: correct type in comment
|
||||||
|
@@ -292,17 +292,17 @@ class Date:
|
|||||||
# if BEFORE, AFTER, or ABOUT/EST, adjust:
|
# if BEFORE, AFTER, or ABOUT/EST, adjust:
|
||||||
if self.modifier == Date.MOD_BEFORE:
|
if self.modifier == Date.MOD_BEFORE:
|
||||||
stopmax = date_offset(startmin, -1)
|
stopmax = date_offset(startmin, -1)
|
||||||
f = _DATE_BEFORE_RANGE
|
fdiff = _DATE_BEFORE_RANGE
|
||||||
startmin = (stopmax[0] - f, stopmax[1], stopmax[2])
|
startmin = (stopmax[0] - fdiff, stopmax[1], stopmax[2])
|
||||||
elif self.modifier == Date.MOD_AFTER:
|
elif self.modifier == Date.MOD_AFTER:
|
||||||
startmin = date_offset(stopmax, 1)
|
startmin = date_offset(stopmax, 1)
|
||||||
f = _DATE_AFTER_RANGE
|
fdiff = _DATE_AFTER_RANGE
|
||||||
stopmax = (startmin[0] + f, startmin[1], startmin[2])
|
stopmax = (startmin[0] + fdiff, startmin[1], startmin[2])
|
||||||
elif (self.modifier == Date.MOD_ABOUT or
|
elif (self.modifier == Date.MOD_ABOUT or
|
||||||
self.quality == Date.QUAL_ESTIMATED):
|
self.quality == Date.QUAL_ESTIMATED):
|
||||||
f = _DATE_ABOUT_RANGE
|
fdiff = _DATE_ABOUT_RANGE
|
||||||
startmin = (startmin[0] - f, startmin[1], startmin[2])
|
startmin = (startmin[0] - fdiff, startmin[1], startmin[2])
|
||||||
stopmax = (stopmax[0] + f, stopmax[1], stopmax[2])
|
stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2])
|
||||||
# return tuples not lists, for comparisons
|
# return tuples not lists, for comparisons
|
||||||
return (tuple(startmin), tuple(stopmax))
|
return (tuple(startmin), tuple(stopmax))
|
||||||
|
|
||||||
@@ -318,10 +318,14 @@ class Date:
|
|||||||
"""
|
"""
|
||||||
if (other_date.modifier == Date.MOD_TEXTONLY or
|
if (other_date.modifier == Date.MOD_TEXTONLY or
|
||||||
self.modifier == Date.MOD_TEXTONLY):
|
self.modifier == Date.MOD_TEXTONLY):
|
||||||
import DateHandler
|
###from DateHandler import displayer
|
||||||
# If either date is just text, then we can only compare textual
|
# If either date is just text, then we can only compare textual
|
||||||
# representations
|
# representations
|
||||||
self_text = DateHandler.displayer.display(self)
|
# Use text as originally given or display date to format
|
||||||
|
# in preferences? That is use self.text or displayer ?
|
||||||
|
# It is unclean to import DateHandler in RelLib !
|
||||||
|
###self_text = displayer.display(self)
|
||||||
|
self_text = self.text
|
||||||
##DEBUG: print ' TEXT COMPARE ONLY '
|
##DEBUG: print ' TEXT COMPARE ONLY '
|
||||||
return (self_text.upper().find(other_date.text.upper()) != -1)
|
return (self_text.upper().find(other_date.text.upper()) != -1)
|
||||||
|
|
||||||
@@ -756,12 +760,12 @@ class Date:
|
|||||||
and self.get_day_valid()
|
and self.get_day_valid()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
""" Test function. Call it as follows from the command line (so as to find
|
# Test function. Call it as follows from the command line (so as to find
|
||||||
imported modules):
|
# imported modules):
|
||||||
export PYTHONPATH=/path/to/gramps/src python src/RelLib/_Date.py
|
# export PYTHONPATH=/path/to/gramps/src python src/RelLib/_Date.py
|
||||||
"""
|
#
|
||||||
import DateHandler
|
from DateHandler import _DateParser
|
||||||
df = DateHandler._DateParser.DateParser() # date factory
|
df = _DateParser.DateParser() # date factory
|
||||||
def test_date(d1, d2, expected1, expected2 = None):
|
def test_date(d1, d2, expected1, expected2 = None):
|
||||||
if expected2 == None:
|
if expected2 == None:
|
||||||
expected2 = expected1
|
expected2 = expected1
|
||||||
@@ -855,11 +859,13 @@ if __name__ == "__main__":
|
|||||||
("before 2007", "2000", True),
|
("before 2007", "2000", True),
|
||||||
# different calendar, same date
|
# different calendar, same date
|
||||||
("Aug 3, 1982", "14 Thermidor 190 (French Republican)", True),
|
("Aug 3, 1982", "14 Thermidor 190 (French Republican)", True),
|
||||||
("after Aug 3, 1982", "before 14 Thermidor 190 (French Republican)", False),
|
("after Aug 3, 1982",
|
||||||
|
"before 14 Thermidor 190 (French Republican)", False),
|
||||||
|
("ab cd", "54 ab cd 2000", True, False),
|
||||||
]
|
]
|
||||||
# test them:
|
# test them:
|
||||||
for data in tests:
|
for testdata in tests:
|
||||||
results = test_date(*data)
|
results = test_date(*testdata)
|
||||||
for result in results:
|
for result in results:
|
||||||
stats[result] += results[result]
|
stats[result] += results[result]
|
||||||
for result in stats:
|
for result in stats:
|
||||||
|
Reference in New Issue
Block a user