PK!800hello_todo/.cli.py.swpb0VIM 8.0r[%xZmathiasGration~mathias/workspace/hello_todo/hello_todo/cli.pyutf-8 3210#"! UtpBad%BpL NML; V K 5 r E $ \ R Q P ? .  | +  s  RQP5%  t todo_list()if __name__ == "__main__": db.add_todo(name, todolist_id, description, deadline)def add_todo(name, todolist_id, deadline, description):@click.option("-d", "--description", default=None, help="Todo description")@click.option("-x", "--deadline", default=None, help="Deadline in format YYYY-MM-dd hh:mm:ss.sss")@click.option("-l", "--todolist_id", help="Todo list id")@click.option("-n", "--name", help="Todo name")@click.command() db.add_todolist(name, description)def add_todolist():@click.option("-d", "--description", default=None, help="Todo list description")@click.option("-n", "--name", help="Todo list name")@click.command() click.echo("initialized db at %s", os.path.join(os.environ["HOME"], ".todolist.db")) db.init_db()def init_todo():@click.command() ) % (status.center(6), deadline.center(25), name.center(20), description.center(20)) "%s|%s|%s|%s" print( description = r["description"] name = r["name"] deadline = r["deadline"] status = "x" if r["status"] else " " for r in results: print("%s+%s+%s+%s" % ("-" * 6, "-" * 25, "-" * 20, "-" * 20)) ) % ("status".center(6), "deadline".center(25), "name".center(20), "description".center(20)) "%s|%s|%s|%s" print( print("** %s **" % todolist_name.upper()) results = db.get_todos(todolist_id) todolist_name = db.get_todolist(todolist_id)["name"]def todo_list(todolist_id):@click.option("-l", "--todolist_id", help="Todo list id")@click.command() print("%s|%s" % (name.center(20), desc.center(20))) desc = r["description"] or "" name = r["name"] for r in results: print("%s+%s" % ("-" * 20, "-" * 20)) print("%s|%s" % ("name".center(20), "description".center(20))) results = db.get_all_todolist()def todo_lists():@click.command() from . import dbelse: from hello_todo import dbif __name__ == '__main__':import osimport clickPK!-00hello_todo/.db.py.swpb0VIM 8.0o[i&xZmathiasGration~mathias/workspace/hello_todo/hello_todo/db.py 3210#"! Utp9ad  9;\.-, ` _ ^  | ] U T E  l k j N : + y  ! return conn.execute("SELECT * FROM todolist where id = ?", (todolist_id, )).fetchone() with conn: conn = get_db()def get_todolist(todolist_id): return results results = conn.execute("SELECT * FROM todo where todolist_id = ?", (todolist_id,)) with conn: conn = get_db()def get_todos(todolist_id): return results results = conn.execute("SELECT * FROM todolist") with conn: conn = get_db()def get_all_todolist(): conn.execute(query, (name, description, deadline, status, todolist_id)) with conn: """ values (?, ?, ?, ?, ?) INSERT INTO todo (name, description, deadline, status, todolist_id) query = """ conn = get_db() """ add a todo to a todolist """def add_todo(name, todolist_id, description=None, deadline=None, status=0): conn.execute("INSERT INTO todolist (name, description) values (?, ?)", (name, description)) with conn: conn = get_db() """ add a todolist """def add_todolist(name, description=None): conn.executescript(query.decode("utf-8")) query = pkg_resources.resource_string(__name__, "init_db.sql") conn = get_db() """ initialize database """def init_db(): return conn conn.row_factory = sqlite3.Row conn = sqlite3.connect(db_path) db_path = db_path or os.path.join(os.environ["HOME"], ".todolist.db") """ returns a connection to the database """def get_db(db_path=None):import pkg_resourcesimport osimport sqlite3PK!`00hello_todo/.init_db.sql.swpb0VIM 8.0c[%xZmathiasGration~mathias/workspace/hello_todo/hello_todo/init_db.sqlutf-8 3210#"! Utpad /[>;:'i2/); FOREIGN KEY (todolist_id) REFERENCES todolist (id) todolist_id INTEGER NOT NULL, status INTEGER, deadline VARCHAR(23), description VARCHAR(150), name VARCHAR(50) UNIQUE NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT,CREATE TABLE todo(); description VARCHAR(150) name VARCHAR(50) UNIQUE NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT,CREATE TABLE todolist (DROP TABLE IF EXISTS todo ;DROP TABLE IF EXISTS todolist ;PK! qhello_todo/__init__.py__version__ = '0.1.0' PK!Rlhello_todo/cli.pyimport click import os if __name__ == '__main__': from hello_todo import db else: from . import db @click.command() def todo_lists(): results = db.get_all_todolist() print("%s|%s" % ("name".center(20), "description".center(20))) print("%s+%s" % ("-" * 20, "-" * 20)) for r in results: name = r["name"] desc = r["description"] or "" print("%s|%s" % (name.center(20), desc.center(20))) @click.command() @click.option("-l", "--todolist_id", help="Todo list id") def todo_list(todolist_id): todolist_name = db.get_todolist(todolist_id)["name"] results = db.get_todos(todolist_id) print("** %s **" % todolist_name.upper()) print( "%s|%s|%s|%s" % ("status".center(6), "deadline".center(25), "name".center(20), "description".center(20)) ) print("%s+%s+%s+%s" % ("-" * 6, "-" * 25, "-" * 20, "-" * 20)) for r in results: status = "x" if r["status"] else " " deadline = r["deadline"] name = r["name"] description = r["description"] print( "%s|%s|%s|%s" % (status.center(6), deadline.center(25), name.center(20), description.center(20)) ) @click.command() def init_todo(): db.init_db() click.echo("initialized db at %s", os.path.join(os.environ["HOME"], ".todolist.db")) @click.command() @click.option("-n", "--name", help="Todo list name") @click.option("-d", "--description", default=None, help="Todo list description") def add_todolist(): db.add_todolist(name, description) @click.command() @click.option("-n", "--name", help="Todo name") @click.option("-l", "--todolist_id", help="Todo list id") @click.option("-x", "--deadline", default=None, help="Deadline in format YYYY-MM-dd hh:mm:ss.sss") @click.option("-d", "--description", default=None, help="Todo description") def add_todo(name, todolist_id, deadline, description): db.add_todo(name, todolist_id, description, deadline) if __name__ == "__main__": todo_list() PK!ǑAhello_todo/db.pyimport sqlite3 import os import pkg_resources def get_db(db_path=None): """ returns a connection to the database """ db_path = db_path or os.path.join(os.environ["HOME"], ".todolist.db") conn = sqlite3.connect(db_path) conn.row_factory = sqlite3.Row return conn def init_db(): """ initialize database """ conn = get_db() query = pkg_resources.resource_string(__name__, "init_db.sql") conn.executescript(query.decode("utf-8")) def add_todolist(name, description=None): """ add a todolist """ conn = get_db() with conn: conn.execute("INSERT INTO todolist (name, description) values (?, ?)", (name, description)) def add_todo(name, todolist_id, description=None, deadline=None, status=0): """ add a todo to a todolist """ conn = get_db() query = """ INSERT INTO todo (name, description, deadline, status, todolist_id) values (?, ?, ?, ?, ?) """ with conn: conn.execute(query, (name, description, deadline, status, todolist_id)) def get_all_todolist(): conn = get_db() with conn: results = conn.execute("SELECT * FROM todolist") return results def get_todos(todolist_id): conn = get_db() with conn: results = conn.execute("SELECT * FROM todo where todolist_id = ?", (todolist_id,)) return results def get_todolist(todolist_id): conn = get_db() with conn: return conn.execute("SELECT * FROM todolist where id = ?", (todolist_id, )).fetchone() PK!u2hello_todo/init_db.sqlDROP TABLE IF EXISTS todolist ; DROP TABLE IF EXISTS todo ; CREATE TABLE todolist ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50) UNIQUE NOT NULL, description VARCHAR(150) ); CREATE TABLE todo( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50) UNIQUE NOT NULL, description VARCHAR(150), deadline VARCHAR(23), status INTEGER, todolist_id INTEGER NOT NULL, FOREIGN KEY (todolist_id) REFERENCES todolist (id) ); PK!H K+hello_todo-0.1.3.dist-info/entry_points.txtN+I/N.,()JLI/OɷH3s2`p9%22Kbtep. F<Ȉb..PK!H WX hello_todo-0.1.3.dist-info/WHEEL A н#Z."jm)Afb~ڠO68oF04UhoAf f4=4h0k::wXPK!HM#hello_todo-0.1.3.dist-info/METADATAN1 U9MT?PyZUhZٸh6.^eyr0x7|WJuPK!H̞|% [!hello_todo-0.1.3.dist-info/RECORD}ɎP}] RdrQ (tCPfhÑoSS7|?^Ox7X$|( d#\Wo;FD"5h+;B I{K^xtC9SwZ3L+b?Hv܃*$؟~onԹLT@t=V1R*7Cɟy+8nVR;ءc +J!x҄"FXBf3T61gcfbz/z9x7b@]WcC/ |YVYB0P%tW,<7xx9# w/٥jŦM_{Y/ÂTCm?c5o_Ug9-JC5^FoPU8&ζkI/cTOʖFbŰPK!800hello_todo/.cli.py.swpPK!-0040hello_todo/.db.py.swpPK!`00g`hello_todo/.init_db.sql.swpPK! qhello_todo/__init__.pyPK!Rlhello_todo/cli.pyPK!ǑAhello_todo/db.pyPK!u2hello_todo/init_db.sqlPK!H K+ hello_todo-0.1.3.dist-info/entry_points.txtPK!H WX hello_todo-0.1.3.dist-info/WHEELPK!HM#6hello_todo-0.1.3.dist-info/METADATAPK!H̞|% [!Fhello_todo-0.1.3.dist-info/RECORDPK