benoit@0: # -*- coding: utf-8 -*- benoit@0: # Description: benoit@0: # Python2 Compatibility module benoit@0: # benoit@0: # Authors: benoit@0: # BenoƮt Allard benoit@0: # benoit@0: # Copyright: benoit@0: # Copyright (C) 2014 Greenbone Networks GmbH benoit@0: # benoit@0: # This program is free software; you can redistribute it and/or benoit@0: # modify it under the terms of the GNU General Public License benoit@0: # as published by the Free Software Foundation; either version 2 benoit@0: # of the License, or (at your option) any later version. benoit@0: # benoit@0: # This program is distributed in the hope that it will be useful, benoit@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of benoit@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the benoit@0: # GNU General Public License for more details. benoit@0: # benoit@0: # You should have received a copy of the GNU General Public License benoit@0: # along with this program; if not, write to the Free Software benoit@0: # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. benoit@0: benoit@0: """\ benoit@0: Glue for missing features of python3 in python2 benoit@0: """ benoit@0: benoit@0: from datetime import tzinfo, timedelta benoit@0: benoit@0: class FixedTimeZone(tzinfo): benoit@0: def __init__(self, offset): benoit@0: self.__offset = offset benoit@0: benoit@0: def utcoffset(self, dt): benoit@0: return self.__offset benoit@0: benoit@0: def dst(self, dt): benoit@0: return timedelta(0) benoit@0: benoit@0: try: benoit@0: from urllib.request import urlopen benoit@0: except ImportError: benoit@0: from urllib2 import urlopen