Anonymous avatar 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)
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.