INNER CODE UNIT · Python
get_newline_positions
multitheftauto/mtasa-blue · utils/localization/build_gettext_catalog_nsi.py:49
def get_newline_positions(content: str) -> t.List[int]:
return [i for i, c in enumerate(content) if c == "\n"]
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)