summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKlauer, Daniel <Daniel.Klauer@gin.de>2016-05-17 12:59:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-19 09:05:18 +0100
commite44c849769088c0522872aff7408abae1797808f (patch)
tree1b5f20ec585d4c3a4ff81a717388102507b7db6a /meta/recipes-devtools
parentbe0cabf816a84c59e0e951b92a570121ed843822 (diff)
downloadpoky-e44c849769088c0522872aff7408abae1797808f.tar.gz
python-smartpm: Remove unnecessary error reporting improvement patch
The error reporting improvements were merged upstream (smartpm 406541f569) and refactored later (smartpm 20af0aac33), yet a part of the patch was kept here (oe-core 5fc580fc44). Due to the upstream refactoring the patch still applies cleanly, but it isn't actually needed. The added changes are duplicate or dead code. (From OE-Core rev: f1cfa9ab5d79198671275cea2c9864ce0cbcb9f0) Signed-off-by: Daniel Klauer <daniel.klauer@gin.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/python/python-smartpm/smart-improve-error-reporting.patch91
-rw-r--r--meta/recipes-devtools/python/python-smartpm_git.bb1
2 files changed, 0 insertions, 92 deletions
diff --git a/meta/recipes-devtools/python/python-smartpm/smart-improve-error-reporting.patch b/meta/recipes-devtools/python/python-smartpm/smart-improve-error-reporting.patch
deleted file mode 100644
index b82265b3ff..0000000000
--- a/meta/recipes-devtools/python/python-smartpm/smart-improve-error-reporting.patch
+++ /dev/null
@@ -1,91 +0,0 @@
1Improve error reporting in smart
2
3Add code to check proper command line arguments for various
4smart commands. Exit with error if erroneous/additional arguments
5are given in the command line.
6
7Upstream-Status: Pending
8
9Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
10
11diff --git a/smart/util/optparse.py b/smart/util/optparse.py
12index 6fff1bc..f445a3b 100644
13--- a/smart/util/optparse.py
14+++ b/smart/util/optparse.py
15@@ -70,6 +70,8 @@ import sys, os
16 import types
17 import textwrap
18 from gettext import gettext as _
19+from smart import Error
20+import re
21
22 def _repr(self):
23 return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self)
24@@ -710,6 +712,12 @@ class Option:
25 self.action, self.dest, opt, value, values, parser)
26
27 def take_action(self, action, dest, opt, value, values, parser):
28+ # Keep all the options in the command line in the '_given_opts' array
29+ # This will be used later to validate the command line
30+ given_opts = getattr(parser.values, "_given_opts", [])
31+ user_opt = re.sub(r"^\-*", "", opt).replace("-", "_")
32+ given_opts.append(user_opt)
33+ setattr(parser.values, "_given_opts", given_opts)
34 if action == "store":
35 setattr(values, dest, value)
36 elif action == "store_const":
37@@ -821,6 +829,54 @@ class Values:
38 setattr(self, attr, value)
39 return getattr(self, attr)
40
41+ # Check if the given option has the specified number of arguments
42+ # Raise an error if the option has an invalid number of arguments
43+ # A negative number for 'nargs' means "at least |nargs| arguments are needed"
44+ def check_args_of_option(self, opt, nargs, err=None):
45+ given_opts = getattr(self, "_given_opts", [])
46+ if not opt in given_opts:
47+ return
48+ values = getattr(self, opt, [])
49+ if type(values) != type([]):
50+ return
51+ if nargs < 0:
52+ nargs = -nargs
53+ if len(values) >= nargs:
54+ return
55+ if not err:
56+ if nargs == 1:
57+ err = _("Option '%s' requires at least one argument") % opt
58+ else:
59+ err = _("Option '%s' requires at least %d arguments") % (opt, nargs)
60+ raise Error, err
61+ elif nargs == 0:
62+ if len( values ) == 0:
63+ return
64+ raise Error, err
65+ else:
66+ if len(values) == nargs:
67+ return
68+ if not err:
69+ if nargs == 1:
70+ err = _("Option '%s' requires one argument") % opt
71+ else:
72+ err = _("Option '%s' requires %d arguments") % (opt, nargs)
73+ raise Error, err
74+
75+ # Check that at least one of the options in 'actlist' was given as an argument
76+ # to the command 'cmdname'
77+ def ensure_action(self, cmdname, actlist):
78+ given_opts = getattr(self, "_given_opts", [])
79+ for action in actlist:
80+ if action in given_opts:
81+ return
82+ raise Error, _("No action specified for command '%s'") % cmdname
83+
84+ # Check if there are any other arguments left after parsing the command line and
85+ # raise an error if such arguments are found
86+ def check_remaining_args(self):
87+ if self.args:
88+ raise Error, _("Invalid argument(s) '%s'" % str(self.args))
89
90 class OptionContainer:
91
diff --git a/meta/recipes-devtools/python/python-smartpm_git.bb b/meta/recipes-devtools/python/python-smartpm_git.bb
index 0d37dae3cb..5acfb0aa09 100644
--- a/meta/recipes-devtools/python/python-smartpm_git.bb
+++ b/meta/recipes-devtools/python/python-smartpm_git.bb
@@ -15,7 +15,6 @@ SRC_URI = "\
15 git://github.com/smartpm/smart.git \ 15 git://github.com/smartpm/smart.git \
16 file://smartpm-rpm5-nodig.patch \ 16 file://smartpm-rpm5-nodig.patch \
17 file://smart-recommends.patch \ 17 file://smart-recommends.patch \
18 file://smart-improve-error-reporting.patch \
19 file://smart-channelsdir.patch \ 18 file://smart-channelsdir.patch \
20 file://smart-rpm-transaction-failure-check.patch \ 19 file://smart-rpm-transaction-failure-check.patch \
21 file://smart-attempt.patch \ 20 file://smart-attempt.patch \