faassen  committed 2f71244

Eliminate ENTRIES_PATH global.

  • Participants
  • Parent commits 7cc2b2b
  • Branches default

Comments (0)

Files changed (1)

 config = get_configuration('blaag.cfg')
-ENTRIES_PATH = config.get('content', 'entries_path')
 TEMPLATES_PATH = config.get('html', 'templates_path')
 BASE = config.get('html', 'base_url')
     """Parse the rst in the string entry and return the parts dict"""
     return publish_parts(entry, writer_name="html")
-def get_entries():
+def get_entries(entries_path):
     """Get the filenames of all entries, sorted using [].sort(reverse=True)"""
-    entries = [x for x in os.listdir(ENTRIES_PATH) if x.endswith(".rst")]
+    entries = [x for x in os.listdir(entries_path) if x.endswith(".rst")]
     return entries
-def get_data_entries(entries):
+def get_data_entries(entries, entries_path):
     """Read and parse entries, return document parts as generated by docutils"""
     data = []
     for entry in entries:
-        with open(os.path.join(ENTRIES_PATH, entry)) as source:
+        with open(os.path.join(entries_path, entry)) as source:
             parts = get_data("utf-8"))
-            parts.update(get_entry_dates(entry))
+            parts.update(get_entry_dates(entry, entries_path))
     return data
     """Convert a hgdate format string to unix time UTC"""
     return sum([int(i) for i in hgdate_string.split()])
-def get_entry_dates(entry):
+def get_entry_dates(entry, entries_path):
     """Get (creation, last modification) as unix time UTC"""
-    repo = hgapi.Repo(ENTRIES_PATH)
+    repo = hgapi.Repo(entries_path)
     times = repo.hg_log(template='{date|hgdate}\n', filespec=entry).split("\n")
     if times == ['']: #not in repo yet
         css_name=config.get('html', 'css_name')
-    entries = get_entries()
-    data = get_data_entries(entries)
+    entries_path = config.get('content', 'entries_path')
+    entries = get_entries(entries_path)
+    data = get_data_entries(entries, entries_path)
     main = []
     #Get timestamps from Mercurial