Attachment 'InlineSource.py'

Download

   1 #!/usr/bin/python
   2 
   3 Dependencies = []
   4 
   5 from MoinMoin.parser import cplusplus
   6 from MoinMoin import wikiutil
   7 
   8 class Parser(cplusplus.Parser):
   9 
  10     parsername = "CPlusPlusInclude"
  11 
  12     def __init__(self, raw, request, **kw):
  13         cplusplus.Parser.__init__(self, raw, request)
  14         self.raw        = raw
  15         self.request    = request
  16         self.form       = request.form
  17         self._          = request.getText
  18         self.args       = kw.get('format_args', '')
  19 
  20         attrs, msg = wikiutil.parseAttributes(request, self.args)
  21         self.filename   = attrs.get('filename', '')[1:-1]
  22 
  23     def format(self, formatter):
  24         # Modify this line to point to the root of your source code project
  25         # Users can specify the source file with {{{#!InlineSource filename='/directory/file.c'}}}
  26         # This will display the source file located under /usr/src/myproject/directory/file.c
  27 
  28         src_path = "/usr/src/myproject";
  29 
  30         request = self.request
  31 
  32         src = open(src_path + self.filename, "r").read()
  33 
  34         self.raw = src
  35 
  36         return cplusplus.Parser.format(self, formatter)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-03-09 07:43:22, 1.1 KB) [[attachment:InlineSource.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.