[PATCH 4/9] sb: Add XML formatter

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Dec 8 06:48:47 UTC 2014


---
 source-builder/sb/reports.py | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/source-builder/sb/reports.py b/source-builder/sb/reports.py
index d573003..fd38767 100644
--- a/source-builder/sb/reports.py
+++ b/source-builder/sb/reports.py
@@ -88,6 +88,9 @@ class formatter(object):
         c.line('Report: %s' % (name))
         return c.get()
 
+    def epilogue(self, name):
+        return ''
+
 class asciidoc_formatter(formatter):
     def format(self):
         return 'asciidoc'
@@ -158,6 +161,25 @@ class ini_formatter(text_formatter):
             c.line(';')
         return c.get()
 
+class xml_formatter(formatter):
+    def format(self):
+        return 'xml'
+
+    def ext(self):
+        return '.xml'
+
+    def introduction(self, name, intro_text):
+        c = chunk()
+        c.line('<RTEMSSourceBuilderReport>')
+        if intro_text:
+            c.line('\t<Introduction>%s</Introduction>' % (intro_text))
+        return c.get()
+
+    def epilogue(self, name):
+        c = chunk()
+        c.line('</RTEMSSourceBuilderReport>')
+        return c.get()
+
 def _tree_name(path_):
     return path.splitext(path.basename(path_))[0]
 
@@ -295,6 +317,9 @@ class report:
         self.out += self.formatter.introduction(name, intro_text)
         self.git_status()
 
+    def epilogue(self, name):
+        self.out += self.formatter.epilogue(name)
+
     def config_start(self, name, _config):
         self.files['configs'] += [name]
         for cf in _config.includes():
@@ -627,13 +652,14 @@ class report:
         self.setup()
         self.introduction(inname, intro_text)
         self.generate(inname)
+        self.epilogue(inname)
         self.write(outname)
 
 def run(args):
     try:
         optargs = { '--list-bsets':   'List available build sets',
                     '--list-configs': 'List available configurations',
-                    '--format':       'Output format (text, html, asciidoc, ini)',
+                    '--format':       'Output format (text, html, asciidoc, ini, xml)',
                     '--output':       'File name to output the report' }
         opts = options.load(args, optargs)
         if opts.get_arg('--output') and len(opts.params()) > 1:
@@ -660,6 +686,8 @@ def run(args):
                     formatter = html_formatter()
                 elif format_opt[1] == 'ini':
                     formatter = ini_formatter()
+                elif format_opt[1] == 'xml':
+                    formatter = xml_formatter()
                 else:
                     raise error.general('invalid format: %s' % (format_opt[1]))
             r = report(formatter, configs, opts)
-- 
1.8.4.5




More information about the devel mailing list