python-efl: api_coverage: Fix ecore-file and refine the regexps.

SVN revision: 84415
This commit is contained in:
Kai Huuhko 2013-03-09 00:13:54 +00:00
parent 2e2fa9ed6d
commit acc6f19282
1 changed files with 15 additions and 16 deletions

View File

@ -28,17 +28,17 @@ def get_capis(inc_path, prefix):
for f in files:
with open(os.path.join(path, f), "r") as header:
capi = header.read()
matches = re.finditer("^ *EAPI [A-Za-z_ *\n]+ +\**(" + prefix + "_\w+)\(", capi, re.S|re.M)
matches = re.finditer("^ *EAPI [A-Za-z_ *\n]+ +\**(" + prefix + "_\w+) *\(", capi, re.S|re.M)
for match in matches:
func = match.group(1)
#print(func)
capis.append(func)
return capis
def get_pyapis(pxd_path, header_name, prefix):
pyapis = []
for path, dirs, files in os.walk(pxd_path):
for f in files:
if f.endswith(".pxd"):
@ -46,18 +46,18 @@ def get_pyapis(pxd_path, header_name, prefix):
pyapi = pxd.read()
cdef = re.search('(cdef extern from "' + header_name + '\.h":\n)(.+)', pyapi, re.S)
if cdef:
matches = re.finditer(" .+(" + prefix + "_\w+)\(", cdef.group(2))
matches = re.finditer("^ [a-zA-Z _*]+?(" + prefix + "_\w+)\(", cdef.group(2), re.M)
for match in matches:
func = match.group(1)
#print(func)
pyapis.append(func)
return pyapis
parser = argparse.ArgumentParser()
parser.add_argument("--python", action="store_true", default=False, help="Show Python API coverage")
parser.add_argument("--c", action="store_true", default=False, help="Show C API coverage")
parser.add_argument("libs", nargs="+", help="Possible values are eo, evas, ecore, efile, edje, emotion, edbus, elementary and all.")
parser.add_argument("libs", nargs="+", help="Possible values are eo, evas, ecore, ecore-file, edje, emotion, edbus, elementary and all.")
args = parser.parse_args()
if args.libs is "all":
@ -67,7 +67,7 @@ params = {
"eo": ("include", "Eo", "eo"),
"evas": ("include", "Evas", "evas"),
"ecore": ("include", "Ecore", "ecore"),
"efile": ("include", "Ecore_File", "ecore_file"),
"ecore-file": ("include", "Ecore_File", "ecore_file"),
"edje": ("include", "Edje", "edje"),
"emotion": ("include", "Emotion", "emotion"),
"edbus2": ("efl/edbus", "EDBus", "edbus"),
@ -77,38 +77,37 @@ params = {
for key in args.libs:
inc_path = pkg_config(key, "1.7.99")[0][2:]
pxd_path, header_name, prefix = params[key]
capis = get_capis(inc_path, prefix)
pyapis = get_pyapis(pxd_path, header_name, prefix)
ecs = set(capis)
eps = set(pyapis)
differences = ecs.union(eps) - ecs.intersection(eps)
for d in sorted(differences):
if args.python and d in ecs:
print("{0} is missing from Python API".format(d))
if args.c and d in eps:
print("{0} is missing from C API".format(d))
if args.python or args.c: print("\n---")
if args.python:
print("Number of functions missing from Python API: {0}".format(len(ecs - ecs.intersection(eps))))
if args.c:
print("Number of functions missing from C API: {0}".format(len(eps - ecs.intersection(eps))))
if args.python or args.c: print("---")
if args.python:
print("Python API functions: {0}".format(len(eps)))
if args.c:
print("C API functions: {0}".format(len(ecs)))
if args.python:
percentage = float(len(ecs.intersection(eps))) / float(len(ecs)) * 100.0
print("===")
print("Bindings coverage {0:.2f}%".format(percentage))
if args.python or args.c: print("---\n")