Browse Source

warn instead of failing

boyska 2 years ago
parent
commit
65fe358aff
1 changed files with 7 additions and 4 deletions
  1. 7 4
      ics2mdwn.py

+ 7 - 4
ics2mdwn.py

@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 
+import logging
 import argparse
 import os.path
 from typing import Iterable
@@ -25,7 +26,7 @@ def get_parser():
         default="data/schedule.yml",
         type=Path,
     )
-    p.add_argument('--trust-location', type=str, nargs='*', default=[])
+    p.add_argument("--trust-location", type=str, nargs="*", default=[])
     p.add_argument("--night-threshold", metavar="HOUR", default=5, type=int)
     p.add_argument("--mode", choices=["hugo"], default="hugo")
     return p
@@ -116,11 +117,13 @@ class HugoConverter(Converter):
                         ).total_seconds()
                         // 60
                     ),
+                    tags=[],
                 )
             if "CATEGORIES" in talk:
-                frontmatter["tags"] = [str(t) for t in talk.get("CATEGORIES").cats]
-            else:
-                frontmatter["tags"] = []
+                try:
+                    frontmatter["tags"] = [str(t) for t in talk.get("CATEGORIES").cats]
+                except Exception as exc:
+                    logging.warning("Error parsing categories: %s", str(exc))
             if 'base' in frontmatter['tags']:
                 frontmatter['level'] = 'Principiante'
             with open(str(fpath), "w") as buf: