Merge "Fix issues found by flake8"
This commit is contained in:
commit
64f2f860c8
|
@ -6,7 +6,6 @@
|
||||||
# For an example of usage, run this program with the -h switch.
|
# For an example of usage, run this program with the -h switch.
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# this is for the internationalisation function in gettext
|
# this is for the internationalisation function in gettext
|
||||||
|
|
|
@ -7,7 +7,6 @@ from oslo.config import cfg
|
||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
import pkgutil
|
|
||||||
import glob
|
import glob
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
|
@ -64,15 +63,20 @@ def extract_flags(repo_location, module_name, verbose=0, names_only=True):
|
||||||
for root, dirs, files in os.walk(module_location + '/' + module_name):
|
for root, dirs, files in os.walk(module_location + '/' + module_name):
|
||||||
for name in dirs:
|
for name in dirs:
|
||||||
abs_path = os.path.join(root.split(module_location)[1][1:], name)
|
abs_path = os.path.join(root.split(module_location)[1][1:], name)
|
||||||
if ('/tests' not in abs_path and '/locale' not in abs_path and
|
if ('/tests' not in abs_path and
|
||||||
'/cmd' not in abs_path and '/db/migration' not in abs_path and
|
'/locale' not in abs_path and
|
||||||
|
'/cmd' not in abs_path and
|
||||||
|
'/db/migration' not in abs_path and
|
||||||
'/transfer' not in abs_path):
|
'/transfer' not in abs_path):
|
||||||
usable_dirs.append(os.path.join(root.split(module_location)[1][1:], name))
|
usable_dirs.append(os.path.join(root.split(module_location)
|
||||||
|
[1][1:], name))
|
||||||
|
|
||||||
for directory in usable_dirs:
|
for directory in usable_dirs:
|
||||||
for python_file in glob.glob(module_location + '/' + directory + "/*.py"):
|
for python_file in glob.glob(module_location + '/' + directory
|
||||||
|
+ "/*.py"):
|
||||||
if '__init__' not in python_file:
|
if '__init__' not in python_file:
|
||||||
usable_dirs.append(os.path.splitext(python_file)[0][len(module_location) + 1:])
|
usable_dirs.append(os.path.splitext(python_file)
|
||||||
|
[0][len(module_location) + 1:])
|
||||||
|
|
||||||
package_name = directory.replace('/', '.')
|
package_name = directory.replace('/', '.')
|
||||||
try:
|
try:
|
||||||
|
@ -112,20 +116,24 @@ def extract_flags_test(repo_loc, module, verbose=0):
|
||||||
TEST TEST TEST TEST TEST TEST
|
TEST TEST TEST TEST TEST TEST
|
||||||
"""
|
"""
|
||||||
flag_data = {}
|
flag_data = {}
|
||||||
flag_files = []
|
|
||||||
usable_dirs = []
|
usable_dirs = []
|
||||||
module_location = os.path.dirname(repo_loc + '/' + module)
|
module_location = os.path.dirname(repo_loc + '/' + module)
|
||||||
for root, dirs, files in os.walk(module_location + '/' + module):
|
for root, dirs, files in os.walk(module_location + '/' + module):
|
||||||
for name in dirs:
|
for name in dirs:
|
||||||
abs_path = os.path.join(root.split(module_location)[1][1:], name)
|
abs_path = os.path.join(root.split(module_location)[1][1:], name)
|
||||||
if ('/tests' not in abs_path and '/locale' not in abs_path and
|
if ('/tests' not in abs_path and
|
||||||
'/cmd' not in abs_path and '/db/migration' not in abs_path):
|
'/locale' not in abs_path and
|
||||||
usable_dirs.append(os.path.join(root.split(module_location)[1][1:], name))
|
'/cmd' not in abs_path and
|
||||||
|
'/db/migration' not in abs_path):
|
||||||
|
usable_dirs.append(os.path.join(root.split(module_location)
|
||||||
|
[1][1:], name))
|
||||||
|
|
||||||
for directory in usable_dirs:
|
for directory in usable_dirs:
|
||||||
for python_file in glob.glob(module_location + '/' + directory + "/*.py"):
|
for python_file in glob.glob(module_location + '/' + directory +
|
||||||
|
"/*.py"):
|
||||||
if '__init__' not in python_file:
|
if '__init__' not in python_file:
|
||||||
usable_dirs.append(os.path.splitext(python_file)[0][len(module_location) + 1:])
|
usable_dirs.append(os.path.splitext(python_file)[0]
|
||||||
|
[len(module_location) + 1:])
|
||||||
|
|
||||||
package_name = directory.replace('/', '.')
|
package_name = directory.replace('/', '.')
|
||||||
try:
|
try:
|
||||||
|
@ -165,7 +173,7 @@ def write_test(file, repo_dir, pkg_name):
|
||||||
print "\n -- end file name area --\n"
|
print "\n -- end file name area --\n"
|
||||||
print len(flag_info)
|
print len(flag_info)
|
||||||
for name, value in flag_info:
|
for name, value in flag_info:
|
||||||
opt = value['opt']
|
#opt = value['opt']
|
||||||
#print type(opt)
|
#print type(opt)
|
||||||
#print opt
|
#print opt
|
||||||
#print name
|
#print name
|
||||||
|
@ -183,7 +191,9 @@ def write_header(filepath, verbose=0):
|
||||||
|
|
||||||
def write_buffer(file, flags, verbose=0):
|
def write_buffer(file, flags, verbose=0):
|
||||||
"""
|
"""
|
||||||
Write flag data to file. (The header is written with the write_header function.)
|
Write flag data to file.
|
||||||
|
|
||||||
|
Note that the header is written with the write_header function.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
#with open(os.path.expanduser(filepath), 'wb') as f:
|
#with open(os.path.expanduser(filepath), 'wb') as f:
|
||||||
|
@ -253,7 +263,8 @@ def write_docbook(directory, flags, groups, package_name, verbose=0):
|
||||||
opt = flag[1]["opt"]
|
opt = flag[1]["opt"]
|
||||||
if not opt.help:
|
if not opt.help:
|
||||||
opt.help = "No help text available for this option"
|
opt.help = "No help text available for this option"
|
||||||
if type(opt).__name__ == "ListOpt" and opt.default is not None:
|
if (type(opt).__name__ == "ListOpt" and
|
||||||
|
opt.default is not None):
|
||||||
opt.default = ",".join(opt.default)
|
opt.default = ",".join(opt.default)
|
||||||
groups_file.write('\n <tr>\n\
|
groups_file.write('\n <tr>\n\
|
||||||
<td>' + flag_name + '=' + str(opt.default) + '</td>\n\
|
<td>' + flag_name + '=' + str(opt.default) + '</td>\n\
|
||||||
|
|
|
@ -80,10 +80,12 @@ def extract_descriptions_from_devref(repo, options):
|
||||||
+ ' ' + line.strip())
|
+ ' ' + line.strip())
|
||||||
for option in options:
|
for option in options:
|
||||||
line_parts = line.strip().split(None, 2)
|
line_parts = line.strip().split(None, 2)
|
||||||
if (' ' in line and len(line_parts) == 3
|
if (' ' in line and
|
||||||
and option == line_parts[0]
|
len(line_parts) == 3 and
|
||||||
and line_parts[1] != '=' and option != 'use'
|
option == line_parts[0] and
|
||||||
and (option not in option_descs or
|
line_parts[1] != '=' and
|
||||||
|
option != 'use' and
|
||||||
|
(option not in option_descs or
|
||||||
len(option_descs[option]) < len(line_parts[2]))):
|
len(option_descs[option]) < len(line_parts[2]))):
|
||||||
option_descs[option] = line_parts[2]
|
option_descs[option] = line_parts[2]
|
||||||
prev_option = option
|
prev_option = option
|
||||||
|
@ -94,7 +96,8 @@ def new_section_file(sample, current_section):
|
||||||
section_filename = ('swift-' +
|
section_filename = ('swift-' +
|
||||||
path.basename(sample).split('.conf')[0]
|
path.basename(sample).split('.conf')[0]
|
||||||
+ '-'
|
+ '-'
|
||||||
+ current_section.replace('[', '').replace(']', '').replace(':', '-')
|
+ current_section.replace('[', '').
|
||||||
|
replace(']', '').replace(':', '-')
|
||||||
+ '.xml')
|
+ '.xml')
|
||||||
section_file = open(section_filename, 'w')
|
section_file = open(section_filename, 'w')
|
||||||
section_file.write('<?xml version="1.0" encoding="UTF-8"?>\n\
|
section_file.write('<?xml version="1.0" encoding="UTF-8"?>\n\
|
||||||
|
@ -104,7 +107,8 @@ def new_section_file(sample, current_section):
|
||||||
<para xmlns="http://docbook.org/ns/docbook" version="5.0">\n\
|
<para xmlns="http://docbook.org/ns/docbook" version="5.0">\n\
|
||||||
<table rules="all">\n\
|
<table rules="all">\n\
|
||||||
<caption>Description of configuration options for <literal>'
|
<caption>Description of configuration options for <literal>'
|
||||||
+ current_section + '</literal> in <literal>' + path.basename(sample) +
|
+ current_section + '</literal> in <literal>'
|
||||||
|
+ path.basename(sample) +
|
||||||
'</literal></caption>\n\
|
'</literal></caption>\n\
|
||||||
<col width="50%"/>\n\
|
<col width="50%"/>\n\
|
||||||
<col width="50%"/>\n\
|
<col width="50%"/>\n\
|
||||||
|
@ -159,10 +163,12 @@ def create_new_tables(repo, verbose):
|
||||||
if (parsed_line[0] in options.keys()
|
if (parsed_line[0] in options.keys()
|
||||||
and 'No help text' not in options[parsed_line[0]]):
|
and 'No help text' not in options[parsed_line[0]]):
|
||||||
# use the help text from existing tables
|
# use the help text from existing tables
|
||||||
option_desc = options[parsed_line[0]].replace(u'\xa0', u' ')
|
option_desc = options[parsed_line[0]].replace(u'\xa0',
|
||||||
|
u' ')
|
||||||
elif parsed_line[0] in option_descs:
|
elif parsed_line[0] in option_descs:
|
||||||
# use the help text from the devref
|
# use the help text from the devref
|
||||||
option_desc = option_descs[parsed_line[0]].replace(u'\xa0', u' ')
|
option_desc = option_descs[parsed_line[0]].replace(
|
||||||
|
u'\xa0', u' ')
|
||||||
else:
|
else:
|
||||||
option_desc = 'No help text available for this option'
|
option_desc = 'No help text available for this option'
|
||||||
if verbose > 0:
|
if verbose > 0:
|
||||||
|
|
|
@ -35,7 +35,7 @@ import textwrap
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import gettextutils
|
#from openstack.common import gettextutils
|
||||||
from openstack.common import importutils
|
from openstack.common import importutils
|
||||||
|
|
||||||
# sld
|
# sld
|
||||||
|
|
|
@ -13,7 +13,8 @@ import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
# should be the same like in tools/validate.py
|
# should be the same like in tools/validate.py
|
||||||
FILE_EXCEPTIONS = ['ha-guide-docinfo.xml','bk001-ch003-associate-general.xml']
|
FILE_EXCEPTIONS = ['ha-guide-docinfo.xml',
|
||||||
|
'bk001-ch003-associate-general.xml']
|
||||||
|
|
||||||
elements = [
|
elements = [
|
||||||
'listitem',
|
'listitem',
|
||||||
|
@ -31,8 +32,10 @@ elements = [
|
||||||
|
|
||||||
checks = []
|
checks = []
|
||||||
for element in elements:
|
for element in elements:
|
||||||
checks.append(re.compile("(.*<%s>)\s+([\w\-().:!?{}\[\]]+.*\n)" % element)),
|
checks.append(re.compile("(.*<%s>)\s+([\w\-().:!?{}\[\]]+.*\n)"
|
||||||
checks.append(re.compile("(.*[\w\-().:!?{}\[\]]+)\s+(<\/%s>.*\n)" % element))
|
% element)),
|
||||||
|
checks.append(re.compile("(.*[\w\-().:!?{}\[\]]+)\s+(<\/%s>.*\n)"
|
||||||
|
% element))
|
||||||
|
|
||||||
for root, dirs, files in os.walk('doc/'):
|
for root, dirs, files in os.walk('doc/'):
|
||||||
for f in files:
|
for f in files:
|
||||||
|
|
|
@ -791,12 +791,15 @@ def main():
|
||||||
|
|
||||||
if prog_args.check_syntax or prog_args.check_niceness:
|
if prog_args.check_syntax or prog_args.check_niceness:
|
||||||
if prog_args.force:
|
if prog_args.force:
|
||||||
validate_all_files(prog_args.path, FILE_EXCEPTIONS, prog_args.verbose,
|
validate_all_files(prog_args.path, FILE_EXCEPTIONS,
|
||||||
prog_args.check_syntax, prog_args.check_niceness,
|
prog_args.verbose,
|
||||||
|
prog_args.check_syntax,
|
||||||
|
prog_args.check_niceness,
|
||||||
prog_args.ignore_errors)
|
prog_args.ignore_errors)
|
||||||
else:
|
else:
|
||||||
validate_individual_files(prog_args.path, FILE_EXCEPTIONS,
|
validate_individual_files(prog_args.path, FILE_EXCEPTIONS,
|
||||||
prog_args.verbose, prog_args.check_syntax,
|
prog_args.verbose,
|
||||||
|
prog_args.check_syntax,
|
||||||
prog_args.check_niceness,
|
prog_args.check_niceness,
|
||||||
prog_args.ignore_errors)
|
prog_args.ignore_errors)
|
||||||
|
|
||||||
|
@ -805,7 +808,8 @@ def main():
|
||||||
|
|
||||||
if prog_args.check_build:
|
if prog_args.check_build:
|
||||||
build_affected_books(prog_args.path, BOOK_EXCEPTIONS,
|
build_affected_books(prog_args.path, BOOK_EXCEPTIONS,
|
||||||
prog_args.verbose, prog_args.force, prog_args.ignore_errors)
|
prog_args.verbose, prog_args.force,
|
||||||
|
prog_args.ignore_errors)
|
||||||
|
|
||||||
|
|
||||||
def default_root():
|
def default_root():
|
||||||
|
|
Loading…
Reference in New Issue