Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add python2.6 support

  • Loading branch information...
commit 6e8b642aa31b0e3ca0b3e00b6c18773cff9bfa4e 1 parent 774ce20
Mark McClain authored
Showing with 27 additions and 4 deletions.
  1. +17 −1 cliff/app.py
  2. +9 −2 cliff/lister.py
  3. +1 −1  tox.ini
View
18 cliff/app.py
@@ -12,7 +12,23 @@
# Make sure the cliff library has a logging handler
# in case the app developer doesn't set up logging.
-logging.getLogger('cliff').addHandler(logging.NullHandler())
+# For py26 compat, create a NullHandler
+
+if hasattr(logging, 'NullHandler'):
+ NullHandler = logging.NullHandler
+else:
+ class NullHandler(logging.Handler):
+ def handle(self, record):
+ pass
+
+ def emit(self, record):
+ pass
+
+ def createLock(self):
+ self.lock = None
+
+logging.getLogger('cliff').addHandler(NullHandler())
+
LOG = logging.getLogger(__name__)
View
11 cliff/lister.py
@@ -1,7 +1,14 @@
"""Application base class for providing a list of data as output.
"""
import abc
-import itertools
+
+try:
+ from itertools import compress
+except ImportError:
+ # for py26 compat
+ def compress(data, selectors):
+ return (d for d, s in izip(data, selectors) if s)
+
import logging
from .display import DisplayCommandBase
@@ -47,7 +54,7 @@ def produce_output(self, parsed_args, column_names, data):
# of data that the user has expressed interest in
# seeing. We have to convert the compress() output to a
# list so the table formatter can ask for its length.
- data_gen = (list(itertools.compress(row, selector))
+ data_gen = (list(compress(row, selector))
for row in data)
self.formatter.emit_list(columns_to_include,
data_gen,
View
2  tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,py32,pep8
+envlist = py26,py27,py32,pep8
[testenv]
commands = nosetests -d --with-coverage --cover-inclusive --cover-package cliff []

0 comments on commit 6e8b642

Please sign in to comment.
Something went wrong with that request. Please try again.