Fix reading inp bug

This commit is contained in:
WQY\qiong
2023-02-09 00:08:36 +08:00
parent 7f9c9a8e8c
commit 8979885eac
6 changed files with 45 additions and 38 deletions

View File

@@ -106,26 +106,28 @@ def set_option(name: str, cs: ChangeSet) -> ChangeSet:
def inp_in_option(section: list[str]) -> ChangeSet:
cs = g_update_prefix | { 'type' : 'option' }
for s in section:
if s.startswith(';'):
continue
if len(section) > 0:
cs = g_update_prefix | { 'type' : 'option' }
for s in section:
if s.startswith(';'):
continue
tokens = s.strip().split()
if tokens[0].upper() == 'PATTERN':
cs |= { 'PATTERN' : tokens[1] }
elif tokens[0].upper() == 'QUALITY':
value = tokens[1]
if len(tokens) > 2:
value += f' {tokens[2]}'
cs |= { 'QUALITY' : value }
else:
line = s.upper().strip()
for key in get_option_schema('').keys():
if line.startswith(key):
value = line.removeprefix(key).strip()
cs |= { key : value }
return ChangeSet(cs)
tokens = s.strip().split()
if tokens[0].upper() == 'PATTERN':
cs |= { 'PATTERN' : tokens[1] }
elif tokens[0].upper() == 'QUALITY':
value = tokens[1]
if len(tokens) > 2:
value += f' {tokens[2]}'
cs |= { 'QUALITY' : value }
else:
line = s.upper().strip()
for key in get_option_schema('').keys():
if line.startswith(key):
value = line.removeprefix(key).strip()
cs |= { key : value }
return ChangeSet(cs)
return ChangeSet()
def inp_out_option(name: str) -> list[str]: