/opt/alt/python34/lib64/python3.4/__pycache__
NameSizeModeActions
abc.cpython-34.pyc78770644editdlrm
abc.cpython-34.pyo78270644editdlrm
aifc.cpython-34.pyc279120644editdlrm
aifc.cpython-34.pyo279120644editdlrm
antigravity.cpython-34.pyc8470644editdlrm
antigravity.cpython-34.pyo8470644editdlrm
argparse.cpython-34.pyc658740644editdlrm
argparse.cpython-34.pyo657150644editdlrm
ast.cpython-34.pyc123600644editdlrm
ast.cpython-34.pyo123600644editdlrm
asynchat.cpython-34.pyc83590644editdlrm
asynchat.cpython-34.pyo83590644editdlrm
asyncore.cpython-34.pyc179630644editdlrm
asyncore.cpython-34.pyo179630644editdlrm
base64.cpython-34.pyc182970644editdlrm
base64.cpython-34.pyo180990644editdlrm
bdb.cpython-34.pyc186940644editdlrm
bdb.cpython-34.pyo186940644editdlrm
binhex.cpython-34.pyc135410644editdlrm
binhex.cpython-34.pyo135410644editdlrm
bisect.cpython-34.pyc28580644editdlrm
bisect.cpython-34.pyo28580644editdlrm
bz2.cpython-34.pyc151560644editdlrm
bz2.cpython-34.pyo151560644editdlrm
calendar.cpython-34.pyc275670644editdlrm
calendar.cpython-34.pyo275670644editdlrm
cgi.cpython-34.pyc298270644editdlrm
cgi.cpython-34.pyo298270644editdlrm
cgitb.cpython-34.pyc110640644editdlrm
cgitb.cpython-34.pyo110640644editdlrm
chunk.cpython-34.pyc52700644editdlrm
chunk.cpython-34.pyo52700644editdlrm
cmd.cpython-34.pyc134560644editdlrm
cmd.cpython-34.pyo134560644editdlrm
code.cpython-34.pyc97020644editdlrm
code.cpython-34.pyo97020644editdlrm
codecs.cpython-34.pyc351320644editdlrm
codecs.cpython-34.pyo351320644editdlrm
codeop.cpython-34.pyc64660644editdlrm
codeop.cpython-34.pyo64660644editdlrm
colorsys.cpython-34.pyc36590644editdlrm
colorsys.cpython-34.pyo36590644editdlrm
compileall.cpython-34.pyc73780644editdlrm
compileall.cpython-34.pyo73780644editdlrm
configparser.cpython-34.pyc448820644editdlrm
configparser.cpython-34.pyo448820644editdlrm
contextlib.cpython-34.pyc103700644editdlrm
contextlib.cpython-34.pyo103700644editdlrm
copy.cpython-34.pyc80610644editdlrm
copy.cpython-34.pyo79750644editdlrm
copyreg.cpython-34.pyc46070644editdlrm
copyreg.cpython-34.pyo45660644editdlrm
cProfile.cpython-34.pyc46220644editdlrm
cProfile.cpython-34.pyo46220644editdlrm
crypt.cpython-34.pyc24370644editdlrm
crypt.cpython-34.pyo24370644editdlrm
csv.cpython-34.pyc129970644editdlrm
csv.cpython-34.pyo129970644editdlrm
datetime.cpython-34.pyc562640644editdlrm
datetime.cpython-34.pyo542960644editdlrm
decimal.cpython-34.pyc1725260644editdlrm
decimal.cpython-34.pyo1725260644editdlrm
difflib.cpython-34.pyc605150644editdlrm
difflib.cpython-34.pyo604670644editdlrm
dis.cpython-34.pyc145870644editdlrm
dis.cpython-34.pyo145870644editdlrm
doctest.cpython-34.pyc801100644editdlrm
doctest.cpython-34.pyo798370644editdlrm
dummy_threading.cpython-34.pyc12140644editdlrm
dummy_threading.cpython-34.pyo12140644editdlrm
enum.cpython-34.pyc163390644editdlrm
enum.cpython-34.pyo163390644editdlrm
filecmp.cpython-34.pyc91200644editdlrm
filecmp.cpython-34.pyo91200644editdlrm
fileinput.cpython-34.pyc142970644editdlrm
fileinput.cpython-34.pyo142970644editdlrm
fnmatch.cpython-34.pyc31460644editdlrm
fnmatch.cpython-34.pyo31460644editdlrm
formatter.cpython-34.pyc189160644editdlrm
formatter.cpython-34.pyo189160644editdlrm
fractions.cpython-34.pyc192700644editdlrm
fractions.cpython-34.pyo192700644editdlrm
ftplib.cpython-34.pyc333220644editdlrm
ftplib.cpython-34.pyo333220644editdlrm
functools.cpython-34.pyc236140644editdlrm
functools.cpython-34.pyo236140644editdlrm
genericpath.cpython-34.pyc34930644editdlrm
genericpath.cpython-34.pyo34930644editdlrm
getopt.cpython-34.pyc67330644editdlrm
getopt.cpython-34.pyo66910644editdlrm
getpass.cpython-34.pyc46240644editdlrm
getpass.cpython-34.pyo46240644editdlrm
gettext.cpython-34.pyc151740644editdlrm
gettext.cpython-34.pyo151740644editdlrm
glob.cpython-34.pyc28800644editdlrm
glob.cpython-34.pyo28800644editdlrm
gzip.cpython-34.pyc194460644editdlrm
gzip.cpython-34.pyo193920644editdlrm
hashlib.cpython-34.pyc79440644editdlrm
hashlib.cpython-34.pyo79440644editdlrm
heapq.cpython-34.pyc139100644editdlrm
heapq.cpython-34.pyo139100644editdlrm
hmac.cpython-34.pyc51460644editdlrm
hmac.cpython-34.pyo51460644editdlrm
imaplib.cpython-34.pyc434790644editdlrm
imaplib.cpython-34.pyo409550644editdlrm
imghdr.cpython-34.pyc41430644editdlrm
imghdr.cpython-34.pyo41430644editdlrm
imp.cpython-34.pyc98670644editdlrm
imp.cpython-34.pyo98670644editdlrm
inspect.cpython-34.pyc763270644editdlrm
inspect.cpython-34.pyo760060644editdlrm
io.cpython-34.pyc34580644editdlrm
io.cpython-34.pyo34580644editdlrm
ipaddress.cpython-34.pyc629840644editdlrm
ipaddress.cpython-34.pyo629840644editdlrm
keyword.cpython-34.pyc19460644editdlrm
keyword.cpython-34.pyo19460644editdlrm
linecache.cpython-34.pyc31120644editdlrm
linecache.cpython-34.pyo31120644editdlrm
locale.cpython-34.pyc372760644editdlrm
locale.cpython-34.pyo372760644editdlrm
lzma.cpython-34.pyc159170644editdlrm
lzma.cpython-34.pyo159170644editdlrm
macpath.cpython-34.pyc60060644editdlrm
macpath.cpython-34.pyo60060644editdlrm
macurl2path.cpython-34.pyc21020644editdlrm
macurl2path.cpython-34.pyo21020644editdlrm
mailbox.cpython-34.pyc702880644editdlrm
mailbox.cpython-34.pyo701890644editdlrm
mailcap.cpython-34.pyc65440644editdlrm
mailcap.cpython-34.pyo65440644editdlrm
mimetypes.cpython-34.pyc168070644editdlrm
mimetypes.cpython-34.pyo168070644editdlrm
modulefinder.cpython-34.pyc173760644editdlrm
modulefinder.cpython-34.pyo172970644editdlrm
netrc.cpython-34.pyc42770644editdlrm
netrc.cpython-34.pyo42770644editdlrm
nntplib.cpython-34.pyc363100644editdlrm
nntplib.cpython-34.pyo363100644editdlrm
ntpath.cpython-34.pyc133050644editdlrm
ntpath.cpython-34.pyo133050644editdlrm
nturl2path.cpython-34.pyc17160644editdlrm
nturl2path.cpython-34.pyo17160644editdlrm
numbers.cpython-34.pyc126670644editdlrm
numbers.cpython-34.pyo126670644editdlrm
opcode.cpython-34.pyc51740644editdlrm
opcode.cpython-34.pyo51740644editdlrm
operator.cpython-34.pyc127780644editdlrm
operator.cpython-34.pyo127780644editdlrm
optparse.cpython-34.pyc515370644editdlrm
optparse.cpython-34.pyo514600644editdlrm
os.cpython-34.pyc295990644editdlrm
os.cpython-34.pyo295990644editdlrm
pathlib.cpython-34.pyc404830644editdlrm
pathlib.cpython-34.pyo404830644editdlrm
pdb.cpython-34.pyc494720644editdlrm
pdb.cpython-34.pyo494060644editdlrm
pickle.cpython-34.pyc469840644editdlrm
pickle.cpython-34.pyo468380644editdlrm
pickletools.cpython-34.pyc702540644editdlrm
pickletools.cpython-34.pyo691670644editdlrm
pipes.cpython-34.pyc84310644editdlrm
pipes.cpython-34.pyo84310644editdlrm
pkgutil.cpython-34.pyc176000644editdlrm
pkgutil.cpython-34.pyo176000644editdlrm
platform.cpython-34.pyc311720644editdlrm
platform.cpython-34.pyo311720644editdlrm
plistlib.cpython-34.pyc301510644editdlrm
plistlib.cpython-34.pyo300680644editdlrm
poplib.cpython-34.pyc137540644editdlrm
poplib.cpython-34.pyo137540644editdlrm
posixpath.cpython-34.pyc98090644editdlrm
posixpath.cpython-34.pyo98090644editdlrm
pprint.cpython-34.pyc114600644editdlrm
pprint.cpython-34.pyo112950644editdlrm
profile.cpython-34.pyc151510644editdlrm
profile.cpython-34.pyo148980644editdlrm
pstats.cpython-34.pyc236750644editdlrm
pstats.cpython-34.pyo236750644editdlrm
pty.cpython-34.pyc42250644editdlrm
pty.cpython-34.pyo42250644editdlrm
pyclbr.cpython-34.pyc91920644editdlrm
pyclbr.cpython-34.pyo91920644editdlrm
pydoc.cpython-34.pyc909150644editdlrm
pydoc.cpython-34.pyo908540644editdlrm
py_compile.cpython-34.pyc68570644editdlrm
py_compile.cpython-34.pyo68570644editdlrm
queue.cpython-34.pyc92620644editdlrm
queue.cpython-34.pyo92620644editdlrm
quopri.cpython-34.pyc64460644editdlrm
quopri.cpython-34.pyo62360644editdlrm
random.cpython-34.pyc190590644editdlrm
random.cpython-34.pyo190590644editdlrm
re.cpython-34.pyc145500644editdlrm
re.cpython-34.pyo145500644editdlrm
reprlib.cpython-34.pyc58720644editdlrm
reprlib.cpython-34.pyo58720644editdlrm
rlcompleter.cpython-34.pyc56950644editdlrm
rlcompleter.cpython-34.pyo56950644editdlrm
runpy.cpython-34.pyc77530644editdlrm
runpy.cpython-34.pyo77530644editdlrm
sched.cpython-34.pyc65730644editdlrm
sched.cpython-34.pyo65730644editdlrm
selectors.cpython-34.pyc167440644editdlrm
selectors.cpython-34.pyo167440644editdlrm
shelve.cpython-34.pyc99550644editdlrm
shelve.cpython-34.pyo99550644editdlrm
shlex.cpython-34.pyc75180644editdlrm
shlex.cpython-34.pyo75180644editdlrm
shutil.cpython-34.pyc330150644editdlrm
shutil.cpython-34.pyo330150644editdlrm
site.cpython-34.pyc179710644editdlrm
site.cpython-34.pyo179710644editdlrm
smtpd.cpython-34.pyc256690644editdlrm
smtpd.cpython-34.pyo256690644editdlrm
smtplib.cpython-34.pyc331290644editdlrm
smtplib.cpython-34.pyo330550644editdlrm
sndhdr.cpython-34.pyc67690644editdlrm
sndhdr.cpython-34.pyo67690644editdlrm
socket.cpython-34.pyc181110644editdlrm
socket.cpython-34.pyo180610644editdlrm
socketserver.cpython-34.pyc232550644editdlrm
socketserver.cpython-34.pyo232550644editdlrm
sre_compile.cpython-34.pyc119350644editdlrm
sre_compile.cpython-34.pyo117780644editdlrm
sre_constants.cpython-34.pyc55810644editdlrm
sre_constants.cpython-34.pyo55810644editdlrm
sre_parse.cpython-34.pyc202380644editdlrm
sre_parse.cpython-34.pyo202380644editdlrm
ssl.cpython-34.pyc276080644editdlrm
ssl.cpython-34.pyo276080644editdlrm
stat.cpython-34.pyc35780644editdlrm
stat.cpython-34.pyo35780644editdlrm
statistics.cpython-34.pyc171580644editdlrm
statistics.cpython-34.pyo168560644editdlrm
string.cpython-34.pyc83760644editdlrm
string.cpython-34.pyo83760644editdlrm
stringprep.cpython-34.pyc136360644editdlrm
stringprep.cpython-34.pyo135730644editdlrm
struct.cpython-34.pyc3470644editdlrm
struct.cpython-34.pyo3470644editdlrm
subprocess.cpython-34.pyc433590644editdlrm
subprocess.cpython-34.pyo432460644editdlrm
sunau.cpython-34.pyc183090644editdlrm
sunau.cpython-34.pyo183090644editdlrm
symbol.cpython-34.pyc26620644editdlrm
symbol.cpython-34.pyo26620644editdlrm
symtable.cpython-34.pyc113050644editdlrm
symtable.cpython-34.pyo111830644editdlrm
sysconfig.cpython-34.pyc172870644editdlrm
sysconfig.cpython-34.pyo172870644editdlrm
tabnanny.cpython-34.pyc77490644editdlrm
tabnanny.cpython-34.pyo77490644editdlrm
tarfile.cpython-34.pyc680400644editdlrm
tarfile.cpython-34.pyo680400644editdlrm
telnetlib.cpython-34.pyc193940644editdlrm
telnetlib.cpython-34.pyo193940644editdlrm
tempfile.cpython-34.pyc215760644editdlrm
tempfile.cpython-34.pyo215760644editdlrm
textwrap.cpython-34.pyc138000644editdlrm
textwrap.cpython-34.pyo137140644editdlrm
this.cpython-34.pyc13160644editdlrm
this.cpython-34.pyo13160644editdlrm
threading.cpython-34.pyc389650644editdlrm
threading.cpython-34.pyo382520644editdlrm
timeit.cpython-34.pyc110620644editdlrm
timeit.cpython-34.pyo110620644editdlrm
token.cpython-34.pyc36150644editdlrm
token.cpython-34.pyo36150644editdlrm
tokenize.cpython-34.pyc199510644editdlrm
tokenize.cpython-34.pyo199010644editdlrm
trace.cpython-34.pyc241840644editdlrm
trace.cpython-34.pyo241270644editdlrm
traceback.cpython-34.pyc110910644editdlrm
traceback.cpython-34.pyo110910644editdlrm
tracemalloc.cpython-34.pyc171300644editdlrm
tracemalloc.cpython-34.pyo171300644editdlrm
tty.cpython-34.pyc11460644editdlrm
tty.cpython-34.pyo11460644editdlrm
types.cpython-34.pyc55600644editdlrm
types.cpython-34.pyo55600644editdlrm
uu.cpython-34.pyc40210644editdlrm
uu.cpython-34.pyo40210644editdlrm
uuid.cpython-34.pyc218640644editdlrm
uuid.cpython-34.pyo218020644editdlrm
warnings.cpython-34.pyc122680644editdlrm
warnings.cpython-34.pyo115360644editdlrm
wave.cpython-34.pyc191350644editdlrm
wave.cpython-34.pyo190740644editdlrm
weakref.cpython-34.pyc203450644editdlrm
weakref.cpython-34.pyo203080644editdlrm
webbrowser.cpython-34.pyc171320644editdlrm
webbrowser.cpython-34.pyo170930644editdlrm
xdrlib.cpython-34.pyc90020644editdlrm
xdrlib.cpython-34.pyo90020644editdlrm
zipfile.cpython-34.pyc458200644editdlrm
zipfile.cpython-34.pyo457710644editdlrm
_bootlocale.cpython-34.pyc10470644editdlrm
_bootlocale.cpython-34.pyo10160644editdlrm
_collections_abc.cpython-34.pyc239490644editdlrm
_collections_abc.cpython-34.pyo239490644editdlrm
_compat_pickle.cpython-34.pyc75010644editdlrm
_compat_pickle.cpython-34.pyo74270644editdlrm
_dummy_thread.cpython-34.pyc48250644editdlrm
_dummy_thread.cpython-34.pyo48250644editdlrm
_markupbase.cpython-34.pyc89320644editdlrm
_markupbase.cpython-34.pyo87450644editdlrm
_osx_support.cpython-34.pyc106300644editdlrm
_osx_support.cpython-34.pyo106300644editdlrm
_pyio.cpython-34.pyc649330644editdlrm
_pyio.cpython-34.pyo649070644editdlrm
_sitebuiltins.cpython-34.pyc36770644editdlrm
_sitebuiltins.cpython-34.pyo36770644editdlrm
_strptime.cpython-34.pyc157790644editdlrm
_strptime.cpython-34.pyo157790644editdlrm
_sysconfigdata.cpython-34.pyc227000644editdlrm
_sysconfigdata.cpython-34.pyo227000644editdlrm
_threading_local.cpython-34.pyc69460644editdlrm
_threading_local.cpython-34.pyo69460644editdlrm
_weakrefset.cpython-34.pyc84650644editdlrm
_weakrefset.cpython-34.pyo84650644editdlrm
__future__.cpython-34.pyc41680644editdlrm
__future__.cpython-34.pyo41680644editdlrm
__phello__.foo.cpython-34.pyc1340644editdlrm
__phello__.foo.cpython-34.pyo1340644editdlrm
Edit: /opt/alt/python34/lib64/python3.4/__pycache__/tarfile.cpython-34.pyo (68040B)
fe@sdZdZdZdZdZdZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZyddlZddlZWnek rdZZYnXeefZyeef7ZWnek r YnXd d d d gZd ZdZedZdZdZdZ dZ!dZ"dZ#d Z$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/d Z0d!Z1dZ2d"Z3d#Z4e3Z5e#e$e%e&e)e*e+e'e(e,e-e.f Z6e#e$e+e.fZ7e,e-e.fZ8d$d%d&d'd(d)d*d+fZ9d$d%d*d+hZ:ie;d,6e;d-6e;d'6e<d(6e<d)6e<d&6Z=e j>d.d/fkrd0Z?n e j@Z?d1d2ZAd3d4ZBd5d6ZCd7e5d8d9ZDd:d;ZEded<d=ZFd>d?ZGd@dAZHGdBd d eIZJGdCdDdDeJZKGdEdFdFeJZLGdGdHdHeJZMGdIdJdJeJZNGdKdLdLeJZOGdMdNdNeOZPGdOdPdPeOZQGdQdRdReOZRGdSdTdTeOZSGdUdVdVeOZTGdWdXdXZUGdYdZdZZVGd[d\d\eWZXGd]d^d^eWZYGd_d`d`e jZZ[Gdad d eWZ\Gdbd d eWZ]GdcddddZ^ded Z_e]jZdfdgZ`eadhkre`ndS)iz,Read from and write to tar format archives. z0.9.0u"Lars Gustäbel (lars@gustaebel.de)z5$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $z?$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $u4Gustavo Niemeyer, Niels Gustäbel, Richard Townsend.)openNTarFileTarInfo is_tarfileTarErrorsisustar sustar00d01234567LKSxgXpathlinkpathsizemtimeuidgidunamegnameZatimeZctimentZcezutf-8cCs2|j||}|d||t|tS)z8Convert a string to a null-terminated bytes object. N)encodelenNUL)slengthencodingerrorsr*,/opt/alt/python34/lib64/python3.4/tarfile.pystnsr,cCs>|jd}|dkr.|d|}n|j||S)z8Convert a null-terminated bytes object to a string. srN)finddecode)r&r(r)pr*r*r+ntss r1c Cs|dd krd}x:tt|dD]"}|dK}|||d7}q-W|ddkrdt|d| }qnRy1t|dd}t|jpd d}Wntk rtd YnX|S) z/Convert a number field to a python number. rrasciistrict0zinvalid header)r2r3)ranger$r1intstrip ValueErrorInvalidHeaderError)r&nir*r*r+ntis  r@r4cCsd|kod|dknrNtd|dt|fdt}n|tkrd|d |kod|dknr|dkrtdg}ntdg}d||}xEt|dD]$}|jd|d@|dL}qWn td |S) z/Convert a python number to a number field. rr4rz%0*or6r5r2r3zoverflow in number field)bytesr:r% GNU_FORMAT bytearrayr9insertr<)r>digitsformatr&r?r*r*r+itns $*9  rGcCsBdttjd|}dttjd|}||fS)aCalculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in the buffer with the high bit set. So we calculate two checksums, unsigned and signed. r5Z 148B8x356BZ 148b8x356b)sumstructZ unpack_from)bufZunsigned_chksumZ signed_chksumr*r*r+ calc_chksumss rKc Cs|dkrdS|dkr0tj||dSd}t||\}}xQt|D]C}|j|}t||kr|dn|j|qXW|dkr|j|}t||kr|dn|j|ndS)zjCopy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. rNizunexpected end of datai@)shutil copyfileobjdivmodr9readr$write) srcZdstr' exceptionZBUFSIZEblocks remainderbrJr*r*r+rNs$   rNcCs,ddl}|jdtdtj|S)z/Deprecated in this location; use stat.filemode.rNz$deprecated in favor of stat.filemoder)warningswarnDeprecationWarningstatfilemode)moderWr*r*r+r[s   r[cCsSttjdd}|dk r?|j|dj|}nt|dddS)Nr(backslashreplaceend )getattrsysstdoutr#r/print)r&r(r*r*r+ _safe_prints rdc@seZdZdZdS)rzBase exception.N)__name__ __module__ __qualname____doc__r*r*r*r+r s c@seZdZdZdS) ExtractErrorz%General exception for extract errors.N)rerfrgrhr*r*r*r+ris ric@seZdZdZdS) ReadErrorz&Exception for unreadable tar archives.N)rerfrgrhr*r*r*r+rjs rjc@seZdZdZdS)CompressionErrorz.Exception for unavailable compression methods.N)rerfrgrhr*r*r*r+rks rkc@seZdZdZdS) StreamErrorz=Exception for unsupported operations on stream-like TarFiles.N)rerfrgrhr*r*r*r+rls rlc@seZdZdZdS) HeaderErrorz!Base exception for header errors.N)rerfrgrhr*r*r*r+rms rmc@seZdZdZdS)EmptyHeaderErrorzException for empty headers.N)rerfrgrhr*r*r*r+rns rnc@seZdZdZdS)TruncatedHeaderErrorz Exception for truncated headers.N)rerfrgrhr*r*r*r+ro s roc@seZdZdZdS)EOFHeaderErrorz"Exception for end of file headers.N)rerfrgrhr*r*r*r+rp#s rpc@seZdZdZdS)r=zException for invalid headers.N)rerfrgrhr*r*r*r+r=&s r=c@seZdZdZdS)SubsequentHeaderErrorz3Exception for missing and invalid extended headers.N)rerfrgrhr*r*r*r+rq)s rqc@sFeZdZdZddZddZddZdd Zd S) _LowLevelFilezLow-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. cCsgitjd6tjtjBtjBd6|}ttdrK|tjO}ntj||d|_dS)NrwO_BINARYi) osO_RDONLYO_WRONLYO_CREATO_TRUNChasattrrurfd)selfnamer\r*r*r+__init__6s z_LowLevelFile.__init__cCstj|jdS)N)rvcloser|)r}r*r*r+r?sz_LowLevelFile.closecCstj|j|S)N)rvrPr|)r}rr*r*r+rPBsz_LowLevelFile.readcCstj|j|dS)N)rvrQr|)r}r&r*r*r+rQEsz_LowLevelFile.writeN)rerfrgrhrrrPrQr*r*r*r+rr0s   rrc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dddZ dddZ ddZddZdS)_StreamaClass that serves as an adapter between TarFile and a stream-like object. The stream-like object only needs to have a read() or write() method and is accessed blockwise. Use of gzip or bzip2 compression is possible. A stream-like object could be for example: sys.stdin, sys.stdout, a socket, a tape device etc. _Stream is intended to be used only internally. c Csd|_|dkr0t||}d|_n|dkrWt|}|j}n|p`d|_||_||_||_||_d|_ d|_ d|_ y|dkr2yddl }Wnt k rtd YnX||_ |jd|_|d kr%|j|j|_qR|jn |d kryddl}Wnt k rntd YnX|d krd|_|j|_t|_qR|j|_n|d kr3yddl}Wnt k rtdYnX|d kr!d|_|j|_|j|_qR|j|_n|dkrRtd|nWn-|jsr|jjnd|_ YnXdS)z$Construct a _Stream object. TNF*rgzzzlib module is not availablersbz2zbz2 module is not availablexzzlzma module is not availabletarzunknown compression type %r) _extfileobjrr _StreamProxy getcomptyper~r\comptypefileobjbufsizerJposclosedzlib ImportErrorrkcrc32crc _init_read_gzerrorrS_init_write_gzrdbufZBZ2DecompressorcmpOSErrorZ BZ2CompressorlzmaZLZMADecompressor LZMAErrorZLZMACompressorr) r}r~r\rrrrrrr*r*r+rSsl                              z_Stream.__init__cCs*t|dr&|j r&|jndS)Nr)r{rr)r}r*r*r+__del__sz_Stream.__del__cCs|jjd|jj|jj |jjd|_tjdtt j }|j d|d|j j dr|j dd |_ n|j |j j d d tdS) z6Initialize for writing with gzip compression. rz|t krPqqWn|d@rc|jdnd S)z:Initialize for reading a gzip compressed fileobj. rrsznot a gzip filerszunsupported compression methodr5r4rLN) rZ decompressobjrrr _Stream__readrjrkordrPr%)r}ZflagZxlenr&r*r*r+rs.   ,     z_Stream._init_read_gzcCs|jS)z3Return the stream's file pointer position. )r)r}r*r*r+tellsz _Stream.tellrcCs|||jdkrit||j|j\}}x$t|D]}|j|jq?W|j|n td|jS)zXSet the stream's file pointer to pos. Negative seeking is forbidden. rz seeking backwards is not allowed)rrOrr9rPrl)r}rrTrUr?r*r*r+seeks z _Stream.seekNcCs||dkrTg}x-|j|j}|s1Pn|j|qWdj|}n|j|}|jt|7_|S)zReturn the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF. Nr)_readrappendjoinrr$)r}rtrJr*r*r+rP s z _Stream.readc Cs|jdkr|j|St|j}x||kr|j|j}|sVPny|jj|}Wn!|jk rtdYnX|j|7_|t|7}q.W|jd|}|j|d|_|S)z+Return size bytes from the stream. rzinvalid compressed dataN) rrr$rrrZ decompressrSrj)r}rcrJr*r*r+rs  z _Stream._readcCst|j}xN||kr_|jj|j}|s=Pn|j|7_|t|7}qW|jd|}|j|d|_|S)zsReturn size bytes from stream. If internal buffer is empty, read another block from the stream. N)r$rJrrPr)r}rrrJr*r*r+Z__read2sz_Stream.__read)rerfrgrhrrrrQrrrrrrPrrr*r*r*r+rHs  F       rc@sFeZdZdZddZddZddZdd Zd S) rzsSmall proxy class that enables transparent compression detection for the Stream interface (mode 'r|*'). cCs"||_|jjt|_dS)N)rrP BLOCKSIZErJ)r}rr*r*r+rGs z_StreamProxy.__init__cCs|jj|_|jS)N)rrPrJ)r}rr*r*r+rPKsz_StreamProxy.readcCsj|jjdrdS|jdddkrL|jdddkrLd S|jjdrbd Sd SdS)NsrrrsBZhr s1AY&SYr]7zXZrr)rr)rJ startswith)r}r*r*r+rOs2z_StreamProxy.getcomptypecCs|jjdS)N)rr)r}r*r*r+rYsz_StreamProxy.closeN)rerfrgrhrrPrrr*r*r*r+rBs    rc@seZdZdZdddZddZddZd d Zd d Zd dZ e j ddZ dddZ ddZddZdS) _FileInFilezA thin wrapper around an existing file object that provides a part of its data as an individual file object. NcCs,||_||_||_d|_t|dd|_d|_|dkr`d|fg}nd|_g|_d}|j}xs|D]k\}}||kr|jj d||dfn|jj d||||f||7}||}qW||jkr(|jj d||jdfndS)Nrr~FT) roffsetrpositionr`r~r map_indexmapr)r}rrrZ blockinfoZlastposZrealposr*r*r+rfs(            z_FileInFile.__init__cCsdS)Nr*)r}r*r*r+rsz_FileInFile.flushcCsdS)NTr*)r}r*r*r+readablesz_FileInFile.readablecCsdS)NFr*)r}r*r*r+writablesz_FileInFile.writablecCs |jjS)N)rseekable)r}r*r*r+rsz_FileInFile.seekablecCs|jS)z*Return the current file position. )r)r}r*r*r+rsz_FileInFile.tellcCs|tjkr0tt|d|j|_n|tjkr|dkrgt|j|d|_qt|j||j|_nC|tjkrtt|j||jd|_n td|jS)z(Seek to a position in the file. rzInvalid argument) ioSEEK_SETminmaxrrSEEK_CURSEEK_ENDr<)r}rwhencer*r*r+rs! ( z_FileInFile.seekc Csl|dkr|j|j}nt||j|j}d}x'|dkrgxv|j|j\}}}}||jko|knrPqP|jd7_|jt|jkrPd|_qPqPWt|||j}|r=|jj||j||jj|}t||kr0t dn||7}n|t |7}||8}|j|7_qAW|S)z!Read data from the file. Nrrrzunexpected end of data) rrrrrr$rrrPrjr%) r}rrJdatastartstoprr'rVr*r*r+rPs.   z_FileInFile.readcCs5|jt|}||dt|d?Zd@dAZ dBdCZ!dDdEZ"dFdGZ#dHdIZ$dJdKZ%dLdMZ&dNdOZ'dPdQZ(dRdSZ)dTdUZ*dVdWZ+dXdYZ,dZd[Z-d\d]Z.d^d_Z/d`daZ0dbdcZ1dddeZ2dfdgZ3dhS)jraInformational class which holds the details about an archive member given by a tar header block. TarInfo objects are returned by TarFile.getmember(), TarFile.getmembers() and TarFile.gettarinfo() and are usually created internally. r~r\rrrrchksumtypelinknamer r!devmajordevminorrr pax_headersrr_sparse_structs _link_targetrcCs||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_i|_dS)zXConstruct a TarInfo object. name is the optional name of the member. irrN)r~r\rrrrrREGTYPErrr r!rrrrrr)r}r~r*r*r+rs"                zTarInfo.__init__cCs|jS)N)r~)r}r*r*r+_getpathszTarInfo._getpathcCs ||_dS)N)r~)r}r~r*r*r+_setpathszTarInfo._setpathcCs|jS)N)r)r}r*r*r+ _getlinkpathszTarInfo._getlinkpathcCs ||_dS)N)r)r}rr*r*r+ _setlinkpathszTarInfo._setlinkpathcCs d|jj|jt|fS)Nz<%s %r at %#x>)rrer~id)r}r*r*r+__repr__szTarInfo.__repr__cCsi |jd6|jd@d6|jd6|jd6|jd6|jd6|jd6|jd 6|jd 6|j d 6|j d 6|j d 6|j d6}|d t kr|djd r|dd7ny||jd d Wn#tk r||||YnXt|||kr>||||q>WxdD]\}}||krd||r0rr*r*r+rs<      1   z"TarInfo._create_pax_generic_headerc Csft|dkr!tdnt|tkrBtdn|jttkrftdnt|dd}|t|krt dn|}t |dd|||_ t|dd |_ t|d d |_ t|d d |_t|d d |_t|d d|_||_|dd |_t |d d|||_t |dd|||_t |dd|||_t|dd|_t|dd|_t |dd||}|jtkr6|j jdr6t|_n|jtkrd}g}xtdD]u} y<t|||d} t||d|d} Wntk rPYnX|j| | f|d7}q^Wt|d} t|dd} || | f|_ n|j!r6|j j"d|_ n|rb|jt#krb|d|j |_ n|S)zAConstruct a TarInfo object from a 512 byte bytes object. rz empty headerztruncated headerzend of file headerz bad checksumrlt|ii i)iIiQiYirirriii)$r$rnrrocountr%rpr@rKr=r1r~r\rrrrrrrr r!rrAREGTYPErrGNUTYPE_SPARSEr9r<rboolrisdirrstrip GNU_TYPES)r rJr(r)robjrrstructsr?rnumbytes isextendedorigsizer*r*r+frombufsZ  ! "  zTarInfo.frombufcCsP|jjt}|j||j|j}|jjt|_|j|S)zOReturn the next TarInfo object from TarFile object tarfile. ) rrPrr)r(r)rr _proc_member)r rrJr$r*r*r+ fromtarfile:szTarInfo.fromtarfilecCst|jttfkr"|j|S|jtkr>|j|S|jtttfkrc|j |S|j |SdS)zYChoose the right processing method depending on the type and call it. N) rrr _proc_gnulongr _proc_sparserrSOLARIS_XHDTYPE _proc_pax _proc_builtin)r}rr*r*r+r*Os   zTarInfo._proc_membercCsx|jj|_|j}|js6|jtkrO||j|j7}n||_|j |j |j |j |S)zfProcess a builtin type or an unknown type which will be treated as a regular file. ) rrrisregrSUPPORTED_TYPES_blockrr_apply_pax_inforr(r))r}rrr*r*r+r0\s  zTarInfo._proc_builtinc Cs|jj|j|j}y|j|}Wntk rQtdYnX|j|_|jt krt ||j |j |_ n-|jtkrt ||j |j |_n|S)zSProcess the blocks that hold a GNU longname or longlink member. z missing or bad subsequent header)rrPr3rr+rmrqrrrr1r(r)r~rr)r}rrJnextr*r*r+r,ms  zTarInfo._proc_gnulongc Cs&|j\}}}|`x|r|jjt}d}xtdD]}y<t|||d}t||d|d} Wntk rPYnX|r| r|j|| fn|d7}qFWt|d}qW||_ |jj |_ |j |j |j |_||_ |S)z8Process a GNU sparse header plus extra headers. rrri)rrrPrr9r@r<rr rrrr3rr) r}rr%r'r(rJrr?rr&r*r*r+r-s( "    zTarInfo._proc_sparsec Cs|jj|j|j}|jtkr9|j}n|jj}tj d|}|dk r|j dj d|ds z.TarInfo._proc_gnusparse_01..zGNU.sparse.map,Nrr)splitrErFr)r}r5rrr*r*r+rAs zTarInfo._proc_gnusparse_01cCsd}g}|jjt}|jdd\}}t|}xjt||dkrd|kr||jjt7}n|jdd\}}|jt|qEW|jj|_t t |ddd|ddd|_ dS)z?Process a GNU tar extended sparse header, version 1.0. Ns rr) rrPrrKr:r$rrrrErFr)r}r5rrZfieldsrrJZnumberr*r*r+rCs  zTarInfo._proc_gnusparse_10c Csx|jD]\}}|dkr8t|d|q |dkr]t|dt|q |dkrt|dt|q |tkr |tkryt||}Wqtk rd}YqXn|dkr|jd}nt|||q q W|j|_dS) zoReplace fields with supplemental information from a previous pax extended or global header. zGNU.sparse.namerzGNU.sparse.sizerzGNU.sparse.realsizerrN) rsetattrr: PAX_FIELDSPAX_NUMBER_FIELDSr<r"rr)r}rr(r)rrr*r*r+r4&s"       zTarInfo._apply_pax_infoc Cs=y|j|dSWn"tk r8|j||SYnXdS)z1Decode a single field from a pax record. r7N)r/UnicodeDecodeError)r}rr(Zfallback_encodingZfallback_errorsr*r*r+r?=s zTarInfo._decode_pax_fieldcCs0t|t\}}|r(|d7}n|tS)z_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. r)rOr)r}rrTrUr*r*r+r3Es zTarInfo._blockcCs |jtkS)N)r REGULAR_TYPES)r}r*r*r+r1Nsz TarInfo.isregcCs |jS)N)r1)r}r*r*r+isfilePszTarInfo.isfilecCs |jtkS)N)rr)r}r*r*r+r!Rsz TarInfo.isdircCs |jtkS)N)rSYMTYPE)r}r*r*r+issymTsz TarInfo.issymcCs |jtkS)N)rLNKTYPE)r}r*r*r+islnkVsz TarInfo.islnkcCs |jtkS)N)rCHRTYPE)r}r*r*r+ischrXsz TarInfo.ischrcCs |jtkS)N)rBLKTYPE)r}r*r*r+isblkZsz TarInfo.isblkcCs |jtkS)N)rFIFOTYPE)r}r*r*r+isfifo\szTarInfo.isfifocCs |jdk S)N)r)r}r*r*r+issparse^szTarInfo.issparsecCs|jtttfkS)N)rrVrXrZ)r}r*r*r+isdev`sz TarInfo.isdevN)znamezmodezuidzgidzsizezmtimezchksumztypezlinknamezunamezgnamezdevmajorzdevminorzoffsetz offset_dataz pax_headerszsparseztarfilez_sparse_structsz _link_target)4rerfrgrh __slots__rrrpropertyrrrrrrDEFAULT_FORMATENCODINGrrrr classmethodr r staticmethodrrrrr)r+r*r0r,r-r/rBrArCr4r?r3r1rQr!rSrUrWrYr[r\r]r*r*r*r+rs`         1  3?    f             c@seZdZdZdZdZdZdZeZ e Z dZ e ZeZdddddddddddddd Zeddded d Zeddd d ZedddddZedddddZedddddZidd6dd6dd6dd6ZddZdd Zd!d"Zd#d$Zdddd%d&Zd'd(d)Zdd'dd*dd+d,Z dd-d.Z!d/dd0d1Z"d2d'd3d4Z#d5d6Z$d'd7d8Z%d9d:Z&d;d<Z'd=d>Z(d?d@Z)dAdBZ*dCdDZ+dEdFZ,dGdHZ-dIdJZ.dKdLZ/dddMdNZ0dOdPZ1ddQdRZ2dSdTZ3dUdVZ4dWdXZ5dYdZZ6d[d\Z7dS)]rz=The TarFile Class provides an interface to tar archives. rFrNrsrc Csidd6dd6dd6} || kr6tdn||_| ||_|s|jdkrtjj| rd|_d|_nt||j}d|_nf|d krt|d rt |j t t fr|j }nt|d r|j|_nd |_|r%tjj |nd |_ ||_|d k rO||_n|d k rg||_n|d k r||_n|d k r||_n|d k r||_n| |_| d k r|jtkr| |_n i|_| d k r| |_n| d k r| |_nd|_g|_d|_|jj|_i|_yF|jdkr{d |_|j |_n|jdkr,x|jj!|jy&|jj"|}|jj#|Wqt$k r|jj!|jPYqt%k r$}zt&t |WYd d }~XqXqWn|jd krd |_|jr|jj'|jj(}|jj)||jt*|7_qnWn-|js|jj+nd |_YnXd S)aOpen an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. rbrszr+bawbrtzmode must be 'r', 'a' or 'w'FNr~r\Taw),r<r\_modervrexists bltn_openrr{rr~rrAabspathrrFr dereference ignore_zerosr(r)rrdebug errorlevelrmembers_loadedrrinodes firstmemberr5rr+rrprmrjr rrQr$r)r}r~r\rrFrrlrmr(r)rrnroZmodeserJr*r*r+r~s    "     !                        ,    zTarFile.__init__c KsG| r| rtdn|dkrx|jD]}t||j|}|dk rj|j}ny||d||SWq3ttfk r} z$|dk r|j|nw3WYdd} ~ Xq3Xq3WtdnVd|krh|jdd\} }| pd} |pd}||jkrEt||j|}ntd |||| ||Sd |kr|jd d\} }| pd} |pd}| dkrtd nt|| |||} y||| | |} Wn| j YnXd | _ | S|dkr7|j ||||StddS)aOpen a tar archive for reading, writing or appending. Return an appropriate TarFile class. mode: 'r' or 'r:*' open for reading with transparent compression 'r:' open for reading exclusively uncompressed 'r:gz' open for reading with gzip compression 'r:bz2' open for reading with bzip2 compression 'r:xz' open for reading with lzma compression 'a' or 'a:' open for appending, creating the file if necessary 'w' or 'w:' open for writing without compression 'w:gz' open for writing with gzip compression 'w:bz2' open for writing with bzip2 compression 'w:xz' open for writing with lzma compression 'r|*' open a stream of tar blocks with transparent compression 'r|' open an uncompressed stream of tar blocks for reading 'r|gz' open a gzip compressed stream of tar blocks 'r|bz2' open a bzip2 compressed stream of tar blocks 'r|xz' open an lzma compressed stream of tar blocks 'w|' open an uncompressed stream for writing 'w|gz' open a gzip compressed stream for writing 'w|bz2' open a bzip2 compressed stream for writing 'w|xz' open an lzma compressed stream for writing znothing to openrsr:*Nz%file could not be opened successfully:rrzunknown compression type %r|rtzmode must be 'r' or 'w'Frezundiscernible mode)rsru)rsrt)rert) r< OPEN_METHr`rrjrkrrKrrrtaropen) r r~r\rrkwargsrfuncZ saved_posrtr[streamrr*r*r+rsN             z TarFile.opencKs.|dkrtdn|||||S)zCOpen uncompressed tar archive name for reading or writing. rsrertzmode must be 'r', 'a' or 'w')rsrert)r<)r r~r\rrzr*r*r+ry;s zTarFile.taropenrcKs2|d krtdnyddl}|jWn$ttfk rXtdYnXy |j||d||}Wn<tk r|dk r|dkrtdnYnXy|j||||}WnNtk r|j |dkr tdnYn|j YnXd |_ |S) zkOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. rsrtzmode must be 'r' or 'w'rNzgzip module is not availablerVznot a gzip fileF)rsrt) r<gzipZGzipFilerAttributeErrorrkrrjryrr)r r~r\r compresslevelrzr}rr*r*r+gzopenCs2          zTarFile.gzopencKs|d krtdnyddl}Wntk rKtdYnX|j|p[||d|}y|j||||}WnTttfk r|j|dkrt dnYn|jYnXd |_ |S) zlOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. rsrtzmode must be 'r' or 'w'.rNzbz2 module is not availablerznot a bzip2 fileF)rsrt) r<rrrkZBZ2FileryrEOFErrorrrjr)r r~r\rrrzrrr*r*r+bz2openes(       zTarFile.bz2opencKs|d krtdnyddl}Wntk rKtdYnX|j|p[||d|}y|j||||}WnW|jtfk r|j|dkrt dnYn|jYnXd |_ |S) zkOpen lzma compressed tar archive name for reading or writing. Appending is not allowed. rsrtzmode must be 'r' or 'w'rNzlzma module is not availablepresetznot an lzma fileF)rsrt) r<rrrkZLZMAFileryrrrrjr)r r~r\rrrzrrr*r*r+xzopens&      zTarFile.xzopenryrrrrrrrc Cs|jr dSd|_z|jdkr|jjttd|jtd7_t|jt\}}|dkr|jjtt|qnWd|j s|jj nXdS)zlClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NTrgrr) rr\rrQr%rrrO RECORDSIZErr)r}rTrUr*r*r+rs   " z TarFile.closecCs2|j|}|dkr.td|n|S)aReturn a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurrence is assumed to be the most up-to-date version. Nzfilename %r not found) _getmemberKeyError)r}r~rr*r*r+ getmembers zTarFile.getmembercCs'|j|js |jn|jS)zReturn the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive. )_checkrq_loadrp)r}r*r*r+ getmemberss   zTarFile.getmemberscCsdd|jDS)zReturn the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). cSsg|]}|jqSr*)r~)rGrr*r*r+rIs z$TarFile.getnames..)r)r}r*r*r+getnamesszTarFile.getnamesc Cs^|jd|dk r%|j}n|dkr:|}ntjj|\}}|jtjd}|jd}|j}||_ |dkrt tdr|j rtj |}qtj |}ntj|j}d}|j}t j|r|j|jf} |j rj|jdkrj| |jkrj||j| krjt} |j| }qt} | dr||j| zlink to )rrdrZr[r\r rr!rrWrYrrrrZ localtimerr~r!rSrrUrc)r}verboserr*r*r+rE;s&  !#  z TarFile.listfilterc Cs|jd|dkr"|}n|dk rtddl}|jdtd||rt|jdd|dSn|jdk rtjj||jkr|jdd|dS|jd||j ||}|dkr|jdd |dS|dk r;||}|dkr;|jdd|dSn|j rrt |d }|j ||WdQXn|j r|j ||rxTtj|D]@}|jtjj||tjj||||d |qWqn |j |dS) a~Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' to False. `exclude' is a function that should return True for each filename to be excluded. `filter' is a function that expects a TarInfo object argument and returns the changed TarInfo object, if it returns None the TarInfo object will be excluded from the archive. rgNrzuse the filter argument insteadrztarfile: Excluded %rztarfile: Skipped %rrztarfile: Unsupported type %rrdr)rrWrXrY_dbgr~rvrrkrr1rjaddfiler!listdiraddr) r}r~rZ recursiveZexcluderrWrfr*r*r+rXsB        *       *z TarFile.addcCs|jdtj|}|j|j|j|j}|jj||jt |7_|dk rt ||j|j t |j t \}}|dkr|jjtt ||d7}n|j|t 7_n|jj|dS)a]Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. rgNrr)rrrrFr(r)rrQrr$rNrrOrr%rpr)r}rrrJrTrUr*r*r+rs    zTarFile.addfile.cCsOg}|dkr|}nx_|D]W}|jr\|j|tj|}d|_n|j||d|j q"W|jddd|jx|D]}tjj ||j }y4|j |||j |||j ||Wqtk rF}z.|jdkr n|jdd|WYdd}~XqXqWdS) aMExtract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmembers(). Ni set_attrskeycSs|jS)N)r~)rer*r*r+sz$TarFile.extractall..rz tarfile: %s)r!rrr\extractsortreverservrrr~chownutimechmodriror)r}rrpZ directoriesrdirpathrtr*r*r+ extractalls*      !  zTarFile.extractallrcCsa|jdt|tr.|j|}n|}|jr^tjj||j|_ ny,|j |tjj||j d|Wnt k r}zc|j dkrnI|jdkr|jdd|jn |jdd|j|jfWYdd}~XnNtk r\}z.|j dkr6n|jdd|WYdd}~XnXdS)axExtract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible. `member' may be a filename or a TarInfo object. You can specify a different directory using `path'. File attributes (owner, mtime, mode) are set unless `set_attrs' is False. rsrrNrz tarfile: %sztarfile: %s %r)rrrrrUrvrrrr_extract_memberr~rrofilenamerstrerrorri)r}memberrrrrtr*r*r+rs&  ! 2zTarFile.extractcCs|jdt|tr.|j|}n|}|jsO|jtkr_|j||S|jsw|j rt|j t rt dq|j |j|SndSdS)zExtract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file or a link, an io.BufferedReader object is returned. Otherwise, None is returned. rsz'cannot extract (sym)link as file objectN)rrrrr1rr2 fileobjectrUrSrrrl extractfile_find_link_target)r}rrr*r*r+rs zTarFile.extractfilecCs|jd}|jdtj}tjj|}|r_tjj| r_tj|n|jsw|j r|j dd|j |j fn|j d|j |j r|j||n|jr|j||n|jr |j||n|js"|jr5|j||n]|jsM|j r`|j||n2|jtkr|j||n|j|||r|j|||j s|j|||j||qndS)z\Extract the TarInfo object tarinfo to a physical file called targetpath. rrz%s -> %sN)r"rrvrrdirnamerimakedirsrUrSrr~rr1makefiler!makedirr[makefiforWrYmakedevmakelinkrr2 makeunknownrrr)r}r targetpathrZ upperdirsr*r*r+rs4#    zTarFile._extract_memberc Cs-ytj|dWntk r(YnXdS)z,Make a directory called targetpath. iN)rvmkdirFileExistsError)r}rrr*r*r+rGs zTarFile.makedirc Cs|j}|j|jt|d}|jdk rwxP|jD],\}}|j|t|||tqDWnt|||jt|j|j|jWdQXdS)z'Make a file called targetpath. rfN) rrrrjrrNrjrtruncate)r}rrsourcetargetrrr*r*r+rQs  zTarFile.makefilecCs+|j|||jdd|jdS)zYMake a file from a TarInfo object with an unknown type at targetpath. rz9tarfile: Unknown file type %r, extracted as regular file.N)rrr)r}rrr*r*r+r`s zTarFile.makeunknowncCs/ttdrtj|n tddS)z'Make a fifo called targetpath. mkfifozfifo not supported by systemN)r{rvrri)r}rrr*r*r+rhszTarFile.makefifocCsttd s ttd r/tdn|j}|jrT|tjO}n |tjO}tj||tj |j |j dS)zzShow listing of a tarfilez-ez --extractnargs+ zExtract tarfile into target dirz-cz--createzCreate tarfile from sourcesz-tz--testzTest if a tarfile is validrsrz{!r} is a tar archive.rz{!r} is not a tar archive. zr:*rrrrz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.rz.gzz.tgzrz.xzz.txzrz.bz2z.tbzz.tbz2z.tb2zw:rtz{!r} file created.)rr)rr)argparseArgumentParser add_argumentZadd_mutually_exclusive_group parse_argsZtestrrrrcrarrrFexitrErrr$rvcurdirZ format_helprcreatepoprsplitextr)rrparserr;argsrRrZtfrrZtar_name_ZextZ compressionsZtar_modeZ tar_files file_namer*r*r+main s                        r __main__)brhversion __author__Z__date__Z __cvsid__ __credits__builtinsrrjrarvrrMrZrrIrr9rrrr~NotImplementedErrorrr NameError__all__r%rrrrrrr rrrTrRrVrXrrZZCONTTYPErrrrrr.rrBrr`r2rPr#rMr@rr:rNr~ragetfilesystemencodingr,r1r@rGrKrNr[rd Exceptionrrirjrkrlrmrnrorpr=rqrrrobjectrrBufferedReaderrrrrrr rer*r*r*r+s                             h )  Z