[PATCH v2 11/20] nmbug-status: Add an OrderedDict stub for Python 2.6
authorW. Trevor King <wking@tremily.us>
Mon, 10 Feb 2014 18:40:32 +0000 (10:40 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:52 +0000 (09:59 -0800)
05/883a223bc085d59233e9956707a6ee594118bf [new file with mode: 0644]

diff --git a/05/883a223bc085d59233e9956707a6ee594118bf b/05/883a223bc085d59233e9956707a6ee594118bf
new file mode 100644 (file)
index 0000000..f318984
--- /dev/null
@@ -0,0 +1,124 @@
+Return-Path: <wking@tremily.us>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2C579429E48\r
+       for <notmuch@notmuchmail.org>; Mon, 10 Feb 2014 10:42:21 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id fZoElOa6L6Cp for <notmuch@notmuchmail.org>;\r
+       Mon, 10 Feb 2014 10:42:17 -0800 (PST)\r
+Received: from qmta04.westchester.pa.mail.comcast.net\r
+       (qmta04.westchester.pa.mail.comcast.net [76.96.62.40])\r
+       by olra.theworths.org (Postfix) with ESMTP id 6E0C3431E64\r
+       for <notmuch@notmuchmail.org>; Mon, 10 Feb 2014 10:41:58 -0800 (PST)\r
+Received: from omta05.westchester.pa.mail.comcast.net ([76.96.62.43])\r
+       by qmta04.westchester.pa.mail.comcast.net with comcast\r
+       id Qffh1n0040vyq2s54ihyCY; Mon, 10 Feb 2014 18:41:58 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+       by omta05.westchester.pa.mail.comcast.net with comcast\r
+       id Qihx1n00B152l3L3RihxRN; Mon, 10 Feb 2014 18:41:58 +0000\r
+Received: from mjolnir.tremily.us (unknown [192.168.0.140])\r
+       by odin.tremily.us (Postfix) with ESMTPS id D7B9910167B7;\r
+       Mon, 10 Feb 2014 10:41:56 -0800 (PST)\r
+Received: (nullmailer pid 1267 invoked by uid 1000);\r
+       Mon, 10 Feb 2014 18:40:45 -0000\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 11/20] nmbug-status: Add an OrderedDict stub for Python 2.6\r
+Date: Mon, 10 Feb 2014 10:40:32 -0800\r
+Message-Id:\r
+ <0f5ffa25276acd33c0b9afedc3e51c450a95b9b4.1392056624.git.wking@tremily.us>\r
+X-Mailer: git-send-email 1.8.5.2.8.g0f6c0d1\r
+In-Reply-To: <cover.1392056624.git.wking@tremily.us>\r
+References: <cover.1392056624.git.wking@tremily.us>\r
+In-Reply-To: <cover.1392056624.git.wking@tremily.us>\r
+References: <cover.1392056624.git.wking@tremily.us>\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+       s=q20121106; t=1392057718;\r
+       bh=YB6FulXB8bFHoMJns9VjFJhQgNsC71rEl5sUI8XDBdA=;\r
+       h=Received:Received:Received:Received:From:To:Subject:Date:\r
+       Message-Id;\r
+       b=MEwtMBuEtSPC9hRpDDZIDWWnguzGkYNS1okbUtS184/Hl83l8PrgGtt388usxwlEm\r
+       h0DVRHv5rC4PG9wlKKhyFLMv/Orn+ttNiQzMxpqA59/ujE9tkL2tYYfNxsJlFo2i7k\r
+       FIkSR+mSHgd/lriCosJYgH/ffKJaT5hjZSxe+FPLdyajY9O0YcjgRTICCYVI5xiAHN\r
+       R0310QLipsyaHGHETJ4RA5wMyyk6bSFphyiDx0PYm7ubH9360GKvra5ane6A2svb3n\r
+       pf5ebgHIAYEkMw0JXwNHPPofNb6M3TuCJmaJiD43/iH9imr9D15CjHRqG0X4f8R4t0\r
+       QDEwG8fTqiSdw==\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 10 Feb 2014 18:42:21 -0000\r
+\r
+Tomi Ollila and David Bremner (and presumably others) are running\r
+Python 2.6 on their nmbug-status boxes, so it makes sense to keep\r
+support for that version.  This commit adds a really minimal\r
+OrderedDict stub (e.g. it doesn't handle key removal), but it gets the\r
+job done for Page._get_threads.  Once we reach a point where Python\r
+2.6 is no longer important (it's already out of it's security-fix\r
+window [1]), we can pull this stub back out.\r
+\r
+[1]: http://www.python.org/download/releases/2.6.9/\r
+---\r
+ devel/nmbug/nmbug-status | 20 +++++++++++++++++++-\r
+ 1 file changed, 19 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status\r
+index 6aa2583..57f16e2 100755\r
+--- a/devel/nmbug/nmbug-status\r
++++ b/devel/nmbug/nmbug-status\r
+@@ -5,7 +5,6 @@\r
+ # dependencies\r
+ #       - python 2.6 for json\r
+ #       - argparse; either python 2.7, or install separately\r
+-#       - collections.OrderedDict; python 2.7\r
\r
+ from __future__ import print_function\r
+ from __future__ import unicode_literals\r
+@@ -30,6 +29,25 @@ _ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding()\r
+ _PAGES = {}\r
\r
\r
++if not hasattr(collections, 'OrderedDict'):  # Python 2.6 or earlier\r
++    class _OrderedDict (dict):\r
++        "Just enough of a stub to get through Page._get_threads"\r
++        def __init__(self, *args, **kwargs):\r
++            super(_OrderedDict, self).__init__(*args, **kwargs)\r
++            self._keys = []  # record key order\r
++\r
++        def __setitem__(self, key, value):\r
++            super(_OrderedDict, self).__setitem__(key, value)\r
++            self._keys.append(key)\r
++\r
++        def __values__(self):\r
++            for key in self._keys:\r
++                yield self[key]\r
++\r
++\r
++    collections.OrderedDict = _OrderedDict\r
++\r
++\r
+ def read_config(path=None, encoding=None):\r
+     "Read config from json file"\r
+     if not encoding:\r
+-- \r
+1.8.5.2.8.g0f6c0d1\r
+\r