Skip to content

Commit 2090f9f

Browse files
authored
Merge branch 'main' into feat/821-switch-long-and-short-click-in-food-plan
2 parents 6170e9b + 468667a commit 2090f9f

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

backend/app/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_secret(env_var: str, default: str = None) -> str | None:
3838
file_path = os.getenv(f"{env_var}_FILE")
3939
if file_path:
4040
try:
41-
with open(file_path, "r") as f:
41+
with open(file_path, "r", encoding="utf-8") as f:
4242
return f.read().strip()
4343
except Exception as e:
4444
raise RuntimeError(f"Failed to read {env_var}_FILE: {e}")

backend/app/service/file_has_access_or_download.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def file_has_access_or_download(
3131
ext = guess_extension(resp.headers["content-type"])
3232
if ext and allowed_file("file" + ext):
3333
filename = secure_filename(str(uuid.uuid4()) + ext)
34-
with open(os.path.join(UPLOAD_FOLDER, filename), "wb") as o:
34+
with open(
35+
os.path.join(UPLOAD_FOLDER, filename), "wb", encoding="utf-8"
36+
) as o:
3537
o.write(resp.content)
3638
blur = None
3739
try:

backend/app/service/import_language.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ def importLanguage(household_id: int, lang: str, bulkSave: bool = False):
1212
file_path = f"{APP_DIR}/../templates/l10n/{lang}.json"
1313
if lang not in SUPPORTED_LANGUAGES or not exists(file_path):
1414
raise NotFoundRequest("Language code not supported")
15-
with open(file_path, "r") as f:
15+
with open(file_path, "r", encoding="utf-8") as f:
1616
data = json.load(f)
17-
with open(f"{APP_DIR}/../templates/attributes.json", "r") as f:
17+
with open(
18+
f"{APP_DIR}/../templates/attributes.json", "r", encoding="utf-8"
19+
) as f:
1820
attributes = json.load(f)
1921

2022
t0 = time.time()

backend/manage_default_items.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def loadLang(lang: str):
2424
default_items[lang] = {"items": {}}
2525
if os.path.exists(BASE_PATH + "/templates/l10n/" + lang + ".json"):
2626
with open(
27-
BASE_PATH + "/templates/l10n/" + lang + ".json", "r", encoding="utf8"
27+
BASE_PATH + "/templates/l10n/" + lang + ".json", "r", encoding="utf-8"
2828
) as f:
2929
default_items[lang] = json.loads(f.read())
3030

@@ -79,15 +79,15 @@ def loadLang(lang: str):
7979

8080
folder = BASE_PATH + "/templates/l10n/" if saveToTemplate else (EXPORT_FOLDER + "/")
8181
for key, content in default_items.items():
82-
with open(folder + key + ".json", "w", encoding="utf8") as f:
82+
with open(folder + key + ".json", "w", encoding="utf-8") as f:
8383
f.write(json.dumps(content, ensure_ascii=False, indent=2, sort_keys=True))
8484

8585

8686
def update_attributes(saveToTemplate: bool = False):
8787
# read files
88-
with open(BASE_PATH + "/templates/l10n/en.json", encoding="utf8") as f:
88+
with open(BASE_PATH + "/templates/l10n/en.json", encoding="utf-8") as f:
8989
en: dict = json.load(f)
90-
with open(BASE_PATH + "/templates/attributes.json", encoding="utf8") as f:
90+
with open(BASE_PATH + "/templates/attributes.json", encoding="utf-8") as f:
9191
attr: dict = json.load(f)
9292

9393
unkownKeys = []
@@ -135,10 +135,10 @@ def update_attributes(saveToTemplate: bool = False):
135135

136136
jsonContent = json.dumps(attr, ensure_ascii=False, indent=2, sort_keys=True)
137137
if saveToTemplate:
138-
with open(BASE_PATH + "/templates/attributes.json", "w", encoding="utf8") as f:
138+
with open(BASE_PATH + "/templates/attributes.json", "w", encoding="utf-8") as f:
139139
f.write(jsonContent)
140140
else:
141-
with open(EXPORT_FOLDER + "/attributes.json", "w", encoding="utf8") as f:
141+
with open(EXPORT_FOLDER + "/attributes.json", "w", encoding="utf-8") as f:
142142
f.write(jsonContent)
143143

144144

0 commit comments

Comments
 (0)