diff --git a/gnupg/_parsers.py b/gnupg/_parsers.py index dd3ddaa..c625d75 100644 --- a/gnupg/_parsers.py +++ b/gnupg/_parsers.py @@ -25,12 +25,9 @@ from __future__ import absolute_import from __future__ import print_function try: - # py2.7+ comes with collections.OrderedDict - from collections import OrderedDict + import collections except ImportError: - # py2.6 doesn't; this is an equivalent; - # `pip install ordereddict` - from ordereddict import OrderedDict + import ordereddict as collections import re @@ -1029,7 +1026,7 @@ class ImportResult(object): _fields = '''count no_user_id imported imported_rsa unchanged n_uids n_subk n_sigs n_revoc sec_read sec_imported sec_dups not_imported'''.split() - _counts = OrderedDict( + _counts = collections.OrderedDict( zip(_fields, [int(0) for x in range(len(_fields))]) ) #: A list of strings containing the fingerprints of the GnuPG keyIDs diff --git a/setup.py b/setup.py index 3b4154d..90b1e8e 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,7 @@ from __future__ import absolute_import from __future__ import print_function import setuptools +import sys import os import versioneer @@ -37,6 +38,12 @@ __contact__ = 'isis@patternsinthevoid.net' __url__ = 'https://github.com/isislovecruft/python-gnupg' +def python26(): + """Returns True if we're running on Python2.6.""" + if sys.version[:3] == "2.6": + return True + return False + def get_requirements(): """Extract the list of requirements from our requirements.txt. @@ -64,6 +71,10 @@ def get_requirements(): except (IOError, OSError) as error: print(error) + if python26(): + # Required to make `collections.OrderedDict` available on Python<=2.6 + requirements.append('ordereddict==1.1#a0ed854ee442051b249bfad0f638bbec') + return requirements, links