unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "W. Trevor King" <wking@tremily.us>
To: notmuch@notmuchmail.org
Cc: Tomi Ollila <tomi.ollila@iki.fi>
Subject: [PATCH v2 2/5] doc/prerst2man.py: Convert execfile to import
Date: Sat, 10 May 2014 10:03:33 -0700	[thread overview]
Message-ID: <4f5a9c7d4fc607128aebbc1443d6da5439f0d2eb.1399740604.git.wking@tremily.us> (raw)
In-Reply-To: <cover.1399740604.git.wking@tremily.us>
In-Reply-To: <cover.1399740604.git.wking@tremily.us>

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
---
 doc/prerst2man.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/doc/prerst2man.py b/doc/prerst2man.py
index 81ce817..7d78e9b 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)
-- 
1.9.1.353.gc66d89d

  parent reply	other threads:[~2014-05-10 17:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-10 17:03 [PATCH v2 0/5] rst2man.py support and doc-build cleanups W. Trevor King
2014-05-10 17:03 ` [PATCH v2 1/5] doc: Allow rst2man.py as an alternative to rst2man W. Trevor King
2014-07-12  8:00   ` Tomi Ollila
2014-05-10 17:03 ` W. Trevor King [this message]
2014-05-10 17:03 ` [PATCH v2 3/5] doc/prerst2x.py: Adjust to handle any output format, not just man pages W. Trevor King
2014-07-12  8:16   ` Tomi Ollila
2014-05-10 17:03 ` [PATCH v2 4/5] doc: Consolidate Makefile targets around {build|install}-{format} W. Trevor King
2014-05-10 17:03 ` [PATCH v2 5/5] doc: Add rst2html support for building HTML docs W. Trevor King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f5a9c7d4fc607128aebbc1443d6da5439f0d2eb.1399740604.git.wking@tremily.us \
    --to=wking@tremily.us \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).