Skip to content

Commit

Permalink
Merge pull request #25281 from ianna/dd4hep-units-checker-v1
Browse files Browse the repository at this point in the history
DD4hep: Update Units Check Script
  • Loading branch information
cmsbuild committed Nov 20, 2018
2 parents 6aa740f + 7f60479 commit 44471b4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions DetectorDescription/DDCMS/test/python/UnitsCheck.py
Expand Up @@ -6,12 +6,12 @@ def index(line,substr):
return result

def errorPrint(line,indices):
print(line)
print(line.replace('\t',' '))
ll = len(line)
errstr="_"*ll
errstr=" "*ll
for i in indices:
errstr = errstr[:i] + '^' + errstr[i+1:]
print errstr
errstr = errstr[:i] + '^-----' + errstr[i+5:]
print(errstr)

def findValuesWithUnits(line,ln):
numList = re.findall(r"\d*?[\s,.]?\d*\*\w*", line)
Expand All @@ -20,7 +20,8 @@ def findValuesWithUnits(line,ln):
errindices.append(match.start())
l = len(numList)
if l > 0:
print 'Line #',ln,'Units defined: '
text = fileinput.filename()+': line# '+str(ln)+' units defined: '
print(text)
errorPrint(line,errindices)
return l

Expand All @@ -39,7 +40,12 @@ def findValuesWithoutUnits(line,ln):
errindices.append(match.start())
l = len(numList)
if l > 0:
print 'Line #', ln, 'WARNING: Numerical values without units: '
if 'MaterialFraction' in line:
return l
if '<?xml' in line:
return l
text = fileinput.filename()+': line# '+str(ln)+' warning: numerical value without units: '
print(text)
errorPrint(line,errindices)
return l

Expand All @@ -53,8 +59,6 @@ def process(line):
ln = lineNumber(line)
l = findValuesWithUnits(line,ln)
k = findValuesWithoutUnits(line,ln)
if l > 0 or k > 0:
print ' '

def check(line):
return 0;
Expand Down

0 comments on commit 44471b4

Please sign in to comment.