def __CheckForConflicts(self, src1: RequirementInfo, src2: RequirementInfo) -> None: if not src1.IsContentEqual(src2): strHelp = src1.DebugGetDifferenceString(src2) raise Exception( "The requirement {0} already exist but there are differences {1}" .format(src1.Name, strHelp))
def __ParseRequirementInfo( log: Log, jsonRequirementDict: Dict[str, object]) -> RequirementInfo: name = __ReadDictStrAttrib(jsonRequirementDict, JsonRequirementKey.Name) strRequirementType = __ReadDictStrAttrib(jsonRequirementDict, JsonRequirementKey.Type) version = __ReadDictStrAttrib(jsonRequirementDict, JsonRequirementKey.Version, "") extends = __ReadDictStrAttrib(jsonRequirementDict, JsonRequirementKey.Extends, "") requirementType = RequirementType.FromString(strRequirementType) if requirementType == RequirementType.Feature: return RequirementFeatureInfo(name, version, extends) elif requirementType == RequirementType.Extension: return RequirementExtensionInfo(name, version, extends) log.LogPrintWarning( "No special handling for requirement type: {0}, using default".format( strRequirementType)) return RequirementInfo(name, requirementType, version, extends)
from typing import Dict from typing import List from typing import Optional from typing import Set from typing import Union from FslBuildGen.Build import RequirementTreeUtil from FslBuildGen.ExtensionListManager import ExtensionListManager from FslBuildGen.Info.AppInfo import AppInfo from FslBuildGen.Info.AppInfoGlobalRequirementTreeNode import AppInfoGlobalRequirementTreeNode from FslBuildGen.Info.PackageInfo import PackageInfo from FslBuildGen.Info.RequirementInfo import RequirementInfo from FslBuildGen.Info.RequirementInfo import RequirementType from FslBuildGen.Log import Log g_rootRequirement = RequirementInfo("", RequirementType.Undefined, None, "") class AppInfoGlobalRequirementTree(object): def __init__(self, log: Log) -> None: self.Log = log self.TreeDict = {} # type: Dict[str, AppInfoGlobalRequirementTreeNode] self.FeatureToNodeDict = {} # type: Dict[str, AppInfoGlobalRequirementTreeNode] self.__RootNode = AppInfoGlobalRequirementTreeNode(g_rootRequirement) def Merge(self, treeDict: Dict[str, RequirementInfo]) -> None: # First we add all new nodes, then we link up the parent with its children newNodes = [] for key, value in treeDict.items(): if key in self.TreeDict: self.__CheckForConflicts(self.TreeDict[key].Content, value)