faassen avatar faassen committed 3720d7f

Get rid of HTML_PATH global.

Refactor generate_rss a bit so that actual writing is done in main
generation function.

Comments (0)

Files changed (1)

 CSS_URL = config.get('html', 'css_url')
 TEMPLATES_PATH = config.get('html', 'templates_path')
-HTML_PATH = config.get('html', 'html_path')
 BASE = config.get('html', 'base_url')
 DISQUS_NAME = config.get('disqus', 'name')
     'python.xml': sieve('python')
-def generate_rss(data, sieve, name):
+def generate_rss(data, sieve):
     """Generate the rss feed, from a list of docutils parts dicts.
     Depends on that the parts['created'] contains UTC """
     items = []
                     guid = PyRSS2Gen.Guid(url(parts)),
                     pubDate = datetime.fromtimestamp(parts['created'])))
-    rss = PyRSS2Gen.RSS2(
+    return PyRSS2Gen.RSS2(
         title = TITLE,
         link = BASE,
         description = DESCRIPTION,
         lastBuildDate = datetime.utcnow(),
         items = items)
-    rss.write_xml(open(os.path.join(HTML_PATH, name), "w"))
 def get_data(entry):
     """Parse the rst in the string entry and return the parts dict"""
             css_path=config.get('html', 'css_path'),
             css_name=config.get('html', 'css_name')
     entries = get_entries()
     data = get_data_entries(entries)
     main = []
                           for parts in data])
+    html_path = config.get('html', 'html_path')
     for parts in data: 
         htmltitle = identifier(parts)
-        target_path = os.path.join(HTML_PATH, htmltitle)
+        target_path = os.path.join(html_path, htmltitle)
         if not os.path.exists(target_path):
-        with open(os.path.join(HTML_PATH, htmltitle, "index.html"), "w") as target:
+        with open(os.path.join(html_path, htmltitle, "index.html"), "w") as target:
             #Write page for post
             fullcomments = comments_full_tpl.substitute(parts, threadid=htmltitle)
             blaag_html = blaag_tpl.substitute(parts, comments=fullcomments)
     #Write main page
-    with open(os.path.join(HTML_PATH, "index.html"), "w") as target:
+    with open(os.path.join(html_path, "index.html"), "w") as target:
         target.write(page_tpl.substitute(defaults, links=links, 
     #Write rss
-    for name in FEEDS:
-        generate_rss(data, FEEDS[name], name)
+    for name in FEEDS:        
+        rss = generate_rss(data, FEEDS[name])
+        f = open(os.path.join(html_path, name), 'w')
+        rss.write_xml(f)
+        f.close()
 def pretxncommit_hook(*args, **kwargs):
     """Run before commit"""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.