INNER CODE UNIT · Python
get_line_number_from_position
multitheftauto/mtasa-blue · utils/localization/build_gettext_catalog_nsi.py:53
def get_line_number_from_position(positions: t.List[int], pos: int) -> int:
return bisect_left(positions, pos) + 1
def clean_msgid(msgid: str) -> str:
"""
Get rid of newlines in the source code file itself (that arent in the string)
which may impact a msgid
"""
return MSGID_CLEAN_PTN.sub("", msgid)
def parse_nsi(content: str) -> t.List[LangString]:
positions = get_newline_positions(content)
lang_strings = []
for m in LANG_STRING_PTN.finditer(content):
lang_strings.append(
LangString(