Back to index

plone3  3.1.7
Classes | Functions | Variables
PortalTransforms.libtransforms.utils Namespace Reference

Classes

class  MissingBinary
class  IllegalHTML
class  StrippingParser

Functions

def bin_search
def getShortPathName
def sansext
def bodyfinder
 The code below is taken from CMFDefault.utils to remove dependencies for Python-only installations.
def scrubHTML

Variables

 WIN32 = True
list envPath = os.environ['PATH']
list bin_search_path
string cygwin = 'c:/cygwin'
tuple p = os.path.join(cygwin, p)
tuple extensions = ('.exe', '.com', '.bat', )
dictionary VALID_TAGS
dictionary NASTY_TAGS

Class Documentation

class PortalTransforms::libtransforms::utils::MissingBinary

Definition at line 17 of file utils.py.

class PortalTransforms::libtransforms::utils::IllegalHTML

Definition at line 142 of file utils.py.


Function Documentation

search the bin_search_path for a given binary returning its fullname or
   raises MissingBinary

Definition at line 37 of file utils.py.

00037 
00038 def bin_search(binary):
00039     """search the bin_search_path for a given binary returning its fullname or
00040        raises MissingBinary"""
00041     mode   = os.R_OK | os.X_OK
00042     for path in bin_search_path:
00043         for ext in ('', ) + extensions:
00044             pathbin = os.path.join(path, binary) + ext
00045             if os.access(pathbin, mode) == 1:
00046                 return pathbin
00047 
00048     raise MissingBinary('Unable to find binary "%s" in %s' % 
00049                         (binary, os.pathsep.join(bin_search_path)))

The code below is taken from CMFDefault.utils to remove dependencies for Python-only installations.

Return body or unchanged text if no body tags found.

Always use html_headcheck() first.

Definition at line 67 of file utils.py.

00067 
00068 def bodyfinder(text):
00069     """ Return body or unchanged text if no body tags found.
00070 
00071     Always use html_headcheck() first.
00072     """
00073     lowertext = text.lower()
00074     bodystart = lowertext.find('<body')
00075     if bodystart == -1:
00076         return text
00077     bodystart = lowertext.find('>', bodystart) + 1
00078     if bodystart == 0:
00079         return text
00080     bodyend = lowertext.rfind('</body>', bodystart)
00081     if bodyend == -1:
00082         return text
00083     return text[bodystart:bodyend]
00084 
00085 
00086 #
00087 #   HTML cleaning code
00088 #
00089 
# These are the HTML tags that we will leave intact

Definition at line 50 of file utils.py.

00050 
00051 def getShortPathName(binary):
00052     if WIN32:
00053         try:
00054             binary = win32api.GetShortPathName(binary)
00055         except win32api.error:
00056             log("Failed to GetShortPathName for '%s'" % binary)
00057     return binary

Definition at line 58 of file utils.py.

00058 
00059 def sansext(path):
00060     return os.path.splitext(os.path.basename(path))[0]
00061 

Here is the caller graph for this function:

Strip illegal HTML tags from string text.  

Definition at line 212 of file utils.py.

00212 
00213 def scrubHTML( html ):
00214     """ Strip illegal HTML tags from string text.  """
00215     parser = StrippingParser()
00216     parser.feed( html )
00217     parser.close()
00218     return parser.result

Variable Documentation

Initial value:
00001 [path for path in envPath.split(os.pathsep)
00002                    if os.path.isdir(path)]

Definition at line 20 of file utils.py.

Definition at line 23 of file utils.py.

Definition at line 19 of file utils.py.

tuple PortalTransforms.libtransforms.utils.extensions = ('.exe', '.com', '.bat', )

Definition at line 33 of file utils.py.

Initial value:
00001 { 'script'     : 1
00002              , 'object'     : 1
00003              , 'embed'      : 1
00004              , 'applet'     : 1
00005              }

Definition at line 136 of file utils.py.

Definition at line 28 of file utils.py.

Definition at line 90 of file utils.py.

Definition at line 13 of file utils.py.