Ϫf*dZddlZddlZddlmZddlmZddlmZGddZ Gd d Z Gd d e Z e fd Z dZ edk(re yy)z" HTML rendering of Python source. N)escape)List)reflectc2eZdZdZd\ZZdxZZdZdZ dZ y) TokenPrinterzU Format a stream of tokens and intermediate whitespace, for pretty-printing. )rrrutf-8c||_y)zJ @param writer: A file-like object, opened in bytes mode. N)writer)selfr s 9/usr/lib/python3/dist-packages/twisted/python/htmlizer.py__init__zTokenPrinter.__init__s  cbttdr|tjk(r||_yt |t s|j |j}|\}}|\}} |j|kr0|jd||jz z|dc|_|_ |jd||jz z|jr d}d|_ np|tjk(r*tj|rd}nE|jrd}n6d }n3tjj!|}|J|j#}|j||| |_ |xj|j%dz c_|j|k7rd|_ |d v|_ |d k(rd|_ yy) NENCODING r identifierrkeyword parametervariable)sdefsclass:)hasattrtokenizerencoding isinstancebytesencode currentLiner currentCollastIdentifier parametersNAMEr iskeywordtok_namegetlowercount) r typetoken sCoordinates eCoordinateslinesrowscolerowecols r printtokenzTokenPrinter.printtoken s} 8Z (TX5F5F-F!DM %'LL/E# t# t   d " KK(8(8!89 :04a -D do DD4??234   DDO X]] "  ' ??&D%D$$((.D# ##::s)rrdecoderrr:r )r r*r)s r writezHTMLWriter.writeUs eU #LL)Eu  W% Lddkk1 KK  KK'++g&'  r)N) r3r4r5r6r:rstr__annotations__rr@r7rr r9r9Gs! FDI rr9ceZdZdZgdZy)SmallerHTMLWriterzi HTMLWriter that doesn't generate spans for some junk. Results in much smaller HTML output. ) endmarkerindentdedentopnewlinenlN)r3r4r5r6r:r7rr rDrDfs FFrrDcL|jdt||jjj} tj|jD]}|\}}}}} ||||||  |jdy#tj $rY'wxYw)Ns
s
)r@rr2rreadline TokenError) inpoutr printerr* tokenTypestringstartendr-s r filterrUpsIIh6#)),223>>G &&s||4 9E49 1YsD Ivuc4 8 9 IIk      s8B B#"B#cddl}t|jd|j}t|jdd5}t ||dddy#1swYyxYw)Nrbufferrrb)sysgetattrstdoutopenargvrU)rYr[fs r mainr_|sN SZZ3:: 6F chhqk4 Aq&s AA__main__)r6rrhtmlrtypingrrrr9rDrUr_r3r7rr rdsa 3 3 l>F F'  zFr