summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Weis <g.weis@griffith.edu.au>2017-07-05 11:17:08 (GMT)
committerGerhard Weis <g.weis@griffith.edu.au>2017-07-05 11:17:08 (GMT)
commitd1a37f70cb32e5e48024645efa2fef701883cdb0 (patch)
tree01953735cf3dad7ee68c2cd4585f380dbdd6c8d5
parentbec98f76b13f6ae23e0330ab1c660b035fdd3290 (diff)
downloadisodate-d1a37f70cb32e5e48024645efa2fef701883cdb0.tar.gz
use six
-rw-r--r--setup.py11
-rw-r--r--src/isodate/isoduration.py8
-rw-r--r--src/isodate/isotime.py10
-rw-r--r--src/isodate/tests/test_pickle.py7
4 files changed, 14 insertions, 22 deletions
diff --git a/setup.py b/setup.py
index baaf03e..427fb12 100644
--- a/setup.py
+++ b/setup.py
@@ -28,21 +28,20 @@
import os
from setuptools import setup
-setupargs = {}
-setupargs['test_suite'] = 'isodate.tests.test_suite'
-
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='isodate',
- version='0.5.5.dev',
+ version='0.7.0.dev',
packages=['isodate', 'isodate.tests'],
package_dir={'': 'src'},
# dependencies:
- # install_requires = [],
+ install_requires=[
+ 'six'
+ ],
# PyPI metadata
author='Gerhard Weis',
@@ -73,4 +72,4 @@ setup(name='isodate',
('Topic :: Software Development :'
': Libraries :: Python Modules'),
],
- **setupargs)
+ test_suite='isodate.tests.test_suite')
diff --git a/src/isodate/isoduration.py b/src/isodate/isoduration.py
index d64b3c0..88829f7 100644
--- a/src/isodate/isoduration.py
+++ b/src/isodate/isoduration.py
@@ -33,7 +33,8 @@ format timedelta or Duration instances as ISO conforming strings.
from datetime import timedelta
from decimal import Decimal
import re
-import sys
+
+from six import string_types
from isodate.duration import Duration
from isodate.isoerror import ISO8601Error
@@ -52,9 +53,6 @@ ISO8601_PERIOD_REGEX = re.compile(
r"(?P<seconds>[0-9]+([,.][0-9]+)?S)?)?$")
# regular expression to parse ISO duartion strings.
-if sys.version_info[0] >= 3:
- basestring = str
-
def parse_duration(datestring):
"""
@@ -84,7 +82,7 @@ def parse_duration(datestring):
The alternative format does not support durations with years, months or
days set to 0.
"""
- if not isinstance(datestring, basestring):
+ if not isinstance(datestring, string_types):
raise TypeError("Expecting a string %r" % datestring)
match = ISO8601_PERIOD_REGEX.match(datestring)
if not match:
diff --git a/src/isodate/isotime.py b/src/isodate/isotime.py
index a430982..113d34b 100644
--- a/src/isodate/isotime.py
+++ b/src/isodate/isotime.py
@@ -32,7 +32,6 @@ It supports all basic and extended formats including time zone specifications
as described in the ISO standard.
'''
import re
-import sys
from decimal import Decimal
from datetime import time
@@ -40,9 +39,6 @@ from isodate.isostrf import strftime, TIME_EXT_COMPLETE, TZ_EXT
from isodate.isoerror import ISO8601Error
from isodate.isotzinfo import TZ_REGEX, build_tzinfo
-if sys.version_info > (3,):
- long = int
-
TIME_REGEX_CACHE = []
# used to cache regular expressions to parse ISO time strings.
@@ -129,7 +125,7 @@ def parse_time(timestring):
if 'second' in groups:
# round to microseconds if fractional seconds are more precise
second = Decimal(groups['second']).quantize(Decimal('.000001'))
- microsecond = (second - int(second)) * long(1e6)
+ microsecond = (second - int(second)) * int(1e6)
# int(...) ... no rounding
# to_integral() ... rounding
return time(int(groups['hour']), int(groups['minute']),
@@ -138,7 +134,7 @@ def parse_time(timestring):
if 'minute' in groups:
minute = Decimal(groups['minute'])
second = (minute - int(minute)) * 60
- microsecond = (second - int(second)) * long(1e6)
+ microsecond = (second - int(second)) * int(1e6)
return time(int(groups['hour']), int(minute), int(second),
int(microsecond.to_integral()), tzinfo)
else:
@@ -146,7 +142,7 @@ def parse_time(timestring):
hour = Decimal(groups['hour'])
minute = (hour - int(hour)) * 60
second = (minute - int(minute)) * 60
- microsecond = (second - int(second)) * long(1e6)
+ microsecond = (second - int(second)) * int(1e6)
return time(int(hour), int(minute), int(second),
int(microsecond.to_integral()), tzinfo)
raise ISO8601Error('Unrecognised ISO 8601 time format: %r' % timestring)
diff --git a/src/isodate/tests/test_pickle.py b/src/isodate/tests/test_pickle.py
index 0d8c184..7fc6213 100644
--- a/src/isodate/tests/test_pickle.py
+++ b/src/isodate/tests/test_pickle.py
@@ -1,8 +1,7 @@
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
import unittest
+
+from six.moves import cPickle as pickle
+
import isodate