10 def escape_line(self, line: str, space: str, tab: str) -> str:
11 if line.startswith(
" "):
13 self == EscapeLeadingWhitespace.ALWAYS
14 or self == EscapeLeadingWhitespace.ONLY_ON_SPACE
16 return f
"{space}{line[1:]}"
19 elif line.startswith(
"\t"):
21 self == EscapeLeadingWhitespace.ALWAYS
22 or self == EscapeLeadingWhitespace.ONLY_ON_TAB
24 return f
"{tab}{line[1:]}"
33 common_whitespace =
None
35 for line
in file_content.splitlines():
36 whitespace =
"".join(c
for c
in line
if c.isspace())
39 elif all(c ==
" " for c
in whitespace):
41 elif all(c ==
"\t" for c
in whitespace):
46 if common_whitespace
is None:
47 common_whitespace = whitespace
48 elif common_whitespace != whitespace:
49 common_whitespace = MIXED
52 if common_whitespace ==
" ":
54 elif common_whitespace ==
"\t":