MCPcopy Create free account
hub / github.com/comaps/comaps / check_android

Function check_android

tools/python/check_store_metadata.py:179–229  ·  view source on GitHub ↗
(is_gplay, fix=False)

Source from the content-addressed store, hash-verified

177
178
179def check_android(is_gplay, fix=False):
180 ok = True
181 flavor = "google" if is_gplay else "fdroid"
182 flavor = f'{ANDROID_META_PATH}/{flavor}/play/'
183 ok = check_url(flavor + 'contact-website.txt') and ok
184 ok = check_email(flavor + 'contact-email.txt') and ok
185 ok = check_exact(flavor + 'default-language.txt', 'en-US') and ok
186 for locale in glob.glob(flavor + 'listings/*/'):
187 if is_gplay and locale.split('/')[-2] not in GPLAY_LOCALES:
188 error(locale, 'unsupported locale')
189 if fix:
190 drop_locale(locale)
191 ok = False
192 else:
193 locale_ok = check_text(locale + 'title.txt', 30 if is_gplay else 50)
194 desc_path = locale + 'short-description.txt'
195 locale_ok = check_text(desc_path, 80) and locale_ok
196 if is_gplay and os.path.exists(desc_path):
197 desc = open(desc_path, 'r').read()
198 if '--' in desc or '–' in desc:
199 # The app may not be promoted on Google Play because of the following
200 print(f'WARN: {desc_path} should use em dashes instead of double hyphens or en dashes')
201 if fix:
202 desc = desc.replace('--', '—').replace('–', '—')
203 open(desc_path, 'w').write(desc)
204 print(f'REPLACED wrong dashes in {desc_path}')
205 locale_ok = check_text(locale + 'full-description.txt', 4000) and locale_ok
206 locale_ok = check_text(locale + 'release-notes.txt', 499, optional=True) and locale_ok
207 done(locale, locale_ok)
208 if not locale_ok:
209 error(locale, 'locale is INVALID or INCOMPLETE')
210 if fix:
211 drop_locale(locale)
212 ok = False
213 ''' TODO: relnotes not necessary exist for all languages, but symlinks are made for all
214 for locale in glob.glob(flavor + 'release-notes/*/'):
215 if locale.split('/')[-2] not in GPLAY_LOCALES:
216 ok = error(locale, 'unsupported locale') and ok
217 continue
218 ok = check_text(locale + 'default.txt', 499) and ok
219 '''
220 if not ok:
221 if fix:
222 print(f'FIXED by removing invalid locales from {flavor}')
223 return True
224 else:
225 error(flavor, 'HAS INVALID LOCALES')
226 return False
227 else:
228 print(f'metadata is OK {flavor}')
229 return True
230
231
232def check_ios(fix=False):

Callers 1

Calls 9

check_urlFunction · 0.85
check_emailFunction · 0.85
check_exactFunction · 0.85
errorFunction · 0.85
drop_localeFunction · 0.85
check_textFunction · 0.85
doneFunction · 0.85
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected