[postprocessor:zip] delete directory (#85)
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
from .common import PostProcessor
|
from .common import PostProcessor
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class ZipPP(PostProcessor):
|
class ZipPP(PostProcessor):
|
||||||
@@ -32,9 +33,10 @@ class ZipPP(PostProcessor):
|
|||||||
algorithm)
|
algorithm)
|
||||||
algorithm = "store"
|
algorithm = "store"
|
||||||
|
|
||||||
path = pathfmt.realdirectory + self.ext
|
self.path = pathfmt.realdirectory
|
||||||
self.zfile = zipfile.ZipFile(
|
self.zfile = zipfile.ZipFile(
|
||||||
path, "a", self.COMPRESSION_ALGORITHMS[algorithm], True)
|
self.path + self.ext, "a",
|
||||||
|
self.COMPRESSION_ALGORITHMS[algorithm], True)
|
||||||
|
|
||||||
def run(self, pathfmt):
|
def run(self, pathfmt):
|
||||||
# 'NameToInfo' is not officially documented, but it's available
|
# 'NameToInfo' is not officially documented, but it's available
|
||||||
@@ -47,5 +49,11 @@ class ZipPP(PostProcessor):
|
|||||||
def finalize(self):
|
def finalize(self):
|
||||||
self.zfile.close()
|
self.zfile.close()
|
||||||
|
|
||||||
|
if self.delete:
|
||||||
|
try:
|
||||||
|
os.rmdir(self.path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
__postprocessor__ = ZipPP
|
__postprocessor__ = ZipPP
|
||||||
|
|||||||
Reference in New Issue
Block a user