upgrade checkJavaDocs.py to python3

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1367071 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-07-30 12:49:40 +00:00
parent 3d9e8b745f
commit e101167585
2 changed files with 17 additions and 17 deletions

View File

@ -41,10 +41,10 @@ def checkSummary(fullPath):
desc = desc.strip() desc = desc.strip()
if desc == '': if desc == '':
if not printed: if not printed:
print print()
print fullPath print(fullPath)
printed = True printed = True
print ' no package description (missing package.html in src?)' print(' no package description (missing package.html in src?)')
anyMissing = True anyMissing = True
desc = None desc = None
else: else:
@ -52,17 +52,17 @@ def checkSummary(fullPath):
if lineLower in ('<td>&nbsp;</td>', '<td></td>', '<td class="collast">&nbsp;</td>'): if lineLower in ('<td>&nbsp;</td>', '<td></td>', '<td class="collast">&nbsp;</td>'):
if not printed: if not printed:
print print()
print fullPath print(fullPath)
printed = True printed = True
print ' missing: %s' % unescapeHTML(lastHREF) print(' missing: %s' % unescapeHTML(lastHREF))
anyMissing = True anyMissing = True
elif lineLower.find('licensed to the apache software foundation') != -1 or lineLower.find('copyright 2004 the apache software foundation') != -1: elif lineLower.find('licensed to the apache software foundation') != -1 or lineLower.find('copyright 2004 the apache software foundation') != -1:
if not printed: if not printed:
print print()
print fullPath print(fullPath)
printed = True printed = True
print ' license-is-javadoc: %s' % unescapeHTML(lastHREF) print(' license-is-javadoc: %s' % unescapeHTML(lastHREF))
anyMissing = True anyMissing = True
m = reHREF.search(line) m = reHREF.search(line)
if m is not None: if m is not None:
@ -85,17 +85,17 @@ def checkPackageSummaries(root, level='class'):
""" """
if level != 'class' and level != 'package': if level != 'class' and level != 'package':
print 'unsupported level: %s, must be "class" or "package"' % level print('unsupported level: %s, must be "class" or "package"' % level)
sys.exit(1) sys.exit(1)
#for dirPath, dirNames, fileNames in os.walk('%s/lucene/build/docs/api' % root): #for dirPath, dirNames, fileNames in os.walk('%s/lucene/build/docs/api' % root):
if False: if False:
os.chdir(root) os.chdir(root)
print print()
print 'Run "ant javadocs" > javadocs.log...' print('Run "ant javadocs" > javadocs.log...')
if os.system('ant javadocs > javadocs.log 2>&1'): if os.system('ant javadocs > javadocs.log 2>&1'):
print ' FAILED' print(' FAILED')
sys.exit(1) sys.exit(1)
anyMissing = False anyMissing = False
@ -116,14 +116,14 @@ def checkPackageSummaries(root, level='class'):
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2 or len(sys.argv) > 3: if len(sys.argv) < 2 or len(sys.argv) > 3:
print 'usage: %s <dir> [class|package]' % sys.argv[0] print('usage: %s <dir> [class|package]' % sys.argv[0])
sys.exit(1) sys.exit(1)
if len(sys.argv) == 2: if len(sys.argv) == 2:
level = 'class' level = 'class'
else: else:
level = sys.argv[2] level = sys.argv[2]
if checkPackageSummaries(sys.argv[1], level): if checkPackageSummaries(sys.argv[1], level):
print print()
print 'Missing javadocs were found!' print('Missing javadocs were found!')
sys.exit(1) sys.exit(1)
sys.exit(0) sys.exit(0)

View File

@ -1701,7 +1701,7 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
<attribute name="dir"/> <attribute name="dir"/>
<attribute name="level" default="class"/> <attribute name="level" default="class"/>
<sequential> <sequential>
<exec dir="." executable="${python.exe}" failonerror="true"> <exec dir="." executable="${python32.exe}" failonerror="true">
<arg value="${dev-tools.dir}/scripts/checkJavaDocs.py"/> <arg value="${dev-tools.dir}/scripts/checkJavaDocs.py"/>
<arg value="@{dir}"/> <arg value="@{dir}"/>
<arg value="@{level}"/> <arg value="@{level}"/>