Use __init__.py to manage api module

This commit is contained in:
wqy
2022-09-02 20:29:22 +08:00
parent 99958a24ca
commit 013d037b0a
9 changed files with 54 additions and 43 deletions

14
api/__init__.py Normal file
View File

@@ -0,0 +1,14 @@
from api.s0_base import delete_curve, delete_node, delete_pattern
from project import have_project, create_project, delete_project
from project import is_project_open, open_project, close_project
from operation import execute_undo as undo
from operation import execute_redo as redo
from s0_base import add_node, add_link, add_curve, add_pattern
from s0_base import have_node, have_link, have_curve, have_pattern
from s0_base import is_junction, is_reservoir, is_tank
from s0_base import is_pipe, is_pump, is_valve
from s0_base import delete_node, delete_link, delete_curve, delete_pattern
from s1_title import set_title, get_title

View File

@@ -1,5 +1,5 @@
from psycopg.rows import dict_row
from api.connection import g_conn_dict as conn
from connection import g_conn_dict as conn
def _get_current_operation(name: str) -> int:
with conn[name].cursor(row_factory=dict_row) as cur:

View File

@@ -1,5 +1,5 @@
import psycopg as pg
from api.connection import g_conn_dict as conn
from connection import g_conn_dict as conn
def have_project(name: str) -> bool:
with pg.connect(conninfo="dbname=postgres", autocommit=True) as conn:

View File

@@ -1,6 +1,6 @@
from psycopg.rows import dict_row
from api.connection import g_conn_dict as conn
from api.operation import *
from connection import g_conn_dict as conn
from operation import *
_NODE = "_node"
_LINK = "_link"

View File

@@ -1,5 +1,5 @@
from psycopg.rows import dict_row
from api.connection import g_conn_dict as conn
from connection import g_conn_dict as conn
def set_title(name: str, value: str) -> None:
with conn[name].cursor() as cur:

View File

@@ -1,5 +1,5 @@
from api.project import *
from api.s0_base import *
from project import *
from s0_base import *
p = "test_operation"

View File

@@ -1,5 +1,5 @@
from api.project import *
from api.s0_base import *
from project import *
from s0_base import *
p = "test_s0_base"
n_1 = "n_1"

View File

@@ -1,5 +1,5 @@
from api.project import *
from api.s1_title import *
from project import *
from s1_title import *
p = "test_s1_title"