Пример #1
0
    def classified(self):
        """
        设计国土行业数据的dem_part_2验证规则
        完成 负责人 李宪 在这里检验dem_part_2的识别规则
        :return:
        """
        super().classified()
        file_main_name_with_path = CFile.join_file(self.file_info.file_path, self.file_info.file_main_name)
        check_file_main_name_exist_tif = CFile.file_or_path_exist(
            '{0}.{1}'.format(file_main_name_with_path, self.Name_Tif))
        check_file_main_name_exist_bil = CFile.file_or_path_exist(
            '{0}.{1}'.format(file_main_name_with_path, self.Name_Bil))
        if (not check_file_main_name_exist_tif) and (not check_file_main_name_exist_bil):
            return self.Object_Confirm_IUnKnown, self._object_name

        # 判断是否有‘-’,并且为一个
        if not self.file_info.file_main_name.count('-') == 1:
            return self.Object_Confirm_IUnKnown, self._object_name

        char_1 = self.file_info.file_main_name.split('-')[0]
        char_2 = self.file_info.file_main_name.split('-')[1]
        # char_1,char_2是否小数
        if CUtils.text_is_decimal(char_1) is False \
                or CUtils.text_is_decimal(char_2) is False:
            return self.Object_Confirm_IUnKnown, self._object_name

        if CUtils.equal_ignore_case(self.file_info.file_ext, self.Name_Tif) \
                or CUtils.equal_ignore_case(self.file_info.file_ext, self.Name_Bil):
            self._object_confirm = self.Object_Confirm_IKnown
            self._object_name = self.file_info.file_main_name
        else:
            self._object_confirm = self.Object_Confirm_IKnown_Not
            self._object_name = None
        return self._object_confirm, self._object_name
Пример #2
0
 def __a_check_value_datatype__(cls, result_template: dict, value,
                                title_prefix, value_type,
                                value_sql_db_server_id):
     """
     完成 赵宇飞 对字段值根据字段类型进行检验(正整数或正小数类型、数字类型(科学计数法/正负整数/正负小数)、文本类型、日期类型...)
     :param result_template: 检查结果的模板
     :param value: 待检验的值, 可能为None
     :param title_prefix:
     :param value_type: 类型(正整数类型、数字类型(科学计数法/正负整数/正负小数)、文本类型、日期类型...)
     :return:
     """
     result_dict = copy.deepcopy(result_template)
     if CUtils.equal_ignore_case(value_type, cls.value_type_string):
         if CUtils.text_is_string(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type, cls.value_type_date):
         if cls.text_is_date_bus(value, value_sql_db_server_id):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type, cls.value_type_date_nosep):
         if cls.text_is_date_nosep_bus(value, value_sql_db_server_id):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type,
                                   cls.value_type_date_month_nosep):
         if CUtils.text_is_date_month_nosep(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type, cls.value_type_datetime):
         if CUtils.text_is_datetime(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type,
                                   cls.value_type_date_or_datetime):
         if CUtils.text_is_date_or_datetime(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type, cls.value_type_decimal):
         if CUtils.text_is_decimal(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type, cls.value_type_integer):
         if CUtils.text_is_integer(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(value_type,
                                   cls.value_type_decimal_or_integer):
         if CUtils.text_is_decimal_or_integer(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     elif CUtils.equal_ignore_case(
             value_type, cls.value_type_decimal_or_integer_positive):
         if CUtils.text_is_decimal_or_integer_positive(value):
             result_dict[cls.Name_Message] = '{0}的值类型符合要求!'.format(
                 title_prefix)
             result_dict[cls.Name_Result] = cls.QA_Result_Pass
         else:
             result_dict[
                 cls.
                 Name_Message] = '{0}的值【{1}】的类型不符合【{2}】类型, 请检查修正!'.format(
                     title_prefix, value, value_type)
     return result_dict