@ -38,11 +38,6 @@ class ImageProcessorNamespace:
self . lookup_dirs = lookup_dirs
self . web_path = web_path if web_path [ - 1 ] != " / " else web_path [ : - 1 ]
self . include_src = include_src
if not os . path . exists ( self . public_dir ) :
os . mkdir ( self . public_dir )
if not os . path . exists ( self . cache_dir ) :
os . mkdir ( self . cache_dir )
class ImageProcessorSearcher :
def get_lookup_dirs ( self ) - > list [ str ] :
@ -96,6 +91,8 @@ class ImageProcessorCacheSearcher(ImageProcessorSearcher):
def __init__ ( self , cache_dir : str ) :
self . cache_dir = cache_dir
if not os . path . exists ( self . cache_dir ) :
os . makedirs ( self . cache_dir , exist_ok = True )
def get_lookup_dirs ( self ) - > list [ str ] :
return [ self . cache_dir ]
@ -129,10 +126,16 @@ class ImageProcessorNamespaceSearcher(ImageProcessorSearcher):
return path . replace ( " $dir " , self . rel_dir )
def get_cache_dir ( self ) - > str :
return self . transform_path ( self . namespace . cache_dir )
cache_dir = self . transform_path ( self . namespace . cache_dir )
if not os . path . exists ( cache_dir ) :
os . makedirs ( cache_dir , exist_ok = True )
return cache_dir
def get_public_dir ( self ) - > str :
return self . transform_path ( self . namespace . public_dir )
public_dir = self . transform_path ( self . namespace . public_dir )
if not os . path . exists ( public_dir ) :
os . makedirs ( public_dir , exist_ok = True )
return public_dir
def get_web_path ( self ) - > str :
return self . transform_path ( self . namespace . web_path )