"Fossies" - the Fresh Open Source Software Archive

Member "cheetah3-3.2.6.post2/Cheetah/convertTmplPathToModuleName.py" (20 Apr 2021, 755 Bytes) of package /linux/www/cheetah3-3.2.6.post2.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 "convertTmplPathToModuleName.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3-3.0.1_vs_3-3.1.0.

    1 import os.path
    2 import string
    3 from Cheetah.compat import unicode
    4 
    5 letters = None
    6 try:
    7     letters = string.ascii_letters
    8 except AttributeError:
    9     letters = string.letters
   10 
   11 _l = ['_'] * 256
   12 for c in string.digits + letters:
   13     _l[ord(c)] = c
   14 _pathNameTransChars = ''.join(_l)
   15 del _l, c
   16 
   17 
   18 def convertTmplPathToModuleName(tmplPath,
   19                                 _pathNameTransChars=_pathNameTransChars,
   20                                 splitdrive=os.path.splitdrive,
   21                                 ):
   22     try:
   23         moduleName = splitdrive(tmplPath)[1].translate(_pathNameTransChars)
   24     except (UnicodeError, TypeError):
   25         moduleName = unicode(splitdrive(tmplPath)[1])\
   26             .translate(unicode(_pathNameTransChars))
   27     return moduleName