<s> import optparse <EOL> import os <EOL> import sys <EOL> import django . contrib . staticfiles . finders <EOL> import django . core . files . storage <EOL> import django . core . management . base <EOL> from static_precompiler import exceptions , settings , utils <EOL> def get_scanned_dirs ( ) : <EOL> dirs = set ( ) <EOL> if settings . STATIC_ROOT : <EOL> dirs . add ( settings . STATIC_ROOT ) <EOL> for finder in django . contrib . staticfiles . finders . get_finders ( ) : <EOL> if hasattr ( finder , "<STR_LIT>" ) : <EOL> for storage in finder . storages . values ( ) : <EOL> if isinstance ( storage , django . core . files . storage . FileSystemStorage ) : <EOL> dirs . add ( storage . location ) <EOL> return sorted ( dirs ) <EOL> class Command ( django . core . management . base . NoArgsCommand ) : <EOL> help = "<STR_LIT>" <EOL> requires_model_validation = False <EOL> option_list = django . core . management . base . NoArgsCommand . option_list + ( <EOL> optparse . make_option ( "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> dest = "<STR_LIT>" , <EOL> default = False , <EOL> help = "<STR_LIT>" ) , <EOL> optparse . make_option ( "<STR_LIT>" , <EOL> action = "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> default = True , <EOL> help = "<STR_LIT>" ) , <EOL> ) <EOL> def handle_noargs ( self , ** options ) : <EOL> if not options [ "<STR_LIT>" ] and not options [ "<STR_LIT>" ] : <EOL> sys . exit ( "<STR_LIT>" ) <EOL> scanned_dirs = get_scanned_dirs ( ) <EOL> verbosity = int ( options [ "<STR_LIT>" ] ) <EOL> compilers = utils . get_compilers ( ) . values ( ) <EOL> if not options [ "<STR_LIT>" ] or options [ "<STR_LIT>" ] : <EOL> for scanned_dir in scanned_dirs : <EOL> for dirname , dirnames , filenames in os . walk ( scanned_dir ) : <EOL> for filename in filenames : <EOL> path = os . path . join ( dirname , filename ) [ len ( scanned_dir ) : ] <EOL> if path . startswith ( "<STR_LIT:/>" ) : <EOL> path = path [ <NUM_LIT:1> : ] <EOL> for compiler in compilers : <EOL> if compiler . is_supported ( path ) : <EOL> try : <EOL> compiler . handle_changed_file ( path , verbosity = options [ "<STR_LIT>" ] ) <EOL> except ( exceptions . StaticCompilationError , ValueError ) as e : <EOL> print ( e ) <EOL> break <EOL> if options [ "<STR_LIT>" ] : <EOL> from static_precompiler . watch import watch_dirs <EOL> watch_dirs ( scanned_dirs , verbosity ) </s>
