From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: [gentoo-portage-dev] [PATCH 1/2] chpathtool: drop optparse compat logic
Date: Thu, 29 Oct 2015 23:57:15 -0400 [thread overview]
Message-ID: <1446177436-28621-1-git-send-email-vapier@gentoo.org> (raw)
We don't support python 2.6 anymore, so drop the non-argparse logic.
---
bin/chpathtool.py | 45 +++++++++++----------------------------------
1 file changed, 11 insertions(+), 34 deletions(-)
diff --git a/bin/chpathtool.py b/bin/chpathtool.py
index 842f1f4..73c7a5f 100755
--- a/bin/chpathtool.py
+++ b/bin/chpathtool.py
@@ -7,18 +7,12 @@ doc = """Helper tool for converting installed files to custom prefixes.
In other words, eprefixy $D for Gentoo/Prefix."""
__doc__ = doc
-
+import argparse
import io
import os
import stat
import sys
-try:
- from argparse import ArgumentParser
-except ImportError:
- ArgumentParser = None
- from optparse import OptionParser
-
CONTENT_ENCODING = 'utf_8'
FS_ENCODING = 'utf_8'
@@ -152,33 +146,16 @@ def chpath_inplace_symlink(filename, st, old, new):
def main(argv):
- if ArgumentParser is not None:
- parser = ArgumentParser(description=doc)
- parser.add_argument('location', default=None,
- help='root directory (e.g. $D)')
- parser.add_argument('old', default=None,
- help='original build prefix (e.g. /)')
- parser.add_argument('new', default=None,
- help='new install prefix (e.g. $EPREFIX)')
- opts = parser.parse_args(argv)
-
- location, old, new = opts.location, opts.old, opts.new
- else:
- # Argument parsing compatibility for Python 2.6 using optparse.
- parser = OptionParser(description=doc,
- usage="usage: %prog [-h] location old new\n\n" + \
- " location: root directory (e.g. $D)\n" + \
- " old: original build prefix (e.g. /)\n" + \
- " new: new install prefix (e.g. $EPREFIX)")
-
- (opts, args) = parser.parse_args()
-
- if len(args) != 3:
- parser.print_usage()
- parser.error("%s: error: expected 3 arguments, got %i"
- % (__file__, len(args)))
-
- location, old, new = args[0:3]
+ parser = argparse.ArgumentParser(description=doc)
+ parser.add_argument('location', default=None,
+ help='root directory (e.g. $D)')
+ parser.add_argument('old', default=None,
+ help='original build prefix (e.g. /)')
+ parser.add_argument('new', default=None,
+ help='new install prefix (e.g. $EPREFIX)')
+ opts = parser.parse_args(argv)
+
+ location, old, new = opts.location, opts.old, opts.new
is_text_file = IsTextFile()
--
2.5.2
next reply other threads:[~2015-10-30 3:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 3:57 Mike Frysinger [this message]
2015-10-30 3:57 ` [gentoo-portage-dev] [PATCH 2/2] _argparse: punt the module Mike Frysinger
2015-10-30 5:24 ` Zac Medico
2015-10-30 12:14 ` Alexander Berntsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446177436-28621-1-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox