diff --git a/scripts/modules-json.py b/scripts/modules-json.py index 201a778dfcff4331a83196d3abfdaa1a98362917..e394df2385f313f4f088274bda1859082170cb73 100755 --- a/scripts/modules-json.py +++ b/scripts/modules-json.py @@ -9,13 +9,14 @@ import re from distutils.version import LooseVersion + def get_data(filename): '''function to read the data form the input csv file to use in the analysis''' - reader = [] # Just in case the file open fails + reader = [] # Just in case the file open fails with open(filename, 'rb') as f: - reader = csv.reader(f,delimiter=',') - #returns all the data from the csv file in list form - #f.close() # May need to close the file when done + reader = csv.reader(f, delimiter=',') + # returns all the data from the csv file in list form + # f.close() # May need to close the file when done return list(reader) # only return the reader when you have finished. your_list = [] @@ -28,8 +29,9 @@ your_list += get_data('./scripts/barbora.csv') counts = dict() for i in your_list: - counts[i[0]]=counts.get(i[0], 0) + int(i[1]) + counts[i[0]] = counts.get(i[0], 0) + int(i[1]) +# 1 2 4 8 16 32 l = ['A', 'S', 'U', 'P', 'D', 'B'] c = [] mask = ''.join(reversed(l)) @@ -49,23 +51,23 @@ versions = '' clusters = '' prev = '' -for m,i in sorted(counts.items()): - #print m - split = m.split('/') - #print split - if len(split) > 1: - a = split[0] - b = split[1] - if split[0] <> prev: - software[a] = {} - software[a][b] = '`' + c[i] + '`' - prev = a +for m, i in sorted(counts.items()): + # print m + split = m.split('/') + # print split + if len(split) > 1: + a = split[0] + b = split[1] + if split[0] <> prev: + software[a] = {} + software[a][b] = '`' + c[i] + '`' + prev = a packages = {} for m in sorted(software.items(), key=lambda i: i[0].lower()): - packages[m[0]]=sorted(m[1], key=LooseVersion)[len(m[1])-1] + packages[m[0]] = sorted(m[1], key=LooseVersion)[len(m[1]) - 1] -data = {'total': len(packages), 'projects': packages } +data = {'total': len(packages), 'projects': packages} print json.dumps(data) diff --git a/scripts/modules-matrix.py b/scripts/modules-matrix.py index 8e99eb2ea1ec6c3830496d58b896ebfbcf752c84..c66f8723a85573d405c1ed51c9ace3058efdcfd6 100755 --- a/scripts/modules-matrix.py +++ b/scripts/modules-matrix.py @@ -8,13 +8,14 @@ import re from distutils.version import LooseVersion + def get_data(filename): '''function to read the data form the input csv file to use in the analysis''' - reader = [] # Just in case the file open fails + reader = [] # Just in case the file open fails with open(filename, 'rb') as f: - reader = csv.reader(f,delimiter=',') - #returns all the data from the csv file in list form - #f.close() # May need to close the file when done + reader = csv.reader(f, delimiter=',') + # returns all the data from the csv file in list form + # f.close() # May need to close the file when done return list(reader) # only return the reader when you have finished. your_list = [] @@ -29,10 +30,11 @@ print your_list counts = dict() for i in your_list: - #print i[0] - #print int(i[1]) - counts[i[0]]=counts.get(i[0], 0) + int(i[1]) + # print i[0] + # print int(i[1]) + counts[i[0]] = counts.get(i[0], 0) + int(i[1]) +# 1 2 4 8 16 32 l = ['A', 'S', 'U', 'P', 'D', 'B'] c = [] mask = ''.join(reversed(l)) @@ -59,7 +61,7 @@ print ' | +------------> DGX-2' print ' +--------------> Barbora' print ' ```' print -print '| Module </br><input id="searchInput" placeholder="🔍 Filter" style="width: 8rem; border-radius: 0.2rem; color: black; padding-left: .2rem;"> | Versions | Clusters |' +print '| Module </br><form><input id="searchInput" placeholder="🔍 Filter" style="width: 8rem; border-radius: 0.2rem; color: black; padding-left: .2rem;"></form> | Versions | Clusters |' print "| ------ | -------- | -------- |" software = dict() @@ -67,26 +69,26 @@ versions = '' clusters = '' prev = '' -for m,i in sorted(counts.items()): -# print m - split = m.split('/') +for m, i in sorted(counts.items()): + # print m + split = m.split('/') # print split - if len(split) > 1: - a = split[0] - b = split[1] - if split[0] <> prev: - software[a] = {} - software[a][b] = '`' + c[i] + '`' - prev = a + if len(split) > 1: + a = split[0] + b = split[1] + if split[0] <> prev: + software[a] = {} + software[a][b] = '`' + c[i] + '`' + prev = a for m in sorted(software.items(), key=lambda i: i[0].lower()): - software = m[0] - versions = [] - clusters = [] - for key in sorted(m[1], key=LooseVersion ): - versions.append(key) - clusters.append(m[1][key]) - print "| %s | %s | %s |" % (software, '</br>'.join(versions), '</br>'.join(clusters)) + software = m[0] + versions = [] + clusters = [] + for key in sorted(m[1], key=LooseVersion): + versions.append(key) + clusters.append(m[1][key]) + print "| %s | %s | %s |" % (software, '</br>'.join(versions), '</br>'.join(clusters)) print print '---8<--- "modules_matrix_search.md"'