<s> import core . modules <EOL> import core . modules . module_registry <EOL> from core . modules . vistrails_module import Module , ModuleError <EOL> from core . system import list2cmdline <EOL> import os <EOL> _mesh_filter_path = None <EOL> identifier = '<STR_LIT>' <EOL> version = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> class MeshFilter ( Module ) : <EOL> def guess_input_format ( self , input_file_name ) : <EOL> i = input_file_name . rfind ( '<STR_LIT:.>' ) <EOL> if i == - <NUM_LIT:1> : <EOL> return None <EOL> else : <EOL> return input_file_name [ i : ] <EOL> def compute ( self ) : <EOL> self . check_input ( '<STR_LIT>' ) <EOL> input_file = self . get_input ( '<STR_LIT>' ) <EOL> if self . has_input ( '<STR_LIT>' ) : <EOL> output_suffix = self . get_input ( '<STR_LIT>' ) <EOL> else : <EOL> output_suffix = self . guess_input_format ( input_file . name ) <EOL> if not output_suffix : <EOL> output_suffix = '<STR_LIT>' <EOL> output_file = self . interpreter . filePool . create_file ( suffix = output_suffix ) <EOL> values = [ _mesh_filter_path , <EOL> input_file . name , <EOL> output_file . name ] <EOL> cmdline = list2cmdline ( values ) <EOL> print cmdline <EOL> result = os . system ( cmdline ) <EOL> if result != <NUM_LIT:0> : <EOL> raise ModuleError ( self , '<STR_LIT>' ) <EOL> self . set_output ( '<STR_LIT>' , output_file ) <EOL> class PlanarSubdiv ( MeshFilter ) : <EOL> def compute ( self ) : <EOL> self . check_input ( '<STR_LIT>' ) <EOL> self . check_input ( '<STR_LIT>' ) <EOL> iters = self . get_input ( '<STR_LIT>' ) <EOL> if iters < <NUM_LIT:1> : <EOL> raise ModuleError ( self , '<STR_LIT>' ) <EOL> input_file = self . get_input ( '<STR_LIT>' ) <EOL> if self . has_input ( '<STR_LIT>' ) : <EOL> output_suffix = self . get_input ( '<STR_LIT>' ) <EOL> else : <EOL> output_suffix = self . guess_input_format ( input_file . name ) <EOL> if not output_suffix : <EOL> output_suffix = '<STR_LIT>' <EOL> output_file = self . interpreter . filePool . create_file ( suffix = output_suffix ) <EOL> values = [ _mesh_filter_path , <EOL> input_file . name , <EOL> '<STR_LIT>' , <EOL> output_file . name ] <EOL> cmdline = list2cmdline ( values ) <EOL> print cmdline <EOL> result = os . system ( cmdline ) <EOL> if result != <NUM_LIT:0> : <EOL> raise ModuleError ( self , '<STR_LIT>' ) <EOL> for i in xrange ( iters - <NUM_LIT:1> ) : <EOL> cmdline = '<STR_LIT>' % ( _mesh_filter_path , <EOL> output_file . name , <EOL> output_file . name ) <EOL> print cmdline <EOL> result = os . system ( cmdline ) <EOL> if result != <NUM_LIT:0> : <EOL> raise ModuleError ( self , '<STR_LIT>' ) <EOL> self . set_output ( '<STR_LIT>' , output_file ) <EOL> def initialize ( executable_path = None ) : <EOL> global _mesh_filter_path <EOL> if not executable_path : <EOL> print "<STR_LIT>" <EOL> _mesh_filter_path = '<STR_LIT>' <EOL> else : <EOL> print "<STR_LIT>" % executable_path <EOL> _mesh_filter_path = executable_path + '<STR_LIT>' <EOL> reg = core . modules . module_registry <EOL> reg . add_module ( MeshFilter ) <EOL> reg . add_input_port ( MeshFilter , '<STR_LIT>' , <EOL> core . modules . basic_modules . File ) <EOL> reg . add_input_port ( MeshFilter , '<STR_LIT>' , <EOL> core . modules . basic_modules . String ) <EOL> reg . add_output_port ( MeshFilter , '<STR_LIT>' , <EOL> core . modules . basic_modules . File ) <EOL> reg . add_module ( PlanarSubdiv ) <EOL> reg . add_input_port ( PlanarSubdiv , '<STR_LIT>' , <EOL> core . modules . basic_modules . Integer ) </s>
