You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'countlines.py -- count the lines of files end by ".*" in a folder.'
import os
def countLines(filename):
count = 0
f = open(filename, 'r')
for eachline in f:
count += 1
f.close()
return count
def getFilePathsDict(path):
pyDict = {}
filesList = os.listdir(path)
for each in filesList:
filepath = os.path.join(path, each)
if os.path.isfile(filepath) and (each.endswith('.h') or each.endswith('.cpp') or each.endswith('.cu')): # change this line to choose the file kinds you want to count
pyDict[filepath] = 0
elif os.path.isdir(filepath):
pyDict = dict(pyDict, **getFilePathsDict(filepath)) # recursive when it is a folder