[CI] Format code

This commit is contained in:
yunohost-bot 2021-09-04 22:52:35 +00:00
parent e489d31290
commit a289f081d9
3 changed files with 51 additions and 20 deletions

View file

@ -172,7 +172,10 @@ class BaseSystemDiagnoser(Diagnoser):
try: try:
return int(n_failures) return int(n_failures)
except Exception: except Exception:
self.logger_warning("Failed to parse number of recent auth failures, expected an int, got '%s'" % n_failures) self.logger_warning(
"Failed to parse number of recent auth failures, expected an int, got '%s'"
% n_failures
)
return -1 return -1
def is_vulnerable_to_meltdown(self): def is_vulnerable_to_meltdown(self):

View file

@ -27,11 +27,17 @@ def fix_locale(locale_file):
# should also be in the translated string, otherwise the .format # should also be in the translated string, otherwise the .format
# will trigger an exception! # will trigger an exception!
subkeys_in_ref = [k[0] for k in re.findall(r"{(\w+)(:\w)?}", string)] subkeys_in_ref = [k[0] for k in re.findall(r"{(\w+)(:\w)?}", string)]
subkeys_in_this_locale = [k[0] for k in re.findall(r"{(\w+)(:\w)?}", this_locale[key])] subkeys_in_this_locale = [
k[0] for k in re.findall(r"{(\w+)(:\w)?}", this_locale[key])
]
if set(subkeys_in_ref) != set(subkeys_in_this_locale) and (len(subkeys_in_ref) == len(subkeys_in_this_locale)): if set(subkeys_in_ref) != set(subkeys_in_this_locale) and (
len(subkeys_in_ref) == len(subkeys_in_this_locale)
):
for i, subkey in enumerate(subkeys_in_ref): for i, subkey in enumerate(subkeys_in_ref):
this_locale[key] = this_locale[key].replace('{%s}' % subkeys_in_this_locale[i], '{%s}' % subkey) this_locale[key] = this_locale[key].replace(
"{%s}" % subkeys_in_this_locale[i], "{%s}" % subkey
)
fixed_stuff = True fixed_stuff = True
if fixed_stuff: if fixed_stuff:

View file

@ -1,5 +1,6 @@
import re import re
def reformat(lang, transformations): def reformat(lang, transformations):
locale = open(f"locales/{lang}.json").read() locale = open(f"locales/{lang}.json").read()
@ -8,21 +9,41 @@ def reformat(lang, transformations):
open(f"locales/{lang}.json", "w").write(locale) open(f"locales/{lang}.json", "w").write(locale)
###################################################### ######################################################
godamn_spaces_of_hell = ["\u00a0", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u202f", "\u202F", "\u3000"] godamn_spaces_of_hell = [
"\u00a0",
"\u2000",
"\u2001",
"\u2002",
"\u2003",
"\u2004",
"\u2005",
"\u2006",
"\u2007",
"\u2008",
"\u2009",
"\u200A",
"\u202f",
"\u202F",
"\u3000",
]
transformations = {s: " " for s in godamn_spaces_of_hell} transformations = {s: " " for s in godamn_spaces_of_hell}
transformations.update({ transformations.update(
{
"": "...", "": "...",
}) }
)
reformat("en", transformations) reformat("en", transformations)
###################################################### ######################################################
transformations.update({ transformations.update(
{
"courriel": "email", "courriel": "email",
"e-mail": "email", "e-mail": "email",
"Courriel": "Email", "Courriel": "Email",
@ -33,6 +54,7 @@ transformations.update({
"»": "'", "»": "'",
"": "'", "": "'",
# r"$(\w{1,2})'|( \w{1,2})'": r"\1\2", # r"$(\w{1,2})'|( \w{1,2})'": r"\1\2",
}) }
)
reformat("fr", transformations) reformat("fr", transformations)