diff options
author | Christian Franke <nobody@nowhere.ws> | 2011-10-08 15:46:14 +0200 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2011-10-08 15:46:14 +0200 |
commit | 8525430d9187028f0e156955566aea31d8c57fd8 (patch) | |
tree | eaa1000024679e4c1c40bf8daaa1cf7b1206dcd6 /scripts | |
parent | 1019adda9a8e8a76aa712b7416cad26d47010b3b (diff) |
template.py: Avoid global variable
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/template.py | 14 |
1 files changed, 6 insertions, 8 deletions
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 |