get rid of circular imports part 2
This commit is contained in:
parent
ac3eb272ad
commit
46b97acf95
2 changed files with 38 additions and 3 deletions
|
|
@ -7,7 +7,6 @@ from .tracker import get
|
|||
import pyerrors.input.json as pj
|
||||
import os
|
||||
from configparser import ConfigParser
|
||||
from .find import list_ensembles, list_projects
|
||||
from typing import Any
|
||||
|
||||
|
||||
|
|
@ -64,6 +63,38 @@ def are_keys_unique(db: Path, table: str, col: str) -> bool:
|
|||
return bool(results[0] == results[1])
|
||||
|
||||
|
||||
def _list_projects(path: Path) -> list[tuple[str, str]]:
|
||||
"""
|
||||
List all projects known to the library.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
path: str
|
||||
The path of the library.
|
||||
|
||||
Returns
|
||||
-------
|
||||
results: list[Any]
|
||||
The projects known to the library.
|
||||
"""
|
||||
db_file = get_db_file(path)
|
||||
get(path, db_file)
|
||||
conn = sqlite3.connect(os.path.join(path, db_file))
|
||||
c = conn.cursor()
|
||||
c.execute("SELECT id,aliases FROM projects")
|
||||
results = c.fetchall()
|
||||
conn.close()
|
||||
return results
|
||||
|
||||
|
||||
def _list_ensembles(path: Path) -> list[str]:
|
||||
res = []
|
||||
for item in os.listdir(path / "archive"):
|
||||
if os.path.isdir(path / "archive" / item):
|
||||
res.append(item)
|
||||
return res
|
||||
|
||||
|
||||
def check_path_format(result: pd.Series, ensembles: list[str], projects: list[str]) -> None:
|
||||
"""
|
||||
Check whether the path of the given result has the right format.
|
||||
|
|
@ -107,8 +138,8 @@ def check_db_integrity(path: Path) -> None:
|
|||
search_expr = "SELECT * FROM 'backlogs'"
|
||||
conn = sqlite3.connect(path / db)
|
||||
results = pd.read_sql(search_expr, conn)
|
||||
ensembles = list_ensembles(path)
|
||||
projects = [p[0] for p in list_projects(path)]
|
||||
ensembles = _list_ensembles(path)
|
||||
projects = [p[0] for p in _list_projects(path)]
|
||||
|
||||
for _, result in results.iterrows():
|
||||
if not has_valid_times(result):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue