/usr/lib/python2.6/site-packages/tablib
NameSizeModeActions
formats/-0755rm
packages/-0755rm
compat.py12120644editdlrm
compat.pyc15330644editdlrm
core.py287050644editdlrm
core.pyc346430644editdlrm
__init__.py1800644editdlrm
__init__.pyc4530644editdlrm
Edit: /usr/lib/python2.6/site-packages/tablib/core.pyc (34643B)
Ñò }DVc@sEdZddklZddklZddklZddklZlZdZ dZ dZ d Z d Z d Zd Zd efd„ƒYZdefd„ƒYZdefd„ƒYZd„Zd„Zd„Zdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZd S(!s¶ tablib.core ~~~~~~~~~~~ This module implements the central Tablib objects. :copyright: (c) 2014 by Kenneth Reitz. :license: MIT, see LICENSE for more details. iÿÿÿÿ(tcopy(t itemgetter(tformats(t OrderedDicttunicodettablibs0.10.0is Kenneth ReitztMITsCopyright 2014 Kenneth ReitztrestructuredtexttRowcBsÔeZdZddgZeƒeƒd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zed„ƒZed„ƒZd„ZRS(s/Internal Row object. Mainly used for filtering.t_rowttagscCs"t|ƒ|_t|ƒ|_dS(N(tlistR R (tselftrowR ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt__init__"scCsd„|iDƒS(Ncssx|] }|VqWdS(N((t.0tcol((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys 's (R (R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt__iter__&scCs t|iƒS(N(tlenR (R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt__len__)scCs t|iƒS(N(treprR (R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt__repr__,scCs|i||fS(N(R (R titj((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt __getslice__/scCs |i|S(N(R (R R((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt __getitem__2scCs||i|`. cOs¢td„|Dƒƒ|_d|_g|_g|_y|d|_Wntj od|_nXy|d|_Wntj od|_nX|i ƒdS(Ncssx|]}t|ƒVqWdS(N(R(Rtarg((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys s theadersttitle( R t_dataR2t_Dataset__headerst _separatorst _formattersR@tKeyErrorRAt_register_formats(R targstkwargs((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRœs   cCs|iS(N(theight(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR³scCs¾t|tƒpt|tƒoS||ijo9|ii|ƒ}g}|iD]}|||qP~St‚nH|i|}t|tƒo|iSg}|D]}||iq£~SdS(N( R4R5RR@R.RBRFRR1(R tkeytpost_[1]R t_resultst_[2]tresult((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR·s '  cCs$|i|ƒt|ƒ|i|s(RAtlowertAttributeError(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRÜscs¼|ig}|id„|iDƒƒd„|Dƒ}tttt|Œƒƒ}|idg}|D]}|d|qe~ƒdid„t |ƒDƒƒ‰di‡fd†|DƒƒS( Ncss(x!|]}ttt|ƒƒVqWdS(N(R tmapR(RR ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys ås css(x!|]}ttt|ƒƒVqWdS(N(R RUR(RR ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys ès it-t|cssx|]}d|VqWdS(s{%s:%s}N((RR/((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys îs s c3s"x|]}ˆi|ŒVqWdS(N(tformat(RR (t format_string(s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys ðs ( RCtextendRBR RUtmaxtzipR*tjoinRR(R RPtlenst field_lensRMtlength((RYs+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt __unicode__âs /cCs |iƒS(N(Ra(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt__str__òsc CsŠxƒtiD]x}y\y&t||it|i|iƒƒWn/tj o#t||it|iƒƒnXWq tj oq Xq WdS(sAdds format properties.N(Rt availableR%RAR=t export_sett import_setRT(tclstfmt((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRGús &%csÃ|o*ˆiot|ƒˆijnt}nn|oGt|ƒdjo t}qžˆiot|ƒˆijnt}n t‡fd†ˆiDƒƒ}|otS|p t‚ntSdS(s>Assures size of every row in dataset is of proper proportions.ic3s(x!|]}t|ƒˆijVqWdS(N(Rtwidth(Rtx(R (s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pys s N(RhRtTrueRJtallRBtInvalidDimensionsR3(R R Rtsafetytis_valid((R s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRQs* * c Cs~t|iƒ}|o t}nt}|ioµx²t|ƒD] \}}x‘|iD]†\}}y^|djo5xJt|ƒD] \} } || ƒ||| ` to the row you are inserting. This gives you the ability to :class:`filter ` your :class:`Dataset` later. R…RiN(R2R‡R RURBR‰RQR@t HeadersNeededRJRRlR*RhRRR(R R.RRˆRR RM((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt insert_col€s$    $  cCs|i|i|d|ƒdS(s|Adds a column to the end of the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. RˆN(R—Rh(R RRˆ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt rpush_col¾scCs|id|d|ƒdS(s|Adds a column to the top of the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. iRˆN(R—(R RRˆ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt lpush_colÆsRVcCs ||f}|ii|ƒdS(s4Adds a separator to :class:`Dataset` at given index.N(RDR-(R R.ttexttsep((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytinsert_separatorÎs cCsZ|ip|io |ind}n|io|idnd}|i||ƒdS(s=Adds a :ref:`separator ` to the :class:`Dataset`.iiN(R@RJRœ(R RšR.((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytappend_separatorÕs cCs|i||ƒdS(suAdds a column to the :class:`Dataset`. See :class:`Dataset.insert_col` for additional documentation. N(R˜(R RRˆ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt append_coláscCs&g}|iD]}|||q~S(s@Returns the column from the :class:`Dataset` at the given index.(RB(R R.RMR ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytget_coléscCstt|tƒo0||ijo|ii|ƒ}q@t‚n||ijp|ii||fƒnt‚t S(sAdds a :ref:`formatter` to the :class:`Dataset`. .. versionadded:: 0.9.5 :param col: column to. Accepts index int or header str. :param handler: reference to callback function to execute against each cell value. ( R4R5R@R.RFRhRER-RpRj(R Rthandler((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt add_formatterós  cCsKt|ƒ}g}|iD]!}|i|ƒo ||qq~|_|S(s…Returns a new instance of the :class:`Dataset`, excluding any rows that do not contain the given :ref:`tags `. (RRBR9(R R8t_dsetRMR ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytfilter s ;c Csut|tƒpt|tƒo|ip t‚nt|idt|ƒd|ƒ}td|id|i ƒ}xþ|D]>}g}|iD]}|||q‹~}|i d|ƒqwWnµ|io|i|}nt|idt|ƒd|ƒ}td|id|i ƒ}xZ|D]R}|io,g} |iD]}| ||q9~ }n|}|i d|ƒqW|S(sSort a :class:`Dataset` by a specific column, given string (for header) or integer (for column index). The order can be reversed by setting ``reverse`` to ``True``. Returns a new :class:`Dataset` instance where columns have been sorted. RKtreverseR@RAR ( R4R5RR@R–tsortedRRR>RAR-( R RR¤t_sortedR¢R/RMRKR RO((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytsorts(   !( ! ,cCs|pdStƒ}|idg||id}||_xY|iD]N}||idjoqGn|g||}t|ƒ}|id|ƒqGW|S(sÀTranspose a :class:`Dataset`, turning rows into columns and vice versa, returning a new ``Dataset`` instance. The first row of the original instance becomes the new header row.NiR (R>R@RR-(R R¢t new_headerstcolumntrow_data((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt transpose;s    cCs t|tƒpdS|i|ijo t‚nt|ƒ}g}|iD] }||qL~}g}|iD] }||qp~}|i|ƒ||_|S(sˆStack two :class:`Dataset` instances together by joining at the row level, and return new combined ``Dataset`` instance.N(R4R>RhRlRRBRZ(R totherR¢RMR t rows_to_stackROt other_rows((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytstackXs  $$  c Cst|tƒpdS|ip |io$|i p |i o t‚qMn|i|ijo t‚ny|i|i}Wntj o d}nXtƒ}x%|iD]}|id||ƒq­Wx%|iD]}|id||ƒqÕW||_|S(sÙStack two :class:`Dataset` instances together by joining at the column level, and return a new combined ``Dataset`` instance. If either ``Dataset`` has headers set, than the other must as well.NR( R4R>R@R–RJRlR{R2Rž(R R¬R¨R¢R©((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt stack_colsos(      cCstƒ|_d|_dS(sARemoves all content and headers from the :class:`Dataset` object.N(R RBR2RC(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR‘s N(;R:R;R<RRRRRRRaRbt classmethodRGR2R3RQRjRyRzR}R=R@R~R„RR‰RJRhRŠR‹RŒRRŽRRR‘R R*R+R,R-RZR”R•R†R—R˜R™RœRRžRŸR¡R£R§R«R¯R°R(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR>nsf,        %        >      '   "tDatabookcBsheZdZd d„Zd„Zd„Zed„ƒZd„Z d„Z e d„Z e d„ƒZRS( s(A book of :class:`Dataset` objects. cCs4|djotƒ|_n ||_|iƒdS(N(R2R t _datasetsRG(R tsets((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRœs  cCs0yd|iiƒSWntj odSXdS(Ns <%s databook>s(RARSRT(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR¥scCs g|_dS(s@Removes all :class:`Dataset` objects from the :class:`Databook`.N(R³(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR¬sc CsŠxƒtiD]x}y\y&t||it|i|iƒƒWn/tj o#t||it|iƒƒnXWq tj oq Xq WdS(sAdds format properties.N(RRcR%RAR=t export_bookt import_bookRT(RfRg((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRG±s &%cCs|iS(N(R³(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytsheets¾scCs.t|tƒo|ii|ƒnt‚dS(s5Adds given :class:`Dataset` to the :class:`Databook`.N(R4R>R³R-tInvalidDatasetType(R tdataset((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt add_sheetÁsc Cs`g}|o t}nt}x<|iD]1}|i|d|id|id|ƒƒƒq'W|S(s(Packages :class:`Databook` for delivery.RARxRr(RRR³R-RARy(R Rrt collectorRstdset((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRyÉs    cCs t|iƒS(sDThe number of the :class:`Dataset` objects within :class:`Databook`.(RR³(R ((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pytsizeÚsN(R:R;R<R2RRRR±RGR·RºRjRyR=R½(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR²˜s     cCsSxFtiD];}y|i|ƒo ||fSWq tj oq Xq Wd|fS(s(Return (format, stream) of given stream.N(RRctdetectRTR2(tstreamRg((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR¾às  cCsNt|ƒ\}}y!tƒ}|i||ƒ|SWntj odSXdS(sReturn dataset of given stream.N(R¾R>ReRTR2(R¿RXRx((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyReës cCsNt|ƒ\}}y!tƒ}|i||ƒ|SWntj odSXdS(sReturn dataset of given stream.N(R¾R²R¶RTR2(R¿RXtdatabook((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR¶øs R¸cBseZdZRS(s(Only Datasets can be added to a DataBook(R:R;R<(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR¸sRlcBseZdZRS(s Invalid size(R:R;R<(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRl sRpcBseZdZRS(sOutside of Dataset size(R:R;R<(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyRp sR–cBseZdZRS(sGHeader parameter must be given when appending a column in this Dataset.(R:R;R<(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR–sR‚cBseZdZRS(sFormat is not supported(R:R;R<(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyR‚sN(R<RtoperatorRRRt tablib.compatRRt __title__t __version__t __build__t __author__t __license__t __copyright__t __docformat__tobjectRR>R²R¾ReR¶t ExceptionR¸RlRpR–tNotImplementedErrorR‚(((s+/tmp/pip-build-lt8jXN/tablib/tablib/core.pyt s2Qÿÿÿ-H