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

Function main

Utilities/vtk2xml.py:141–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139
140
141def main():
142 options = "bahnd:"
143 long_opts = ['binary', 'ascii', 'help', 'no-encode', 'output-dir=']
144
145 try:
146 opts, args = getopt.getopt(sys.argv[1:], options, long_opts)
147 except getopt.error(msg):
148 print(msg)
149 print(usage())
150 print('-'*70)
151 print(msg)
152 sys.exit(1)
153
154 mode = 'p'
155 encode = 1
156 out_dir = None
157 for o, a in opts:
158 if o in ('-h', '--help'):
159 print(usage())
160 sys.exit(0)
161 if o in ('-b', '--binary'):
162 mode = 'b'
163 if o in ('-a', '--ascii'):
164 mode = 'a'
165 if o in ('-n', '--no-encode'):
166 encode = 0
167 if o in ('-d', '--output-dir'):
168 out_dir = a
169 if not os.path.exists(out_dir):
170 print("Error: Directory %s does not exist!"%out_dir)
171 sys.exit(1)
172
173 if len(args) < 1:
174 print("\nError: Incorrect number of arguments\n")
175 print(usage())
176 sys.exit(1)
177
178 for i in args:
179 r, w = getReaderWriter(i, out_dir)
180 if not r:
181 print("\nError: Could not convert file: %s"%i)
182 print("Unsupported data format!\n")
183 else:
184 o = setAllAttributes(r)
185 w.SetInputData(o)
186 # set output modes
187 if mode == 'a':
188 w.SetDataModeToAscii()
189 elif mode == 'b':
190 w.SetDataModeToBinary()
191 else:
192 w.SetDataModeToAppended()
193
194 w.SetEncodeAppendedData(encode)
195 w.Write()
196
197
198if __name__ == "__main__":

Callers 1

vtk2xml.pyFile · 0.70

Calls 9

getReaderWriterFunction · 0.85
setAllAttributesFunction · 0.85
existsMethod · 0.80
usageFunction · 0.70
printFunction · 0.50
errorMethod · 0.45
exitMethod · 0.45
SetInputDataMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected