Browse Source

Bump hacking to 0.9.x series

Require at least 0.9.1 because 0.9.0. had a minor bug.

This change also fixes all found issues.

Rewrote some docstrings to fit H405.

Change-Id: Ifeef11b783dbe70b2652d2b9ea29d5b20f69f2ce
tags/0.16
Christian Berendt 5 years ago
parent
commit
d449a6bcd2

+ 2
- 3
autogenerate_config_docs/autohelp.py View File

@@ -26,13 +26,12 @@ import os
26 26
 import pickle
27 27
 import re
28 28
 import sys
29
-
30
-import git
31
-import stevedore
32 29
 import xml.sax.saxutils
33 30
 
31
+import git
34 32
 from hooks import HOOKS
35 33
 import openstack.common.config.generator as generator
34
+import stevedore
36 35
 
37 36
 
38 37
 TABLE_HEADER = '''<?xml version="1.0" encoding="UTF-8"?>

+ 3
- 9
autogenerate_config_docs/diff_branches.py View File

@@ -31,9 +31,7 @@ PROJECTS = ['ceilometer', 'cinder', 'glance', 'heat', 'keystone', 'neutron',
31 31
 
32 32
 
33 33
 def setup_venv(branch, novenvupdate):
34
-    """Uses the autohelp-wrapper script to generate a virtualenv for a given
35
-    branch.
36
-    """
34
+    """Setup a virtual environment for `branch`."""
37 35
     dirname = os.path.join('venv', branch.replace('/', '_'))
38 36
     if novenvupdate and os.path.exists(dirname):
39 37
         return
@@ -46,9 +44,7 @@ def setup_venv(branch, novenvupdate):
46 44
 
47 45
 
48 46
 def get_options(project, branch, args):
49
-    """Calls the autohelp script in a venv to get the list of known
50
-    options.
51
-    """
47
+    """Get the list of known options for a project."""
52 48
     print("Working on %(project)s (%(branch)s)" % {'project': project,
53 49
                                                    'branch': branch})
54 50
     # Checkout the required branch
@@ -136,9 +132,7 @@ def dbk_append_header(parent, cells):
136 132
 
137 133
 
138 134
 def diff(old_list, new_list):
139
-    """Compare the old and new lists of options to generate lists of modified
140
-    options.
141
-    """
135
+    """Compare the old and new lists of options."""
142 136
     new_opts = []
143 137
     changed_default = []
144 138
     deprecated_opts = []

+ 27
- 26
autogenerate_config_docs/extract_swift_flags.py View File

@@ -15,7 +15,6 @@
15 15
 import glob
16 16
 import os
17 17
 import sys
18
-
19 18
 from xml.dom import minidom
20 19
 import xml.sax.saxutils
21 20
 
@@ -118,25 +117,27 @@ def new_section_file(sample, current_section):
118 117
                         replace(']', '').replace(':', '-')
119 118
                         + '.xml')
120 119
     section_file = open(section_filename, 'w')
121
-    section_file.write('<?xml version="1.0" encoding="UTF-8"?>\n\
122
-    <!-- The tool that generated this table lives in the\n\
123
-         openstack-doc-tools repository. The editions made in\n\
124
-         this file will *not* be lost if you run the script again. -->\n\
125
-    <para xmlns="http://docbook.org/ns/docbook" version="5.0">\n\
126
-    <table rules="all">\n\
127
-    <caption>Description of configuration options for <literal>'
128
-                       + current_section + '</literal> in <literal>'
129
-                       + os.path.basename(sample) +
130
-                       '</literal></caption>\n\
131
-    <col width="50%"/>\n\
132
-    <col width="50%"/>\n\
133
-    <thead>\n\
134
-        <tr>\n\
135
-            <th>Configuration option = Default value</th>\n\
136
-            <th>Description</th>\n\
137
-        </tr>\n\
138
-    </thead>\n\
139
-    <tbody>')
120
+    section_file.write(
121
+        ('<?xml version="1.0" encoding="UTF-8"?>\n'
122
+         '    <!-- The tool that generated this table lives in the\n'
123
+         '         openstack-doc-tools repository. The editions made in\n'
124
+         '         this file will *not* be lost if you run the script '
125
+         'again. -->\n'
126
+         '    <para xmlns="http://docbook.org/ns/docbook" version="5.0">\n'
127
+         '    <table rules="all">\n'
128
+         '    <caption>Description of configuration options for <literal>'
129
+         + current_section + '</literal> in <literal>'
130
+         + os.path.basename(sample) +
131
+         '</literal></caption>\n'
132
+         '    <col width="50%"/>\n'
133
+         '    <col width="50%"/>\n'
134
+         '    <thead>\n'
135
+         '        <tr>\n'
136
+         '            <th>Configuration option = Default value</th>\n'
137
+         '            <th>Description</th>\n'
138
+         '        </tr>\n'
139
+         '    </thead>\n'
140
+         '    <tbody>'))
140 141
     return section_file
141 142
 
142 143
 
@@ -167,9 +168,9 @@ def create_new_tables(repo, verbose):
167 168
                 """
168 169
                 if current_section != line.strip('#').strip():
169 170
                     if section_file is not None:
170
-                        section_file.write('\n    </tbody>\n\
171
-    </table>\n\
172
-    </para>')
171
+                        section_file.write(('\n    </tbody>\n'
172
+                                            '    </table>\n'
173
+                                            '    </para>'))
173 174
                         section_file.close()
174 175
                     current_section = line.strip('#').strip()
175 176
                     section_file = new_section_file(sample, current_section)
@@ -201,9 +202,9 @@ def create_new_tables(repo, verbose):
201 202
                                        '</td><td>' + option_desc + '</td>\n' +
202 203
                                        '        </tr>')
203 204
         if section_file is not None:
204
-            section_file.write('\n    </tbody>\n\
205
-    </table>\n\
206
-    </para>')
205
+            section_file.write(('\n    </tbody>\n'
206
+                                '    </table>\n'
207
+                                '</para>'))
207 208
             section_file.close()
208 209
 
209 210
 

+ 4
- 4
autogenerate_config_docs/test/generator.py View File

@@ -170,17 +170,17 @@ def _list_opts(obj):
170 170
 
171 171
 def print_group_opts(group, opts_by_module):
172 172
     print("[%s]" % group)
173
-    print
173
+    print('')
174 174
     global OPTION_COUNT
175 175
     for mod, opts in opts_by_module:
176 176
         OPTION_COUNT += len(opts)
177 177
         print('#')
178 178
         print('# Options defined in %s' % mod)
179 179
         print('#')
180
-        print
180
+        print('')
181 181
         for opt in opts:
182 182
             _print_opt(opt)
183
-        print
183
+        print('')
184 184
 
185 185
 
186 186
 def _get_my_ip():
@@ -246,7 +246,7 @@ def _print_opt(opt):
246 246
                 opt_default = ['']
247 247
             for default in opt_default:
248 248
                 print('#%s=%s' % (opt_name, default))
249
-        print
249
+        print('')
250 250
     except Exception:
251 251
         sys.stderr.write('Error in option "%s"\n' % opt_name)
252 252
         sys.exit(1)

+ 4
- 1
cleanup/retf/retf.py View File

@@ -36,8 +36,11 @@ import yaml
36 36
 
37 37
 
38 38
 class DownloadRetfListingFailed(Exception):
39
-    """Exception will be raised when the download of the RETF
39
+    """Exception for failed downloads of the RETF listing.
40
+
41
+    Exception will be raised when the download of the RETF
40 42
     listing failed or the destination file could not be written.
43
+
41 44
     """
42 45
 
43 46
     pass

+ 21
- 20
os_doc_tools/doctest.py View File

@@ -13,7 +13,6 @@
13 13
 # under the License.
14 14
 
15 15
 '''
