From nobody Thu Mar 28 22:24:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59702+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59702+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1589579036; cv=none; d=zohomail.com; s=zohoarc; b=fiZC4ndiTj9zYjzKXp+CjPL0ixppDewEjiVvoOS2FnCWeRfHOWQFDQPwx5UBrghFG9jAHtP3RD4NWLADBEa1SapfE+KqD2QOoRggHo/Kpl2jElHy8sUkOdfwOaaa9o5WP8xakd3w45fg9yNsI3muthc34mGmgWp1gCC06uKJi3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589579036; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=tnXyhJxHxVsh4ZmGz51iN2l1eF8JKxj4ln3lL39M834=; b=UbDv8pNdqAnLBaeG5sqWLLmmU7+KM94fcfQUOqX+9ldNDS/lSk5juOTi+2k0R4v0n0J7C8A+gKVv1bUCYscG9F6+kxeaa8jcXvSqjD46jvKg15pb8gWQzrt07ZhyFjsJG1dJoGTH7noEzNh5UakZyVBEoYtcxj/c9ym4MsxoeDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59702+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589579036906154.459936674627; Fri, 15 May 2020 14:43:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id t4o3YY1788612xpB9TvLDRYH; Fri, 15 May 2020 14:43:56 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.1467.1589579035519069832 for ; Fri, 15 May 2020 14:43:55 -0700 IronPort-SDR: OIWQg1Sm4NOAq6/C8c3YVkUMtEMsOuU31hUAxMr0myk9KOhUjU8CyJoq94pFL1y9rSiMP5br9K oXjXKG/lLqMA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2020 14:43:54 -0700 IronPort-SDR: VsV5icqJp88/2pLOyy43C1H6voaAvec5V574Pgo+VFF36tEE3UTvAjO1ypq0mGKttOGgX2k0ah VAUZm7wh/Vag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,396,1583222400"; d="scan'208";a="410599848" X-Received: from ecbjorge-mobl1.amr.corp.intel.com ([10.212.5.228]) by orsmga004.jf.intel.com with ESMTP; 15 May 2020 14:43:53 -0700 From: "Bjorge, Erik C" To: devel@edk2.groups.io Cc: Ashley E Desimone , Nate DeSimone , Puja Pandya , Bret Barkelew , Prince Agyeman Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 1/2] EdkRepo: Normalize line endings Date: Fri, 15 May 2020 14:43:29 -0700 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,erik.c.bjorge@intel.com X-Gm-Message-State: e0VKaY6CBAuEdBNS1lKagPNZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589579036; bh=KAxIUaQ9CxBKwluDpCCow++0uzKwIaFP5qUCsqbOZFg=; h=Cc:Date:From:Reply-To:Subject:To; b=Flp2HleUZlZrPgusZbklgy7OPxt1cEj34y/yQK+auw/i7D9EcwHCME0qRjx6C096WhU Tb5M7k5UjjAuo2kE/W/G1VlQxd9ot2Z4m0MI93sRoxGqlQqlFWt247bRi0DVlwqScC38B 0/1p3yFuKU4MFnTcqpPfeJjEFqAPFTD2JCA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The file had mixed line endings. Normalized line endings to CRLF. Signed-off-by: Erik Bjorge Cc: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Bret Barkelew Cc: Prince Agyeman Cc: Erik Bjorge --- edkrepo_manifest_parser/edk_manifest.py | 2022 +++++++++++------------ 1 file changed, 1011 insertions(+), 1011 deletions(-) diff --git a/edkrepo_manifest_parser/edk_manifest.py b/edkrepo_manifest_par= ser/edk_manifest.py index 26535f8..480cd3f 100644 --- a/edkrepo_manifest_parser/edk_manifest.py +++ b/edkrepo_manifest_parser/edk_manifest.py @@ -1,198 +1,198 @@ -#!/usr/bin/env python3 -# -## @file -# edk_manifest.py -# -# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# - -# Standard imports -import xml.etree.ElementTree as ET -from collections import namedtuple -import os -import copy - -# 3rd party imports -# None planned at this time - - -# -# All the namedtuple data structures that consumers of this module will ne= ed. -# -ProjectInfo =3D namedtuple('ProjectInfo', ['codename', 'description', 'dev= _leads', 'reviewers', 'org', 'short_name']) -GeneralConfig =3D namedtuple('GeneralConfig', ['default_combo', 'current_c= ombo', 'pin_path', 'source_manifest_repo']) -RemoteRepo =3D namedtuple('RemoteRepo', ['name', 'url']) -RepoHook =3D namedtuple('RepoHook', ['source', 'dest_path', 'dest_file', '= remote_url']) -Combination =3D namedtuple('Combination', ['name', 'description']) -RepoSource =3D namedtuple('RepoSource', ['root', 'remote_name', 'remote_ur= l', 'branch', 'commit', 'sparse', - 'enable_submodule', 'tag']) - -SparseSettings =3D namedtuple('SparseSettings', ['sparse_by_default']) -SparseData =3D namedtuple('SparseData', ['combination', 'remote_name', 'al= ways_include', 'always_exclude']) - -FolderToFolderMapping =3D namedtuple('FolderToFolderMapping', ['project1',= 'project2', 'remote_name', 'folders']) -FolderToFolderMappingFolder =3D namedtuple('FolderToFolderMappingFolder', = ['project1_folder', 'project2_folder', - '= excludes']) -FolderToFolderMappingFolderExclude =3D namedtuple('FolderToFolderMappingFo= lderExclude', ['path']) - -SubmoduleAlternateRemote =3D namedtuple('SubmoduleAlternateRemote', ['remo= te_name', 'original_url', 'alternate_url']) +#!/usr/bin/env python3 +# +## @file +# edk_manifest.py +# +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +# Standard imports +import xml.etree.ElementTree as ET +from collections import namedtuple +import os +import copy + +# 3rd party imports +# None planned at this time + + +# +# All the namedtuple data structures that consumers of this module will ne= ed. +# +ProjectInfo =3D namedtuple('ProjectInfo', ['codename', 'description', 'dev= _leads', 'reviewers', 'org', 'short_name']) +GeneralConfig =3D namedtuple('GeneralConfig', ['default_combo', 'current_c= ombo', 'pin_path', 'source_manifest_repo']) +RemoteRepo =3D namedtuple('RemoteRepo', ['name', 'url']) +RepoHook =3D namedtuple('RepoHook', ['source', 'dest_path', 'dest_file', '= remote_url']) +Combination =3D namedtuple('Combination', ['name', 'description']) +RepoSource =3D namedtuple('RepoSource', ['root', 'remote_name', 'remote_ur= l', 'branch', 'commit', 'sparse', + 'enable_submodule', 'tag']) + +SparseSettings =3D namedtuple('SparseSettings', ['sparse_by_default']) +SparseData =3D namedtuple('SparseData', ['combination', 'remote_name', 'al= ways_include', 'always_exclude']) + +FolderToFolderMapping =3D namedtuple('FolderToFolderMapping', ['project1',= 'project2', 'remote_name', 'folders']) +FolderToFolderMappingFolder =3D namedtuple('FolderToFolderMappingFolder', = ['project1_folder', 'project2_folder', + '= excludes']) +FolderToFolderMappingFolderExclude =3D namedtuple('FolderToFolderMappingFo= lderExclude', ['path']) + +SubmoduleAlternateRemote =3D namedtuple('SubmoduleAlternateRemote', ['remo= te_name', 'original_url', 'alternate_url']) SubmoduleInitPath =3D namedtuple('SubmoduleInitPath', ['remote_name', 'com= bo', 'recursive', 'path']) - -REQUIRED_ATTRIB_ERROR_MSG =3D "Required attribute malformed in <{}>: {}" -NO_ASSOCIATED_REMOTE =3D 'There are no remotes associated with the ClientG= itHook entry:\nsource:{} destination:{}' \ - '\nThis hook will not be installed, updated or dele= ted.\n' -NO_REMOTE_EXISTS_WITH_NAME =3D 'There are no remotes with the name: {} lis= ted in the manifest file.' -PIN_COMB_ERROR =3D "Pin \"{}\" Pin did not have a single tag= ." -DUPLICATE_TAG_ERROR =3D "Duplicate <{}> tag not allowed: '{}' (Note: check= 's" -COMB_INVALIDINPUT_ERROR =3D "Invalid input: {} not found in 'combinations'= property" -COMB_UNKOWN_ERROR =3D "Could not find a Combination named '{}' in '{}'" -ATTRIBUTE_MISSING_ERROR =3D "Missing required attribute. Must specify eith= er 'branch' or 'commit' for each ." -GENERAL_CONFIG_MISSING_ERROR =3D "Unable to locate " -SOURCELIST_EMPTY_ERROR =3D "Invalid input: empty values in source list" -INVALID_PROJECTNAME_ERROR =3D "Invalid input: {} not found in CiIndexXml" -UNSUPPORTED_TYPE_ERROR =3D "{} is not a supported xml type: {}" -INVALID_XML_ERROR =3D "{} is not a valid xml file ({})" - - -class BaseXmlHelper(): - def __init__(self, fileref, xml_types): - self._fileref =3D fileref - try: - self._tree =3D ET.ElementTree(file=3Dfileref) # fileref can b= e a filename or filestream - except Exception as et_error: - raise TypeError(INVALID_XML_ERROR.format(fileref, et_error)) - - self._xml_type =3D self._tree.getroot().tag - if self._xml_type not in xml_types: - raise TypeError(UNSUPPORTED_TYPE_ERROR.format(fileref, self._x= ml_type)) - - -# -# This class will parse and the Index XML file and provide the data to th= e caller -# -class CiIndexXml(BaseXmlHelper): - def __init__(self, fileref): - super().__init__(fileref, 'ProjectList') - self._projects =3D {} - for element in self._tree.iter(tag=3D'Project'): - proj =3D _Project(element) - # Todo: add check for unique - self._projects[proj.name] =3D proj - - @property - def project_list(self): - proj_names =3D [] - for proj in self._projects.values(): - if proj.archived is False: - proj_names.append(proj.name) - return proj_names - - @property - def archived_project_list(self): - proj_names =3D [] - for proj in self._projects.values(): - if proj.archived is True: - proj_names.append(proj.name) - return proj_names - - def get_project_xml(self, project_name): - if project_name in self._projects: - return self._projects[project_name].xmlPath - else: - raise ValueError(INVALID_PROJECTNAME_ERROR.format(project_name= )) - - -class _Project(): - def __init__(self, element): - try: - self.name =3D element.attrib['name'] - self.xmlPath =3D element.attrib['xmlPath'] - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - try: - # if the archived attrib is not explicitly set to true, then a= ssume false - self.archived =3D (element.attrib['archived'].lower() =3D=3D '= true') - except Exception: - self.archived =3D False - - -# -# This class will parse and the manifest XML file and populate the named -# tuples defined above to provide abstracted access to the manifest data -# -class ManifestXml(BaseXmlHelper): - def __init__(self, fileref): - # Most of the attributes of this class are intended to be private = as they are used for - # internally gathering and storing the manifest data. As such, all= access to them should be - # done through the provided methods to ensure future compatibility= if the xml schema changes - super().__init__(fileref, ['Pin', 'Manifest']) - self._project_info =3D None - self._general_config =3D None - self._remotes =3D {} # dict of _Remote objs, wi= th Remote.name as key - self._client_hook_list =3D [] - self._combinations =3D {} # dict of _Combination obj= s, with Combination.name as key - self._combo_sources =3D {} # dict of _RepoSource obj = lists, with Combination.name as key - self._dsc_list =3D [] - self._sparse_settings =3D None # A single instance of pla= tform sparse checkout settings - self._sparse_data =3D [] # List of SparseData objec= ts - self._commit_templates =3D {} # dict of commit message t= emplates with the remote name as the key - self._folder_to_folder_mappings =3D [] # List of FolderToFolderMa= pping objects - self._submodule_alternate_remotes =3D [] + +REQUIRED_ATTRIB_ERROR_MSG =3D "Required attribute malformed in <{}>: {}" +NO_ASSOCIATED_REMOTE =3D 'There are no remotes associated with the ClientG= itHook entry:\nsource:{} destination:{}' \ + '\nThis hook will not be installed, updated or dele= ted.\n' +NO_REMOTE_EXISTS_WITH_NAME =3D 'There are no remotes with the name: {} lis= ted in the manifest file.' +PIN_COMB_ERROR =3D "Pin \"{}\" Pin did not have a single tag= ." +DUPLICATE_TAG_ERROR =3D "Duplicate <{}> tag not allowed: '{}' (Note: check= 's" +COMB_INVALIDINPUT_ERROR =3D "Invalid input: {} not found in 'combinations'= property" +COMB_UNKOWN_ERROR =3D "Could not find a Combination named '{}' in '{}'" +ATTRIBUTE_MISSING_ERROR =3D "Missing required attribute. Must specify eith= er 'branch' or 'commit' for each ." +GENERAL_CONFIG_MISSING_ERROR =3D "Unable to locate " +SOURCELIST_EMPTY_ERROR =3D "Invalid input: empty values in source list" +INVALID_PROJECTNAME_ERROR =3D "Invalid input: {} not found in CiIndexXml" +UNSUPPORTED_TYPE_ERROR =3D "{} is not a supported xml type: {}" +INVALID_XML_ERROR =3D "{} is not a valid xml file ({})" + + +class BaseXmlHelper(): + def __init__(self, fileref, xml_types): + self._fileref =3D fileref + try: + self._tree =3D ET.ElementTree(file=3Dfileref) # fileref can b= e a filename or filestream + except Exception as et_error: + raise TypeError(INVALID_XML_ERROR.format(fileref, et_error)) + + self._xml_type =3D self._tree.getroot().tag + if self._xml_type not in xml_types: + raise TypeError(UNSUPPORTED_TYPE_ERROR.format(fileref, self._x= ml_type)) + + +# +# This class will parse and the Index XML file and provide the data to th= e caller +# +class CiIndexXml(BaseXmlHelper): + def __init__(self, fileref): + super().__init__(fileref, 'ProjectList') + self._projects =3D {} + for element in self._tree.iter(tag=3D'Project'): + proj =3D _Project(element) + # Todo: add check for unique + self._projects[proj.name] =3D proj + + @property + def project_list(self): + proj_names =3D [] + for proj in self._projects.values(): + if proj.archived is False: + proj_names.append(proj.name) + return proj_names + + @property + def archived_project_list(self): + proj_names =3D [] + for proj in self._projects.values(): + if proj.archived is True: + proj_names.append(proj.name) + return proj_names + + def get_project_xml(self, project_name): + if project_name in self._projects: + return self._projects[project_name].xmlPath + else: + raise ValueError(INVALID_PROJECTNAME_ERROR.format(project_name= )) + + +class _Project(): + def __init__(self, element): + try: + self.name =3D element.attrib['name'] + self.xmlPath =3D element.attrib['xmlPath'] + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + try: + # if the archived attrib is not explicitly set to true, then a= ssume false + self.archived =3D (element.attrib['archived'].lower() =3D=3D '= true') + except Exception: + self.archived =3D False + + +# +# This class will parse and the manifest XML file and populate the named +# tuples defined above to provide abstracted access to the manifest data +# +class ManifestXml(BaseXmlHelper): + def __init__(self, fileref): + # Most of the attributes of this class are intended to be private = as they are used for + # internally gathering and storing the manifest data. As such, all= access to them should be + # done through the provided methods to ensure future compatibility= if the xml schema changes + super().__init__(fileref, ['Pin', 'Manifest']) + self._project_info =3D None + self._general_config =3D None + self._remotes =3D {} # dict of _Remote objs, wi= th Remote.name as key + self._client_hook_list =3D [] + self._combinations =3D {} # dict of _Combination obj= s, with Combination.name as key + self._combo_sources =3D {} # dict of _RepoSource obj = lists, with Combination.name as key + self._dsc_list =3D [] + self._sparse_settings =3D None # A single instance of pla= tform sparse checkout settings + self._sparse_data =3D [] # List of SparseData objec= ts + self._commit_templates =3D {} # dict of commit message t= emplates with the remote name as the key + self._folder_to_folder_mappings =3D [] # List of FolderToFolderMa= pping objects + self._submodule_alternate_remotes =3D [] self._submodule_init_list =3D [] - - # - # Append include XML's to the Manifest etree before parsing - # - tree_root =3D self._tree.getroot() - incl_path =3D os.path.dirname(os.path.abspath(fileref)) - for include_elem in self._tree.iter(tag=3D'Include'): - incl_file =3D os.path.join(incl_path, include_elem.attrib['xml= ']) - try: - include_tree =3D ET.ElementTree(file=3Dincl_file) - except Exception: - raise TypeError("{} is not a valid xml file".format(incl_f= ile)) - for elem in include_tree.iterfind('*'): - if elem.tag !=3D 'ProjectInfo' and elem.tag !=3D 'GeneralC= onfig': - tree_root.append(elem) - # remove include tags after added to etree to prevent feedback= issues - tree_root.remove(include_elem) - - # - # parse tags - # - for subroot in self._tree.iter(tag=3D'RemoteList'): - for element in subroot.iter(tag=3D'Remote'): - self._add_unique_item(_RemoteRepo(element), self._remotes,= element.tag) - - # - # parse tags - # - subroot =3D self._tree.find('ProjectInfo') - self._project_info =3D _ProjectInfo(subroot) - - # - # parse tags - # - subroot =3D self._tree.find('GeneralConfig') - self._general_config =3D _GeneralConfig(subroot) - - # - # parse tags - # requires RemoteList to be parsed first - # - for subroot in self._tree.iter(tag=3D'ClientGitHookList'): - for element in subroot.iter(tag=3D'ClientGitHook'): - self._client_hook_list.append(_RepoHook(element, self._rem= otes)) - - # - # Parse - # Requires RemoteList to be parsed first - # - for subroot in self._tree.iter(tag=3D'SubmoduleAlternateRemotes'): - for element in subroot.iter(tag=3D'SubmoduleAlternateRemote'): - self._submodule_alternate_remotes.append(_SubmoduleAlterna= teRemote(element, self._remotes)) - + + # + # Append include XML's to the Manifest etree before parsing + # + tree_root =3D self._tree.getroot() + incl_path =3D os.path.dirname(os.path.abspath(fileref)) + for include_elem in self._tree.iter(tag=3D'Include'): + incl_file =3D os.path.join(incl_path, include_elem.attrib['xml= ']) + try: + include_tree =3D ET.ElementTree(file=3Dincl_file) + except Exception: + raise TypeError("{} is not a valid xml file".format(incl_f= ile)) + for elem in include_tree.iterfind('*'): + if elem.tag !=3D 'ProjectInfo' and elem.tag !=3D 'GeneralC= onfig': + tree_root.append(elem) + # remove include tags after added to etree to prevent feedback= issues + tree_root.remove(include_elem) + + # + # parse tags + # + for subroot in self._tree.iter(tag=3D'RemoteList'): + for element in subroot.iter(tag=3D'Remote'): + self._add_unique_item(_RemoteRepo(element), self._remotes,= element.tag) + + # + # parse tags + # + subroot =3D self._tree.find('ProjectInfo') + self._project_info =3D _ProjectInfo(subroot) + + # + # parse tags + # + subroot =3D self._tree.find('GeneralConfig') + self._general_config =3D _GeneralConfig(subroot) + + # + # parse tags + # requires RemoteList to be parsed first + # + for subroot in self._tree.iter(tag=3D'ClientGitHookList'): + for element in subroot.iter(tag=3D'ClientGitHook'): + self._client_hook_list.append(_RepoHook(element, self._rem= otes)) + + # + # Parse + # Requires RemoteList to be parsed first + # + for subroot in self._tree.iter(tag=3D'SubmoduleAlternateRemotes'): + for element in subroot.iter(tag=3D'SubmoduleAlternateRemote'): + self._submodule_alternate_remotes.append(_SubmoduleAlterna= teRemote(element, self._remotes)) + # # Determine submodule initialization paths # @@ -200,201 +200,201 @@ class ManifestXml(BaseXmlHelper): for element in subroot.iter(tag=3D'Submodule'): self._submodule_init_list.append(_SubmoduleInitEntry(eleme= nt)) =20 - # - # parse tags - # requires RemoteList to be parsed first - # - if self._xml_type =3D=3D 'Pin': - combos =3D self._tree.findall('Combination') - if len(combos) !=3D 1: - raise KeyError(PIN_COMB_ERROR.format(fileref)) - - # container tag not required for pin files - if self._tree.find('CombinationList') is None: - combolist =3D ET.SubElement(tree_root, 'CombinationList') - combolist.append(combos[0]) - tree_root.remove(combos[0]) - - for subroot in self._tree.iter(tag=3D'CombinationList'): - for element in subroot.iter(tag=3D'Combination'): - combo =3D _Combination(element) - - # add the combo obj to the combinations and combo_sources = dicts - self._add_combo_source(element, combo) - - if self._xml_type =3D=3D 'Pin': - # done with Pin parsing at this point, so exit init - # remaining tag types are unique to manifest xml (for now...) - return - - # - # parse tags - # - for subroot in self._tree.iter(tag=3D'DscList'): - for element in subroot.iter(tag=3D'Dsc'): - self._dsc_list.append(element.text) - - # - # Process tag - # - subroot =3D self._tree.find('SparseCheckout') - if subroot is not None: - try: - self._sparse_settings =3D _SparseSettings(subroot.find('Sp= arseSettings')) - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, subroot= .tag)) - for sparse_data in subroot.iter(tag=3D'SparseData'): - self._sparse_data.append(_SparseData(sparse_data)) - - # - # Process any commit log templates that may exist (optional) - # - subroot =3D self._tree.find('CommitTemplates') - if subroot is not None: - for template_element in subroot.iter(tag=3D'Template'): - try: - remote_name =3D template_element.attrib['remoteName'] - template_text =3D template_element.text - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, sub= root.tag)) - self._commit_templates[remote_name] =3D template_text - - # - # Process tag - # - subroot =3D self._tree.find('FolderToFolderMappingList') - if subroot is not None: - for f2f_mapping in subroot.iter(tag=3D'FolderToFolderMapping'): - self._folder_to_folder_mappings.append(_FolderToFolderMapp= ing(f2f_mapping)) - - return - - def is_pin_file(self): - if self._xml_type =3D=3D 'Pin': - return True - else: - return False - - def add_combo(self, element): - self._tree.find('CombinationList').append(element) - combo =3D _Combination(element) - self._add_combo_source(element, combo) - - def _add_combo_source(self, subroot, combo): - # create a list of _RepoSource objs from the tags in subr= oot - # and add it to the __combo_sources dictionary - self._add_unique_item(combo, self._combinations, subroot.tag) - temp_sources =3D [] - for element in subroot.iter(tag=3D'Source'): - temp_sources.append(_RepoSource(element, self._remotes)) - self._combo_sources[combo.name] =3D temp_sources - - def _add_unique_item(self, obj, item_dict, tag): - # add the 'obj' to 'dict', or raise error if it already exists - if obj.name in item_dict: - raise KeyError(DUPLICATE_TAG_ERROR.format(tag, obj.name)) - item_dict[obj.name] =3D obj - - def _tuple_list(self, obj_list): - tuples =3D [] - for obj in obj_list: - tuples.append(obj.tuple) - return tuples - - # - # EdkManifestLib properties and methods - # These will convert the internal classes and attributes into the arch= itecurally - # defined lists and tuples that the caller is expecting. - # - @property - def project_info(self): - return self._project_info.tuple - - @property - def general_config(self): - return self._general_config.tuple - - @property - def remotes(self): - return self._tuple_list(self._remotes.values()) - - @property - def combinations(self): - return self._tuple_list([x for x in self._combinations.values() if= not x.archived]) - - @property - def archived_combinations(self): - return self._tuple_list([x for x in self._combinations.values() if= x.archived]) - - def get_repo_sources(self, combo_name): - if combo_name in self._combo_sources: - return self._tuple_list(self._combo_sources[combo_name]) - elif combo_name.startswith('Pin:'): - # If currently checked out onto a pin file reture the sources = in the - # default combo - return self._tuple_list(self._combo_sources[self.general_confi= g.default_combo]) - else: - raise ValueError(COMB_INVALIDINPUT_ERROR.format(combo_name)) - - @property - def repo_hooks(self): - return self._tuple_list(self._client_hook_list) - - @property - def dsc_list(self): - return self._dsc_list - - @property - def sparse_settings(self): - if self._sparse_settings: - return self._sparse_settings.tuple - return None - - @property - def sparse_data(self): - return self._tuple_list(self._sparse_data) - - @property - def folder_to_folder_mappings(self): - f2f_tuples =3D [] - for f2f_mapping in self._folder_to_folder_mappings: - folders =3D f2f_mapping.folders - folder_tuples =3D [] - for folder in folders: - f =3D copy.deepcopy(folder) - f.excludes =3D self._tuple_list(folder.excludes) - folder_tuples.append(f.tuple) - m =3D copy.deepcopy(f2f_mapping) - m.folders =3D folder_tuples - f2f_tuples.append(m.tuple) - return f2f_tuples - - @property - def current_combo(self): - return self.general_config.current_combo - - def get_combo_element(self, name): - combinations =3D self._tree.find('CombinationList') - for combo in combinations.iter(tag=3D'Combination'): - if combo.attrib['name'] =3D=3D name: - return copy.deepcopy(combo) - raise ValueError(COMB_UNKOWN_ERROR.format(name, self._fileref)) - - @property - def commit_templates(self): - return self._commit_templates - - @property - def submodule_alternate_remotes(self): - return self._tuple_list(self._submodule_alternate_remotes) - - def get_submodule_alternates_for_remote(self, remote_name): - alternates =3D [] - for alternate in self._submodule_alternate_remotes: - if alternate.remote_name =3D=3D remote_name: - alternates.append(alternate.tuple) - return alternates - + # + # parse tags + # requires RemoteList to be parsed first + # + if self._xml_type =3D=3D 'Pin': + combos =3D self._tree.findall('Combination') + if len(combos) !=3D 1: + raise KeyError(PIN_COMB_ERROR.format(fileref)) + + # container tag not required for pin files + if self._tree.find('CombinationList') is None: + combolist =3D ET.SubElement(tree_root, 'CombinationList') + combolist.append(combos[0]) + tree_root.remove(combos[0]) + + for subroot in self._tree.iter(tag=3D'CombinationList'): + for element in subroot.iter(tag=3D'Combination'): + combo =3D _Combination(element) + + # add the combo obj to the combinations and combo_sources = dicts + self._add_combo_source(element, combo) + + if self._xml_type =3D=3D 'Pin': + # done with Pin parsing at this point, so exit init + # remaining tag types are unique to manifest xml (for now...) + return + + # + # parse tags + # + for subroot in self._tree.iter(tag=3D'DscList'): + for element in subroot.iter(tag=3D'Dsc'): + self._dsc_list.append(element.text) + + # + # Process tag + # + subroot =3D self._tree.find('SparseCheckout') + if subroot is not None: + try: + self._sparse_settings =3D _SparseSettings(subroot.find('Sp= arseSettings')) + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, subroot= .tag)) + for sparse_data in subroot.iter(tag=3D'SparseData'): + self._sparse_data.append(_SparseData(sparse_data)) + + # + # Process any commit log templates that may exist (optional) + # + subroot =3D self._tree.find('CommitTemplates') + if subroot is not None: + for template_element in subroot.iter(tag=3D'Template'): + try: + remote_name =3D template_element.attrib['remoteName'] + template_text =3D template_element.text + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, sub= root.tag)) + self._commit_templates[remote_name] =3D template_text + + # + # Process tag + # + subroot =3D self._tree.find('FolderToFolderMappingList') + if subroot is not None: + for f2f_mapping in subroot.iter(tag=3D'FolderToFolderMapping'): + self._folder_to_folder_mappings.append(_FolderToFolderMapp= ing(f2f_mapping)) + + return + + def is_pin_file(self): + if self._xml_type =3D=3D 'Pin': + return True + else: + return False + + def add_combo(self, element): + self._tree.find('CombinationList').append(element) + combo =3D _Combination(element) + self._add_combo_source(element, combo) + + def _add_combo_source(self, subroot, combo): + # create a list of _RepoSource objs from the tags in subr= oot + # and add it to the __combo_sources dictionary + self._add_unique_item(combo, self._combinations, subroot.tag) + temp_sources =3D [] + for element in subroot.iter(tag=3D'Source'): + temp_sources.append(_RepoSource(element, self._remotes)) + self._combo_sources[combo.name] =3D temp_sources + + def _add_unique_item(self, obj, item_dict, tag): + # add the 'obj' to 'dict', or raise error if it already exists + if obj.name in item_dict: + raise KeyError(DUPLICATE_TAG_ERROR.format(tag, obj.name)) + item_dict[obj.name] =3D obj + + def _tuple_list(self, obj_list): + tuples =3D [] + for obj in obj_list: + tuples.append(obj.tuple) + return tuples + + # + # EdkManifestLib properties and methods + # These will convert the internal classes and attributes into the arch= itecurally + # defined lists and tuples that the caller is expecting. + # + @property + def project_info(self): + return self._project_info.tuple + + @property + def general_config(self): + return self._general_config.tuple + + @property + def remotes(self): + return self._tuple_list(self._remotes.values()) + + @property + def combinations(self): + return self._tuple_list([x for x in self._combinations.values() if= not x.archived]) + + @property + def archived_combinations(self): + return self._tuple_list([x for x in self._combinations.values() if= x.archived]) + + def get_repo_sources(self, combo_name): + if combo_name in self._combo_sources: + return self._tuple_list(self._combo_sources[combo_name]) + elif combo_name.startswith('Pin:'): + # If currently checked out onto a pin file reture the sources = in the + # default combo + return self._tuple_list(self._combo_sources[self.general_confi= g.default_combo]) + else: + raise ValueError(COMB_INVALIDINPUT_ERROR.format(combo_name)) + + @property + def repo_hooks(self): + return self._tuple_list(self._client_hook_list) + + @property + def dsc_list(self): + return self._dsc_list + + @property + def sparse_settings(self): + if self._sparse_settings: + return self._sparse_settings.tuple + return None + + @property + def sparse_data(self): + return self._tuple_list(self._sparse_data) + + @property + def folder_to_folder_mappings(self): + f2f_tuples =3D [] + for f2f_mapping in self._folder_to_folder_mappings: + folders =3D f2f_mapping.folders + folder_tuples =3D [] + for folder in folders: + f =3D copy.deepcopy(folder) + f.excludes =3D self._tuple_list(folder.excludes) + folder_tuples.append(f.tuple) + m =3D copy.deepcopy(f2f_mapping) + m.folders =3D folder_tuples + f2f_tuples.append(m.tuple) + return f2f_tuples + + @property + def current_combo(self): + return self.general_config.current_combo + + def get_combo_element(self, name): + combinations =3D self._tree.find('CombinationList') + for combo in combinations.iter(tag=3D'Combination'): + if combo.attrib['name'] =3D=3D name: + return copy.deepcopy(combo) + raise ValueError(COMB_UNKOWN_ERROR.format(name, self._fileref)) + + @property + def commit_templates(self): + return self._commit_templates + + @property + def submodule_alternate_remotes(self): + return self._tuple_list(self._submodule_alternate_remotes) + + def get_submodule_alternates_for_remote(self, remote_name): + alternates =3D [] + for alternate in self._submodule_alternate_remotes: + if alternate.remote_name =3D=3D remote_name: + alternates.append(alternate.tuple) + return alternates + def get_submodule_init_paths(self, remote_name=3DNone, combo=3DNone): submodule_list =3D [] if remote_name is None and combo is None: @@ -411,111 +411,111 @@ class ManifestXml(BaseXmlHelper): if x.remote_name =3D=3D remote_name and (x.combo =3D=3D c= ombo or x.combo is None)]) return submodule_list =20 - def write_current_combo(self, combo_name, filename=3DNone): - # - # Updates the CurrentClonedCombo tag of _tree attribute and writes= the entire tree out to the - # file specified. If no file is given, then the file used to insta= ntiate this object will be used. - # Note: It will also strip all the comments from the file - # - if self._xml_type =3D=3D 'Pin': - # raise Warning("This method is not supported for Pin xmls") - return - if filename is None: - filename =3D self._fileref - - subroot =3D self._tree.find('GeneralConfig') - if subroot is None: - raise KeyError(GENERAL_CONFIG_MISSING_ERROR) - - element =3D subroot.find('CurrentClonedCombo') - if element is None: - element =3D ET.SubElement(subroot, 'CurrentClonedCombo') - element.tail =3D '\n' - - element.attrib['combination'] =3D combo_name - self._tree.write(filename) - self._general_config.current_combo =3D combo_name - - def write_source_manifest_repo(self, manifest_repo, filename=3DNone): - ''' - Writes the name of the source manifest repository to the - general config sections of the manifest file. - ''' - if filename is None: - filename =3D self._fileref - subroot =3D self._tree.find('GeneralConfig') - if subroot is None: - raise KeyError(GENERAL_CONFIG_MISSING_ERROR) - - element =3D subroot.find('SourceManifestRepository') - if element is None: - element =3D ET.SubElement(subroot, 'SourceManifestRepository') - element.tail =3D '\n' - element.attrib['manifest_repo'] =3D manifest_repo - self._tree.write(filename) - self.__general_config.source_manifest_repo =3D manifest_repo - - def generate_pin_xml(self, description, combo_name, repo_source_list, = filename=3DNone): - - pin_tree =3D ET.ElementTree(ET.Element('Pin')) - pin_root =3D pin_tree.getroot() - - subroot_m =3D self._tree.find('ProjectInfo') - pin_root.append(subroot_m) - project_root =3D pin_root.find('ProjectInfo') - for elem in list(project_root): - if elem.tag !=3D 'CodeName' and elem.tag !=3D 'Description': - project_root.remove(elem) - project_root.find('Description').text =3D description - - subroot_m =3D self._tree.find('GeneralConfig') - pin_root.append(subroot_m) - config_root =3D pin_root.find('GeneralConfig') - for elem in list(config_root): - if elem.tag !=3D 'StitchConfigPath' and elem.tag !=3D 'WitConf= igPath' and elem.tag !=3D 'CurrentClonedCombo': - config_root.remove(elem) - - subroot_m =3D self._tree.find('BinaryList') - if subroot_m is not None: - pin_root.append(subroot_m) - - hook_root =3D ET.SubElement(pin_root, 'ClientGitHookList') - - submodule_alt_url_root =3D None - if self._tree.find('SubmoduleAlternateRemotes'): - submodule_alt_url_root =3D ET.SubElement(pin_root, 'SubmoduleA= lternateRemotes') - + def write_current_combo(self, combo_name, filename=3DNone): + # + # Updates the CurrentClonedCombo tag of _tree attribute and writes= the entire tree out to the + # file specified. If no file is given, then the file used to insta= ntiate this object will be used. + # Note: It will also strip all the comments from the file + # + if self._xml_type =3D=3D 'Pin': + # raise Warning("This method is not supported for Pin xmls") + return + if filename is None: + filename =3D self._fileref + + subroot =3D self._tree.find('GeneralConfig') + if subroot is None: + raise KeyError(GENERAL_CONFIG_MISSING_ERROR) + + element =3D subroot.find('CurrentClonedCombo') + if element is None: + element =3D ET.SubElement(subroot, 'CurrentClonedCombo') + element.tail =3D '\n' + + element.attrib['combination'] =3D combo_name + self._tree.write(filename) + self._general_config.current_combo =3D combo_name + + def write_source_manifest_repo(self, manifest_repo, filename=3DNone): + ''' + Writes the name of the source manifest repository to the + general config sections of the manifest file. + ''' + if filename is None: + filename =3D self._fileref + subroot =3D self._tree.find('GeneralConfig') + if subroot is None: + raise KeyError(GENERAL_CONFIG_MISSING_ERROR) + + element =3D subroot.find('SourceManifestRepository') + if element is None: + element =3D ET.SubElement(subroot, 'SourceManifestRepository') + element.tail =3D '\n' + element.attrib['manifest_repo'] =3D manifest_repo + self._tree.write(filename) + self.__general_config.source_manifest_repo =3D manifest_repo + + def generate_pin_xml(self, description, combo_name, repo_source_list, = filename=3DNone): + + pin_tree =3D ET.ElementTree(ET.Element('Pin')) + pin_root =3D pin_tree.getroot() + + subroot_m =3D self._tree.find('ProjectInfo') + pin_root.append(subroot_m) + project_root =3D pin_root.find('ProjectInfo') + for elem in list(project_root): + if elem.tag !=3D 'CodeName' and elem.tag !=3D 'Description': + project_root.remove(elem) + project_root.find('Description').text =3D description + + subroot_m =3D self._tree.find('GeneralConfig') + pin_root.append(subroot_m) + config_root =3D pin_root.find('GeneralConfig') + for elem in list(config_root): + if elem.tag !=3D 'StitchConfigPath' and elem.tag !=3D 'WitConf= igPath' and elem.tag !=3D 'CurrentClonedCombo': + config_root.remove(elem) + + subroot_m =3D self._tree.find('BinaryList') + if subroot_m is not None: + pin_root.append(subroot_m) + + hook_root =3D ET.SubElement(pin_root, 'ClientGitHookList') + + submodule_alt_url_root =3D None + if self._tree.find('SubmoduleAlternateRemotes'): + submodule_alt_url_root =3D ET.SubElement(pin_root, 'SubmoduleA= lternateRemotes') + selective_submodules_root =3D None if self._tree.find('SelectiveSubmoduleInitList'): selective_submodules_root =3D ET.SubElement(pin_root, 'Selecti= veSubmoduleInitList') =20 - remote_root =3D ET.SubElement(pin_root, 'RemoteList') - source_root =3D ET.SubElement(pin_root, 'Combination') - source_root.attrib['name'] =3D self._combinations[combo_name].name - - # Add tags for each RepoSource tuple in the list provided - # Only one of Branch or SHA is required to write PIN and checkout = code - for src_tuple in repo_source_list: - if (src_tuple.root is None or src_tuple.remote_name is None or= src_tuple.remote_url is - None or (src_tuple.commit is None and src_tuple.branch= is None and src_tuple.tag is None)): - raise ValueError("Invalid input: empty values in source li= st") - - # the data to create the remote elements could also be retriev= ed - # from __remotes, but this is easier - elem =3D ET.SubElement(remote_root, 'Remote', {'name': src_tup= le.remote_name}) - elem.text =3D src_tuple.remote_url - elem.tail =3D '\n ' - - for subroot_hook in self._tree.iter('ClientGitHookList'): - for hook_element in subroot_hook.iter('ClientGitHook'): - if hook_element.attrib['remote'] =3D=3D src_tuple.remo= te_name: - hook_root.append(hook_element) - - for subroot_submodule_alt_url in self._tree.iter('SubmoduleAlt= ernateRemotes'): - for alt_url_element in subroot_submodule_alt_url.iter('Sub= moduleAlternateRemote'): - if alt_url_element.attrib['remote'] =3D=3D src_tuple.r= emote_name: - submodule_alt_url_root.append(alt_url_element) - + remote_root =3D ET.SubElement(pin_root, 'RemoteList') + source_root =3D ET.SubElement(pin_root, 'Combination') + source_root.attrib['name'] =3D self._combinations[combo_name].name + + # Add tags for each RepoSource tuple in the list provided + # Only one of Branch or SHA is required to write PIN and checkout = code + for src_tuple in repo_source_list: + if (src_tuple.root is None or src_tuple.remote_name is None or= src_tuple.remote_url is + None or (src_tuple.commit is None and src_tuple.branch= is None and src_tuple.tag is None)): + raise ValueError("Invalid input: empty values in source li= st") + + # the data to create the remote elements could also be retriev= ed + # from __remotes, but this is easier + elem =3D ET.SubElement(remote_root, 'Remote', {'name': src_tup= le.remote_name}) + elem.text =3D src_tuple.remote_url + elem.tail =3D '\n ' + + for subroot_hook in self._tree.iter('ClientGitHookList'): + for hook_element in subroot_hook.iter('ClientGitHook'): + if hook_element.attrib['remote'] =3D=3D src_tuple.remo= te_name: + hook_root.append(hook_element) + + for subroot_submodule_alt_url in self._tree.iter('SubmoduleAlt= ernateRemotes'): + for alt_url_element in subroot_submodule_alt_url.iter('Sub= moduleAlternateRemote'): + if alt_url_element.attrib['remote'] =3D=3D src_tuple.r= emote_name: + submodule_alt_url_root.append(alt_url_element) + for subroot_selective_subs in self._tree.iter('SelectiveSubmod= uleInitList'): for selective_sub in subroot_selective_subs.iter('Submodul= e'): if selective_sub.attrib['remote'] =3D=3D src_tuple.rem= ote_name: @@ -523,405 +523,405 @@ class ManifestXml(BaseXmlHelper): continue selective_submodules_root.append(selective_sub) =20 - sparse =3D 'true' if src_tuple.sparse else 'false' - sub =3D 'true' if src_tuple.enable_submodule else 'false' - # Write the source element based on what value branch or commi= t is available. - if src_tuple.commit: - if src_tuple.branch: - if src_tuple.tag: - elem =3D ET.SubElement(source_root, 'Source', {'lo= calRoot': src_tuple.root, - 'remo= te': src_tuple.remote_name, - 'bran= ch': src_tuple.branch, - 'comm= it': src_tuple.commit, - 'spar= seCheckout': sparse, - 'enab= le_submodule': sub, - 'tag'= : src_tuple.tag}) - else: - elem =3D ET.SubElement(source_root, 'Source', {'lo= calRoot': src_tuple.root, - 'remo= te': src_tuple.remote_name, - 'bran= ch': src_tuple.branch, - 'comm= it': src_tuple.commit, - 'spar= seCheckout': sparse, - 'enab= le_submodule': sub}) - elif src_tuple.branch is None and src_tuple.tag: - elem =3D ET.SubElement(source_root, 'Source', {'localR= oot': src_tuple.root, - 'remote':= src_tuple.remote_name, - 'commit':= src_tuple.commit, - 'sparseCh= eckout': sparse, - 'enable_s= ubmodule': sub, - 'tag': sr= c_tuple.tag}) - elif src_tuple.branch is None and src_tuple.tag is None: - elem =3D ET.SubElement(source_root, 'Source', {'localR= oot': src_tuple.root, - 'remote':= src_tuple.remote_name, - 'commit':= src_tuple.commit, - 'sparseCh= eckout': sparse, - 'enable_s= ubmodule': sub}) - else: - raise ValueError('Pin.xml cannot be generated with an empt= y commit value') - - elem.tail =3D '\n ' - - # fixup formating for readability (in order) - pin_root.text =3D '\n ' - list(project_root)[-1].tail =3D '\n ' - list(config_root)[-1].tail =3D '\n ' - hook_root.text =3D '\n ' - hook_root.tail =3D '\n\n ' - if submodule_alt_url_root: - submodule_alt_url_root.text =3D '\n ' - submodule_alt_url_root.tail =3D '\n\n ' - list(submodule_alt_url_root)[-1].tail =3D '\n ' + sparse =3D 'true' if src_tuple.sparse else 'false' + sub =3D 'true' if src_tuple.enable_submodule else 'false' + # Write the source element based on what value branch or commi= t is available. + if src_tuple.commit: + if src_tuple.branch: + if src_tuple.tag: + elem =3D ET.SubElement(source_root, 'Source', {'lo= calRoot': src_tuple.root, + 'remo= te': src_tuple.remote_name, + 'bran= ch': src_tuple.branch, + 'comm= it': src_tuple.commit, + 'spar= seCheckout': sparse, + 'enab= le_submodule': sub, + 'tag'= : src_tuple.tag}) + else: + elem =3D ET.SubElement(source_root, 'Source', {'lo= calRoot': src_tuple.root, + 'remo= te': src_tuple.remote_name, + 'bran= ch': src_tuple.branch, + 'comm= it': src_tuple.commit, + 'spar= seCheckout': sparse, + 'enab= le_submodule': sub}) + elif src_tuple.branch is None and src_tuple.tag: + elem =3D ET.SubElement(source_root, 'Source', {'localR= oot': src_tuple.root, + 'remote':= src_tuple.remote_name, + 'commit':= src_tuple.commit, + 'sparseCh= eckout': sparse, + 'enable_s= ubmodule': sub, + 'tag': sr= c_tuple.tag}) + elif src_tuple.branch is None and src_tuple.tag is None: + elem =3D ET.SubElement(source_root, 'Source', {'localR= oot': src_tuple.root, + 'remote':= src_tuple.remote_name, + 'commit':= src_tuple.commit, + 'sparseCh= eckout': sparse, + 'enable_s= ubmodule': sub}) + else: + raise ValueError('Pin.xml cannot be generated with an empt= y commit value') + + elem.tail =3D '\n ' + + # fixup formating for readability (in order) + pin_root.text =3D '\n ' + list(project_root)[-1].tail =3D '\n ' + list(config_root)[-1].tail =3D '\n ' + hook_root.text =3D '\n ' + hook_root.tail =3D '\n\n ' + if submodule_alt_url_root: + submodule_alt_url_root.text =3D '\n ' + submodule_alt_url_root.tail =3D '\n\n ' + list(submodule_alt_url_root)[-1].tail =3D '\n ' if selective_submodules_root: selective_submodules_root.text =3D '\n ' selective_submodules_root.tail =3D '\n\n ' list(selective_submodules_root)[-1].tail =3D '\n ' - remote_root.text =3D '\n ' - remote_root.tail =3D '\n\n ' - list(remote_root)[-1].tail =3D '\n ' - source_root.text =3D '\n ' - source_root.tail =3D '\n' - list(source_root)[-1].tail =3D '\n ' - - pin_tree.write(filename) - - def _compare_elements(self, element1, element2): - if element1.tag !=3D element2.tag: - return False - if element1.text !=3D element2.text: - return False - if element1.tail !=3D element2.tail: - if element1.tail is not None: - tail1 =3D element1.tail.strip() - else: - tail1 =3D '' - if element2.tail is not None: - tail2 =3D element2.tail.strip() - else: - tail2 =3D '' - if tail1 !=3D tail2: - return False - if element1.attrib !=3D element2.attrib: - return False - if len(element1) !=3D len(element2): - return False - return all(self._compare_elements(e1, e2) for e1, e2 in zip(elemen= t1, element2)) - - def equals(self, other, ignore_current_combo=3DFalse): - status =3D self._compare_elements(self._tree.getroot(), other._tre= e.getroot()) - if not status: - tree1 =3D copy.deepcopy(self._tree.getroot()) - tree2 =3D copy.deepcopy(other._tree.getroot()) - subroot =3D tree1.find('GeneralConfig') - if subroot is None: - return False - if ignore_current_combo: - element =3D subroot.find('CurrentClonedCombo') - if element is None: - element =3D ET.SubElement(subroot, 'CurrentClonedCombo= ') - element.tail =3D '\n' - element.attrib['combination'] =3D '' - element =3D subroot.find('SourceManifestRepository') - if element is None: - element =3D ET.SubElement(subroot, 'SourceManifestReposito= ry') - element.tail =3D'\n' - element.attrib['manifest_repo'] =3D '' - subroot =3D tree2.find('GeneralConfig') - if subroot is None: - return False - if ignore_current_combo: - element =3D subroot.find('CurrentClonedCombo') - if element is None: - element =3D ET.SubElement(subroot, 'CurrentClonedCombo= ') - element.tail =3D '\n' - element.attrib['combination'] =3D '' - element =3D subroot.find('SourceManifestRepository') - if element is None: - element =3D ET.SubElement(subroot, 'SourceManifestReposito= ry') - element.tail =3D'\n' - element.attrib['manifest_repo'] =3D '' - status =3D self._compare_elements(tree1, tree2) - return status - - def __eq__(self, other): - return self.equals(other) - - def __ne__(self, other): - return not self.__eq__(other) - - -class _ProjectInfo(): - def __init__(self, element): - try: - self.codename =3D element.find('CodeName').text - self.descript =3D element.find('Description').text - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - - try: - self.lead_list =3D [] - for lead in element.findall('DevLead'): - self.lead_list.append(lead.text) - except Exception: - self.lead_list =3D None - - try: - self.org =3D element.find('Org').text - except Exception: - self.org =3D None - - try: - self.short_name =3D element.find('ShortName').text - except Exception: - self.short_name =3D None - - try: - self.reviewer_list =3D [] - subroot =3D element.find('LeadReviewers') - for reviewer in subroot.iter(tag=3D'Reviewer'): - self.reviewer_list.append(reviewer.text) - except Exception: - self.reviewer_list =3D None - - @property - def tuple(self): - return ProjectInfo(self.codename, self.descript, self.lead_list, s= elf.reviewer_list, self.org, self.short_name) - - -class _GeneralConfig(): - def __init__(self, element): - try: - self.pin_path =3D element.find('PinPath').text - except Exception: - self.pin_path =3D None - try: - self.default_combo =3D element.find('DefaultCombo').attrib['co= mbination'] - except Exception: - self.default_combo =3D None - try: - self.curr_combo =3D element.find('CurrentClonedCombo').attrib[= 'combination'] - except Exception: - self.curr_combo =3D None - try: - self.source_manifest_repo =3D element.find('SourceManifestRepo= sitory').attrib['manifest_repo'] - except: - self.source_manifest_repo =3D None - - @property - def tuple(self): - return GeneralConfig(self.default_combo, self.curr_combo, self.pin= _path, self.source_manifest_repo) - - -class _RemoteRepo(): - def __init__(self, element): - try: - self.name =3D element.attrib['name'] - self.url =3D element.text - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - - @property - def tuple(self): - return RemoteRepo(self.name, self.url) - - -class _RepoHook(): - def __init__(self, element, remotes): - try: - self.source =3D element.attrib['source'] - self.dest_path =3D element.attrib['destination'] - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - try: - self.remote_url =3D remotes[element.attrib['remote']].url - except Exception: - self.remote_url =3D None - print(NO_ASSOCIATED_REMOTE.format(self.source, self.dest_path)) - try: - self.dest_file =3D element.attrib['destination_file'] - except Exception: - self.dest_file =3D None - - @property - def tuple(self): - return RepoHook(self.source, self.dest_path, self.dest_file, self.= remote_url) - - -class _Combination(): - def __init__(self, element): - try: - self.name =3D element.attrib['name'] - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - try: - self.description =3D element.attrib['description'] - except Exception: - self.description =3D None # description is optional attribute - try: - self.archived =3D (element.attrib['archived'].lower() =3D=3D '= true') - except Exception: - self.archived =3D False - - @property - def tuple(self): - return Combination(self.name, self.description) - - -class _RepoSource(): - def __init__(self, element, remotes): - try: - self.root =3D element.attrib['localRoot'] - self.remote_name =3D element.attrib['remote'] - self.remote_url =3D remotes[element.attrib['remote']].url - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - try: - self.branch =3D element.attrib['branch'] - except Exception: - self.branch =3D None - try: - self.commit =3D element.attrib['commit'] - except Exception: - self.commit =3D None - try: - self.tag =3D element.attrib['tag'] - except Exception: - self.tag =3D None - try: - # if the sparse attrib is not explicitly set to true, then ass= ume false - self.sparse =3D (element.attrib['sparseCheckout'].lower() =3D= =3D 'true') - except Exception: - self.sparse =3D False - try: - # If enableSubmodule is not set to True then default to False - self.enableSub =3D (element.attrib['enableSubmodule'].lower() = =3D=3D 'true') - except Exception: - self.enableSub =3D False - - if self.branch is None and self.commit is None and self.tag is Non= e: - raise KeyError(ATTRIBUTE_MISSING_ERROR) - - @property - def tuple(self): - return RepoSource(self.root, self.remote_name, self.remote_url, se= lf.branch, - self.commit, self.sparse, self.enableSub, self.t= ag) - - -class _SparseSettings(): - def __init__(self, element): - self.sparse_by_default =3D False - try: - self.sparse_by_default =3D (element.attrib['sparseByDefault'].= lower() =3D=3D 'true') - except Exception: - pass - - @property - def tuple(self): - return SparseSettings(self.sparse_by_default) - - -class _SparseData(): - def __init__(self, element): - self.combination =3D None - self.remote_name =3D None - self.always_include =3D [] - self.always_exclude =3D [] - try: - self.combination =3D element.attrib['combination'] - except Exception: - pass - try: - self.remote_name =3D element.attrib['remote'] - except Exception: - pass - for includes in element.iter(tag=3D'AlwaysInclude'): - self.always_include.extend(includes.text.split('|')) - for includes in element.iter(tag=3D'AlwaysExclude'): - self.always_exclude.extend(includes.text.split('|')) - - @property - def tuple(self): - return SparseData(self.combination, self.remote_name, self.always_= include, self.always_exclude) - - -class _FolderToFolderMappingFolderExclude(): - def __init__(self, element): - self.path =3D None - try: - self.path =3D element.attrib['path'] - except Exception: - pass - - @property - def tuple(self): - return FolderToFolderMappingFolderExclude(self.path) - - -class _FolderToFolderMappingFolder(): - def __init__(self, element): - self.project1_folder =3D None - self.project2_folder =3D None - self.excludes =3D [] - try: - self.project1_folder =3D element.attrib['project1'] - except Exception: - pass - try: - self.project2_folder =3D element.attrib['project2'] - except Exception: - pass - for exclude in element.iter(tag=3D'Exclude'): - self.excludes.append(_FolderToFolderMappingFolderExclude(exclu= de)) - - @property - def tuple(self): - return FolderToFolderMappingFolder(self.project1_folder, self.proj= ect2_folder, self.excludes) - - -class _FolderToFolderMapping(): - def __init__(self, element): - self.project1 =3D None - self.project2 =3D None - self.remote_name =3D None - self.folders =3D [] - try: - self.project1 =3D element.attrib['project1'] - except Exception: - pass - try: - self.project2 =3D element.attrib['project2'] - except Exception: - pass - try: - self.remote_name =3D element.attrib['remote'] - except Exception: - pass - for folder in element.iter(tag=3D'Folder'): - self.folders.append(_FolderToFolderMappingFolder(folder)) - for folder in element.iter(tag=3D'File'): - self.folders.append(_FolderToFolderMappingFolder(folder)) - - @property - def tuple(self): - return FolderToFolderMapping(self.project1, self.project2, self.re= mote_name, self.folders) - - -class _SubmoduleAlternateRemote(): - def __init__(self, element, remotes): - try: - self.remote_name =3D element.attrib['remote'] - self.originalUrl =3D element.attrib['originalUrl'] - self.altUrl =3D element.text - except KeyError as k: - raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) - - if self.remote_name not in remotes: - raise KeyError(NO_REMOTE_EXISTS_WITH_NAME.format(self.remote_n= ame)) - - @property - def tuple(self): - return SubmoduleAlternateRemote(self.remote_name, self.originalUrl= , self.altUrl) - - + remote_root.text =3D '\n ' + remote_root.tail =3D '\n\n ' + list(remote_root)[-1].tail =3D '\n ' + source_root.text =3D '\n ' + source_root.tail =3D '\n' + list(source_root)[-1].tail =3D '\n ' + + pin_tree.write(filename) + + def _compare_elements(self, element1, element2): + if element1.tag !=3D element2.tag: + return False + if element1.text !=3D element2.text: + return False + if element1.tail !=3D element2.tail: + if element1.tail is not None: + tail1 =3D element1.tail.strip() + else: + tail1 =3D '' + if element2.tail is not None: + tail2 =3D element2.tail.strip() + else: + tail2 =3D '' + if tail1 !=3D tail2: + return False + if element1.attrib !=3D element2.attrib: + return False + if len(element1) !=3D len(element2): + return False + return all(self._compare_elements(e1, e2) for e1, e2 in zip(elemen= t1, element2)) + + def equals(self, other, ignore_current_combo=3DFalse): + status =3D self._compare_elements(self._tree.getroot(), other._tre= e.getroot()) + if not status: + tree1 =3D copy.deepcopy(self._tree.getroot()) + tree2 =3D copy.deepcopy(other._tree.getroot()) + subroot =3D tree1.find('GeneralConfig') + if subroot is None: + return False + if ignore_current_combo: + element =3D subroot.find('CurrentClonedCombo') + if element is None: + element =3D ET.SubElement(subroot, 'CurrentClonedCombo= ') + element.tail =3D '\n' + element.attrib['combination'] =3D '' + element =3D subroot.find('SourceManifestRepository') + if element is None: + element =3D ET.SubElement(subroot, 'SourceManifestReposito= ry') + element.tail =3D'\n' + element.attrib['manifest_repo'] =3D '' + subroot =3D tree2.find('GeneralConfig') + if subroot is None: + return False + if ignore_current_combo: + element =3D subroot.find('CurrentClonedCombo') + if element is None: + element =3D ET.SubElement(subroot, 'CurrentClonedCombo= ') + element.tail =3D '\n' + element.attrib['combination'] =3D '' + element =3D subroot.find('SourceManifestRepository') + if element is None: + element =3D ET.SubElement(subroot, 'SourceManifestReposito= ry') + element.tail =3D'\n' + element.attrib['manifest_repo'] =3D '' + status =3D self._compare_elements(tree1, tree2) + return status + + def __eq__(self, other): + return self.equals(other) + + def __ne__(self, other): + return not self.__eq__(other) + + +class _ProjectInfo(): + def __init__(self, element): + try: + self.codename =3D element.find('CodeName').text + self.descript =3D element.find('Description').text + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + + try: + self.lead_list =3D [] + for lead in element.findall('DevLead'): + self.lead_list.append(lead.text) + except Exception: + self.lead_list =3D None + + try: + self.org =3D element.find('Org').text + except Exception: + self.org =3D None + + try: + self.short_name =3D element.find('ShortName').text + except Exception: + self.short_name =3D None + + try: + self.reviewer_list =3D [] + subroot =3D element.find('LeadReviewers') + for reviewer in subroot.iter(tag=3D'Reviewer'): + self.reviewer_list.append(reviewer.text) + except Exception: + self.reviewer_list =3D None + + @property + def tuple(self): + return ProjectInfo(self.codename, self.descript, self.lead_list, s= elf.reviewer_list, self.org, self.short_name) + + +class _GeneralConfig(): + def __init__(self, element): + try: + self.pin_path =3D element.find('PinPath').text + except Exception: + self.pin_path =3D None + try: + self.default_combo =3D element.find('DefaultCombo').attrib['co= mbination'] + except Exception: + self.default_combo =3D None + try: + self.curr_combo =3D element.find('CurrentClonedCombo').attrib[= 'combination'] + except Exception: + self.curr_combo =3D None + try: + self.source_manifest_repo =3D element.find('SourceManifestRepo= sitory').attrib['manifest_repo'] + except: + self.source_manifest_repo =3D None + + @property + def tuple(self): + return GeneralConfig(self.default_combo, self.curr_combo, self.pin= _path, self.source_manifest_repo) + + +class _RemoteRepo(): + def __init__(self, element): + try: + self.name =3D element.attrib['name'] + self.url =3D element.text + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + + @property + def tuple(self): + return RemoteRepo(self.name, self.url) + + +class _RepoHook(): + def __init__(self, element, remotes): + try: + self.source =3D element.attrib['source'] + self.dest_path =3D element.attrib['destination'] + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + try: + self.remote_url =3D remotes[element.attrib['remote']].url + except Exception: + self.remote_url =3D None + print(NO_ASSOCIATED_REMOTE.format(self.source, self.dest_path)) + try: + self.dest_file =3D element.attrib['destination_file'] + except Exception: + self.dest_file =3D None + + @property + def tuple(self): + return RepoHook(self.source, self.dest_path, self.dest_file, self.= remote_url) + + +class _Combination(): + def __init__(self, element): + try: + self.name =3D element.attrib['name'] + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + try: + self.description =3D element.attrib['description'] + except Exception: + self.description =3D None # description is optional attribute + try: + self.archived =3D (element.attrib['archived'].lower() =3D=3D '= true') + except Exception: + self.archived =3D False + + @property + def tuple(self): + return Combination(self.name, self.description) + + +class _RepoSource(): + def __init__(self, element, remotes): + try: + self.root =3D element.attrib['localRoot'] + self.remote_name =3D element.attrib['remote'] + self.remote_url =3D remotes[element.attrib['remote']].url + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + try: + self.branch =3D element.attrib['branch'] + except Exception: + self.branch =3D None + try: + self.commit =3D element.attrib['commit'] + except Exception: + self.commit =3D None + try: + self.tag =3D element.attrib['tag'] + except Exception: + self.tag =3D None + try: + # if the sparse attrib is not explicitly set to true, then ass= ume false + self.sparse =3D (element.attrib['sparseCheckout'].lower() =3D= =3D 'true') + except Exception: + self.sparse =3D False + try: + # If enableSubmodule is not set to True then default to False + self.enableSub =3D (element.attrib['enableSubmodule'].lower() = =3D=3D 'true') + except Exception: + self.enableSub =3D False + + if self.branch is None and self.commit is None and self.tag is Non= e: + raise KeyError(ATTRIBUTE_MISSING_ERROR) + + @property + def tuple(self): + return RepoSource(self.root, self.remote_name, self.remote_url, se= lf.branch, + self.commit, self.sparse, self.enableSub, self.t= ag) + + +class _SparseSettings(): + def __init__(self, element): + self.sparse_by_default =3D False + try: + self.sparse_by_default =3D (element.attrib['sparseByDefault'].= lower() =3D=3D 'true') + except Exception: + pass + + @property + def tuple(self): + return SparseSettings(self.sparse_by_default) + + +class _SparseData(): + def __init__(self, element): + self.combination =3D None + self.remote_name =3D None + self.always_include =3D [] + self.always_exclude =3D [] + try: + self.combination =3D element.attrib['combination'] + except Exception: + pass + try: + self.remote_name =3D element.attrib['remote'] + except Exception: + pass + for includes in element.iter(tag=3D'AlwaysInclude'): + self.always_include.extend(includes.text.split('|')) + for includes in element.iter(tag=3D'AlwaysExclude'): + self.always_exclude.extend(includes.text.split('|')) + + @property + def tuple(self): + return SparseData(self.combination, self.remote_name, self.always_= include, self.always_exclude) + + +class _FolderToFolderMappingFolderExclude(): + def __init__(self, element): + self.path =3D None + try: + self.path =3D element.attrib['path'] + except Exception: + pass + + @property + def tuple(self): + return FolderToFolderMappingFolderExclude(self.path) + + +class _FolderToFolderMappingFolder(): + def __init__(self, element): + self.project1_folder =3D None + self.project2_folder =3D None + self.excludes =3D [] + try: + self.project1_folder =3D element.attrib['project1'] + except Exception: + pass + try: + self.project2_folder =3D element.attrib['project2'] + except Exception: + pass + for exclude in element.iter(tag=3D'Exclude'): + self.excludes.append(_FolderToFolderMappingFolderExclude(exclu= de)) + + @property + def tuple(self): + return FolderToFolderMappingFolder(self.project1_folder, self.proj= ect2_folder, self.excludes) + + +class _FolderToFolderMapping(): + def __init__(self, element): + self.project1 =3D None + self.project2 =3D None + self.remote_name =3D None + self.folders =3D [] + try: + self.project1 =3D element.attrib['project1'] + except Exception: + pass + try: + self.project2 =3D element.attrib['project2'] + except Exception: + pass + try: + self.remote_name =3D element.attrib['remote'] + except Exception: + pass + for folder in element.iter(tag=3D'Folder'): + self.folders.append(_FolderToFolderMappingFolder(folder)) + for folder in element.iter(tag=3D'File'): + self.folders.append(_FolderToFolderMappingFolder(folder)) + + @property + def tuple(self): + return FolderToFolderMapping(self.project1, self.project2, self.re= mote_name, self.folders) + + +class _SubmoduleAlternateRemote(): + def __init__(self, element, remotes): + try: + self.remote_name =3D element.attrib['remote'] + self.originalUrl =3D element.attrib['originalUrl'] + self.altUrl =3D element.text + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag= )) + + if self.remote_name not in remotes: + raise KeyError(NO_REMOTE_EXISTS_WITH_NAME.format(self.remote_n= ame)) + + @property + def tuple(self): + return SubmoduleAlternateRemote(self.remote_name, self.originalUrl= , self.altUrl) + + class _SubmoduleInitEntry(): def __init__(self, element): try: @@ -943,80 +943,80 @@ class _SubmoduleInitEntry(): return SubmoduleInitPath(self.remote_name, self.combo, self.recurs= ive, self.path) =20 =20 -# -# Optional entry point for debug and validation of the CiIndexXml & Manife= stXml classes -# -def main(): - import argparse - import traceback - import sys - - separator_string =3D '------------------------------------------------= ----------------' - project_header_string =3D '\nProject Name: Project XML Path' - - parser =3D argparse.ArgumentParser() - parser.add_argument("InputFile", help=3D"Xml file to parse", nargs=3D'= ?', default=3D"manifest.xml") - parser.add_argument('-v', '--verbose', action=3D'store_true', - help=3D'Increased verbosity including exception tr= acebacks') - - args =3D parser.parse_args() - - # Attempt initial parse as index file - print('\nAttempting to parse {} as an Index.xml file ...'.format(args.= InputFile)) - print(separator_string) - try: - test_index =3D CiIndexXml(args.InputFile) - project_list =3D test_index.project_list - print('\nActive Projects') - print(project_header_string) - for project in project_list: - index =3D project_list.index(project) - print('{} : {}'.format(str(project_list[index]), str(test_inde= x.get_project_xml(project_list[index])))) - print('\nArchived Projects') - archived_list =3D test_index.archived_project_list - print(project_header_string) - for project in archived_list: - index =3D archived_list.index(project) - print('{} : {}'.format(str(archived_list[index]), str(test_ind= ex.get_project_xml(archived_list[index])))) - print(separator_string) - print('\nSuccessfully parsed {} as an Index.xml file.\nExiting ...= \n'.format(args.InputFile)) - print(separator_string) - sys.exit(0) - except (TypeError, ValueError): - print('{} is an invalid Index.xml file or an invalid xml file.'.fo= rmat(args.InputFile)) - if args.verbose: - traceback.print_exc() - - print(separator_string) - print('\nAttempting to parse {} as a Manifest or Pin file ...'.format(= args.InputFile)) - print(separator_string) - try: - test_manifest =3D ManifestXml(args.InputFile) - - if test_manifest.is_pin_file(): - print('\n{} determined to be a pin file'.format(args.InputFile= )) - - print('\nProjectInfo:') - print(test_manifest.project_info) - - print("\nGeneralConfig:") - print(test_manifest.general_config) - - print("\nRemotes:") - print(test_manifest.remotes) - print('\nClient Git Hooks') - print(test_manifest.repo_hooks) - print('\nSubmodule Alternate Remotes') - print(test_manifest.submodule_alternate_remotes) - - print('\nGet Submodule Alternates for Remote') - for remote in test_manifest.remotes: - alts =3D test_manifest.get_submodule_alternates_for_remote(rem= ote.name) - if alts: - print('\nSubmodule Alternates for Remote: {}'.format(remot= e.name)) - for alt in alts: - print(alt) - +# +# Optional entry point for debug and validation of the CiIndexXml & Manife= stXml classes +# +def main(): + import argparse + import traceback + import sys + + separator_string =3D '------------------------------------------------= ----------------' + project_header_string =3D '\nProject Name: Project XML Path' + + parser =3D argparse.ArgumentParser() + parser.add_argument("InputFile", help=3D"Xml file to parse", nargs=3D'= ?', default=3D"manifest.xml") + parser.add_argument('-v', '--verbose', action=3D'store_true', + help=3D'Increased verbosity including exception tr= acebacks') + + args =3D parser.parse_args() + + # Attempt initial parse as index file + print('\nAttempting to parse {} as an Index.xml file ...'.format(args.= InputFile)) + print(separator_string) + try: + test_index =3D CiIndexXml(args.InputFile) + project_list =3D test_index.project_list + print('\nActive Projects') + print(project_header_string) + for project in project_list: + index =3D project_list.index(project) + print('{} : {}'.format(str(project_list[index]), str(test_inde= x.get_project_xml(project_list[index])))) + print('\nArchived Projects') + archived_list =3D test_index.archived_project_list + print(project_header_string) + for project in archived_list: + index =3D archived_list.index(project) + print('{} : {}'.format(str(archived_list[index]), str(test_ind= ex.get_project_xml(archived_list[index])))) + print(separator_string) + print('\nSuccessfully parsed {} as an Index.xml file.\nExiting ...= \n'.format(args.InputFile)) + print(separator_string) + sys.exit(0) + except (TypeError, ValueError): + print('{} is an invalid Index.xml file or an invalid xml file.'.fo= rmat(args.InputFile)) + if args.verbose: + traceback.print_exc() + + print(separator_string) + print('\nAttempting to parse {} as a Manifest or Pin file ...'.format(= args.InputFile)) + print(separator_string) + try: + test_manifest =3D ManifestXml(args.InputFile) + + if test_manifest.is_pin_file(): + print('\n{} determined to be a pin file'.format(args.InputFile= )) + + print('\nProjectInfo:') + print(test_manifest.project_info) + + print("\nGeneralConfig:") + print(test_manifest.general_config) + + print("\nRemotes:") + print(test_manifest.remotes) + print('\nClient Git Hooks') + print(test_manifest.repo_hooks) + print('\nSubmodule Alternate Remotes') + print(test_manifest.submodule_alternate_remotes) + + print('\nGet Submodule Alternates for Remote') + for remote in test_manifest.remotes: + alts =3D test_manifest.get_submodule_alternates_for_remote(rem= ote.name) + if alts: + print('\nSubmodule Alternates for Remote: {}'.format(remot= e.name)) + for alt in alts: + print(alt) + print('\nGet Submodule Init Objects') print('\nAll:') for entry in test_manifest.get_submodule_init_paths(): @@ -1034,56 +1034,56 @@ def main(): for entry in test_manifest.get_submodule_init_paths(remote.nam= e, current_combo): print('+ {}'.format(entry)) =20 - if not test_manifest.is_pin_file(): - print('\nSparse settings:') - print(test_manifest.sparse_settings) - print('\nSparse data:') - print(test_manifest.sparse_data) - - print('\nCommit templates:') - print(test_manifest.commit_templates) - - print('\nDsc List:') - print(test_manifest.dsc_list) - - print('\nFolder to Folder Mapping') - print(test_manifest.folder_to_folder_mappings) - - combos =3D test_manifest.combinations - print('\nCombinations') - print(combos) - - print('\nget_repo_sources by combo:') - for combo in combos: - index =3D combos.index(combo) - print('get_repo_sources({}) =3D '.format(combos[index].name)) - print(test_manifest.get_repo_sources(combos[index].name)) - - print('\nAttempting to write TestPin.xml') - pin_combo =3D [] - for src in test_manifest.get_repo_sources(combos[0].name): - if src.commit is None: - pin_combo.append(src._replace(commit=3D'TESTHASH1234')) - else: - pin_combo.append(src) - test_manifest.generate_pin_xml('TestPin', combos[0].name, pin_= combo, 'TestPin.xml') - - print('\nAttempting to write TESTCOMBO to current combo field = of TestManifest.xml') - test_manifest.write_current_combo('TESTCOMBO', 'TestManifest.x= ml') - - print(separator_string) - if test_manifest.is_pin_file(): - print('Successfully parsed {} as a pin file.\nExiting...'.form= at(args.InputFile)) - else: - print('Successfully parsed {} as a manifest file.\nExiting...'= .format(args.InputFile)) - print(separator_string) - sys.exit(0) - - except (TypeError, KeyError, ValueError): - print('{} is an invalid Manifest or Pin file or an invalid xml fil= e.'.format(args.InputFile)) - if args.verbose: - traceback.print_exc() - - -if __name__ =3D=3D "__main__": - main() + if not test_manifest.is_pin_file(): + print('\nSparse settings:') + print(test_manifest.sparse_settings) + print('\nSparse data:') + print(test_manifest.sparse_data) + + print('\nCommit templates:') + print(test_manifest.commit_templates) + + print('\nDsc List:') + print(test_manifest.dsc_list) + + print('\nFolder to Folder Mapping') + print(test_manifest.folder_to_folder_mappings) + + combos =3D test_manifest.combinations + print('\nCombinations') + print(combos) + + print('\nget_repo_sources by combo:') + for combo in combos: + index =3D combos.index(combo) + print('get_repo_sources({}) =3D '.format(combos[index].name)) + print(test_manifest.get_repo_sources(combos[index].name)) + + print('\nAttempting to write TestPin.xml') + pin_combo =3D [] + for src in test_manifest.get_repo_sources(combos[0].name): + if src.commit is None: + pin_combo.append(src._replace(commit=3D'TESTHASH1234')) + else: + pin_combo.append(src) + test_manifest.generate_pin_xml('TestPin', combos[0].name, pin_= combo, 'TestPin.xml') + + print('\nAttempting to write TESTCOMBO to current combo field = of TestManifest.xml') + test_manifest.write_current_combo('TESTCOMBO', 'TestManifest.x= ml') + + print(separator_string) + if test_manifest.is_pin_file(): + print('Successfully parsed {} as a pin file.\nExiting...'.form= at(args.InputFile)) + else: + print('Successfully parsed {} as a manifest file.\nExiting...'= .format(args.InputFile)) + print(separator_string) + sys.exit(0) + + except (TypeError, KeyError, ValueError): + print('{} is an invalid Manifest or Pin file or an invalid xml fil= e.'.format(args.InputFile)) + if args.verbose: + traceback.print_exc() + + +if __name__ =3D=3D "__main__": + main() --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#59702): https://edk2.groups.io/g/devel/message/59702 Mute This Topic: https://groups.io/mt/74237839/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-