2
Python 3.4에서 "심볼릭 링크를 따르십시오"기능으로 tar + gzip 압축을 어떻게 사용할 수 있습니까? 문제는 : ": GZ w"모드하지만 ("역 참조"옵션을 파이썬 tarfile : 기호 링크를 따라 tar + gzip 압축을 사용하는 방법?
- tarfile.open는()를 지원 GZ "모드
코드 :
...
mode = ""
if bckentry['method'] == "tar":
mode = "w"
elif bckentry['method'] == "targz":
mode = "w:gz"
archive = tarfile.TarFile(name=filepath, mode=mode)
archive.dereference = True if bckentry['followsym'] == "yes" else False
# archive = tarfile.open(filepath, mode=mode)
if bckentry['withpath'] == 'yes':
for entry in bckentry['include_dirs']:
archive.add(entry, filter=self.filter_tar)
elif bckentry['withpath'] == 'no':
for entry in bckentry['include_dirs']:
archive.add(entry, arcname=os.path.basename(entry), filter=self.filter_tar)
...
을 : 당신은 그냥 키워드 인수로 전달하면
따라서 당신은 그들 중 하나와
dereference
을 사용할 수 있습니다! 고마워, 나는 설명서를 읽고 그냥이 명백한 방법을 시도하지 않았다. – Balint