Commits

Luke Plant committed 4da8cbe

Python 2.5 compatibility

Comments (0)

Files changed (2)

django_easyfilters/filters.py

-from collections import namedtuple
 from datetime import date, timedelta
 from dateutil.relativedelta import relativedelta
 import math
 from django.utils.text import capfirst
 from django_easyfilters.queries import date_aggregation
 
+try:
+    from collections import namedtuple
+    FilterChoice = namedtuple('FilterChoice', 'label count params link_type')
+except ImportError:
+    # We don't use it a tuple, so this will do:
+    class FilterChoice(object):
+        def __init__(self, label, count, params, link_type):
+            self.label, self.count, self.params, self.link_type = label, count, params, link_type
+
+
 FILTER_ADD = 'add'
 FILTER_REMOVE = 'remove'
 FILTER_DISPLAY = 'display'
 
-FilterChoice = namedtuple('FilterChoice', 'label count params link_type')
-
 
 class Filter(object):
     """
         "Intended Audience :: Developers",
         "License :: OSI Approved :: MIT License",
         "Operating System :: OS Independent",
-        "Programming Language :: Python",
+        "Programming Language :: Python :: 2.5",
+        "Programming Language :: Python :: 2.6",
+        "Programming Language :: Python :: 2.7",
         "Framework :: Django",
         "Topic :: Software Development :: User Interfaces",
         ],
-    install_requires = ['django >= 1.3', 'dateutil'],
+    install_requires = ['django >= 1.3', 'python-dateutil'],
 )