Created
November 14, 2019 05:12
-
-
Save ichisadashioko/e757f8f8a7959bb197ee74d64fdf9e01 to your computer and use it in GitHub Desktop.
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 | |
def count_code_lines(fpath): | |
count = 0 | |
if os.path.isdir(fpath): | |
file_list = os.listdir(fpath) | |
for fname in file_list: | |
child_path = os.path.join(fpath, fname) | |
count += count_code_lines(child_path) | |
else: | |
ext = os.path.splitext(fpath)[1] | |
if ext == '.java': | |
count += len(open(fpath, mode='r', encoding='utf-8').readlines()) | |
return count | |
if __name__ == "__main__": | |
fpath = r'E:\Programs\jd-gui-windows-1.6.4\heroes-lore-wind-of-solti.jar.src' | |
print(repr(fpath)) | |
print(count_code_lines(fpath)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment