<s> import imp <EOL> from django . conf import settings <EOL> from django . core . management . base import BaseCommand <EOL> from django . utils . importlib import import_module <EOL> from optparse import make_option <EOL> class Command ( BaseCommand ) : <EOL> help = '<STR_LIT>' <EOL> option_list = BaseCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) , <EOL> ) <EOL> def handle ( self , * args , ** options ) : <EOL> if options . get ( '<STR_LIT>' ) : <EOL> for item in options [ '<STR_LIT>' ] : <EOL> if '<STR_LIT:=>' in item : <EOL> key , val = item . split ( '<STR_LIT:=>' ) <EOL> else : <EOL> key , val = item , True <EOL> options [ key ] = val <EOL> if not args : <EOL> args = [ ] <EOL> for app in settings . INSTALLED_APPS : <EOL> if args and app not in args : <EOL> continue <EOL> try : <EOL> app_path = import_module ( app ) . __path__ <EOL> except AttributeError : <EOL> continue <EOL> try : <EOL> imp . find_module ( '<STR_LIT>' , app_path ) <EOL> except ImportError : <EOL> continue <EOL> module = import_module ( '<STR_LIT>' % app ) <EOL> if hasattr ( module , '<STR_LIT>' ) : <EOL> self . stdout . write ( '<STR_LIT>' % app ) <EOL> module . generate_sampledata ( options ) <EOL> self . stdout . write ( '<STR_LIT>' ) </s>
