Volker Birk  committed 41ee643

Python 2.6 works, but without unittests

  • Participants
  • Parent commits 937b0cd
  • Branches default

Comments (0)

Files changed (1)

File pypeg2/

 import re
-import collections
 import sys
 import weakref
 import warnings
 from functools import reduce
 from types import FunctionType
+from collections import namedtuple
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 word = re.compile(r"\w+")
                     + repr(name), SyntaxWarning)
     return attr.Class(name, thing, subtype)
-attr.Class = collections.namedtuple("Attribute", ("name", "thing", "subtype"))
+attr.Class = namedtuple("Attribute", ("name", "thing", "subtype"))
 def flag(name, thing):
 class _UserDict(object):
-    # collections.UserDict cannot be used because of metaclass conflicts
+    # UserDict cannot be used because of metaclass conflicts
     def __init__(self, *args, **kwargs): = dict(*args, **kwargs)
     def __len__(self):
         Arguments are being put into the Namespace, keyword arguments give the
         attributes of the Namespace.
- = collections.OrderedDict()
+ = OrderedDict()
         for k, v in kwargs:
             setattr(self, k, v)
     def __init__(self, *things):
         """Construct an Enum using a tuple of things."""
- = collections.OrderedDict()
+ = OrderedDict()
         for thing in things:
             if type(thing) == str:
                 thing = Symbol(thing)