--- /dev/null
+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 5FAE6431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 10 Feb 2014 10:42:08 -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 O4lVNyLvDpbZ for <notmuch@notmuchmail.org>;\r
+ Mon, 10 Feb 2014 10:42:03 -0800 (PST)\r
+Received: from qmta10.westchester.pa.mail.comcast.net\r
+ (qmta10.westchester.pa.mail.comcast.net [76.96.62.17])\r
+ by olra.theworths.org (Postfix) with ESMTP id 85E00431FC2\r
+ for <notmuch@notmuchmail.org>; Mon, 10 Feb 2014 10:41:55 -0800 (PST)\r
+Received: from omta11.westchester.pa.mail.comcast.net ([76.96.62.36])\r
+ by qmta10.westchester.pa.mail.comcast.net with comcast\r
+ id Qhok1n00D0mv7h05AihvE0; Mon, 10 Feb 2014 18:41:55 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+ by omta11.westchester.pa.mail.comcast.net with comcast\r
+ id Qiht1n00b152l3L3XihuvE; Mon, 10 Feb 2014 18:41:55 +0000\r
+Received: from mjolnir.tremily.us (unknown [192.168.0.140])\r
+ by odin.tremily.us (Postfix) with ESMTPS id B489410167A9;\r
+ Mon, 10 Feb 2014 10:41:53 -0800 (PST)\r
+Received: (nullmailer pid 1250 invoked by uid 1000);\r
+ Mon, 10 Feb 2014 18:40:44 -0000\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 04/20] nmbug-status: Factor config-loading out into\r
+ read_config\r
+Date: Mon, 10 Feb 2014 10:40:25 -0800\r
+Message-Id:\r
+ <65fe8d8f253ba3dfa48f89193765ba16f44b4f81.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=1392057715;\r
+ bh=7QgiYpMpmn8WqWRsOxQXygu5qDb5C0F7IAUnsXEftMU=;\r
+ h=Received:Received:Received:Received:From:To:Subject:Date:\r
+ Message-Id;\r
+ b=pU+iK8OWQtxdPVhjt1I0b/x2nif7S0IvKXPPZPNXY7DRAKWpcdb9gLQnlbfcoDXMi\r
+ sjVfaitTQBfs+kNSJKLQgcSsJswH7FeYVUNoitSh73JvjRP9aLKkd4spqClogwtzOZ\r
+ Ee6IFXk+Ynx/5851vwYPYnGTGAkDfI2epebSLTuB2AdbYkATCkq2ZMOPoYxS0TvD2H\r
+ hFDwDs5gRyJaRk2hFCOvk8pzukgJ95yauCm7yfIxRiYVCzFM9NWjWTWAmTzQxvtMbt\r
+ lHIK7SWWRwO7b4Xmtg5qkVbokc+TiUzjiiQuUB1z9EC3orwW6ClnNYQUD9vEtNe7y1\r
+ mYE63qqFcyaIQ==\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:08 -0000\r
+\r
+By isolating this peripheral handling, we make the core logic of\r
+nmbug-status easier to read.\r
+---\r
+ devel/nmbug/nmbug-status | 45 +++++++++++++++++++++++++--------------------\r
+ 1 file changed, 25 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status\r
+index a7a391d..6dfbe4d 100755\r
+--- a/devel/nmbug/nmbug-status\r
++++ b/devel/nmbug/nmbug-status\r
+@@ -23,6 +23,30 @@ import subprocess\r
+ _ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding()\r
+ \r
+ \r
++def read_config(path=None, encoding=None):\r
++ "Read config from json file"\r
++ if not encoding:\r
++ encoding = _ENCODING\r
++ if path:\r
++ fp = open(path)\r
++ else:\r
++ nmbhome = os.getenv('NMBGIT', os.path.expanduser('~/.nmbug'))\r
++\r
++ # read only the first line from the pipe\r
++ sha1_bytes = subprocess.Popen(\r
++ ['git', '--git-dir', nmbhome, 'show-ref', '-s', 'config'],\r
++ stdout=subprocess.PIPE).stdout.readline()\r
++ sha1 = sha1_bytes.decode(encoding).rstrip()\r
++\r
++ fp_byte_stream = subprocess.Popen(\r
++ ['git', '--git-dir', nmbhome, 'cat-file', 'blob',\r
++ sha1+':status-config.json'],\r
++ stdout=subprocess.PIPE).stdout\r
++ fp = codecs.getreader(encoding=encoding)(stream=fp_byte_stream)\r
++\r
++ return json.load(fp)\r
++\r
++\r
+ # parse command line arguments\r
+ \r
+ parser = argparse.ArgumentParser()\r
+@@ -35,26 +59,7 @@ parser.add_argument('--get-query', help='get query for view')\r
+ \r
+ args = parser.parse_args()\r
+ \r
+-# read config from json file\r
+-\r
+-if args.config != None:\r
+- fp = open(args.config)\r
+-else:\r
+- nmbhome = os.getenv('NMBGIT', os.path.expanduser('~/.nmbug'))\r
+-\r
+- # read only the first line from the pipe\r
+- sha1_bytes = subprocess.Popen(\r
+- ['git', '--git-dir', nmbhome, 'show-ref', '-s', 'config'],\r
+- stdout=subprocess.PIPE).stdout.readline()\r
+- sha1 = sha1_bytes.decode(_ENCODING).rstrip()\r
+-\r
+- fp_byte_stream = subprocess.Popen(\r
+- ['git', '--git-dir', nmbhome, 'cat-file', 'blob',\r
+- sha1+':status-config.json'],\r
+- stdout=subprocess.PIPE).stdout\r
+- fp = codecs.getreader(encoding=_ENCODING)(stream=fp_byte_stream)\r
+-\r
+-config = json.load(fp)\r
++config = read_config(path=args.config)\r
+ \r
+ if args.list_views:\r
+ for view in config['views']:\r
+-- \r
+1.8.5.2.8.g0f6c0d1\r
+\r