From 8525430d9187028f0e156955566aea31d8c57fd8 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Sat, 8 Oct 2011 15:46:14 +0200 Subject: template.py: Avoid global variable --- scripts/template.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/template.py b/scripts/template.py index 748df8c..a4d4e9e 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -13,15 +13,13 @@ from string import Template import ConfigParser def readdir(directory): + return_value = {"content.html":"", "keywords":"", "desc_de":"", "desc_en":""} - global content - content= {"content.html":"", "keywords":"", "desc_de":"", "desc_en":""} - - for c in content: + for c in return_value: f = open(os.path.join(directory, c), "r") - content[c] = f.read() + return_value[c] = f.read() f.close - + return return_value def substitute(target, prefix, htmltemplate, datenow, topic, content): @@ -110,8 +108,8 @@ if verbose: for page in os.listdir(pagepath): prefix = os.path.join(pagepath, page) - readdir(prefix) - substitute(target, prefix, htmltemplate, datenow, topic, content) + page_data = readdir(prefix) + substitute(target, prefix, htmltemplate, datenow, topic, page_data) if verbose: print "%s.html written" % prefix # vi: noexpandtab:tabstop=8:shiftwidth=8 -- cgit v1.2.1