1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-19 13:19:41 +02:00

chore: automatic crowdin sync via gh actions (#5630)

This commit is contained in:
Hayden 2025-07-04 19:00:23 -05:00 committed by GitHub
parent c9e22892a6
commit 9cce0f65aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 161 additions and 21 deletions

View file

@ -1,5 +1,4 @@
import logging
import re
import subprocess
from dataclasses import dataclass
from pathlib import Path
@ -35,7 +34,7 @@ class CodeSlicer:
start: int
end: int
indentation: str
indentation: str | None
text: list[str]
_next_line = None
@ -47,15 +46,24 @@ class CodeSlicer:
def push_line(self, string: str) -> None:
self._next_line = self._next_line or self.start + 1
self.text.insert(self._next_line, self.indentation + string + "\n")
self.text.insert(self._next_line, (self.indentation or "") + string + "\n")
self._next_line += 1
def get_indentation_of_string(line: str, comment_char: str = "//|#") -> str:
return re.sub(rf"{comment_char}.*", "", line).removesuffix("\n")
def get_indentation_of_string(line: str) -> str:
# Extract everything before the comment
if "//" in line:
indentation = line.split("//")[0]
elif "#" in line:
indentation = line.split("#")[0]
else:
indentation = line
# Keep only the whitespace, remove any non-whitespace characters
return "".join(c for c in indentation if c.isspace())
def find_start_end(file_text: list[str], gen_id: str) -> tuple[int, int, str]:
def find_start_end(file_text: list[str], gen_id: str) -> tuple[int, int, str | None]:
start = None
end = None
indentation = None