Created
December 16, 2019 14:16
-
-
Save dtaivpp/e482401f8df98b22e47ab2fd816bac06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Occurances will track each time an offensive bit of code is found | |
# Its format will be: | |
# File Path, Function, Num Occurances | |
occurances = [] | |
# Methods that need to be update | |
nogos = [ | |
".SetFocus(", | |
".IsValid(", | |
".Clear", | |
".IsDirty", | |
".RemoveItem", | |
".SetTime", | |
".RemoveItem", | |
".SetTime" | |
] | |
# Iterate previously collected file paths | |
for file_path in file_paths: | |
# Open the file as read only ignoring unknown chars | |
with open(file_path, 'r', encoding='utf8', errors='ignore' ) as f: | |
contents = f.read() | |
# Check each of the offensive code bits | |
for string in nogos: | |
countNogo = contents.count(string) | |
# If there is offensive code in the file append it to | |
# the occurances array | |
if countNogo > 0: | |
occurances.append([file_path, string, str(countNogo)]) | |
# Create an output csv string | |
outCSV = "\n".join([",".join(line) for line in occurances]) | |
# Write to file | |
with open("Outfile.csv", 'w+') as f: | |
f.write(outCSV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment