Modified: trunk/Tools/ChangeLog (265067 => 265068)
--- trunk/Tools/ChangeLog 2020-07-29 23:34:55 UTC (rev 265067)
+++ trunk/Tools/ChangeLog 2020-07-29 23:40:45 UTC (rev 265068)
@@ -1,3 +1,12 @@
+2020-07-29 Darin Adler <[email protected]>
+
+ Add script to help us count uses of non-inclusive terms
+ https://bugs.webkit.org/show_bug.cgi?id=214942
+
+ Reviewed by Beth Dakin.
+
+ * Scripts/report-non-inclusive-language: Added.
+
2020-07-29 Kate Cheney <[email protected]>
Migrate App-Bound Domains code from WebKit Additions
Added: trunk/Tools/Scripts/report-non-inclusive-language (0 => 265068)
--- trunk/Tools/Scripts/report-non-inclusive-language (rev 0)
+++ trunk/Tools/Scripts/report-non-inclusive-language 2020-07-29 23:40:45 UTC (rev 265068)
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2020 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import argparse, os, re
+
+# For now: Searches all files in current directory tree.
+# Reads every file so it does take a while.
+# On my fast computer takes about 15 seconds for WebCore.
+
+# Things to do next:
+#
+# Clever default for use on WebKit source tree instead of current directory by default.
+# Report third party sources separately from WebKit project files.
+# Skip known examples on an exception list that we don't intend to fix.
+# Replace special cases for ChangeLog and ".order" files with something smarter.
+
+# Hard-coded for now, could read these out of a file instead.
+# Term, then the regular _expression_ for that term.
+nonInclusiveTerms = [
+ [ "blacklist", "black ?list" ],
+ [ "whitelist", "white ?list" ],
+ [ "slave", "slave" ]
+]
+
+parser = argparse.ArgumentParser(description='Report counts and locations of non-inclusive terms.')
+parser.add_argument('--verbose', '-v', action='');
+args = parser.parse_args()
+
+for term in nonInclusiveTerms:
+ term[1] = re.compile(term[1], re.IGNORECASE)
+ term.append(0)
+ term.append(0)
+
+root = os.getcwd()
+for subroot, directories, files in os.walk(os.getcwd()):
+ prefix = subroot[len(root) + 1:]
+ for file in files:
+ if file.startswith("ChangeLog"):
+ continue
+ if file.endswith(".order"):
+ continue
+ handle = open(os.path.join(subroot, file), "r")
+ for line in handle.readlines():
+ for term in nonInclusiveTerms:
+ if re.search(term[1], line):
+ term[2] += 1
+ if args.verbose:
+ for term in nonInclusiveTerms:
+ if term[2] != 0:
+ print(os.path.join(prefix, file) + ": " + term[0] + ": " + str(term[2]))
+ for term in nonInclusiveTerms:
+ term[3] += term[2]
+ term[2] = 0
+
+for term in nonInclusiveTerms:
+ print("total " + term[0] + ": " + str(term[3]))
Property changes on: trunk/Tools/Scripts/report-non-inclusive-language
___________________________________________________________________