summaryrefslogtreecommitdiff
path: root/python/subunit/iso8601.py
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-12-15 10:18:17 +0000
committerStephen Finucane <stephenfin@redhat.com>2021-12-15 10:38:24 +0000
commit01682c1dcfd5fa92f08c00437fadb4650b8d4bf9 (patch)
treea4ba51740bf8bd1d145b0469b8d5109262570d34 /python/subunit/iso8601.py
parent6340268cad342f41c357604535c842f5df1d4a10 (diff)
downloadsubunit-git-01682c1dcfd5fa92f08c00437fadb4650b8d4bf9.tar.gz
Remove logic for Python < 3.6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'python/subunit/iso8601.py')
-rw-r--r--python/subunit/iso8601.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/python/subunit/iso8601.py b/python/subunit/iso8601.py
index 07855d0..7d392d4 100644
--- a/python/subunit/iso8601.py
+++ b/python/subunit/iso8601.py
@@ -1,5 +1,5 @@
# Copyright (c) 2007 Michael Twomey
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -31,7 +31,6 @@ datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.iso8601.Utc ...>)
from datetime import datetime, timedelta, tzinfo
import re
-import sys
__all__ = ["parse_date", "ParseError"]
@@ -47,10 +46,6 @@ TIMEZONE_REGEX = re.compile(TIMEZONE_REGEX_PATTERN.encode('utf8'))
zulu = "Z".encode('latin-1')
minus = "-".encode('latin-1')
-if sys.version_info < (3, 0):
- bytes = str
-
-
class ParseError(Exception):
"""Raised when there is a problem parsing a date string"""
@@ -58,7 +53,7 @@ class ParseError(Exception):
ZERO = timedelta(0)
class Utc(tzinfo):
"""UTC
-
+
"""
def utcoffset(self, dt):
return ZERO
@@ -72,7 +67,7 @@ UTC = Utc()
class FixedOffset(tzinfo):
"""Fixed offset in hours and minutes from UTC
-
+
"""
def __init__(self, offset_hours, offset_minutes, name):
self.__offset = timedelta(hours=offset_hours, minutes=offset_minutes)
@@ -86,13 +81,13 @@ class FixedOffset(tzinfo):
def dst(self, dt):
return ZERO
-
+
def __repr__(self):
return "<FixedOffset %r>" % self.__name
def parse_timezone(tzstring, default_timezone=UTC):
"""Parses ISO 8601 time zone specs into tzinfo offsets
-
+
"""
if tzstring == zulu:
return default_timezone
@@ -111,7 +106,7 @@ def parse_timezone(tzstring, default_timezone=UTC):
def parse_date(datestring, default_timezone=UTC):
"""Parses ISO 8601 dates into datetime objects
-
+
The timezone is parsed from the date string. However it is quite common to
have dates without a timezone (not strictly correct). In this case the
default timezone specified in default_timezone is used. This is UTC by