-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInit.py
More file actions
60 lines (57 loc) · 1.72 KB
/
Copy pathInit.py
File metadata and controls
60 lines (57 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from lib.FileOperate import getDirData,collectFileData
from lib.Policy import setRule
from lib.Config import *
from lib.DBOperate import *
import time
import sqlite3
import threading
def insertOne(file):
fdata = filedb
file = file.encode('UTF-8', 'ignore').decode('UTF-8')
fdata['PATH'] = file
fdata['Rule_Type'], fdata['Rule_Check'] = setRule(file)
if not fdata['Rule_Check'] == '':
fdata = collectFileData(fdata)
if not fdata == None:
a = SQLinsert('FILEDB', fdata)
c.execute(a)
def buildInitDB(allfile):
for file in allfile:
insertOne(file)
# ts = []
# for file in allfile[:5]:
# print(file)
# t = threading.Thread(target=insertOne,args=(file,))
# t.start()
# ts.append(t)
# for t in ts:
# t.join()
# for i in range(len(allfile)%500):
# ts = []
# if (i + 1) * 500 < len(allfile):
# for file in allfile[i * 500:(i + 1) * 500]:
# print(file)
# t = threading.Thread(target=insertOne, args=(file))
# t.start()
# ts.append(t)
# for t in ts:
# t.join()
# else:
# for file in allfile[i * 500:]:
# t = threading.Thread(target=get_chapter, args=(file))
# t.start()
# ts.append(t)
# for t in ts:
# t.join()
if __name__ == '__main__':
now = time.time()
connect = sqlite3.connect(initDB_Path)
c = connect.cursor()
SQLcreatetable(c,'FILEDB')
print('新建数据表成功')
allfile = getDirData()
buildInitDB(allfile)
print(time.time()-now)
connect.commit()
c.close()
connect.close()