changeset 38986:60f7e9292ed8

parser: support license set
author Dmitry Selyutin <ghostmansd@gmail.com>
date Mon, 25 Sep 2017 23:19:03 +0300
parents ec4ec0591db4
children e7d09d75b382
files pygnulib/parser.py
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pygnulib/parser.py	Mon Sep 25 23:14:04 2017 +0300
+++ b/pygnulib/parser.py	Mon Sep 25 23:19:03 2017 +0300
@@ -8,6 +8,7 @@
 import enum as _enum_
 import os as _os_
 
+from .config import LicenseSet as _LicenseSet_
 from .error import CommandLineError as _CommandLineError_
 
 
@@ -200,10 +201,19 @@
 
 
     class _LicenseOption_(_Option_):
+        _TABLE_ = {
+            "2": ("LGPLv2", "LGPLv2+"),
+            "3": ("LGPLv2+", "LGPLv3", "LGPLv3+"),
+            "3orGPLv2": ("LGPLv2+", "LGPLv3+", "GPLv2"),
+        }
+
         def __call__(self, parser, namespace, value, option=None):
+            if value == "yes":
+                value = "3"
+            if value not in CommandLine._LicenseOption_._TABLE_.keys():
+                parser.__error("illegal --license argument value")
+            value = _LicenseSet_(CommandLine._LicenseOption_._TABLE_[value])
             args = (parser, namespace, value, option)
-            if value not in ("2", "3"):
-                parser.__error("illegal --license argument value")
             super().__call__(*args)
 
 
@@ -701,7 +711,8 @@
                         "the default is currently LGPLv3.",
                     ),
                     "action": _LicenseOption_,
-                    "metavar": "[=2|=3]",
+                    "dest": "license",
+                    "metavar": "[=2|=3orGPLv2|=3]",
                 }),
                 (["--makefile-name"], {
                     "help": (