parent:
ba2a53f732d125d6d7d3abcdac9bf5aaa0ec64f1
Nick Mykins <nick.mykins@gmail.com>
2014-11-08T08:48:12-05:00
refactor deploy.py
diff --git a/deploy.py b/deploy.py
index 2cff45f153d005e5cd72bab76efd4ede3de1caf6..4c6dcb36469803c90d82c2bc1456cec5e6a9f2e6 100644
--- a/deploy.py
+++ b/deploy.py
@@ -27,6 +27,17 @@ 'cowtext': cowdict[cowdate][1]}
for cowdate in cowblogorder]
+def write_cowfiles(cowposts):
+ cowtemplate = template_env.get_template('cowtemplate.html')
+ cowposttemplate = template_env.get_template('cowposttemplate.html')
+ with open(PATH + '/public_html/index.html', 'w') as moo:
+ moo.write(cowtemplate.render(cowposts=cowposts))
+ for cowpost in cowposts:
+ with open(PATH + '/cowposts_html/%s'
+ % cowpost['htmltitle'], 'w') as moo:
+ moo.write(cowposttemplate.render(cowpost=cowpost))
+
+
def cowmain():
os.chdir(COWPOSTPATH)
cowlinelists = []
@@ -37,14 +48,7 @@ cowlinelists.append(moo.readlines())
cownamedlines = zip(cowpostfiles, cowlinelists)
cowdict = make_cowdict(cownamedlines)
cowposts = cowblogsort(cowdict)
- cowtemplate = template_env.get_template('cowtemplate.html')
- cowposttemplate = template_env.get_template('cowposttemplate.html')
- with open(PATH + '/public_html/index.html', 'w') as moo:
- moo.write(cowtemplate.render(cowposts=cowposts))
- for cowpost in cowposts:
- with open(PATH + '/cowposts_html/%s'
- % cowpost['htmltitle'], 'w') as moo:
- moo.write(cowposttemplate.render(cowpost=cowpost))
+ write_cowfiles(cowposts)
if __name__ == '__main__':