1. Matthew Schinckel
  2. django-timedelta-field


Matthew Schinckel  committed 9a6a403 Merge

Merged in fcurella/django-timedelta-field/py3k (pull request #9)

added py3k support.

  • Participants
  • Parent commits 7b75f00, 329d2cc
  • Branches default

Comments (0)

Files changed (4)

File setup.py

View file
  • Ignore whitespace
+    install_requires = [
+        "six",
+    ],
     package_data = {'timedelta': ['VERSION']},
     classifiers = [
         'Programming Language :: Python',

File timedelta/fields.py

View file
  • Ignore whitespace
 from collections import defaultdict
 import datetime
+import six
 from .helpers import parse
 from .forms import TimedeltaFormField
     def get_prep_value(self, value):
         if self.null and value == "":
             return None
-        if (value is None) or isinstance(value, (str, unicode)):
+        if (value is None) or isinstance(value, six.string_types):
             return value
         return str(value).replace(',', '')

File timedelta/helpers.py

View file
  • Ignore whitespace
 import datetime
 from decimal import Decimal
+import six
 def nice_repr(timedelta, display="long", sep=", "):
     Turns a datetime.timedelta object into a nice string repr.
     # and from serialization
     d = re.match(r'^((?P<days>\d+) days?,? )?(?P<hours>\d+):'
-                 unicode(string))
+                 six.text_type(string))
     if d: 
         d = d.groupdict(0)
-                     unicode(string))
+                     six.text_type(string))
         if not d:
             raise TypeError("'%s' is not a valid time interval" % string)
         d = d.groupdict(0)

File timedelta/widgets.py

View file
  • Ignore whitespace
 from django import forms
 import datetime
+import six
 from .helpers import nice_repr, parse
     def render(self, name, value, attrs=None):
         if value is None:
             value = ""
-        elif isinstance(value, (str, unicode)):
+        elif isinstance(value, six.string_types):
             if isinstance(value, int):