rm extra whitespace in python, per PEP8

This commit is contained in:
Christopher Dunn
2015-01-24 15:29:52 -06:00
parent f4bc0bf4ec
commit 494950a63d
17 changed files with 489 additions and 495 deletions

View File

@@ -14,7 +14,7 @@ def find_program(*filenames):
@return: the full path of the filename if found, or '' if filename could not be found
"""
paths = os.environ.get('PATH', '').split(os.pathsep)
suffixes = ('win32' in sys.platform ) and '.exe .com .bat .cmd' or ''
suffixes = ('win32' in sys.platform) and '.exe .com .bat .cmd' or ''
for filename in filenames:
for name in [filename+ext for ext in suffixes.split()]:
for directory in paths:
@@ -47,24 +47,24 @@ def do_subst_in_file(targetfile, sourcefile, dict):
raise
def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
config_file = os.path.abspath( config_file )
config_file = os.path.abspath(config_file)
doxygen_path = doxygen_path
old_cwd = os.getcwd()
try:
os.chdir( working_dir )
os.chdir(working_dir)
cmd = [doxygen_path, config_file]
print('Running:', ' '.join( cmd ))
print('Running:', ' '.join(cmd))
try:
import subprocess
except:
if os.system( ' '.join( cmd ) ) != 0:
if os.system(' '.join(cmd)) != 0:
print('Documentation generation failed')
return False
else:
if is_silent:
process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
process = subprocess.Popen( cmd )
process = subprocess.Popen(cmd)
stdout, _ = process.communicate()
if process.returncode:
print('Documentation generation failed:')
@@ -72,9 +72,9 @@ def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
return False
return True
finally:
os.chdir( old_cwd )
os.chdir(old_cwd)
def build_doc( options, make_release=False ):
def build_doc(options, make_release=False):
if make_release:
options.make_tarball = True
options.with_dot = True
@@ -85,35 +85,35 @@ def build_doc( options, make_release=False ):
version = open('version','rt').read().strip()
output_dir = 'dist/doxygen' # relative to doc/doxyfile location.
if not os.path.isdir( output_dir ):
os.makedirs( output_dir )
top_dir = os.path.abspath( '.' )
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
top_dir = os.path.abspath('.')
html_output_dirname = 'jsoncpp-api-html-' + version
tarball_path = os.path.join( 'dist', html_output_dirname + '.tar.gz' )
warning_log_path = os.path.join( output_dir, '../jsoncpp-doxygen-warning.log' )
html_output_path = os.path.join( output_dir, html_output_dirname )
def yesno( bool ):
tarball_path = os.path.join('dist', html_output_dirname + '.tar.gz')
warning_log_path = os.path.join(output_dir, '../jsoncpp-doxygen-warning.log')
html_output_path = os.path.join(output_dir, html_output_dirname)
def yesno(bool):
return bool and 'YES' or 'NO'
subst_keys = {
'%JSONCPP_VERSION%': version,
'%DOC_TOPDIR%': '',
'%TOPDIR%': top_dir,
'%HTML_OUTPUT%': os.path.join( '..', output_dir, html_output_dirname ),
'%HTML_OUTPUT%': os.path.join('..', output_dir, html_output_dirname),
'%HAVE_DOT%': yesno(options.with_dot),
'%DOT_PATH%': os.path.split(options.dot_path)[0],
'%HTML_HELP%': yesno(options.with_html_help),
'%UML_LOOK%': yesno(options.with_uml_look),
'%WARNING_LOG_PATH%': os.path.join( '..', warning_log_path )
'%WARNING_LOG_PATH%': os.path.join('..', warning_log_path)
}
if os.path.isdir( output_dir ):
if os.path.isdir(output_dir):
print('Deleting directory:', output_dir)
shutil.rmtree( output_dir )
if not os.path.isdir( output_dir ):
os.makedirs( output_dir )
shutil.rmtree(output_dir)
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
do_subst_in_file( 'doc/doxyfile', 'doc/doxyfile.in', subst_keys )
ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent )
do_subst_in_file('doc/doxyfile', 'doc/doxyfile.in', subst_keys)
ok = run_doxygen(options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent)
if not options.silent:
print(open(warning_log_path, 'rb').read())
index_path = os.path.abspath(os.path.join('doc', subst_keys['%HTML_OUTPUT%'], 'index.html'))
@@ -121,7 +121,7 @@ def build_doc( options, make_release=False ):
print(index_path)
if options.open:
import webbrowser
webbrowser.open( 'file://' + index_path )
webbrowser.open('file://' + index_path)
if options.make_tarball:
print('Generating doc tarball to', tarball_path)
tarball_sources = [
@@ -131,8 +131,8 @@ def build_doc( options, make_release=False ):
'NEWS.txt',
'version'
]
tarball_basedir = os.path.join( output_dir, html_output_dirname )
tarball.make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
tarball_basedir = os.path.join(output_dir, html_output_dirname)
tarball.make_tarball(tarball_path, tarball_sources, tarball_basedir, html_output_dirname)
return tarball_path, html_output_dirname
def main():
@@ -163,7 +163,7 @@ def main():
help="""Hides doxygen output""")
parser.enable_interspersed_args()
options, args = parser.parse_args()
build_doc( options )
build_doc(options)
if __name__ == '__main__':
main()