cloc统计代码行数
生活随笔
收集整理的這篇文章主要介紹了
cloc统计代码行数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ubuntu下使用cloc統計代碼行數很好用。記錄兩個實際用到的擴展選項
2.有些語言或擴展名的文件cloc默認不統計,比如typeScript,需要手動指定以某種語言的統計方式統計某種擴展名的文件:
--force-lang="JSP",ts注意,這樣統計之后表格中的JSP統計結果中會包含.ts擴展名文件中的代碼行數。
最后貼一下備份自己統計代碼行數的爛代碼:
import oscube_files = ['cubenet','cubenet_uaa','cubenet_gateway','cubenet_portal','cubenet_uapp1','cubenet_uapp2','cubenet_papp1','cubenet_serviceboot','cubenet_iboot','cubeai','cubeai_umm','cubeai_pmodelhub','cubeai_umu','cubeai_umd','cubeai_popen','cubeai_ability','cubeai_ppersonal','examples/cubeai_examples','examples/cubeai_examples_2','examples/cubeai_examples_3', 'cubeai_examples_3']print(len(cube_files))path = '/home/xu/cubeai_openi/' exclude = '--exclude-dir=./webapp/src/assets,./venv,./webapp/www,./webapp/node_models --force-lang="JSP",ts'fcount = open('fcount.txt', 'w+')count_py = 0 count_ts = 0 count_html = 0 for folder in cube_files:print(folder)current_path = path + folderos.chdir(current_path)command = 'cloc ./ ' + exclude redata = os.popen(command).read()fcount.write('#' + folder + '\n\n' + redata + '\n\n')for line in redata.split('\n'):if 'Python' in line:nums = line.split(' ')count_py = count_py + int(nums[-1])elif 'HTML' in line:nums = line.split(' ')count_html = count_html + int(nums[-1])elif ('Javascript' in line) or ('JSP' in line):nums = line.split(' ')count_ts = count_ts + int(nums[-1])print( count_py, count_ts, count_html ) fcount.close()總結
以上是生活随笔為你收集整理的cloc统计代码行数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql修改记录_MySQL中如何创建
- 下一篇: Mentor.Graphics.Desi