Fix build error
This commit is contained in:
@@ -84,9 +84,9 @@ def inp_in_status(line: str) -> str:
|
||||
link = str(tokens[0])
|
||||
value = tokens[1].upper()
|
||||
if value == LINK_STATUS_OPEN or value == LINK_STATUS_CLOSED or value == LINK_STATUS_ACTIVE:
|
||||
return f"insert into status (link, status, setting) values ('{link}', '{value}', null);"
|
||||
return str(f"insert into status (link, status, setting) values ('{link}', '{value}', null);")
|
||||
else:
|
||||
return f"insert into status (link, status, setting) values ('{link}', null, {float(value)});"
|
||||
return str(f"insert into status (link, status, setting) values ('{link}', null, {float(value)});")
|
||||
|
||||
|
||||
def inp_out_status(name: str) -> list[str]:
|
||||
|
||||
@@ -151,7 +151,7 @@ def delete_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
def inp_in_curve(line: str) -> str:
|
||||
tokens = line.split()
|
||||
return f"insert into curves (id, x, y) values ('{tokens[0]}', {float(tokens[1])}, {float(tokens[2])});"
|
||||
return str(f"insert into curves (id, x, y) values ('{tokens[0]}', {float(tokens[1])}, {float(tokens[2])});")
|
||||
|
||||
|
||||
def inp_out_curve(name: str) -> list[str]:
|
||||
|
||||
@@ -45,7 +45,7 @@ def set_control(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
|
||||
def inp_in_control(line: str) -> str:
|
||||
return f"insert into controls (line) values ('{line}');"
|
||||
return str(f"insert into controls (line) values ('{line}');")
|
||||
|
||||
|
||||
def inp_out_control(name: str) -> list[str]:
|
||||
|
||||
@@ -41,7 +41,7 @@ def set_rule(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
|
||||
def inp_in_rule(line: str) -> str:
|
||||
return f"insert into rules (line) values ('{line}');"
|
||||
return str(f"insert into rules (line) values ('{line}');")
|
||||
|
||||
|
||||
def inp_out_rule(name: str) -> list[str]:
|
||||
|
||||
@@ -153,7 +153,7 @@ def inp_in_energy(line: str) -> str:
|
||||
if key == 'efficiency':
|
||||
key = 'effic'
|
||||
|
||||
return f"insert into energy_pump_{key} (pump, {key}) values ('{pump}', {value});"
|
||||
return str(f"insert into energy_pump_{key} (pump, {key}) values ('{pump}', {value});")
|
||||
|
||||
else:
|
||||
line = line.upper().strip()
|
||||
@@ -165,9 +165,9 @@ def inp_in_energy(line: str) -> str:
|
||||
if line.startswith('GLOBAL EFFICIENCY'):
|
||||
value = line.removeprefix('GLOBAL EFFICIENCY').strip()
|
||||
|
||||
return f"update energy set value = '{value}' where key = '{key}';"
|
||||
return str(f"update energy set value = '{value}' where key = '{key}';")
|
||||
|
||||
return ''
|
||||
return str('')
|
||||
|
||||
|
||||
def inp_out_energy(name: str) -> list[str]:
|
||||
|
||||
@@ -78,7 +78,7 @@ def inp_in_emitter(line: str) -> str:
|
||||
junction = str(tokens[0])
|
||||
coefficient = float(tokens[1])
|
||||
|
||||
return f"insert into emitters (junction, coefficient) values ('{junction}', {coefficient});"
|
||||
return str(f"insert into emitters (junction, coefficient) values ('{junction}', {coefficient});")
|
||||
|
||||
|
||||
def inp_out_emitter(name: str) -> list[str]:
|
||||
|
||||
@@ -75,7 +75,7 @@ def inp_in_quality(line: str) -> str:
|
||||
node = str(tokens[0])
|
||||
quality = float(tokens[1])
|
||||
|
||||
return f"insert into quality (node, quality) values ('{node}', {quality});"
|
||||
return str(f"insert into quality (node, quality) values ('{node}', {quality});")
|
||||
|
||||
|
||||
def inp_out_quality(name: str) -> list[str]:
|
||||
|
||||
@@ -121,8 +121,7 @@ def inp_in_source(line: str) -> str:
|
||||
pattern = str(tokens[3]) if num_without_desc >= 4 else None
|
||||
pattern = f"'{pattern}'" if pattern != None else 'null'
|
||||
|
||||
return f"insert into sources (node, s_type, strength, pattern) values ('{node}', '{s_type}', {strength}, {pattern});"
|
||||
|
||||
return str(f"insert into sources (node, s_type, strength, pattern) values ('{node}', '{s_type}', {strength}, {pattern});")
|
||||
|
||||
|
||||
def inp_out_source(name: str) -> list[str]:
|
||||
|
||||
@@ -201,21 +201,21 @@ def inp_in_reaction(line: str) -> str:
|
||||
pipe = tokens[1]
|
||||
key = token0.lower()
|
||||
value = tokens[2]
|
||||
return f"insert into reactions_pipe_{key} (pipe, value) values ('{pipe}', {value});"
|
||||
return str(f"insert into reactions_pipe_{key} (pipe, value) values ('{pipe}', {value});")
|
||||
|
||||
elif token0 == 'TANK':
|
||||
tank = tokens[1]
|
||||
value = tokens[2]
|
||||
return f"insert into reactions_tank (tank, value) values ('{tank}', {value});"
|
||||
return str(f"insert into reactions_tank (tank, value) values ('{tank}', {value});")
|
||||
|
||||
else:
|
||||
line = line.upper().strip()
|
||||
for key in get_reaction_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
return f"update reactions set value = '{value}' where key = '{key}';"
|
||||
return str(f"update reactions set value = '{value}' where key = '{key}';")
|
||||
|
||||
return ''
|
||||
return str('')
|
||||
|
||||
|
||||
def inp_out_reaction(name: str) -> list[str]:
|
||||
|
||||
@@ -29,10 +29,10 @@ def set_title(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
def inp_in_title(section: list[str]) -> str:
|
||||
if section == []:
|
||||
return ''
|
||||
return str('')
|
||||
|
||||
title = '\n'.join(section)
|
||||
return f"update title set value = '{title}';"
|
||||
return str(f"update title set value = '{title}';")
|
||||
|
||||
|
||||
def inp_out_title(name: str) -> list[str]:
|
||||
|
||||
@@ -129,7 +129,7 @@ def inp_in_mixing(line: str) -> str:
|
||||
value = float(tokens[3]) if num_without_desc >= 4 else None
|
||||
value = value if value != None else 'null'
|
||||
|
||||
return f"insert into mixing (tank, model, value) values ('{tank}', '{model}', {value});"
|
||||
return str(f"insert into mixing (tank, model, value) values ('{tank}', '{model}', {value});")
|
||||
|
||||
|
||||
def inp_out_mixing(name: str) -> list[str]:
|
||||
|
||||
@@ -3,16 +3,16 @@ from .database import *
|
||||
|
||||
def sql_update_coord(node: str, x: float, y: float) -> str:
|
||||
coord = f"st_geomfromtext('point({x} {y})')"
|
||||
return f"update coordinates set coord = {coord} where node = '{node}';"
|
||||
return str(f"update coordinates set coord = {coord} where node = '{node}';")
|
||||
|
||||
|
||||
def sql_insert_coord(node: str, x: float, y: float) -> str:
|
||||
coord = f"st_geomfromtext('point({x} {y})')"
|
||||
return f"insert into coordinates (node, coord) values ('{node}', {coord});"
|
||||
return str(f"insert into coordinates (node, coord) values ('{node}', {coord});")
|
||||
|
||||
|
||||
def sql_delete_coord(node: str) -> str:
|
||||
return f"delete from coordinates where node = '{node}';"
|
||||
return str(f"delete from coordinates where node = '{node}';")
|
||||
|
||||
|
||||
def from_postgis_point(coord: str) -> dict[str, float]:
|
||||
@@ -43,7 +43,7 @@ def inp_in_coord(line: str) -> str:
|
||||
tokens = line.split()
|
||||
node = tokens[0]
|
||||
coord = f"st_geomfromtext('point({tokens[1]} {tokens[2]})')"
|
||||
return f"insert into coordinates (node, coord) values ('{node}', {coord});"
|
||||
return str(f"insert into coordinates (node, coord) values ('{node}', {coord});")
|
||||
|
||||
|
||||
def inp_out_coord(name: str) -> list[str]:
|
||||
|
||||
@@ -99,7 +99,7 @@ def inp_in_vertex(line: str) -> str:
|
||||
link = tokens[0]
|
||||
x = float(tokens[1])
|
||||
y = float(tokens[2])
|
||||
return f"insert into vertices (link, x, y) values ('{link}', {x}, {y});"
|
||||
return str(f"insert into vertices (link, x, y) values ('{link}', {x}, {y});")
|
||||
|
||||
|
||||
def inp_out_vertex(name: str) -> list[str]:
|
||||
|
||||
@@ -112,7 +112,7 @@ def inp_in_label(line: str) -> str:
|
||||
node = str(tokens[3]) if num >= 4 else None
|
||||
node = f"'{node}'" if node != None else 'null'
|
||||
|
||||
return f"insert into labels (x, y, label, node) values ({x}, {y}, '{label}', {node});"
|
||||
return str(f"insert into labels (x, y, label, node) values ({x}, {y}, '{label}', {node});")
|
||||
|
||||
|
||||
def inp_out_label(name: str) -> list[str]:
|
||||
|
||||
@@ -28,10 +28,10 @@ def set_backdrop(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
def inp_in_backdrop(section: list[str]) -> str:
|
||||
if section == []:
|
||||
return ''
|
||||
return str('')
|
||||
|
||||
content = '\n'.join(section)
|
||||
return f"update backdrop set content = '{content}';"
|
||||
return str(f"update backdrop set content = '{content}';")
|
||||
|
||||
|
||||
def inp_out_backdrop(name: str) -> list[str]:
|
||||
|
||||
@@ -158,7 +158,7 @@ def inp_in_junction(line: str, demand_outside: bool) -> str:
|
||||
if demand != None and demand_outside == False:
|
||||
sql += f"insert into demands (junction, demand, pattern) values ('{id}', {demand}, {pattern});"
|
||||
|
||||
return sql
|
||||
return str(sql)
|
||||
|
||||
|
||||
def inp_out_junction(name: str) -> list[str]:
|
||||
|
||||
@@ -22,14 +22,14 @@ def to_postgis_polygon(boundary: list[tuple[float, float]]) -> str:
|
||||
polygon = ''
|
||||
for pt in boundary:
|
||||
polygon += f'{pt[0]} {pt[1]},'
|
||||
return f'polygon(({polygon[:-1]}))'
|
||||
return str(f'polygon(({polygon[:-1]}))')
|
||||
|
||||
|
||||
def to_postgis_linestring(boundary: list[tuple[float, float]]) -> str:
|
||||
line = ''
|
||||
for pt in boundary:
|
||||
line += f'{pt[0]} {pt[1]},'
|
||||
return f'linestring({line[:-1]})'
|
||||
return str(f'linestring({line[:-1]})')
|
||||
|
||||
|
||||
def get_nodes_in_boundary(name: str, boundary: list[tuple[float, float]]) -> list[str]:
|
||||
|
||||
@@ -148,7 +148,7 @@ def inp_in_reservoir(line: str) -> str:
|
||||
pattern = f"'{pattern}'" if pattern != None else 'null'
|
||||
desc = str(tokens[-1]) if has_desc else None
|
||||
|
||||
return f"insert into _node (id, type) values ('{id}', 'reservoir');insert into reservoirs (id, head, pattern) values ('{id}', {head}, {pattern});"
|
||||
return str(f"insert into _node (id, type) values ('{id}', 'reservoir');insert into reservoirs (id, head, pattern) values ('{id}', {head}, {pattern});")
|
||||
|
||||
|
||||
def inp_out_reservoir(name: str) -> list[str]:
|
||||
|
||||
@@ -191,7 +191,7 @@ def inp_in_tank(line: str) -> str:
|
||||
overflow = f"'{overflow}'" if overflow != None else 'null'
|
||||
desc = str(tokens[-1]) if has_desc else None
|
||||
|
||||
return f"insert into _node (id, type) values ('{id}', 'tank');insert into tanks (id, elevation, init_level, min_level, max_level, diameter, min_vol, vol_curve, overflow) values ('{id}', {elevation}, {init_level}, {min_level}, {max_level}, {diameter}, {min_vol}, {vol_curve}, {overflow});"
|
||||
return str(f"insert into _node (id, type) values ('{id}', 'tank');insert into tanks (id, elevation, init_level, min_level, max_level, diameter, min_vol, vol_curve, overflow) values ('{id}', {elevation}, {init_level}, {min_level}, {max_level}, {diameter}, {min_vol}, {vol_curve}, {overflow});")
|
||||
|
||||
|
||||
def inp_out_tank(name: str) -> list[str]:
|
||||
|
||||
@@ -164,7 +164,7 @@ def inp_in_pipe(line: str) -> str:
|
||||
status = str(tokens[7].upper()) if num_without_desc >= 8 else PIPE_STATUS_OPEN
|
||||
desc = str(tokens[-1]) if has_desc else None
|
||||
|
||||
return f"insert into _link (id, type) values ('{id}', 'pipe');insert into pipes (id, node1, node2, length, diameter, roughness, minor_loss, status) values ('{id}', '{node1}', '{node2}', {length}, {diameter}, {roughness}, {minor_loss}, '{status}');"
|
||||
return str(f"insert into _link (id, type) values ('{id}', 'pipe');insert into pipes (id, node1, node2, length, diameter, roughness, minor_loss, status) values ('{id}', '{node1}', '{node2}', {length}, {diameter}, {roughness}, {minor_loss}, '{status}');")
|
||||
|
||||
|
||||
def inp_out_pipe(name: str) -> list[str]:
|
||||
|
||||
@@ -158,7 +158,7 @@ def inp_in_pump(line: str) -> str:
|
||||
pattern = f"'{pattern}'" if pattern != None else 'null'
|
||||
desc = str(tokens[-1]) if has_desc else None
|
||||
|
||||
return f"insert into _link (id, type) values ('{id}', 'pump');insert into pumps (id, node1, node2, power, head, speed, pattern) values ('{id}', '{node1}', '{node2}', {power}, {head}, {speed}, {pattern});"
|
||||
return str(f"insert into _link (id, type) values ('{id}', 'pump');insert into pumps (id, node1, node2, power, head, speed, pattern) values ('{id}', '{node1}', '{node2}', {power}, {head}, {speed}, {pattern});")
|
||||
|
||||
|
||||
def inp_out_pump(name: str) -> list[str]:
|
||||
|
||||
@@ -160,7 +160,7 @@ def inp_in_valve(line: str) -> str:
|
||||
minor_loss = float(tokens[6]) if len(tokens) >= 7 else 0.0
|
||||
desc = str(tokens[-1]) if has_desc else None
|
||||
|
||||
return f"insert into _link (id, type) values ('{id}', 'valve');insert into valves (id, node1, node2, diameter, v_type, setting, minor_loss) values ('{id}', '{node1}', '{node2}', {diameter}, '{v_type}', '{setting}', {minor_loss});"
|
||||
return str(f"insert into _link (id, type) values ('{id}', 'valve');insert into valves (id, node1, node2, diameter, v_type, setting, minor_loss) values ('{id}', '{node1}', '{node2}', {diameter}, '{v_type}', '{setting}', {minor_loss});")
|
||||
|
||||
|
||||
def inp_out_valve(name: str) -> list[str]:
|
||||
|
||||
@@ -104,10 +104,10 @@ def inp_in_tag(line: str) -> str:
|
||||
tag = str(tokens[2])
|
||||
|
||||
if t_type == TAG_TYPE_NODE:
|
||||
return f"insert into tags_node (id, tag) values ('{id}', '{tag}');"
|
||||
return str(f"insert into tags_node (id, tag) values ('{id}', '{tag}');")
|
||||
elif t_type == TAG_TYPE_LINK:
|
||||
return f"insert into tags_link (id, tag) values ('{id}', '{tag}');"
|
||||
return ''
|
||||
return str(f"insert into tags_link (id, tag) values ('{id}', '{tag}');")
|
||||
return str('')
|
||||
|
||||
|
||||
def inp_out_tag(name: str) -> list[str]:
|
||||
|
||||
@@ -79,7 +79,7 @@ def inp_in_demand(line: str) -> str:
|
||||
category = str(tokens[3]) if num_without_desc >= 4 else None
|
||||
category = f"'{category}'" if category != None else 'null'
|
||||
|
||||
return f"insert into demands (junction, demand, pattern, category) values ('{junction}', {demand}, {pattern}, {category});"
|
||||
return str(f"insert into demands (junction, demand, pattern, category) values ('{junction}', {demand}, {pattern}, {category});")
|
||||
|
||||
|
||||
def inp_out_demand(name: str) -> list[str]:
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
from distutils.core import setup
|
||||
from Cython.Build import cythonize
|
||||
|
||||
setup(ext_modules=cythonize("tjnetwork.py"))
|
||||
setup(ext_modules=cythonize([
|
||||
"tjnetwork.py",
|
||||
"api/*.py",
|
||||
"epanet/*.py"
|
||||
]))
|
||||
Reference in New Issue
Block a user