apilint: Allow parsing 3.0 signature files
Test: python apilint_test.py
Change-Id: I59df950229c05329afde93f94efc13adb4640ad7
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py
index 75c3eba..59e89f5 100644
--- a/tools/apilint/apilint.py
+++ b/tools/apilint/apilint.py
@@ -223,6 +223,7 @@
class V2Tokenizer(object):
__slots__ = ["raw"]
+ SIGNATURE_PREFIX = "// Signature format: "
DELIMITER = re.compile(r'\s+|[()@<>;,={}/"!?]|\[\]|\.\.\.')
STRING_SPECIAL = re.compile(r'["\\]')
@@ -610,8 +611,12 @@
else:
blame = None
- if line == 1 and raw == "// Signature format: 2.0":
- sig_format = 2
+ if line == 1 and raw.startswith("// Signature format: "):
+ sig_format_string = raw[len(V2Tokenizer.SIGNATURE_PREFIX):]
+ if sig_format_string in ["2.0", "3.0"]:
+ sig_format = 2
+ else:
+ raise ValueError("Unknown format: %s" % (sig_format_string,))
elif raw.startswith("package"):
pkg = Package(line, raw, blame)
elif raw.startswith(" ") and raw.endswith("{"):