diff options
author | isen <isen@isen-desktop.(none)> | 2009-09-25 03:44:47 (GMT) |
---|---|---|
committer | isen <isen@isen-desktop.(none)> | 2009-09-25 03:44:47 (GMT) |
commit | c7957e876fdc012af627f0cfacca019daffbbaad (patch) | |
tree | 8b8c0a82f7389a4565a9a57c4c5051fffb060367 /tutorius | |
parent | c8f35a0319cfafb3573a6e55318f8ac33831ddfa (diff) |
propriété position, tuple de deux int (sans contraintes)
Diffstat (limited to 'tutorius')
-rw-r--r-- | tutorius/constraints.py | 12 | ||||
-rw-r--r-- | tutorius/properties.py | 26 |
2 files changed, 37 insertions, 1 deletions
diff --git a/tutorius/constraints.py b/tutorius/constraints.py index 36abdfb..f2e324f 100644 --- a/tutorius/constraints.py +++ b/tutorius/constraints.py @@ -204,4 +204,14 @@ class FileConstraint(Constraint): if not os.path.isfile(value): raise FileConstraintError("Non-existing file : %s"%value) return - + +class SameTypeConstraint(Exception): + pass + +class SameTypeConstraint(ValueConstraint): + pass + #def validate(self, typePropertie): + # if self.limit != typePropertie: + # raise SameTypeConstraint("Value with a diffferent type") + #return + diff --git a/tutorius/properties.py b/tutorius/properties.py index 7423d25..9db600e 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -310,5 +310,31 @@ class TAddonProperty(TutoriusProperty): if isinstance(value, TPropContainer): return super(TAddonProperty, self).validate(value) raise ValueError("Expected TPropContainer instance as TaddonProperty value") + + +class TPositionProperty(TutoriusProperty): + """ + Represents a tuple of two int. The first value is the x position and the second the y position + """ + def __init__(self, (x, y)): + TutoriusProperty.__init__(self) + self.type = "position" + self._x=x or 0 + self._y=y or 0 + self.default = self.validate((self._x,self._y)) + #voir les contraintes ou créer x en TintProperty + + +#class TArrayOneTypeProperty(TutoriusProperty): +# """ +# Represents an array list of properties. Can have a maximum number of element +# limit. All the elements in the list must have the same type. +# """ +# def __init__(self, value, min_size_limit=None, max_size_limit=None): +# TutoriusProperty.__init__(self) +# self.max_size_limit = MaxSizeConstraint(max_size_limit) +# self.min_size_limit = MinSizeConstraint(min_size_limit) +# self.type = SameTypeConstraint(self.type) +# self.default = self.validate(value) |