From d28fa6983bb628c6d111a5f16e222f7b020a3b94 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Thu, 27 Jun 2013 15:40:42 -0400 Subject: python3: Add python3 compatibility. Fix basestring/str idioms for both python2 and python3 (used by python-novaclient). Change-Id: I440c7c1c18660c3d73f699c0a02cbbfee331bfbf Signed-off-by: Chuck Short --- openstack/common/timeutils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openstack/common/timeutils.py b/openstack/common/timeutils.py index ac2441b..bd60489 100644 --- a/openstack/common/timeutils.py +++ b/openstack/common/timeutils.py @@ -23,6 +23,7 @@ import calendar import datetime import iso8601 +import six # ISO 8601 extended time format with microseconds @@ -75,14 +76,14 @@ def normalize_time(timestamp): def is_older_than(before, seconds): """Return True if before is older than seconds.""" - if isinstance(before, basestring): + if isinstance(before, six.string_types): before = parse_strtime(before).replace(tzinfo=None) return utcnow() - before > datetime.timedelta(seconds=seconds) def is_newer_than(after, seconds): """Return True if after is newer than seconds.""" - if isinstance(after, basestring): + if isinstance(after, six.string_types): after = parse_strtime(after).replace(tzinfo=None) return after - utcnow() > datetime.timedelta(seconds=seconds) -- cgit