forked from kim-sanghoon/rico-json-processing
-
Notifications
You must be signed in to change notification settings - Fork 3
/
delete.py
executable file
·49 lines (45 loc) · 1.93 KB
/
delete.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python3
import json, sys, os
FILES = sys.argv[1:]
for FILE_NUM in FILES:
try:
FILE_JSON = json.load(open(os.path.join(os.path.curdir, 'json', 'refined', FILE_NUM + '.json')))
except FileNotFoundError:
print("File not found: %s" % os.path.join(os.path.curdir, 'json', 'refined', FILE_NUM + '.json'))
continue
print("File you want to delete is:")
print(" - %s" % os.path.join(os.path.curdir, 'json', 'refined', FILE_NUM + '.json'))
print(" - %s" % os.path.join(os.path.curdir, 'json', 'raw', FILE_NUM + '.json'))
print(" - %s" % os.path.join(os.path.curdir, 'layout', FILE_NUM + '.json_out.png'))
print(" - %s" % os.path.join(os.path.curdir, 'comparison', FILE_NUM + '.json_comp.png'))
print("App info: ")
print(" - Package name: %s" % FILE_JSON['app']['package_name'])
print(" - Store name : %s" % FILE_JSON['app']['store_name'])
print(" - Category : %s" % FILE_JSON['app']['category'])
print("\nPlease check the information before you delete.\nDo you really want to delete this info? (Y/N) ")
while True:
n = input()
if n == 'Y' or n == 'y':
try:
os.remove(os.path.join(os.path.curdir, 'json', 'refined', FILE_NUM + '.json'))
except:
pass
try:
os.remove(os.path.join(os.path.curdir, 'json', 'raw', FILE_NUM + '.json'))
except:
pass
try:
os.remove(os.path.join(os.path.curdir, 'layout', FILE_NUM + '.json_out.png'))
except:
pass
try:
os.remove(os.path.join(os.path.curdir, 'comparison', FILE_NUM + '.json_comp.png'))
except:
pass
print("Delete complete.")
break
elif n == 'N' or n == 'n':
print("Deletion aborted.")
break
else:
print("Please answer with Y/N. ")