]> git.notmuchmail.org Git - notmuch/commitdiff
nmbug-status: Factor out header/footer context into a shared dict
authorW. Trevor King <wking@tremily.us>
Sat, 31 May 2014 22:20:25 +0000 (15:20 -0700)
committerDavid Bremner <david@tethera.net>
Tue, 15 Jul 2014 23:08:24 +0000 (20:08 -0300)
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

index c92d268caf2972eb68779a641eaec9b3c49cb702..b7c2f80ec75133cdddd983ad227f0d3608e2e832 100755 (executable)
@@ -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}
 </p>
 <h3>Views</h3>
-'''.format(title=config['meta']['title'],
-           blurb=config['meta']['blurb'],
-           encoding=_ENCODING,
-           inter_message_padding='0.25em',
-           border_radius='0.5em'),
+'''.format(**context),
     footer='''
 <hr>
 <p>Generated: {date}
 </body>
 </html>
-'''.format(date=datetime.datetime.utcnow().date())
+'''.format(**context),
     )
 
 if args.list_views: