Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2C579429E48 for ; Mon, 10 Feb 2014 10:42:21 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fZoElOa6L6Cp for ; Mon, 10 Feb 2014 10:42:17 -0800 (PST) Received: from qmta04.westchester.pa.mail.comcast.net (qmta04.westchester.pa.mail.comcast.net [76.96.62.40]) by olra.theworths.org (Postfix) with ESMTP id 6E0C3431E64 for ; Mon, 10 Feb 2014 10:41:58 -0800 (PST) Received: from omta05.westchester.pa.mail.comcast.net ([76.96.62.43]) by qmta04.westchester.pa.mail.comcast.net with comcast id Qffh1n0040vyq2s54ihyCY; Mon, 10 Feb 2014 18:41:58 +0000 Received: from odin.tremily.us ([24.18.63.50]) by omta05.westchester.pa.mail.comcast.net with comcast id Qihx1n00B152l3L3RihxRN; Mon, 10 Feb 2014 18:41:58 +0000 Received: from mjolnir.tremily.us (unknown [192.168.0.140]) by odin.tremily.us (Postfix) with ESMTPS id D7B9910167B7; Mon, 10 Feb 2014 10:41:56 -0800 (PST) Received: (nullmailer pid 1267 invoked by uid 1000); Mon, 10 Feb 2014 18:40:45 -0000 From: "W. Trevor King" To: notmuch@notmuchmail.org Subject: [PATCH v2 11/20] nmbug-status: Add an OrderedDict stub for Python 2.6 Date: Mon, 10 Feb 2014 10:40:32 -0800 Message-Id: <0f5ffa25276acd33c0b9afedc3e51c450a95b9b4.1392056624.git.wking@tremily.us> X-Mailer: git-send-email 1.8.5.2.8.g0f6c0d1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1392057718; bh=YB6FulXB8bFHoMJns9VjFJhQgNsC71rEl5sUI8XDBdA=; h=Received:Received:Received:Received:From:To:Subject:Date: Message-Id; b=MEwtMBuEtSPC9hRpDDZIDWWnguzGkYNS1okbUtS184/Hl83l8PrgGtt388usxwlEm h0DVRHv5rC4PG9wlKKhyFLMv/Orn+ttNiQzMxpqA59/ujE9tkL2tYYfNxsJlFo2i7k FIkSR+mSHgd/lriCosJYgH/ffKJaT5hjZSxe+FPLdyajY9O0YcjgRTICCYVI5xiAHN R0310QLipsyaHGHETJ4RA5wMyyk6bSFphyiDx0PYm7ubH9360GKvra5ane6A2svb3n pf5ebgHIAYEkMw0JXwNHPPofNb6M3TuCJmaJiD43/iH9imr9D15CjHRqG0X4f8R4t0 QDEwG8fTqiSdw== Cc: Tomi Ollila X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Feb 2014 18:42:21 -0000 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/ --- devel/nmbug/nmbug-status | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status index 6aa2583..57f16e2 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: -- 1.8.5.2.8.g0f6c0d1