Browse Source

Drop 2.6 support

pull/339/head
Florian Mounier 8 years ago
parent
commit
f4c2808fd9
  1. 2
      .travis.yml
  2. 2
      docs/installing.rst
  3. 11
      pygal/_compat.py
  4. 4
      pygal/graph/map.py
  5. 4
      pygal/graph/time.py
  6. 7
      pygal/test/conftest.py

2
.travis.yml

@ -1,10 +1,10 @@
language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
- 3.5
- nightly
# - pypy Disabled for pypy < 2.6.0
install:

2
docs/installing.rst

@ -2,7 +2,7 @@
Installing
==========
pygal is available for python 2.6, 2.7 and 3.2, 3.3, 3.4 and pypy.
pygal is available for python 2.7 and 3.2, 3.3, 3.4, 3.5 and pypy.
PyPI

11
pygal/_compat.py

@ -69,15 +69,6 @@ def u(s):
return s.decode('utf-8')
return s
def total_seconds(td):
"""Backport of `timedelta.total_second` function for python 2.6"""
if sys.version_info[:2] == (2, 6):
return (
(td.days * 86400 + td.seconds) * 10 ** 6 + td.microseconds
) / 10 ** 6
return td.total_seconds()
try:
from datetime import timezone
utc = timezone.utc
@ -103,7 +94,7 @@ def timestamp(x):
if hasattr(x, 'timestamp'):
return x.timestamp()
else:
return total_seconds(x - datetime(1970, 1, 1, tzinfo=utc))
return (x - datetime(1970, 1, 1, tzinfo=utc)).total_seconds()
try:
from urllib import quote_plus

4
pygal/graph/map.py

@ -82,14 +82,10 @@ class BaseMap(Graph):
else:
ratio = .3 + .7 * (value - min_) / (max_ - min_)
try:
areae = map.findall(
".//*[@class='%s%s %s map-element']" % (
self.area_prefix, area_code,
self.kind))
except SyntaxError:
# Python 2.6 (you'd better install lxml)
raise ImportError('lxml is required under python 2.6')
if not areae:
continue

4
pygal/graph/time.py

@ -24,7 +24,7 @@ into float for xy plot and back to their type for display
from datetime import date, datetime, time, timedelta
from pygal._compat import is_str, timestamp, total_seconds
from pygal._compat import is_str, timestamp
from pygal.adapters import positive
from pygal.graph.xy import XY
@ -60,7 +60,7 @@ def time_to_datetime(x):
def timedelta_to_seconds(x):
"""Convert a timedelta into an amount of seconds"""
if isinstance(x, timedelta):
return total_seconds(x)
return x.total_seconds()
return x

7
pygal/test/conftest.py

@ -37,14 +37,11 @@ def etreefx(request):
def pytest_generate_tests(metafunc):
"""Generate the tests for etree and lxml"""
if etree._lxml_etree and sys.version_info[:2] != (2, 6):
if etree._lxml_etree:
metafunc.fixturenames.append('etreefx')
metafunc.parametrize('etreefx', ['lxml', 'etree'], indirect=True)
if sys.version_info[:2] != (2, 6) and not hasattr(
sys, 'pypy_version_info'):
if not etree._lxml_etree:
raise ImportError('lxml is required under python 2.6')
if not hasattr(sys, 'pypy_version_info'):
etree.to_lxml()
if hasattr(sys, 'pypy_version_info'):

Loading…
Cancel
Save