From f3576888936b4a3bb14fa852d4315e0a2b8d6150 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Sat, 24 Jan 2015 16:20:25 -0600 Subject: [PATCH] make doxybuild.py work with python3.4 --- devtools/tarball.py | 5 +++-- doxybuild.py | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/devtools/tarball.py b/devtools/tarball.py index e461e8f..b2030fb 100644 --- a/devtools/tarball.py +++ b/devtools/tarball.py @@ -1,5 +1,5 @@ from contextlib import closing -import os.path +import os import tarfile TARGZ_DEFAULT_COMPRESSION_LEVEL = 9 @@ -34,7 +34,8 @@ def make_tarball(tarball_path, sources, base_dir, prefix_dir=''): for source in sources: source_path = source if os.path.isdir(source): - os.path.walk(source_path, visit, tar) + for dirpath, dirnames, filenames in os.walk(source_path): + visit(tar, dirpath, filenames) else: path_in_tar = archive_name(source_path) tar.add(source_path, path_in_tar) # filename, arcname diff --git a/doxybuild.py b/doxybuild.py index 8d19f70..6221850 100644 --- a/doxybuild.py +++ b/doxybuild.py @@ -1,6 +1,7 @@ """Script to generate doxygen documentation. """ from __future__ import print_function +from __future__ import unicode_literals from devtools import tarball from contextlib import contextmanager import subprocess @@ -42,12 +43,12 @@ def do_subst_in_file(targetfile, sourcefile, dict): For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'}, then all instances of %VERSION% in the file will be replaced with 1.2345 etc. """ - with open(sourcefile, 'rb') as f: + with open(sourcefile, 'r') as f: contents = f.read() for (k,v) in list(dict.items()): v = v.replace('\\','\\\\') contents = re.sub(k, v, contents) - with open(targetfile, 'wb') as f: + with open(targetfile, 'w') as f: f.write(contents) def getstatusoutput(cmd): @@ -100,7 +101,7 @@ def build_doc(options, make_release=False): options.open = False options.silent = True - version = open('version','rt').read().strip() + 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) @@ -132,7 +133,7 @@ def build_doc(options, make_release=False): do_subst_in_file('doc/doxyfile', 'doc/doxyfile.in', subst_keys) run_doxygen(options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent) if not options.silent: - print(open(warning_log_path, 'rb').read()) + print(open(warning_log_path, 'r').read()) index_path = os.path.abspath(os.path.join('doc', subst_keys['%HTML_OUTPUT%'], 'index.html')) print('Generated documentation can be found in:') print(index_path)