예제 #1
0
	def _closeSubTar(self, tar, subTarTuple):
		if subTarTuple:
			(subTarFile, subTarFileObj, subTarFileName) = subTarTuple
			subTarFile.close()
			try: # Python 3.2 does not close the wrapping gzip file object if an external file object is given
				subTarFile.fileobj.close()
			except Exception:
				clear_current_exception()
			subTarFileObj.seek(0)
			subTarFileInfo = tarfile.TarInfo(subTarFileName)
			subTarFileInfo.size = len(subTarFileObj.getvalue())
			tar.addfile(subTarFileInfo, subTarFileObj)
예제 #2
0
	def _close_nested_tar(self, outer_tar, nested_tar):
		# Function to close all contained outer_tar objects
		if nested_tar:
			nested_tar.close()
			try:  # Python 3.2 does not close the wrapping gzip file object
				nested_tar.fileobj.close()  # if an external file object is given
			except Exception:
				clear_current_exception()
			nested_tar.nested_tar_fp.seek(0)
			nested_tar_info = tarfile.TarInfo(nested_tar.nested_fn)
			nested_tar_info.size = len(nested_tar.nested_tar_fp.getvalue())
			outer_tar.addfile(nested_tar_info, nested_tar.nested_tar_fp)
예제 #3
0
 def getTarInfo(self):
     info = tarfile.TarInfo(self.name)
     info.size = self.size
     return (info, self)