16
-
17 16
 Usage:
18 17
     test.py [path]
19 18
 
@@ -29,7 +28,6 @@ Requires:
29 28
     - Python 2.7 or greater
30 29
     - lxml Python library
31 30
     - Maven
32
-
33 31
 '''
34 32
 
35 33
 import gzip
@@ -43,10 +41,10 @@ import subprocess
43 41
 import sys
44 42
 
45 43
 from lxml import etree
44
+from oslo.config import cfg
46 45
 
47 46
 import os_doc_tools
48 47
 from os_doc_tools.common import check_output   # noqa
49
-from oslo.config import cfg
50 48
 
51 49
 
52 50
 # These are files that are known to not pass syntax or niceness checks
@@ -120,19 +118,19 @@ def get_wadl_schema():
120 118
 
121 119
 
122 120
 def validation_failed(schema, doc):
123
-    """Return True if the parsed doc fails against the schema
121
+    """Return True if the parsed doc fails against the schema.
124 122
 
125 123
     This will ignore validation failures of the type: IDREF attribute linkend
126 124
     references an unknown ID. This is because we are validating individual
127 125
     files that are being imported, and sometimes the reference isn't present
128 126
     in the current file.
129 127
     """
130
-    return not schema.validate(doc) and \
131
-        any(log.type_name != "DTD_UNKNOWN_ID" for log in schema.error_log)
128
+    return (not schema.validate(doc) and
129
+            any(log.type_name != "DTD_UNKNOWN_ID" for log in schema.error_log))
132 130
 
133 131
 
134 132
 def verify_section_tags_have_xmid(doc):
135
-    """Check that all section tags have an xml:id attribute
133
+    """Check that all section tags have an xml:id attribute.
136 134
 
137 135
     Will throw an exception if there's at least one missing.
138 136
     """
@@ -144,11 +142,13 @@ def verify_section_tags_have_xmid(doc):
144 142
 
145 143
 
146 144
 def verify_attribute_profiling(doc, attribute, known_values):
147
-    """Check for elements with attribute profiling set that conflicts with
148
-       the attribute profiling of nodes below them in the DOM
149
-       tree. This picks up cases where content is accidentally
150
-       omitted via conflicting profiling. Checks known_values also for
151
-       supported profiling values.
145
+    """Check for conflicts in attribute profiling.
146
+
147
+    Check for elements with attribute profiling set that conflicts with
148
+    the attribute profiling of nodes below them in the DOM
149
+    tree. This picks up cases where content is accidentally
150
+    omitted via conflicting profiling. Checks known_values also for
151
+    supported profiling values.
152 152
     """
153 153
 
154 154
     ns = {"docbook": "http://docbook.org/ns/docbook"}
@@ -234,8 +234,8 @@ def verify_whitespace_niceness(docfile):
234 234
     if affected_lines:
235 235
         if (msg):
236 236
             msg += "\n    "
237
-        msg += "trailing or unnecessary whitespaces found in lines: %s"\
238
-               % (", ".join(affected_lines))
237
+        msg += ("trailing or unnecessary whitespaces found in lines: %s"
238
+                % (", ".join(affected_lines)))
239 239
     if tab_lines:
240 240
         if (msg):
241 241
             msg += "\n    "
@@ -349,9 +349,7 @@ def filter_dirs(dirs):
349 349
 
350 350
 
351 351
 def check_deleted_files(rootdir, file_exceptions, verbose):
352
-    """Check whether files got deleted and verify that no other file
353
-    references them.
354
-    """
352
+    """Checking that no removed files are referenced."""
355 353
 
356 354
     print("Checking that no removed files are referenced...")
357 355
     deleted_files = get_modified_files(rootdir, "--diff-filter=D")
@@ -480,7 +478,7 @@ def is_testable_xml_file(path, exceptions):
480 478
 
481 479
     filename = os.path.basename(path)
482 480
     return (filename.endswith('.xml') and not filename == 'pom.xml' and
483
-            not filename in exceptions)
481
+            filename not in exceptions)
484 482
 
485 483
 
486 484
 def is_testable_file(path, exceptions):
@@ -492,7 +490,7 @@ def is_testable_file(path, exceptions):
492 490
     filename = os.path.basename(path)
493 491
     return (filename.endswith(('.xml', '.xsd', '.xsl', '.wadl',
494 492
                                '.xjb', '.json')) and
495
-            not filename == 'pom.xml' and not filename in exceptions)
493
+            not filename == 'pom.xml' and filename not in exceptions)
496 494
 
497 495
 
498 496
 def is_wadl(filename):
@@ -848,11 +846,14 @@ def build_book(book, publish_path, log_path):
848 846
 
849 847
 
850 848
 def is_book_master(filename):
851
-    """Returns True if filename is one of the special filenames used for the
849
+    """Check if a file is a book master file.
850
+
851
+    Returns True if filename is one of the special filenames used for the
852 852
     book master files.
853 853
 
854 854
     We do not parse pom.xml for the includes directive to determine
855 855
     the top-level files and thus have to use a heuristic.
856
+
856 857
     """
857 858
 
858 859
     return ((filename.startswith(('bk-', 'bk_', 'st-', 'api-'))

+ 3
- 2
sitemap/generator/pipelines.py View File

@@ -49,8 +49,9 @@ class IgnoreDuplicateUrls(object):
49 49
 
50 50
 
51 51
 class ExportSitemap(object):
52
-    '''Write found URLs to a sitemap file, based on
53
-    http://doc.scrapy.org/en/latest/topics/exporters.html.
52
+    '''Write found URLs to a sitemap file.
53
+
54
+    Based on http://doc.scrapy.org/en/latest/topics/exporters.html.
54 55
     '''
55 56
 
56 57
     def __init__(self):

+ 1
- 2
sitemap/generator/spiders/sitemap.py View File

@@ -14,11 +14,10 @@ import posixpath
14 14
 import time
15 15
 import urlparse
16 16
 
17
+from generator import items
17 18
 from scrapy.contrib.linkextractors import sgml
18 19
 from scrapy.contrib import spiders
19 20
 
20
-from generator import items
21
-
22 21
 
23 22
 class SitemapSpider(spiders.CrawlSpider):
24 23
     name = 'sitemap'

+ 1
- 1
test-requirements.txt View File

@@ -1,4 +1,4 @@
1 1
 # Hacking already pins down pep8, pyflakes and flake8
2
-hacking>=0.8.0,<0.9
2
+hacking>=0.9.1,<0.10
3 3
 pylint==0.25.2
4 4
 sphinx>=1.2.1,<1.3

Loading…
Cancel
Save