def _loadFromFile( self, fname ):
      # Allow style files to use some variables.
      createData = lambda : {
         'MplStyle' : MplStyle,
         }

      data = createData()
      try:
         execfile( fname, data )
      except Exception, e:
         msg = "MplStyleManager had an error loading the file '%s'" % fname
         raise S.util.mergeExceptions( e, msg )

      if 'style' in data:
         style = data['style']
      else:
         msg = "MplStyleManager is unable to load the style file '%s' " \
               "because there was no value named 'style' of type 'MplStyle' " \
               "found." % (fname,)
         raise Exception( msg )

      if not isinstance( style, MplStyle ):
         msg = "MplStyleManager is unable to load the style file '%s' " \
               "because the value named 'style' was expected to be of type " \
               "'MplStyle', but was instead of type '%s'" % \
               (fname, style.__class__.__name__)
         raise Exception( msg )

      # Load the custom file
      custom = os.path.dirname( fname )
      customBase, customExt = os.path.splitext( fname )
      custom = os.path.join( custom, ( "%s_custom%s" % (customBase,
                                                        customExt) ) )

      if os.path.exists( custom ):
         customData = createData()
         execfile( custom, customData )

         if MPLSTYLE_CUSTOM_FUNC in customData:
            style.custom = customData[MPLSTYLE_CUSTOM_FUNC]
         else:
            msg = "MplStyleManager encountered an error while loading the " \
                  "style '%s'.  A custom script was found, but the expected " \
                  "entry point '%s' was not found in the file.\nCustom File: " \
                  "'%s'" % (style.name, MPLSTYLE_CUSTOM_FUNC, custom)
            raise Exception( msg )

      return style

   #-----------------------------------------------------------------------
: Load the specified style file.
dataset/ETHPy150Open nasa/mplStyle/mplStyle/MplStyleManager.py/MplStyleManager._loadFromFile