From 51612845b8a4c34ff099582d61f98e38a08ced6b Mon Sep 17 00:00:00 2001 From: Adrian Woodley Date: Mon, 15 Jul 2019 11:52:41 +0800 Subject: [PATCH] Initial version on SC200-html.py --- sc200-html.py | 378 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100755 sc200-html.py diff --git a/sc200-html.py b/sc200-html.py new file mode 100755 index 0000000..1e797bd --- /dev/null +++ b/sc200-html.py @@ -0,0 +1,378 @@ +#!/usr/bin/python3 + +import sys +import csv +import re +import textwrap + +inFilePath = sys.argv[1] + +class MyDict(dict): + def __missing__(self, key): + return {} + +def Input(): + with open(inFilePath, 'r', newline='') as inFile: + csvReader = csv.DictReader(inFile) + + # print(csvReader) + + for row in csvReader: + Description = row['description'] + IP = row['ip address'] + District=re.split(r'[\d]+', Description)[0] + if District.endswith('S') and "-" not in Description: + District = District[:-1] + Segment=re.split(r'[\s-]+', Description)[0] + + if not Description: + continue + # print("""|%s|""" % Description) + + if District not in Devices.keys(): + Devices[District] = {} + Devices[District][Segment] = {} + elif Segment not in Devices[District].keys(): + Devices[District][Segment] = {} + + Devices[District][Segment][Description] = IP + inFile.close() + +def Output(): + for District in sorted(Devices.keys()): + print ("""\ + + """) + + # print ("""\ + # + # + # """) + + print ("""\ + + + + """) + + +def Header(): + print (r""" + + + + SC200 Management Interface + + + + + +

SC200 Management Interface

+
+ Expand All + Collapse All +
+ +
+