def Filter(log: Log, topLevelPackage: Package, requestedPackages: Optional[List[Package]], packageFilters: PackageFilters) -> List[Package]: """ Filter the package list based - Required packages by the requested packages (if requestedPackages isnt None) - If there is executeables then chose those that implement the required features in requiredFeatureNameList - the available features from featureNameList - the available extensions from extensionNameList - if they are supported on the platform """ resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder requirements = RequirementFilter.GetRequirementList( topLevelPackage, None) requirementTree = RequirementTree(requirements) # Smart expand the input lists # - First we add all parent features automatically to ensure the feature list is complete useStrictFeatureWarning = requestedPackages is None or len( requestedPackages) <= 0 featureNameList2 = PackageFilter.__AddParentFeatures( log, packageFilters.FeatureNameList, requirementTree, useStrictFeatureWarning) extensionNameList = packageFilters.ExtensionNameList if not packageFilters.ExtensionNameList.AllowAllExtensions: # Filter extensions by available features extensionNameList = PackageFilter.__FilterExtensionsByAvailableFeatures( log, featureNameList2, extensionNameList) requirementTree.SetExtensionSupport(log, extensionNameList) # Try to determine what the user is interested in building requestedPackagesInOrder = PackageFilter.__DetermineActualUserBuildRequest( resolvedBuildOrder, requestedPackages) # Remove recipe packages requestedPackagesInOrder = PackageFilter.__FiltersRecipePackages( log, requestedPackagesInOrder) # Remove packages based on the users required features request requestedPackagesInOrder = PackageFilter.__FiltersPackagesByRequiredFeature( log, requestedPackagesInOrder, packageFilters.RequiredFeatureNameList) # Remove packages based on the available features (remove all packages that can't be build due to missing features) requestedPackagesInOrder = PackageFilter.__FiltersPackagesByFeatures( log, requestedPackagesInOrder, featureNameList2) # Remove packages based on the available extensions (remove all packages that can't be build due missing extensions) requestedPackagesInOrder = PackageFilter.__FiltersPackagesByExtensions( log, requestedPackagesInOrder, extensionNameList, featureNameList2, requirementTree) # Remove packages that are not supported on this platform requestedPackagesInOrder = PackageFilter.__FiltersPackagesBySupported( log, requestedPackagesInOrder) # Now that we have a filtered list of desired packages, extend it to include all required packages return PackageListUtil.GetRequiredPackagesInSourcePackageListOrder( requestedPackagesInOrder, resolvedBuildOrder)
def FilterNotSupported(log: Log, topLevelPackage: Package, requestedPackages: Optional[List[Package]]) -> List[Package]: """ Filter the package list based - if they are supported on the platform """ resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder # Try to determine what the user is interested in building requestedPackagesInOrder = PackageFilter.__DetermineActualUserBuildRequest(resolvedBuildOrder, requestedPackages) # remove all the unsupported packages requestedPackagesInOrder = PackageFilter.__FiltersPackagesBySupported(log, requestedPackagesInOrder) # Now that we have a filtered list of desired packages, extend it to include all required packages return PackageListUtil.GetRequiredPackagesInSourcePackageListOrder(requestedPackagesInOrder, resolvedBuildOrder)