aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy.py
diff options
context:
space:
mode:
authorDuncan Keall <duncan@duncankeall.com>2014-09-09 12:16:50 +1200
committerDuncan Keall <duncan@duncankeall.com>2014-09-10 10:01:46 +1200
commit8e25e958ab8dd6262beb7787b4a9698e858bac1d (patch)
treea2fcf4034cb03c1c7d5e38df43e184ef0121e7bd /python/tidy.py
parent6c48066565f84a57340e954e82448088380360ce (diff)
downloadservo-8e25e958ab8dd6262beb7787b4a9698e858bac1d.tar.gz
servo-8e25e958ab8dd6262beb7787b4a9698e858bac1d.zip
Cleaned up python/licenseck.py
- Moved logic into tidy.py - Removed explicit BSD license exceptions, they are already ignored by being inside the codegen directory.
Diffstat (limited to 'python/tidy.py')
-rw-r--r--python/tidy.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/python/tidy.py b/python/tidy.py
index dd4ba848213..ee1372761fa 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -11,7 +11,7 @@
import os
import fnmatch
-import licenseck
+from licenseck import licenses
directories_to_check = ["src", "components"]
filetypes_to_check = [".rs", ".rc", ".cpp", ".c", ".h", ".py"]
@@ -45,12 +45,14 @@ def should_check(file_name):
return True
-def check_license(file_name, contents):
- if not licenseck.check_license(file_name, contents):
+def check_license(contents):
+ valid_license = any(contents.startswith(license) for license in licenses)
+ acknowledged_bad_license = "xfail-license" in contents[:100]
+ if not (valid_license or acknowledged_bad_license):
yield (1, "incorrect license")
-def check_whitespace(file_name, contents):
+def check_whitespace(contents):
lines = contents.splitlines(True)
for idx, line in enumerate(lines):
if line[-1] == "\n":
@@ -73,7 +75,7 @@ def collect_errors_for_files(files_to_check, checking_functions):
with open(file_name, "r") as fp:
contents = fp.read()
for check in checking_functions:
- for error in check(file_name, contents):
+ for error in check(contents):
# filename, line, message
yield (file_name, error[0], error[1])