def build_goaltree(*goal_prototypes, message_fn=None): goals = [(g.goal_id, g.name, g.open) for g in goal_prototypes] edges = [(g.goal_id, e, EdgeType.PARENT) for g in goal_prototypes for e in g.children] + [(g.goal_id, e, EdgeType.BLOCKER) for g in goal_prototypes for e in g.blockers] selection = {g.goal_id for g in goal_prototypes if g.select == selected} prev_selection = { g.goal_id for g in goal_prototypes if g.select == previous } assert len(selection) == 1 assert len(prev_selection) <= 1 selection_id = selection.pop() return Goals.build( goals, edges, [ ("selection", selection_id), ( "previous_selection", prev_selection.pop() if prev_selection else selection_id, ), ], message_fn, )
def build_goals(conn): with closing(conn.cursor()) as cur: goals = [row for row in cur.execute('select * from goals')] edges = [row for row in cur.execute('select * from edges')] selection = [row for row in cur.execute('select * from settings')] note(goals) note(edges) note(selection) return Goals.build(goals, edges, selection)
def build_goals(conn): with closing(conn.cursor()) as cur: goals = list(cur.execute("select * from goals")) edges = list(cur.execute("select parent, child, reltype from edges")) db_settings = list(cur.execute("select * from settings")) zoom_data = list(cur.execute("select * from zoom")) autolink_data = list(cur.execute("select * from autolink")) note( f"Goals: {goals}, Edges: {edges}, Settings: {db_settings}, Zoom: {zoom_data}, Autolink: {autolink_data}" ) goals = Goals.build(goals, edges, db_settings) return all_layers(goals, zoom_data, autolink_data)
def load(filename=DEFAULT_DB): if path.isfile(filename): connection = sqlite3.connect(filename) run_migrations(connection) cur = connection.cursor() goals = [row for row in cur.execute('select * from goals')] edges = [row for row in cur.execute('select * from edges')] settings = [row for row in cur.execute('select * from settings')] cur.close() goals = Goals.build(goals, edges, settings) else: goals = Goals('Rename me') return Enumeration(Zoom(goals))