Skip to content

Commit 25dbbe7

Browse files
tormodvoldenperexg
authored andcommitted
doc: Applied 2to3 on APICoverage.py and
alsa-python-coverage.py Closes: #15 Signed-off-by: Tormod Volden <[email protected]> Signed-off-by: Jaroslav Kysela <[email protected]>
1 parent 8d0aaf4 commit 25dbbe7

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

doc/APICoverage.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2323

2424

25-
import os, pickle, urllib, sys
25+
import os, pickle, urllib.request, urllib.parse, urllib.error, sys
2626
from pyparsing import *
27-
from htmlentitydefs import entitydefs
27+
from html.entities import entitydefs
2828
from htmllib import HTMLParser
2929
from formatter import AbstractFormatter, DumbWriter
3030

@@ -40,7 +40,7 @@
4040
count_total = count_miss = count_exc = 0
4141

4242
if not os.path.exists(cache):
43-
print "Creating cache dir: %s" % cache
43+
print("Creating cache dir: %s" % cache)
4444
os.makedirs(cache)
4545

4646
def read_source(name):
@@ -74,18 +74,18 @@ def get_cached_parse(index_parser_list, name):
7474
if not modified:
7575
return pickle.load(open(name))
7676

77-
print "generating cache, file: %s" % name,
77+
print("generating cache, file: %s" % name, end=' ')
7878
dict = {}
7979
for source, parser in index_parser_list:
80-
print source[0],
80+
print(source[0], end=' ')
8181
sys.stdout.flush()
8282
list = []
8383
for tokenlist, start, end in parser.scanString(source[1]):
8484
tlist = list_to_str(tokenlist)
8585
list.append((tlist, int(start), int(end)))
8686
dict[source[0]] = list
8787
pickle.dump(dict, open(name, "wb"))
88-
print
88+
print()
8989
return dict
9090

9191
# API html parsing/caching
@@ -100,8 +100,8 @@ def get_cached_api(url, name):
100100
if os.path.exists(name):
101101
data = "".join(open(name).readlines())
102102
else:
103-
print "downloading %s" % url
104-
data = urllib.urlopen(url).read()
103+
print("downloading %s" % url)
104+
data = urllib.request.urlopen(url).read()
105105
open(name, "w").write(data)
106106
return data
107107

@@ -156,16 +156,16 @@ def parse_asoundlib_api(lines):
156156
line = line[:-1]
157157
if False:
158158
if id(current) == id(defines):
159-
print "defines ",
159+
print("defines ", end=' ')
160160
elif id(current) == id(typedefs):
161-
print "typedefs ",
161+
print("typedefs ", end=' ')
162162
elif id(current) == id(enums):
163-
print "enums ",
163+
print("enums ", end=' ')
164164
elif id(current) == id(functions):
165-
print "functions ",
165+
print("functions ", end=' ')
166166
else:
167-
print " ",
168-
print "%s %d %s" % (id(current), state, line)
167+
print(" ", end=' ')
168+
print("%s %d %s" % (id(current), state, line))
169169

170170
if line.startswith('Define Documentation'):
171171
current = defines
@@ -253,22 +253,22 @@ def print_name(d0, d1, name, look_constant, look_usage, exclude_list):
253253
else:
254254
used = "%s" % usecount
255255

256-
print "%-4s%s" % (used, d0)
257-
print "%8s%s" % ("", d1)
256+
print("%-4s%s" % (used, d0))
257+
print("%8s%s" % ("", d1))
258258

259259
if usecount > 0:
260260
excstr = "Comment"
261261
else:
262262
excstr = "Excluded"
263263
for token, comment in exclude_list:
264264
if token == name:
265-
print "%10s==> %11s: %s" % ("", excstr, comment)
265+
print("%10s==> %11s: %s" % ("", excstr, comment))
266266
for s in lc:
267-
print "%10s=> As constant: %s" % ("", s)
267+
print("%10s=> As constant: %s" % ("", s))
268268
for s in uc:
269-
print "%10s=> Used in : %s" % ("", s)
269+
print("%10s=> Used in : %s" % ("", s))
270270
if used == "N/A":
271-
print " "*10 + "**** NOT AVAILABLE/USED %s ****" % name
271+
print(" "*10 + "**** NOT AVAILABLE/USED %s ****" % name)
272272

273273

