From 3b9bff2ef1826987d95815ff03c235052cea9aae Mon Sep 17 00:00:00 2001 From: mike Date: Sat, 17 Oct 2009 17:47:58 +0000 Subject: LP 439980 : Code review changes : renamed is_identical to __eq__, relaxed action insertion constraints, added fixed meta-props for addons --- (limited to 'tutorius/properties.py') diff --git a/tutorius/properties.py b/tutorius/properties.py index 2afe119..4c34511 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -95,7 +95,7 @@ class TPropContainer(object): """ return object.__getattribute__(self, "_props").keys() - def is_identical(self, otherContainer): + def __eq__(self, otherContainer): """ Compare this property container to the other one and returns True only if the every property of the first one can be found in the other container, with @@ -108,6 +108,10 @@ class TPropContainer(object): # Make sure both have the same number of properties if len(self._props) != len(otherContainer._props): return False + + if not(type(self) == type(otherContainer)): + return False + # For every property in this container for prop in self._props.keys(): found = False @@ -131,12 +135,12 @@ class TPropContainer(object): # If this is just an embedded / decorated container, then we want to # make sure the sub component are identical. elif this_type == "addon": - if not self._props[prop].is_identical(otherContainer._props[prop]): + if not (self._props[prop] == otherContainer._props[prop]): return False found = True break else: - if self._props[prop]== otherContainer._props[prop]: + if self._props[prop] == otherContainer._props[prop]: found = True break # If we arrive here, then we couldn't find any property in the second @@ -161,7 +165,7 @@ class TPropContainer(object): # Attempt to match it with every property in the other list for other_container in otherList: # If the containers are identical, - if container.is_identical(other_container): + if container == other_container: # We found a matching container. We don't need to search in the # second list anymore, so we break found = True -- cgit v0.9.1