Last active
March 25, 2018 18:48
-
-
Save sshh12/17c07015d88824e601fff05f22a9df23 to your computer and use it in GitHub Desktop.
Count total lines of code
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
import glob | |
import os | |
## Count | |
exts = ['.py', '.js', '.md', 'java', '.html', '.css', '.pde'] | |
def count_lines(fn): | |
i = 0 | |
with open(fn, 'r', encoding="utf8") as code: | |
for _ in code: | |
i += 1 | |
return i | |
## Run | |
total = 0 | |
for filename in glob.iglob('./**/*', recursive=True): | |
fn, ext = os.path.splitext(filename) | |
if ext.lower() in exts and "node_modules" not in fn and "\\plugins\\" not in fn and "\\platforms\\" not in fn: | |
print(fn) | |
total += count_lines(filename) | |
print(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment