mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
add line break syntax to python config parser
This commit is contained in:
@@ -262,14 +262,50 @@ def _parse(
|
|||||||
else:
|
else:
|
||||||
from ..constants import config_dir
|
from ..constants import config_dir
|
||||||
base_path_for_includes = config_dir
|
base_path_for_includes = config_dir
|
||||||
for i, line in enumerate(lines):
|
|
||||||
|
it = iter(lines)
|
||||||
|
line: str;
|
||||||
|
nextLine: str = ""
|
||||||
|
nextLineNum = 0;
|
||||||
|
|
||||||
|
while True:
|
||||||
try:
|
try:
|
||||||
with currently_parsing.set_line(line, i + 1):
|
if nextLine != "":
|
||||||
parse_line(line, parse_conf_item, ans, base_path_for_includes, accumulate_bad_lines)
|
line = nextLine
|
||||||
except Exception as e:
|
else:
|
||||||
if accumulate_bad_lines is None:
|
line = next(it).lstrip()
|
||||||
raise
|
nextLineNum += 1
|
||||||
accumulate_bad_lines.append(BadLine(i + 1, line.rstrip(), e, currently_parsing.file))
|
lineNum = nextLineNum
|
||||||
|
|
||||||
|
try:
|
||||||
|
nextLine = next(it).lstrip()
|
||||||
|
nextLineNum += 1
|
||||||
|
|
||||||
|
while nextLine.startswith('\\'):
|
||||||
|
if line.endswith("\n"):
|
||||||
|
line = line[:-1]
|
||||||
|
line += nextLine[1:]
|
||||||
|
try:
|
||||||
|
nextLine = next(it).lstrip()
|
||||||
|
nextLineNum += 1
|
||||||
|
except StopIteration:
|
||||||
|
nextLine = ""
|
||||||
|
break
|
||||||
|
except StopIteration:
|
||||||
|
nextLine = ""
|
||||||
|
pass
|
||||||
|
|
||||||
|
# code
|
||||||
|
|
||||||
|
try:
|
||||||
|
with currently_parsing.set_line(line, lineNum):
|
||||||
|
parse_line(line, parse_conf_item, ans, base_path_for_includes, accumulate_bad_lines)
|
||||||
|
except Exception as e:
|
||||||
|
if accumulate_bad_lines is None:
|
||||||
|
raise
|
||||||
|
accumulate_bad_lines.append(BadLine(lineNum, line.rstrip(), e, currently_parsing.file))
|
||||||
|
except StopIteration:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def parse_config_base(
|
def parse_config_base(
|
||||||
|
|||||||
Reference in New Issue
Block a user