From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-633797-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 251381381F3 for <garchives@archives.gentoo.org>; Tue, 8 Oct 2013 20:00:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EE030E09EC; Tue, 8 Oct 2013 20:00:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 87823E09EC for <gentoo-commits@lists.gentoo.org>; Tue, 8 Oct 2013 20:00:28 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9B78633EF3F for <gentoo-commits@lists.gentoo.org>; Tue, 8 Oct 2013 20:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 32688E5308 for <gentoo-commits@lists.gentoo.org>; Tue, 8 Oct 2013 20:00:26 +0000 (UTC) From: "Mike Frysinger" <vapier@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" <vapier@gentoo.org> Message-ID: <1381262419.54df6c66ccebfa238126bad543b1af08524cedc6.vapier@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/chpathtool.py X-VCS-Directories: bin/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 54df6c66ccebfa238126bad543b1af08524cedc6 X-VCS-Branch: master Date: Tue, 8 Oct 2013 20:00:26 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 778d7607-76a6-4faf-a2c8-191f00944436 X-Archives-Hash: f14964f93800914713c4db3b640ce45f commit: 54df6c66ccebfa238126bad543b1af08524cedc6 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Tue Oct 8 19:58:58 2013 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Tue Oct 8 20:00:19 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=54df6c66 chpathtool: clean up arg parsing to use proper argparse module Also throw in some documentation for good measure since not everyone knows what this thing does. --- bin/chpathtool.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/chpathtool.py b/bin/chpathtool.py index b8c6fd5..aa3b7d4 100755 --- a/bin/chpathtool.py +++ b/bin/chpathtool.py @@ -2,6 +2,10 @@ # Copyright 2011-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +"""Helper tool for converting installed files to custom prefixes. + +In other words, eprefixy $D for Gentoo/Prefix.""" + import io import os import stat @@ -142,14 +146,16 @@ def chpath_inplace_symlink(filename, st, old, new): def main(argv): - usage = '%(prog)s [options] <location> <old> <new>' - parser = ArgumentParser(usage=usage) - options, args = parser.parse_known_args(argv) - - if len(args) != 3: - parser.error('3 args required, got %s' % (len(args),)) + 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 = args + location, old, new = opts.location, opts.old, opts.new is_text_file = IsTextFile()