Use basestring instead of str for type check.

Change-Id: I1dbf453cc08bd8aaeb4fee2491a1e8aa74f8bee3 introduced some
checks to is_older_than and is_newer_than functions against str instead
of basestring.

I'm aware that basestring doesn't exist in Python3 but since it isn't
a target right now and there's no "standard" way to support it right now
in openstack.

Change-Id: I8d67d384637dfdde3f5621052d8511e7b6ecab7b
This commit is contained in:
Flaper Fesp
2013-01-04 18:07:45 +01:00
parent cad152f0f0
commit a08daf15d4

View File

@@ -71,14 +71,14 @@ def normalize_time(timestamp):
def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
if isinstance(before, str):
if isinstance(before, basestring):
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, str):
if isinstance(after, basestring):
after = parse_strtime(after).replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds)