Skip to content

Commit 2b72375

Browse files
authored
Fix #3750 — fix TypeError in nikola new_post --available-formats
1 parent c0362ef commit 2b72375

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Features
77
Bugfixes
88
--------
99

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

nikola/plugin_manager.py

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class PluginCandidate:
5959

6060
name: str
6161
description: Optional[str]
62+
friendly_name: str
6263
plugin_id: str
6364
category: str
6465
compiler: Optional[str]
@@ -72,6 +73,7 @@ class PluginInfo:
7273

7374
name: str
7475
description: Optional[str]
76+
friendly_name: str
7577
plugin_id: str
7678
category: str
7779
compiler: Optional[str]
@@ -129,6 +131,7 @@ def locate_plugins(self) -> List[PluginCandidate]:
129131
continue
130132
category = config["Nikola"].get("PluginCategory")
131133
compiler = config["Nikola"].get("Compiler")
134+
friendly_name = config["Nikola"].get("friendlyname") or name
132135
if not category:
133136
self.logger.warning(f"{plugin_id} does not specify any category (Nikola.PluginCategory is missing in .plugin file) - plugin will not be loaded")
134137
self.has_warnings = True
@@ -144,6 +147,7 @@ def locate_plugins(self) -> List[PluginCandidate]:
144147
PluginCandidate(
145148
name=name,
146149
description=description,
150+
friendly_name=friendly_name,
147151
plugin_id=plugin_id,
148152
category=category,
149153
compiler=compiler,
@@ -225,6 +229,7 @@ def load_plugins(self, candidates: List[PluginCandidate]) -> None:
225229
info = PluginInfo(
226230
name=name,
227231
description=candidate.description,
232+
friendly_name=candidate.friendly_name,
228233
plugin_id=candidate.plugin_id,
229234
category=candidate.category,
230235
compiler=candidate.compiler,

nikola/plugins/command/new_post.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -520,22 +520,18 @@ def print_compilers(self):
520520
False
521521
])
522522

523-
for name, (_, _, pi) in self.site.disabled_compilers.items():
524-
if pi.details.has_option('Nikola', 'Friendlyname'):
525-
f_name = pi.details.get('Nikola', 'Friendlyname')
526-
else:
527-
f_name = name
528-
if name in compilers_raw:
523+
for plugin in self.site.disabled_compilers.values():
524+
if plugin.name in compilers_raw:
529525
unused_compilers.append([
530-
name,
531-
f_name,
532-
compilers_raw[name],
526+
plugin.name,
527+
plugin.friendly_name,
528+
compilers_raw[plugin.name],
533529
False
534530
])
535531
else:
536532
disabled_compilers.append([
537-
name,
538-
f_name,
533+
plugin.name,
534+
plugin.friendly_name,
539535
(),
540536
False
541537
])

0 commit comments

Comments
 (0)