MCPcopy Create free account
hub / github.com/Kitware/VTK / ParseModuleFile

Function ParseModuleFile

Utilities/Maintenance/VisualizeModuleDependencies.py:72–116  ·  view source on GitHub ↗

Read each module file returning the module name and what it depends on or implements.

(fileName)

Source from the content-addressed store, hash-verified

70 return moduleFiles
71
72def ParseModuleFile(fileName):
73 '''
74 Read each module file returning the module name and what
75 it depends on or implements.
76 '''
77 fh = open(fileName, 'rb')
78 lines = []
79 for line in fh:
80 line = line.strip()
81 if line.startswith('$'): # Skip CMake variable names
82 continue
83 if line.startswith('#'):
84 continue
85 line = line.split('#')[0].strip() # inline comments
86 if line == "":
87 continue
88 line = line.split(')')[0].strip() # closing brace with no space
89 if line == "":
90 continue
91 for l in line.split(" "):
92 lines.append(l)
93 languages = ['PYTHON', 'JAVA']
94 keywords = ['BACKEND', 'COMPILE_DEPENDS', 'DEPENDS', 'EXCLUDE_FROM_ALL',
95 'EXCLUDE_FROM_WRAPPING', 'GROUPS', 'IMPLEMENTS', 'KIT', 'LEGACY',
96 'PRIVATE_DEPENDS', 'TEST_DEPENDS', 'OPTIONAL_PYTHON_LINK'
97 'IMPLEMENTATION_REQUIRED_BY_BACKEND'] + \
98 map(lambda l: 'EXCLUDE_FROM_%s_WRAPPING' % l, languages)
99 moduleName = ""
100 depends = []
101 implements = []
102 state = "START";
103 for item in lines:
104 if state == "START" and item.startswith("vtk_module("):
105 moduleName = item.split("(")[1]
106 continue
107 if item in keywords:
108 state = item
109 continue
110 if state == 'DEPENDS' and item != ')':
111 depends.append(item)
112 continue
113 if state == 'IMPLEMENTS' and item != ')':
114 implements.append(item)
115 continue
116 return [moduleName, depends + implements]
117
118def FindAllNeededModules(modules, foundModules, moduleDepencencies):
119 '''

Callers 1

mainFunction · 0.85

Calls 2

mapFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected