• File: PySourceColor.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyc
  • Date Modified: 08/01/2016 7:39 PM
  • File size: 53.86 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

bNc=@sOdZddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=g=Zd>Zd?Zd@ZdAZdBZdCdDlZdCdDlZdCdDl	Z	dCdDl
Z
dCdDlZdCdDlZdCdDl
Z
dCdDlZdCdDlZydCdDlZWndCdDlZnXe
jZe
jZejZe
jZe
jZe
jdEZe
jdFZe
jdGZe
jdHZe
jdIZe
jdJZe
jdKZe
jdLZ e
jdMZ!e
jdNZ"e
jdOZ#e
jdPZ$e
jdQZ%e
jdRZ&e
jdSZ'e
jdTZ(e
jdUZ)e
jdVZ*e
jdWZ+e
jdXZ,e
jdYZ-e
jdZZ.e
jd[Z/e
jd\Z0e
jd]Z1e
jd^Z2e
jd_Z3e
jd`Z4e
jdaZ5idbe6dce,6dde+6dee6dfe6dge6dhe6die6dje6dke6dle6dme6dne6doe6dpe 6dqe!6dre"6dse#6dte$6due%6dve&6dwe'6dxe(6dye)6dze-6d{e.6d|e/6d}e06Z6ide6de,6de+6de6de6de6de6d	e6de6de6d
e6de6de6de6de 6de!6de"6de#6de$6de%6de&6de'6de(6de)6de-6d
e.6de/6de06de*6Z7id~dd~fe6d~dd~fe,6d~dd~fe+6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe.6d~dd~fe-6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe 6d~dd~fe!6d~dd~fe"6d~dd~fe#6d~dd~fe$6d~dd~fe%6d~dd~fe&6d~dd~fe'6d~dd~fe(6d~dd~fe)6d~dd~fe06ddd~fe/6de*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TE_UtDOUBLEQUOTEt
DOUBLEQUOTE_Rt
DOUBLEQUOTE_UtTRIPLESINGLEQUOTEtTEXTtTRIPLESINGLEQUOTE_RtTRIPLESINGLEQUOTE_UtTRIPLEDOUBLEQUOTEtTRIPLEDOUBLEQUOTE_RtTRIPLEDOUBLEQUOTE_UtPAGEBACKGROUNDt
LINENUMBERt	CODESTARTtCODEENDtPYtTOKEN_NAMEStCSSHOOKtnulltmonotlitetdarktdark2t	pythonwintidletviewcvstUsagetclit
str2stdouttpath2stdouttParsertstr2filetstr2htmltstr2csst
str2markupt	path2filet	path2htmltconverttwalkdirt
defaultColorstshowpagetpageconvertt
tagreplacet
MARKUPDICTt
PySourceColors2.1as
25 April 2005sM.E.Farmer Jr.sThis was originally based on a python recipe
submitted by Jrgen Hermann to ASPN. Now based on the voices in my head.
M.E.Farmer 2004, 2005
Python license
iNiiiiiiiii	i
iii
iiiiiiiiiiiiiiiitpy_errtpy_decntpy_dectpy_argstpy_nametpy_numtpy_optpy_comtpy_dcomtpy_clsntpy_defntpy_keytpy_sqtpy_sqrtpy_squtpy_dqtpy_dqrtpy_dqutpy_tsqtpy_tsqrtpy_tsqutpy_tdqtpy_tdqrtpy_tdqutpy_bratpy_moptpy_lnumtpy_textts#000000s
>ti#555555s#FFFFFFss#FF0000s#FF8080tbutbs#555555tis#999999s#FFBBAAs#CC5511s#DDDDFFs#DDDDDDs#FF0000s#FAF785s#45FCA0s#A7C7A9s#B666FDs#EBAE5Cs#8680FFs#F8BAFEs#FF80C0s#FF9595s#B3FFFFs
>mi#555555s#bbccbbs#333333s#C0C0C0s#00FF00s#FF090Fs#EE7020s#FFB90Fs#D0D000s#522000s#DD4080s#FF8040s#4726d1s#8080C0s#ADB9F1s#00C1C1s#33E3E3s#BB4422s#3333AFs#DD2200s#007F00s#608060s#0000DFs#9C7A00s#0000AFs#600080s#A0008As#337799s#1166AAs#900090s#FF7700s#DD0000s#0000FFs#00AA00s#DD0080s#000080s#303030s#008080s#7F7F7Fs#007F7Fs#808000s#b22222s#0000ffs#a020f0s#bc8f8fcCs d}|tGHtjddS(Ns
 -----------------------------------------------------------------------------
  PySourceColor.py ver: %s
 -----------------------------------------------------------------------------
  Module summary:
     This module is designed to colorize python source code.
         Input--->python source
         Output-->colorized (html, html4.01/css, xhtml1.0)
     Standalone:
         This module will work from the command line with options.
         This module will work with redirected stdio.
     Imported:
         This module can be imported and used directly in your code.
 -----------------------------------------------------------------------------
  Command line options:
     -h, --help
         Optional-> Display this help message.
     -t, --test
         Optional-> Will ignore all others flags but  --profile
             test all schemes and markup combinations
     -p, --profile
         Optional-> Works only with --test or -t
             runs profile.py and makes the test work in quiet mode.
     -i, --in, --input
         Optional-> If you give input on stdin.
         Use any of these for the current dir (.,cwd)
         Input can be file or dir.
         Input from stdin use one of the following (-,stdin)
         If stdin is used as input stdout is output unless specified.
     -o, --out, --output
         Optional-> output dir for the colorized source.
             default: output dir is the input dir.
         To output html to stdout use one of the following (-,stdout)
         Stdout can be used without stdin if you give a file as input.
     -c, --color
         Optional-> null, mono, dark, dark2, lite, idle, pythonwin, viewcvs
             default: dark 
     -s, --show
         Optional-> Show page after creation.
             default: no show
     -m, --markup
         Optional-> html, css, xhtml
             css, xhtml also support external stylesheets (-e,--external)
             default: HTML
     -e, --external
         Optional-> use with css, xhtml
             Writes an style sheet instead of embedding it in the page
             saves it as pystyle.css in the same directory.
             html markup will silently ignore this flag.
     -H, --header
         Opional-> add a page header to the top of the output
         -H
             Builtin header (name,date,hrule)
         --header
             You must specify a filename.
             The header file must be valid html
             and must handle its own font colors.
             ex. --header c:/tmp/header.txt
     -F, --footer
         Opional-> add a page footer to the bottom of the output
         -F 
             Builtin footer (hrule,name,date)
         --footer
             You must specify a filename.
             The footer file must be valid html
             and must handle its own font colors.
             ex. --footer c:/tmp/footer.txt  
     -l, --linenumbers
         Optional-> default is no linenumbers
             Adds line numbers to the start of each line in the code.
    --convertpage
         Given a webpage that has code embedded in tags it will
             convert embedded code to colorized html. 
             (see pageconvert for details)
 -----------------------------------------------------------------------------
  Option usage:
   # Test and show pages
      python PySourceColor.py -t -s
   # Test and only show profile results
      python PySourceColor.py -t -p
   # Colorize all .py,.pyw files in cwdir you can also use: (.,cwd)
      python PySourceColor.py -i .
   # Using long options w/ =
      python PySourceColor.py --in=c:/myDir/my.py --color=lite --show
   # Using short options w/out =
      python PySourceColor.py -i c:/myDir/  -c idle -m css -e
   # Using any mix
      python PySourceColor.py --in . -o=c:/myDir --show
   # Place a custom header on your files
      python PySourceColor.py -i . -o c:/tmp -m xhtml --header c:/header.txt
 -----------------------------------------------------------------------------
  Stdio usage:
   # Stdio using no options
      python PySourceColor.py < c:/MyFile.py > c:/tmp/MyFile.html
   # Using stdin alone automatically uses stdout for output: (stdin,-)
      python PySourceColor.py -i- < c:/MyFile.py > c:/tmp/myfile.html
   # Stdout can also be written to directly from a file instead of stdin
      python PySourceColor.py -i c:/MyFile.py -m css -o- > c:/tmp/myfile.html
   # Stdin can be used as input , but output can still be specified
      python PySourceColor.py -i- -o c:/pydoc.py.html -s < c:/Python22/my.py
 _____________________________________________________________________________
 i(t__version__tsystexit(tdoc((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR+7sf	cCsyPtjtjddddddddd	d
ddd
dddg\}}Wntjk
rmtnXd4}d4}d4}d}d4}d4}d}d}	d}
d}d}d}
d4}x|D]\}}|dDkrttjn|dEkr|}n|dFkr4|}|dGkr4tj}q4n|dHkrId}	n|dIkr^d}
n|dJkrsd}n|dKkrd}
n|dLkrd}n|dMkrd}n|dNkrt	|}n|dOkrd}n|dPkrt	|}n|d-krd.}n|dQkr-t	|}n|d0krBd.}n|dRkryt
j|j}Wqt
jtqXqqW|r|rd3d4l}|jd5|	|
fqt|	|
n|dSks|dTkr|dUkrAtjj|r5t|d9|d:|d|d;|d<|d=|qtd>qytjjr_td?n|dVkrttjjd9|d:|d;|d<|d|d=|n=ttjjd@|d|	d:|d;|d<|d|d=|Wqt
jtqXntjj|r|
rDt|dA|d9|d|	d:|d|qtdB|dC|d9|d|	d:|d|
d;|d<|d|d=|
ntd>td4S(Ws)Handle command line args and redirectionsishseqtplHFi:o:c:m:h:f:thelptshowtquietttesttexternaltlinenumberstconvertpagetprofilesinput=soutput=scolor=smarkup=sheader=sfooter=thtmlis-hs--helps-os--outputs--outs-is--inputs--int.tcwds-ss--shows-qs--quiets-ts--tests
--convertpages-ps	--profiles-es
--externals-ms--markups-ls
--linenumberss--headers-HRZs--footers-Fs-cs--coloriNs_test(show=%s, quiet=%s)t-tstdintstdouttcolorstmarkuptheadertfootertformsFile does not exists!sPlease check input!toutfiletouttsourcetoutdir(s-hs--help(s-os--outputs--out(s-is--inputs--in(Rkscwd(s-ss--show(s-qs--quiet(s-ts--test(s
--convertpage(s-ps	--profile(s-es
--external(s-ms--markup(s-ls
--linenumbers(s--header(s--footer(s-cs--color(NRmsstdin(Rmsstdout(NRmsstdin(NRmsstdout(tgetoptR_targvtGetoptErrorR+tNoneR`tostgetcwdtstrtglobalstgettlowert	tracebackt	print_excRitrunt_testtpathtisfileR.t	PathErrorRntisattyt
InputErrorR-treadR0texistsR:R6(toptstargstinputtoutputtcolorschemeRqRrRsRgRcRdReRiRhRttota((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR,s%
										


	icCs*tjd}|jdst|dtd|d|t|dtd|ddd|t|d	td|d|t|d
td|ddd|t|dtd|d|t|dtd|ddd|d
dddddt|dtd|ddd|t|dtd|d|t|dtd|ddd|ddt|dtd|d|t|dtd|ddd|t|dtd|ddd|d
dddddddt|dt	d|d|t|dt	d|ddd|t|dt
d|d|ddt|dt
d|ddddd|t|dtd|d|t|d td|ddd|d!}tj
jd"}t||d#tdddd$d|td%||tj
jd&}t||d#tddd|td%||ntd'S((sTest the parser and most of the functions.

       There are 19 test total(eight colorschemes in three diffrent markups,
       and a str2file test. Most functions are tested by this.
    is.exes/tmp/null.htmlRcRds/tmp/null_css.htmlRqtcsss/tmp/mono.htmls/tmp/mono_css.htmls/tmp/lite.htmls/tmp/lite_css.htmlRrRZRsRgis/tmp/lite_xhtml.htmltxhtmls/tmp/dark.htmls/tmp/dark_css.htmls/tmp/dark2.htmls/tmp/dark2_css.htmls/tmp/dark2_xhtml.htmlRtRfs/tmp/idle.htmls/tmp/idle_css.htmls/tmp/viewcvs.htmls/tmp/viewcvs_css.htmls/tmp/pythonwin.htmls/tmp/pythonwin_css.htmls"""This is a test of decorators and other things"""
# This should be line 421...
@whatever(arg,arg2)
@A @B(arghh) @C
def LlamaSaysNi(arg='Ni!',arg2="RALPH"):
   """This docstring is deeply disturbed by all the llama references"""
   print '%s The Wonder Llama says %s'% (arg2,arg)
# So I was like duh!, and he was like ya know?!,
# and so we were both like huh...wtf!? RTFM!! LOL!!;)
@staticmethod## Double comments are KewL.
def LlamasRLumpy():
   """This docstring is too sexy to be here.
   """
   u"""
=============================
A Mse once bit my sister...
=============================
   """
   ## Relax, this won't hurt a bit, just a simple, painless procedure,
   ## hold still while I get the anesthetizing hammer.
   m = {'three':'1','won':'2','too':'3'}
   o = r'fishy\fishy\fishy/fish\oh/where/is\my/little\..'
   python = uR""" 
 No realli! She was Karving her initials n the mse with the sharpened end  
 of an interspace tthbrush given her by Svenge - her brother-in-law -an Oslo
 dentist and star of many Norwegian mvies: "The Ht Hands of an Oslo         
 Dentist", "Fillings of Passion", "The Huge Mlars of Horst Nordfink"..."""
   RU"""142 MEXICAN WHOOPING LLAMAS"""#<-Can you fit 142 llamas in a red box?
   n = u' HERMSGERVRDENBRTBRDA ' + """ YUTTE """
   t = """SAMALLNIATNUOMNAIRODAUCE"""+"DENIARTYLLAICEPS04"
   ## We apologise for the fault in the
   ## comments. Those responsible have been
   ## sacked.
   y = '14 NORTH CHILEAN GUANACOS \
(CLOSELY RELATED TO THE LLAMA)'
   rules = [0,1,2,3,4,5]
   print ys/tmp/strtest_lines.htmlRpis
  wrote %ss/tmp/strtest_nolines.htmlN(R_RztendswithR4R#R$R%R&R'R)R*R(R}RtabspathR0t
_printinfoR+(RcRdtfitteststrthtmlPath((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRsZ








%
RjcCs;t|d|d|d|d|d|d|j|dS(sConverts a code(string) to colorized HTML. Writes to stdout.

       form='code',or'snip' (for "<pre>yourcode</pre>" only)
       colors=null,mono,lite,dark,dark2,idle,or pythonwin
    RpttitleRqRrRsRgN(R/tformat(tsourcestringRpRRqRrRsRgRt((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR-usc	CsMt|j}t|d|d|d|d|d|d|j|dS(sConverts code(file) to colorized HTML. Writes to stdout.

       form='code',or'snip' (for "<pre>yourcode</pre>" only)
       colors=null,mono,lite,dark,dark2,idle,or pythonwin
    RpRRqRrRsRgN(topenRR/R(	t
sourcepathRRpRqRrRsRgRtR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR.sc	Cs`tj}t|d|d|d|d|d|d|d|j||jd|jS(	sConverts a code(string) to colorized HTML. Returns an HTML string.

       form='code',or'snip' (for "<pre>yourcode</pre>" only)
       colors=null,mono,lite,dark,dark2,idle,or pythonwin
    RpRRvRqRrRsRgi(tStringIOR/RtseekR(	RRpRRqRrRsRgRttstringIO((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR1s
Rc
Cs|jdkrd}ntj}t|d|d|d|d|d|d|d	|}	|	j||jd
|d
kr|	jdd|jfSd
|jfSd
S(sConverts a code string to colorized CSS/HTML. Returns CSS/HTML string
       
       If form != None then this will return (stylesheet_str, code_str)
       colors=null,mono,lite,dark,dark2,idle,or pythonwin
    RRRpRRvRqRrRsRgiRfiN(scsssxhtml(RRR/RRR|t
_sendCSSStyleR(
RRpRRqRrRsRgRtRtparse((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR2s		

RcCs|jdkrLd	t|d|d|d|d|d|d|d|fSt|d|d|d|d|d|d|d|Sd	S(
sD Convert code strings into ([stylesheet or None], colorized string) RjRpRRrRsRqRgRtN(RR|R1R2(RRpRRqRrRsRgRt((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR3scCst|d|ddd|d|d|d|d|
\}}t|d	}
|
j||
j|dkr|	rtjj|}tjj|d
}t|d	}
|
j||
jn|rt	|ndS(s[Converts a code string to a file.

       makes no attempt at correcting bad pathnames
    RpRRZRqRrRsRgRttwtspystyle.cssN(
R3Rt
writelinestcloseR|R}RtdirnametjoinR9(RRuRpRRqRrRsRgRctdosheetRtRRjtftdirtoutcss((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR0s



c	Csotj}t|j}t||d|d|d|d|d|d|j||jd|jS(sConverts code(file) to colorized HTML. Returns an HTML string.

       form='code',or'snip' (for "<pre>yourcode</pre>" only)
       colors=null,mono,lite,dark,dark2,idle,or pythonwin
    RRvRqRrRsRgi(RRRR/RR(	RRpRqRrRsRgRtRR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR5s
c


Cs5d}
tjj|sktjj|r_|
d7}
t|||||||	||||
q1tdnt|}|dkr$|dkrtjj|ddkrtjj	|d}qnx@|D]8}|
d7}
t|||||||	||||
qWt
dt|
|n
t
d|dS(s{Takes a file or dir as input and places the html in the outdir.

       If outdir is none it defaults to the input dir
    iisFile does not exist!RZsCompleted colorizing %s files.sNo files to convert in dir.N(R}RtisdirRR4RR7R|tsplitexttsplitRR(
RwRxRpRcRqRdRrRsRgRttcounttfileListtitem((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR6s$


c	Cs|dkr|d}ntjj|ddkrtjj|sWtj|ntjj|}tjj||d}n>tjj|d}
tjj|
stj|
n|}tjj	|}t
|j}t|||t
|d||||	}|j
|td|||dkr|
dkr|dkr|jdd}tjjtjj|d	}t
|d}|j||jtd
||n|rt|n|S(s$ Converts python source to html files.htmliRZiRs
  wrote %sRfRjspystyle.csss    wrote %sN(R|R}RRRtmakedirstbasenameRRRRRR/RRRRtwriteRR9(t
sourcePathRvRpRcRqRdRtRrRsRgRRt
sourceNameRxRwRtcssSheettcssPathR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR4	s6

$!


s<PY>s</PY>spystyle.csscCsi|jdkrRd}||}	|j|	dkrR|jd|	d}qRn|j|}
|j|}|
rP|
|kr=xt|
D]}|j|}
|j|}||
t||!}t|}t|d|d|d|d	d
\}	}||
 }||t|}dj|||g}qWqPt	d||n|s_d
}	n|	|fS(sBThis is a helper function for pageconvert. Returns css, page.
    Rjs9<link rel="stylesheet" href="%s" type="text/css"/></head>is</head>iRpRgRqRttembedRZsTag mismatch!
Check %s,%s tagsN(RtfindtreplaceRtrangetlentunescapeR3RRR|(t	sourcestrRpRqRgRttagstartttagendt
stylesheettlinkRt	starttagstendtagst_t	datastarttdataendtdatatstarttend((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR;4s.

	tpystylecCs|d
kr!tjj|}nt|dj}td|d|d|d|d|d|d|d	|\}}
|
stjjtjj|d
tjj	|}tjj
|sytjtjj|WqqXnt|d}|j|
|j
|rdtjjtjj|d
d|}t|d}|j||j
n|	rytj|WqtjqXn|S||
fSd
S(sdThis function can colorize Python source

       that is written in a webpage enclosed in tags.
    trRRpRqRgRRRRttmptws%s.cssN(R|R}RRRRR;RRRRRRRt	startfileRR(RRvRpRqRgRRRRRct	returnstrtinfileRtpagetnewpathtytcsspathtx((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR:Rs<



cCsstjj|d}tj|}g|D]*}|jdsO|jdr+|^q+}|gkrk|SdSdS(sReturn a list of .py and .pyw files from a given directory.

       This function can be written as a generator Python 2.3, or a genexp
       in Python 2.4. But 2.2 and 2.1 would be left out....
    s	*.[p][y]*s.pys.pywN(R}RRtglobRR|(RtGLOB_PATTERNtpathlistRt
filterlist((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR7|s
cCsAy)ddl}|jtjj|WntjnXdS(s Helper function to open webpagesiN(t
webbrowsertopen_newR}RRRR(RR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR9s
cCs|s|GHndS(sHelper to print messagesN((tmessageRd((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRscCs:|jdd}|jdd}|jdd}|S(s+escape text for html. similar to cgi.escapet&s&amp;t<s&lt;t>s&gt;(R(ttext((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pytescapescCsL|jdd}|jdd}|jdd}|jdd}|S(	sunsecape escaped texts&quot;t"s&gt;Rs&lt;Rs&amp;R(R(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs
tPySourceColorErrorcBs#eZddZdZeZRS(RZcCs||_tj||dS(N(t_msgt	Exceptiont__init__(tselftmsg((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs	cCs|jS(N(R(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt__repr__s(t__name__t
__module__RRt__str__(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs	RcBseZdZRS(cCstj|d|dS(NsPath error! : %s(RR(RR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs	(RRR(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRsRcBseZdZRS(cCstj|d|dS(NsInput error! : %s(RR(RR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs	(RRR(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRscBseZdZedejdeeddZedZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZddZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+RS(*s)MoinMoin python parser heavily chopped :)RZRjic		CsX|dkrt}n|jj|_tjj||_||_	d|_
d|_d|_d|_
d|_d|_d|_|j|_||_||_||_d|_d|_d|_d|_d|_dj|_dj|_d|_|jjtd|_ t!||_"|_#|dkrKd|_$n	d|_$dS(s&Store the source text & set some flagsRZiit
___line___t___start___N(%R|R8t
expandtabstrstriptrawR}RRRRvtlinetlasttexttargFlagt	classFlagtdefFlagt
decoratorFlagRftupperRqRpRrRstdoArgstdoNamest	doMathOpst
doBracketstdoURLt
LINENUMHOLDERt	LINESTARTtskipRRt
extraspacetabst
dolinenumstlinenumtnumberlinks(	RRRpRRvRqRrRsRg((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs:																		cCsx|dkrd|_nB|dkr9d|_d|_n!|dkrQd|_nd|_ddg|_d}|jr|jd|j}n
d|j}g}|jjd}x|D]}|jd	s|jd
s|jdr|j	|q|j
dkr,|j	|jd||q|j	||qWdj|d|_x6|jj
d|d}|s}Pn|jj	|qZ|jj	t|jd|_tj|j}|jr|jn
|jytj|j|WnVtjk
rS}|d}	|dd}
|jjd|	|j|j|
fnX|jrj|jn
|jdS(s#Parse and send the colorized sourcetsniptcodeiRiRft RZs#$#s#%#s#@#tXHTMLtCSSs
s<h3>ERROR: %s</h3>%s
N(Rscode(RR(taddEndsRftlinesR	RRRt
splitlinest
startswithtappendRqRRRRtposRt_doPageStartt_doSnippetStartttokenizetreadlinet
TokenErrorRvRt
_doPageEndt
_doSnippetEnd(RRtRRtnewlinesRtlRtexRR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRsZ			

		


 	
cCs	|\}}|\}}	||_|j}
|j||}|t||_|tjtjfkrd|_|_	|j
dIkr|jjdn|jjddS||
kr|j
|
|!jr0|j|jkr|j|jkr|jj|j
|
|!q|jj|j
|
d|!q|j
|
|!jd|
}|jj|j
|
|!t|d	|j
td|jd7_|j
dJkr|jjdn|jj|j
|d|!n|tjtjfkr||_dStj|kr|tjkr|d
kr>t}d|_|_	q5|jr|dkrh|j	rhd|_	q|d
krd|_	qn|jr|dKkrt}q5|jr|dLkrt}q5t}|dkr|j	dkrd|_	q5|d$kr5|j	dkr5d|_	q5n|t krt!j"|rt#}|dMkr5|d%kr||jd% j$d'rd|_%|_	q|d&kr||jd& j$d'rd|_&|_	qt'}q5nn|j%s|j&s|jr?|j(r?|j%rd|_%t)}q5|j&r!d|_&t*}q5|jr5d|_t+}q5n|tj,kr|j-}
|
d( d)krst.}nS|
d* d+krt/}n:|
d* d,ks|
d- d.krt0}n|
d d/krt1}n|
d d0krt2}n|
d d1ks|
d( d2krt3}n|
d( d3kr)t4}n|
d* d4krBt5}n|
d* d5ksb|
d- d6krkt6}n[|
d d7krt7}nB|
d d8krt8}n)|
d d9ks|
d( d:krt9}n|jj-d;kr5t'}q5nN|t:krf|d d<krt;}n|d( d=kr8t<}d>|_=|d(}nX|d( d?krdt<}d@|_=|d(}n,|d( dAkrt<}dB|_=|d(}n|j>r5|jdC}|dDkrc|| }||d*}|jd$}|jd}||d}|| }|dDkrG|j?d$d}dE||d|dj@|f}q`dE||||f}qcq5n|t'kr|j	r|jr|jj|dS|jr|jArd|_AdS|jj|dSq5|d
kr5t}d|_|_	q5n9|j	dkr5|t kr5|dFkr5|jr5tB}n||j|jgkrtC}||jkrl|jDs{||jkrd|_Aqn|dGkrdS||_|t;t:fkr|jdHdDkrtE|}qn|t<krntE|}t|d	|j
||dS(Ns3Token handler. Order is important do not rearrange.iRRs</span>s
Nis\s_send%sTextt@t(it:t[t]t)t{t}s*=s**=s-=s+=s|=s%=s>>=s<<=t=s^=s/=t+Rms**t*t/t%t,tclasstdefRkis"""isr"""su"""isur"""Rsr"su"sur"s'''sr'''su'''sur'''t'sr'su'sur'trus##s#$#tSPANs#%#tDIVs#@#tRAWsurl(is%s<a href="%s">%s</a>%sR|RZs<a href=(sXHTMLsCSS(sXHTMLsCSS(R$R%R"R&R'R((s*=s**=s-=s+=s|=s%=s>>=s<<=R)s^=s/=R*Rms**R+R,R-(R/R0(FRRRRttokentNEWLINERtNLRRRqRvRRtisspaceRRRRtgetattrRR
tINDENTtDEDENTtLPARtOPRRRRRR	Rtkeywordt	iskeywordR
RRRRRRRRtSTRINGRRRRRRRRRRRRRRR
RttextFlagRRtlstripRRRR	R(Rttoktypettoktextt.3t.4RtsrowtscolterowtecoltoldpostnewpostslashRturl_postbeforeturlt
splitpointtendpointtafterturlparts((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt__call__2sH		!!																												
	
	
	

$					cCsE|jdkr"|jjdn|jj|jjtddS(NtHTMLs<pre>
s<pre class="py">
(RqRvRRpRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR3scCs#|jj|jjtddS(Ns</pre>
(RvRRpRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR;scCsGy)t|d}|j}|jWntjd}nX|S(NRRZ(RRRRR(Rtfilepatht_filetcontent((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getFileAs

cCst|d|jdS(Ns
_do%sStart(R:Rq(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRKscCs|jdkr|jjddksW|jjddksW|jjddkrq|jj|jdq|jdkr|j|j|_nt|d|jndS(Ns#$#is#%#iRZs_do%sHeader(RrR|RRvRR[R:Rq(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_doPageHeaderNscCs|jdkr|jjddksW|jjddksW|jjddkrq|jj|jdq|jdkr|j|j|_nt|d|jndS(Ns#$#is#@#s#%#iRZs_do%sFooter(RsR|RRvRR[R:Rq(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_doPageFooterYscCst|d|jdS(Ns_do%sEnd(R:Rq(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRdscCs/|j}|jd7_t|jddS(NiiR(R
Rtrjust(Rtnum((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getLineNumberjs	cCs|jj||jtdS(Ni(RpRR(Rtkey((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getTagsoscCs=|jj||jtd}|d dkr9d}n|S(Nit#s#000000(RpRR(RRatcolor((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_getForeColorss 	cCs|jj||jtdS(Ni(RpRR(RRa((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_getBackColorzscCs|jjtdS(Ns#FFFFFF(RpRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_getPageColor~scCs|jj||jtS(N(RpRR(RRa((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt	_getStylescCstj|ttS(N(R<RR(RRa((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getMarkupClassscCsdtttjfS(Ns1<!--This document created by %s ver.%s on: %s-->
(t	__title__R^ttimetctime(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getDocumentCreatedByscCs|jjd|jjd|j|jj|j|jjd|jjd|j|j|jjddS(Ns3<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
s<html><head><title>%s</title>
sH<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
s</head><body bgcolor="%s">
s<pre>(RvRRRmRgR\(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doHTMLStarts		
c	Cs|jj||jtd \}}g}g}d|kr[|jd|jdnd|kr|jd|jdnd|kr|jd	|jd
n|jdj|}dj|}|||fS(NiR\s<b>s</b>R]s<i>s</i>tus<u>s</u>RZ(RpRRRtreverseR(	RRDREttagsRdRRRR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getHTMLStyless &



cCs|j}|tkrd}nd}|j||\}}}|j|jr~|tkrr|j|j}n|j|jd}g}	|	j|jd|jt|\}
}}t	|}
x|D]}|j
}|r|j}d|||f}n|}|
dkr-d\}}ndj|d|d|
||d	|g	}|	j||qWdj|	}n|d
krd||f}d	}nd
\}}|tkr|j
jdj|||||gn|j
j|dS(Ns% style="border: solid 1.5pt #FF0000;"RZRis<a name="%s" href="#%s">%s</a>is<font color=Rs</font>s#000000s<font color="%s"%s>(RZRZ(RZRZ(RRRrRRRRRtpopRR`tstripRRvR(RRDRERtstyletstarttagtendtagRdt	splittexttstoret	lstarttagtlendtagtlcolorRRR_tnumstripRZt
linenumbert	startfonttendfont((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_sendHTMLTextsF		
	cCsb|jdkr)|jjd|jn5|jt}|jjd||jtjfdS(NRZs%s
sM<b><font color="%s"># %s                             <br># %s</font></b><hr>
(RrRvRReRRRkRl(RRd((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_doHTMLHeaders	cCsb|jdkr)|jjd|jn5|jt}|jjd||jtjfdS(NRZs%s
sM<b><font color="%s">                             <hr># %s<br># %s</font></b>
(RsRvRReRRRkRl(RRd((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_doHTMLFooters	cCs.|jjd|j|jjddS(Ns</pre>
s</body></html>
(RvRR](R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_doHTMLEnds
c
CsX|j|\}}}g}d}d}|j}|rd|kr|jd}|d}	|||	!}|j|ddnd|kr|jdn
|jdd|kr|jd	nd
|kr|jdnd|krd
}
n0d|krd}
nd|kr$d}
nd}
d|kr?d}nd|krTd}n~d|krid}nid|kr~d}nTd|krd}n?d|krd}n*d|krd}nd |krd!}nd"}x3d#d$d%d&gD]}||kr|d7}qqW|d"kr:|r:|jd'||
fq|dkrOd!}nd&|kru|jd(||
fnd#|kr|jd)||
fnd$|kr|jd*||
fnd%|kr|jd+||
fqn
|jd|r|jd,|n|jd-||r<|jd.|n|j|d/j|fS(0NRciRZiR\sfont-weight:bold;sfont-weight:normal;R]sfont-style:italic;Rostext-decoration:underline;RtthicktmtmediumtttthintntinsetRtoutsetRtridgetgtgrooveR)tdoubleRktdottedRmtdashedtstsolidiRRt^tvsborder: %s %s;sborder-bottom:%s %s;sborder-left:%s %s;sborder-right:%s %s;sborder-top:%s %s;sborder-color:%s;s	color:%s;sbackground-color:%s;R(RhR|RRRRRiR(
RRaRqt	forecolort	backcolorRutbordertbordercolorRRtsizetseperate_sidestside((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_getCSSStyles


												
cCsg}||j7}|s)|jdn|jd|jx(tD] }|jd|j|qGW|j|jjtd|j|jjtd|js|jdndj	|S(s* create external and internal style sheetss<style type="text/css">
<!--
sbody { background:%s; }
s.%s { %s }
s.py { }
RZs--></style>
(
RfRRgR<RRpRR R"R(RRftstylesRa((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR]s

	cCs|jjd|jjd|j|jj|j|jjd|j|jjd|j|jj|jjtddS(Ns3<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
s<html><head><title>%s</title>
sH<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
s</head>
<body>
s<pre class="py">
(	RvRRRmt_doCSSStyleSheetR\RpRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doCSSStartvs	

cCs6|js"|jj|jn|jjddS(Ns:<link rel="stylesheet" href="pystyle.css" type="text/css">(RfRvRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyRs
		cCstj|tt}||jkrE|tkrE|jjddS|j|jrStjttt}d|}|tkr|j	|j}n|j	|jd}g}|j
