From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2B18413888F for ; Fri, 30 Oct 2015 03:57:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CC28F21C003; Fri, 30 Oct 2015 03:57:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8629321C001 for ; Fri, 30 Oct 2015 03:57:21 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 471813409B7 for ; Fri, 30 Oct 2015 03:57:19 +0000 (UTC) From: Mike Frysinger 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 Message-Id: <1446177436-28621-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 98113fd0-ddd9-4746-8b5f-d3a336c68399 X-Archives-Hash: a4cd5d9b0e80f173c08785b62430c4b1 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