From 1fd0588edc549d13e6a7e8307ea85dab25df3e5f Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 20 Dec 2007 14:11:41 +0530 Subject: [PATCH] fix cfg.py in parsing template variables --- README | 6 +++--- cfg.py | 6 +++++- wrigit.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README b/README index af0ee94..5dc06a4 100644 --- a/README +++ b/README @@ -14,8 +14,8 @@ Getting Started $ sudo easy_install docutils Mako Pygments $ git clone http://repo.or.cz/r/wrigit.git $ cd wrigit - $ ./wrigit.cgi --help - $ ./wrigit.cgi # uses ./example/ and default options; + $ ./wrigit.py --help + $ ./wrigit.py --conf example/conf $ /usr/sbin/thttpd -p 8080 -d example/ $ firefox http://localhost:8080/ @@ -27,10 +27,10 @@ The following features are supported, - ReStructuredText - Disqus.com for comments - Syntax highlighting using Pygments + - default command-line options in onfiguration file The following features are planned, - - settings.ini - RSS (or Atom) - Paging (next/prev) - Search (by tags, date) diff --git a/cfg.py b/cfg.py index 6c9c103..34eaf7c 100644 --- a/cfg.py +++ b/cfg.py @@ -26,6 +26,7 @@ cfg = None def configobj_namespace(namespace): global configobj + import re class GoodConfigParserInterpolation(configobj.ConfigParserInterpolation): """Resolve custom template variables manually passed""" @@ -40,7 +41,7 @@ def configobj_namespace(namespace): if match: var = match.group(1) if var in namespace: - return namespace[var] + return re.sub(self._KEYCRE, namespace[var], value) raise # There is another engine 'template' which, for me, never seems to @@ -86,6 +87,9 @@ def setup_cfg(option_list, defaults, namespace={}): oparser.set_defaults(**defaults) (options, args) = oparser.parse_args() + if options.conf is None: + raise SystemExit, "You must specific the --conf option" + # `pwd` contains the directory where the conf file lies. namespace['pwd'] = abspath(dirname(abspath(options.conf))) diff --git a/wrigit.py b/wrigit.py index 08223d1..8bacee3 100755 --- a/wrigit.py +++ b/wrigit.py @@ -92,8 +92,8 @@ if __name__ == '__main__': except ImportError: pass - print '--> rstdir:%s [using templatedir:%s]' % ( - cfg['rstdir'], cfg['templatedir']) + print '[%s - %s] rstdir:%s [using templatedir:%s]' % ( + cfg['baseurl'], cfg['title'], cfg['rstdir'], cfg['templatedir']) blog_posts = [] blog_path = abspath(join(cfg['rstdir'], 'blog')) -- 2.11.4.GIT