From 41186be872cb117e4049c24040e83057786e7ee4 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 16 Feb 2015 17:51:36 +0100 Subject: [PATCH] Fix old python --- CHANGELOG | 8 ++++---- pygal/__init__.py | 2 +- pygal/_compat.py | 2 +- pygal/graph/time.py | 6 +++--- pygal/test/test_date.py | 5 +++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c7f02583..e423c6d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,9 @@ V 2.0.0 UNRELEASED - Remove DateY and replace it by real XY datetime, date, time and timedelta support. - Introduce new XY configuration options: `xrange`, `x_value_formatter` - Rework the ghost mechanism to come back to a more object oriented behavior (WIP) + Rework the ghost mechanism to come back to a more object oriented behavior (Maybe) -V 1.6.3 +V 1.7.0 + Remove DateY and replace it by real XY datetime, date, time and timedelta support. (#188) + Introduce new XY configuration options: `xrange`, `x_value_formatter`. Add show_x_labels option to remove them and the x axis. Set print_values to False by default. Fix secondary serie text values when None in data. (#192) diff --git a/pygal/__init__.py b/pygal/__init__.py index fbb9b561..0d16844e 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -21,7 +21,7 @@ """ -__version__ = '1.6.3' +__version__ = '1.7.0' import sys from pygal.config import Config from pygal.ghost import Ghost, REAL_CHARTS diff --git a/pygal/_compat.py b/pygal/_compat.py index 138ea12a..55e2f03e 100644 --- a/pygal/_compat.py +++ b/pygal/_compat.py @@ -63,7 +63,7 @@ def total_seconds(td): return td.total_seconds() -def to_timestamp(x): +def timestamp(x): if hasattr(x, 'timestamp'): return x.timestamp() else: diff --git a/pygal/graph/time.py b/pygal/graph/time.py index d9a89634..f2738400 100644 --- a/pygal/graph/time.py +++ b/pygal/graph/time.py @@ -22,12 +22,12 @@ from pygal.graph.xy import XY from datetime import datetime, date, time, timedelta -from pygal._compat import to_timestamp +from pygal._compat import timestamp, total_seconds def datetime_to_timestamp(x): if isinstance(x, datetime): - return to_timestamp(x) + return timestamp(x) return x @@ -45,7 +45,7 @@ def time_to_datetime(x): def timedelta_to_seconds(x): if isinstance(x, timedelta): - return x.total_seconds() + return total_seconds(x) return x diff --git a/pygal/test/test_date.py b/pygal/test/test_date.py index 875284de..8ac08fea 100644 --- a/pygal/test/test_date.py +++ b/pygal/test/test_date.py @@ -19,6 +19,7 @@ from pygal import DateLine, TimeLine, DateTimeLine, TimeDeltaLine from pygal.test.utils import texts from datetime import datetime, date, time, timedelta +import sys def test_date(): @@ -96,9 +97,9 @@ def test_timedelta(): ]) q = timedelta_chart.render_pyquery() - assert list( - q(".axis.x text").map(texts)) == [ + t for t in q(".axis.x text").map(texts) if t != '0:00:00' + ) == [ '1 day, 3:46:40', '2 days, 7:33:20', '3 days, 11:20:00',