#!/usr/bin/env python3
#coding: utf-8
# 统计某一个目录中代码量的总和,并显示离十万行代码量还有多远
# 要求一:递归搜索各个文件夹
# 要求二: 显示各个类型的源文件和源文件数量
# 要求三: 显示总行数与百分比
import easygui as g
import os
def show_result(start_dir):
lines = 0
total = 0
text = ""
for i in source_list:
lines = source_list[i]
total += lines
text += "【%s】源文件 %d 个,源代码 %d 行\n" % (i, file_list[i], lines)
title = '统计结果'
msg = '您目前共累积编写了 %d 行代码,完成进度:%.2f %%\n离 10 万行代码还差 %d 行,请继续努力!' % (total, total/1000, 100000-total)
g.textbox(msg, title, text)
def calc_code(file_name):
lines = 0
with open(file_name) as f:
print('正在分析文件:%s ...' % file_name)
try:
for each_line in f:</