From 9500e288397de5710151f32ced2e9a2903766a2e Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 04 Dec 2009 22:25:14 +0000 Subject: Boy scout : Fixing tests for properties' values (cherry picked from commit 9f985564d6ade807a9182fcb7411388ed863e311) --- (limited to 'tutorius/properties.py') diff --git a/tutorius/properties.py b/tutorius/properties.py index f273569..2258656 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -26,7 +26,9 @@ from .constraints import Constraint, \ UpperLimitConstraint, LowerLimitConstraint, \ MaxSizeConstraint, MinSizeConstraint, \ ColorConstraint, FileConstraint, BooleanConstraint, EnumConstraint, \ - ResourceConstraint + ResourceConstraint, IntTypeConstraint, FloatTypeConstraint, \ + StringTypeConstraint, ArrayTypeConstraint, BoolTypeConstraint, \ + SequenceTypeConstraint from .propwidgets import PropWidget, \ StringPropWidget, \ @@ -205,6 +207,7 @@ class TIntProperty(TutoriusProperty): self.type = "int" self.upper_limit = UpperLimitConstraint(upper_limit) self.lower_limit = LowerLimitConstraint(lower_limit) + self.int_type = IntTypeConstraint() self.default = self.validate(value) @@ -220,6 +223,7 @@ class TFloatProperty(TutoriusProperty): self.upper_limit = UpperLimitConstraint(upper_limit) self.lower_limit = LowerLimitConstraint(lower_limit) + self.float_type = FloatTypeConstraint() self.default = self.validate(value) @@ -232,6 +236,7 @@ class TStringProperty(TutoriusProperty): TutoriusProperty.__init__(self) self.type = "string" self.size_limit = MaxSizeConstraint(size_limit) + self.string_type = StringTypeConstraint() self.default = self.validate(value) @@ -246,6 +251,7 @@ class TArrayProperty(TutoriusProperty): self.type = "array" self.max_size_limit = MaxSizeConstraint(max_size_limit) self.min_size_limit = MinSizeConstraint(min_size_limit) + self.array_type = ArrayTypeConstraint() self.default = tuple(self.validate(value)) #Make this thing hashable @@ -261,6 +267,22 @@ class TArrayProperty(TutoriusProperty): value=self.value, ) +class TSequenceProperty(TutoriusProperty): + """ + Represents a data type that can be accessed with indices (via []). Those + are mainly for structures that only expect a list of elements that may + also be specified using a string. E.g. the strokes in a text type filter. + Since it is more convenient to specify a list of keystrokes as a string + rather than a list of characters, a sequence is the best option. + """ + def __init__(self, value, min_size_limit=None, max_size_limit=None): + TutoriusProperty.__init__(self) + self.type = "sequence" + self.max_size_limit = MaxSizeConstraint(max_size_limit) + self.min_size_limit = MinSizeConstraint(min_size_limit) + self.sequence_type = SequenceTypeConstraint() + self.default = tuple(self.validate(value)) + class TColorProperty(TutoriusProperty): """ Represents a RGB color with 3 8-bit integer values. @@ -271,6 +293,7 @@ class TColorProperty(TutoriusProperty): TutoriusProperty.__init__(self) self.type = "color" + self.array_type = ArrayTypeConstraint() self.color_constraint = ColorConstraint() self._red = red or 0 @@ -362,6 +385,7 @@ class TBooleanProperty(TutoriusProperty): self.type = "boolean" + self.bool_type = BoolTypeConstraint() self.boolean_constraint = BooleanConstraint() self.default = self.validate(value) -- cgit v0.9.1