added bunker.files.tarfile.RewriteableTarFile.has_file

This commit is contained in:
Daniel Knüttel 2019-03-13 14:01:50 +01:00
parent 48985cc57d
commit 327a585eac

View File

@ -98,3 +98,16 @@ class RewriteableTarFile(object):
new_handle.addfile(member, handle.extractfile(member))
new_handle.close()
def has_file(self, member):
if(isinstance(member, tarfile.TarInfo)):
member_name = member.name
elif(isinstance(member, str)):
member_name = member
else:
raise TypeError("member must be TarInfo or str, not {}".format(type(member)))
handle = self._open_handle()
return member_name in handle.getnames()