Package lemon :: Package external :: Module PyFontify
[show private | hide private]
[frames | no frames]

Module lemon.external.PyFontify

Module to analyze Python source code; for syntax coloring tools.

Interface:
    tags = fontify(pytext, searchfrom, searchto)

The 'pytext' argument is a string containing Python source code.
The (optional) arguments 'searchfrom' and 'searchto' may contain a slice in pytext. 
The returned value is a list of tuples, formatted like this:
    [('keyword', 0, 6, None), ('keyword', 11, 17, None), ('comment', 23, 53, None), etc. ]
The tuple contents are always like this:
    (tag, startindex, endindex, sublist)
tag is one of ('comment', 'string', 'keyword', 'function', 'class')
sublist is not used, hence always None.

Function Summary
  fontify(pytext, searchfrom, searchto)
  test(path)

Variable Summary
str __version__ = '0.4'
str commentPat = '#.*'
SRE_Pattern idRE = [ \t]*[A-Za-z_][A-Za-z_0-9\.]*
str keyPat = '(^|[^a-zA-Z0-9_."\'])(and|assert|break|class|c...
str keywordsPat = 'and|assert|break|class|continue|def|del|e...
str matchPat = '(^|[^a-zA-Z0-9_."\'])(and|assert|break|class...
SRE_Pattern matchRE = (^|[^a-zA-Z0-9_\."'])(and|assert|break|class|c...
str nonKeyPat = '(^|[^a-zA-Z0-9_."\'])'
str pat = 'qqq[^\\q]*((\\\\[\x00-\xff]|q(\\\\[\x00-\xff]|[^\...
str quotePat = '\'[^\\\'\n]*(\\\\[\x00-\xff][^\\\'\n]*)*\'|"...
str tripleQuotePat = '\'\'\'[^\\\']*((\\\\[\x00-\xff]|\'(\\\...

Variable Details

__version__

Type:
str
Value:
'0.4'                                                                  

commentPat

Type:
str
Value:
'#.*'                                                                  

idRE

Type:
SRE_Pattern
Value:
[ \t]*[A-Za-z_][A-Za-z_0-9\.]*                                         

keyPat

Type:
str
Value:
'(^|[^a-zA-Z0-9_."\'])(and|assert|break|class|continue|def|del|elif|el\
se|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|p\
ass|print|raise|return|try|while|yield)(^|[^a-zA-Z0-9_."\'])'          

keywordsPat

Type:
str
Value:
'and|assert|break|class|continue|def|del|elif|else|except|exec|finally\
|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return\
|try|while|yield'                                                      

matchPat

Type:
str
Value:
'''(^|[^a-zA-Z0-9_."\'])(and|assert|break|class|continue|def|del|elif|\
else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or\
|pass|print|raise|return|try|while|yield)(^|[^a-zA-Z0-9_."\'])|#.*|\'\\
'\'[^\\\']*((\\\\[\x00-\xff]|\'(\\\\[\x00-\xff]|[^\\\']|\'(\\\\[\x00-\\
xff]|[^\\\'])))[^\\\']*)*\'\'\'|"""[^\\"]*((\\\\[\x00-\xff]|"(\\\\[\x0\
0-\xff]|[^\\"]|"(\\\\[\x00-\xff]|[^\\"])))[^\\"]*)*"""|\'[^\\\'
]*(\\\\[\x00-\xff][^\\\'
]*)*\'|"[^\\"
...                                                                    

matchRE

Type:
SRE_Pattern
Value:
(^|[^a-zA-Z0-9_\."'])(and|assert|break|class|continue|def|del|elif|els\
e|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pa\
ss|print|raise|return|try|while|yield)(^|[^a-zA-Z0-9_\."'])|#.*|'''[^'\
]*((\\[-ÿ]|'(\\[-ÿ]|[^']|'(\\[-ÿ]|[^'])))[^']*)*'''|"""[^"]*((\\[-\
ÿ]|"(\\[-ÿ]|[^"]|"(\\[-ÿ]|[^"])))[^"]*)*"""|'[^'\n]*(\\[-ÿ][^'\n]*)\
*'|"[^"\n]*(\\[-ÿ][^"\n]*)*"                                          

nonKeyPat

Type:
str
Value:
'(^|[^a-zA-Z0-9_."\'])'                                                

pat

Type:
str
Value:
'qqq[^\\q]*((\\\\[\x00-\xff]|q(\\\\[\x00-\xff]|[^\\q]|q(\\\\[\x00-\xff\
]|[^\\q])))[^\\q]*)*qqq'                                               

quotePat

Type:
str
Value:
'''\'[^\\\'
]*(\\\\[\x00-\xff][^\\\'
]*)*\'|"[^\\"
]*(\\\\[\x00-\xff][^\\"
]*)*"'''                                                               

tripleQuotePat

Type:
str
Value:
'\'\'\'[^\\\']*((\\\\[\x00-\xff]|\'(\\\\[\x00-\xff]|[^\\\']|\'(\\\\[\x\
00-\xff]|[^\\\'])))[^\\\']*)*\'\'\'|"""[^\\"]*((\\\\[\x00-\xff]|"(\\\\\
[\x00-\xff]|[^\\"]|"(\\\\[\x00-\xff]|[^\\"])))[^\\"]*)*"""'            

Generated by Epydoc 2.0 on Mon Nov 10 15:07:49 2003 http://epydoc.sf.net