def __TryParseFlavor(self, flavor: Optional[str]) -> Dict[str, str]: if flavor is None or len(flavor) <= 0: return {} uniqueIds = {} # type: Dict[str, str] resDict = {} # type: Dict[str, str] entries = flavor.split(',') for entry in entries: parts = entry.split('=') if len(parts) != 2: raise XmlFormatException( "Dependency flavor constraint '{0}' not in the expected format 'flavor1=option, flavor2=option'" .format(flavor)) key = parts[0].strip() value = parts[1].strip() if key in resDict: raise XmlFormatException( "Dependency flavor constraint key '{0}' already defined to '{1}'" .format(key, resDict[key])) keyId = key.upper() if keyId in uniqueIds: raise XmlFormatException( "Dependency flavor constraint key '{0}' already collides with '{1}'" .format(key, uniqueIds[keyId])) if not Util.IsValidFlavorName(key): raise XmlFormatException( "Dependency flavor name '{0}' is invalid".format(key)) if not Util.IsValidFlavorOptionName(value): raise XmlFormatException( "Dependency flavor option '{1}' is invalid in {0}={1}". format(key, value)) uniqueIds[keyId] = key resDict[key] = value return resDict
def __init__(self, name: str) -> None: super().__init__() if not Util.IsValidFlavorName(name): raise InvalidPackageFlavorNameException(name) self.Value = name