Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove DotExpandedDict, which was undocumented and unused.

  • Loading branch information...
commit c57abd3c29cedcca00821d2a0d5708f10977f3c6 1 parent 0f57935
Alex Gaynor authored July 14, 2012
32  django/utils/datastructures.py
@@ -412,38 +412,6 @@ def dict(self):
412 412
         """
413 413
         return dict((key, self[key]) for key in self)
414 414
 
415  
-class DotExpandedDict(dict):
416  
-    """
417  
-    A special dictionary constructor that takes a dictionary in which the keys
418  
-    may contain dots to specify inner dictionaries. It's confusing, but this
419  
-    example should make sense.
420  
-
421  
-    >>> d = DotExpandedDict({'person.1.firstname': ['Simon'], \
422  
-            'person.1.lastname': ['Willison'], \
423  
-            'person.2.firstname': ['Adrian'], \
424  
-            'person.2.lastname': ['Holovaty']})
425  
-    >>> d
426  
-    {'person': {'1': {'lastname': ['Willison'], 'firstname': ['Simon']}, '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}}
427  
-    >>> d['person']
428  
-    {'1': {'lastname': ['Willison'], 'firstname': ['Simon']}, '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}
429  
-    >>> d['person']['1']
430  
-    {'lastname': ['Willison'], 'firstname': ['Simon']}
431  
-
432  
-    # Gotcha: Results are unpredictable if the dots are "uneven":
433  
-    >>> DotExpandedDict({'c.1': 2, 'c.2': 3, 'c': 1})
434  
-    {'c': 1}
435  
-    """
436  
-    def __init__(self, key_to_list_mapping):
437  
-        for k, v in key_to_list_mapping.items():
438  
-            current = self
439  
-            bits = k.split('.')
440  
-            for bit in bits[:-1]:
441  
-                current = current.setdefault(bit, {})
442  
-            # Now assign value to current position
443  
-            try:
444  
-                current[bits[-1]] = v
445  
-            except TypeError: # Special-case if current isn't a dict.
446  
-                current = {bits[-1]: v}
447 415
 
448 416
 class ImmutableList(tuple):
449 417
     """
18  tests/regressiontests/utils/datastructures.py
@@ -6,8 +6,8 @@
6 6
 import pickle
7 7
 
8 8
 from django.test import SimpleTestCase
9  
-from django.utils.datastructures import (DictWrapper, DotExpandedDict,
10  
-    ImmutableList, MultiValueDict, MultiValueDictKeyError, MergeDict, SortedDict)
  9
+from django.utils.datastructures import (DictWrapper, ImmutableList,
  10
+    MultiValueDict, MultiValueDictKeyError, MergeDict, SortedDict)
11 11
 
12 12
 
13 13
 class SortedDictTests(SimpleTestCase):
@@ -251,20 +251,6 @@ def test_dict_translation(self):
251 251
         self.assertEqual({}, MultiValueDict().dict())
252 252
 
253 253
 
254  
-class DotExpandedDictTests(SimpleTestCase):
255  
-
256  
-    def test_dotexpandeddict(self):
257  
-
258  
-        d = DotExpandedDict({'person.1.firstname': ['Simon'],
259  
-                             'person.1.lastname': ['Willison'],
260  
-                             'person.2.firstname': ['Adrian'],
261  
-                             'person.2.lastname': ['Holovaty']})
262  
-
263  
-        self.assertEqual(d['person']['1']['lastname'], ['Willison'])
264  
-        self.assertEqual(d['person']['2']['lastname'], ['Holovaty'])
265  
-        self.assertEqual(d['person']['2']['firstname'], ['Adrian'])
266  
-
267  
-
268 254
 class ImmutableListTests(SimpleTestCase):
269 255
 
270 256
     def test_sort(self):
2  tests/regressiontests/utils/tests.py
@@ -16,7 +16,7 @@
16 16
 from .functional import FunctionalTestCase
17 17
 from .timesince import TimesinceTests
18 18
 from .datastructures import (MultiValueDictTests, SortedDictTests,
19  
-    DictWrapperTests, ImmutableListTests, DotExpandedDictTests, MergeDictTests)
  19
+    DictWrapperTests, ImmutableListTests, MergeDictTests)
20 20
 from .tzinfo import TzinfoTests
21 21
 from .datetime_safe import DatetimeTests
22 22
 from .baseconv import TestBaseConv

0 notes on commit c57abd3

Please sign in to comment.
Something went wrong with that request. Please try again.