Refine option v2

This commit is contained in:
WQY\qiong
2023-03-03 19:50:49 +08:00
parent ece98ae07c
commit 9ad47d27cc

View File

@@ -143,28 +143,29 @@ def set_option(name: str, cs: ChangeSet) -> ChangeSet:
# MAP filename
#--------------------------------------------------------------
def inp_in_option(section: list[str]) -> ChangeSet:
if len(section) > 0:
cs = g_update_prefix | { 'type' : 'option' }
for s in section:
if s.startswith(';'):
continue
if len(section) <= 0:
return ChangeSet()
tokens = s.strip().split()
if tokens[0].upper() == 'PATTERN': # can not upper id
cs |= { 'PATTERN' : tokens[1] }
elif tokens[0].upper() == 'QUALITY': # can not upper trace node
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()
cs = g_update_prefix | { 'type' : 'option' }
for s in section:
if s.startswith(';'):
continue
tokens = s.strip().split()
if tokens[0].upper() == 'PATTERN': # can not upper id
cs |= { 'PATTERN' : tokens[1] }
elif tokens[0].upper() == 'QUALITY': # can not upper trace node
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)
def inp_out_option(name: str) -> list[str]: