added bunker.files.tarfile.RewriteableTarFile.has_file
This commit is contained in:
parent
48985cc57d
commit
327a585eac
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user