Created
May 29, 2020 12:42
-
-
Save jadudm/c576a55ed6ee6977a1ff89373babbf31 to your computer and use it in GitHub Desktop.
Counting usages of $( in files as a way of estimating JQuery usage.
This file contains 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
import os | |
import re | |
root = "." | |
list_of_files = [] | |
file_count = 0 | |
ignore_extensions = ["sh", "md", "png", "otf", "woff2", "ttf", "woff", "eot", "ico", "jpg", "sample"] | |
for root, directory_names, file_names in os.walk(root): | |
for fname in file_names: | |
regex = "$|".join(ignore_extensions) | |
if (not re.search(regex, fname)): | |
list_of_files.append(os.path.join(root, fname)) | |
jquery_use = 0 | |
for filepath in list_of_files: | |
try: | |
with open(filepath, "r") as a_file: | |
# Start at zero, can increment at top of loop | |
line_number = 0 | |
for line in a_file: | |
line_number += 1 | |
stripped = line.strip() | |
if re.search("\\$\\(", stripped): | |
print(filepath) | |
print("-----------------------------") | |
print(line_number, stripped) | |
print() | |
jquery_use += 1 | |
except: | |
pass | |
print(jquery_use) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In tock, there are 55 uses of "$(".