diff --git a/tools/python/check_store_metadata.py b/tools/python/check_store_metadata.py index 13157a9ac..0fe0531bf 100755 --- a/tools/python/check_store_metadata.py +++ b/tools/python/check_store_metadata.py @@ -104,11 +104,7 @@ GPLAY_LOCALES = [ # From a Fastline error message and https://help.apple.com/app-store-connect/#/dev997f9cf7c APPSTORE_LOCALES = [ - "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" + "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" ] def error(path, message, *args, **kwargs): @@ -121,32 +117,34 @@ def done(path, ok): print("✅", path) return ok -def check_raw(path, max_length): +def check_raw(path, max_length, ignoreEmptyFilesAndNewLines=False): ok = True with open(path, 'r') as f: text = f.read() - if not text: - ok = error(path, "empty") - elif text[-1] == os.linesep: - text = text[:-1] - else: - ok = error(path, "missing new line") + if not ignoreEmptyFilesAndNewLines: + if not text: + ok = error(path, "empty") + elif text[-1] == os.linesep: + text = text[:-1] + else: + ok = error(path, "missing new line") + cur_length = len(text) if cur_length > max_length: ok = error(path, "too long: got={}, expected={}", cur_length, max_length) return ok, text -def check_text(path, max, optional=False): +def check_text(path, max, optional=False, ignoreEmptyFilesAndNewLines=False): try: - return done(path, check_raw(path, max)[0]) + return done(path, check_raw(path, max, ignoreEmptyFilesAndNewLines)[0]) except FileNotFoundError as e: if optional: return True, print("🚫", path) return False, -def check_url(path,): - (ok, url) = check_raw(path, 500) +def check_url(path, ignoreEmptyFilesAndNewLines=False): + (ok, url) = check_raw(path, 500, ignoreEmptyFilesAndNewLines) url = urlparse(url) if not url.scheme in ('https', 'http'): ok = error(path, "invalid URL: {}", url) @@ -191,40 +189,26 @@ def check_android(): def check_ios(): 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/*/'): if locale.split('/')[-2] not in APPSTORE_LOCALES: ok = error(locale, "unsupported locale") and ok continue - ok = check_text(locale + "name.txt", 30) and ok - ok = check_text(locale + "subtitle.txt", 30) and ok - ok = check_text(locale + "promotional_text.txt", 170) and ok - ok = check_text(locale + "description.txt", 4000) and ok - ok = check_text(locale + "release_notes.txt", 4000) and ok - ok = check_text(locale + "keywords.txt", 100, True) and ok - ok = check_url(locale + "support_url.txt") and ok - ok = check_url(locale + "marketing_url.txt") and ok - ok = check_url(locale + "privacy_url.txt") and ok - for locale in glob.glob('keywords/ios/*/'): - if locale.split('/')[-2] not in APPSTORE_LOCALES: - ok = error(locale, "unsupported locale") and ok - continue + + locale_complete = True + for name in ["description.txt", "keywords.txt", "marketing_url.txt", "privacy_url.txt", "subtitle.txt", "support_url.txt"]: + name_path = os.path.join(locale, name) + if not os.path.exists(name_path): + locale_complete = False + + if locale_complete: + ok = check_text(locale + "subtitle.txt", 30, False, True) and ok + ok = check_text(locale + "description.txt", 4000, False, True) and ok + ok = check_text(locale + "release_notes.txt", 4000, True, True) and ok + ok = check_text(locale + "keywords.txt", 100, False, True) and ok + 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 if __name__ == "__main__":