Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/properties.py
diff options
context:
space:
mode:
authorisen <isen@isen-desktop.(none)>2009-10-18 08:38:05 (GMT)
committer isen <isen@isen-desktop.(none)>2009-10-18 08:38:05 (GMT)
commit04bef3e0d6f0db689b31c05799f9a6c55e3220d9 (patch)
treed90d83a46a0ad38328ec16bfc2befab41839ab64 /tutorius/properties.py
parent1d062b1e7397b9413f4f73efb451bb8d890ab296 (diff)
Commit before holidays lp426452
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r--tutorius/properties.py77
1 files changed, 47 insertions, 30 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py
index 65059b2..28f0ed4 100644
--- a/tutorius/properties.py
+++ b/tutorius/properties.py
@@ -133,6 +133,13 @@ class TutoriusProperty(object):
constraint = getattr(self, constraint_name)
constraint.validate(value)
return value
+
+ def type(self,value):################################################
+ """
+ Allow to use type() in the same way for TutoriusProperty or Python elements
+ """
+ if value != None :
+ return self.type
class TAddonListProperty(TutoriusProperty):
"""
@@ -166,9 +173,9 @@ class TIntProperty(TutoriusProperty):
self.type = "int"
self.upper_limit = UpperLimitConstraint(upper_limit)
self.lower_limit = LowerLimitConstraint(lower_limit)
-
+ self.type_check = IntCheckConstraint()##########################################################
self.default = self.validate(value)
-
+ #faut_il convertir value en int quelque part ?
class TFloatProperty(TutoriusProperty):
"""
Represents a floating point number. Can have an upper value limit and/or
@@ -177,12 +184,12 @@ class TFloatProperty(TutoriusProperty):
def __init__(self, value, lower_limit=None, upper_limit=None):
TutoriusProperty.__init__(self)
self.type = "float"
-
+ self.type_check = FloatCheckConstraint()##########################################################
self.upper_limit = UpperLimitConstraint(upper_limit)
self.lower_limit = LowerLimitConstraint(lower_limit)
self.default = self.validate(value)
-
+ #faut_il convertir value en float quelque part ?
class TStringProperty(TutoriusProperty):
"""
Represents a string. Can have a maximum size limit.
@@ -194,7 +201,7 @@ class TStringProperty(TutoriusProperty):
self.default = self.validate(value)
-class TArrayProperty(TutoriusProperty):
+class TArrayProperty(TutoriusProperty):#############################################################
"""
Represents an array of values. Can have a maximum number of element
limit, but there are no constraints on the content of the array.
@@ -202,14 +209,17 @@ class TArrayProperty(TutoriusProperty):
def __init__(self, value, min_size_limit=None, max_size_limit=None):
TutoriusProperty.__init__(self)
self.type = "array"
+ self.indexeur = value #stock la value, pour l'indexation
self.max_size_limit = MaxSizeConstraint(max_size_limit)
self.min_size_limit = MinSizeConstraint(min_size_limit)
- self.indexeur = value #stock la value, pour l'indexation
- self.default = self.validate(value)
+ self.default = self.validate(value)
- #def __getitem__(self, key): # obligation de redéfinir l'indexation
- # return self.indexeur[key] #
+ def __getitem__(self, key): # obligation de redéfinir l'indexation pour le dessin dans overlayer
+ return self.indexeur[key] #
+ #def append(self, value) ?: #invalide
+ #et enlever un élément ?
+
class TColorProperty(TutoriusProperty):
"""
Represents a RGB color with 3 8-bit integer values.
@@ -227,7 +237,7 @@ class TColorProperty(TutoriusProperty):
self._blue = blue or 0
self.default = self.validate([self._red, self._green, self._blue])
-
+
class TFileProperty(TutoriusProperty):
"""
Represents a path to a file on the disk.
@@ -311,36 +321,43 @@ class TAddonProperty(TutoriusProperty):
if isinstance(value, TPropContainer):
return super(TAddonProperty, self).validate(value)
raise ValueError("Expected TPropContainer instance as TaddonProperty value")
-
-
-
-class TPositionProperty(TutoriusProperty):
+
+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._x=x or 0 #peut etre superflu ?
self._y=y or 0
+ self.typeCheck = ListIntCheckConstraint()
+ self.indexeur = [self._x, self._y]
self.default = self.validate((self._x,self._y))
- #voir les contraintes ou créer x en TintProperty
- #convertir en int ou raise error idem sur Tintproperty
-
- #contrainte générique du style is 'type' qui essai de convertir les éléments d'une séquence
-
- #contraintes deux élements
-
-
-class TArrayOneTypeProperty(TArrayProperty):
+
+ def __getitem__(self, key): # obligation de redéfinir l'indexation pour le dessin dans overlayer
+ return self.indexeur[key]
+ #fonctionnement obscur pour la modification des valeur a l'interieur du tuple position (par le clavier)
+
+class TArrayOneTypeProperty(TutoriusProperty):######################################################
"""
- Represents an array list of properties. Can have a maximum (and/or minimum) number of element
- limit. All the elements in the list must have the same type. The list must not be empty
+ Represents an array list of Tutorius_properties. All the elements in the list must have the same type. The list must not be empty
"""
- def __init__(self, value, min_size_limit=None, max_size_limit=None):
- TArrayProperty.__init__(self, value, min_size_limit, max_size_limit)
- self.type = "typedlist"
- self.required_type = SameTypeConstraint()
+ def __init__(self, value, OneType):
+ TutoriusProperty.__init__(self)
+ self.type = OneType
+ self.indexeur = value #stock la value, pour l'indexation
+ self.required_type = SameTypeConstraint(self.type)
self.default = self.validate(value)
+
+ # Tester
+
+ #Ne comprends pas bien les traitements a faire et comment ils sont fait actuellement dans le creator
+ #append
+ #et enlever un élément
+
+ #def __getitem__(self, key): # obligation de redéfinir l'indexation pour le dessin dans overlayer ou pas
+ # return self.indexeur[key]
+