[Cryptech-Commits] [user/sra/pelican] 33/68: Hard-link image tree

git at cryptech.is git at cryptech.is
Mon Jul 19 22:25:12 UTC 2021


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch pelican
in repository user/sra/pelican.

commit 89110a41886e7f388a348a561ae78b5088b3669f
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sun Feb 14 17:07:40 2021 +0000

    Hard-link image tree
---
 .gitignore | 1 +
 extract.py | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 38cf45b..3d9d661 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ __pycache__
 attachments
 trac.db
 pelican/pelicanconf.py
+pelican/images
diff --git a/extract.py b/extract.py
index 9f53f38..ffd183b 100755
--- a/extract.py
+++ b/extract.py
@@ -50,7 +50,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(urllib.parse.quote(row.id, ""), urllib.parse.quote(row.filename, ""))
+        os.path.join("pelican", "images", urllib.parse.quote(row.id, ""), urllib.parse.quote(row.filename, ""))
 
 class Filter:
 
@@ -97,7 +97,11 @@ def main():
                 f.write(md)
 
     for row in db.execute(attachment_query):
-        print("{} => {}".format(*attachment_link(row)))
+        src, dst = attachment_link(row)
+        print("{} => {}".format(dst, src))
+        if not os.path.isdir(os.path.dirname(dst)):
+            os.makedirs(os.path.dirname(dst))
+        os.link(src, dst)
 
     db.close()
 



More information about the Commits mailing list