1
2
3
4
5 """
6
7 Serialize DOAP as XML/RDF
8 =========================
9
10 This plugin outputs DOAP in RDF/XML
11 It basically does nothing because all DOAP today is in RDF/XML.
12 In the future this may take N3, Turtle, RDFa etc. and convert it to RDF/XML.
13
14 """
15
16 __docformat__ = 'epytext'
17
18
19 from doapfiend.plugins.base import Plugin
20
21
23
24 """Class for formatting DOAP output"""
25
26
27 name = "xml"
28 enabled = False
29 enable_opt = None
30
32 '''Setup RDF/XML OutputPlugin class'''
33 super(OutputPlugin, self).__init__()
34 self.options = None
35
37 """Add plugin's options to doapfiend's opt parser"""
38 output.add_option('-x', '--%s' % self.name,
39 action='store_true',
40 dest=self.enable_opt,
41 help='Output DOAP as RDF/XML')
42 return parser, output, search
43
45 '''
46 Serialize RDF/XML DOAP as N3 syntax
47
48 @param doap_xml: DOAP in RDF/XML serialization
49 @type doap_xml: string
50
51 @rtype: unicode
52 @returns: DOAP
53 '''
54
55 if hasattr(self.options, 'no_color'):
56 color = not self.options.no_color
57 if color:
58
59
60 try:
61 from pygments import highlight
62 from pygments.lexers import XmlLexer
63 from pygments.formatters import TerminalFormatter
64 except ImportError:
65 return doap_xml
66 return highlight(doap_xml,
67 XmlLexer(),
68 TerminalFormatter(full=False))
69 else:
70 return doap_xml
71