-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscanFolder.py
35 lines (28 loc) · 1.05 KB
/
scanFolder.py
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
import os
import json
def scanFolder(scanPath):
scanPath = str(scanPath)
# print scanPath
if '.ignore' in os.listdir(scanPath):
return False
if 'ignore.txt' in os.listdir(scanPath):
return False
if 'ignore' in os.listdir(scanPath):
return False
if 'data.dat' and 'data.json' and 'meta.json' in os.listdir(scanPath):
metafile = os.path.join(scanPath, 'meta.json')
tmpmeta = []
with open(metafile) as json_data:
tmpmeta = json.load(json_data)
name = tmpmeta["name"]
folderData = {'name': name, 'path': scanPath}
elif 'forward.dat' and 'forward.json' and 'backward.dat' and 'backward.json' and 'meta.json' in os.listdir(scanPath):
metafile = os.path.join(scanPath, 'meta.json')
tmpmeta = []
with open(metafile) as json_data:
tmpmeta = json.load(json_data)
name = tmpmeta["name"]
folderData = {'name': name, 'path': scanPath}
else:
return False
return folderData