about summary refs log tree commit diff
path: root/strike.py
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2021-10-21 20:03:33 -0500
committerStarfall <us@starfall.systems>2023-12-05 10:00:09 -0600
commit2028e9fceb6222a9d8f21959792584e8ceeb040c (patch)
tree57701c0e4a4eff14e9d8aad61038325948b1602c /strike.py
parent98f2902f6e880c756eff5046c0ee9bfaf889c102 (diff)
strike: move template from fstring to file
Diffstat (limited to 'strike.py')
-rwxr-xr-xstrike.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/strike.py b/strike.py
index 3ca1e19..e3e5e52 100755
--- a/strike.py
+++ b/strike.py
@@ -1,29 +1,26 @@
 #!/usr/bin/env python3
 from os import listdir, mkdir
 from sys import exit
-from inspect import cleandoc
 
-def get_output(content):
-    return cleandoc(f'''
-    i am a template
-    with some stuff,
-    {content},
-    and some more stuff
-    ''')
+def get_output(content, template="{content}"):
+    return template.format(content = content)
 
 def main():
     src = 'blog'
     dest = 'output'
+    template = 'template'
 
     try: mkdir(dest)
     except FileExistsError: pass
 
-    for file in listdir(src):
-        with open(src + '/' + file, 'r') as fin:
-            file_contents = fin.read()
-            output = get_output(file_contents)
-            with open(dest + '/' + file, 'w') as fout:
-                fout.write(output)
+    with open(template) as t:
+        template_contents = t.read()
+        for file in listdir(src):
+            with open(src + '/' + file, 'r') as fin:
+                file_contents = fin.read()
+                output = get_output(file_contents, template=template_contents)
+                with open(dest + '/' + file, 'w') as fout:
+                    fout.write(output)
 
 if __name__ == '__main__':
     exit(main())