Kc=@sQdZddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=g=Zd>Zd?Zd@ZdAZdBZdCdDkZdCdDkZdCdDk Z dCdDk Z dCdDk Z dCdDk Z dCdDk Z dCdDkZdCdDkZydCdDkZWndCdDkZnXe iZe iZeiZe iZe iZe idEZe idFZe idGZe idHZe idIZe idJZe idKZe idLZ e idMZ!e idNZ"e idOZ#e idPZ$e idQZ%e idRZ&e idSZ'e idTZ(e idUZ)e idVZ*e idWZ+e idXZ,e idYZ-e idZZ.e id[Z/e id\Z0e id]Z1e id^Z2e id_Z3e id`Z4e idaZ5hdbe6dce,6dde+6dee6dfe6dge6dhe6die6dje6dke6dle6dme6dne6doe6dpe 6dqe!6dre"6dse#6dte$6due%6dve&6dwe'6dxe(6dye)6dze-6d{e.6d|e/6d}e06Z6hde6de,6de+6de6de6de6de6d e6d e6d e6d e6de6de6de6de 6de!6de"6de#6de$6de%6de&6de'6de(6de)6de-6d e.6de/6de06de*6Z7hd~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*6Z8hddd~fe6ddd~fe,6ddd~fe+6ddd~fe6d~dd~fe6ddd~fe6ddd~fe6ddd~fe.6ddd~fe-6ddd~fe6ddd~fe6ddd~fe6ddd~fe6ddd~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&6ddd~fe'6ddd~fe(6ddd~fe)6d~dd~fe06ddd~fe/6de*6Z9hddd~fe6ddd~fe,6ddd~fe+6ddd~fe6d~dd~fe6d~dd~fe6ddd~fe6ddd~fe.6ddd~fe-6d~dd~fe6ddd~fe6ddd~fe6ddd~fe6ddd~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~fe06dddfe/6de*6Z:hd~dd~fe6ddd~fe,6ddd~fe+6ddd~fe6d~dd~fe6ddd~fe6ddd~fe6ddd~fe.6ddd~fe-6dddfe6dddfe6ddd~fe6ddd~fe6ddd~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~fe06dddfe/6de*6Z;hddd~fe6ddd~fe,6ddd~fe+6ddd~fe6d~dd~fe6ddd~fe6ddd~fe6ddd~fe.6ddd~fe-6d~dd~fe6d~dd~fe6ddd~fe6ddd~fe6ddd~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*6Z<hddd~fe6d~dd~fe,6d~dd~fe+6d~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*6Z=hddd~fe6ddd~fe,6ddd~fe+6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe.6d~dd~fe-6d~dd~fe6d~dd~fe6ddd~fe6ddd~fe6ddd~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*6Z>hddd~fe6d~dd~fe,6d~dd~fe+6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe6d~dd~fe.6d~dd~fe-6ddd~fe6ddd~fe6d~dd~fe6ddd~fe6ddd~fe6ddd~fe6ddd~fe6ddd~fe 6ddd~fe!6ddd~fe"6ddd~fe#6ddd~fe$6ddd~fe%6ddd~fe&6ddd~fe'6ddd~fe(6ddd~fe)6d~dd~fe06ddd~fe/6de*6Z?e<Z@dZAdZBdddZCeDd~deDeDdeDdZEd~eDdeDeDdeDdZFeDd~deDeDdeDdZGeDd~deDeDdeDdZHeDd~deDeDdeDdZIeDd~deDeDdddEeDd ZJeDdeDeDdeDdZKeDeDdddeDeDdeDd ZLeDeDdddeDeDeDddEd ZMe<dddEdiNdiNddZOeDe<dddEdiNdiNddEdd ZPdZQdZRdZSdZTdZUdeVfdYZWdeWfdYZXdeWfdYZYd0eZfdYZ[e\djo eBndDS(s) PySourceColor: color Python source code t ERRORTOKENtDECORATOR_NAMEt DECORATORtARGSt EXTRASPACEtNAMEtNUMBERtOPERATORtCOMMENTt MATH_OPERATORt DOUBLECOMMENTt CLASS_NAMEtDEF_NAMEtKEYWORDtBRACKETSt SINGLEQUOTEt SINGLEQUOTE_Rt SINGLEQUOTE_Ut DOUBLEQUOTEt DOUBLEQUOTE_Rt DOUBLEQUOTE_UtTRIPLESINGLEQUOTEtTEXTtTRIPLESINGLEQUOTE_RtTRIPLESINGLEQUOTE_UtTRIPLEDOUBLEQUOTEtTRIPLEDOUBLEQUOTE_RtTRIPLEDOUBLEQUOTE_UtPAGEBACKGROUNDt LINENUMBERt CODESTARTtCODEENDtPYt TOKEN_NAMEStCSSHOOKtnulltmonotlitetdarktdark2t pythonwintidletviewcvstUsagetclit str2stdoutt path2stdouttParsertstr2filetstr2htmltstr2csst str2markupt path2filet path2htmltconverttwalkdirt defaultColorstshowpaget pageconvertt 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 i i i 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}|tGHtiddS(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((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR+7sf cCsyPtitiddddddddd d d d d dddg\}}Wntij otnXd4}d4}d4}d}d4}d4}d}d} d} d} d} d} d4}x|D]\}}|dDjottin|dEjo |}n|dFjo'|}|dGjoti}q>n|dHjo d} n|dIjo d} n|dJjo d} n|dKjo d} n|dLjo d} n|dMjo d}n|dNjot |}n|dOjo d}n|dPjot |}n|d-jo d.}n|dQjot |}n|d0jo d.}n|dRjo;yt i |i }Wqt itqXqqW| o?| o'd3d4k} | id5| | fqt| | n|dSjp |dTjo$|dUjoRtii|o2t|d9|d:|d|d;|d<|d=|q0td>qytiio td?n|dVjo;ttiid9|d:|d;|d<|d|d=|n>ttiid@|d| d:|d;|d<|d|d=|Wqt itqXntii|oz| o,t|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:thelptshowtquietttesttexternalt linenumberst convertpagetprofilesinput=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_targvt GetoptErrorR+tNoneR`tostgetcwdtstrtglobalstgettlowert tracebackt print_excRitrunt_testtpathtisfileR.t PathErrorRntisattyt InputErrorR-treadR0texistsR:R6(toptstargstinputtoutputt colorschemeRqRrRsRgRcRdReRiRhRttota((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR,s %                                         icCs,tid}|idpt|dtd|d|t|dtd|ddd|t|d td|d|t|d td|ddd|t|d td|d|t|d td|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|dt d|d|t|d t d|ddd|d!}t i id"}t||d#tdddd$d|td%||t i id&}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((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRsZ         % RjcCs;t|d|d|d|d|d|d|i|dS(sConverts a code(string) to colorized HTML. Writes to stdout. form='code',or'snip' (for "
yourcode
" only) colors=null,mono,lite,dark,dark2,idle,or pythonwin RpttitleRqRrRsRgN(R/tformat(t sourcestringRpRRqRrRsRgRt((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR-us c CsMt|i}t|d|d|d|d|d|d|i|dS(sConverts code(file) to colorized HTML. Writes to stdout. form='code',or'snip' (for "
yourcode
" only) colors=null,mono,lite,dark,dark2,idle,or pythonwin RpRRqRrRsRgN(topenRR/R( t sourcepathRRpRqRrRsRgRtR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR.sc Cs`ti}t|d|d|d|d|d|d|d|i||id|iS( sConverts a code(string) to colorized HTML. Returns an HTML string. form='code',or'snip' (for "
yourcode
" only) colors=null,mono,lite,dark,dark2,idle,or pythonwin RpRRvRqRrRsRgi(tStringIOR/RtseekR( RRpRRqRrRsRgRttstringIO((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR1s   Rc Cs|idjo d}nti}t|d|d|d|d|d|d|d |} | i||id |d jo| id d |ifSd |ifSd 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((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR2s        RcCs|idjo;d 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((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR3sc Cst|d|ddd|d|d|d|d| \} } t|d } | i| | i| d joX| oQtii|}tii|d }t|d } | i| | in|ot |nd S( s[Converts a code string to a file. makes no attempt at correcting bad pathnames RpRRZRqRrRsRgRttwts pystyle.cssN( R3Rt writelinestcloseR|R}RtdirnametjoinR9(RRuRpRRqRrRsRgRctdosheetRtRRjtftdirtoutcss((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR0s   c Csoti}t|i}t||d|d|d|d|d|d|i||id|iS(sConverts code(file) to colorized HTML. Returns an HTML string. form='code',or'snip' (for "
yourcode
" only) colors=null,mono,lite,dark,dark2,idle,or pythonwin RRvRqRrRsRgi(RRRR/RR( RRpRqRrRsRgRtRR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR5s  c Cs?d} tii|pVtii|o6| d7} t||||||| |||| q;tdnt|} | djo|djo;tii|ddjotii |d}qnx@| D]8} | d7} t| |||||| |||| qWt dt | |nt 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((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR6s&      c  Cs|d jo|d} ntii|ddjoStii|pti|ntii|} tii|| d} nAtii|d} tii| pti| n|} tii | } t |i }t |||t | d|||| }|i |td| ||djo| djo{|djon|idd}tiitii| d }t |d}|i||itd ||n|ot| n| S( s$ Converts python source to html files.htmliRZiRs wrote %sRfRjs pystyle.csss wrote %sN(R|R}RRRtmakedirstbasenameRRRRRR/RRRRtwriteRR9(t sourcePathRvRpRcRqRdRtRrRsRgRRt sourceNameRxRwRtcssSheettcssPathR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR4 s6  '!  sss pystyle.cssc Css|idjoCd}||} |i| djo|id| d}qVn|i|} |i|} | o| | joxt| D]} |i|} |i|}|| t||!}t|}t|d|d|d|d d \} }|| }||t|}d i|||g}qWqXt d ||n|p d } n| |fS(sBThis is a helper function for pageconvert. Returns css, page. Rjs9isiRpRgRqRttembedRZsTag mismatch! Check %s,%s tagsN( RtfindtreplaceRtrangetlentunescapeR3RRR|(t sourcestrRpRqRgRttagstartttagendt stylesheettlinkRt starttagstendtagst_t datastarttdataendtdatatstarttend((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR;4s0       tpystylec Cs|d jotii|}nt|di} td| d|d|d|d|d|d|d |\} } | p"tiitii|d tii |}tii |p+yti tii|WqqXnt|d }|i | |i | oRtiitii|d d |}t|d }|i | |i n| o)yti|WqtiqXn|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((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR:Rs<    cCstii|d}ti|}g}|D]1}|idp|ido ||q/q/~}|gjo|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|(Rt GLOB_PATTERNtpathlistt_[1]Rt filterlist((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR7|s$ cCsAy)ddk}|itii|WntinXdS(s Helper function to open webpagesiN(t webbrowsertopen_newR}RRRR(RR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR9s  cCs|p |GHndS(sHelper to print messagesN((tmessageRd((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRscCs:|idd}|idd}|idd}|S(s+escape text for html. similar to cgi.escapet&s&ts>(R(ttext((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pytescapescCsL|idd}|idd}|idd}|idd}|S( sunsecape escaped texts"t"s>Rs<Rs&R(R(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs tPySourceColorErrorcBs#eZddZdZeZRS(RZcCs||_ti||dS(N(t_msgt Exceptiont__init__(tselftmsg((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs cCs|iS(N(R(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt__repr__s(t__name__t __module__RRt__str__(((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs  RcBseZdZRS(cCsti|d|dS(NsPath error! : %s(RR(RR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs (RRR(((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRsRcBseZdZRS(cCsti|d|dS(NsInput error! : %s(RR(RR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs (RRR(((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRscBseZdZedeideeddZedZdZdZ dZ d Z d Z d Z d Zd 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 Cs\|djo t}n|ii|_tii||_||_ d|_ d|_ d|_ d|_ d|_d|_d|_|i|_||_||_||_d|_d|_d|_d|_d|_di|_di|_d|_|iitd|_ t!||_"|_#|djo d|_$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 dolinenumstlinenumt numberlinks( RRRpRRvRqRrRsRg((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs:                     c Cs|djo d|_nG|djod|_d|_n$|djo d|_nd|_ddg|_d}|io|id|i}nd|i}g}|iid}x|D]}|id p |id p|id o|i |q|i djo |i |i d||q|i ||qWdi |d|_x8|ii d|d}|pPn|ii |qh|ii t|id|_ti|i}|io|in |iyti|i|WnXtij oI}|d} |dd} |iid| |i|i| fnX|io|in |idS(s#Parse and send the colorized sourcetsniptcodeiRiRft RZs#$#s#%#s#@#tXHTMLtCSSs s

ERROR: %s

%s N(R scode(RR(taddEndsRftlinesR RRRt splitlinest startswithtappendRqRRRRtposRt _doPageStartt_doSnippetStartttokenizetreadlinet TokenErrorRvRt _doPageEndt _doSnippetEnd( RRtRRtnewlinesRtlRtexRR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs\                ! cCs |\}}|\}} ||_|i} |i||} | t||_|titifjoId|_|_ |i dIjo|i i dn|i i ddS| | jo&|i | | !iof|i|ijo1|i|ijo|i i |i | | !q|i i |i | d| !q|i | | !id| } |i i |i | | !t|d |i td|id7_|i dJjo|i i dn|i i |i | d| !n|titifjo| |_dSti|jo#|tijo|d jot}d|_|_ q|ioB|d jo|i o d |_ q|d jo d|_ qn|io|dKjo t}q|io|dLjo t}qt}|djo|i d jo d|_ q|d$jo|i djo d |_ qnv|t jot!i"|ot#}|dMjo|d%jo2||id% i$d' od|_%|_ q|d&jo2||id& i$d' od|_&|_ qt'}qn|i%p|i&p |ioe|i(o[|i%od|_%t)}q|i&od|_&t*}q|iod|_t+}qn7|ti,jo|i-} | d( d)jo t.}nn| d* d+jo t/}nS| d* d,jp| d- d.jo t0}n'| d d/jo t1}n | d d0jo t2}n| d d1jp| d( d2jo t3}n| d( d3jo t4}n| d* d4jo t5}n| d* d5jp| d- d6jo t6}nc| d d7jo t7}nH| d d8jo t8}n-| d d9jp| d( d:jo t9}n|ii-d;jo t'}qno|t:jo|d d<jo t;}n|d( d=jot<}d>|_=|d(}n]|d( d?jot<}d@|_=|d(}n/|d( dAjot<}dB|_=|d(}n|i>o|idC}|dDjo|| }||d*}|id$}|id}||d}|| }|dDjo:|i?d$d}dE||d|di@|f}qdE||||f}qqn|t'jo|i o"|io|i i |dS|io0|iAod|_AdS|i i |dSq|d jot}d|_|_ qn?|i d jo.|t jo!|dFjo|io tB}n||i|igjoBtC}||ijo |iD p||ijo d|_Aq n|dGjodS||_|t;t:fjo*|idHdDjotE|}q n|t<jon tE|}t|d |i ||dS(Ns3Token handler. Order is important do not rearrange.iRRss 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%s%sR|RZs>=s<<=R*s^=s/=R+Rms**R,R-R.(R0R1(FRRRRttokentNEWLINERtNLRRRqRvRRtisspaceRRRRtgetattrRR tINDENTtDEDENTtLPARtOPRRRRRR Rtkeywordt iskeywordR RRRRRR R RtSTRINGRRRRRRRRRRRRRRR RttextFlagRRtlstripRRRR R(Rttoktypettoktextt.3t.4RtsrowtscolterowtecoltoldpostnewpostslashRturl_postbeforeturlt splitpointtendpointtafterturlparts((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt__call__2sH   ""                                              %"             cCsG|idjo|iidn |ii|iitddS(NtHTMLs
s
(RqRvRRpRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR3scCs#|ii|iitddS(Ns
(RvRRpRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR;scCsGy)t|d}|i}|iWntid}nX|S(NRRZ(RRRRR(Rtfilepatht_filetcontent((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_getFileAs   cCst|d|idS(Ns _do%sStart(R;Rq(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRKscCs|idjo|iiddjp2|iiddjp|iiddjo|ii|idq|idjo|i|i|_nt|d|indS(Ns#$#is#%#iRZs _do%sHeader(RrR|RRvRR\R;Rq(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doPageHeaderNscCs|idjo|iiddjp2|iiddjp|iiddjo|ii|idq|idjo|i|i|_nt|d|indS(Ns#$#is#@#s#%#iRZs _do%sFooter(RsR|RRvRR\R;Rq(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doPageFooterYscCst|d|idS(Ns_do%sEnd(R;Rq(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRdscCs/|i}|id7_t|iddS(NiiR(R Rtrjust(Rtnum((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_getLineNumberjs cCs|ii||itdS(Ni(RpRR(Rtkey((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_getTagsoscCs?|ii||itd}|d djo d}n|S(Nit#s#000000(RpRR(RRbtcolor((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _getForeColorss  cCs|ii||itdS(Ni(RpRR(RRb((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _getBackColorzscCs|iitdS(Ns#FFFFFF(RpRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _getPageColor~scCs|ii||itS(N(RpRR(RRb((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _getStylescCsti|ttS(N(R<RR(RRb((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_getMarkupClassscCsdtttifS(Ns1 (t __title__R^ttimetctime(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_getDocumentCreatedByscCs|iid|iid|i|ii|i|iid|iid|i|i|iiddS(Ns3 s%s sH s s
(RvRRRnRhR](R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_doHTMLStarts		
c	Cs|ii||itd \}}g}g}d|jo|id|idnd|jo|id|idnd|jo|id	|id
n|idi|}di|}|||fS(NiR\ssR]sstussRZ(RpRRRtreverseR(	RRERFttagsReRRRR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_getHTMLStyless &






cCs|i}|tjo
d}nd}|i||\}}}|i|io4|tjo|i|i}n|i|id}g}	|	i|id|it|\}
}}t	|}
x|D]}|i
}|o#|i}d|||f}n|}|
djod\}}ndi|d|d|
||d	|g	}|	i||qWdi|	}n|d
jod||f}d	}n
d
\}}|tjo,|i
idi|||||gn|i
i|dS(Ns% style="border: solid 1.5pt #FF0000;"RZRis%siss#000000s(RZRZ(RZRZ(RRRsRRRRRtpopRRatstripRRvR(RRERFRtstyletstarttagtendtagRet	splittexttstoret	lstarttagtlendtagtlcolorRRR`tnumstripR[t
linenumbert	startfonttendfont((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt
_sendHTMLTextsH	






cCsd|idjo|iid|in6|it}|iid||itifdS(NRZs%s
sM# %s                             
# %s

(RrRvRRfRRRlRm(RRe((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doHTMLHeaders  cCsd|idjo|iid|in6|it}|iid||itifdS(NRZs%s sM
# %s
# %s
(RsRvRRfRRRlRm(RRe((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doHTMLFooters  cCs.|iid|i|iiddS(Ns
s (RvRR^(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doHTMLEnds c Cs|i|\}}}g}d}d}|i}|od|jo=|id}|d} ||| !}|i|ddnd|jo|idn|idd|jo|id nd |jo|id nd |jo d } n5d|jo d} nd|jo d} nd} d|jo d}nd|jo d}nd|jo d}ntd|jo d}n]d|jo d}nFd|jo d}n/d|jo d}nd |jo d!}nd"} x5d#d$d%d&gD]!} | |jo| d7} q q W| d"jo"|o|id'|| fq&|djo d!}nd&|jo|id(|| fnd#|jo|id)|| fnd$|jo|id*|| fnd%|jo|id+|| fq&n|id|o|id,|n|id-||o|id.|n|i|d/i|fS(0NRdiRZiR\sfont-weight:bold;sfont-weight:normal;R]sfont-style:italic;Rpstext-decoration:underline;R tthicktmtmediumtttthintntinsetRtoutsetRtridgetgtgrooveR*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(RiR|RRRRRjR( RRbRrt forecolort backcolorRvtbordert bordercolorRRtsizetseperate_sidestside((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _getCSSStyle s                                      cCsg}||i7}|p|idn|id|ix(tD] }|id|i|qIW|i|iitd|i|iitd|ip|idndi |S(s* create external and internal style sheetss ( RfRRhR<RRpRR R"R(RRftstylesRb((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR]s  cCs|iid|iid|i|ii|i|iid|i|iid|i|ii|iitddS(Ns3 s%s sH s s
(	RvRRRnt_doCSSStyleSheetR]RpRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_doCSSStartvs	

cCs8|ip|ii|in|iiddS(Ns:(RfRvRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyRs

	cCs%ti|tt}||ijo"|tjo|iiddS|i|iotittt}d|}|tjo|i	|i}n|i	|id}g}|i
|idxv|D]n}|i}	|i
o#|	i}
d|
|
|	f}n|	}di||dg}|i
||qWdi|}n|i|iog}|i	|id}
|
id}|id}|d	jo|| d
||}n|i
|x}|
D]u}|io|idd|}nd||f}|id}|d	jo|| d
}n|i
|qWdi|}n|tjo|tjo$|idjod|}d}n>|tjo |idjod\}}nd|}d}|iidi|||gn|ii|dS(NssRis%sRZss
isss%ss
R5s
s
R6(RZRZ(R<RRRRRvRRRRRRtRaR RuRtrfindR RRRC(RRERFt markupclasst newmarkupt lstartspanRyRzRR`R~R[RtpartstfirstRt startspantendspan((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _sendCSSTextsj              &cCsd|idjo|iid|in6tit}|iid||itifdS(NRZs%s s)
# %s
# %s

( RrRvRR<RRRRlRm(Rtname((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doCSSHeaders  cCs^|idjo|iid|in0|iidtit|itifdS(NRZs%s s)
# %s
# %s
( RsRvRR<RRRRlRm(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doCSSFooters cCs=|ii|iitd|i|iiddS(Ns
s (RvRRpRRR^(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doCSSEnds cCs|iid|iid|i|ii|i|iid|i|iid|i|ii|iitddS(Ns s%s sI s s
(	RvRRRnt_doXHTMLStyleSheetR]RpRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt
_doXHTMLStarts		

cCs8|ip|ii|in|iiddS(Ns<
(RfRvRR(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR
s

	cCs|i||dS(N(R(RRERF((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_sendXHTMLTextscCs^|io|iid|in6tit}|iid||itifdS(Ns%s
s,
# %s
# %s

( RrRvRR<RRRRlRm(RR((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_doXHTMLHeaders   cCsX|io|iid|in0|iidtit|itifdS(Ns%s s+
# %s
# %s
( RsRvRR<RRRRlRm(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt_doXHTMLFooter$s  cCs|idS(N(R(R((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyt _doXHTMLEnd,s(,RRt__doc__R|R_RoRRRWRRR\RR]R^RRaRcRfRgRhRiRjRnRoRsRRRRRRRRRRRRRRRRRR(((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyR/sR # H               < R   Q     t__main__(]Rt__all__RkR^t__date__t __author__t __credits__R}R_RlRRyR@R7RRt cStringIORRRRR?RRt NT_OFFSETRR R R R RRRRRRRRRRRRRRRRR RRR RRR"RR<R!R#R$R&R'R%R)R(R*R8R+R,RR|R-R.R1R2R3R0R5R6R4RR;R:R7R9RRRRRRRtobjectR/R(((s</usr/lib/python2.6/site-packages/paste/util/PySourceColor.pyts<                                                          l t^            ) (      r