aboutsummaryrefslogtreecommitdiffhomepage
path: root/devel
diff options
context:
space:
mode:
authorGravatar W. Trevor King <wking@tremily.us>2014-02-10 10:40:32 -0800
committerGravatar David Bremner <david@tethera.net>2014-02-10 22:51:40 -0400
commitc48a12365fba12a8ec0922a011a86ee15bc5cc8f (patch)
treeedca2c50549c2ea8a5edb29e5e00160a2a5fc365 /devel
parent98cb4779c02a07c0405073ca4a1e8a9006844904 (diff)
nmbug-status: Add an OrderedDict stub for Python 2.6
Tomi Ollila and David Bremner (and presumably others) are running Python 2.6 on their nmbug-status boxes, so it makes sense to keep support for that version. This commit adds a really minimal OrderedDict stub (e.g. it doesn't handle key removal), but it gets the job done for Page._get_threads. Once we reach a point where Python 2.6 is no longer important (it's already out of it's security-fix window [1]), we can pull this stub back out. [1]: http://www.python.org/download/releases/2.6.9/
Diffstat (limited to 'devel')
-rwxr-xr-xdevel/nmbug/nmbug-status20
1 files changed, 19 insertions, 1 deletions
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 6aa25832..57f16e25 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -5,7 +5,6 @@
# dependencies
# - python 2.6 for json
# - argparse; either python 2.7, or install separately
-# - collections.OrderedDict; python 2.7
from __future__ import print_function
from __future__ import unicode_literals
@@ -30,6 +29,25 @@ _ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding()
_PAGES = {}
+if not hasattr(collections, 'OrderedDict'): # Python 2.6 or earlier
+ class _OrderedDict (dict):
+ "Just enough of a stub to get through Page._get_threads"
+ def __init__(self, *args, **kwargs):
+ super(_OrderedDict, self).__init__(*args, **kwargs)
+ self._keys = [] # record key order
+
+ def __setitem__(self, key, value):
+ super(_OrderedDict, self).__setitem__(key, value)
+ self._keys.append(key)
+
+ def __values__(self):
+ for key in self._keys:
+ yield self[key]
+
+
+ collections.OrderedDict = _OrderedDict
+
+
def read_config(path=None, encoding=None):
"Read config from json file"
if not encoding: