我将浏览许多包含相同源代码的类似makefile。我试图找出一个特定的源文件存在于多少个项目中。
我想要的是:
foo.c 4[项目、项目、项目、项目]
钢筋混凝土1[projC]
似乎我需要为每个makefile创建一个新的lstof项目,我所做的就是删除它。
我试过很多其他的方法
元组可以有一个列表作为它的元素之一吗?你知道吗
for file in listOf Makefiles
for line in Makeifle
find code file (.c or .h)
try:
index = lstFilenames.index(strFilename) # to determine if I have seen this file name yet
# Yes the file name is already in list
lstOfFile = lstProjectNames[index] # get list of projects that this file is seen in
try:
fileIndex = lstOfFile.index(myProject) # check to see if the project is in the project list
except: # project not in list
lstCount[index] +1 # add one to count - I am counting the number of projects this file appears
lstOfProjects.append(myProject) # append the new project to list
except: # file name not found in list
lstFilenames.append (strFilename) # put file in file name list
lstCount.append(1) # set count to one
lstOfProjects.append(myProject) # add project name to project list
#************************************************************************** End of makefile
lstProjectNames.append(lstOfProjects) # add project list to this list ( this list in indexed with teh file names and the counts)
del lstOfProjects[:]
你的
del lstOfProjects[:]
行是罪魁祸首,因为你的lstProjectNames
持有一个reference到你的lstOfProjects
,一旦你删除了它的内容,它就会在lstProjectNames
中被删除相关问题 更多 >
编程相关推荐