I am writing a script that detects the methods of a file. Keys are function names and values are holding its path, row,column in this format :
[path,row,column]
Same function might be occur in a different locations(same file or a different file)
So I am checking this case: If we have same function, then we add new values corresponding to its key.
if methodDictionary.get(functionName) is None:
methodDictionary[functionName] =[path,row,column]
elif [path,row,column] not in methodDictionary[functionName]:
methodDictionary[functionName] =[methodDictionary.get(functionName)]
methodDictionary[functionName].append([path,row,column])
I think that the problem occurs in elif statement. It can't checks whether key has same value or not. Bu I can't fix that. Also there is a formatting problem can be seen from output.
I want a format like this;
{'int a(int x)' : [[path1,row1,column1],[path2,row2,column2]]}
How can I do that?
The output of code :
f()': [[[[[[[[[[[[[[[[[['a.cpp', '3', '3'], ['a.cpp', '8', '3']], ['a.cpp', '13', '3']], ['a.cpp', '3', '3']], ['a.cpp', '8', '3']], ['a.cpp', '13', '3']], ['a.cpp', '3', '3']], ['a.cpp', '8', '3']], ['a.cpp', '13', '3']], ['a.cpp', '3', '3']], ['a.cpp', '8', '3']], ['a.cpp', '13', '3']], ['a.cpp', '3', '3']], ['a.cpp', '8', '3']], ['a.cpp', '13', '3']], ['a.cpp', '3', '3']], ['a.cpp', '8', '3']], ['a.cpp', '13', '3']]
Aucun commentaire:
Enregistrer un commentaire