Merge "Adds niceness check to avoid unwanted unicode charaters"
This commit is contained in:
commit
6e7c0ab6c4
@ -1,6 +1,12 @@
|
|||||||
Release notes
|
Release notes
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
0.22
|
||||||
|
----
|
||||||
|
|
||||||
|
* ``openstack-doc-test``: New niceness check to avoid specific unicode
|
||||||
|
characters.
|
||||||
|
|
||||||
0.21.1
|
0.21.1
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf8 -*-
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
@ -208,6 +209,23 @@ def verify_newline_end_of_file(docfile):
|
|||||||
raise ValueError('last line of a file must end with a \\n')
|
raise ValueError('last line of a file must end with a \\n')
|
||||||
|
|
||||||
|
|
||||||
|
def verify_unicode_niceness(docfile):
|
||||||
|
"""Check that no unwanted unicode charaters are used."""
|
||||||
|
|
||||||
|
invalid_characters = '“”‘’―—'
|
||||||
|
|
||||||
|
affected_lines = []
|
||||||
|
lc = 0
|
||||||
|
for line in open(docfile, 'r'):
|
||||||
|
lc += 1
|
||||||
|
any(c in line for c in invalid_characters)
|
||||||
|
|
||||||
|
if len(affected_lines):
|
||||||
|
raise ValueError("unwanted unicode charaters (one of %s) "
|
||||||
|
"found in line(s): %" % (" ".join(invalid_characters),
|
||||||
|
", ".join(affected_lines)))
|
||||||
|
|
||||||
|
|
||||||
def verify_whitespace_niceness(docfile):
|
def verify_whitespace_niceness(docfile):
|
||||||
"""Check that no unnecessary whitespaces are used."""
|
"""Check that no unnecessary whitespaces are used."""
|
||||||
checks = [
|
checks = [
|
||||||
@ -530,6 +548,7 @@ def validate_one_json_file(rootdir, path, verbose, check_syntax,
|
|||||||
if check_niceness:
|
if check_niceness:
|
||||||
verify_whitespace_niceness(path)
|
verify_whitespace_niceness(path)
|
||||||
verify_newline_end_of_file(path)
|
verify_newline_end_of_file(path)
|
||||||
|
verify_unicode_niceness(path)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
any_failures = True
|
any_failures = True
|
||||||
print(" %s: %s" % (os.path.relpath(path, rootdir), e))
|
print(" %s: %s" % (os.path.relpath(path, rootdir), e))
|
||||||
@ -561,6 +580,7 @@ def validate_one_file(schema, rootdir, path, verbose,
|
|||||||
if check_niceness:
|
if check_niceness:
|
||||||
verify_whitespace_niceness(path)
|
verify_whitespace_niceness(path)
|
||||||
verify_newline_end_of_file(path)
|
verify_newline_end_of_file(path)
|
||||||
|
verify_unicode_niceness(path)
|
||||||
except etree.XMLSyntaxError as e:
|
except etree.XMLSyntaxError as e:
|
||||||
any_failures = True
|
any_failures = True
|
||||||
print(" %s: %s" % (os.path.relpath(path, rootdir), e))
|
print(" %s: %s" % (os.path.relpath(path, rootdir), e))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user