o —~µ_† ã@sJddlZddlZeeddƒZeeddƒZeeddƒZGdd„dejƒZdS) éNÚSEEK_SETÚSEEK_CURéÚSEEK_ENDécs\eZdZdZd‡fdd„ Zef‡fdd „ Z‡fd d „Zd‡fd d„ Zdd„Z dd„Z ‡Z S)Ú FileChunkIOzA A class that allows you reading only a chunk of a file. ÚrTrNcsj| d¡s tdƒ‚||_||_|durt |¡j|j|_tt|ƒj |||g|¢Ri|¤Ž|  d¡dS)a/ Open a file chunk. The mode can only be 'r' for reading. Offset is the amount of bytes that the chunks starts after the real file's first byte. Bytes defines the amount of bytes the chunk has, which you can set to None to include the last byte of the real file. rzMode string must begin with 'r'Nr) Ú startswithÚ ValueErrorÚoffsetÚbytesÚosÚstatÚst_sizeÚsuperrÚ__init__Úseek)ÚselfÚnameÚmodeÚclosefdr r ÚargsÚkwargs©Ú __class__©ú7/usr/lib/python3/dist-packages/duplicity/filechunkio.pyrs "zFileChunkIO.__init__cs`|tkrtt|ƒ |j|¡dS|tkr | | ¡|¡dS|tkr.| |j|¡dSdS)z/ Move to a new chunk position. N) rrrrr rÚtellrr )rr Úwhencerrrr&sÿzFileChunkIO.seekcstt|ƒ ¡|jS)z( Current file position. )rrrr ©rrrrr1ózFileChunkIO.telléÿÿÿÿcs:|dkr|j| ¡}t||gƒ}tt|ƒ |¡S| ¡S)z2 Read and return at most n bytes. r)r rÚminrrÚreadÚreadall)rÚnÚmax_nrrrr#7s  zFileChunkIO.readcCs| |j| ¡¡S)z/ Read all data from the chunk. )r#r rrrrrr$Br zFileChunkIO.readallc Cs|| t|ƒ¡}t|ƒ}z ||d|…<W|Sty=}zddl}t||jƒs(|‚| d|¡|d|…<WYd}~|Sd}~ww)z/ Same as RawIOBase.readinto(). Nrób)r#ÚlenÚ TypeErrorÚarrayÚ isinstance)rÚbÚdatar%Úerrr*rrrÚreadintoHsû €ûzFileChunkIO.readinto)rTrN)r!) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrr#r$r/Ú __classcell__rrrrrs  r)Úior ÚgetattrrrrÚFileIOrrrrrÚs