

def extract(self, to_path):
    members = [member for member in self._archive.getmembers() if (member.name != 'pax_global_header')]
    leading = self.has_leading_dir(members)
    for member in members:
        name = member.name
        if leading:
            name = self.split_leading_dir(name)[1]
        filename = os.path.join(to_path, name)
        if member.isdir():
            if (filename and (not os.path.exists(filename))):
                os.makedirs(filename)
        else:
            try:
                extracted = self._archive.extractfile(member)
            except (KeyError, AttributeError) as exc:
                print(('In the tar file %s the member %s is invalid: %s' % (name, member.name, exc)))
            else:
                dirname = os.path.dirname(filename)
                if (dirname and (not os.path.exists(dirname))):
                    os.makedirs(dirname)
                with open(filename, 'wb') as outfile:
                    shutil.copyfileobj(extracted, outfile)
            finally:
                if extracted:
                    extracted.close()

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/utils/archive.py TarArchive.extract/original