274274
def _print_stat(title, section, missing, excluded, total):
@@ -283,9 +283,9 @@ def _print_stat(title, section, missing, excluded, total):
283283
fmissing = "%3.0f%%" % fmissing
284284
fexcluded = "%3.0f%%" % fexcluded
285285
fcovered = "%3.0f%%" % fcovered
286-
print "STAT %-30.30s %-12.12s: " % (title, section) + \
286+
print("STAT %-30.30s %-12.12s: " % (title, section) + \
287287
"%3d missing (%4s) %3d excluded (%4s) of %3d total (%4s covered)." % \
288-
(missing, fmissing, excluded, fexcluded, total, fcovered)
288+
(missing, fmissing, excluded, fexcluded, total, fcovered))
289289

290290

291291
def print_stat(title, section):
@@ -329,24 +329,24 @@ def print_api_coverage(urls, look_constant, look_usage, excludes):
329329
AsoundlibAPIHTMLParser(tmp, data)
330330
(title, defines, typedefs, enums, functions) = \
331331
parse_asoundlib_api(open(tmp).readlines())
332-
print title
333-
print "="*len(title)
334-
print "\n"*2
332+
print(title)
333+
print("="*len(title))
334+
print("\n"*2)
335335
#print "%s\n%s\n%s\n%s\n%s\n\n" % \
336336
# (title, defines, typedefs, enums, functions)
337337
summary_total = 0
338338
summary_miss = 0
339339
if len(defines) > 0:
340-
print "Defines"
341-
print "-------"
340+
print("Defines")
341+
print("-------")
342342
for d in defines:
343343
name = d[0].split(' ')[1]
344344
print_name(d[0], d[1], name, look_constant, look_usage, el)
345345
print_stat(title, "Defines")
346-
print "\n"*2
346+
print("\n"*2)
347347
if len(typedefs) > 0:
348-
print "Typedefs"
349-
print "--------"
348+
print("Typedefs")
349+
print("--------")
350350
for d in typedefs:
351351
names = d[0].split(' ')
352352
name = names[-1]
@@ -355,20 +355,20 @@ def print_api_coverage(urls, look_constant, look_usage, excludes):
355355
name = names[-2].split()[-1]
356356
print_name(d[0], d[1], name, look_constant, look_usage, el)
357357
print_stat(title, "Typedefs")
358-
print "\n"*2
358+
print("\n"*2)
359359
if len(enums) > 0:
360-
print "Enumerations"
361-
print "------------"
360+
print("Enumerations")
361+
print("------------")
362362
for e in enums:
363-
print "%s" % e[0]
363+
print("%s" % e[0])
364364
for d in e[2]:
365365
name = d[0]
366366
print_name(d[0], d[1], name, look_constant, look_usage, el)
367367
print_stat(title, "Enumerations")
368-
print "\n"*2
368+
print("\n"*2)
369369
if len(functions) > 0:
370-
print "Functions"
371-
print "---------"
370+
print("Functions")
371+
print("---------")
372372
for d in functions:
373373
name = None
374374
for n in d[0].split(' '):
@@ -379,7 +379,7 @@ def print_api_coverage(urls, look_constant, look_usage, excludes):
379379
if name != None:
380380
print_name(d[0], d[1], name, look_constant, look_usage, el)
381381
print_stat(title, "Functions")
382-
print "\n"*2
382+
print("\n"*2)
383383
print_summary_stat(title)
384-
print "\n"*4
384+
print("\n"*4)
385385

doc/alsa-python-coverage.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,15 @@ def look_usage(name):
229229
rs = tokens[0]
230230
if rs == name:
231231
list.append(start)
232-
if dict.has_key(file):
232+
if file in dict:
233233
dict[file].extend(list)
234234
else:
235235
dict[file] = list
236236

237237
nlist = []
238238
for file in dict:
239239
for lstart in dict[file]:
240-
if not index.has_key(file):
240+
if file not in index:
241241
continue
242242
found = None
243243
previous = None
@@ -314,7 +314,7 @@ def look_usage(name):
314314
"""
315315

316316

317-
print """
317+
print("""
318318
*******************************
319319
PYALSA/ASOUNDLIB COVERAGE/USAGE
320320
*******************************
@@ -342,7 +342,7 @@ def look_usage(name):
342342
343343
344344
345-
"""
345+
""")
346346

347347

348348
print_api_coverage(urls, look_constant, look_usage, comments)
@@ -351,7 +351,7 @@ def look_usage(name):
351351
time_end = time.time()
352352
time_diff = time_end - time_start
353353

354-
print """%s
354+
print("""%s
355355
Generated for ALSA project by alsa-python-coverage.py %s
356356
%s UTC (%s@%s %3.3f seconds).
357357
""" % ("-"*72,
@@ -360,5 +360,5 @@ def look_usage(name):
360360
os.getlogin(),
361361
os.uname()[1],
362362
time_diff
363-
)
364-
print
363+
))
364+
print()

0 commit comments

Comments
 (0)