diff options
author | isen <isen@isen-desktop.(none)> | 2009-10-09 04:09:42 (GMT) |
---|---|---|
committer | isen <isen@isen-desktop.(none)> | 2009-10-09 04:09:42 (GMT) |
commit | 1d062b1e7397b9413f4f73efb451bb8d890ab296 (patch) | |
tree | 2d4ad914d9a6f02c232151522e5a081de0638057 /tutorius/constraints.py | |
parent | 335833bba32a4643e95bd31337637f5e2a075cee (diff) | |
parent | c67e568a0a34e89a77cb2121d2b3859cd6885e69 (diff) |
Merge branch 'lp426452_suite' into lp426452
lp426452_suite was the generalisation of the tail drawing (n tails)
Conflicts:
addons/bubblemessage.py
setup.cfg
tutorius/overlayer.py
Diffstat (limited to 'tutorius/constraints.py')
-rw-r--r-- | tutorius/constraints.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tutorius/constraints.py b/tutorius/constraints.py index 36abdfb..455ede3 100644 --- a/tutorius/constraints.py +++ b/tutorius/constraints.py @@ -204,4 +204,22 @@ class FileConstraint(Constraint): if not os.path.isfile(value): raise FileConstraintError("Non-existing file : %s"%value) return - + + +class SameTypeConstraintError(Exception): + pass + +class SameTypeConstraint(Constraint): + """ + Ensures that the list is not empty and that properties of the list have the same type. + """ + + def validate(self, value): + if len(value)==0: + raise SameTypeConstraintError("The list is empty") + for i in value: + if i.type != value[0].type: + raise SameTypeConstraintError("Properties have diffferent type") + return + + |