Update of /cvsroot/freevo/freevo/src/helpers
In directory sc8-pr-cvs1:/tmp/cvs-serv12667/src/helpers

Modified Files:
        plugins.py 
Log Message:
add html output

Index: plugins.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/helpers/plugins.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** plugins.py  9 Sep 2003 20:26:35 -0000       1.2
--- plugins.py  12 Sep 2003 20:33:18 -0000      1.3
***************
*** 14,17 ****
--- 14,20 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.3  2003/09/12 20:33:18  dischi
+ # add html output
+ #
  # Revision 1.2  2003/09/09 20:26:35  dischi
  # add short description for -l
***************
*** 50,54 ****
  import sys
  
- 
  def parse_plugins():
      start = re.compile('^class *(.*)\((.*Plugin).:')
--- 53,56 ----
***************
*** 69,72 ****
--- 71,75 ----
              continue
          parse_status = 0
+         whitespaces  = 0
          for line in util.readfile(file):
              if (comment.match(line) and parse_status == 2) or \
***************
*** 78,86 ****
                  if desc:
                      desc += '\n'
!                 desc += line.lstrip().rstrip()
  
              if comment.match(line) and parse_status == 1:
                  parse_status = 2
! 
              if start.match(line):
                  fname = re.sub('^src.', '', file)
--- 81,93 ----
                  if desc:
                      desc += '\n'
!                 if not whitespaces:
!                     tmp = line.lstrip()
!                     whitespaces = line.find(tmp)
!                 desc += line[whitespaces:].rstrip()
  
              if comment.match(line) and parse_status == 1:
                  parse_status = 2
!                 whitespaces  = 0
!                 
              if start.match(line):
                  fname = re.sub('^src.', '', file)
***************
*** 132,135 ****
--- 139,209 ----
  
  
+ def iscode(line):
+     return (len(line) > 2 and line[:2].upper() == line[:2] and \
+             line.find('=') > 0) or \
+             (line and line[0] in ('#',' ', '[', '(')) or (line.find('plugin.') == 0)
+ 
+ 
+ def info_html(plugin_name, all_plugins):
+     ret = ''
+     for name, file, type, status, desc in all_plugins:
+         if name == plugin_name:
+             ret += '<h2>%s</h2>' % name
+             ret += '<b>Type: %s</b><br>' % type
+             ret += '<b>File: %s</b><br><br><br>' % file
+             ret += '\n'
+             ret += '<b>Description</b>:'
+             ret += '<p>'
+             tmp  = desc
+             desc = []
+             for block in tmp.split('\n\n'):
+                 for line in block.split('\n'):
+                     desc.append(line)
+                 desc.append('')
+ 
+             code = 0
+             for i in range(len(desc)):
+                 line = desc[i]
+                 if iscode(line):
+                     if not code:
+                         ret += '<br><pre class="code">\n'
+                     ret += line+'\n'
+                     code = 1
+ 
+                     try:
+                         if (desc[i+1] and not iscode(desc[i+1])) or \
+                                (desc[i+2] and not iscode(desc[i+2])):
+                             ret += '</pre>'
+                             code = 0
+                     except IndexError:
+                         ret += '</pre>'
+                         code = 0
+                 elif line:
+                     ret += line
+                 elif code:
+                     ret += '\n'
+                 else:
+                     ret += '<br>'
+ 
+             if code:
+                 ret += '</pre>'
+                 code = 0
+             ret += '</p>'
+             ret += '\n'
+ 
+             if status == 'active':
+                 ret += '<p>The plugin is loaded with the following settings:<br>'
+                 for p in plugin.__all_plugins__:
+                     if p[0] == name:
+                         type = p[1]
+                         if not type:
+                             type = 'default'
+                         ret += 'type=%s, level=%s, args=%s' % (type, p[2], p[3])
+                 ret += '</p><br>'
+             else:
+                 ret += '<p>The plugin is not activated in the current setting</p>'
+ 
+     return ret
+     
  
  
***************
*** 172,175 ****
--- 246,272 ----
              print '\n********************************\n'
          print_info(p[0], [p])
+ 
+ # show infos about all plugins as html
+ elif len(sys.argv)>1 and sys.argv[1] == '-html':
+     all_plugins = parse_plugins()
+ 
+     print '<html><head>\
+ <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-8859-1">\
+ <title>Freevo Plugins</title>\
+ <link rel="stylesheet" type="text/css" href="freevowiki.css">\
+ </head>\
+ <body>\
+ <font class="headline" size="+3">Freevo Plugin List</font>\
+ <p><b>Index</b><ol>'
+ 
+     for p in all_plugins:
+         print '<li><a href="#%s">%s</a></li>' % (p[0], p[0])
+     print '</ol> '
+ 
+     for p in all_plugins:
+         print '<a name="%s"></a>' % p[0]
+         print info_html(p[0], [p])
+ 
+     print '</body>'
  
  else:




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to