From ff651ac9238e34202bcc5af18997af47e7bb0982 Mon Sep 17 00:00:00 2001 From: rlbr Date: Thu, 6 Dec 2018 12:45:21 -0600 Subject: [PATCH] filled out db_save and backup --- fs_class.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs_class.py b/fs_class.py index b30a09d..8ff1a89 100755 --- a/fs_class.py +++ b/fs_class.py @@ -67,13 +67,23 @@ class fs: self.id = id def write_to_db(self): - pass + '''stores self.hash_files in database, along with a backup id and hash_func parameters''' + for hash,files in self.hash_files.item() + for file in files: + self.cur.execue('INSERT INTO paths VALUES (?,?)',[hash,file]) + self.con.commit() def morph(self,other): + '''renames/copies all files in self.top to match other''' pass def backup(self,other): + '''fills in self.hash_file {hash:[filepaths]}''' + paths = hashify(self.top,self.hashfunc) + for filepath,hash in paths: + self.hash_file.setdefault(hash,[]).append(filepath) + if __name__ == "__main__": import os test = fs(os.getcwd())