diff options
author | Vincent Driessen <vincent@3rdcloud.com> | 2012-10-15 22:31:01 +0200 |
---|---|---|
committer | Vincent Driessen <vincent@3rdcloud.com> | 2012-10-15 22:31:01 +0200 |
commit | 4369c2878cda52d4b3e00900f4d00e5815865a00 (patch) | |
tree | c5466c537474f46e6c6b4515f389840c51a76028 | |
parent | d91208893f9d855d7ad21e6011bb348e8316653d (diff) | |
download | times-4369c2878cda52d4b3e00900f4d00e5815865a00.tar.gz |
Don't depend on six.
Times a tiny library and it already has two dependencies, which I think
is one too many already. Let's not make it two :)
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | times/__init__.py | 15 |
2 files changed, 12 insertions, 5 deletions
@@ -27,7 +27,7 @@ setup( include_package_data=True, zip_safe=False, platforms='any', - install_requires=['pytz', 'python-dateutil >= 2.1', 'six'], + install_requires=['pytz', 'python-dateutil >= 2.1'], classifiers=[ # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers #'Development Status :: 1 - Planning', diff --git a/times/__init__.py b/times/__init__.py index eef19f3..e446f19 100644 --- a/times/__init__.py +++ b/times/__init__.py @@ -1,7 +1,14 @@ +import sys import datetime import calendar import pytz -import six + +PY3 = sys.version_info[0] == 3 +if PY3: + string_types = str +else: + string_types = basestring + from dateutil.parser import parse from .version import VERSION @@ -20,7 +27,7 @@ def to_universal(local_dt, timezone=None): 'Timezone argument illegal when using UNIX timestamps.' ) return from_unix(local_dt) - elif isinstance(local_dt, six.string_types): + elif isinstance(local_dt, string_types): local_dt = parse(local_dt) return from_local(local_dt, timezone) @@ -38,7 +45,7 @@ def from_local(local_dt, timezone=None): 'argument.' ) - if isinstance(timezone, six.string_types): + if isinstance(timezone, string_types): timezone = pytz.timezone(timezone) dt_with_tzinfo = timezone.localize(local_dt) else: @@ -70,7 +77,7 @@ def to_local(dt, timezone): raise ValueError( 'First argument to to_local() should be a universal time.' ) - if isinstance(timezone, six.string_types): + if isinstance(timezone, string_types): timezone = pytz.timezone(timezone) return pytz.utc.localize(dt).astimezone(timezone) |