mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
sb: Add XML formatter
This commit is contained in:
parent
97e083a72c
commit
1f77f9e36b
@ -89,6 +89,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'
|
||||
@ -160,6 +163,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, now, 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]
|
||||
|
||||
@ -298,6 +320,9 @@ class report:
|
||||
self.out += self.formatter.introduction(name, now, 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():
|
||||
@ -630,13 +655,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:
|
||||
@ -663,6 +689,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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user