@ -34,16 +34,24 @@ class ClassifyPP(PostProcessor):
def prepare ( self , pathfmt ) :
def prepare ( self , pathfmt ) :
ext = pathfmt . extension
ext = pathfmt . extension
if ext in self . mapping :
if ext in self . mapping :
self . _dir = pathfmt . realdirectory + os . sep + self . mapping [ ext ]
# set initial paths to enable download skips
pathfmt . realpath = self . _dir + os . sep + pathfmt . filename
self . _build_paths ( pathfmt , self . mapping [ ext ] )
else :
self . _dir = None
def run ( self , pathfmt ) :
def run ( self , pathfmt ) :
if self . _dir :
ext = pathfmt . extension
os . makedirs ( self . _dir , exist_ok = True )
if ext in self . mapping :
# rebuild paths in case the filename extension changed
path = self . _build_paths ( pathfmt , self . mapping [ ext ] )
os . makedirs ( path , exist_ok = True )
@staticmethod
def _build_paths ( pathfmt , extra ) :
path = pathfmt . realdirectory + os . sep + extra
pathfmt . realpath = path + os . sep + pathfmt . filename
pathfmt . path = ( pathfmt . directory + os . sep +
extra + os . sep + pathfmt . filename )
return path
__postprocessor__ = ClassifyPP
__postprocessor__ = ClassifyPP