Commit 6d272674 authored by Inkhey's avatar Inkhey

depth capacity

parent a2a2176a
......@@ -11,7 +11,8 @@
import sqlite3
import os
# TODO:  import walkdir <- use walkir instead of os.walk to be able
from walkdir import filtered_walk, all_paths
# use walkir instead of os.walk to be able
# to select a depth
......@@ -112,14 +113,27 @@ class sqlGit(object):
def insert_file(self, depth):
''' insert file data into file table, depth define how precise
file data will be.'''
if depth > 0:
mdepth = depth
else:
mdepth = None
c = self.conn.cursor()
# TODO : gérer profondeur et ignorer fichier dans .git ?
for root, dirs, files in os.walk(".", topdown=True):
for root, dirs, files in filtered_walk(".", depth=depth):
for fn in files:
path = os.path.join(root, fn)
size = os.stat(path).st_size
data = (root, size, fn)
data = (fn, size, root)
c.execute(
'''INSERT INTO file(name,size,dir)
values (?,?,?);''', data)
for root, dirs, files in filtered_walk(".",
depth=depth,
min_depth=mdepth):
for d in dirs:
path = os.path.join(root, d)
size = os.stat(path).st_size
data = (d, size, root)
c.execute(
'''INSERT INTO file(name,size,dir)
values (?,?,?);''', data)
......
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