Skip to content

Commit

Permalink
Fix old python
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Feb 16, 2015
1 parent a5f94eb commit 41186be
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pygal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pygal/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions pygal/graph/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand Down
5 changes: 3 additions & 2 deletions pygal/test/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 41186be

Please sign in to comment.