aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2015-11-26 23:08:53 -0500
committerTim Harder <radhermit@gmail.com>2015-11-26 23:08:53 -0500
commit50b3d254a53c7442e6a4507c8aa1463a295ac401 (patch)
treee19e95a1148369a232122e35d64fbc636d70a374
parentpinspect profile: check for invalid profile paths (diff)
downloadpkgcore-50b3d254a53c7442e6a4507c8aa1463a295ac401.tar.gz
pkgcore-50b3d254a53c7442e6a4507c8aa1463a295ac401.tar.bz2
pkgcore-50b3d254a53c7442e6a4507c8aa1463a295ac401.zip
pinspect profile: use arg validation phase instead of profile typing
Allows us to provide more succinct error output and is more extensible for future use.
-rw-r--r--pkgcore/ebuild/inspect_profile.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pkgcore/ebuild/inspect_profile.py b/pkgcore/ebuild/inspect_profile.py
index b1f5d7f9c..1bed50d95 100644
--- a/pkgcore/ebuild/inspect_profile.py
+++ b/pkgcore/ebuild/inspect_profile.py
@@ -22,19 +22,20 @@ commands = []
class _base(commandline.ArgparseCommand):
@staticmethod
- def profile(path):
- """Profile stack type for argparse"""
+ def _validate_args(parser, namespace):
+ path = namespace.profile
stack = profiles.ProfileStack(commandline.existent_path(path))
if stack.node.repoconfig is None:
- raise ValueError('invalid profile path')
- return stack
+ parser.only_error("invalid profile path: '%s'" % path)
+ namespace.profile = stack
def bind_to_parser(self, parser):
commandline.ArgparseCommand.bind_to_parser(self, parser)
- parser.add_argument("profile", help="path to the profile to inspect", type=self.profile)
+ parser.add_argument('profile', help='path to the profile to inspect')
name = self.__class__.__name__
kwds = {('_%s_suppress' % name): commandline.DelayedDefault.wipe(('domain'), 50)}
parser.set_defaults(**kwds)
+ parser.bind_final_check(self._validate_args)
self._subclass_bind(parser)
def _subclass_bind(self, parser):