-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsanitize_csv.py
More file actions
executable file
·53 lines (43 loc) · 1.67 KB
/
sanitize_csv.py
File metadata and controls
executable file
·53 lines (43 loc) · 1.67 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
#! /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
from _sanitizedlinuxtimeline import read_distros, add_ancestors, apply_rules, remove_comments, write_csv, remove_unneeded_distros
def argparse():
try:
global listfile
listfile = sys.argv[1]
global inputcsv
inputcsv = sys.argv[2]
global rulefile
rulefile = sys.argv[3]
global outputcsv
outputcsv = sys.argv[4]
except:
print("Usage: ./sanitize_csv.py LISTFILE INPUTCSV RULEFILE OUTPUTCSV")
sys.exit(1)
if __name__ == "__main__":
argparse()
distros = read_distros(listfile)
distros = apply_rules(distros, rulefile)
csvdata = remove_comments(inputcsv)
for distro in distros.copy():
distros = add_ancestors(distro, distros, csvdata)
print(len(distros))
print(distros)
csvdata = remove_unneeded_distros(csvdata, distros)
write_csv(outputcsv, csvdata)