Commit 501704c8 authored by Inkhey's avatar Inkhey

better generator for file

parent 549f22af
...@@ -115,20 +115,19 @@ class sqlGit(object): ...@@ -115,20 +115,19 @@ class sqlGit(object):
data = line.split('[;;|\/|;;]') data = line.split('[;;|\/|;;]')
yield (data) yield (data)
def _gInsertFile(self,depth,mdepth): def _gInsertFile(self,depth):
for root, dirs, files in filtered_walk(".", depth=depth): for root, dirs, files in filtered_walk(".", depth=depth):
for fn in files: for fn in files:
path = os.path.join(root, fn) path = os.path.join(root, fn)
size = os.path.getsize(path) size = os.path.getsize(path)
data = (fn, size, root) data = (fn, size, root)
yield(data) yield(data)
for root, dirs, files in filtered_walk(".",
depth=depth, if( root.count("/") == depth):
min_depth=mdepth): for d in dirs:
for d in dirs: path = os.path.join(root, d)
path = os.path.join(root, d) size = self._get_size_dir(path)
size = self._get_size_dir(path) data = (d, size, root)
data = (d, size, root)
yield(data) yield(data)
def _gInsertLFC(self,l): def _gInsertLFC(self,l):
...@@ -197,13 +196,9 @@ class sqlGit(object): ...@@ -197,13 +196,9 @@ class sqlGit(object):
def insert_file(self,depth): def insert_file(self,depth):
''' insert file data into file table, depth define how precise ''' insert file data into file table, depth define how precise
file data will be.''' file data will be.'''
if depth > 0:
mdepth = depth
else:
mdepth = None
c = self.conn.cursor() c = self.conn.cursor()
# TODO : gérer profondeur et ignorer fichier dans .git ? # TODO : gérer profondeur et ignorer fichier dans .git ?
g = self._gInsertFile(depth,mdepth) g = self._gInsertFile(depth)
c.executemany( c.executemany(
'''INSERT INTO file(name,size,dir) '''INSERT INTO file(name,size,dir)
values (?,?,?);''', g) values (?,?,?);''', g)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment