Get api
This commit is contained in:
@@ -12,6 +12,7 @@ from .s0_base import is_node, is_junction, is_reservoir, is_tank
|
||||
from .s0_base import is_link, is_pipe, is_pump, is_valve
|
||||
from .s0_base import is_curve
|
||||
from .s0_base import is_pattern
|
||||
from .s0_base import get_nodes, get_links, get_curves, get_patterns
|
||||
|
||||
from .s1_title import set_title, get_title
|
||||
|
||||
|
||||
@@ -53,3 +53,23 @@ def is_curve(name: str, id: str) -> bool:
|
||||
|
||||
def is_pattern(name: str, id: str) -> bool:
|
||||
return _get_from(name, id, _PATTERN) != None
|
||||
|
||||
def _get_all(name: str, base_type: str) -> list[str]:
|
||||
ids : list[str] = []
|
||||
with conn[name].cursor(row_factory=dict_row) as cur:
|
||||
cur.execute(f"select id from {base_type} order by id")
|
||||
for record in cur:
|
||||
ids.append(record['id'])
|
||||
return ids
|
||||
|
||||
def get_nodes(name: str) -> list[str]:
|
||||
return _get_all(name, _NODE)
|
||||
|
||||
def get_links(name: str) -> list[str]:
|
||||
return _get_all(name, _LINK)
|
||||
|
||||
def get_curves(name: str) -> list[str]:
|
||||
return _get_all(name, _CURVE)
|
||||
|
||||
def get_patterns(name: str) -> list[str]:
|
||||
return _get_all(name, _PATTERN)
|
||||
|
||||
@@ -104,6 +104,18 @@ def is_curve(name: str, curve_id: str) -> bool:
|
||||
def is_pattern(name: str, pattern_id: str) -> bool:
|
||||
return api.is_pattern(name, pattern_id)
|
||||
|
||||
def get_nodes(name: str) -> list[str]:
|
||||
return api.get_nodes(name)
|
||||
|
||||
def get_links(name: str) -> list[str]:
|
||||
return api.get_links(name)
|
||||
|
||||
def get_curves(name: str) -> list[str]:
|
||||
return api.get_curves(name)
|
||||
|
||||
def get_patterns(name: str) -> list[str]:
|
||||
return api.get_patterns(name)
|
||||
|
||||
|
||||
############################################################
|
||||
# title 1.[TITLE]
|
||||
|
||||
Reference in New Issue
Block a user