当前位置: 首页>>代码示例>>Python>>正文


Python Report.template_load_xml方法代码示例

本文整理汇总了Python中report.Report.template_load_xml方法的典型用法代码示例。如果您正苦于以下问题:Python Report.template_load_xml方法的具体用法?Python Report.template_load_xml怎么用?Python Report.template_load_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在report.Report的用法示例。


在下文中一共展示了Report.template_load_xml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from report import Report [as 别名]
# 或者: from report.Report import template_load_xml [as 别名]
        def __init__(self, application=None, *args, **kwargs):
            self.application = application
            wx.Frame.__init__(self, None, *args, **kwargs)
            self.Bind(wx.EVT_CLOSE, lambda x: self.Destroy())
            # self.Show()
            import sys

            def val(key):
                if key in sys.argv:
                    return sys.argv[sys.argv.index("-t") + 1]
                else:
                    return None

            def is_yaml(filename):
                ext = ".yaml"
                return filename[-len(ext) :] == ext

            template_file = val("-t")
            content_file = val("-c")
            kb_file = val("-k")
            scan_file = val("-s")
            report_file = val("-r")

            if template_file and report_file:
                report = Report()
                report.template_load_xml(template_file)
                if content_file:
                    if is_yaml(content_file):
                        report.content_load_yaml(content_file)
                    else:
                        report.content_load_json(content_file)
                if kb_file:
                    if is_yaml(kb_file):
                        report.kb_load_yaml(kb_file)
                    else:
                        report.kb_load_json(kb_file)
                if scan_file:
                    report.scan = Scan(scan_file)
                report.xml_apply_meta(
                    vulnparam_highlighting=self.menu_view_v.IsChecked(), truncation=self.menu_view_i.IsChecked()
                )
                report.save_report_xml(report_file)
            else:
                print "Usage: "
                print
                print "    " + self.application.title + ".exe"
                print "        start GUI application"
                print
                print "    " + self.application.title + ".exe -t template-file [-c content-file] [-k kb-file] [-s scan-file] -r report-file"
                print "        generate report"
                print
                print "    " + self.application.title + ".exe [any other arguments]"
                print "        display usage and exit"

            self.Close()
开发者ID:hvqzao,项目名称:report-ng,代码行数:57,代码来源:gui.py

示例2: __MainWindow

# 需要导入模块: from report import Report [as 别名]
# 或者: from report.Report import template_load_xml [as 别名]

#.........这里部分代码省略.........
        def Destroy(self):
            map(lambda x: x.Close(), filter(lambda x: isinstance(x, wx.Frame), self.GetChildren()))
            wx.WakeUpIdle()
            # print 'destroying MainWindow'
            super(wx.Frame, self).Destroy()

        def Open_Template(self, e):
            openFileDialog = wx.FileDialog(
                self,
                "Open Template",
                "",
                "",
                "XML files (*.xml)|*.xml|All files (*.*)|*.*",
                wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
            )
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            self._open_template(openFileDialog.GetPath())

        def _open_template(self, filename):
            self.status("Loading template...")
            self.ctrl_st_t.Enable(False)
            self.ctrl_tc_t.SetValue("")
            self.ctrl_st_c.Enable(False)
            self.ctrl_tc_c.SetValue("")
            self.menu_file_open_k.Enable(False)
            self.menu_file_save_t.Enable(False)
            self.menu_file_save_r.Enable(False)
            self.menu_tools_template_structure_preview.Enable(False)
            # if self.report:
            #    del self.report
            # self.report = Report()
            # print self.report._skel
            self.report.template_load_xml(filename, clean=self.menu_view_c.IsChecked())
            if self.menu_view_y.IsChecked():
                self.ctrl_tc_t.SetValue(self.report.template_dump_yaml())
            else:
                self.ctrl_tc_t.SetValue(self.report.template_dump_json())
            self.ctrl_st_t.Enable(True)
            self.ctrl_tc_c.Enable(True)
            self.ctrl_tc_c.SetBackgroundColour(self.color_tc_bg_e)
            self.ctrl_tc_k.Enable(True)
            self.ctrl_tc_k.SetBackgroundColour(self.color_tc_bg_e)
            self.menu_file_open_k.Enable(True)
            self.menu_file_open_c.Enable(True)
            self.menu_file_save_t.Enable(True)
            self.menu_tools_template_structure_preview.Enable(True)
            if self.scan:
                self.menu_file_save_r.Enable(True)
            if self.ctrl_st_s.IsEnabled():
                self.menu_tools_merge_scan_into_content.Enable(True)
            self.status("Template loaded")

        def Open_Content(self, e):
            openFileDialog = wx.FileDialog(
                self,
                "Open Content",
                "",
                "",
                "Content files (*.yaml; *.json)|*.yaml;*.json|All files (*.*)|*.*",
                wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
            )
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            self._open_content(openFileDialog.GetPath())
开发者ID:hvqzao,项目名称:report-ng,代码行数:69,代码来源:gui.py


注:本文中的report.Report.template_load_xml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。