parameters: (self, m_startup='', c_file=True)
return_statement: return result
docstring: Setup your startup.m file to enable FSL MATLAB functions to work
docstring_summary: Setup your startup.m file to enable FSL MATLAB functions to work
docstring_tokens: Setup your startup . m file to enable FSL MATLAB functions to work
function: def configure_matlab(self, m_startup='', c_file=True):
          '''Setup your startup.m file to enable FSL MATLAB functions to work'''
          from os import path, getenv, mkdir
  
          mlines = self.lines['startup.m']
          if m_startup == '':
              m_startup = '/'.join((getenv('HOME'), 'matlab', 'startup.m'))
          if path.exists(m_startup):
              # Check if already configured
              match = file_contains_1stline(mlines[0], m_startup)
              MsgUser.debug(match)
              if match == '':
                  match = file_contains(m_startup, self.test['startup.m'])
                  if match:
                      result = edit_file(m_startup, line_starts_replace, self.test['startup.m'], mlines[0], False)
                      MsgUser.debug('MATLAB startup file is miss-configured, replacing %s with %s.' % (self.test['startup.m'], mlines[0]))
                  else:
                      MsgUser.debug('Adding FSL settings to MATLAB.')
                      result = add_to_file(m_startup, mlines, False)
              else:
                  MsgUser.debug('MATLAB already configured.')
                  result = FslIResult(True, FslIResult.WARN, "MATLAB already configured.")
          elif c_file:
              # No startup.m file found. Create one
              try:
                  MsgUser.debug('No MATLAB startup.m file found, creating one.')
                  if not path.isdir( path.dirname(m_startup)):
                      MsgUser.debug('No MATLAB startup.m file found, creating one.')
                      mkdir(path.dirname(m_startup))
                  result = create_file(m_startup, mlines,False)    
              except OSError:
                  MsgUser.debug('Unable to create ~/matlab folder, cannot configure.')
                  result = FslIResult(False, FslIResult.ERROR, "Unable to create your ~/matlab folder, so cannot configure MATLAB for FSL.")
          else:
              MsgUser.debug('MATLAB may not be installed, doing nothing.')
              result = FslIResult(True, FslIResult.WARN, "I can't tell if you have MATLAB installed.")
          return result
function_tokens: def configure_matlab ( self , m_startup = '' , c_file = True ) : from os import path , getenv , mkdir mlines = self . lines [ 'startup.m' ] if m_startup == '' : m_startup = '/' . join ( ( getenv ( 'HOME' ) , 'matlab' , 'startup.m' ) ) if path . exists ( m_startup ) : # Check if already configured match = file_contains_1stline ( mlines [ 0 ] , m_startup ) MsgUser . debug ( match ) if match == '' : match = file_contains ( m_startup , self . test [ 'startup.m' ] ) if match : result = edit_file ( m_startup , line_starts_replace , self . test [ 'startup.m' ] , mlines [ 0 ] , False ) MsgUser . debug ( 'MATLAB startup file is miss-configured, replacing %s with %s.' % ( self . test [ 'startup.m' ] , mlines [ 0 ] ) ) else : MsgUser . debug ( 'Adding FSL settings to MATLAB.' ) result = add_to_file ( m_startup , mlines , False ) else : MsgUser . debug ( 'MATLAB already configured.' ) result = FslIResult ( True , FslIResult . WARN , "MATLAB already configured." ) elif c_file : # No startup.m file found. Create one try : MsgUser . debug ( 'No MATLAB startup.m file found, creating one.' ) if not path . isdir ( path . dirname ( m_startup ) ) : MsgUser . debug ( 'No MATLAB startup.m file found, creating one.' ) mkdir ( path . dirname ( m_startup ) ) result = create_file ( m_startup , mlines , False ) except OSError : MsgUser . debug ( 'Unable to create ~/matlab folder, cannot configure.' ) result = FslIResult ( False , FslIResult . ERROR , "Unable to create your ~/matlab folder, so cannot configure MATLAB for FSL." ) else : MsgUser . debug ( 'MATLAB may not be installed, doing nothing.' ) result = FslIResult ( True , FslIResult . WARN , "I can't tell if you have MATLAB installed." ) return result