From 7759433b80bf8e0e8ed54c8d393a8c4fb2b2f00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com> Date: Mon, 13 Feb 2023 11:16:06 +0100 Subject: [PATCH] Fix Jekyll import --- shared/jekyll_import.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shared/jekyll_import.py b/shared/jekyll_import.py index bfa8898f..8087bfca 100644 --- a/shared/jekyll_import.py +++ b/shared/jekyll_import.py @@ -83,18 +83,18 @@ def download_repo_as_zip(url: str) -> (str, str): # zdá se, že někdy je -gh-pages, někdy -master... gh_pages_path = os.path.join(path, "{}-gh-pages".format(repo_name)) - gh_pages_path_exists = os.path.exists(gh_pages_path) - master_path = os.path.join(path, "{}-master".format(repo_name)) - master_path_exists = os.path.exists(master_path) - - if gh_pages_path_exists: + if os.path.exists(gh_pages_path): return gh_pages_path, repo_name - if master_path_exists: + master_path = os.path.join(path, "{}-master".format(repo_name)) + if os.path.exists(master_path): return master_path, repo_name - else: - raise NotImplementedError("Tento zip nedokážeme zpracovat.") + main_path = os.path.join(path, "{}-main".format(repo_name)) + if os.path.exists(main_path): + return main_path, repo_name + + raise NotImplementedError("Tento zip nedokážeme zpracovat.") def get_or_create_image( @@ -576,7 +576,9 @@ class JekyllArticleImporter: md = r[2] # "raw" markdown z postu html = html_md.convert(md) # očistíme o případné nechtěné HTML tagy - html = bleach.clean(html, tags=bleach.sanitizer.ALLOWED_TAGS + ["div", "p"]) + html = bleach.clean( + html, tags=list(bleach.sanitizer.ALLOWED_TAGS) + ["div", "p"] + ) article.perex = self.get_perex(md) or "..." self.handle_content(article, meta, html) -- GitLab