σ Q+GPc@@sƒddlmZmZddlZddlZddlZddlmZmZddl m Z ddl m Z dZ dZdd d gad Zd d dddgZdZdZdZdZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZedkrddlZed ejd!ƒZejj ƒZ e!e j"dƒƒndS("i(tabsolute_importtprint_functionN(tArFiletArError(t Changelog(tDeb822sdata.tars control.tartgztbz2tlzmas debian-binarytpreinsttpostinsttprermtpostrmtconfigtcontrolsusr/share/doc/%s/changelog.gzs$usr/share/doc/%s/changelog.Debian.gztmd5sumstDebErrorcB@seZRS((t__name__t __module__(((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR(stDebPartcB@s•eZdZd„Zd„Zed„ƒZd„Zd d d„Z d d d„Z d„Z d„Z e jd krd „Znd „Zd „ZRS(sW'Part' of a .deb binary package. A .deb package is considered as made of 2 parts: a 'data' part (corresponding to the 'data.tar.gz' archive embedded in a .deb) and a 'control' part (the 'control.tar.gz' archive). Each of them is represented by an instance of this class. Each archive should be a compressed tar archive; supported compression formats are: .tar.gz, .tar.bz2 . When referring to file members of the underlying .tar.gz archive, file names can be specified in one of 3 formats "file", "./file", "/file". In all cases the file is considered relative to the root of the archive. For the control part the preferred mechanism is the first one (as in deb.control.get_content('control') ); for the data part the preferred mechanism is the third one (as in deb.data.get_file('/etc/vim/vimrc') ). cC@s||_d|_dS(N(t_DebPart__membertNonet _DebPart__tgz(tselftmember((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt__init__=s cC@s­|jdkr¦|jj}|jdƒrctjd|jddƒ}tjd|ddƒ|_q¦|jdƒr“tj d|jddƒ|_q¦t d|ƒ‚n|jS( sέReturn a TarFile object corresponding to this part of a .deb package. Despite the name, this method gives access to various kind of compressed tar archives, not only gzipped ones. s.gztfileobjtmodetrs.bz2sr:bz2s"part '%s' has unexpected extensionN( RRRtnametendswithtgziptGzipFilettarfiletTarFiletopenR(RRR((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyttgzAs !cC@s<|jdƒr|d}n|jdƒr8|d}n|S(sw try (not so hard) to obtain a member file name in a form relative to the .tar.gz root and with no heading '.' s./it/i(t startswith(tfname((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt__normalize_memberVs   cC@s;tj|ƒ}|jƒjƒ}d||kp:||kS(s.Check if this part contains a given file name.s./(Rt_DebPart__normalize_memberR$tgetnames(RR'tnames((s2/usr/lib/python2.7/dist-packages/debian/debfile.pythas_filegscC@sυtj|ƒ}y|jƒjd|ƒ}Wn&tk rT|jƒj|ƒ}nX|dk rνtjdkr³ddl}t |dƒsšd„|_ n|j |d|d|ƒSddl }|dkrΤd }n|j ||d|ƒSn|SdS( sΎReturn a file object corresponding to a given file name. If encoding is given, then the file object will return Unicode data; otherwise, it will return binary data. s./t3iNtflushcS@sdS(N(R(((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt€stencodingterrorststrict(RR)R$t extractfiletKeyErrorRtsystversiontiothasattrR.t TextIOWrappertcodecst EncodedFile(RR'R0R1tfobjR7R:((s2/usr/lib/python2.7/dist-packages/debian/debfile.pytget_fileos       cC@sD|j|d|d|ƒ}d}|r@|jƒ}|jƒn|S(sΥReturn the string content of a given file, or None (e.g. for directories). If encoding is given, then the content will be a Unicode object; otherwise, it will contain binary data. R0R1N(R=Rtreadtclose(RR'R0R1tftcontent((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt get_contentŠs   cC@st|jƒjƒƒS(N(titerR$R*(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt__iter__›scC@s |j|ƒS(N(R,(RR'((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt __contains__žsR-cC@s |j|ƒS(N(R,(RR'((s2/usr/lib/python2.7/dist-packages/debian/debfile.pythas_key’scC@s |j|ƒS(N(RB(RR'((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt __getitem__₯scC@s|jjƒdS(N(RR?(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR?¨sN(RRt__doc__RR$t staticmethodR)R,RR=RBRDRER5R6RFRGR?(((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR,s       tDebDatacB@seZRS((RR(((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyRJ¬st DebControlcB@s)eZd„Zd„Zddd„ZRS(cC@s@i}x3tD]+}|j|ƒr |j|ƒ||too many parts in given .deb (was looking for only one of: %s)i(t PART_EXTSt intersectiontsetRtlentlist(tbasenametextt candidatestparts(t actual_names(s2/usr/lib/python2.7/dist-packages/debian/debfile.pytcompressed_part_nameϊs#  s4missing required part in given .deb (expected: '%s')(RRR_R*t INFO_PARTRt_DebFile__partsRKt getmembert CTRL_PARTRJt DATA_PARTRt_DebFile__pkgnameR>tstript_DebFile__versionR?(RtfilenameRRRgR@((Rfs2/usr/lib/python2.7/dist-packages/debian/debfile.pyRφs      cC@s|jƒd|_dS(Ntpackage(RORm(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt__updatePkgNamescC@s|jS(N(Ro(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR/scC@s |jtS(N(RiRl(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR/scC@s |jtS(N(RiRk(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR/scC@s |jjƒS(s See .control.debcontrol() (RRO(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyROscC@s |jjƒS(s See .control.scripts() (RRM(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyRM#scC@s|jjd|d|ƒS(s See .control.md5sums() R0R1(RR(RR0R1((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR'scC@s•|jdkr|jƒnxrt|jt|jgD]V}|jj|ƒr7tjd|jj |ƒƒ}|j ƒ}|j ƒt |ƒSq7WdS(s† Return a Changelog object for the changelog.Debian.gz of the present .deb package. Return None if no changelog can be found. RN( RmRt_DebFile__updatePkgNametCHANGELOG_DEBIANtCHANGELOG_NATIVEtdataR,RR R=R>R?R(RR'Rt raw_changelog((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyt changelog+s    cC@s|jjƒ|jjƒdS(N(RR?Rv(R((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR?;s N(RRRHRRRstpropertyR6RvRRORMRRxR?(((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyR\ηs     t__main__Rpi(#t __future__RRRR!R5t debian.arfileRRtdebian.changelogRt debian.deb822RRlRkR]RhRLRNRuRtRPRtobjectRRJRKR\RtargvtdebRR$tprintRj(((s2/usr/lib/python2.7/dist-packages/debian/debfile.pyts2   €6Y