<s> import glob <EOL> from optparse import make_option <EOL> import os <EOL> from django . core . management . base import CommandError <EOL> from django . core . management . templates import TemplateCommand <EOL> from django . utils . importlib import import_module <EOL> import horizon <EOL> class Command ( TemplateCommand ) : <EOL> args = "<STR_LIT>" <EOL> option_list = TemplateCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> make_option ( '<STR_LIT>' , <EOL> dest = '<STR_LIT:target>' , <EOL> action = '<STR_LIT:store>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , ) <EOL> template = os . path . join ( horizon . __path__ [ <NUM_LIT:0> ] , "<STR_LIT>" , "<STR_LIT>" ) <EOL> help = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def handle ( self , panel_name = None , ** options ) : <EOL> if panel_name is None : <EOL> raise CommandError ( "<STR_LIT>" ) <EOL> if options . get ( '<STR_LIT>' ) is None : <EOL> raise CommandError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> dashboard_path = options . get ( '<STR_LIT>' ) <EOL> dashboard_mod_path = "<STR_LIT:.>" . join ( [ dashboard_path , "<STR_LIT>" ] ) <EOL> try : <EOL> dashboard_mod = import_module ( dashboard_mod_path ) <EOL> options [ "<STR_LIT>" ] = dashboard_path <EOL> options [ "<STR_LIT>" ] = dashboard_path . split ( "<STR_LIT:.>" ) [ - <NUM_LIT:1> ] <EOL> except ImportError : <EOL> raise CommandError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % options . get ( "<STR_LIT>" ) ) <EOL> target = options . pop ( "<STR_LIT:target>" , None ) <EOL> if target == "<STR_LIT>" : <EOL> target = os . path . join ( os . path . dirname ( dashboard_mod . __file__ ) , <EOL> panel_name ) <EOL> if not os . path . exists ( target ) : <EOL> try : <EOL> os . mkdir ( target ) <EOL> except OSError as exc : <EOL> raise CommandError ( "<STR_LIT>" <EOL> % exc ) <EOL> if not options . get ( "<STR_LIT>" , None ) : <EOL> options [ "<STR_LIT>" ] = self . template <EOL> options [ "<STR_LIT>" ] . extend ( [ "<STR_LIT>" , "<STR_LIT:html>" ] ) <EOL> try : <EOL> import_module ( panel_name ) <EOL> except ImportError : <EOL> pass <EOL> else : <EOL> raise CommandError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % panel_name ) <EOL> super ( Command , self ) . handle ( '<STR_LIT>' , panel_name , target , ** options ) <EOL> if not target : <EOL> target = os . path . join ( os . curdir , panel_name ) <EOL> file_names = glob . glob ( os . path . join ( target , "<STR_LIT>" ) ) <EOL> for filename in file_names : <EOL> os . rename ( filename , filename [ : - <NUM_LIT:5> ] ) </s>
