From 37f2f17ff3252ba5bb13f35b306aac0db224aa7d Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Tue, 27 Nov 2018 11:54:54 -0600 Subject: [PATCH] Newline between functios --- backup.py | 3 +++ restore.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backup.py b/backup.py index 0c3509a..77baf43 100755 --- a/backup.py +++ b/backup.py @@ -53,18 +53,21 @@ def hashify(top): print(e,file) os.chdir(old_dir) return ret + def __init_database__(path): con = sqlite3.connect(path) cur = con.cursor() cur.execute('CREATE TABLE IF NOT EXISTS `paths` (`path` TEXT, `imohash` BLOB, `blake` BLOB, UNIQUE(`path`, `imohash`, `blake`));') con.commit() return con + def backup(top,db_path): paths = hashify(top) con = __init_database__(db_path) cur = con.cursor() cur.executemany('INSERT OR IGNORE INTO `paths` VALUES (?,?,?);',paths) con.commit() + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('dir') diff --git a/restore.py b/restore.py index b59290e..e13c094 100755 --- a/restore.py +++ b/restore.py @@ -11,14 +11,15 @@ def create_temp(): name= 'fsb{}'.format(hex(time.time_ns())[2:]) os.mkdir(name) return name + def lookup(cur,imohash,realhash=None): if realhash is not None: cur.execute('SELECT path FROM paths where blake=?',[realhash]) else: cur.execute('SELECT path FROM paths where imohash=?',[imohash]) - res = cur.fetchone() - if len(res) == 1: - return res[0] + res = cur.fetchall() + return res + def restore(database,source,destination): con=sqlite3.connect(database) cur=con.cursor() @@ -34,6 +35,7 @@ def restore(database,source,destination): print(ppath,qpath,sep = '->') os.rename(ppath,qpath) os.rename(temp,destination) + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('database')