Skip to content

Commit

Permalink
Fixed fatal error with map path not existing (#13)
Browse files Browse the repository at this point in the history
* Fixed fatal error with map path not existing

* Reverted erroneous variable changes

* Lint change

* Lint change

* Matching lint requirements

* Matching lint requirements for maximum line length

* Re-added exist_ok from testing

* handling specific errors likely
  • Loading branch information
Ceralor authored Dec 13, 2023
1 parent 1648193 commit 29a73fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions pelican/plugins/pelimoji/pelimoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ def init(pelican_object):
content_root, pelican_object.settings.get("PELIMOJI_SOURCE", "emoji")
)
output_path = Path(content_root, "emoji_map")
if not output_path.exists():
try:
output_path.mkdir(parents=True, exist_ok=True)
except NotADirectoryError as e:
logger.fatal(
f"Non-directory file exists at '{output_path!s}' \
{e}"
)
except PermissionError as e:
logger.fatal(f"Unable to create '{output_path!s}', permission error {e}")
pelican_object.settings["STATIC_PATHS"].append(str(output_path))
pelimoji_ext = pelican_object.settings.get(
"PELIMOJI_FILE_EXTENSIONS", ["md", "html", "rst"]
Expand Down Expand Up @@ -108,9 +118,7 @@ def replace(content):
content._content = pelimoji_prog.sub(pelimoji_replace, content._content)
except TypeError:
logger.warning(
"Something went wrong editing {} for pelimoji, sorry".format(
str(content)
)
f"Something went wrong editing {content!s} for pelimoji, sorry"
)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pelimoji"
version = "1.0.0"
version = "1.0.1"
description = "Pelican plugin to add custom emoji to your site"
authors = ["Kay Ohtie <[email protected]>"]
license = "AGPL-3.0"
Expand Down

0 comments on commit 29a73fc

Please sign in to comment.