#NEWLINE# def from_file( self , filename ) : #NEWLINE# #INDENT# if ( not os . path . exists ( filename ) ) : #NEWLINE# #INDENT# print ( ( 'Failed to open SDF because %s does not exist' % filename ) ) #NEWLINE# return #NEWLINE# #UNINDENT# tree = ET . parse ( filename ) #NEWLINE# root = tree . getroot ( ) #NEWLINE# if ( root . tag != 'sdf' ) : #NEWLINE# #INDENT# print ( 'Not a SDF file. Aborting.' ) #NEWLINE# return #NEWLINE# #UNINDENT# self . version = float ( root . attrib [ 'version' ] ) #NEWLINE# if ( not ( self . version in supported_sdf_versions ) ) : #NEWLINE# #INDENT# print ( ( 'Unsupported SDF version in %s. Aborting.\n' % filename ) ) #NEWLINE# return #NEWLINE# #UNINDENT# self . world . from_tree ( root , version = self . version )