Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Lars =?iso-8859-1?Q?Gust=E4bel?= Newsgroups: comp.lang.python Subject: Re: tarfile : read from a socket? Date: Thu, 11 Feb 2016 18:27:28 +0100 Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de elJdTqnkgoEKfgNEdr/l+Q61w9BRFFYi6Hqp8QWykxKg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'def': 0.13; 'thu,': 0.15; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cheers,': 0.22; 'cc:no real name:2**0': 0.22; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'skip:t 40': 0.27; 'yield': 0.27; 'print': 0.30; 'subject: : ': 0.30; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:88.198': 0.37; 'subject:from': 0.39; 'received:192': 0.39; 'received:de': 0.40; 'subject:read': 0.84 Mail-Followup-To: Lars =?iso-8859-1?Q?Gust=E4bel?= , Ulli Horlacher , python-list@python.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Virus-Scanned: clamav-milter 0.98.7 at tera X-Virus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102821 On Thu, Feb 11, 2016 at 04:41:43PM +0000, Ulli Horlacher wrote: > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) What about using an iterator? def myiter(tar): for t in tar: print "extracting", t.name yield t sfo = sock.makefile('r') taro = tarfile.open(fileobj=sfo,mode='r|') taro.extractall(members=myiter(taro),path=edir) Cheers, -- Lars Gustäbel lars@gustaebel.de