From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mail.openembedded.org (Postfix) with ESMTP id 020DB731FB for ; Tue, 19 Jan 2016 18:48:52 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 19 Jan 2016 10:48:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,318,1449561600"; d="scan'208";a="32428162" Received: from linux.intel.com ([10.23.219.25]) by fmsmga004.fm.intel.com with ESMTP; 19 Jan 2016 10:48:52 -0800 Received: from vmed.fi.intel.com (vmed.fi.intel.com [10.237.72.51]) by linux.intel.com (Postfix) with ESMTP id 4C2C32C8001 for ; Tue, 19 Jan 2016 11:36:48 -0800 (PST) From: Ed Bartosh To: openembedded-core@lists.openembedded.org Date: Tue, 19 Jan 2016 18:51:08 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [wic][PATCH v2 6/9] wic: implement search of includes X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2016 18:48:54 -0000 Used custom argument type to implement search of include .wks files in canned wks paths. Include files can be specified either by full path or by name. [YOCTO #8848] Signed-off-by: Ed Bartosh --- scripts/lib/wic/ksparser.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py index c73a456..3722799 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py @@ -25,11 +25,12 @@ # Ed Bartosh (at] linux.intel.com> - +import os import shlex from argparse import ArgumentParser, ArgumentError, ArgumentTypeError from wic.partition import Partition +from wic.utils.misc import find_canned class KickStartError(Exception): pass @@ -78,6 +79,17 @@ def overheadtype(arg): return result +def cannedpathtype(arg): + """ + Custom type for ArgumentParser + Tries to find file in the list of canned wks paths + """ + scripts_path = os.path.abspath(os.path.dirname(__file__) + '../../..') + result = find_canned(scripts_path, arg) + if not result: + raise ArgumentTypeError("file not found: %s" % arg) + return result + class KickStart(object): def __init__(self, confpath): @@ -117,7 +129,7 @@ class KickStart(object): bootloader.add_argument('--source') include = subparsers.add_parser('include') - include.add_argument('path') + include.add_argument('path', type=cannedpathtype) self._parse(parser, confpath) -- 2.1.4