소스 검색

Undo URL quoting of directory names in Markdown output

Rob Austein 3 년 전
부모
커밋
d0c10e7a18
1개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. 8 6
      extract.py

+ 8 - 6
extract.py

@@ -49,7 +49,7 @@ def attachment_link(row):
     fn2 = os.path.splitext(row["filename"])[1]
     return \
         os.path.join("attachments", "wiki", h1[:3], h1, h2 + fn2), \
-        os.path.join("pelican", "content", urllib.parse.quote(row.id, ""), row.filename)
+        os.path.join("pelican", "content", row.id, row.filename)
 
 class Filter:
 
@@ -108,12 +108,14 @@ def main():
 
     for row in db.execute(wiki_query):
         if keep(row.name):
-            slug = urllib.parse.quote(row.name, "")
-            #print(slug, row.version)
-            with open("wiki/{}.trac".format(slug), "w") as f:
+            with open("wiki/{}.trac".format(urllib.parse.quote(row.name, "")), "w") as f:
                 f.write(row.text)
-            md = markdown_header(row, first_published) + wiki_to_markdown(row.text, slug)
-            with open("pelican/content/{}.md".format(slug), "w") as f:
+            md = markdown_header(row, first_published) + wiki_to_markdown(row.text, row.name)
+            fn = "pelican/content/{}.md".format(row.name)
+            dn = os.path.dirname(fn)
+            if not os.path.exists(dn):
+                os.makedirs(dn)
+            with open(fn, "w") as f:
                 f.write(md)
 
     for row in db.execute(attachment_query):