Add language filter for AME(v.26x)

This commit is contained in:
ckamte
2026-01-31 12:41:21 +06:30
parent b3a4c2bb7b
commit d885396886

View File

@@ -252,7 +252,8 @@ def set_config() -> dict:
os.makedirs(prodDir, exist_ok=True) os.makedirs(prodDir, exist_ok=True)
winver = get_winver() winver = get_winver()
print(f"\nSet windows version to {winver}. You may not install or run products on Windows version below: {winver}!") print(
f"\nSet windows version to {winver}. You may not install or run products on Windows version below: {winver}!")
print(f"\nDownloaded files will be saved in: {prodDir}") print(f"\nDownloaded files will be saved in: {prodDir}")
@@ -426,6 +427,20 @@ def get_products(cfg: dict) -> dict:
): ):
productVersion = ls.find(".//appVersion").text productVersion = ls.find(".//appVersion").text
# check available languages using tutorial pages
langList = product_languages(ls)
if len(langList) == 1 and langList[0] == "mul":
tutLangs = []
for cEntries in product.findall("./custom-data/custom-entry"):
eKey = cEntries.get("key")
if "tutorialsPage_" in eKey:
tutLocale = eKey.split("_", 1)[1]
if tutLocale != "mul":
tutLangs.append(tutLocale)
if tutLangs:
langList = tutLangs
# get product with version # get product with version
if productVersion is not None: if productVersion is not None:
allProducts[sapCode]["versions"][productVersion] = { allProducts[sapCode]["versions"][productVersion] = {
@@ -433,7 +448,7 @@ def get_products(cfg: dict) -> dict:
"displayName": displayName, "displayName": displayName,
"appPlatform": appPlatform, "appPlatform": appPlatform,
"productVersion": productVersion, "productVersion": productVersion,
"supportedLanguages": product_languages(ls), "supportedLanguages": langList,
"buildGuid": languageSet.get("buildGuid"), "buildGuid": languageSet.get("buildGuid"),
"manifestURL": manifestURL, "manifestURL": manifestURL,
} }
@@ -646,7 +661,8 @@ def install_language(appLangs: list[str]) -> list[str]:
else: else:
print(f"\nProvided language not available: {l}") print(f"\nProvided language not available: {l}")
if len(appLangs) == 1: if len(appLangs) == 1:
print(f"\nSet language to available language {appLangs[0]}") print(
f"\nSet language to available language {appLangs[0]}")
installLanguage = appLangs installLanguage = appLangs
break break
@@ -796,7 +812,7 @@ def do_test(cond: str, key: str | list[str]) -> bool:
else: else:
c = int(c) c = int(c)
k = int(keys[idx]) k = int(keys[idx])
if opt(k, c) is not True: if opt(k, c) is not True:
return False return False
@@ -975,7 +991,18 @@ def get_appjson(prodInfo: list) -> dict:
return download_json(ADOBE_APPLICATION_JSON_URL, headers) return download_json(ADOBE_APPLICATION_JSON_URL, headers)
def write_driver_xml(pkgJson: dict, pkgDir: str) -> None: def xml_langs_list(langRoot, langList):
for lg in langList:
if isinstance(lg, dict):
lg = lg["locale"]
for key, val in dict({"Language": ""}).items():
child = ET.Element(key)
child.set("locale", lg)
langRoot.append(child)
def write_driver_xml(pkgJson: dict, pkgDir: str, reqLang: list[str]) -> None:
"""Generate Diver.xml and save to product dir""" """Generate Diver.xml and save to product dir"""
driverInfo = ET.Element("DriverInfo") driverInfo = ET.Element("DriverInfo")
productInfo = ET.SubElement(driverInfo, "ProductInfo") productInfo = ET.SubElement(driverInfo, "ProductInfo")
@@ -1025,11 +1052,10 @@ def write_driver_xml(pkgJson: dict, pkgDir: str) -> None:
availLoc = pkgJson["SupportedLanguages"]["Language"] availLoc = pkgJson["SupportedLanguages"]["Language"]
if availLoc[0]["locale"] != "mul": if availLoc[0]["locale"] != "mul":
for lg in availLoc: xml_langs_list(langRoot, availLoc)
for key, val in dict({"Language": ""}).items():
child = ET.Element(key) elif reqLang[0] != "mul":
child.set("locale", lg["locale"]) xml_langs_list(langRoot, reqLang)
langRoot.append(child)
# suppress error on dep package download # suppress error on dep package download
if "MinimumSupportedClientVersion" in pkgJson and "HDBuilderVersion" in pkgJson: if "MinimumSupportedClientVersion" in pkgJson and "HDBuilderVersion" in pkgJson:
@@ -1082,7 +1108,7 @@ def product_download(prodInfo: list, allProducts: dict, reqLang: list) -> None:
print(f"\nDownloading packages for {appName}, version-{version}") print(f"\nDownloading packages for {appName}, version-{version}")
print("\nCreating Driver.xml file...") print("\nCreating Driver.xml file...")
write_driver_xml(appJsonData, cfg['productDir']) write_driver_xml(appJsonData, cfg['productDir'], reqLang)
print("\nCreating Application.json file...") print("\nCreating Application.json file...")
create_json(os.path.join(pkgDir, "Application.json"), appJsonData) create_json(os.path.join(pkgDir, "Application.json"), appJsonData)