From 01682c1dcfd5fa92f08c00437fadb4650b8d4bf9 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 15 Dec 2021 10:18:17 +0000 Subject: Remove logic for Python < 3.6 Signed-off-by: Stephen Finucane --- python/subunit/iso8601.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'python/subunit/iso8601.py') 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=) 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 "" % 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 -- cgit v1.2.1