diff --git a/ChangeLog b/ChangeLog index a9f21174b..633bd7639 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-11-25 Douglas S. Blank + * 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 * src/Config/_GrampsGconfKeys.py: fixed changes in gconf interface diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index 10838345e..642375c50 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -54,24 +54,7 @@ log = logging.getLogger(".Date") # #------------------------------------------------------------------------ from gen.lib.calendar import * - -#------------------------------------------------------------------------ -# -# 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 +import Config #------------------------------------------------------------------------- # @@ -291,15 +274,15 @@ class Date: # if BEFORE, AFTER, or ABOUT/EST, adjust: if self.modifier == Date.MOD_BEFORE: stopmax = date_offset(startmin, -1) - fdiff = _DATE_BEFORE_RANGE + fdiff = Config.get(Config.DATE_BEFORE_RANGE) startmin = (stopmax[0] - fdiff, stopmax[1], stopmax[2]) elif self.modifier == Date.MOD_AFTER: startmin = date_offset(stopmax, 1) - fdiff = _DATE_AFTER_RANGE + fdiff = Config.get(Config.DATE_AFTER_RANGE) stopmax = (startmin[0] + fdiff, startmin[1], startmin[2]) elif (self.modifier == Date.MOD_ABOUT or self.quality == Date.QUAL_ESTIMATED): - fdiff = _DATE_ABOUT_RANGE + fdiff = Config.get(Config.DATE_ABOUT_RANGE) startmin = (startmin[0] - fdiff, startmin[1], startmin[2]) stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2]) # return tuples not lists, for comparisons diff --git a/src/gen/lib/test/date_test.py b/src/gen/lib/test/date_test.py index f001ba79b..6fd8ba8ab 100644 --- a/src/gen/lib/test/date_test.py +++ b/src/gen/lib/test/date_test.py @@ -29,6 +29,7 @@ import unittest from test import test_util test_util.path_append_parent() +import Config import date from DateHandler import parser as df @@ -124,6 +125,9 @@ if __name__ == "__main__": "before 14 Thermidor 190 (French Republican)", 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() count = 1 for test in tests: