From 3a80cd07e5ea9ff73927c2f2f6dd7b9883d45452 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 13 Jul 2014 20:10:34 +1700 Subject: [PATCH] [PATCH v3 2/5] doc/prerst2man.py: Convert execfile to import --- d5/afc6209def9c7e7d72fb5959343076a2edc0d9 | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 d5/afc6209def9c7e7d72fb5959343076a2edc0d9 diff --git a/d5/afc6209def9c7e7d72fb5959343076a2edc0d9 b/d5/afc6209def9c7e7d72fb5959343076a2edc0d9 new file mode 100644 index 000000000..dc371429c --- /dev/null +++ b/d5/afc6209def9c7e7d72fb5959343076a2edc0d9 @@ -0,0 +1,128 @@ +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 16A2D431FD2 + for ; Sat, 12 Jul 2014 20:11:45 -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 WLPFrhcQSuAz for ; + Sat, 12 Jul 2014 20:11:38 -0700 (PDT) +Received: from qmta04.emeryville.ca.mail.comcast.net + (qmta04.emeryville.ca.mail.comcast.net [76.96.30.40]) + by olra.theworths.org (Postfix) with ESMTP id B8F00431FC0 + for ; Sat, 12 Jul 2014 20:11:29 -0700 (PDT) +Received: from omta16.emeryville.ca.mail.comcast.net ([76.96.30.72]) + by qmta04.emeryville.ca.mail.comcast.net with comcast + id Rf9p1o0011ZMdJ4A4fBVAq; Sun, 13 Jul 2014 03:11:29 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta16.emeryville.ca.mail.comcast.net with comcast + id RfBT1o003152l3L8cfBTGn; Sun, 13 Jul 2014 03:11:28 +0000 +Received: from mjolnir.tremily.us (unknown [192.168.0.150]) + by odin.tremily.us (Postfix) with ESMTPS id CD3FB1286F03; + Sat, 12 Jul 2014 20:11:26 -0700 (PDT) +Received: (nullmailer pid 31450 invoked by uid 1000); + Sun, 13 Jul 2014 03:10:44 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH v3 2/5] doc/prerst2man.py: Convert execfile to import +Date: Sat, 12 Jul 2014 20:10:34 -0700 +Message-Id: + <8cc9dd580ad672527e12f43706f9803b2c8e99d8.1405220724.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=1405221089; + bh=surGy6r4gr9e//xrzFrd6sbiw4m4FMtByh0+q6ZgS2o=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=WzUD0km5VsFm2RTPQuCOU98uzGwiK9/Irq+AFWnWvVnuir6v6Cr/O6naCnbVhHQbw + U8A4oKKQCUG2sHqAkkqv+Q4eHlGz0IpRXGZktF/wx3jXBFD6UezJyvVcIJGLTtWzUX + eT2r+F4SqA6eTaSrntcK/d3g343+KJpBpP3CDtUPuMdmTAXrob9QnEigwSlNzaLiJ1 + wW9e5Qzo4hwt+KD7egmEyqXlNnOjCAa5h1FzySUqpMQBYsBSAWfVeegroYxfQeu2p7 + m8vo7y/W3nEr2PYdqc2Al1zxgIraDEFiM4wLVkH9nS7gv+LtLRvytomRNSW5y7LLWs + NtNxdJWfSg71A== +Cc: Tomi Ollila +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: Sun, 13 Jul 2014 03:11:45 -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 + -- 2.26.2