From: W. Trevor King Date: Sat, 5 Apr 2014 17:13:55 +0000 (-0700) Subject: doc/prerst2man.py: Convert execfile to import X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4f5a9c7d4fc607128aebbc1443d6da5439f0d2eb;p=notmuch.git doc/prerst2man.py: Convert execfile to import excefile is gone in Python 3 [1]. Instead of exec-ing the configuration, it's easier to insert the source directory in Python's path [2], and just import the configuration. With this change, prerst2man.py is compatible with both Python 2 and 3. [1]: https://docs.python.org/3.0/whatsnew/3.0.html#builtins [2]: https://docs.python.org/3/library/sys.html#sys.path --- diff --git a/doc/prerst2man.py b/doc/prerst2man.py index 81ce8176..7d78e9b0 100644 --- a/doc/prerst2man.py +++ b/doc/prerst2man.py @@ -1,18 +1,20 @@ -from sys import argv +import sys from datetime import date from os.path import dirname, isdir from os import makedirs, system import re -rst2man = argv[1] -sourcedir = argv[2] -outdir = argv[3] +rst2man = sys.argv[1] +sourcedir = sys.argv[2] +outdir = sys.argv[3] + +sys.path.insert(0, sourcedir) +import conf + if not isdir(outdir): makedirs(outdir, 0o755) -execfile(sourcedir + "/conf.py") - def header(file, startdocname, command, description, authors, section): file.write(""" @@ -29,10 +31,10 @@ def header(file, startdocname, command, description, authors, section): '-' * len(description), description, '-' * len(description), -date.today().isoformat(), release, section, project)) +date.today().isoformat(), conf.release, section, conf.project)) blankre = re.compile("^\s*$") -for page in man_pages: +for page in conf.man_pages: outdirname = outdir + '/' + dirname(page[0]) if not isdir(outdirname): makedirs(outdirname, 0o755)