當前位置: 首頁>>代碼示例>>Python>>正文


Python Validator.check_config_xml方法代碼示例

本文整理匯總了Python中aeneas.validator.Validator.check_config_xml方法的典型用法代碼示例。如果您正苦於以下問題:Python Validator.check_config_xml方法的具體用法?Python Validator.check_config_xml怎麽用?Python Validator.check_config_xml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aeneas.validator.Validator的用法示例。


在下文中一共展示了Validator.check_config_xml方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: perform_command

# 需要導入模塊: from aeneas.validator import Validator [as 別名]
# 或者: from aeneas.validator.Validator import check_config_xml [as 別名]
    def perform_command(self):
        """
        Perform command and return the appropriate exit code.

        :rtype: int
        """
        if len(self.actual_arguments) < 2:
            return self.print_help()
        mode = self.actual_arguments[0]

        validator = Validator(rconf=self.rconf, logger=self.logger)
        if mode == u"config":
            config_file_path = self.actual_arguments[1]
            config_txt = None
            if config_file_path.lower().endswith(u".txt"):
                config_txt = True
            elif config_file_path.lower().endswith(u".xml"):
                config_txt = False
            else:
                return self.print_help()
            if not self.check_input_file(config_file_path):
                return self.ERROR_EXIT_CODE
            contents = gf.read_file_bytes(config_file_path)
            if contents is None:
                return self.ERROR_EXIT_CODE
            if config_txt:
                result = validator.check_config_txt(contents)
                msg = u"TXT configuration"
            else:
                result = validator.check_config_xml(contents)
                msg = "XML configuration"
        elif mode == u"container":
            container_path = self.actual_arguments[1]
            result = validator.check_container(container_path)
            msg = "container"
        elif mode == u"job":
            config_string = self.actual_arguments[1]
            result = validator.check_configuration_string(config_string, is_job=True)
            msg = u"job configuration string"
        elif mode == u"task":
            config_string = self.actual_arguments[1]
            result = validator.check_configuration_string(config_string, is_job=False, external_name=True)
            msg = u"task configuration string"
        elif mode == u"wizard":
            if (len(self.actual_arguments) < 3) or (self.actual_arguments[2].startswith(u"-")):
                return self.print_help()
            config_string = self.actual_arguments[1]
            container_path = self.actual_arguments[2]
            if not self.check_input_file(container_path):
                return self.ERROR_EXIT_CODE
            result = validator.check_container(container_path, config_string=config_string)
            msg = "container with configuration string from wizard"
        else:
            return self.print_help()

        if result.passed:
            self.print_success(u"Valid %s" % msg)
            for warning in result.warnings:
                self.print_warning(u"%s" % warning)
            return self.NO_ERROR_EXIT_CODE
        else:
            self.print_error(u"Invalid %s" % msg)
            for error in result.errors:
                self.print_error(u"%s" % error)

        return self.ERROR_EXIT_CODE
開發者ID:eomerdws,項目名稱:aeneas,代碼行數:68,代碼來源:validate.py


注:本文中的aeneas.validator.Validator.check_config_xml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。