diff options
| -rwxr-xr-x | underwriter | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/underwriter b/underwriter index dd62ef3..96e29bf 100755 --- a/underwriter +++ b/underwriter @@ -98,6 +98,13 @@ class Context: con.executescript(initscript) return con + def get_entry(self, s): + l = self.db.execute("""SELECT id,dat,file,created + FROM cards WHERE name = ?""", (s,)).fetchall() + if len(l) == 0: + return None + else: + return l[0] def get_data(self, s): l = self.db.execute("""SELECT dat, file FROM cards @@ -179,6 +186,18 @@ f""""{n}" already has a {typ} associated with it. Overwrite? [y/N]: """) else: sys.stdout.write(od["blob"]) + def report(self, l): + for i in l: + d = self.get_entry(i) + if d is None: + print("no card") + elif d[1] is not None: + print("blob") + elif d[2] is not None: + print(f"file {d[2]}") + else: + print("no data") + def __init__(self, name): if not os.path.isfile(name): self.db = Context.initdb(name) @@ -195,6 +214,8 @@ untag file [tags...]: remove tags from a file set [filename | blob] name file: associate a filename (or the contents of the file) with a name. retrieve name: get file data +type name: report the filename of "name", or the fact that is is a +blob, or "no data" if there is no data for the name, or "no card" list [tags | cards]: list all tags or cards in the database """ @@ -224,5 +245,6 @@ if __name__ == "__main__": ctx.set_filename) argparse.addarg(["set", "blob"], lambda x: x == 2, ctx.set_blob) argparse.addarg(["retrieve"], lambda x:x == 1, ctx.retrieve) + argparse.addarg(["type"], lambda x:x > 0, ctx.report) argparse.execarg(args) |
