示例#1
0
    def __FilterExtensionsByAvailableFeatures(log: Log, featureNameList: List[str],
                                              qualifiedExtensionNameList: ExtensionListManager) -> ExtensionListManager:
        if qualifiedExtensionNameList.AllowAllExtensions:
            return qualifiedExtensionNameList

        filteredList = []
        for qualifiedExtensionNameRecord in qualifiedExtensionNameList.Content:
            if qualifiedExtensionNameRecord.FeatureName in featureNameList:
                filteredList.append(qualifiedExtensionNameRecord)
            else:
                log.LogPrint("Removing extension '{0}' as the feature '{1}' is unavailable".format(qualifiedExtensionNameRecord, qualifiedExtensionNameRecord.FeatureName))
        return ExtensionListManager(False, filteredList)
 def __init__(self,
              featureNameList: Optional[List[str]] = None,
              extensionNameList: Optional[ExtensionListManager] = None,
              requiredFeatureNameList: Optional[List[str]] = None) -> None:
     self.FeatureNameList = [
         '*'
     ] if featureNameList is None else featureNameList  # type: List[str]
     self.ExtensionNameList = ExtensionListManager(
         True, []
     ) if extensionNameList is None else extensionNameList  # type: ExtensionListManager
     self.RequiredFeatureNameList = [
         '*'
     ] if requiredFeatureNameList is None else requiredFeatureNameList  # type: List[str]
示例#3
0
def ParseExtensionList(strExtensionList: str) -> ExtensionListManager:
    parsedList = ParseList(strExtensionList, "extension", True)
    if not '*' in parsedList:
        newParsedList = []
        for entry in parsedList:
            # Do some minimal basic validation of the input
            # All extensions has to be qualified with a feature "featureName:extensionName
            values = entry.split(':')
            if not len(values) == 2:
                raise Exception(
                    "The extension list must be valid, the extension '{0}' did not follow the expected '<FeatureName>:<ExtensionName>' format"
                    .format(entry))
            if not Util.IsValidRequirementName(values[0]):
                raise Exception(
                    "The extension list must be valid, the extension '{0}' did not contain a valid feature name '{1}'"
                    .format(entry, values[0]))
            if not Util.IsValidRequirementName(values[1]):
                raise Exception(
                    "The extension list must be valid, the extension '{0}' did not contain a valid extension name '{1}'"
                    .format(entry, values[1]))
            newParsedList.append(
                QualifiedRequirementExtensionName(values[0], values[1]))
        return ExtensionListManager(False, newParsedList)
    return ExtensionListManager(True, [])