get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/808122/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 808122,
    "url": "http://patchwork.ozlabs.org/api/patches/808122/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170831082210.8362-12-stefanha@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170831082210.8362-12-stefanha@redhat.com>",
    "list_archive_url": null,
    "date": "2017-08-31T08:22:06",
    "name": "[PULL,for-2.10,11/15] scripts: add argparse module for Python 2.6 compatibility",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7d1775db7009dbd137f9eb3e46b19a056d9e0fc3",
    "submitter": {
        "id": 17227,
        "url": "http://patchwork.ozlabs.org/api/people/17227/?format=api",
        "name": "Stefan Hajnoczi",
        "email": "stefanha@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170831082210.8362-12-stefanha@redhat.com/mbox/",
    "series": [
        {
            "id": 766,
            "url": "http://patchwork.ozlabs.org/api/series/766/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=766",
            "date": "2017-08-31T08:21:55",
            "name": "[PULL,for-2.10,01/15] nvme: Fix get/set number of queues feature, again",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/766/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/808122/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/808122/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
            "ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=stefanha@redhat.com"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjb4n1Hs2z9s83\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 18:24:09 +1000 (AEST)",
            "from localhost ([::1]:54471 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnKlj-0005qz-42\n\tfor incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 04:24:07 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:42679)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <stefanha@redhat.com>) id 1dnKki-0005gI-96\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 04:23:12 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <stefanha@redhat.com>) id 1dnKkY-0005xg-VT\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 04:23:04 -0400",
            "from mx1.redhat.com ([209.132.183.28]:39782)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <stefanha@redhat.com>) id 1dnKkY-0005xC-Fy\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 04:22:54 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 9FE4C9022D;\n\tThu, 31 Aug 2017 08:22:53 +0000 (UTC)",
            "from localhost (ovpn-117-89.ams2.redhat.com [10.36.117.89])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 69A3B908D1;\n\tThu, 31 Aug 2017 08:22:49 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 9FE4C9022D",
        "From": "Stefan Hajnoczi <stefanha@redhat.com>",
        "To": "<qemu-devel@nongnu.org>",
        "Date": "Thu, 31 Aug 2017 09:22:06 +0100",
        "Message-Id": "<20170831082210.8362-12-stefanha@redhat.com>",
        "In-Reply-To": "<20170831082210.8362-1-stefanha@redhat.com>",
        "References": "<20170831082210.8362-1-stefanha@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.11",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tThu, 31 Aug 2017 08:22:53 +0000 (UTC)",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]",
        "X-Received-From": "209.132.183.28",
        "Subject": "[Qemu-devel] [PULL for-2.10 11/15] scripts: add argparse module for\n\tPython 2.6 compatibility",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "Peter Maydell <peter.maydell@linaro.org>,\n\tStefan Hajnoczi <stefanha@redhat.com>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "The minimum Python version supported by QEMU is 2.6.  The argparse\nstandard library module was only added in Python 2.7.  Many scripts\nwould like to use argparse because it supports command-line\nsub-commands.\n\nThis patch adds argparse.  See the top of argparse.py for details.\n\nSuggested-by: Daniel P. Berrange <berrange@redhat.com>\nSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>\nAcked-by: John Snow <jsnow@redhat.com>\nMessage-id: 20170825155732.15665-2-stefanha@redhat.com\nSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n---\n COPYING.PYTHON      |  270 ++++++\n scripts/argparse.py | 2406 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 2676 insertions(+)\n create mode 100644 COPYING.PYTHON\n create mode 100644 scripts/argparse.py",
    "diff": "diff --git a/COPYING.PYTHON b/COPYING.PYTHON\nnew file mode 100644\nindex 0000000000..4d3f1ef276\n--- /dev/null\n+++ b/COPYING.PYTHON\n@@ -0,0 +1,270 @@\n+A. HISTORY OF THE SOFTWARE\n+==========================\n+\n+Python was created in the early 1990s by Guido van Rossum at Stichting\n+Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands\n+as a successor of a language called ABC.  Guido remains Python's\n+principal author, although it includes many contributions from others.\n+\n+In 1995, Guido continued his work on Python at the Corporation for\n+National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)\n+in Reston, Virginia where he released several versions of the\n+software.\n+\n+In May 2000, Guido and the Python core development team moved to\n+BeOpen.com to form the BeOpen PythonLabs team.  In October of the same\n+year, the PythonLabs team moved to Digital Creations (now Zope\n+Corporation, see http://www.zope.com).  In 2001, the Python Software\n+Foundation (PSF, see http://www.python.org/psf/) was formed, a\n+non-profit organization created specifically to own Python-related\n+Intellectual Property.  Zope Corporation is a sponsoring member of\n+the PSF.\n+\n+All Python releases are Open Source (see http://www.opensource.org for\n+the Open Source Definition).  Historically, most, but not all, Python\n+releases have also been GPL-compatible; the table below summarizes\n+the various releases.\n+\n+    Release         Derived     Year        Owner       GPL-\n+                    from                                compatible? (1)\n+\n+    0.9.0 thru 1.2              1991-1995   CWI         yes\n+    1.3 thru 1.5.2  1.2         1995-1999   CNRI        yes\n+    1.6             1.5.2       2000        CNRI        no\n+    2.0             1.6         2000        BeOpen.com  no\n+    1.6.1           1.6         2001        CNRI        yes (2)\n+    2.1             2.0+1.6.1   2001        PSF         no\n+    2.0.1           2.0+1.6.1   2001        PSF         yes\n+    2.1.1           2.1+2.0.1   2001        PSF         yes\n+    2.2             2.1.1       2001        PSF         yes\n+    2.1.2           2.1.1       2002        PSF         yes\n+    2.1.3           2.1.2       2002        PSF         yes\n+    2.2.1           2.2         2002        PSF         yes\n+    2.2.2           2.2.1       2002        PSF         yes\n+    2.2.3           2.2.2       2003        PSF         yes\n+    2.3             2.2.2       2002-2003   PSF         yes\n+    2.3.1           2.3         2002-2003   PSF         yes\n+    2.3.2           2.3.1       2002-2003   PSF         yes\n+    2.3.3           2.3.2       2002-2003   PSF         yes\n+    2.3.4           2.3.3       2004        PSF         yes\n+    2.3.5           2.3.4       2005        PSF         yes\n+    2.4             2.3         2004        PSF         yes\n+    2.4.1           2.4         2005        PSF         yes\n+    2.4.2           2.4.1       2005        PSF         yes\n+    2.4.3           2.4.2       2006        PSF         yes\n+    2.5             2.4         2006        PSF         yes\n+    2.7             2.6         2010        PSF         yes\n+\n+Footnotes:\n+\n+(1) GPL-compatible doesn't mean that we're distributing Python under\n+    the GPL.  All Python licenses, unlike the GPL, let you distribute\n+    a modified version without making your changes open source.  The\n+    GPL-compatible licenses make it possible to combine Python with\n+    other software that is released under the GPL; the others don't.\n+\n+(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,\n+    because its license has a choice of law clause.  According to\n+    CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1\n+    is \"not incompatible\" with the GPL.\n+\n+Thanks to the many outside volunteers who have worked under Guido's\n+direction to make these releases possible.\n+\n+\n+B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON\n+===============================================================\n+\n+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2\n+--------------------------------------------\n+\n+1. This LICENSE AGREEMENT is between the Python Software Foundation\n+(\"PSF\"), and the Individual or Organization (\"Licensee\") accessing and\n+otherwise using this software (\"Python\") in source or binary form and\n+its associated documentation.\n+\n+2. Subject to the terms and conditions of this License Agreement, PSF\n+hereby grants Licensee a nonexclusive, royalty-free, world-wide\n+license to reproduce, analyze, test, perform and/or display publicly,\n+prepare derivative works, distribute, and otherwise use Python\n+alone or in any derivative version, provided, however, that PSF's\n+License Agreement and PSF's notice of copyright, i.e., \"Copyright (c)\n+2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation; All Rights\n+Reserved\" are retained in Python alone or in any derivative version \n+prepared by Licensee.\n+\n+3. In the event Licensee prepares a derivative work that is based on\n+or incorporates Python or any part thereof, and wants to make\n+the derivative work available to others as provided herein, then\n+Licensee hereby agrees to include in any such work a brief summary of\n+the changes made to Python.\n+\n+4. PSF is making Python available to Licensee on an \"AS IS\"\n+basis.  PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\n+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND\n+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\n+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT\n+INFRINGE ANY THIRD PARTY RIGHTS.\n+\n+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\n+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\n+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,\n+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n+\n+6. This License Agreement will automatically terminate upon a material\n+breach of its terms and conditions.\n+\n+7. Nothing in this License Agreement shall be deemed to create any\n+relationship of agency, partnership, or joint venture between PSF and\n+Licensee.  This License Agreement does not grant permission to use PSF\n+trademarks or trade name in a trademark sense to endorse or promote\n+products or services of Licensee, or any third party.\n+\n+8. By copying, installing or otherwise using Python, Licensee\n+agrees to be bound by the terms and conditions of this License\n+Agreement.\n+\n+\n+BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0\n+-------------------------------------------\n+\n+BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1\n+\n+1. This LICENSE AGREEMENT is between BeOpen.com (\"BeOpen\"), having an\n+office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the\n+Individual or Organization (\"Licensee\") accessing and otherwise using\n+this software in source or binary form and its associated\n+documentation (\"the Software\").\n+\n+2. Subject to the terms and conditions of this BeOpen Python License\n+Agreement, BeOpen hereby grants Licensee a non-exclusive,\n+royalty-free, world-wide license to reproduce, analyze, test, perform\n+and/or display publicly, prepare derivative works, distribute, and\n+otherwise use the Software alone or in any derivative version,\n+provided, however, that the BeOpen Python License is retained in the\n+Software, alone or in any derivative version prepared by Licensee.\n+\n+3. BeOpen is making the Software available to Licensee on an \"AS IS\"\n+basis.  BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\n+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND\n+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\n+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT\n+INFRINGE ANY THIRD PARTY RIGHTS.\n+\n+4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE\n+SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS\n+AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY\n+DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n+\n+5. This License Agreement will automatically terminate upon a material\n+breach of its terms and conditions.\n+\n+6. This License Agreement shall be governed by and interpreted in all\n+respects by the law of the State of California, excluding conflict of\n+law provisions.  Nothing in this License Agreement shall be deemed to\n+create any relationship of agency, partnership, or joint venture\n+between BeOpen and Licensee.  This License Agreement does not grant\n+permission to use BeOpen trademarks or trade names in a trademark\n+sense to endorse or promote products or services of Licensee, or any\n+third party.  As an exception, the \"BeOpen Python\" logos available at\n+http://www.pythonlabs.com/logos.html may be used according to the\n+permissions granted on that web page.\n+\n+7. By copying, installing or otherwise using the software, Licensee\n+agrees to be bound by the terms and conditions of this License\n+Agreement.\n+\n+\n+CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1\n+---------------------------------------\n+\n+1. This LICENSE AGREEMENT is between the Corporation for National\n+Research Initiatives, having an office at 1895 Preston White Drive,\n+Reston, VA 20191 (\"CNRI\"), and the Individual or Organization\n+(\"Licensee\") accessing and otherwise using Python 1.6.1 software in\n+source or binary form and its associated documentation.\n+\n+2. Subject to the terms and conditions of this License Agreement, CNRI\n+hereby grants Licensee a nonexclusive, royalty-free, world-wide\n+license to reproduce, analyze, test, perform and/or display publicly,\n+prepare derivative works, distribute, and otherwise use Python 1.6.1\n+alone or in any derivative version, provided, however, that CNRI's\n+License Agreement and CNRI's notice of copyright, i.e., \"Copyright (c)\n+1995-2001 Corporation for National Research Initiatives; All Rights\n+Reserved\" are retained in Python 1.6.1 alone or in any derivative\n+version prepared by Licensee.  Alternately, in lieu of CNRI's License\n+Agreement, Licensee may substitute the following text (omitting the\n+quotes): \"Python 1.6.1 is made available subject to the terms and\n+conditions in CNRI's License Agreement.  This Agreement together with\n+Python 1.6.1 may be located on the Internet using the following\n+unique, persistent identifier (known as a handle): 1895.22/1013.  This\n+Agreement may also be obtained from a proxy server on the Internet\n+using the following URL: http://hdl.handle.net/1895.22/1013\".\n+\n+3. In the event Licensee prepares a derivative work that is based on\n+or incorporates Python 1.6.1 or any part thereof, and wants to make\n+the derivative work available to others as provided herein, then\n+Licensee hereby agrees to include in any such work a brief summary of\n+the changes made to Python 1.6.1.\n+\n+4. CNRI is making Python 1.6.1 available to Licensee on an \"AS IS\"\n+basis.  CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\n+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND\n+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\n+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT\n+INFRINGE ANY THIRD PARTY RIGHTS.\n+\n+5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\n+1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\n+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,\n+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n+\n+6. This License Agreement will automatically terminate upon a material\n+breach of its terms and conditions.\n+\n+7. This License Agreement shall be governed by the federal\n+intellectual property law of the United States, including without\n+limitation the federal copyright law, and, to the extent such\n+U.S. federal law does not apply, by the law of the Commonwealth of\n+Virginia, excluding Virginia's conflict of law provisions.\n+Notwithstanding the foregoing, with regard to derivative works based\n+on Python 1.6.1 that incorporate non-separable material that was\n+previously distributed under the GNU General Public License (GPL), the\n+law of the Commonwealth of Virginia shall govern this License\n+Agreement only as to issues arising under or with respect to\n+Paragraphs 4, 5, and 7 of this License Agreement.  Nothing in this\n+License Agreement shall be deemed to create any relationship of\n+agency, partnership, or joint venture between CNRI and Licensee.  This\n+License Agreement does not grant permission to use CNRI trademarks or\n+trade name in a trademark sense to endorse or promote products or\n+services of Licensee, or any third party.\n+\n+8. By clicking on the \"ACCEPT\" button where indicated, or by copying,\n+installing or otherwise using Python 1.6.1, Licensee agrees to be\n+bound by the terms and conditions of this License Agreement.\n+\n+        ACCEPT\n+\n+\n+CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2\n+--------------------------------------------------\n+\n+Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,\n+The Netherlands.  All rights reserved.\n+\n+Permission to use, copy, modify, and distribute this software and its\n+documentation for any purpose and without fee is hereby granted,\n+provided that the above copyright notice appear in all copies and that\n+both that copyright notice and this permission notice appear in\n+supporting documentation, and that the name of Stichting Mathematisch\n+Centrum or CWI not be used in advertising or publicity pertaining to\n+distribution of the software without specific, written prior\n+permission.\n+\n+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO\n+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE\n+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\n+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ndiff --git a/scripts/argparse.py b/scripts/argparse.py\nnew file mode 100644\nindex 0000000000..288c1f06c0\n--- /dev/null\n+++ b/scripts/argparse.py\n@@ -0,0 +1,2406 @@\n+# This is a local copy of the standard library argparse module taken from PyPI.\n+# It is licensed under the Python Software Foundation License.  This is a\n+# fallback for Python 2.6 which does not include this module.  Python 2.7+ and\n+# 3+ will never load this module because built-in modules are loaded before\n+# anything in sys.path.\n+#\n+# If your script is not located in the same directory as this file, import it\n+# like this:\n+#\n+#   import os\n+#   import sys\n+#   sys.path.append(os.path.join(os.path.dirname(__file__), ..., 'scripts'))\n+#   import argparse\n+\n+# Author: Steven J. Bethard <steven.bethard@gmail.com>.\n+# Maintainer: Thomas Waldmann <tw@waldmann-edv.de>\n+\n+\"\"\"Command-line parsing library\n+\n+This module is an optparse-inspired command-line parsing library that:\n+\n+    - handles both optional and positional arguments\n+    - produces highly informative usage messages\n+    - supports parsers that dispatch to sub-parsers\n+\n+The following is a simple usage example that sums integers from the\n+command-line and writes the result to a file::\n+\n+    parser = argparse.ArgumentParser(\n+        description='sum the integers at the command line')\n+    parser.add_argument(\n+        'integers', metavar='int', nargs='+', type=int,\n+        help='an integer to be summed')\n+    parser.add_argument(\n+        '--log', default=sys.stdout, type=argparse.FileType('w'),\n+        help='the file where the sum should be written')\n+    args = parser.parse_args()\n+    args.log.write('%s' % sum(args.integers))\n+    args.log.close()\n+\n+The module contains the following public classes:\n+\n+    - ArgumentParser -- The main entry point for command-line parsing. As the\n+        example above shows, the add_argument() method is used to populate\n+        the parser with actions for optional and positional arguments. Then\n+        the parse_args() method is invoked to convert the args at the\n+        command-line into an object with attributes.\n+\n+    - ArgumentError -- The exception raised by ArgumentParser objects when\n+        there are errors with the parser's actions. Errors raised while\n+        parsing the command-line are caught by ArgumentParser and emitted\n+        as command-line messages.\n+\n+    - FileType -- A factory for defining types of files to be created. As the\n+        example above shows, instances of FileType are typically passed as\n+        the type= argument of add_argument() calls.\n+\n+    - Action -- The base class for parser actions. Typically actions are\n+        selected by passing strings like 'store_true' or 'append_const' to\n+        the action= argument of add_argument(). However, for greater\n+        customization of ArgumentParser actions, subclasses of Action may\n+        be defined and passed as the action= argument.\n+\n+    - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,\n+        ArgumentDefaultsHelpFormatter -- Formatter classes which\n+        may be passed as the formatter_class= argument to the\n+        ArgumentParser constructor. HelpFormatter is the default,\n+        RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser\n+        not to change the formatting for help text, and\n+        ArgumentDefaultsHelpFormatter adds information about argument defaults\n+        to the help.\n+\n+All other classes in this module are considered implementation details.\n+(Also note that HelpFormatter and RawDescriptionHelpFormatter are only\n+considered public as object names -- the API of the formatter objects is\n+still considered an implementation detail.)\n+\"\"\"\n+\n+__version__ = '1.4.0'  # we use our own version number independant of the\n+                       # one in stdlib and we release this on pypi.\n+\n+__external_lib__ = True  # to make sure the tests really test THIS lib,\n+                         # not the builtin one in Python stdlib\n+\n+__all__ = [\n+    'ArgumentParser',\n+    'ArgumentError',\n+    'ArgumentTypeError',\n+    'FileType',\n+    'HelpFormatter',\n+    'ArgumentDefaultsHelpFormatter',\n+    'RawDescriptionHelpFormatter',\n+    'RawTextHelpFormatter',\n+    'Namespace',\n+    'Action',\n+    'ONE_OR_MORE',\n+    'OPTIONAL',\n+    'PARSER',\n+    'REMAINDER',\n+    'SUPPRESS',\n+    'ZERO_OR_MORE',\n+]\n+\n+\n+import copy as _copy\n+import os as _os\n+import re as _re\n+import sys as _sys\n+import textwrap as _textwrap\n+\n+from gettext import gettext as _\n+\n+try:\n+    set\n+except NameError:\n+    # for python < 2.4 compatibility (sets module is there since 2.3):\n+    from sets import Set as set\n+\n+try:\n+    basestring\n+except NameError:\n+    basestring = str\n+\n+try:\n+    sorted\n+except NameError:\n+    # for python < 2.4 compatibility:\n+    def sorted(iterable, reverse=False):\n+        result = list(iterable)\n+        result.sort()\n+        if reverse:\n+            result.reverse()\n+        return result\n+\n+\n+def _callable(obj):\n+    return hasattr(obj, '__call__') or hasattr(obj, '__bases__')\n+\n+\n+SUPPRESS = '==SUPPRESS=='\n+\n+OPTIONAL = '?'\n+ZERO_OR_MORE = '*'\n+ONE_OR_MORE = '+'\n+PARSER = 'A...'\n+REMAINDER = '...'\n+_UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'\n+\n+# =============================\n+# Utility functions and classes\n+# =============================\n+\n+class _AttributeHolder(object):\n+    \"\"\"Abstract base class that provides __repr__.\n+\n+    The __repr__ method returns a string in the format::\n+        ClassName(attr=name, attr=name, ...)\n+    The attributes are determined either by a class-level attribute,\n+    '_kwarg_names', or by inspecting the instance __dict__.\n+    \"\"\"\n+\n+    def __repr__(self):\n+        type_name = type(self).__name__\n+        arg_strings = []\n+        for arg in self._get_args():\n+            arg_strings.append(repr(arg))\n+        for name, value in self._get_kwargs():\n+            arg_strings.append('%s=%r' % (name, value))\n+        return '%s(%s)' % (type_name, ', '.join(arg_strings))\n+\n+    def _get_kwargs(self):\n+        return sorted(self.__dict__.items())\n+\n+    def _get_args(self):\n+        return []\n+\n+\n+def _ensure_value(namespace, name, value):\n+    if getattr(namespace, name, None) is None:\n+        setattr(namespace, name, value)\n+    return getattr(namespace, name)\n+\n+\n+# ===============\n+# Formatting Help\n+# ===============\n+\n+class HelpFormatter(object):\n+    \"\"\"Formatter for generating usage messages and argument help strings.\n+\n+    Only the name of this class is considered a public API. All the methods\n+    provided by the class are considered an implementation detail.\n+    \"\"\"\n+\n+    def __init__(self,\n+                 prog,\n+                 indent_increment=2,\n+                 max_help_position=24,\n+                 width=None):\n+\n+        # default setting for width\n+        if width is None:\n+            try:\n+                width = int(_os.environ['COLUMNS'])\n+            except (KeyError, ValueError):\n+                width = 80\n+            width -= 2\n+\n+        self._prog = prog\n+        self._indent_increment = indent_increment\n+        self._max_help_position = max_help_position\n+        self._width = width\n+\n+        self._current_indent = 0\n+        self._level = 0\n+        self._action_max_length = 0\n+\n+        self._root_section = self._Section(self, None)\n+        self._current_section = self._root_section\n+\n+        self._whitespace_matcher = _re.compile(r'\\s+')\n+        self._long_break_matcher = _re.compile(r'\\n\\n\\n+')\n+\n+    # ===============================\n+    # Section and indentation methods\n+    # ===============================\n+    def _indent(self):\n+        self._current_indent += self._indent_increment\n+        self._level += 1\n+\n+    def _dedent(self):\n+        self._current_indent -= self._indent_increment\n+        assert self._current_indent >= 0, 'Indent decreased below 0.'\n+        self._level -= 1\n+\n+    class _Section(object):\n+\n+        def __init__(self, formatter, parent, heading=None):\n+            self.formatter = formatter\n+            self.parent = parent\n+            self.heading = heading\n+            self.items = []\n+\n+        def format_help(self):\n+            # format the indented section\n+            if self.parent is not None:\n+                self.formatter._indent()\n+            join = self.formatter._join_parts\n+            for func, args in self.items:\n+                func(*args)\n+            item_help = join([func(*args) for func, args in self.items])\n+            if self.parent is not None:\n+                self.formatter._dedent()\n+\n+            # return nothing if the section was empty\n+            if not item_help:\n+                return ''\n+\n+            # add the heading if the section was non-empty\n+            if self.heading is not SUPPRESS and self.heading is not None:\n+                current_indent = self.formatter._current_indent\n+                heading = '%*s%s:\\n' % (current_indent, '', self.heading)\n+            else:\n+                heading = ''\n+\n+            # join the section-initial newline, the heading and the help\n+            return join(['\\n', heading, item_help, '\\n'])\n+\n+    def _add_item(self, func, args):\n+        self._current_section.items.append((func, args))\n+\n+    # ========================\n+    # Message building methods\n+    # ========================\n+    def start_section(self, heading):\n+        self._indent()\n+        section = self._Section(self, self._current_section, heading)\n+        self._add_item(section.format_help, [])\n+        self._current_section = section\n+\n+    def end_section(self):\n+        self._current_section = self._current_section.parent\n+        self._dedent()\n+\n+    def add_text(self, text):\n+        if text is not SUPPRESS and text is not None:\n+            self._add_item(self._format_text, [text])\n+\n+    def add_usage(self, usage, actions, groups, prefix=None):\n+        if usage is not SUPPRESS:\n+            args = usage, actions, groups, prefix\n+            self._add_item(self._format_usage, args)\n+\n+    def add_argument(self, action):\n+        if action.help is not SUPPRESS:\n+\n+            # find all invocations\n+            get_invocation = self._format_action_invocation\n+            invocations = [get_invocation(action)]\n+            for subaction in self._iter_indented_subactions(action):\n+                invocations.append(get_invocation(subaction))\n+\n+            # update the maximum item length\n+            invocation_length = max([len(s) for s in invocations])\n+            action_length = invocation_length + self._current_indent\n+            self._action_max_length = max(self._action_max_length,\n+                                          action_length)\n+\n+            # add the item to the list\n+            self._add_item(self._format_action, [action])\n+\n+    def add_arguments(self, actions):\n+        for action in actions:\n+            self.add_argument(action)\n+\n+    # =======================\n+    # Help-formatting methods\n+    # =======================\n+    def format_help(self):\n+        help = self._root_section.format_help()\n+        if help:\n+            help = self._long_break_matcher.sub('\\n\\n', help)\n+            help = help.strip('\\n') + '\\n'\n+        return help\n+\n+    def _join_parts(self, part_strings):\n+        return ''.join([part\n+                        for part in part_strings\n+                        if part and part is not SUPPRESS])\n+\n+    def _format_usage(self, usage, actions, groups, prefix):\n+        if prefix is None:\n+            prefix = _('usage: ')\n+\n+        # if usage is specified, use that\n+        if usage is not None:\n+            usage = usage % dict(prog=self._prog)\n+\n+        # if no optionals or positionals are available, usage is just prog\n+        elif usage is None and not actions:\n+            usage = '%(prog)s' % dict(prog=self._prog)\n+\n+        # if optionals and positionals are available, calculate usage\n+        elif usage is None:\n+            prog = '%(prog)s' % dict(prog=self._prog)\n+\n+            # split optionals from positionals\n+            optionals = []\n+            positionals = []\n+            for action in actions:\n+                if action.option_strings:\n+                    optionals.append(action)\n+                else:\n+                    positionals.append(action)\n+\n+            # build full usage string\n+            format = self._format_actions_usage\n+            action_usage = format(optionals + positionals, groups)\n+            usage = ' '.join([s for s in [prog, action_usage] if s])\n+\n+            # wrap the usage parts if it's too long\n+            text_width = self._width - self._current_indent\n+            if len(prefix) + len(usage) > text_width:\n+\n+                # break usage into wrappable parts\n+                part_regexp = r'\\(.*?\\)+|\\[.*?\\]+|\\S+'\n+                opt_usage = format(optionals, groups)\n+                pos_usage = format(positionals, groups)\n+                opt_parts = _re.findall(part_regexp, opt_usage)\n+                pos_parts = _re.findall(part_regexp, pos_usage)\n+                assert ' '.join(opt_parts) == opt_usage\n+                assert ' '.join(pos_parts) == pos_usage\n+\n+                # helper for wrapping lines\n+                def get_lines(parts, indent, prefix=None):\n+                    lines = []\n+                    line = []\n+                    if prefix is not None:\n+                        line_len = len(prefix) - 1\n+                    else:\n+                        line_len = len(indent) - 1\n+                    for part in parts:\n+                        if line_len + 1 + len(part) > text_width:\n+                            lines.append(indent + ' '.join(line))\n+                            line = []\n+                            line_len = len(indent) - 1\n+                        line.append(part)\n+                        line_len += len(part) + 1\n+                    if line:\n+                        lines.append(indent + ' '.join(line))\n+                    if prefix is not None:\n+                        lines[0] = lines[0][len(indent):]\n+                    return lines\n+\n+                # if prog is short, follow it with optionals or positionals\n+                if len(prefix) + len(prog) <= 0.75 * text_width:\n+                    indent = ' ' * (len(prefix) + len(prog) + 1)\n+                    if opt_parts:\n+                        lines = get_lines([prog] + opt_parts, indent, prefix)\n+                        lines.extend(get_lines(pos_parts, indent))\n+                    elif pos_parts:\n+                        lines = get_lines([prog] + pos_parts, indent, prefix)\n+                    else:\n+                        lines = [prog]\n+\n+                # if prog is long, put it on its own line\n+                else:\n+                    indent = ' ' * len(prefix)\n+                    parts = opt_parts + pos_parts\n+                    lines = get_lines(parts, indent)\n+                    if len(lines) > 1:\n+                        lines = []\n+                        lines.extend(get_lines(opt_parts, indent))\n+                        lines.extend(get_lines(pos_parts, indent))\n+                    lines = [prog] + lines\n+\n+                # join lines into usage\n+                usage = '\\n'.join(lines)\n+\n+        # prefix with 'usage:'\n+        return '%s%s\\n\\n' % (prefix, usage)\n+\n+    def _format_actions_usage(self, actions, groups):\n+        # find group indices and identify actions in groups\n+        group_actions = set()\n+        inserts = {}\n+        for group in groups:\n+            try:\n+                start = actions.index(group._group_actions[0])\n+            except ValueError:\n+                continue\n+            else:\n+                end = start + len(group._group_actions)\n+                if actions[start:end] == group._group_actions:\n+                    for action in group._group_actions:\n+                        group_actions.add(action)\n+                    if not group.required:\n+                        if start in inserts:\n+                            inserts[start] += ' ['\n+                        else:\n+                            inserts[start] = '['\n+                        inserts[end] = ']'\n+                    else:\n+                        if start in inserts:\n+                            inserts[start] += ' ('\n+                        else:\n+                            inserts[start] = '('\n+                        inserts[end] = ')'\n+                    for i in range(start + 1, end):\n+                        inserts[i] = '|'\n+\n+        # collect all actions format strings\n+        parts = []\n+        for i, action in enumerate(actions):\n+\n+            # suppressed arguments are marked with None\n+            # remove | separators for suppressed arguments\n+            if action.help is SUPPRESS:\n+                parts.append(None)\n+                if inserts.get(i) == '|':\n+                    inserts.pop(i)\n+                elif inserts.get(i + 1) == '|':\n+                    inserts.pop(i + 1)\n+\n+            # produce all arg strings\n+            elif not action.option_strings:\n+                part = self._format_args(action, action.dest)\n+\n+                # if it's in a group, strip the outer []\n+                if action in group_actions:\n+                    if part[0] == '[' and part[-1] == ']':\n+                        part = part[1:-1]\n+\n+                # add the action string to the list\n+                parts.append(part)\n+\n+            # produce the first way to invoke the option in brackets\n+            else:\n+                option_string = action.option_strings[0]\n+\n+                # if the Optional doesn't take a value, format is:\n+                #    -s or --long\n+                if action.nargs == 0:\n+                    part = '%s' % option_string\n+\n+                # if the Optional takes a value, format is:\n+                #    -s ARGS or --long ARGS\n+                else:\n+                    default = action.dest.upper()\n+                    args_string = self._format_args(action, default)\n+                    part = '%s %s' % (option_string, args_string)\n+\n+                # make it look optional if it's not required or in a group\n+                if not action.required and action not in group_actions:\n+                    part = '[%s]' % part\n+\n+                # add the action string to the list\n+                parts.append(part)\n+\n+        # insert things at the necessary indices\n+        for i in sorted(inserts, reverse=True):\n+            parts[i:i] = [inserts[i]]\n+\n+        # join all the action items with spaces\n+        text = ' '.join([item for item in parts if item is not None])\n+\n+        # clean up separators for mutually exclusive groups\n+        open = r'[\\[(]'\n+        close = r'[\\])]'\n+        text = _re.sub(r'(%s) ' % open, r'\\1', text)\n+        text = _re.sub(r' (%s)' % close, r'\\1', text)\n+        text = _re.sub(r'%s *%s' % (open, close), r'', text)\n+        text = _re.sub(r'\\(([^|]*)\\)', r'\\1', text)\n+        text = text.strip()\n+\n+        # return the text\n+        return text\n+\n+    def _format_text(self, text):\n+        if '%(prog)' in text:\n+            text = text % dict(prog=self._prog)\n+        text_width = self._width - self._current_indent\n+        indent = ' ' * self._current_indent\n+        return self._fill_text(text, text_width, indent) + '\\n\\n'\n+\n+    def _format_action(self, action):\n+        # determine the required width and the entry label\n+        help_position = min(self._action_max_length + 2,\n+                            self._max_help_position)\n+        help_width = self._width - help_position\n+        action_width = help_position - self._current_indent - 2\n+        action_header = self._format_action_invocation(action)\n+\n+        # ho nelp; start on same line and add a final newline\n+        if not action.help:\n+            tup = self._current_indent, '', action_header\n+            action_header = '%*s%s\\n' % tup\n+\n+        # short action name; start on the same line and pad two spaces\n+        elif len(action_header) <= action_width:\n+            tup = self._current_indent, '', action_width, action_header\n+            action_header = '%*s%-*s  ' % tup\n+            indent_first = 0\n+\n+        # long action name; start on the next line\n+        else:\n+            tup = self._current_indent, '', action_header\n+            action_header = '%*s%s\\n' % tup\n+            indent_first = help_position\n+\n+        # collect the pieces of the action help\n+        parts = [action_header]\n+\n+        # if there was help for the action, add lines of help text\n+        if action.help:\n+            help_text = self._expand_help(action)\n+            help_lines = self._split_lines(help_text, help_width)\n+            parts.append('%*s%s\\n' % (indent_first, '', help_lines[0]))\n+            for line in help_lines[1:]:\n+                parts.append('%*s%s\\n' % (help_position, '', line))\n+\n+        # or add a newline if the description doesn't end with one\n+        elif not action_header.endswith('\\n'):\n+            parts.append('\\n')\n+\n+        # if there are any sub-actions, add their help as well\n+        for subaction in self._iter_indented_subactions(action):\n+            parts.append(self._format_action(subaction))\n+\n+        # return a single string\n+        return self._join_parts(parts)\n+\n+    def _format_action_invocation(self, action):\n+        if not action.option_strings:\n+            metavar, = self._metavar_formatter(action, action.dest)(1)\n+            return metavar\n+\n+        else:\n+            parts = []\n+\n+            # if the Optional doesn't take a value, format is:\n+            #    -s, --long\n+            if action.nargs == 0:\n+                parts.extend(action.option_strings)\n+\n+            # if the Optional takes a value, format is:\n+            #    -s ARGS, --long ARGS\n+            else:\n+                default = action.dest.upper()\n+                args_string = self._format_args(action, default)\n+                for option_string in action.option_strings:\n+                    parts.append('%s %s' % (option_string, args_string))\n+\n+            return ', '.join(parts)\n+\n+    def _metavar_formatter(self, action, default_metavar):\n+        if action.metavar is not None:\n+            result = action.metavar\n+        elif action.choices is not None:\n+            choice_strs = [str(choice) for choice in action.choices]\n+            result = '{%s}' % ','.join(choice_strs)\n+        else:\n+            result = default_metavar\n+\n+        def format(tuple_size):\n+            if isinstance(result, tuple):\n+                return result\n+            else:\n+                return (result, ) * tuple_size\n+        return format\n+\n+    def _format_args(self, action, default_metavar):\n+        get_metavar = self._metavar_formatter(action, default_metavar)\n+        if action.nargs is None:\n+            result = '%s' % get_metavar(1)\n+        elif action.nargs == OPTIONAL:\n+            result = '[%s]' % get_metavar(1)\n+        elif action.nargs == ZERO_OR_MORE:\n+            result = '[%s [%s ...]]' % get_metavar(2)\n+        elif action.nargs == ONE_OR_MORE:\n+            result = '%s [%s ...]' % get_metavar(2)\n+        elif action.nargs == REMAINDER:\n+            result = '...'\n+        elif action.nargs == PARSER:\n+            result = '%s ...' % get_metavar(1)\n+        else:\n+            formats = ['%s' for _ in range(action.nargs)]\n+            result = ' '.join(formats) % get_metavar(action.nargs)\n+        return result\n+\n+    def _expand_help(self, action):\n+        params = dict(vars(action), prog=self._prog)\n+        for name in list(params):\n+            if params[name] is SUPPRESS:\n+                del params[name]\n+        for name in list(params):\n+            if hasattr(params[name], '__name__'):\n+                params[name] = params[name].__name__\n+        if params.get('choices') is not None:\n+            choices_str = ', '.join([str(c) for c in params['choices']])\n+            params['choices'] = choices_str\n+        return self._get_help_string(action) % params\n+\n+    def _iter_indented_subactions(self, action):\n+        try:\n+            get_subactions = action._get_subactions\n+        except AttributeError:\n+            pass\n+        else:\n+            self._indent()\n+            for subaction in get_subactions():\n+                yield subaction\n+            self._dedent()\n+\n+    def _split_lines(self, text, width):\n+        text = self._whitespace_matcher.sub(' ', text).strip()\n+        return _textwrap.wrap(text, width)\n+\n+    def _fill_text(self, text, width, indent):\n+        text = self._whitespace_matcher.sub(' ', text).strip()\n+        return _textwrap.fill(text, width, initial_indent=indent,\n+                                           subsequent_indent=indent)\n+\n+    def _get_help_string(self, action):\n+        return action.help\n+\n+\n+class RawDescriptionHelpFormatter(HelpFormatter):\n+    \"\"\"Help message formatter which retains any formatting in descriptions.\n+\n+    Only the name of this class is considered a public API. All the methods\n+    provided by the class are considered an implementation detail.\n+    \"\"\"\n+\n+    def _fill_text(self, text, width, indent):\n+        return ''.join([indent + line for line in text.splitlines(True)])\n+\n+\n+class RawTextHelpFormatter(RawDescriptionHelpFormatter):\n+    \"\"\"Help message formatter which retains formatting of all help text.\n+\n+    Only the name of this class is considered a public API. All the methods\n+    provided by the class are considered an implementation detail.\n+    \"\"\"\n+\n+    def _split_lines(self, text, width):\n+        return text.splitlines()\n+\n+\n+class ArgumentDefaultsHelpFormatter(HelpFormatter):\n+    \"\"\"Help message formatter which adds default values to argument help.\n+\n+    Only the name of this class is considered a public API. All the methods\n+    provided by the class are considered an implementation detail.\n+    \"\"\"\n+\n+    def _get_help_string(self, action):\n+        help = action.help\n+        if '%(default)' not in action.help:\n+            if action.default is not SUPPRESS:\n+                defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]\n+                if action.option_strings or action.nargs in defaulting_nargs:\n+                    help += ' (default: %(default)s)'\n+        return help\n+\n+\n+# =====================\n+# Options and Arguments\n+# =====================\n+\n+def _get_action_name(argument):\n+    if argument is None:\n+        return None\n+    elif argument.option_strings:\n+        return  '/'.join(argument.option_strings)\n+    elif argument.metavar not in (None, SUPPRESS):\n+        return argument.metavar\n+    elif argument.dest not in (None, SUPPRESS):\n+        return argument.dest\n+    else:\n+        return None\n+\n+\n+class ArgumentError(Exception):\n+    \"\"\"An error from creating or using an argument (optional or positional).\n+\n+    The string value of this exception is the message, augmented with\n+    information about the argument that caused it.\n+    \"\"\"\n+\n+    def __init__(self, argument, message):\n+        self.argument_name = _get_action_name(argument)\n+        self.message = message\n+\n+    def __str__(self):\n+        if self.argument_name is None:\n+            format = '%(message)s'\n+        else:\n+            format = 'argument %(argument_name)s: %(message)s'\n+        return format % dict(message=self.message,\n+                             argument_name=self.argument_name)\n+\n+\n+class ArgumentTypeError(Exception):\n+    \"\"\"An error from trying to convert a command line string to a type.\"\"\"\n+    pass\n+\n+\n+# ==============\n+# Action classes\n+# ==============\n+\n+class Action(_AttributeHolder):\n+    \"\"\"Information about how to convert command line strings to Python objects.\n+\n+    Action objects are used by an ArgumentParser to represent the information\n+    needed to parse a single argument from one or more strings from the\n+    command line. The keyword arguments to the Action constructor are also\n+    all attributes of Action instances.\n+\n+    Keyword Arguments:\n+\n+        - option_strings -- A list of command-line option strings which\n+            should be associated with this action.\n+\n+        - dest -- The name of the attribute to hold the created object(s)\n+\n+        - nargs -- The number of command-line arguments that should be\n+            consumed. By default, one argument will be consumed and a single\n+            value will be produced.  Other values include:\n+                - N (an integer) consumes N arguments (and produces a list)\n+                - '?' consumes zero or one arguments\n+                - '*' consumes zero or more arguments (and produces a list)\n+                - '+' consumes one or more arguments (and produces a list)\n+            Note that the difference between the default and nargs=1 is that\n+            with the default, a single value will be produced, while with\n+            nargs=1, a list containing a single value will be produced.\n+\n+        - const -- The value to be produced if the option is specified and the\n+            option uses an action that takes no values.\n+\n+        - default -- The value to be produced if the option is not specified.\n+\n+        - type -- The type which the command-line arguments should be converted\n+            to, should be one of 'string', 'int', 'float', 'complex' or a\n+            callable object that accepts a single string argument. If None,\n+            'string' is assumed.\n+\n+        - choices -- A container of values that should be allowed. If not None,\n+            after a command-line argument has been converted to the appropriate\n+            type, an exception will be raised if it is not a member of this\n+            collection.\n+\n+        - required -- True if the action must always be specified at the\n+            command line. This is only meaningful for optional command-line\n+            arguments.\n+\n+        - help -- The help string describing the argument.\n+\n+        - metavar -- The name to be used for the option's argument with the\n+            help string. If None, the 'dest' value will be used as the name.\n+    \"\"\"\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 nargs=None,\n+                 const=None,\n+                 default=None,\n+                 type=None,\n+                 choices=None,\n+                 required=False,\n+                 help=None,\n+                 metavar=None):\n+        self.option_strings = option_strings\n+        self.dest = dest\n+        self.nargs = nargs\n+        self.const = const\n+        self.default = default\n+        self.type = type\n+        self.choices = choices\n+        self.required = required\n+        self.help = help\n+        self.metavar = metavar\n+\n+    def _get_kwargs(self):\n+        names = [\n+            'option_strings',\n+            'dest',\n+            'nargs',\n+            'const',\n+            'default',\n+            'type',\n+            'choices',\n+            'help',\n+            'metavar',\n+        ]\n+        return [(name, getattr(self, name)) for name in names]\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        raise NotImplementedError(_('.__call__() not defined'))\n+\n+\n+class _StoreAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 nargs=None,\n+                 const=None,\n+                 default=None,\n+                 type=None,\n+                 choices=None,\n+                 required=False,\n+                 help=None,\n+                 metavar=None):\n+        if nargs == 0:\n+            raise ValueError('nargs for store actions must be > 0; if you '\n+                             'have nothing to store, actions such as store '\n+                             'true or store const may be more appropriate')\n+        if const is not None and nargs != OPTIONAL:\n+            raise ValueError('nargs must be %r to supply const' % OPTIONAL)\n+        super(_StoreAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            nargs=nargs,\n+            const=const,\n+            default=default,\n+            type=type,\n+            choices=choices,\n+            required=required,\n+            help=help,\n+            metavar=metavar)\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        setattr(namespace, self.dest, values)\n+\n+\n+class _StoreConstAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 const,\n+                 default=None,\n+                 required=False,\n+                 help=None,\n+                 metavar=None):\n+        super(_StoreConstAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            nargs=0,\n+            const=const,\n+            default=default,\n+            required=required,\n+            help=help)\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        setattr(namespace, self.dest, self.const)\n+\n+\n+class _StoreTrueAction(_StoreConstAction):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 default=False,\n+                 required=False,\n+                 help=None):\n+        super(_StoreTrueAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            const=True,\n+            default=default,\n+            required=required,\n+            help=help)\n+\n+\n+class _StoreFalseAction(_StoreConstAction):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 default=True,\n+                 required=False,\n+                 help=None):\n+        super(_StoreFalseAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            const=False,\n+            default=default,\n+            required=required,\n+            help=help)\n+\n+\n+class _AppendAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 nargs=None,\n+                 const=None,\n+                 default=None,\n+                 type=None,\n+                 choices=None,\n+                 required=False,\n+                 help=None,\n+                 metavar=None):\n+        if nargs == 0:\n+            raise ValueError('nargs for append actions must be > 0; if arg '\n+                             'strings are not supplying the value to append, '\n+                             'the append const action may be more appropriate')\n+        if const is not None and nargs != OPTIONAL:\n+            raise ValueError('nargs must be %r to supply const' % OPTIONAL)\n+        super(_AppendAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            nargs=nargs,\n+            const=const,\n+            default=default,\n+            type=type,\n+            choices=choices,\n+            required=required,\n+            help=help,\n+            metavar=metavar)\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        items = _copy.copy(_ensure_value(namespace, self.dest, []))\n+        items.append(values)\n+        setattr(namespace, self.dest, items)\n+\n+\n+class _AppendConstAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 const,\n+                 default=None,\n+                 required=False,\n+                 help=None,\n+                 metavar=None):\n+        super(_AppendConstAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            nargs=0,\n+            const=const,\n+            default=default,\n+            required=required,\n+            help=help,\n+            metavar=metavar)\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        items = _copy.copy(_ensure_value(namespace, self.dest, []))\n+        items.append(self.const)\n+        setattr(namespace, self.dest, items)\n+\n+\n+class _CountAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest,\n+                 default=None,\n+                 required=False,\n+                 help=None):\n+        super(_CountAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            nargs=0,\n+            default=default,\n+            required=required,\n+            help=help)\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        new_count = _ensure_value(namespace, self.dest, 0) + 1\n+        setattr(namespace, self.dest, new_count)\n+\n+\n+class _HelpAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 dest=SUPPRESS,\n+                 default=SUPPRESS,\n+                 help=None):\n+        super(_HelpAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            default=default,\n+            nargs=0,\n+            help=help)\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        parser.print_help()\n+        parser.exit()\n+\n+\n+class _VersionAction(Action):\n+\n+    def __init__(self,\n+                 option_strings,\n+                 version=None,\n+                 dest=SUPPRESS,\n+                 default=SUPPRESS,\n+                 help=\"show program's version number and exit\"):\n+        super(_VersionAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            default=default,\n+            nargs=0,\n+            help=help)\n+        self.version = version\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        version = self.version\n+        if version is None:\n+            version = parser.version\n+        formatter = parser._get_formatter()\n+        formatter.add_text(version)\n+        parser.exit(message=formatter.format_help())\n+\n+\n+class _SubParsersAction(Action):\n+\n+    class _ChoicesPseudoAction(Action):\n+\n+        def __init__(self, name, aliases, help):\n+            metavar = dest = name\n+            if aliases:\n+                metavar += ' (%s)' % ', '.join(aliases)\n+            sup = super(_SubParsersAction._ChoicesPseudoAction, self)\n+            sup.__init__(option_strings=[], dest=dest, help=help,\n+                        metavar=metavar)\n+\n+    def __init__(self,\n+                 option_strings,\n+                 prog,\n+                 parser_class,\n+                 dest=SUPPRESS,\n+                 help=None,\n+                 metavar=None):\n+\n+        self._prog_prefix = prog\n+        self._parser_class = parser_class\n+        self._name_parser_map = {}\n+        self._choices_actions = []\n+\n+        super(_SubParsersAction, self).__init__(\n+            option_strings=option_strings,\n+            dest=dest,\n+            nargs=PARSER,\n+            choices=self._name_parser_map,\n+            help=help,\n+            metavar=metavar)\n+\n+    def add_parser(self, name, **kwargs):\n+        # set prog from the existing prefix\n+        if kwargs.get('prog') is None:\n+            kwargs['prog'] = '%s %s' % (self._prog_prefix, name)\n+\n+        aliases = kwargs.pop('aliases', ())\n+\n+        # create a pseudo-action to hold the choice help\n+        if 'help' in kwargs:\n+            help = kwargs.pop('help')\n+            choice_action = self._ChoicesPseudoAction(name, aliases, help)\n+            self._choices_actions.append(choice_action)\n+\n+        # create the parser and add it to the map\n+        parser = self._parser_class(**kwargs)\n+        self._name_parser_map[name] = parser\n+\n+        # make parser available under aliases also\n+        for alias in aliases:\n+            self._name_parser_map[alias] = parser\n+\n+        return parser\n+\n+    def _get_subactions(self):\n+        return self._choices_actions\n+\n+    def __call__(self, parser, namespace, values, option_string=None):\n+        parser_name = values[0]\n+        arg_strings = values[1:]\n+\n+        # set the parser name if requested\n+        if self.dest is not SUPPRESS:\n+            setattr(namespace, self.dest, parser_name)\n+\n+        # select the parser\n+        try:\n+            parser = self._name_parser_map[parser_name]\n+        except KeyError:\n+            tup = parser_name, ', '.join(self._name_parser_map)\n+            msg = _('unknown parser %r (choices: %s)' % tup)\n+            raise ArgumentError(self, msg)\n+\n+        # parse all the remaining options into the namespace\n+        # store any unrecognized options on the object, so that the top\n+        # level parser can decide what to do with them\n+        namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)\n+        if arg_strings:\n+            vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])\n+            getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)\n+\n+\n+# ==============\n+# Type classes\n+# ==============\n+\n+class FileType(object):\n+    \"\"\"Factory for creating file object types\n+\n+    Instances of FileType are typically passed as type= arguments to the\n+    ArgumentParser add_argument() method.\n+\n+    Keyword Arguments:\n+        - mode -- A string indicating how the file is to be opened. Accepts the\n+            same values as the builtin open() function.\n+        - bufsize -- The file's desired buffer size. Accepts the same values as\n+            the builtin open() function.\n+    \"\"\"\n+\n+    def __init__(self, mode='r', bufsize=None):\n+        self._mode = mode\n+        self._bufsize = bufsize\n+\n+    def __call__(self, string):\n+        # the special argument \"-\" means sys.std{in,out}\n+        if string == '-':\n+            if 'r' in self._mode:\n+                return _sys.stdin\n+            elif 'w' in self._mode:\n+                return _sys.stdout\n+            else:\n+                msg = _('argument \"-\" with mode %r' % self._mode)\n+                raise ValueError(msg)\n+\n+        try:\n+            # all other arguments are used as file names\n+            if self._bufsize:\n+                return open(string, self._mode, self._bufsize)\n+            else:\n+                return open(string, self._mode)\n+        except IOError:\n+            err = _sys.exc_info()[1]\n+            message = _(\"can't open '%s': %s\")\n+            raise ArgumentTypeError(message % (string, err))\n+\n+    def __repr__(self):\n+        args = [self._mode, self._bufsize]\n+        args_str = ', '.join([repr(arg) for arg in args if arg is not None])\n+        return '%s(%s)' % (type(self).__name__, args_str)\n+\n+# ===========================\n+# Optional and Positional Parsing\n+# ===========================\n+\n+class Namespace(_AttributeHolder):\n+    \"\"\"Simple object for storing attributes.\n+\n+    Implements equality by attribute names and values, and provides a simple\n+    string representation.\n+    \"\"\"\n+\n+    def __init__(self, **kwargs):\n+        for name in kwargs:\n+            setattr(self, name, kwargs[name])\n+\n+    __hash__ = None\n+\n+    def __eq__(self, other):\n+        return vars(self) == vars(other)\n+\n+    def __ne__(self, other):\n+        return not (self == other)\n+\n+    def __contains__(self, key):\n+        return key in self.__dict__\n+\n+\n+class _ActionsContainer(object):\n+\n+    def __init__(self,\n+                 description,\n+                 prefix_chars,\n+                 argument_default,\n+                 conflict_handler):\n+        super(_ActionsContainer, self).__init__()\n+\n+        self.description = description\n+        self.argument_default = argument_default\n+        self.prefix_chars = prefix_chars\n+        self.conflict_handler = conflict_handler\n+\n+        # set up registries\n+        self._registries = {}\n+\n+        # register actions\n+        self.register('action', None, _StoreAction)\n+        self.register('action', 'store', _StoreAction)\n+        self.register('action', 'store_const', _StoreConstAction)\n+        self.register('action', 'store_true', _StoreTrueAction)\n+        self.register('action', 'store_false', _StoreFalseAction)\n+        self.register('action', 'append', _AppendAction)\n+        self.register('action', 'append_const', _AppendConstAction)\n+        self.register('action', 'count', _CountAction)\n+        self.register('action', 'help', _HelpAction)\n+        self.register('action', 'version', _VersionAction)\n+        self.register('action', 'parsers', _SubParsersAction)\n+\n+        # raise an exception if the conflict handler is invalid\n+        self._get_handler()\n+\n+        # action storage\n+        self._actions = []\n+        self._option_string_actions = {}\n+\n+        # groups\n+        self._action_groups = []\n+        self._mutually_exclusive_groups = []\n+\n+        # defaults storage\n+        self._defaults = {}\n+\n+        # determines whether an \"option\" looks like a negative number\n+        self._negative_number_matcher = _re.compile(r'^-\\d+$|^-\\d*\\.\\d+$')\n+\n+        # whether or not there are any optionals that look like negative\n+        # numbers -- uses a list so it can be shared and edited\n+        self._has_negative_number_optionals = []\n+\n+    # ====================\n+    # Registration methods\n+    # ====================\n+    def register(self, registry_name, value, object):\n+        registry = self._registries.setdefault(registry_name, {})\n+        registry[value] = object\n+\n+    def _registry_get(self, registry_name, value, default=None):\n+        return self._registries[registry_name].get(value, default)\n+\n+    # ==================================\n+    # Namespace default accessor methods\n+    # ==================================\n+    def set_defaults(self, **kwargs):\n+        self._defaults.update(kwargs)\n+\n+        # if these defaults match any existing arguments, replace\n+        # the previous default on the object with the new one\n+        for action in self._actions:\n+            if action.dest in kwargs:\n+                action.default = kwargs[action.dest]\n+\n+    def get_default(self, dest):\n+        for action in self._actions:\n+            if action.dest == dest and action.default is not None:\n+                return action.default\n+        return self._defaults.get(dest, None)\n+\n+\n+    # =======================\n+    # Adding argument actions\n+    # =======================\n+    def add_argument(self, *args, **kwargs):\n+        \"\"\"\n+        add_argument(dest, ..., name=value, ...)\n+        add_argument(option_string, option_string, ..., name=value, ...)\n+        \"\"\"\n+\n+        # if no positional args are supplied or only one is supplied and\n+        # it doesn't look like an option string, parse a positional\n+        # argument\n+        chars = self.prefix_chars\n+        if not args or len(args) == 1 and args[0][0] not in chars:\n+            if args and 'dest' in kwargs:\n+                raise ValueError('dest supplied twice for positional argument')\n+            kwargs = self._get_positional_kwargs(*args, **kwargs)\n+\n+        # otherwise, we're adding an optional argument\n+        else:\n+            kwargs = self._get_optional_kwargs(*args, **kwargs)\n+\n+        # if no default was supplied, use the parser-level default\n+        if 'default' not in kwargs:\n+            dest = kwargs['dest']\n+            if dest in self._defaults:\n+                kwargs['default'] = self._defaults[dest]\n+            elif self.argument_default is not None:\n+                kwargs['default'] = self.argument_default\n+\n+        # create the action object, and add it to the parser\n+        action_class = self._pop_action_class(kwargs)\n+        if not _callable(action_class):\n+            raise ValueError('unknown action \"%s\"' % action_class)\n+        action = action_class(**kwargs)\n+\n+        # raise an error if the action type is not callable\n+        type_func = self._registry_get('type', action.type, action.type)\n+        if not _callable(type_func):\n+            raise ValueError('%r is not callable' % type_func)\n+\n+        return self._add_action(action)\n+\n+    def add_argument_group(self, *args, **kwargs):\n+        group = _ArgumentGroup(self, *args, **kwargs)\n+        self._action_groups.append(group)\n+        return group\n+\n+    def add_mutually_exclusive_group(self, **kwargs):\n+        group = _MutuallyExclusiveGroup(self, **kwargs)\n+        self._mutually_exclusive_groups.append(group)\n+        return group\n+\n+    def _add_action(self, action):\n+        # resolve any conflicts\n+        self._check_conflict(action)\n+\n+        # add to actions list\n+        self._actions.append(action)\n+        action.container = self\n+\n+        # index the action by any option strings it has\n+        for option_string in action.option_strings:\n+            self._option_string_actions[option_string] = action\n+\n+        # set the flag if any option strings look like negative numbers\n+        for option_string in action.option_strings:\n+            if self._negative_number_matcher.match(option_string):\n+                if not self._has_negative_number_optionals:\n+                    self._has_negative_number_optionals.append(True)\n+\n+        # return the created action\n+        return action\n+\n+    def _remove_action(self, action):\n+        self._actions.remove(action)\n+\n+    def _add_container_actions(self, container):\n+        # collect groups by titles\n+        title_group_map = {}\n+        for group in self._action_groups:\n+            if group.title in title_group_map:\n+                msg = _('cannot merge actions - two groups are named %r')\n+                raise ValueError(msg % (group.title))\n+            title_group_map[group.title] = group\n+\n+        # map each action to its group\n+        group_map = {}\n+        for group in container._action_groups:\n+\n+            # if a group with the title exists, use that, otherwise\n+            # create a new group matching the container's group\n+            if group.title not in title_group_map:\n+                title_group_map[group.title] = self.add_argument_group(\n+                    title=group.title,\n+                    description=group.description,\n+                    conflict_handler=group.conflict_handler)\n+\n+            # map the actions to their new group\n+            for action in group._group_actions:\n+                group_map[action] = title_group_map[group.title]\n+\n+        # add container's mutually exclusive groups\n+        # NOTE: if add_mutually_exclusive_group ever gains title= and\n+        # description= then this code will need to be expanded as above\n+        for group in container._mutually_exclusive_groups:\n+            mutex_group = self.add_mutually_exclusive_group(\n+                required=group.required)\n+\n+            # map the actions to their new mutex group\n+            for action in group._group_actions:\n+                group_map[action] = mutex_group\n+\n+        # add all actions to this container or their group\n+        for action in container._actions:\n+            group_map.get(action, self)._add_action(action)\n+\n+    def _get_positional_kwargs(self, dest, **kwargs):\n+        # make sure required is not specified\n+        if 'required' in kwargs:\n+            msg = _(\"'required' is an invalid argument for positionals\")\n+            raise TypeError(msg)\n+\n+        # mark positional arguments as required if at least one is\n+        # always required\n+        if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]:\n+            kwargs['required'] = True\n+        if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs:\n+            kwargs['required'] = True\n+\n+        # return the keyword arguments with no option strings\n+        return dict(kwargs, dest=dest, option_strings=[])\n+\n+    def _get_optional_kwargs(self, *args, **kwargs):\n+        # determine short and long option strings\n+        option_strings = []\n+        long_option_strings = []\n+        for option_string in args:\n+            # error on strings that don't start with an appropriate prefix\n+            if not option_string[0] in self.prefix_chars:\n+                msg = _('invalid option string %r: '\n+                        'must start with a character %r')\n+                tup = option_string, self.prefix_chars\n+                raise ValueError(msg % tup)\n+\n+            # strings starting with two prefix characters are long options\n+            option_strings.append(option_string)\n+            if option_string[0] in self.prefix_chars:\n+                if len(option_string) > 1:\n+                    if option_string[1] in self.prefix_chars:\n+                        long_option_strings.append(option_string)\n+\n+        # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'\n+        dest = kwargs.pop('dest', None)\n+        if dest is None:\n+            if long_option_strings:\n+                dest_option_string = long_option_strings[0]\n+            else:\n+                dest_option_string = option_strings[0]\n+            dest = dest_option_string.lstrip(self.prefix_chars)\n+            if not dest:\n+                msg = _('dest= is required for options like %r')\n+                raise ValueError(msg % option_string)\n+            dest = dest.replace('-', '_')\n+\n+        # return the updated keyword arguments\n+        return dict(kwargs, dest=dest, option_strings=option_strings)\n+\n+    def _pop_action_class(self, kwargs, default=None):\n+        action = kwargs.pop('action', default)\n+        return self._registry_get('action', action, action)\n+\n+    def _get_handler(self):\n+        # determine function from conflict handler string\n+        handler_func_name = '_handle_conflict_%s' % self.conflict_handler\n+        try:\n+            return getattr(self, handler_func_name)\n+        except AttributeError:\n+            msg = _('invalid conflict_resolution value: %r')\n+            raise ValueError(msg % self.conflict_handler)\n+\n+    def _check_conflict(self, action):\n+\n+        # find all options that conflict with this option\n+        confl_optionals = []\n+        for option_string in action.option_strings:\n+            if option_string in self._option_string_actions:\n+                confl_optional = self._option_string_actions[option_string]\n+                confl_optionals.append((option_string, confl_optional))\n+\n+        # resolve any conflicts\n+        if confl_optionals:\n+            conflict_handler = self._get_handler()\n+            conflict_handler(action, confl_optionals)\n+\n+    def _handle_conflict_error(self, action, conflicting_actions):\n+        message = _('conflicting option string(s): %s')\n+        conflict_string = ', '.join([option_string\n+                                     for option_string, action\n+                                     in conflicting_actions])\n+        raise ArgumentError(action, message % conflict_string)\n+\n+    def _handle_conflict_resolve(self, action, conflicting_actions):\n+\n+        # remove all conflicting options\n+        for option_string, action in conflicting_actions:\n+\n+            # remove the conflicting option\n+            action.option_strings.remove(option_string)\n+            self._option_string_actions.pop(option_string, None)\n+\n+            # if the option now has no option string, remove it from the\n+            # container holding it\n+            if not action.option_strings:\n+                action.container._remove_action(action)\n+\n+\n+class _ArgumentGroup(_ActionsContainer):\n+\n+    def __init__(self, container, title=None, description=None, **kwargs):\n+        # add any missing keyword arguments by checking the container\n+        update = kwargs.setdefault\n+        update('conflict_handler', container.conflict_handler)\n+        update('prefix_chars', container.prefix_chars)\n+        update('argument_default', container.argument_default)\n+        super_init = super(_ArgumentGroup, self).__init__\n+        super_init(description=description, **kwargs)\n+\n+        # group attributes\n+        self.title = title\n+        self._group_actions = []\n+\n+        # share most attributes with the container\n+        self._registries = container._registries\n+        self._actions = container._actions\n+        self._option_string_actions = container._option_string_actions\n+        self._defaults = container._defaults\n+        self._has_negative_number_optionals = \\\n+            container._has_negative_number_optionals\n+\n+    def _add_action(self, action):\n+        action = super(_ArgumentGroup, self)._add_action(action)\n+        self._group_actions.append(action)\n+        return action\n+\n+    def _remove_action(self, action):\n+        super(_ArgumentGroup, self)._remove_action(action)\n+        self._group_actions.remove(action)\n+\n+\n+class _MutuallyExclusiveGroup(_ArgumentGroup):\n+\n+    def __init__(self, container, required=False):\n+        super(_MutuallyExclusiveGroup, self).__init__(container)\n+        self.required = required\n+        self._container = container\n+\n+    def _add_action(self, action):\n+        if action.required:\n+            msg = _('mutually exclusive arguments must be optional')\n+            raise ValueError(msg)\n+        action = self._container._add_action(action)\n+        self._group_actions.append(action)\n+        return action\n+\n+    def _remove_action(self, action):\n+        self._container._remove_action(action)\n+        self._group_actions.remove(action)\n+\n+\n+class ArgumentParser(_AttributeHolder, _ActionsContainer):\n+    \"\"\"Object for parsing command line strings into Python objects.\n+\n+    Keyword Arguments:\n+        - prog -- The name of the program (default: sys.argv[0])\n+        - usage -- A usage message (default: auto-generated from arguments)\n+        - description -- A description of what the program does\n+        - epilog -- Text following the argument descriptions\n+        - parents -- Parsers whose arguments should be copied into this one\n+        - formatter_class -- HelpFormatter class for printing help messages\n+        - prefix_chars -- Characters that prefix optional arguments\n+        - fromfile_prefix_chars -- Characters that prefix files containing\n+            additional arguments\n+        - argument_default -- The default value for all arguments\n+        - conflict_handler -- String indicating how to handle conflicts\n+        - add_help -- Add a -h/-help option\n+    \"\"\"\n+\n+    def __init__(self,\n+                 prog=None,\n+                 usage=None,\n+                 description=None,\n+                 epilog=None,\n+                 version=None,\n+                 parents=[],\n+                 formatter_class=HelpFormatter,\n+                 prefix_chars='-',\n+                 fromfile_prefix_chars=None,\n+                 argument_default=None,\n+                 conflict_handler='error',\n+                 add_help=True):\n+\n+        if version is not None:\n+            import warnings\n+            warnings.warn(\n+                \"\"\"The \"version\" argument to ArgumentParser is deprecated. \"\"\"\n+                \"\"\"Please use \"\"\"\n+                \"\"\"\"add_argument(..., action='version', version=\"N\", ...)\" \"\"\"\n+                \"\"\"instead\"\"\", DeprecationWarning)\n+\n+        superinit = super(ArgumentParser, self).__init__\n+        superinit(description=description,\n+                  prefix_chars=prefix_chars,\n+                  argument_default=argument_default,\n+                  conflict_handler=conflict_handler)\n+\n+        # default setting for prog\n+        if prog is None:\n+            prog = _os.path.basename(_sys.argv[0])\n+\n+        self.prog = prog\n+        self.usage = usage\n+        self.epilog = epilog\n+        self.version = version\n+        self.formatter_class = formatter_class\n+        self.fromfile_prefix_chars = fromfile_prefix_chars\n+        self.add_help = add_help\n+\n+        add_group = self.add_argument_group\n+        self._positionals = add_group(_('positional arguments'))\n+        self._optionals = add_group(_('optional arguments'))\n+        self._subparsers = None\n+\n+        # register types\n+        def identity(string):\n+            return string\n+        self.register('type', None, identity)\n+\n+        # add help and version arguments if necessary\n+        # (using explicit default to override global argument_default)\n+        if '-' in prefix_chars:\n+            default_prefix = '-'\n+        else:\n+            default_prefix = prefix_chars[0]\n+        if self.add_help:\n+            self.add_argument(\n+                default_prefix+'h', default_prefix*2+'help',\n+                action='help', default=SUPPRESS,\n+                help=_('show this help message and exit'))\n+        if self.version:\n+            self.add_argument(\n+                default_prefix+'v', default_prefix*2+'version',\n+                action='version', default=SUPPRESS,\n+                version=self.version,\n+                help=_(\"show program's version number and exit\"))\n+\n+        # add parent arguments and defaults\n+        for parent in parents:\n+            self._add_container_actions(parent)\n+            try:\n+                defaults = parent._defaults\n+            except AttributeError:\n+                pass\n+            else:\n+                self._defaults.update(defaults)\n+\n+    # =======================\n+    # Pretty __repr__ methods\n+    # =======================\n+    def _get_kwargs(self):\n+        names = [\n+            'prog',\n+            'usage',\n+            'description',\n+            'version',\n+            'formatter_class',\n+            'conflict_handler',\n+            'add_help',\n+        ]\n+        return [(name, getattr(self, name)) for name in names]\n+\n+    # ==================================\n+    # Optional/Positional adding methods\n+    # ==================================\n+    def add_subparsers(self, **kwargs):\n+        if self._subparsers is not None:\n+            self.error(_('cannot have multiple subparser arguments'))\n+\n+        # add the parser class to the arguments if it's not present\n+        kwargs.setdefault('parser_class', type(self))\n+\n+        if 'title' in kwargs or 'description' in kwargs:\n+            title = _(kwargs.pop('title', 'subcommands'))\n+            description = _(kwargs.pop('description', None))\n+            self._subparsers = self.add_argument_group(title, description)\n+        else:\n+            self._subparsers = self._positionals\n+\n+        # prog defaults to the usage message of this parser, skipping\n+        # optional arguments and with no \"usage:\" prefix\n+        if kwargs.get('prog') is None:\n+            formatter = self._get_formatter()\n+            positionals = self._get_positional_actions()\n+            groups = self._mutually_exclusive_groups\n+            formatter.add_usage(self.usage, positionals, groups, '')\n+            kwargs['prog'] = formatter.format_help().strip()\n+\n+        # create the parsers action and add it to the positionals list\n+        parsers_class = self._pop_action_class(kwargs, 'parsers')\n+        action = parsers_class(option_strings=[], **kwargs)\n+        self._subparsers._add_action(action)\n+\n+        # return the created parsers action\n+        return action\n+\n+    def _add_action(self, action):\n+        if action.option_strings:\n+            self._optionals._add_action(action)\n+        else:\n+            self._positionals._add_action(action)\n+        return action\n+\n+    def _get_optional_actions(self):\n+        return [action\n+                for action in self._actions\n+                if action.option_strings]\n+\n+    def _get_positional_actions(self):\n+        return [action\n+                for action in self._actions\n+                if not action.option_strings]\n+\n+    # =====================================\n+    # Command line argument parsing methods\n+    # =====================================\n+    def parse_args(self, args=None, namespace=None):\n+        args, argv = self.parse_known_args(args, namespace)\n+        if argv:\n+            msg = _('unrecognized arguments: %s')\n+            self.error(msg % ' '.join(argv))\n+        return args\n+\n+    def parse_known_args(self, args=None, namespace=None):\n+        # args default to the system args\n+        if args is None:\n+            args = _sys.argv[1:]\n+\n+        # default Namespace built from parser defaults\n+        if namespace is None:\n+            namespace = Namespace()\n+\n+        # add any action defaults that aren't present\n+        for action in self._actions:\n+            if action.dest is not SUPPRESS:\n+                if not hasattr(namespace, action.dest):\n+                    if action.default is not SUPPRESS:\n+                        setattr(namespace, action.dest, action.default)\n+\n+        # add any parser defaults that aren't present\n+        for dest in self._defaults:\n+            if not hasattr(namespace, dest):\n+                setattr(namespace, dest, self._defaults[dest])\n+\n+        # parse the arguments and exit if there are any errors\n+        try:\n+            namespace, args = self._parse_known_args(args, namespace)\n+            if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):\n+                args.extend(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR))\n+                delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)\n+            return namespace, args\n+        except ArgumentError:\n+            err = _sys.exc_info()[1]\n+            self.error(str(err))\n+\n+    def _parse_known_args(self, arg_strings, namespace):\n+        # replace arg strings that are file references\n+        if self.fromfile_prefix_chars is not None:\n+            arg_strings = self._read_args_from_files(arg_strings)\n+\n+        # map all mutually exclusive arguments to the other arguments\n+        # they can't occur with\n+        action_conflicts = {}\n+        for mutex_group in self._mutually_exclusive_groups:\n+            group_actions = mutex_group._group_actions\n+            for i, mutex_action in enumerate(mutex_group._group_actions):\n+                conflicts = action_conflicts.setdefault(mutex_action, [])\n+                conflicts.extend(group_actions[:i])\n+                conflicts.extend(group_actions[i + 1:])\n+\n+        # find all option indices, and determine the arg_string_pattern\n+        # which has an 'O' if there is an option at an index,\n+        # an 'A' if there is an argument, or a '-' if there is a '--'\n+        option_string_indices = {}\n+        arg_string_pattern_parts = []\n+        arg_strings_iter = iter(arg_strings)\n+        for i, arg_string in enumerate(arg_strings_iter):\n+\n+            # all args after -- are non-options\n+            if arg_string == '--':\n+                arg_string_pattern_parts.append('-')\n+                for arg_string in arg_strings_iter:\n+                    arg_string_pattern_parts.append('A')\n+\n+            # otherwise, add the arg to the arg strings\n+            # and note the index if it was an option\n+            else:\n+                option_tuple = self._parse_optional(arg_string)\n+                if option_tuple is None:\n+                    pattern = 'A'\n+                else:\n+                    option_string_indices[i] = option_tuple\n+                    pattern = 'O'\n+                arg_string_pattern_parts.append(pattern)\n+\n+        # join the pieces together to form the pattern\n+        arg_strings_pattern = ''.join(arg_string_pattern_parts)\n+\n+        # converts arg strings to the appropriate and then takes the action\n+        seen_actions = set()\n+        seen_non_default_actions = set()\n+\n+        def take_action(action, argument_strings, option_string=None):\n+            seen_actions.add(action)\n+            argument_values = self._get_values(action, argument_strings)\n+\n+            # error if this argument is not allowed with other previously\n+            # seen arguments, assuming that actions that use the default\n+            # value don't really count as \"present\"\n+            if argument_values is not action.default:\n+                seen_non_default_actions.add(action)\n+                for conflict_action in action_conflicts.get(action, []):\n+                    if conflict_action in seen_non_default_actions:\n+                        msg = _('not allowed with argument %s')\n+                        action_name = _get_action_name(conflict_action)\n+                        raise ArgumentError(action, msg % action_name)\n+\n+            # take the action if we didn't receive a SUPPRESS value\n+            # (e.g. from a default)\n+            if argument_values is not SUPPRESS:\n+                action(self, namespace, argument_values, option_string)\n+\n+        # function to convert arg_strings into an optional action\n+        def consume_optional(start_index):\n+\n+            # get the optional identified at this index\n+            option_tuple = option_string_indices[start_index]\n+            action, option_string, explicit_arg = option_tuple\n+\n+            # identify additional optionals in the same arg string\n+            # (e.g. -xyz is the same as -x -y -z if no args are required)\n+            match_argument = self._match_argument\n+            action_tuples = []\n+            while True:\n+\n+                # if we found no optional action, skip it\n+                if action is None:\n+                    extras.append(arg_strings[start_index])\n+                    return start_index + 1\n+\n+                # if there is an explicit argument, try to match the\n+                # optional's string arguments to only this\n+                if explicit_arg is not None:\n+                    arg_count = match_argument(action, 'A')\n+\n+                    # if the action is a single-dash option and takes no\n+                    # arguments, try to parse more single-dash options out\n+                    # of the tail of the option string\n+                    chars = self.prefix_chars\n+                    if arg_count == 0 and option_string[1] not in chars:\n+                        action_tuples.append((action, [], option_string))\n+                        char = option_string[0]\n+                        option_string = char + explicit_arg[0]\n+                        new_explicit_arg = explicit_arg[1:] or None\n+                        optionals_map = self._option_string_actions\n+                        if option_string in optionals_map:\n+                            action = optionals_map[option_string]\n+                            explicit_arg = new_explicit_arg\n+                        else:\n+                            msg = _('ignored explicit argument %r')\n+                            raise ArgumentError(action, msg % explicit_arg)\n+\n+                    # if the action expect exactly one argument, we've\n+                    # successfully matched the option; exit the loop\n+                    elif arg_count == 1:\n+                        stop = start_index + 1\n+                        args = [explicit_arg]\n+                        action_tuples.append((action, args, option_string))\n+                        break\n+\n+                    # error if a double-dash option did not use the\n+                    # explicit argument\n+                    else:\n+                        msg = _('ignored explicit argument %r')\n+                        raise ArgumentError(action, msg % explicit_arg)\n+\n+                # if there is no explicit argument, try to match the\n+                # optional's string arguments with the following strings\n+                # if successful, exit the loop\n+                else:\n+                    start = start_index + 1\n+                    selected_patterns = arg_strings_pattern[start:]\n+                    arg_count = match_argument(action, selected_patterns)\n+                    stop = start + arg_count\n+                    args = arg_strings[start:stop]\n+                    action_tuples.append((action, args, option_string))\n+                    break\n+\n+            # add the Optional to the list and return the index at which\n+            # the Optional's string args stopped\n+            assert action_tuples\n+            for action, args, option_string in action_tuples:\n+                take_action(action, args, option_string)\n+            return stop\n+\n+        # the list of Positionals left to be parsed; this is modified\n+        # by consume_positionals()\n+        positionals = self._get_positional_actions()\n+\n+        # function to convert arg_strings into positional actions\n+        def consume_positionals(start_index):\n+            # match as many Positionals as possible\n+            match_partial = self._match_arguments_partial\n+            selected_pattern = arg_strings_pattern[start_index:]\n+            arg_counts = match_partial(positionals, selected_pattern)\n+\n+            # slice off the appropriate arg strings for each Positional\n+            # and add the Positional and its args to the list\n+            for action, arg_count in zip(positionals, arg_counts):\n+                args = arg_strings[start_index: start_index + arg_count]\n+                start_index += arg_count\n+                take_action(action, args)\n+\n+            # slice off the Positionals that we just parsed and return the\n+            # index at which the Positionals' string args stopped\n+            positionals[:] = positionals[len(arg_counts):]\n+            return start_index\n+\n+        # consume Positionals and Optionals alternately, until we have\n+        # passed the last option string\n+        extras = []\n+        start_index = 0\n+        if option_string_indices:\n+            max_option_string_index = max(option_string_indices)\n+        else:\n+            max_option_string_index = -1\n+        while start_index <= max_option_string_index:\n+\n+            # consume any Positionals preceding the next option\n+            next_option_string_index = min([\n+                index\n+                for index in option_string_indices\n+                if index >= start_index])\n+            if start_index != next_option_string_index:\n+                positionals_end_index = consume_positionals(start_index)\n+\n+                # only try to parse the next optional if we didn't consume\n+                # the option string during the positionals parsing\n+                if positionals_end_index > start_index:\n+                    start_index = positionals_end_index\n+                    continue\n+                else:\n+                    start_index = positionals_end_index\n+\n+            # if we consumed all the positionals we could and we're not\n+            # at the index of an option string, there were extra arguments\n+            if start_index not in option_string_indices:\n+                strings = arg_strings[start_index:next_option_string_index]\n+                extras.extend(strings)\n+                start_index = next_option_string_index\n+\n+            # consume the next optional and any arguments for it\n+            start_index = consume_optional(start_index)\n+\n+        # consume any positionals following the last Optional\n+        stop_index = consume_positionals(start_index)\n+\n+        # if we didn't consume all the argument strings, there were extras\n+        extras.extend(arg_strings[stop_index:])\n+\n+        # if we didn't use all the Positional objects, there were too few\n+        # arg strings supplied.\n+        if positionals:\n+            self.error(_('too few arguments'))\n+\n+        # make sure all required actions were present, and convert defaults.\n+        for action in self._actions:\n+            if action not in seen_actions:\n+                if action.required:\n+                    name = _get_action_name(action)\n+                    self.error(_('argument %s is required') % name)\n+                else:\n+                    # Convert action default now instead of doing it before\n+                    # parsing arguments to avoid calling convert functions\n+                    # twice (which may fail) if the argument was given, but\n+                    # only if it was defined already in the namespace\n+                    if (action.default is not None and\n+                            isinstance(action.default, basestring) and\n+                            hasattr(namespace, action.dest) and\n+                            action.default is getattr(namespace, action.dest)):\n+                        setattr(namespace, action.dest,\n+                                self._get_value(action, action.default))\n+\n+        # make sure all required groups had one option present\n+        for group in self._mutually_exclusive_groups:\n+            if group.required:\n+                for action in group._group_actions:\n+                    if action in seen_non_default_actions:\n+                        break\n+\n+                # if no actions were used, report the error\n+                else:\n+                    names = [_get_action_name(action)\n+                             for action in group._group_actions\n+                             if action.help is not SUPPRESS]\n+                    msg = _('one of the arguments %s is required')\n+                    self.error(msg % ' '.join(names))\n+\n+        # return the updated namespace and the extra arguments\n+        return namespace, extras\n+\n+    def _read_args_from_files(self, arg_strings):\n+        # expand arguments referencing files\n+        new_arg_strings = []\n+        for arg_string in arg_strings:\n+\n+            # for regular arguments, just add them back into the list\n+            if arg_string[0] not in self.fromfile_prefix_chars:\n+                new_arg_strings.append(arg_string)\n+\n+            # replace arguments referencing files with the file content\n+            else:\n+                try:\n+                    args_file = open(arg_string[1:])\n+                    try:\n+                        arg_strings = []\n+                        for arg_line in args_file.read().splitlines():\n+                            for arg in self.convert_arg_line_to_args(arg_line):\n+                                arg_strings.append(arg)\n+                        arg_strings = self._read_args_from_files(arg_strings)\n+                        new_arg_strings.extend(arg_strings)\n+                    finally:\n+                        args_file.close()\n+                except IOError:\n+                    err = _sys.exc_info()[1]\n+                    self.error(str(err))\n+\n+        # return the modified argument list\n+        return new_arg_strings\n+\n+    def convert_arg_line_to_args(self, arg_line):\n+        return [arg_line]\n+\n+    def _match_argument(self, action, arg_strings_pattern):\n+        # match the pattern for this action to the arg strings\n+        nargs_pattern = self._get_nargs_pattern(action)\n+        match = _re.match(nargs_pattern, arg_strings_pattern)\n+\n+        # raise an exception if we weren't able to find a match\n+        if match is None:\n+            nargs_errors = {\n+                None: _('expected one argument'),\n+                OPTIONAL: _('expected at most one argument'),\n+                ONE_OR_MORE: _('expected at least one argument'),\n+            }\n+            default = _('expected %s argument(s)') % action.nargs\n+            msg = nargs_errors.get(action.nargs, default)\n+            raise ArgumentError(action, msg)\n+\n+        # return the number of arguments matched\n+        return len(match.group(1))\n+\n+    def _match_arguments_partial(self, actions, arg_strings_pattern):\n+        # progressively shorten the actions list by slicing off the\n+        # final actions until we find a match\n+        result = []\n+        for i in range(len(actions), 0, -1):\n+            actions_slice = actions[:i]\n+            pattern = ''.join([self._get_nargs_pattern(action)\n+                               for action in actions_slice])\n+            match = _re.match(pattern, arg_strings_pattern)\n+            if match is not None:\n+                result.extend([len(string) for string in match.groups()])\n+                break\n+\n+        # return the list of arg string counts\n+        return result\n+\n+    def _parse_optional(self, arg_string):\n+        # if it's an empty string, it was meant to be a positional\n+        if not arg_string:\n+            return None\n+\n+        # if it doesn't start with a prefix, it was meant to be positional\n+        if not arg_string[0] in self.prefix_chars:\n+            return None\n+\n+        # if the option string is present in the parser, return the action\n+        if arg_string in self._option_string_actions:\n+            action = self._option_string_actions[arg_string]\n+            return action, arg_string, None\n+\n+        # if it's just a single character, it was meant to be positional\n+        if len(arg_string) == 1:\n+            return None\n+\n+        # if the option string before the \"=\" is present, return the action\n+        if '=' in arg_string:\n+            option_string, explicit_arg = arg_string.split('=', 1)\n+            if option_string in self._option_string_actions:\n+                action = self._option_string_actions[option_string]\n+                return action, option_string, explicit_arg\n+\n+        # search through all possible prefixes of the option string\n+        # and all actions in the parser for possible interpretations\n+        option_tuples = self._get_option_tuples(arg_string)\n+\n+        # if multiple actions match, the option string was ambiguous\n+        if len(option_tuples) > 1:\n+            options = ', '.join([option_string\n+                for action, option_string, explicit_arg in option_tuples])\n+            tup = arg_string, options\n+            self.error(_('ambiguous option: %s could match %s') % tup)\n+\n+        # if exactly one action matched, this segmentation is good,\n+        # so return the parsed action\n+        elif len(option_tuples) == 1:\n+            option_tuple, = option_tuples\n+            return option_tuple\n+\n+        # if it was not found as an option, but it looks like a negative\n+        # number, it was meant to be positional\n+        # unless there are negative-number-like options\n+        if self._negative_number_matcher.match(arg_string):\n+            if not self._has_negative_number_optionals:\n+                return None\n+\n+        # if it contains a space, it was meant to be a positional\n+        if ' ' in arg_string:\n+            return None\n+\n+        # it was meant to be an optional but there is no such option\n+        # in this parser (though it might be a valid option in a subparser)\n+        return None, arg_string, None\n+\n+    def _get_option_tuples(self, option_string):\n+        result = []\n+\n+        # option strings starting with two prefix characters are only\n+        # split at the '='\n+        chars = self.prefix_chars\n+        if option_string[0] in chars and option_string[1] in chars:\n+            if '=' in option_string:\n+                option_prefix, explicit_arg = option_string.split('=', 1)\n+            else:\n+                option_prefix = option_string\n+                explicit_arg = None\n+            for option_string in self._option_string_actions:\n+                if option_string.startswith(option_prefix):\n+                    action = self._option_string_actions[option_string]\n+                    tup = action, option_string, explicit_arg\n+                    result.append(tup)\n+\n+        # single character options can be concatenated with their arguments\n+        # but multiple character options always have to have their argument\n+        # separate\n+        elif option_string[0] in chars and option_string[1] not in chars:\n+            option_prefix = option_string\n+            explicit_arg = None\n+            short_option_prefix = option_string[:2]\n+            short_explicit_arg = option_string[2:]\n+\n+            for option_string in self._option_string_actions:\n+                if option_string == short_option_prefix:\n+                    action = self._option_string_actions[option_string]\n+                    tup = action, option_string, short_explicit_arg\n+                    result.append(tup)\n+                elif option_string.startswith(option_prefix):\n+                    action = self._option_string_actions[option_string]\n+                    tup = action, option_string, explicit_arg\n+                    result.append(tup)\n+\n+        # shouldn't ever get here\n+        else:\n+            self.error(_('unexpected option string: %s') % option_string)\n+\n+        # return the collected option tuples\n+        return result\n+\n+    def _get_nargs_pattern(self, action):\n+        # in all examples below, we have to allow for '--' args\n+        # which are represented as '-' in the pattern\n+        nargs = action.nargs\n+\n+        # the default (None) is assumed to be a single argument\n+        if nargs is None:\n+            nargs_pattern = '(-*A-*)'\n+\n+        # allow zero or one arguments\n+        elif nargs == OPTIONAL:\n+            nargs_pattern = '(-*A?-*)'\n+\n+        # allow zero or more arguments\n+        elif nargs == ZERO_OR_MORE:\n+            nargs_pattern = '(-*[A-]*)'\n+\n+        # allow one or more arguments\n+        elif nargs == ONE_OR_MORE:\n+            nargs_pattern = '(-*A[A-]*)'\n+\n+        # allow any number of options or arguments\n+        elif nargs == REMAINDER:\n+            nargs_pattern = '([-AO]*)'\n+\n+        # allow one argument followed by any number of options or arguments\n+        elif nargs == PARSER:\n+            nargs_pattern = '(-*A[-AO]*)'\n+\n+        # all others should be integers\n+        else:\n+            nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)\n+\n+        # if this is an optional action, -- is not allowed\n+        if action.option_strings:\n+            nargs_pattern = nargs_pattern.replace('-*', '')\n+            nargs_pattern = nargs_pattern.replace('-', '')\n+\n+        # return the pattern\n+        return nargs_pattern\n+\n+    # ========================\n+    # Value conversion methods\n+    # ========================\n+    def _get_values(self, action, arg_strings):\n+        # for everything but PARSER args, strip out '--'\n+        if action.nargs not in [PARSER, REMAINDER]:\n+            arg_strings = [s for s in arg_strings if s != '--']\n+\n+        # optional argument produces a default when not present\n+        if not arg_strings and action.nargs == OPTIONAL:\n+            if action.option_strings:\n+                value = action.const\n+            else:\n+                value = action.default\n+            if isinstance(value, basestring):\n+                value = self._get_value(action, value)\n+                self._check_value(action, value)\n+\n+        # when nargs='*' on a positional, if there were no command-line\n+        # args, use the default if it is anything other than None\n+        elif (not arg_strings and action.nargs == ZERO_OR_MORE and\n+              not action.option_strings):\n+            if action.default is not None:\n+                value = action.default\n+            else:\n+                value = arg_strings\n+            self._check_value(action, value)\n+\n+        # single argument or optional argument produces a single value\n+        elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:\n+            arg_string, = arg_strings\n+            value = self._get_value(action, arg_string)\n+            self._check_value(action, value)\n+\n+        # REMAINDER arguments convert all values, checking none\n+        elif action.nargs == REMAINDER:\n+            value = [self._get_value(action, v) for v in arg_strings]\n+\n+        # PARSER arguments convert all values, but check only the first\n+        elif action.nargs == PARSER:\n+            value = [self._get_value(action, v) for v in arg_strings]\n+            self._check_value(action, value[0])\n+\n+        # all other types of nargs produce a list\n+        else:\n+            value = [self._get_value(action, v) for v in arg_strings]\n+            for v in value:\n+                self._check_value(action, v)\n+\n+        # return the converted value\n+        return value\n+\n+    def _get_value(self, action, arg_string):\n+        type_func = self._registry_get('type', action.type, action.type)\n+        if not _callable(type_func):\n+            msg = _('%r is not callable')\n+            raise ArgumentError(action, msg % type_func)\n+\n+        # convert the value to the appropriate type\n+        try:\n+            result = type_func(arg_string)\n+\n+        # ArgumentTypeErrors indicate errors\n+        except ArgumentTypeError:\n+            name = getattr(action.type, '__name__', repr(action.type))\n+            msg = str(_sys.exc_info()[1])\n+            raise ArgumentError(action, msg)\n+\n+        # TypeErrors or ValueErrors also indicate errors\n+        except (TypeError, ValueError):\n+            name = getattr(action.type, '__name__', repr(action.type))\n+            msg = _('invalid %s value: %r')\n+            raise ArgumentError(action, msg % (name, arg_string))\n+\n+        # return the converted value\n+        return result\n+\n+    def _check_value(self, action, value):\n+        # converted value must be one of the choices (if specified)\n+        if action.choices is not None and value not in action.choices:\n+            tup = value, ', '.join(map(repr, action.choices))\n+            msg = _('invalid choice: %r (choose from %s)') % tup\n+            raise ArgumentError(action, msg)\n+\n+    # =======================\n+    # Help-formatting methods\n+    # =======================\n+    def format_usage(self):\n+        formatter = self._get_formatter()\n+        formatter.add_usage(self.usage, self._actions,\n+                            self._mutually_exclusive_groups)\n+        return formatter.format_help()\n+\n+    def format_help(self):\n+        formatter = self._get_formatter()\n+\n+        # usage\n+        formatter.add_usage(self.usage, self._actions,\n+                            self._mutually_exclusive_groups)\n+\n+        # description\n+        formatter.add_text(self.description)\n+\n+        # positionals, optionals and user-defined groups\n+        for action_group in self._action_groups:\n+            formatter.start_section(action_group.title)\n+            formatter.add_text(action_group.description)\n+            formatter.add_arguments(action_group._group_actions)\n+            formatter.end_section()\n+\n+        # epilog\n+        formatter.add_text(self.epilog)\n+\n+        # determine help from format above\n+        return formatter.format_help()\n+\n+    def format_version(self):\n+        import warnings\n+        warnings.warn(\n+            'The format_version method is deprecated -- the \"version\" '\n+            'argument to ArgumentParser is no longer supported.',\n+            DeprecationWarning)\n+        formatter = self._get_formatter()\n+        formatter.add_text(self.version)\n+        return formatter.format_help()\n+\n+    def _get_formatter(self):\n+        return self.formatter_class(prog=self.prog)\n+\n+    # =====================\n+    # Help-printing methods\n+    # =====================\n+    def print_usage(self, file=None):\n+        if file is None:\n+            file = _sys.stdout\n+        self._print_message(self.format_usage(), file)\n+\n+    def print_help(self, file=None):\n+        if file is None:\n+            file = _sys.stdout\n+        self._print_message(self.format_help(), file)\n+\n+    def print_version(self, file=None):\n+        import warnings\n+        warnings.warn(\n+            'The print_version method is deprecated -- the \"version\" '\n+            'argument to ArgumentParser is no longer supported.',\n+            DeprecationWarning)\n+        self._print_message(self.format_version(), file)\n+\n+    def _print_message(self, message, file=None):\n+        if message:\n+            if file is None:\n+                file = _sys.stderr\n+            file.write(message)\n+\n+    # ===============\n+    # Exiting methods\n+    # ===============\n+    def exit(self, status=0, message=None):\n+        if message:\n+            self._print_message(message, _sys.stderr)\n+        _sys.exit(status)\n+\n+    def error(self, message):\n+        \"\"\"error(message: string)\n+\n+        Prints a usage message incorporating the message to stderr and\n+        exits.\n+\n+        If you override this in a subclass, it should not return -- it\n+        should either exit or raise an exception.\n+        \"\"\"\n+        self.print_usage(_sys.stderr)\n+        self.exit(2, _('%s: error: %s\\n') % (self.prog, message))\n",
    "prefixes": [
        "PULL",
        "for-2.10",
        "11/15"
    ]
}