Exemple #1
0
   def validateDataSource(self, dataSourceName):
      """
      Iterates through dataSourceReqKeys and confirms required 
      key/value pairs.  Probably a better way of doing this but
      not thinking of anything more elegent at the moment.  Attempting
      to provide the caller with clear messaging regarding missing fields
      in the data source file.

      Parameters:
         dataSourceName - name of the datasource to test

      Returns:
         None
      """
      for key in self.dataSourceReqKeys:
         if key is 'req':
            msg = 'the %s source object in %s' % (dataSourceName, BaseHub.sourceListFile)
            ##Confirm required keys##
            BaseHub.checkKeys(self.dataSourceReqKeys[key], BaseHub.dataSources[dataSourceName], True, msg)
         elif key is 'databases':

            if key in BaseHub.dataSources[dataSourceName]:
               for i in range(len(BaseHub.dataSources[dataSourceName][key])):
                  db = BaseHub.dataSources[dataSourceName][key][i]
                  msg = 'the %s.%s index position %i in %s' % (dataSourceName, key, i, BaseHub.sourceListFile)
                  BaseHub.checkKeys(self.dataSourceReqKeys[key], db, True, msg)
         else:
            msg = 'the %s.%s in %s' % (dataSourceName, key, BaseHub.sourceListFile)
            if key in BaseHub.dataSources[dataSourceName]:
               BaseHub.checkKeys(self.dataSourceReqKeys[key], BaseHub.dataSources[dataSourceName][key], True, msg)