Line 0
Link Here
|
|
|
1 |
https://bugs.gentoo.org/840305 |
2 |
Patch from upstream: |
3 |
|
4 |
commit a4c67b38c0faef6e04a3f2dcd1a26e592ae8f27c |
5 |
Author: Chris Warrick <kwpolska@gmail.com> |
6 |
Date: Fri Apr 22 20:36:26 2022 +0200 |
7 |
|
8 |
Fix #3612 — doit 0.36.0 compatibility |
9 |
|
10 |
--- a/nikola/__main__.py |
11 |
+++ b/nikola/__main__.py |
12 |
@@ -36,8 +36,7 @@ |
13 |
from collections import defaultdict |
14 |
|
15 |
from blinker import signal |
16 |
-from doit.cmd_auto import Auto as DoitAuto |
17 |
-from doit.cmd_base import TaskLoader, _wrap |
18 |
+from doit.cmd_base import TaskLoader2, _wrap |
19 |
from doit.cmd_clean import Clean as DoitClean |
20 |
from doit.cmd_completion import TabCompletion |
21 |
from doit.cmd_help import Help as DoitHelp |
22 |
@@ -247,31 +246,41 @@ def clean_tasks(self, tasks, dryrun, *a): |
23 |
|
24 |
# Nikola has its own "auto" commands that uses livereload. |
25 |
# Expose original doit "auto" command as "doit_auto". |
26 |
-DoitAuto.name = 'doit_auto' |
27 |
+# doit_auto is not available with doit>=0.36.0. |
28 |
+try: |
29 |
+ from doit.cmd_auto import Auto as DoitAuto |
30 |
+ DoitAuto.name = 'doit_auto' |
31 |
+except ImportError: |
32 |
+ DoitAuto = None |
33 |
|
34 |
|
35 |
-class NikolaTaskLoader(TaskLoader): |
36 |
+class NikolaTaskLoader(TaskLoader2): |
37 |
"""Nikola-specific task loader.""" |
38 |
|
39 |
def __init__(self, nikola, quiet=False): |
40 |
"""Initialize the loader.""" |
41 |
+ super().__init__() |
42 |
self.nikola = nikola |
43 |
self.quiet = quiet |
44 |
|
45 |
- def load_tasks(self, cmd, opt_values, pos_args): |
46 |
- """Load Nikola tasks.""" |
47 |
+ def load_doit_config(self): |
48 |
+ """Load doit configuration.""" |
49 |
if self.quiet: |
50 |
- DOIT_CONFIG = { |
51 |
+ doit_config = { |
52 |
'verbosity': 0, |
53 |
'reporter': 'zero', |
54 |
} |
55 |
else: |
56 |
- DOIT_CONFIG = { |
57 |
+ doit_config = { |
58 |
'reporter': ExecutedOnlyReporter, |
59 |
'outfile': sys.stderr, |
60 |
} |
61 |
- DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render'] |
62 |
- DOIT_CONFIG.update(self.nikola._doit_config) |
63 |
+ doit_config['default_tasks'] = ['render_site', 'post_render'] |
64 |
+ doit_config.update(self.nikola._doit_config) |
65 |
+ return doit_config |
66 |
+ |
67 |
+ def load_tasks(self, cmd, pos_args): |
68 |
+ """Load Nikola tasks.""" |
69 |
try: |
70 |
tasks = generate_tasks( |
71 |
'render_site', |
72 |
@@ -286,15 +295,17 @@ def load_tasks(self, cmd, opt_values, pos_args): |
73 |
raise |
74 |
_print_exception() |
75 |
sys.exit(3) |
76 |
- return tasks + latetasks, DOIT_CONFIG |
77 |
+ return tasks + latetasks |
78 |
|
79 |
|
80 |
class DoitNikola(DoitMain): |
81 |
"""Nikola-specific implementation of DoitMain.""" |
82 |
|
83 |
# overwite help command |
84 |
- DOIT_CMDS = list(DoitMain.DOIT_CMDS) + [Help, Build, Clean, DoitAuto] |
85 |
+ DOIT_CMDS = list(DoitMain.DOIT_CMDS) + [Help, Build, Clean] |
86 |
TASK_LOADER = NikolaTaskLoader |
87 |
+ if DoitAuto is not None: |
88 |
+ DOIT_CMDS.append(DoitAuto) |
89 |
|
90 |
def __init__(self, nikola, quiet=False): |
91 |
"""Initialzie DoitNikola.""" |