<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import os <EOL> import shutil <EOL> import sys <EOL> import anvil . commands . util as commandutil <EOL> from anvil . manage import ManageCommand <EOL> class OverlayCommand ( ManageCommand ) : <EOL> def __init__ ( self ) : <EOL> super ( OverlayCommand , self ) . __init__ ( <EOL> name = '<STR_LIT>' , <EOL> help_short = '<STR_LIT>' , <EOL> help_long = __doc__ ) <EOL> self . _add_common_build_hints ( ) <EOL> self . completion_hints . extend ( [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:-c>' , '<STR_LIT>' , <EOL> ] ) <EOL> def create_argument_parser ( self ) : <EOL> parser = super ( OverlayCommand , self ) . create_argument_parser ( ) <EOL> self . _add_common_build_arguments ( parser , targets = True ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> required = True , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> parser . add_argument ( '<STR_LIT:-c>' , '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> return parser <EOL> def execute ( self , args , cwd ) : <EOL> ( result , all_target_outputs ) = commandutil . run_build ( cwd , args ) <EOL> if not result : <EOL> return False <EOL> if args . clean : <EOL> try : <EOL> shutil . rmtree ( args . output ) <EOL> except : <EOL> pass <EOL> if not os . path . isdir ( args . output ) : <EOL> os . makedirs ( args . output ) <EOL> all_target_outputs = list ( all_target_outputs ) <EOL> all_target_outputs . sort ( ) <EOL> checked_dirs = { } <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % ( args . output ) <EOL> skipped_links = <NUM_LIT:0> <EOL> for target_output in all_target_outputs : <EOL> rel_path = os . path . relpath ( target_output , cwd ) <EOL> rel_path_parts = rel_path . split ( os . sep ) <EOL> if rel_path_parts [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' ) : <EOL> rel_path = os . path . join ( * ( rel_path_parts [ <NUM_LIT:1> : ] ) ) <EOL> deploy_path = os . path . normpath ( os . path . join ( args . output , rel_path ) ) <EOL> deploy_dir = os . path . dirname ( deploy_path ) <EOL> if not checked_dirs . get ( deploy_dir , False ) : <EOL> if not os . path . exists ( deploy_dir ) : <EOL> os . makedirs ( deploy_dir ) <EOL> checked_dirs [ deploy_dir ] = True <EOL> if not os . path . exists ( deploy_path ) : <EOL> print '<STR_LIT>' % ( rel_path , deploy_path ) <EOL> os . symlink ( target_output , deploy_path ) <EOL> else : <EOL> skipped_links += <NUM_LIT:1> <EOL> if skipped_links : <EOL> print '<STR_LIT>' % ( skipped_links ) <EOL> return <NUM_LIT:0> if result else <NUM_LIT:1> </s>
