I am trying to implement a python program that analyzes python source files in a given directory and produces class dependency list, along with the source filename in which the class definition is found, in the following format.
Class name1 [filename]
Derived Classname1 [filename]
Derived Classname2 [filename]
Derived Classname3 [filename]
…
Class name2 [filename]
Derived ClassnameA [filename]
Derived ClassnameB[filename]
Derived ClassnameC [filename]
I could not figure out the logic. Code to read the files from directory is given below is there a module for inheritance logic in python? cmd command: >>python cs2.py "C:\Users\PC-server\Documents\PythonCode\dir1"
cs2.py
import sys
import os
def processFiles(path):
try:
fileList = os.listdir(path)
for i in fileList:
filePath= path +"\\"+i;
if(os.path.isfile(filePath)):
fileName = i;
print(filePath)
file = open(filePath, 'r')
#logic will go here
#file.close()
except:
print('Error reading the directory')
def main(argv):
processFiles(argv)
main(sys.argv[1])
classkeyword (after stripping whitespace, of course), and then parse those.