From 1f67eab0d5fa54d031aecb1ceff894e8e497bec9 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Wed, 24 Jul 2013 14:57:03 +0200 Subject: Added authors file --- AUTHORS | 23 +++++++++++++++++++++++ COPYING | 28 ---------------------------- ChangeLog | 2 -- LICENSE | 29 +++++++++++++++++++++++++++++ babel/localtime/_unix.py | 30 ++++++++++++++++++++++++++++-- 5 files changed, 80 insertions(+), 32 deletions(-) create mode 100644 AUTHORS delete mode 100644 COPYING create mode 100644 LICENSE diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..3663977 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,23 @@ +Babel is written and maintained by the Babel team and various contributors: + +Maintainer and Current Project Lead: + +- Armin Ronacher + +Contributors: + +- Christopher Lenz +- Alex Morega +- Felix Schwarz +- Pedro Algarvio +- Jeroen Ruigrok van der Werven +- Philip Jenvey +- Tobias Bieniek +- Jonas Borgström +- Daniel Neuhäuser +- Nick Retallack +- Thomas Waldmann + +Babel was previously developed under the Copyright of Edgewall Software. The +following copyright notice holds true for releases before 2013: "Copyright (c) +2007 - 2011 by Edgewall Software" diff --git a/COPYING b/COPYING deleted file mode 100644 index bddbf62..0000000 --- a/COPYING +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (C) 2007-2011 Edgewall Software -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - 3. The name of the author may not be used to endorse or promote - products derived from this software without specific prior - written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS -OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ChangeLog b/ChangeLog index 74f1182..952f149 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,4 @@ Version 1.0 -http://svn.edgewall.org/repos/babel/tags/1.0.0/ -(? ? 2013 from trunk) * support python 2.6, 2.7, 3.3+ and pypy - drop all other versions * use tox for testing on different pythons diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4f94d2f --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +Copyright (C) 2013 by the Babel Team, see AUTHORS for more information. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/babel/localtime/_unix.py b/babel/localtime/_unix.py index b002c18..b4a3b59 100644 --- a/babel/localtime/_unix.py +++ b/babel/localtime/_unix.py @@ -1,7 +1,11 @@ from __future__ import with_statement import os import re +import sys import pytz +import subprocess + +_systemconfig_tz = re.compile(r'^Time Zone: (.*)$(?m)') def _tz_from_env(tzenv): @@ -30,7 +34,8 @@ def _get_localzone(_root='/'): name is unknown. The parameter _root makes the function look for files like /etc/localtime beneath the _root directory. This is primarily used by the tests. - In normal usage you call the function without parameters.""" + In normal usage you call the function without parameters. + """ tzenv = os.environ.get('TZ') if tzenv: @@ -52,6 +57,26 @@ def _get_localzone(_root='/'): except pytz.UnknownTimeZoneError: pass + # If we are on OS X now we are pretty sure that the rest of the + # code will fail and just fall through until it hits the reading + # of /etc/localtime and using it without name. At this point we + # can invoke systemconfig which internally invokes ICU. ICU itself + # does the same thing we do (readlink + compare file contents) but + # since it knows where the zone files are that should be a bit + # better than reimplementing the logic here. + if sys.platform == 'darwin': + c = subprocess.Popen(['systemsetup', '-gettimezone'], + stdout=subprocess.PIPE) + sys_result = c.communicate()[0] + c.wait() + tz_match = _systemconfig_tz.search(sys_result) + if tz_match is not None: + zone_name = tz_match.group(1) + try: + return pytz.timezone(zone_name) + except pytz.UnknownTimeZoneError: + pass + # Now look for distribution specific configuration files # that contain the timezone name. tzpath = os.path.join(_root, 'etc/timezone') @@ -59,7 +84,7 @@ def _get_localzone(_root='/'): with open(tzpath, 'rb') as tzfile: data = tzfile.read() - # Issue #3 was that /etc/timezone was a zoneinfo file. + # Issue #3 in tzlocal was that /etc/timezone was a zoneinfo file. # That's a misconfiguration, but we need to handle it gracefully: if data[:5] != 'TZif2': etctz = data.strip().decode() @@ -105,6 +130,7 @@ def _get_localzone(_root='/'): if not os.path.exists(tzpath): continue + with open(tzpath, 'rb') as tzfile: return pytz.tzfile.build_tzinfo('local', tzfile) -- cgit v1.2.1