From eef9d50c6da1a8514dade98c8d13e10c3e8c6a01 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 1 Jun 2014 15:20:25 +1700 Subject: [PATCH] [PATCH v2 4/6] nmbug-status: Factor out header/footer context into a shared dict --- 38/ac886c0ff510dd1112e40f094165f70c0406e1 | 121 ++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 38/ac886c0ff510dd1112e40f094165f70c0406e1 diff --git a/38/ac886c0ff510dd1112e40f094165f70c0406e1 b/38/ac886c0ff510dd1112e40f094165f70c0406e1 new file mode 100644 index 000000000..3ad745ba0 --- /dev/null +++ b/38/ac886c0ff510dd1112e40f094165f70c0406e1 @@ -0,0 +1,121 @@ +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 35474431E82 + for ; Sat, 31 May 2014 15:21:11 -0700 (PDT) +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 dD-yu-7Wbs3s for ; + Sat, 31 May 2014 15:21:07 -0700 (PDT) +Received: from qmta07.westchester.pa.mail.comcast.net + (qmta07.westchester.pa.mail.comcast.net [76.96.62.64]) + by olra.theworths.org (Postfix) with ESMTP id 80BC8431FD4 + for ; Sat, 31 May 2014 15:21:02 -0700 (PDT) +Received: from omta05.westchester.pa.mail.comcast.net ([76.96.62.43]) + by qmta07.westchester.pa.mail.comcast.net with comcast + id 8mJu1o0020vyq2s57mM1hQ; Sat, 31 May 2014 22:21:01 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta05.westchester.pa.mail.comcast.net with comcast + id 8mM01o00H152l3L3RmM1nX; Sat, 31 May 2014 22:21:01 +0000 +Received: from mjolnir.tremily.us (unknown [192.168.0.140]) + by odin.tremily.us (Postfix) with ESMTPS id 4649611F0658; + Sat, 31 May 2014 15:21:00 -0700 (PDT) +Received: (nullmailer pid 13194 invoked by uid 1000); + Sat, 31 May 2014 22:20:38 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH v2 4/6] nmbug-status: Factor out header/footer context into a + shared dict +Date: Sat, 31 May 2014 15:20:25 -0700 +Message-Id: + <967d2f99ba4e4b17c8e73b879b9205e64e562448.1401574293.git.wking@tremily.us> +X-Mailer: git-send-email 1.9.1.353.gc66d89d +In-Reply-To: +References: +In-Reply-To: +References: +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1401574861; + bh=I5xH/c/7rC3D3EAdxLDgPzSvqcTmF0hf26DqdE/Z2tM=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=UIjmwfhZle3SoeTFX5Rfzlzosct7cNaYKUJUYpJONYmMcXdbkpMVHxpvlYwqyxnFu + vICvt/5R3kGNs52fL/KRVIGEsfddKw14Hyg5xEa9d+dmDwTdKL9zJ4et/qPbWETZBA + DNSPMd1pqogko3J09MhlCBxZk4qcjIWXxSGPwgkCs3D5W4NzhCPn8d3NSC5v8BfkPE + 1Wnag7avVUd5IZ1ZuWyCTA5dTLRHWgJw8aAvubSsfTixV9JclgRmFFsR+7ODKpo4Y4 + Q9q1B6BK2/PNOtGYWL1W+EBTxA1LDzs9vgXDc3sIhgAkEIic421/zKI1Ic2Ze8Wx9F + eYVOOs9rAeiZw== +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: Sat, 31 May 2014 22:21:11 -0000 + +Rather than splitting this context into header-only and footer-only +groups, just dump it all in a shared dict. This will make it easier +to eventually split the header/footer templates out of this script +(e.g. if we want to load them from the config file). +--- + devel/nmbug/nmbug-status | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status +index c92d268..b7c2f80 100755 +--- a/devel/nmbug/nmbug-status ++++ b/devel/nmbug/nmbug-status +@@ -275,6 +275,14 @@ parser.add_argument('--get-query', help='get query for view', + args = parser.parse_args() + + config = read_config(path=args.config) ++context = { ++ 'date': datetime.datetime.utcnow(), ++ 'title': config['meta']['title'], ++ 'blurb': config['meta']['blurb'], ++ 'encoding': _ENCODING, ++ 'inter_message_padding': '0.25em', ++ 'border_radius': '0.5em', ++ } + + _PAGES['text'] = Page() + _PAGES['html'] = HtmlPage( +@@ -328,17 +336,13 @@ _PAGES['html'] = HtmlPage( + {blurb} +

+

Views

+-'''.format(title=config['meta']['title'], +- blurb=config['meta']['blurb'], +- encoding=_ENCODING, +- inter_message_padding='0.25em', +- border_radius='0.5em'), ++'''.format(**context), + footer=''' +
+

Generated: {date} + + +-'''.format(date=datetime.datetime.utcnow().date()) ++'''.format(**context), + ) + + if args.list_views: +-- +1.9.1.353.gc66d89d + -- 2.26.2