-#!/usr/bin/python2
+#!/usr/bin/python3
import sys, os, re
eol = False
else:
line = fp.readline()
- print(file, funcname, "X")
+ print((file, funcname, "X"))
# handle whitelist API
else:
buf.append(line)
- print(file, funcname, "O")
+ print((file, funcname, "O"))
##############
# Main Start #
if not line: break
# handle EAPI
- if not line[0] == "#" and re.search("\s*EAPI.*\(.*", line):
+ if not line[0] == "#" and re.search("\\s*EAPI.*\\(.*", line):
processEAPI(fp, line, buf, False)
elif not line[0] == "#" and "EAPI" in line and not ";" in line and not line.lstrip()[0] == "*" and not line.lstrip()[1] == "*":
-#!/usr/bin/python2
+#!/usr/bin/python3
+
import sys, os, re
# use space as delimiter
glibdirs = "glib-2.0"
# g_dbus api matcher
-re_func = re.compile("(?P<rtype>\w*[\t ]*[*]{0,3})[\t ]*(?P<api>[_]?g_(test_)?[d]?bus_[\w\d]+)[\t ]+(?P<param>\()")
+re_func = re.compile("(?P<rtype>\\w*[\t ]*[*]{0,3})[\t ]*(?P<api>[_]?g_(test_)?[d]?bus_[\\w\\d]+)[\t ]+(?P<param>\\()")
re_func_end = re.compile("[)]{1}.*[;]{1}")
# special case matcher
# G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusNodeInfo, g_dbus_node_info_unref)
-re_def_auto_ptr = re.compile("G_DEFINE_AUTOPTR_CLEANUP_FUNC\(.*(?P<api>[_]?g_(test_)?[d]?bus_[\w\d]+)+[\w\s]*\)")
+re_def_auto_ptr = re.compile("G_DEFINE_AUTOPTR_CLEANUP_FUNC\\(.*(?P<api>[_]?g_(test_)?[d]?bus_[\\w\\d]+)+[\\w\\s]*\\)")
def api_filter(relative_path):
# traverse header files
for glibdir in glibdirs.split():
glibpath = relative_path + "/usr/include/" + glibdir
if not os.path.isdir(glibpath):
- print(glibpath, 'is not valid path')
+ print((glibpath, 'is not valid path'))
continue
print(glibpath)
for subdir, dirs, files in os.walk(glibpath):
buf = list()
fp = open(filepath, "rt")
if not fp:
- print('file open error', filepath)
+ print(('file open error', filepath))
continue
lines = fp.readlines()
fp.close()
result = re_def_auto_ptr.search(line_dup)
if result:
buf.append('//{0}'.format(line))
- print('{0: <30} {1: <45}\tX'.format(file, '(G_DEFINE*) ' + result.group('api')))
+ print(('{0: <30} {1: <45}\tX'.format(file, '(G_DEFINE*) ' + result.group('api'))))
else:
buf.append(line)
continue
if not result.group('api') or not result.group('api').strip():
- print('error:un reachable', result.groupdict())
+ print(('error:un reachable', result.groupdict()))
continue
# ignore private api _g_dbus_xxx
buf[-1] = '//' + buf[-1]
buf.append('//{0}'.format(line))
- print('{0: <30} {1: <45}\tX'.format(file, result.group('api')))
+ print(('{0: <30} {1: <45}\tX'.format(file, result.group('api'))))
# re-write header file
for i in range(3):
fp = open(filepath, "wt")
if not fp:
- print('file open error. failed to re-write', filepath)
- print('retry re-write', i)
+ print(('file open error. failed to re-write', filepath))
+ print(('retry re-write', i))
continue
fp.writelines(buf)
fp.close()