Esempio n. 1
0
    def validate_data_source(self, data_source_name):
        """
        Iterates through data_source_req_keys 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:
           data_source_name - name of the datasource to test

        Returns:
           None
        """
        for key in self.data_source_req_keys:
            if key is 'req':
                msg = 'the %s source object in %s' % (data_source_name, BaseHub.source_list_file)
                # Confirm required keys
                BaseHub.check_keys(self.data_source_req_keys[key], BaseHub.data_sources[data_source_name], True, msg)
            elif key is 'databases':

                if key in BaseHub.data_sources[data_source_name]:
                    for i in range(len(BaseHub.data_sources[data_source_name][key])):
                        db = BaseHub.data_sources[data_source_name][key][i]
                        msg = 'the %s.%s index position %i in %s' % (data_source_name, key, i, BaseHub.source_list_file)
                        BaseHub.check_keys(self.data_source_req_keys[key], db, True, msg)
            else:
                msg = 'the %s.%s in %s' % (data_source_name, key, BaseHub.source_list_file)
                if key in BaseHub.data_sources[data_source_name]:
                    BaseHub.check_keys(self.data_source_req_keys[key], BaseHub.data_sources[data_source_name][key], True, msg)
Esempio n. 2
0
    def validate_data_source(self, data_source_name):
        """
        Iterates through data_source_req_keys 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:
           data_source_name - name of the datasource to test

        Returns:
           None
        """
        for key in self.data_source_req_keys:
            if key is 'req':
                msg = 'the %s source object in %s' % (data_source_name,
                                                      BaseHub.source_list_file)
                # Confirm required keys
                BaseHub.check_keys(self.data_source_req_keys[key],
                                   BaseHub.data_sources[data_source_name],
                                   True, msg)
            elif key is 'databases':

                if key in BaseHub.data_sources[data_source_name]:
                    for i in range(
                            len(BaseHub.data_sources[data_source_name][key])):
                        db = BaseHub.data_sources[data_source_name][key][i]
                        msg = 'the %s.%s index position %i in %s' % (
                            data_source_name, key, i, BaseHub.source_list_file)
                        BaseHub.check_keys(self.data_source_req_keys[key], db,
                                           True, msg)
            else:
                msg = 'the %s.%s in %s' % (data_source_name, key,
                                           BaseHub.source_list_file)
                if key in BaseHub.data_sources[data_source_name]:
                    BaseHub.check_keys(
                        self.data_source_req_keys[key],
                        BaseHub.data_sources[data_source_name][key], True, msg)