public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH 1/2] chpathtool: drop optparse compat logic
@ 2015-10-30  3:57 Mike Frysinger
  2015-10-30  3:57 ` [gentoo-portage-dev] [PATCH 2/2] _argparse: punt the module Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2015-10-30  3:57 UTC (permalink / raw
  To: gentoo-portage-dev

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-30 12:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-30  3:57 [gentoo-portage-dev] [PATCH 1/2] chpathtool: drop optparse compat logic Mike Frysinger
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox