<s> import os <EOL> from django . core . management . base import BaseCommand <EOL> class Command ( BaseCommand ) : <EOL> help = '<STR_LIT>' <EOL> def handle ( self , * args , ** options ) : <EOL> from django . conf import settings <EOL> from lfs . core . models import Shop <EOL> from lfs . core . fields import thumbs <EOL> from lfs . catalog . settings import THUMBNAIL_SIZES <EOL> from lfs . catalog . models import Category <EOL> from lfs . catalog . models import Image <EOL> for m in [ Shop , Category , Image ] : <EOL> for o in m . objects . all ( ) : <EOL> img_file = getattr ( o , '<STR_LIT:image>' ) <EOL> if img_file . name : <EOL> self . stdout . write ( "<STR_LIT>" % img_file . name ) <EOL> for size in THUMBNAIL_SIZES : <EOL> ( w , h ) = size <EOL> split = img_file . name . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> thumb_name = '<STR_LIT>' % ( split [ <NUM_LIT:0> ] , w , h , split [ <NUM_LIT:1> ] ) <EOL> if os . path . isfile ( "<STR_LIT>" % ( settings . MEDIA_ROOT , thumb_name ) ) : <EOL> self . stdout . write ( "<STR_LIT>" % ( w , h ) ) <EOL> continue <EOL> thumb_content = thumbs . generate_thumb ( img_file , size , split [ <NUM_LIT:1> ] ) <EOL> thumb_name_ = img_file . storage . save ( thumb_name , thumb_content ) <EOL> self . stdout . write ( "<STR_LIT>" % ( w , h ) ) </s>
