-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
linter.py
47 lines (33 loc) · 1.8 KB
/
linter.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
import json, os, sys
os.chdir(r'C:\Users\xtrem\Desktop\Electric\Electric Packages\packages')
for f in os.listdir():
data = ''
try:
with open(f, 'r') as file:
data = json.load(file)
except:
continue
linted = {
'display-name': data['display-name'],
'package-name': data['package-name'],
}
# Change Based On Version
# Not Portable
if 'portable' in list(data.keys()):
linted['portable'] = {'latest-version': data['portable']['latest-version']}
for version in list(data['portable'].keys()):
if version not in ['latest-version', 'auto-update', 'package-name', 'display-name']:
linted['portable'][version] = {'url': data['portable'][version]['url']}
if 'checksum' in list(data['portable'][version].keys()):
linted['portable'][version]['checksum'] = data['portable'][version]['checksum']
if 'file-type' in list(data['portable'][version].keys()):
linted['portable'][version]['file-type'] = data['portable'][version]['file-type']
if 'pre-install' in list(data['portable'][version].keys()):
linted['portable'][version]['pre-install'] = data['portable'][version]['pre-install']
if 'post-install' in list(data['portable'][version].keys()):
linted['portable'][version]['post-install'] = data['portable'][version]['post-install']
for key in list(data['portable'][version].keys()):
if key not in list(linted['portable'][version].keys()):
linted['portable'][version][key] = data['portable'][version][key]
print(json.dumps(linted, indent=4))
# TODO: Handle Portable Section data['portable']