|jdxt|D]l}|j}	|j
r|	j}
d|
|
|	f}n|	}dj||dg}|j
||qWdj|}n|j|jr_g}|j	|jd}
|
jd}|jd}|d	kr|| d
||}n|j
|xy|
D]q}|jr|jdd|}nd||f}|jd}|d	kr<|| d
}n|j
|qWdj|}n|tkr|tkr|jdkrd|}d}n:|tkr|jdkrd\}}nd|}d}|jjdj|||gn|jj|dS(Ns<span class="py_line">s<span class="%s">Ris<a name="%s" href="#%s">%s</a>RZs</span>s
is</span></span>s</span><span class="%s">s<span class="%s">%ss</span></span>
R4s<div class="%s">s</div>R5(RZRZ(R<RRRRRvRRRRRRsR`RRtRtrfindR	RRRB(RRDREtmarkupclasst	newmarkupt
lstartspanRxRyRR_R}RZR~tpartstfirstRt	startspantendspan((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_sendCSSTextsf

	

		
	
%cCsb|jdkr)|jjd|jn5tjt}|jjd||jtjfdS(NRZs%s
s)<div class="%s"># %s <br> # %s</div><hr>
(	RrRvRR<RRRRkRl(Rtname((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doCSSHeaders
	cCs\|jdkr)|jjd|jn/|jjdtjt|jtjfdS(NRZs%s
s)<hr><div class="%s"># %s <br> # %s</div>
(	RsRvRR<RRRRkRl(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doCSSFooters	cCs=|jj|jjtd|j|jjddS(Ns</pre>
s</body></html>
(RvRRpRRR](R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt	_doCSSEnds
cCs|jjd|jjd|j|jj|j|jjd|j|jjd|j|jj|jjtddS(Ns<?xml version="1.0"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
s<head><title>%s</title>
sI<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
s</head>
<body>
s<pre class="py">
(	RvRRRmt_doXHTMLStyleSheetR\RpRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt
_doXHTMLStarts		

cCs6|js"|jj|jn|jjddS(Ns<<link rel="stylesheet" href="pystyle.css" type="text/css"/>
(RfRvRR(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR
s
		cCs|j||dS(N(R(RRDRE((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_sendXHTMLTextscCs\|jr#|jjd|jn5tjt}|jjd||jtjfdS(Ns%s
s,<div class="%s"># %s <br/> # %s</div><hr/>
 (	RrRvRR<RRRRkRl(RR((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doXHTMLHeaders		cCsV|jr#|jjd|jn/|jjdtjt|jtjfdS(Ns%s
s+<hr/><div class="%s"># %s <br/> # %s</div>
(	RsRvRR<RRRRkRl(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doXHTMLFooter$s		cCs|jdS(N(R(R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt_doXHTMLEnd,s(,RRt__doc__R|R_RoRRRVRRR[RR\R]RR`RbReRfRgRhRiRmRnRrRRRRRRRRRRRRRRRRRR(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyR/sR#H				
													
		<	
	
			R		
	Q			
		
		
	t__main__(]Rt__all__RjR^t__date__t
__author__t__credits__R}R_RkRRyR?R6RRt	cStringIORRRRR>RRt	NT_OFFSETRR
RRR
RRRRRRRRRRRRRRRRR	RRR RRR"RR<R!R#R$R&R'R%R)R(R*R8R+R,RR|R-R.R1R2R3R0R5R6R4RR;R:R7R9RRRRRRRtobjectR/R(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/util/PySourceColor.pyt<module>s<							






































	l	t^	
		
						)(					
	r