#NEWLINE# def read_template_file( filename , rosdistro ) : #NEWLINE# #INDENT# template_dir = os . path . join ( os . path . dirname ( __file__ ) , 'templates' ) #NEWLINE# templates = [ ] #NEWLINE# templates . append ( os . path . join ( template_dir , rosdistro , ( '%s.in' % filename ) ) ) #NEWLINE# templates . append ( os . path . join ( template_dir , ( '%s.in' % filename ) ) ) #NEWLINE# for template in templates : #NEWLINE# #INDENT# if os . path . isfile ( template ) : #NEWLINE# #INDENT# with open ( template , 'r' ) as fhand : #NEWLINE# #INDENT# template_contents = fhand . read ( ) #NEWLINE# #UNINDENT# return template_contents #NEWLINE# #UNINDENT# #UNINDENT# raise IOError ( ( "Could not read template for ROS distro '{}' at '{}': " . format ( rosdistro , ', ' . join ( templates ) ) + 'no such file or directory' ) )