* src/Date.py: Raise Exception.DateError on invalid arguments
svn: r4581
This commit is contained in:
parent
46f65e9d33
commit
dffb9781b3
@ -6,6 +6,8 @@
|
||||
* src/dates/Date_de.py: Register for all variants of german; Add other
|
||||
variants of month names for parser
|
||||
|
||||
* src/Date.py: Raise Exception.DateError on invalid arguments
|
||||
|
||||
2005-05-12 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsBSDDB.py: force database sync on transaction commit
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision$"
|
||||
|
||||
from Errors import DateError
|
||||
from CalSdn import *
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -233,6 +234,8 @@ class Date:
|
||||
"""
|
||||
Sets the modifier for the date.
|
||||
"""
|
||||
if val not in (MOD_NONE,MOD_BEFORE,MOD_AFTER,MOD_ABOUT,MOD_RANGE,MOD_SPAN,MOD_TEXTONLY):
|
||||
raise DateError("Invalid modifier")
|
||||
self.modifier = val
|
||||
|
||||
def get_quality(self):
|
||||
@ -250,6 +253,8 @@ class Date:
|
||||
"""
|
||||
Sets the quality selected for the date.
|
||||
"""
|
||||
if val not in (QUAL_NONE,QUAL_ESTIMATED,QUAL_CALCULATED):
|
||||
raise DateError("Invalid quality")
|
||||
self.quality = val
|
||||
|
||||
def get_calendar(self):
|
||||
@ -270,6 +275,8 @@ class Date:
|
||||
"""
|
||||
Sets the calendar selected for the date.
|
||||
"""
|
||||
if val not in (CAL_GREGORIAN,CAL_JULIAN,CAL_HEBREW,CAL_FRENCH,CAL_PERSIAN,CAL_ISLAMIC):
|
||||
raise DateError("Invalid calendar")
|
||||
self.calendar = val
|
||||
|
||||
def get_start_date(self):
|
||||
@ -427,6 +434,18 @@ class Date:
|
||||
|
||||
The sort value is recalculated.
|
||||
"""
|
||||
|
||||
if modifier in (MOD_NONE,MOD_BEFORE,MOD_AFTER,MOD_ABOUT) and len(value) < 4:
|
||||
raise DateError("Invalid value. Should be: (DD,MM,YY,slash)")
|
||||
if modifier in (MOD_RANGE,MOD_SPAN) and len(value) < 8:
|
||||
raise DateError("Invalid value. Should be: (DD,MM,YY,slash1,DD,MM,YY,slash2)")
|
||||
if modifier not in (MOD_NONE,MOD_BEFORE,MOD_AFTER,MOD_ABOUT,MOD_RANGE,MOD_SPAN,MOD_TEXTONLY):
|
||||
raise DateError("Invalid modifier")
|
||||
if quality not in (QUAL_NONE,QUAL_ESTIMATED,QUAL_CALCULATED):
|
||||
raise DateError("Invalid quality")
|
||||
if calendar not in (CAL_GREGORIAN,CAL_JULIAN,CAL_HEBREW,CAL_FRENCH,CAL_PERSIAN,CAL_ISLAMIC):
|
||||
raise DateError("Invalid calendar")
|
||||
|
||||
self.quality = quality
|
||||
self.modifier = modifier
|
||||
self.calendar = calendar
|
||||
|
Loading…
Reference in New Issue
Block a user