def is_processed(filepath): query = """select * from filelog where filename = ?""" c = conn.cursor() r = c.execute(query, (compat.decode(filepath), )) if len(r.fetchall()): return True else: return False
def get_processed_status(filepath): query = """select reason from filelog where filename = ?""" c = conn.cursor() r = c.execute(query, (compat.decode(filepath), )) row = r.fetchone() if row: reason = row[0] # An empty `reason` field means that it was successful if reason is None: colour, reason = GREEN, ":) done" else: # The status is only 10 chars wide (3 for smile) so we # chop the status text to 7 colour = RED reason = ":( %s" % reason[:7] return True, (colour, reason) else: return False, None
def add_to_filelist(filepath, reason=None): query = """insert into filelog(filename, reason) values(?, ?)""" c = conn.cursor() c.execute(query, (compat.decode(filepath), reason)) conn.commit()