|
0 |
Description: Fix compatibility for sphinx 2.4+
|
|
1 |
Author: Michal Arbet
|
|
2 |
Forwarded: not-needed
|
|
3 |
Last-Update: 2020-04-24
|
|
4 |
|
|
5 |
diff --git a/oslosphinx/__init__.py b/oslosphinx/__init__.py
|
|
6 |
index 58692ab..0b6d7b1 100644
|
|
7 |
--- a/oslosphinx/__init__.py
|
|
8 |
+++ b/oslosphinx/__init__.py
|
|
9 |
@@ -18,6 +18,9 @@ import six
|
|
10 |
from six.moves.urllib import parse
|
|
11 |
import string
|
|
12 |
import subprocess
|
|
13 |
+from sphinx.util import logging
|
|
14 |
+
|
|
15 |
+LOG = logging.getLogger(__name__)
|
|
16 |
|
|
17 |
|
|
18 |
CGIT_BASE = 'http://git.openstack.org/cgit/'
|
|
19 |
@@ -57,8 +60,12 @@ def _get_other_versions(app):
|
|
20 |
git_cmd, stdout=subprocess.PIPE).communicate()[0]
|
|
21 |
raw_version_list = raw_version_list.decode("utf8")
|
|
22 |
except OSError:
|
|
23 |
- app.warn('Cannot get tags from git repository. '
|
|
24 |
- 'Not setting "other_versions".')
|
|
25 |
+ try:
|
|
26 |
+ app.warn('Cannot get tags from git repository. '
|
|
27 |
+ 'Not setting "other_versions".')
|
|
28 |
+ except AttributeError:
|
|
29 |
+ LOG.warning('Cannot get tags from git repository. '
|
|
30 |
+ 'Not setting "other_versions".')
|
|
31 |
raw_version_list = u''
|
|
32 |
|
|
33 |
# grab last five that start with a number and reverse the order
|
|
34 |
@@ -73,7 +80,10 @@ def _get_other_versions(app):
|
|
35 |
|
|
36 |
def builder_inited(app):
|
|
37 |
theme_dir = os.path.join(os.sep, 'usr', 'share', 'oslosphinx')
|
|
38 |
- app.info('Using openstack theme from %s' % theme_dir)
|
|
39 |
+ try:
|
|
40 |
+ app.info('Using openstack theme from %s' % theme_dir)
|
|
41 |
+ except AttributeError:
|
|
42 |
+ LOG.info('Using openstack theme from %s' % theme_dir)
|
|
43 |
# Insert our theme directory at the front of the search path and
|
|
44 |
# force the theme setting to use the one in the package unless
|
|
45 |
# another openstack theme is already selected. This is done here,
|
|
46 |
diff --git a/oslosphinx/check_blueprints.py b/oslosphinx/check_blueprints.py
|
|
47 |
index e241edc..930f6af 100644
|
|
48 |
--- a/oslosphinx/check_blueprints.py
|
|
49 |
+++ b/oslosphinx/check_blueprints.py
|
|
50 |
@@ -15,6 +15,9 @@
|
|
51 |
"""
|
|
52 |
|
|
53 |
import requests
|
|
54 |
+from sphinx.util import logging
|
|
55 |
+
|
|
56 |
+LOG = logging.getLogger(__name__)
|
|
57 |
|
|
58 |
|
|
59 |
class BlueprintChecker(object):
|
|
60 |
@@ -74,11 +77,17 @@ class BlueprintChecker(object):
|
|
61 |
|
|
62 |
def blueprint_exists(self, project_name, bp_name):
|
|
63 |
"""Return boolean indicating whether the blueprint exists."""
|
|
64 |
- self.app.info('Checking for %s in %s' % (bp_name, project_name))
|
|
65 |
+ try:
|
|
66 |
+ self.app.info('Checking for %s in %s' % (bp_name, project_name))
|
|
67 |
+ except AttributeError:
|
|
68 |
+ LOG.info('Checking for %s in %s' % (bp_name, project_name))
|
|
69 |
url = self.BP_URL_TEMPLATE % (project_name, bp_name)
|
|
70 |
response = requests.get(url)
|
|
71 |
if response.status_code == 200:
|
|
72 |
- self.app.info('Found %s in %s' % (bp_name, project_name))
|
|
73 |
+ try:
|
|
74 |
+ self.app.info('Found %s in %s' % (bp_name, project_name))
|
|
75 |
+ except AttributeError:
|
|
76 |
+ LOG.info('Found %s in %s' % (bp_name, project_name))
|
|
77 |
return True
|
|
78 |
return False
|
|
79 |
|
|
80 |
@@ -87,7 +96,10 @@ class BlueprintChecker(object):
|
|
81 |
if bp_name in self._good_bps:
|
|
82 |
return True
|
|
83 |
self._load_project_settings()
|
|
84 |
- self.app.info('') # emit newline
|
|
85 |
+ try:
|
|
86 |
+ self.app.info('') # emit newline
|
|
87 |
+ except AttributeError:
|
|
88 |
+ LOG.info('') # emit newline
|
|
89 |
candidate_project, dash, bp_name_to_find = bp_name.partition('-')
|
|
90 |
if candidate_project in self.project_names:
|
|
91 |
# First check the shortened name of the blueprint in the project.
|
|
92 |
@@ -96,33 +108,56 @@ class BlueprintChecker(object):
|
|
93 |
# Then check the full name of the blueprint in the project.
|
|
94 |
if self.blueprint_exists(candidate_project, bp_name):
|
|
95 |
return
|
|
96 |
- self.app.info(
|
|
97 |
- ('Blueprint name %r looks like it starts with a project '
|
|
98 |
- 'name, but %r was not found in project %r') %
|
|
99 |
- (bp_name, bp_name_to_find, candidate_project)
|
|
100 |
- )
|
|
101 |
+ try:
|
|
102 |
+ self.app.info(
|
|
103 |
+ ('Blueprint name %r looks like it starts with a project '
|
|
104 |
+ 'name, but %r was not found in project %r') %
|
|
105 |
+ (bp_name, bp_name_to_find, candidate_project)
|
|
106 |
+ )
|
|
107 |
+ except AttributeError:
|
|
108 |
+ LOG.info(
|
|
109 |
+ ('Blueprint name %r looks like it starts with a project '
|
|
110 |
+ 'name, but %r was not found in project %r') %
|
|
111 |
+ (bp_name, bp_name_to_find, candidate_project)
|
|
112 |
+ )
|
|
113 |
else:
|
|
114 |
- self.app.info(
|
|
115 |
- 'Blueprint checking is faster if the file names '
|
|
116 |
- 'start with the launchpad project name.'
|
|
117 |
- )
|
|
118 |
+ try:
|
|
119 |
+ self.app.info(
|
|
120 |
+ 'Blueprint checking is faster if the file names '
|
|
121 |
+ 'start with the launchpad project name.'
|
|
122 |
+ )
|
|
123 |
+ except AttributeError:
|
|
124 |
+ LOG.info(
|
|
125 |
+ 'Blueprint checking is faster if the file names '
|
|
126 |
+ 'start with the launchpad project name.'
|
|
127 |
+ )
|
|
128 |
for project_name in self.project_names:
|
|
129 |
if self.blueprint_exists(project_name, bp_name):
|
|
130 |
self._good_bps.add(bp_name)
|
|
131 |
break
|
|
132 |
else:
|
|
133 |
- self.app.warn(
|
|
134 |
- 'Could not find a blueprint called %r in %s'
|
|
135 |
- % (bp_name, self._warn_search),
|
|
136 |
- location=(bp_name, 0),
|
|
137 |
- )
|
|
138 |
+ try:
|
|
139 |
+ self.app.warn(
|
|
140 |
+ 'Could not find a blueprint called %r in %s'
|
|
141 |
+ % (bp_name, self._warn_search),
|
|
142 |
+ location=(bp_name, 0),
|
|
143 |
+ )
|
|
144 |
+ except AttributeError:
|
|
145 |
+ LOG.warning(
|
|
146 |
+ 'Could not find a blueprint called %r in %s'
|
|
147 |
+ % (bp_name, self._warn_search),
|
|
148 |
+ location=(bp_name, 0),
|
|
149 |
+ )
|
|
150 |
raise ValueError(
|
|
151 |
'Document %s does not match any blueprint name in %s'
|
|
152 |
% (bp_name, self._warn_search))
|
|
153 |
|
|
154 |
|
|
155 |
def setup(app):
|
|
156 |
- app.info('Initializing %s' % __name__)
|
|
157 |
+ try:
|
|
158 |
+ app.info('Initializing %s' % __name__)
|
|
159 |
+ except AttributeError:
|
|
160 |
+ LOG.info('Initializing %s' % __name__)
|
|
161 |
checker = BlueprintChecker(app)
|
|
162 |
app.connect('doctree-resolved', checker.doctree_resolved)
|
|
163 |
app.add_config_value('check_blueprints_project_group', 'openstack', 'env')
|