Skip to content

Commit

Permalink
Fix #3750 — fix TypeError in nikola new_post --available-formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska committed Jan 25, 2024
1 parent c0362ef commit 20c6156
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Features
Bugfixes
--------

* Fix ``nikola new_post --available-formats`` crashing with TypeError
(Issue #3750)
* Fix the new plugin manager not loading plugins if the plugin folder is a symlink (Issue #3741)
* Fix the ``nikola plugin`` command not working (Issue #3736)

Expand Down
5 changes: 5 additions & 0 deletions nikola/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class PluginCandidate:

name: str
description: Optional[str]
friendly_name: str
plugin_id: str
category: str
compiler: Optional[str]
Expand All @@ -72,6 +73,7 @@ class PluginInfo:

name: str
description: Optional[str]
friendly_name: str
plugin_id: str
category: str
compiler: Optional[str]
Expand Down Expand Up @@ -129,6 +131,7 @@ def locate_plugins(self) -> List[PluginCandidate]:
continue
category = config["Nikola"].get("PluginCategory")
compiler = config["Nikola"].get("Compiler")
friendly_name = config["Nikola"].get("friendlyname") or name
if not category:
self.logger.warning(f"{plugin_id} does not specify any category (Nikola.PluginCategory is missing in .plugin file) - plugin will not be loaded")
self.has_warnings = True
Expand All @@ -144,6 +147,7 @@ def locate_plugins(self) -> List[PluginCandidate]:
PluginCandidate(
name=name,
description=description,
friendly_name=friendly_name,
plugin_id=plugin_id,
category=category,
compiler=compiler,
Expand Down Expand Up @@ -225,6 +229,7 @@ def load_plugins(self, candidates: List[PluginCandidate]) -> None:
info = PluginInfo(
name=name,
description=candidate.description,
friendly_name=candidate.friendly_name,
plugin_id=candidate.plugin_id,
category=candidate.category,
compiler=candidate.compiler,
Expand Down
18 changes: 7 additions & 11 deletions nikola/plugins/command/new_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,22 +520,18 @@ def print_compilers(self):
False
])

for name, (_, _, pi) in self.site.disabled_compilers.items():
if pi.details.has_option('Nikola', 'Friendlyname'):
f_name = pi.details.get('Nikola', 'Friendlyname')
else:
f_name = name
if name in compilers_raw:
for plugin in self.site.disabled_compilers.values():
if plugin.name in compilers_raw:
unused_compilers.append([
name,
f_name,
compilers_raw[name],
plugin.name,
plugin.friendly_name,
compilers_raw[plugin.name],
False
])
else:
disabled_compilers.append([
name,
f_name,
plugin.name,
plugin.friendly_name,
(),
False
])
Expand Down

0 comments on commit 20c6156

Please sign in to comment.