ó ìDwJc @swdZdZdZdZdZdefd„ƒYZdefd„ƒYZd efd „ƒYZd efd „ƒYZ d „Z d„Z d„Z d„Z edkrseddƒZeƒZejjedddgdeƒƒejjedddgƒƒejjd[ƒejeeƒdƒeeƒGHdd GHed\d#d$ggd%d&d'd]d*d^ƒZejeeƒdƒeGHdd GHejjd-d.gƒed/d0d1ƒejd2d2d?gd@dAdBdCggZej ed'dDdEdFdGgd*d+dHdIdIgdJdKd6dLdMgdNdOd+dPdQgƒZejedƒeGHdd GHdR„ZedSedTƒd'd_ƒZejeeƒdƒdd GHe dWdXdYgƒZejeeƒdƒee_ejeeƒdƒdTe_ejeeƒdƒejƒndZS(`s+ HTML.py - v0.04 2009-07-28 Philippe Lagadec This module provides a few classes to easily generate HTML code such as tables and lists. Project website: http://www.decalage.info/python/html License: CeCILL (open-source GPL compatible), see source code for details. http://www.cecill.info s0.04s 2009-07-28sPhilippe Lagadecs5border: 1px solid #000000; border-collapse: collapse;t TableCellc Bs>eZdZddedddddddd„ Zd„ZRS(s a TableCell object is used to create a cell in a HTML table. (TD or TH) Attributes: - text: text in the cell (may contain HTML tags). May be any object which can be converted to a string using str(). - header: bool, false for a normal data cell (TD), true for a header cell (TH) - bgcolor: str, background color - width: str, width - align: str, horizontal alignement (left, center, right, justify or char) - char: str, alignment character, decimal point if not specified - charoff: str, see HTML specs - valign: str, vertical alignment (top|middle|bottom|baseline) - style: str, CSS style - attribs: dict, additional attributes for the TD/TH tag Reference: http://www.w3.org/TR/html4/struct/tables.html#h-11.2.6 tc Csv||_||_||_||_||_||_||_||_| |_| |_ | dkrri|_ ndS(sTableCell constructorN( ttexttbgcolortheadertwidthtaligntchartcharofftvaligntstyletattribstNone( tselfRRRRRRRR R R ((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyt__init__ws           cCsCd}|jr"|j|jd|j|jd%s s %s N( RR RRRRR R RtstrR(R t attribs_strtattrR((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyt__str__ˆs.         N(t__name__t __module__t__doc__R tFalseRR(((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyRcs   tTableRowc Bs;eZdZddeddddddd„ Zd„ZRS(s a TableRow object is used to create a row in a HTML table. (TR tag) Attributes: - cells: list, tuple or any iterable, containing one string or TableCell object for each cell - header: bool, true for a header row (TH), false for a normal data row (TD) - bgcolor: str, background color - col_align, col_valign, col_char, col_charoff, col_styles: see Table class - attribs: dict, additional attributes for the TR tag Reference: http://www.w3.org/TR/html4/struct/tables.html#h-11.2.5 c Csm||_||_||_||_||_||_||_| |_||_|dkrii|_ndS(sTableCell constructorN( RtcellsRt col_alignt col_valigntcol_chart col_charofft col_stylesR R ( R RRRR RRRRR((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR¯s          c Csd}|jr"|j|jd Rs N(RR Rtindext isinstanceRRRRR RRRRRR RR R(R RRtresulttcelltcol((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR¿s.   N(RRRR RRR(((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR s    tTablecBsJeZdZddddddddddddddd„Zd„ZRS(së a Table object is used to create a HTML table. (TABLE tag) Attributes: - rows: list, tuple or any iterable, containing one iterable or TableRow object for each row - header_row: list, tuple or any iterable, containing the header row (optional) - border: str or int, border width - style: str, table style in CSS syntax (thin black borders by default) - width: str, width of the table on the page - attribs: dict, additional attributes for the TABLE tag - col_width: list or tuple defining width for each column - col_align: list or tuple defining horizontal alignment for each column - col_char: list or tuple defining alignment character for each column - col_charoff: list or tuple defining charoff attribute for each column - col_valign: list or tuple defining vertical alignment for each column - col_styles: list or tuple of HTML styles for each column Reference: http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1 t1icCs¾||_||_|dkr*t|_n||_||_||_||_||_|sig|_n||_ |s„i|_ n| |_ | |_ | |_ | |_ | |_||_dS(sTableCell constructorN(tborderR R tTABLE_STYLE_THINBORDERRt cellspacingt cellpaddingt header_rowtrowsR t col_widthRRRRR(R R*R%R RR'R(R R)R+RRRRR((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyRòs(                c CsFd}|jr"|j|jd|j|jd s Rs(R%R R RR'R(R+R)RRRtTrueR*RRRRR(R RRR Rtrow((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR sJ        " N(RRRR RR(((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR#Üs    tListcBs,eZdZdeddd„Zd„ZRS(sƒ a List object is used to create an ordered or unordered list in HTML. (UL/OL tag) Attributes: - lines: list, tuple or any iterable, containing one string for each line - ordered: bool, choice between an ordered (OL) or unordered list (UL) - attribs: dict, additional attributes for the OL/UL tag Reference: http://www.w3.org/TR/html4/struct/lists.html cCsL|r||_n g|_||_||_|r?||_n i|_dS(sList constructorN(tlinestorderedtstartR (R R/R0R1R ((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR\s     cCs³d}|jr"|j|jd s
  • %s s (R1R R0R/R(R RRttagR tline((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyRis  N(RRRR RRR(((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyR.Os  cCsd||fS(Ns%s((Rturl((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pytLink™scCsd||fS(Ns%s((RR6((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pytlinkœscOstt||ŽƒS(sIreturn HTML code for a table as a string. See Table class for parameters.(RR#(targstkwargs((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyttableŸscOstt||ŽƒS(sGreturn HTML code for a list as a string. See List class for parameters.(RR.(R9R:((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pytlist£st__main__s test.htmltwtAtBtCRtDtEtFtitjtks

    t-iOR$t2t3t4Rs100%R)tcol1tcol2R+Rs75%t5t6tnewRtredit7t8R tcenterRtSmithtJohnig@t CarpentertJacki/itJohnsontPauli>gš™™™™%@s Last names First nametAgetScores20%s10%RtlefttrightRRsfont-size: largesfont-size: smallsbackground-color:yellowccs1x*td|dƒD]}|||fVqWdS(sI Generator to create table rows for integers from 1 to n iN(trange(tntx((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pytgen_table_squaresØsR*i Ras square(x)taaatbbbtcccN(RERFRG(R$RI(RLRM(Rs75%(Ras square(x)( Rt __version__t__date__t __author__R&tobjectRRR#R.R7R8R;R<RtopentfttR*tappendR,twriteRtt2t table_datatHTMLthtmlcodeRbtlR0R1tclose(((s7/home/kaligula/galaxy/tools/my_tools/jvenn/HTML/HTML.pyt srL=<sJ     %     )