Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/properties.py
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r--tutorius/properties.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py
index abf76e5..6d30a8d 100644
--- a/tutorius/properties.py
+++ b/tutorius/properties.py
@@ -95,6 +95,39 @@ class TPropContainer(object):
"""
return object.__getattribute__(self, "_props").keys()
+ def is_identical(self, otherContainer):
+ for prop in self._props.keys():
+ found = False
+ for otherProp in otherContainer._props.keys():
+ if prop == otherProp:
+ this_type = getattr(type(self), prop).type
+ other_type = getattr(type(otherContainer), prop).type
+ if this_type != other_type:
+ return False
+ if this_type == "addonlist":
+ for inner_cont in self._props[prop]:
+ inner_found = False
+ for other_inner in otherContainer._props[prop]:
+ if inner_cont.is_identical(other_inner):
+ inner_found = True
+ break
+ if inner_found == False:
+ return False
+ found = True
+ break
+ elif this_type == "addon":
+ if not self._props[prop].is_identical(otherContainer._props[prop]):
+ return False
+ found = True
+ break
+ else:
+ if self._props[prop]== otherContainer._props[prop]:
+ found = True
+ break
+ if found == False:
+ return False
+ return True
+
class TutoriusProperty(object):
"""
The base class for all actions' properties. The interface is the following :
@@ -317,8 +350,15 @@ class TAddonListProperty(TutoriusProperty):
See TAddonProperty
"""
def __init__(self):
- super(TAddonProperty, self).__init__()
+ TutoriusProperty.__init__(self)
self.type = "addonlist"
self.default = []
+ def validate(self, value):
+ if isinstance(value, list):
+ for component in value:
+ if not (isinstance(component, TPropContainer)):
+ raise ValueError("Expected a list of TPropContainer instances inside TAddonListProperty value, got a %s" % (str(type(component))))
+ return value
+ raise ValueError("Value proposed to TAddonListProperty is not a list")