Skip to content

Commit

Permalink
revert drop support for Python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
posativ committed Jun 15, 2013
1 parent 3facb9e commit dd748f3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
language: python
python:
- 2.6
- 2.7
- 3.3
install:
- pip install --use-mirrors cram mako Jinja2 markdown docutils Attest-latest
- pip install --use-mirrors cram unidecode mako Jinja2 markdown docutils Attest-latest
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]];
then pip install --use-mirrors argparse ordereddict;
fi
- python setup.py -q install
script:
- python setup.py test && cram specs/
Expand Down
6 changes: 4 additions & 2 deletions acrylamid/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from acrylamid.lib import lazy, history
from acrylamid.core import cache, load, Environment
from acrylamid.utils import hash, HashableList, import_object, OrderedDict as dict
from acrylamid.utils import total_seconds
from acrylamid.helpers import event

if compat.PY2K:
Expand Down Expand Up @@ -87,8 +88,9 @@ def initialize(conf, env):
log.warn('no `www_root` specified, using localhost:8000')
conf['www_root'] = 'http://localhost:8000/'

# figure out timezone and set offset
offset = round(((datetime.now() - datetime.utcnow()).total_seconds()) / 3600.0)
# figure out timezone and set offset, more verbose for 2.6 compatibility
td = (datetime.now() - datetime.utcnow())
offset = round(total_seconds(td) / 3600.0)
conf['tzinfo'] = readers.Timezone(offset)

# determine http(s), host and path
Expand Down
4 changes: 4 additions & 0 deletions acrylamid/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def force_unicode(string): # This function can be removed with Python 3
force_unicode = lambda x: x


def total_seconds(td): # timedelta.total_seconds, required for 2.6
return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6


class cached_property(object):
"""A property that is only computed once per instance and then replaces
itself with an ordinary attribute. Deleting the attribute resets the
Expand Down
6 changes: 3 additions & 3 deletions acrylamid/views/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime, timedelta
from wsgiref.handlers import format_date_time

from acrylamid.utils import HashableList
from acrylamid.utils import HashableList, total_seconds
from acrylamid.views import View, tag
from acrylamid.compat import text_type as str
from acrylamid.helpers import joinurl, event, expand, union
Expand Down Expand Up @@ -109,7 +109,7 @@ def init(self, conf, env, num_entries=25):

self.num_entries = num_entries
env.engine.register(
'rfc822', lambda dt: str(format_date_time((dt - epoch).total_seconds())))
'rfc822', lambda dt: str(format_date_time(total_seconds(dt - epoch))))
self.type = 'rss'


Expand All @@ -129,5 +129,5 @@ def init(self, conf, env, num_entries=25):

self.num_entries = num_entries
env.engine.register(
'rfc822', lambda dt: str(format_date_time((dt - epoch).total_seconds())))
'rfc822', lambda dt: str(format_date_time(total_seconds(dt - epoch))))
self.type = 'rss'
12 changes: 6 additions & 6 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ typography, MathML and hyphenation.
Linux/Debian and OS X
*********************

You'll need the python interpreter with version ≥ 2.7 (or 3.3) and a python
package manager. If you are on Linux (Debian-based), just ``apt-get install
python python-setuputils``. If you are using OS X the proper Python version is
You'll need the python interpreter with version ≥ 2.6 and a python package
manager. If you are on Linux (Debian-based), just ``apt-get install python
python-setuputils``. If you are using OS X the proper Python version is
already installed (10.6 or later).

::
Expand Down Expand Up @@ -70,9 +70,9 @@ Works, but remains uncovered by the developer and test suite.
Python 3
********

Acrylamid fully supports Python 2.7 and 3.3 (or higher). At the time of this
writing (June '13) Jinja2 has not yet finished its Python 3.3+ port. You are
probably better off with Python 2.7 (almost all third-party application
Acrylamid fully supports Python 2.6, 2.7 and 3.3 (or higher). At the time of
this writing (June '13) Jinja2 has not yet finished its Python 3.3+ port. You
are probably better off with Python 2.7 (almost all third-party application
support 2.7, but only a few 3.3+).

Please report any issues related to Python 3, as I do not often test Acrylamid
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

requires = ['Jinja2>=2.4', 'Markdown>=2.0.1', 'unidecode>=0.04.13']

if sys.version_info < (2, 7):
requires += ['argparse', 'ordereddict']

if sys.platform == 'win32':
requires.append('colorama')

Expand All @@ -32,6 +35,7 @@
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
Expand Down
14 changes: 13 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
[tox]
envlist = py27,py33
envlist = py26,py27,py33
[testenv:py26]
deps=
Attest-latest
translitcodec
Jinja2
argparse
ordereddict
docutils
markdown
unidecode
mako
cram
[testenv:py27]
deps=
Attest-latest
Expand Down

0 comments on commit dd748f3

Please sign in to comment.