Mercurial > farol > farolluz
comparison farolluz/py2.py @ 0:e18b61a73a68
Initial Release
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Tue, 23 Sep 2014 15:19:14 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e18b61a73a68 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 # Description: | |
3 # Python2 Compatibility module | |
4 # | |
5 # Authors: | |
6 # BenoƮt Allard <benoit.allard@greenbone.net> | |
7 # | |
8 # Copyright: | |
9 # Copyright (C) 2014 Greenbone Networks GmbH | |
10 # | |
11 # This program is free software; you can redistribute it and/or | |
12 # modify it under the terms of the GNU General Public License | |
13 # as published by the Free Software Foundation; either version 2 | |
14 # of the License, or (at your option) any later version. | |
15 # | |
16 # This program is distributed in the hope that it will be useful, | |
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 # GNU General Public License for more details. | |
20 # | |
21 # You should have received a copy of the GNU General Public License | |
22 # along with this program; if not, write to the Free Software | |
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
24 | |
25 """\ | |
26 Glue for missing features of python3 in python2 | |
27 """ | |
28 | |
29 from datetime import tzinfo, timedelta | |
30 | |
31 class FixedTimeZone(tzinfo): | |
32 def __init__(self, offset): | |
33 self.__offset = offset | |
34 | |
35 def utcoffset(self, dt): | |
36 return self.__offset | |
37 | |
38 def dst(self, dt): | |
39 return timedelta(0) | |
40 | |
41 try: | |
42 from urllib.request import urlopen | |
43 except ImportError: | |
44 from urllib2 import urlopen |