"Fossies" - the Fresh Open Source Software Archive

Member "Tahchee-1.0.0/Sources/tahchee/plugins/pamelamarkup.py" (17 Feb 2009, 1834 Bytes) of package /linux/privat/old/tahchee-1.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "pamelamarkup.py" see the Fossies "Dox" file reference documentation.

    1 # vim: ts=4
    2 # -----------------------------------------------------------------------------
    3 # Project           :   Tahchee                      <http://www.ivy.fr/tachee>
    4 # -----------------------------------------------------------------------------
    5 # Author            :   Sebastien Pierre                     <sebastien@ivy.fr>
    6 # License           :   Revised BSD License
    7 # -----------------------------------------------------------------------------
    8 # Creation date     :   14-Mar-2008
    9 # Last mod.         :   14-Mar-2008
   10 # -----------------------------------------------------------------------------
   11 
   12 import os, sys, StringIO
   13 try:
   14     import pamela.engine as pamela
   15 except ImportError:
   16     import _pamela.engine as pamela
   17 
   18 NAME    = "pamela"
   19 VERSION = None
   20 SUMMARY = "Pamela markup to HTML conversion functions."
   21 
   22 class PamelaPlugin:
   23 
   24     def __init__( self, site ):
   25         self.site = site
   26 
   27     def name( self ): return NAME
   28     def summary( self ): return SUMMARY
   29     def version( self ): return VERSION
   30     def doc( self ): return __doc__
   31 
   32     def install( self, localdict ):
   33         localdict["pamela"] = self
   34     
   35     def include( self, path ):
   36         if not path[0] == "/":
   37             path = self.site.pagesDir + "/" + path
   38         if pamela:
   39             r = pamela.run(path)
   40             return r
   41         else:
   42             self.site.warn("Pamela is not available, but you used the $site.pamela function")
   43             self.site.info("You can get Kiwi from <http://www.ivy.fr/pamela>")
   44             return path
   45 
   46     def process( self, text ):
   47 
   48         if pamela:
   49             try:
   50                 return pamela.Parser().parseText(text)
   51             except Exception, e:
   52                 self.site.error("Can't process pamela markup " + str(e))
   53                 raise
   54         else:
   55             self.site.warn("Pamela is not available, but you used the $site.pamela function")
   56             info("You can get Pamela from <http://www.ivy.fr/pamela>")
   57             return text
   58 
   59     def __call__( self, text):
   60         return self.process(text)
   61 
   62 # EOF