Commits

Anonymous committed 41ee643

Python 2.6 works, but without unittests

Comments (0)

Files changed (1)

pypeg2/__init__.py

 
 
 import re
-import collections
 import sys
 import weakref
 import warnings
 from functools import reduce
 from types import FunctionType
+from collections import namedtuple
+try:
+    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):
         self.data = dict(*args, **kwargs)
     def __len__(self):
         Arguments are being put into the Namespace, keyword arguments give the
         attributes of the Namespace.
         """
-        self.data = collections.OrderedDict()
+        self.data = OrderedDict()
         for k, v in kwargs:
             setattr(self, k, v)
 
 
     def __init__(self, *things):
         """Construct an Enum using a tuple of things."""
-        self.data = collections.OrderedDict()
+        self.data = OrderedDict()
         for thing in things:
             if type(thing) == str:
                 thing = Symbol(thing)