Author: jamest
Date: 2006-05-10 11:41:52 -0500 (Wed, 10 May 2006)
New Revision: 242
Modified:
objectWrapper/src/ObjectWrapper.py
Log:
resynced with internal copy
Modified: objectWrapper/src/ObjectWrapper.py
===================================================================
--- objectWrapper/src/ObjectWrapper.py 2006-03-20 14:11:56 UTC (rev 241)
+++ objectWrapper/src/ObjectWrapper.py 2006-05-10 16:41:52 UTC (rev 242)
@@ -565,4 +565,29 @@
'prepost' : prePost
}
}
- return result
\ No newline at end of file
+ return result
+
+# Separate --------------------------------------------------------------------
+def separateByField(objects, fieldName):
+ """
+ Creates a dict of object lists keyed by field name
+
+ When passed a list of object and a field name a dict is returned that
+ contains the objects seperated into lists by the value of the specified
+ field.
+
+ @param objects: A list of objectWrapper objects
+ @param fieldName: The name of the field to use as the separator
+ """
+ resultDict = {}
+
+ for object in objects:
+ fieldValue = getattr(object, fieldName)
+ try:
+ targetList = resultDict[fieldValue]
+ except:
+ resultDict[fieldValue] = targetList = []
+
+ targetList.append(adjustment)
+
+ return resultDict
_______________________________________________
commit-gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-gnue