From: W. Trevor King Date: Sat, 5 Apr 2014 17:31:10 +0000 (+1700) Subject: [PATCH 6/7] doc/prerst2man.py: Convert execfile to import X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e045d32f3a422d8c34b9c41b994396a46ab1b8f7;p=notmuch-archives.git [PATCH 6/7] doc/prerst2man.py: Convert execfile to import --- diff --git a/fc/a7967053e7bba70441ad291ad721a4a8ac8120 b/fc/a7967053e7bba70441ad291ad721a4a8ac8120 new file mode 100644 index 000000000..95146b69e --- /dev/null +++ b/fc/a7967053e7bba70441ad291ad721a4a8ac8120 @@ -0,0 +1,127 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2D13C431FAE + for ; Sat, 5 Apr 2014 10:31:44 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id XXUaVvQLRY4x for ; + Sat, 5 Apr 2014 10:31:38 -0700 (PDT) +Received: from qmta03.westchester.pa.mail.comcast.net + (qmta03.westchester.pa.mail.comcast.net [76.96.62.32]) + by olra.theworths.org (Postfix) with ESMTP id 77C72431FC2 + for ; Sat, 5 Apr 2014 10:31:28 -0700 (PDT) +Received: from omta20.westchester.pa.mail.comcast.net ([76.96.62.71]) + by qmta03.westchester.pa.mail.comcast.net with comcast + id mHWN1n0011YDfWL53HXUS2; Sat, 05 Apr 2014 17:31:28 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta20.westchester.pa.mail.comcast.net with comcast + id mHXT1n00B152l3L3gHXT2M; Sat, 05 Apr 2014 17:31:28 +0000 +Received: from mjolnir.tremily.us (unknown [192.168.0.140]) + by odin.tremily.us (Postfix) with ESMTPS id 01F971103C1D; + Sat, 5 Apr 2014 10:31:27 -0700 (PDT) +Received: (nullmailer pid 16923 invoked by uid 1000); + Sat, 05 Apr 2014 17:31:15 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH 6/7] doc/prerst2man.py: Convert execfile to import +Date: Sat, 5 Apr 2014 10:31:10 -0700 +Message-Id: + <7c43c614cb09665400544fc0928ac14bb67ceeb5.1396718720.git.wking@tremily.us> +X-Mailer: git-send-email 1.9.1.353.gc66d89d +In-Reply-To: +References: +In-Reply-To: +References: +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1396719088; + bh=surGy6r4gr9e//xrzFrd6sbiw4m4FMtByh0+q6ZgS2o=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=NBbHUAr9J7jtf89wz9cL5nvdQa+2ccEcUIMsTYTl5FHhz/L/rH1CDq81nKCVM9Y2i + WD8EMt81Ra5pqNu5/HoUKQT9PZ8vxcfCeZ03E9tC7kAZMSmi3UbCpZPF6GKZ5ZnR6G + Nh5Q3oRNDLWISWkIeHQi96ZTI/ppSssbu9kAY1Ryh6pqGnJ0nt3aI7q77M0M7iynJ0 + l43KIjWj+7CwWJHEec5gcEIVp8xRD6pRv/uuiDpspqZjjE6b1hagkNPT4X/wiqQfnY + MvJsvSeKi2fq9qEmnSFH7HpwgOs7CQYRSOY8AbILHLNJcVcYIFtcnQ+vittk/XLMHu + gXjI3jD/O1TUQ== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 05 Apr 2014 17:31:44 -0000 + +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 +