Skip to content

Commit

Permalink
Adding script to read the .uses and .classes files from coverage testing
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21515 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jul 15, 2014
1 parent a4102c3 commit 2bd7088
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Examples/CountClassUses.py
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
# To test this, use for example:
# rsync -a --progress test.openmodelica.org:/var/www/libraries/ --include=*/ --include="*.uses" --include="*.classes" --exclude='*' --delete .
# python3 CountClassUses.py MSL_3.2.1 ModelicaTest_3.2.1
# Or use the BuildModelRecursive.mos script to generate the required files

import glob
from sys import argv

classes = glob.glob('*/files/*.classes')

library = argv[1]
for f in argv[1:]:
assert -1 == f.find('/')

all_classes = dict((c.strip(),[]) for c in open(glob.glob('%s/files/*.classes' % library)[0], 'r').readlines())
unused_classes = set(all_classes.keys()) # Mainly for debugging since we print out the count of classes...

for cls in [glob.glob('%s/files/*.uses' % cl) for cl in argv[1:]]:
for cl in cls:
name = cl[:-5].split('files/')[1]
used_classes = set(c.strip() for c in open(cl,'r').readlines())
unused_classes = unused_classes - used_classes
for c in used_classes:
if c in all_classes:
all_classes[c].append(name)

for cl in sorted(all_classes, key = lambda cl: (len(all_classes[cl]),cl)):
print(len(all_classes[cl]),cl)

0 comments on commit 2bd7088

Please sign in to comment.