mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
[ios] Adjusted script for checking App Store metadata
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
@@ -104,11 +104,7 @@ GPLAY_LOCALES = [
|
|||||||
|
|
||||||
# From a Fastline error message and https://help.apple.com/app-store-connect/#/dev997f9cf7c
|
# From a Fastline error message and https://help.apple.com/app-store-connect/#/dev997f9cf7c
|
||||||
APPSTORE_LOCALES = [
|
APPSTORE_LOCALES = [
|
||||||
"ar-SA", "ca", "cs", "da", "de-DE", "el", "en-AU", "en-CA",
|
"ar-SA", "ca", "cs", "da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "he", "hi", "hr", "hu", "id", "it", "ja", "ko", "ms", "nl-NL", "no", "pl", "pt-BR", "pt-PT", "ro", "ru", "sk", "sv", "th", "tr", "uk", "vi", "zh-Hans", "zh-Hant"
|
||||||
"en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR",
|
|
||||||
"he", "hi", "hr", "hu", "id", "it", "ja", "ko", "ms", "nl-NL",
|
|
||||||
"no", "pl", "pt-BR", "pt-PT", "ro", "ru", "sk", "sv", "th", "tr",
|
|
||||||
"uk", "vi", "zh-Hans", "zh-Hant"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def error(path, message, *args, **kwargs):
|
def error(path, message, *args, **kwargs):
|
||||||
@@ -121,32 +117,34 @@ def done(path, ok):
|
|||||||
print("✅", path)
|
print("✅", path)
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def check_raw(path, max_length):
|
def check_raw(path, max_length, ignoreEmptyFilesAndNewLines=False):
|
||||||
ok = True
|
ok = True
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
text = f.read()
|
text = f.read()
|
||||||
if not text:
|
if not ignoreEmptyFilesAndNewLines:
|
||||||
ok = error(path, "empty")
|
if not text:
|
||||||
elif text[-1] == os.linesep:
|
ok = error(path, "empty")
|
||||||
text = text[:-1]
|
elif text[-1] == os.linesep:
|
||||||
else:
|
text = text[:-1]
|
||||||
ok = error(path, "missing new line")
|
else:
|
||||||
|
ok = error(path, "missing new line")
|
||||||
|
|
||||||
cur_length = len(text)
|
cur_length = len(text)
|
||||||
if cur_length > max_length:
|
if cur_length > max_length:
|
||||||
ok = error(path, "too long: got={}, expected={}", cur_length, max_length)
|
ok = error(path, "too long: got={}, expected={}", cur_length, max_length)
|
||||||
return ok, text
|
return ok, text
|
||||||
|
|
||||||
def check_text(path, max, optional=False):
|
def check_text(path, max, optional=False, ignoreEmptyFilesAndNewLines=False):
|
||||||
try:
|
try:
|
||||||
return done(path, check_raw(path, max)[0])
|
return done(path, check_raw(path, max, ignoreEmptyFilesAndNewLines)[0])
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
if optional:
|
if optional:
|
||||||
return True,
|
return True,
|
||||||
print("🚫", path)
|
print("🚫", path)
|
||||||
return False,
|
return False,
|
||||||
|
|
||||||
def check_url(path,):
|
def check_url(path, ignoreEmptyFilesAndNewLines=False):
|
||||||
(ok, url) = check_raw(path, 500)
|
(ok, url) = check_raw(path, 500, ignoreEmptyFilesAndNewLines)
|
||||||
url = urlparse(url)
|
url = urlparse(url)
|
||||||
if not url.scheme in ('https', 'http'):
|
if not url.scheme in ('https', 'http'):
|
||||||
ok = error(path, "invalid URL: {}", url)
|
ok = error(path, "invalid URL: {}", url)
|
||||||
@@ -191,40 +189,26 @@ def check_android():
|
|||||||
|
|
||||||
def check_ios():
|
def check_ios():
|
||||||
ok = True
|
ok = True
|
||||||
for locale in APPSTORE_LOCALES:
|
|
||||||
locale_dir = os.path.join('iphone', 'metadata', locale)
|
|
||||||
english_dir = os.path.join('iphone', 'metadata', 'en-US')
|
|
||||||
overlay_dir = os.path.join('keywords', 'ios', locale)
|
|
||||||
if not os.path.isdir(locale_dir):
|
|
||||||
os.mkdir(locale_dir)
|
|
||||||
for name in ["name.txt", "subtitle.txt", "promotional_text.txt",
|
|
||||||
"description.txt", "release_notes.txt", "keywords.txt",
|
|
||||||
"support_url.txt", "marketing_url.txt", "privacy_url.txt"]:
|
|
||||||
overlay_path = os.path.join(overlay_dir, name)
|
|
||||||
english_path = os.path.join(english_dir, name)
|
|
||||||
target_path = os.path.join(locale_dir, name)
|
|
||||||
if os.path.exists(overlay_path):
|
|
||||||
shutil.copy(overlay_path, target_path)
|
|
||||||
elif os.path.exists(english_path) and not os.path.exists(target_path):
|
|
||||||
shutil.copy(english_path, target_path)
|
|
||||||
|
|
||||||
for locale in glob.glob('iphone/metadata/*/'):
|
for locale in glob.glob('iphone/metadata/*/'):
|
||||||
if locale.split('/')[-2] not in APPSTORE_LOCALES:
|
if locale.split('/')[-2] not in APPSTORE_LOCALES:
|
||||||
ok = error(locale, "unsupported locale") and ok
|
ok = error(locale, "unsupported locale") and ok
|
||||||
continue
|
continue
|
||||||
ok = check_text(locale + "name.txt", 30) and ok
|
|
||||||
ok = check_text(locale + "subtitle.txt", 30) and ok
|
locale_complete = True
|
||||||
ok = check_text(locale + "promotional_text.txt", 170) and ok
|
for name in ["description.txt", "keywords.txt", "marketing_url.txt", "privacy_url.txt", "subtitle.txt", "support_url.txt"]:
|
||||||
ok = check_text(locale + "description.txt", 4000) and ok
|
name_path = os.path.join(locale, name)
|
||||||
ok = check_text(locale + "release_notes.txt", 4000) and ok
|
if not os.path.exists(name_path):
|
||||||
ok = check_text(locale + "keywords.txt", 100, True) and ok
|
locale_complete = False
|
||||||
ok = check_url(locale + "support_url.txt") and ok
|
|
||||||
ok = check_url(locale + "marketing_url.txt") and ok
|
if locale_complete:
|
||||||
ok = check_url(locale + "privacy_url.txt") and ok
|
ok = check_text(locale + "subtitle.txt", 30, False, True) and ok
|
||||||
for locale in glob.glob('keywords/ios/*/'):
|
ok = check_text(locale + "description.txt", 4000, False, True) and ok
|
||||||
if locale.split('/')[-2] not in APPSTORE_LOCALES:
|
ok = check_text(locale + "release_notes.txt", 4000, True, True) and ok
|
||||||
ok = error(locale, "unsupported locale") and ok
|
ok = check_text(locale + "keywords.txt", 100, False, True) and ok
|
||||||
continue
|
ok = check_url(locale + "support_url.txt", True) and ok
|
||||||
|
ok = check_url(locale + "marketing_url.txt", True) and ok
|
||||||
|
ok = check_url(locale + "privacy_url.txt", True) and ok
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user