cloc统计代码行数
生活随笔
收集整理的這篇文章主要介紹了
cloc统计代码行数
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
ubuntu下使用cloc統(tǒng)計(jì)代碼行數(shù)很好用。記錄兩個(gè)實(shí)際用到的擴(kuò)展選項(xiàng)
2.有些語言或擴(kuò)展名的文件cloc默認(rèn)不統(tǒng)計(jì),比如typeScript,需要手動(dòng)指定以某種語言的統(tǒng)計(jì)方式統(tǒng)計(jì)某種擴(kuò)展名的文件:
--force-lang="JSP",ts注意,這樣統(tǒng)計(jì)之后表格中的JSP統(tǒng)計(jì)結(jié)果中會(huì)包含.ts擴(kuò)展名文件中的代碼行數(shù)。
最后貼一下備份自己統(tǒng)計(jì)代碼行數(shù)的爛代碼:
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()總結(jié)
以上是生活随笔為你收集整理的cloc统计代码行数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql修改记录_MySQL中如何创建
- 下一篇: Mentor.Graphics.Desi