日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

cloc统计代码行数

發(fā)布時(shí)間:2023/12/14 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cloc统计代码行数 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

ubuntu下使用cloc統(tǒng)計(jì)代碼行數(shù)很好用。記錄兩個(gè)實(shí)際用到的擴(kuò)展選項(xiàng)

  • 排除項(xiàng)目路徑下某些目錄,比如python的虛擬環(huán)境或者node包:
  • cloc . --exclude-dir=./venv,./webapp/node_models,./webapp/www,./webapp/src.assets

    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)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。