Browse Source

Require hacking for additional checks

Require hacking for additional pep8 checks to follow
OpenStack python hacking conventions.

Fix problems found by hacking.

Disable autogenerate-config-docs from check, it needs further
work to be clean enough.

Change-Id: Ib1dedf2e8262ba3d8ae1b58c4e4dbab82bbb5297
Andreas Jaeger 8 years ago
6 changed files with 34 additions and 25 deletions
  1. +1
  2. +3
  3. +1
  4. +26
  5. +1
  6. +2

+ 1
- 1
autogenerate-config-docs/ View File

@ -17,13 +17,13 @@
# For an example of usage, run this program with the -h switch.
import common
import sys
# this is for the internationalisation function in gettext
import __builtin__
__builtin__.__dict__['_'] = lambda x: x
import common
def main(action, file, format, repo, verbose=0, name=False, test=False):

+ 3
- 2
autogenerate-config-docs/ View File

@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from os import path
import glob
import os
import sys
from xml.dom import minidom
from xml.sax.saxutils import escape

+ 1
- 1
cleanup/ View File

@ -20,8 +20,8 @@
import os
import re
import tempfile
import shutil
import tempfile
# should be the same like in tools/
FILE_EXCEPTIONS = ['ha-guide-docinfo.xml',

+ 26
- 20
os_doc_tools/ View File

@ -31,9 +31,6 @@ Requires:
- Maven
import os_doc_tools
from lxml import etree
import argparse
import multiprocessing
@ -44,6 +41,11 @@ import subprocess
import sys
import urllib2
from lxml import etree
import os_doc_tools
# These are files that are known to not be in DocBook format
FILE_EXCEPTIONS = ['st-training-guides.xml',
@ -93,7 +95,7 @@ def check_output(*popenargs, **kwargs):
def get_schema(is_api_site=False):
"""Return the DocBook RELAX NG schema"""
"""Return the DocBook RELAX NG schema."""
if is_api_site:
url = ""
@ -103,7 +105,7 @@ def get_schema(is_api_site=False):
def get_wadl_schema():
"""Return the Wadl schema"""
"""Return the Wadl schema."""
url = ""
xmlschema_doc = etree.parse(urllib2.urlopen(url))
return etree.XMLSchema(xmlschema_doc)
@ -115,7 +117,8 @@ def validation_failed(schema, doc):
This will ignore validation failures of the type: IDREF attribute linkend
references an unknown ID. This is because we are validating individual
files that are being imported, and sometimes the reference isn't present
in the current file."""
in the current file.
return not schema.validate(doc) and \
any(log.type_name != "DTD_UNKNOWN_ID" for log in schema.error_log)
@ -123,7 +126,8 @@ def validation_failed(schema, doc):
def verify_section_tags_have_xmid(doc):
"""Check that all section tags have an xml:id attribute
Will throw an exception if there's at least one missing"""
Will throw an exception if there's at least one missing.
ns = {"docbook": ""}
for node in doc.xpath('//docbook:section', namespaces=ns):
if "{}id" not in node.attrib:
@ -169,13 +173,13 @@ def verify_attribute_profiling(doc, attribute, known_values):
def verify_profiling(doc):
""""Check profiling information"""
""""Check profiling information."""
verify_attribute_profiling(doc, "os", KNOWN_OS_VALUES)
verify_attribute_profiling(doc, "audience", KNOWN_AUDIENCE_VALUES)
def verify_nice_usage_of_whitespaces(docfile):
"""Check that no unnecessary whitespaces are used"""
"""Check that no unnecessary whitespaces are used."""
checks = [
@ -227,7 +231,7 @@ def error_message(error_log):
def only_www_touched():
"""Check whether only files in www directory are touched"""
"""Check whether only files in www directory are touched."""
git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"]
@ -248,7 +252,7 @@ def only_www_touched():
def ha_guide_touched():
"""Check whether files in high-availability-guide directory are touched"""
"""Check whether files in high-availability-guide directory are touched."""
git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"]
@ -295,7 +299,7 @@ def check_modified_affects_all(rootdir, verbose):
def get_modified_files(rootdir, filtering=None):
"""Get modified files below doc directory"""
"""Get modified files below doc directory."""
# There are several tree traversals in this program that do a
# chdir, we need to run this git command always from the rootdir,
@ -315,10 +319,10 @@ def get_modified_files(rootdir, filtering=None):
def check_deleted_files(rootdir, file_exceptions, verbose):
""" Check whether files got deleted and verify that no other file
"""Check whether files got deleted and verify that no other file
references them.
print("Checking that no removed files are referenced...")
deleted_files = get_modified_files(rootdir, "--diff-filter=D")
if not deleted_files:
@ -387,7 +391,7 @@ def check_deleted_files(rootdir, file_exceptions, verbose):
def validate_one_file(schema, rootdir, path, verbose,
check_syntax, check_niceness):
"""Validate a single file"""
"""Validate a single file."""
# We pass schema in as a way of caching it, generating it is expensive
any_failures = False
@ -414,7 +418,7 @@ def validate_one_file(schema, rootdir, path, verbose,
def is_xml(filename):
"""Returns true if file ends with .xml and is not a pom.xml file"""
"""Returns true if file ends with .xml and is not a pom.xml file."""
return filename.endswith('.xml') and not filename.endswith('/pom.xml')
@ -430,7 +434,7 @@ def is_xml_wadl(filename):
def is_wadl(filename):
"""Returns true if file ends with .wadl"""
"""Returns true if file ends with .wadl."""
return filename.endswith('.wadl')
@ -543,12 +547,12 @@ def validate_all_files(rootdir, exceptions, verbose,
def logging_build_book(result):
"""Callback for book building"""
"""Callback for book building."""
def build_book(book):
"""Build book(s) in directory book"""
"""Build book(s) in directory book."""
# Note that we cannot build in parallel several books in the same
# directory like the Install Guide. Thus we build sequentially per
@ -916,7 +920,9 @@ def default_root():
"""Return the location of openstack-manuals
The current working directory must be inside of the openstack-manuals
repository for this method to succeed"""
repository for this method to succeed
git_args = ["git", "rev-parse", "--show-toplevel"]
gitroot = check_output(git_args).rstrip()

+ 1
- 0
test-requirements.txt View File

@ -1,3 +1,4 @@

+ 2
- 1
tox.ini View File

@ -27,8 +27,9 @@ commands = python testr --coverage --testr-args='{posargs}'
# H803 skipped on purpose per list discussion.
# E123, E125 skipped as they are invalid PEP-8.
# autogenerate-config-tools skipped until it passes all tests
show-source = True
ignore = E123,E125,H803
builtins = _