-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_replacement_json.py
More file actions
executable file
·46 lines (40 loc) · 1.48 KB
/
make_replacement_json.py
File metadata and controls
executable file
·46 lines (40 loc) · 1.48 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
#! /usr/bin/python3
# SanitizedLinuxTimeline: Reduce the Linux Distribution Timeline to the most popular distributions.
# Copyright (C) 2020-2021 Philipp Leclercq
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
import csv
import json
from _sanitizedlinuxtimeline import read_distros, check_existence
def argparse():
try:
global listfile
listfile = sys.argv[1]
global csvfile
csvfile = sys.argv[2]
global rulefile
rulefile = sys.argv[3]
except:
print("Usage: ./make_replacement_json.py LISTFILE CSVFILE OUTPUTFILE")
sys.exit(1)
if __name__ == "__main__":
argparse()
distros = read_distros(listfile)
nonexistent = check_existence(distros, csvfile)
ne_dict = {}
for distro in nonexistent:
ne_dict[distro] = ""
with open(rulefile, "w") as f:
f.write(json.dumps(ne_dict, sort_keys=True, indent=4))