Mike Orr avatar Mike Orr committed 987df9e

Rename 'dict_of' functions in webhelpers.containers.

dict_of_dicts -> correlate_dicts
dict_of_objects -> correlate_objects

Comments (0)

Files changed (1)

webhelpers/containers.py

         except KeyError:
             pass
 
-def dict_of_dicts(dicts, key):
+def correllate_dicts(dicts, key):
     """Correlate several dicts under one superdict.
 
-    E.g., If you have several dicts each with a 'name' key, this will
-    create a superdict containing each dict keyed by name.
+    E.g., If you have several dicts each with a 'name' key, this can
+    put them in a container dict keyed by name.
 
     >>> d1 = {"name": "Fred", "age": 41}
     >>> d2 = {"name": "Barney", "age": 31}
-    >>> flintstones = dict_of_dicts([d1, d2], "name")
+    >>> flintstones = correllate_dicts([d1, d2], "name")
     >>> sorted(flintstones.keys())
     ['Barney', 'Fred']
     >>> flintstones["Fred"]["age"]
     return ret
 
 
-def dict_of_objects(objects, attr):
-    """Correlate several dict under one dict.
 
-    E.g., If you have several objects each with a 'name' attribute, this will
+def correlate_objects(objects, attr):
+    """Correlate several objects under one dict.
+
+    E.g., If you have several objects each with a 'name' attribute, this can
     create a dict containing each object keyed by name.
 
     >>> class Flintstone(DumbObject):
     ...
     >>> fred = Flintstone(name="Fred", age=41)
     >>> barney = Flintstone(name="Barney", age=31)
-    >>> flintstones = dict_of_objects([fred, barney], "name")
+    >>> flintstones = correlate_objects([fred, barney], "name")
     >>> sorted(flintstones.keys())
     ['Barney', 'Fred']
     >>> flintstones["Barney"].age
     for obj in objects:
         try:
             my_key = getattr(obj, attr)
-        except AttrError:
+        except AttributeError:
             msg = "'%s' object at 'objects[%d]' contains no attribute '%s'"
             tup = type(obj).__name__, i, attr 
             raise AttributeError(msg % tup)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.