From 58c3c6abe2d0f4d10e40d86957f1bcfc4bc6bc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Mon, 13 Nov 2023 21:09:36 +0800 Subject: [PATCH] fix: skip inexistent file, instead of raising exception --- md2zhihu/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/md2zhihu/__init__.py b/md2zhihu/__init__.py index 63effed..e0cda3c 100644 --- a/md2zhihu/__init__.py +++ b/md2zhihu/__init__.py @@ -9,6 +9,7 @@ import k3git import urllib3 import yaml +from k3color import darkred from k3color import darkyellow from k3color import green from k3handy import cmdpass @@ -1638,6 +1639,7 @@ def main(): stat = [] for path in args.src_path: + # TODO Config should accept only two arguments: the path and a args conf = Config( path, @@ -1655,6 +1657,13 @@ def main(): embed=args.embed, ) + # Check if file exists + try: + fread(conf.src_path) + except FileNotFoundError as e: + msg(darkred(sj("Warn: file not found: ", repr(conf.src_path)))) + continue + convert_md(conf) msg(sj("Done building ", darkyellow(conf.md_output_path)))