* src/gen/lib/date.py: refer to Config values via Config.get()
* src/gen/lib/test/date_test.py: set Config values before testing 2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu> svn: r9402
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||||
|
* src/gen/lib/date.py: refer to Config values via Config.get()
|
||||||
|
* src/gen/lib/test/date_test.py: set Config values before testing
|
||||||
|
|
||||||
2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||||
* src/Config/_GrampsGconfKeys.py: fixed changes in gconf interface
|
* src/Config/_GrampsGconfKeys.py: fixed changes in gconf interface
|
||||||
|
|
||||||
|
@@ -54,24 +54,7 @@ log = logging.getLogger(".Date")
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from gen.lib.calendar import *
|
from gen.lib.calendar import *
|
||||||
|
import Config
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Constants
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#obtain the ranges once, they do not change!
|
|
||||||
try:
|
|
||||||
import Config
|
|
||||||
_DATE_BEFORE_RANGE = Config.get(Config.DATE_BEFORE_RANGE)
|
|
||||||
_DATE_AFTER_RANGE = Config.get(Config.DATE_AFTER_RANGE)
|
|
||||||
_DATE_ABOUT_RANGE = Config.get(Config.DATE_ABOUT_RANGE)
|
|
||||||
except ImportError:
|
|
||||||
# gen.lib used as module not part of GRAMPS
|
|
||||||
_DATE_BEFORE_RANGE = 9999
|
|
||||||
_DATE_AFTER_RANGE = 9999
|
|
||||||
_DATE_ABOUT_RANGE = 10
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -291,15 +274,15 @@ 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)
|
||||||
fdiff = _DATE_BEFORE_RANGE
|
fdiff = Config.get(Config.DATE_BEFORE_RANGE)
|
||||||
startmin = (stopmax[0] - fdiff, 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)
|
||||||
fdiff = _DATE_AFTER_RANGE
|
fdiff = Config.get(Config.DATE_AFTER_RANGE)
|
||||||
stopmax = (startmin[0] + fdiff, 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):
|
||||||
fdiff = _DATE_ABOUT_RANGE
|
fdiff = Config.get(Config.DATE_ABOUT_RANGE)
|
||||||
startmin = (startmin[0] - fdiff, startmin[1], startmin[2])
|
startmin = (startmin[0] - fdiff, startmin[1], startmin[2])
|
||||||
stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2])
|
stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2])
|
||||||
# return tuples not lists, for comparisons
|
# return tuples not lists, for comparisons
|
||||||
|
@@ -29,6 +29,7 @@ import unittest
|
|||||||
from test import test_util
|
from test import test_util
|
||||||
test_util.path_append_parent()
|
test_util.path_append_parent()
|
||||||
|
|
||||||
|
import Config
|
||||||
import date
|
import date
|
||||||
from DateHandler import parser as df
|
from DateHandler import parser as df
|
||||||
|
|
||||||
@@ -124,6 +125,9 @@ if __name__ == "__main__":
|
|||||||
"before 14 Thermidor 190 (French Republican)", False),
|
"before 14 Thermidor 190 (French Republican)", False),
|
||||||
("ab cd", "54 ab cd 2000", True, False),
|
("ab cd", "54 ab cd 2000", True, False),
|
||||||
]
|
]
|
||||||
|
Config.set(Config.DATE_BEFORE_RANGE, 9999)
|
||||||
|
Config.set(Config.DATE_AFTER_RANGE, 9999)
|
||||||
|
Config.set(Config.DATE_ABOUT_RANGE, 10)
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
count = 1
|
count = 1
|
||||||
for test in tests:
|
for test in tests:
|
||||||
|
Reference in New Issue
Block a user