From ab978a8c31daafdea04c506e199d43905aa5212a Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 4 Aug 2012 17:09:32 +0200 Subject: [PATCH] Remove utils/gen.py dependency on deprecated libraries (new and UserDict). --- src/utils/gen.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/gen.py b/src/utils/gen.py index e24588cd6..ef57114db 100644 --- a/src/utils/gen.py +++ b/src/utils/gen.py @@ -30,13 +30,12 @@ import os import sys -import new import time import types import compiler import textwrap -import UserDict import traceback +import collections from itertools import imap from str import format @@ -231,7 +230,7 @@ class IterableMap(object): return False -class InsensitivePreservingDict(UserDict.DictMixin, object): +class InsensitivePreservingDict(collections.MutableMapping): def key(self, s): """Override this if you wish.""" if s is not None: @@ -265,6 +264,12 @@ class InsensitivePreservingDict(UserDict.DictMixin, object): def __delitem__(self, k): del self.data[self.key(k)] + def __iter__(self): + return iter(self.data) + + def __len__(self): + return len(self.data) + def iteritems(self): return self.data.itervalues()