From 8fa3551ed61c39b4e659be801dbb12304d75d015 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 9 Jun 2020 13:17:55 +1000 Subject: [PATCH] Add recursive printing for show_by_* --- src/pyelephant.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pyelephant.py b/src/pyelephant.py index 6292f86..b4e194b 100755 --- a/src/pyelephant.py +++ b/src/pyelephant.py @@ -49,7 +49,7 @@ def add(session: sa.orm.Session, title: str, due: str = None, depends: List[int] depends = [] obj = Task(title=title, due_at=due) - obj.depends.extend([session.query(Task).filter(Task.id == idx).one() for idx in depends]) + obj.depends.extend(session.query(Task).filter(Task.id == idx).one() for idx in depends) session.add(obj) session.commit() @@ -72,6 +72,8 @@ def rm(session: sa.orm.Session, index: int): # ----------------------------------------------------------------------------- def show_by_obj(session: sa.orm.Session, obj: Task): + for idx in [i.id for i in obj.depends]: + show_by_id(session, idx) print(obj.id, obj.created_at, obj.due_at, obj.active, obj.title, [i.id for i in obj.depends])