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 0C1531381F3 for ; Fri, 21 Jun 2013 21:24:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A9197E0993; Fri, 21 Jun 2013 21:24:55 +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 3BF25E0993 for ; Fri, 21 Jun 2013 21:24:55 +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 243B233E20B for ; Fri, 21 Jun 2013 21:24:54 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id C6129E468F for ; Fri, 21 Jun 2013 21:24:52 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1371849876.1c47d7ae856e8dea4e0d8bd9244331d752d49c44.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/install.py X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 1c47d7ae856e8dea4e0d8bd9244331d752d49c44 X-VCS-Branch: master Date: Fri, 21 Jun 2013 21:24:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 18b57b34-1c19-4515-8998-b8a03884bbf8 X-Archives-Hash: 5c850f428dfa2d71a641d7a464c34745 commit: 1c47d7ae856e8dea4e0d8bd9244331d752d49c44 Author: Zac Medico gentoo org> AuthorDate: Fri Jun 21 21:24:36 2013 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Jun 21 21:24:36 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1c47d7ae install.py: Python 2.6 and 3.1 optparse compat --- bin/install.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/install.py b/bin/install.py index 6be3900..3fdd5be 100755 --- a/bin/install.py +++ b/bin/install.py @@ -4,13 +4,26 @@ import os import sys -import argparse import subprocess import traceback from portage.util.movefile import _copyxattr from portage.exception import OperationNotSupported +try: + from argparse import ArgumentParser +except ImportError: + # Compatibility with Python 2.6 and 3.1 + from optparse import OptionParser + + class ArgumentParser(object): + def __init__(self, **kwargs): + add_help = kwargs.pop("add_help", None) + if add_help is not None: + kwargs["add_help_option"] = add_help + parser = OptionParser(**kwargs) + self.add_argument = parser.add_option + self.parse_known_args = parser.parse_args def parse_args(args): """ @@ -20,7 +33,7 @@ def parse_args(args): Returns: tuple of the Namespace of parsed options, and a list of order parameters """ - parser = argparse.ArgumentParser(add_help=False) + parser = ArgumentParser(add_help=False) parser.add_argument( "-b",