Split [CURVES] in/out
This commit is contained in:
@@ -125,12 +125,62 @@ def delete_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
# [EPA2][IN][OUT]
|
||||
# ;type: desc
|
||||
# id x y
|
||||
#--------------------------------------------------------------
|
||||
def inp_in_curve(section: list[str]) -> ChangeSet:
|
||||
types = {}
|
||||
descs = {}
|
||||
curves: dict[str, list[dict[str, float]]] = {}
|
||||
|
||||
count = len(section)
|
||||
for i in range(0, count):
|
||||
if section[i].startswith(';'):
|
||||
# this is description
|
||||
type_plus_desc = section[i].removeprefix(';')
|
||||
type_plus_desc_tokens = type_plus_desc.split(':')
|
||||
next = i + 1
|
||||
if next < count and section[next].startswith(';') == False:
|
||||
next_tokens = section[next].split()
|
||||
types[next_tokens[0]] = type_plus_desc_tokens[0].strip().upper()
|
||||
if len(type_plus_desc_tokens) > 1:
|
||||
descs[next_tokens[0]] = type_plus_desc_tokens[1].strip()
|
||||
continue
|
||||
|
||||
tokens = section[i].split()
|
||||
if tokens[0] not in curves:
|
||||
curves[tokens[0]] = []
|
||||
curves[tokens[0]].append({'x': float(tokens[1]), 'y': float(tokens[2])})
|
||||
|
||||
cs = ChangeSet()
|
||||
for id, coords in curves.items():
|
||||
c_type = types[id] if id in types else CURVE_TYPE_PUMP
|
||||
cs.append(g_add_prefix | {'type': 'curve', 'id' : id, 'c_type': c_type, 'coords' : coords})
|
||||
|
||||
#print(descs)
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_curve(name: str) -> list[str]:
|
||||
lines = []
|
||||
types = read_all(name, f"select * from _curve")
|
||||
for type in types:
|
||||
id = type['id']
|
||||
# ;type: desc
|
||||
lines.append(f";{type['type']}:")
|
||||
objs = read_all(name, f"select * from curves where id = '{id}' order by _order")
|
||||
for obj in objs:
|
||||
id = obj['id']
|
||||
x = obj['x']
|
||||
y = obj['y']
|
||||
lines.append(f'{id} {x} {y}')
|
||||
return lines
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# [EPA3][IN][OUT]
|
||||
# id type
|
||||
# id x y
|
||||
#--------------------------------------------------------------
|
||||
def inp_in_curve(section: list[str]) -> ChangeSet:
|
||||
def inp_in_curve_v3(section: list[str]) -> ChangeSet:
|
||||
types = {}
|
||||
descs = {}
|
||||
curves: dict[str, list[dict[str, float]]] = {}
|
||||
@@ -169,17 +219,5 @@ def inp_in_curve(section: list[str]) -> ChangeSet:
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_curve(name: str) -> list[str]:
|
||||
lines = []
|
||||
types = read_all(name, f"select * from _curve")
|
||||
for type in types:
|
||||
id = type['id']
|
||||
# ;type: desc
|
||||
lines.append(f";{type['type']}:")
|
||||
objs = read_all(name, f"select * from curves where id = '{id}' order by _order")
|
||||
for obj in objs:
|
||||
id = obj['id']
|
||||
x = obj['x']
|
||||
y = obj['y']
|
||||
lines.append(f'{id} {x} {y}')
|
||||
return lines
|
||||
def inp_out_curve_v3(name: str) -> list[str]:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user