Browse Source

Makefile: Use whatever version python3 points to

Jakub Valenta 5 months ago
parent
commit
dc26793b87
2 changed files with 27 additions and 25 deletions
  1. 1 1
      Makefile
  2. 26 24
      art_strategies.py

+ 1 - 1
Makefile

@@ -1,5 +1,5 @@
 dist:
-	python3.5 art_strategies.py || python3.4 art_strategies.py
+	./art_strategies.py
 
 .PHONY: clean build serve serve-en serve-cs
 

+ 26 - 24
art_strategies.py

@@ -1,17 +1,18 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import datetime
 import os.path
-try:
-    from os import scandir
-except ImportError:
-    from scandir import scandir
 import shutil
 
 import yaml
 
 import art_lib
 
+try:
+    from os import scandir
+except ImportError:
+    from scandir import scandir
+
 
 def main():
     PATH_SRC = 'jekyll'
@@ -25,8 +26,7 @@ def main():
     TEXTS_EXT = '.yml'
 
     configs = art_lib.jekyll_get_configs(
-        PATH_DATA,
-        os.path.join(PATH_SRC, FILE_CONFIG_DEFAULTS)
+        PATH_DATA, os.path.join(PATH_SRC, FILE_CONFIG_DEFAULTS)
     )
     for lang, config in configs:
         if lang is not None:
@@ -41,18 +41,17 @@ def main():
         path_texts = os.path.join(PATH_TEXTS, lang)
 
         art_lib.mkdir_and_write(
-            path_config,
-            yaml.dump(config, default_flow_style=False)
+            path_config, yaml.dump(config, default_flow_style=False)
         )
 
         files = []
         for entry in sorted(scandir(path_texts), key=lambda x: x.name):
-            if not entry.name.startswith('.') and entry.is_file()\
-               and entry.name.endswith(TEXTS_EXT):
-                files.append((
-                    entry.path,
-                    entry.name
-                ))
+            if (
+                not entry.name.startswith('.')
+                and entry.is_file()
+                and entry.name.endswith(TEXTS_EXT)
+            ):
+                files.append((entry.path, entry.name))
 
         for file in files:
             with open(file[0], 'r') as f:
@@ -66,21 +65,24 @@ def main():
             else:
                 post_fontsize = None
             post_context = {
-                'yaml': yaml.dump({
-                    'name': art_lib.tex_to_plain(post_data['title']),
-                    'timestamp': post_date.strftime('%Y-%m-%d %H:%M:%S'),
-                    'title': art_lib.tex_to_plain(post_data['title']),
-                    'heading': art_lib.tex_to_plain(post_data['heading']),
-                    'text': art_lib.tex_to_plain(post_data['text']),
-                    'classname': post_fontsize,
-                }, default_flow_style=False)
+                'yaml': yaml.dump(
+                    {
+                        'name': art_lib.tex_to_plain(post_data['title']),
+                        'timestamp': post_date.strftime('%Y-%m-%d %H:%M:%S'),
+                        'title': art_lib.tex_to_plain(post_data['title']),
+                        'heading': art_lib.tex_to_plain(post_data['heading']),
+                        'text': art_lib.tex_to_plain(post_data['text']),
+                        'classname': post_fontsize,
+                    },
+                    default_flow_style=False,
+                )
             }
             art_lib.jekyll_write_post(
                 path_template,
                 path_posts,
                 post_date.strftime('%Y-%m-%d'),
                 post_basename,
-                post_context
+                post_context,
             )