<s> __revision__ = "<STR_LIT>" <EOL> __doc__ = """<STR_LIT>""" <EOL> import cmd <EOL> import copy <EOL> import os <EOL> import re <EOL> import shlex <EOL> import sys <EOL> try : <EOL> import readline <EOL> except ImportError : <EOL> pass <EOL> class SConsInteractiveCmd ( cmd . Cmd ) : <EOL> """<STR_LIT>""" <EOL> synonyms = { <EOL> '<STR_LIT:b>' : '<STR_LIT>' , <EOL> '<STR_LIT:c>' : '<STR_LIT>' , <EOL> '<STR_LIT:h>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def __init__ ( self , ** kw ) : <EOL> cmd . Cmd . __init__ ( self ) <EOL> for key , val in kw . items ( ) : <EOL> setattr ( self , key , val ) <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> self . shell_variable = '<STR_LIT>' <EOL> else : <EOL> self . shell_variable = '<STR_LIT>' <EOL> def default ( self , argv ) : <EOL> print "<STR_LIT>" % argv [ <NUM_LIT:0> ] <EOL> def onecmd ( self , line ) : <EOL> line = line . strip ( ) <EOL> if not line : <EOL> print self . lastcmd <EOL> return self . emptyline ( ) <EOL> self . lastcmd = line <EOL> if line [ <NUM_LIT:0> ] == '<STR_LIT:!>' : <EOL> line = '<STR_LIT>' + line [ <NUM_LIT:1> : ] <EOL> elif line [ <NUM_LIT:0> ] == '<STR_LIT:?>' : <EOL> line = '<STR_LIT>' + line [ <NUM_LIT:1> : ] <EOL> if os . sep == '<STR_LIT:\\>' : <EOL> line = line . replace ( '<STR_LIT:\\>' , '<STR_LIT>' ) <EOL> argv = shlex . split ( line ) <EOL> argv [ <NUM_LIT:0> ] = self . synonyms . get ( argv [ <NUM_LIT:0> ] , argv [ <NUM_LIT:0> ] ) <EOL> if not argv [ <NUM_LIT:0> ] : <EOL> return self . default ( line ) <EOL> else : <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + argv [ <NUM_LIT:0> ] ) <EOL> except AttributeError : <EOL> return self . default ( argv ) <EOL> return func ( argv ) <EOL> def do_build ( self , argv ) : <EOL> """<STR_LIT>""" <EOL> import SCons . Node <EOL> import SCons . SConsign <EOL> import SCons . Script . Main <EOL> options = copy . deepcopy ( self . options ) <EOL> options , targets = self . parser . parse_args ( argv [ <NUM_LIT:1> : ] , values = options ) <EOL> SCons . Script . COMMAND_LINE_TARGETS = targets <EOL> if targets : <EOL> SCons . Script . BUILD_TARGETS = targets <EOL> else : <EOL> SCons . Script . BUILD_TARGETS = SCons . Script . _build_plus_default <EOL> nodes = SCons . Script . Main . _build_targets ( self . fs , <EOL> options , <EOL> targets , <EOL> self . target_top ) <EOL> if not nodes : <EOL> return <EOL> x = [ ] <EOL> for n in nodes : <EOL> x . extend ( n . alter_targets ( ) [ <NUM_LIT:0> ] ) <EOL> nodes . extend ( x ) <EOL> SCons . Script . Main . progress_display ( "<STR_LIT>" ) <EOL> seen_nodes = { } <EOL> def get_unseen_children ( node , parent , seen_nodes = seen_nodes ) : <EOL> def is_unseen ( node , seen_nodes = seen_nodes ) : <EOL> return node not in seen_nodes <EOL> return list ( filter ( is_unseen , node . children ( scan = <NUM_LIT:1> ) ) ) <EOL> def add_to_seen_nodes ( node , parent , seen_nodes = seen_nodes ) : <EOL> seen_nodes [ node ] = <NUM_LIT:1> <EOL> try : <EOL> rfile_method = node . rfile <EOL> except AttributeError : <EOL> return <EOL> else : <EOL> rfile = rfile_method ( ) <EOL> if rfile != node : <EOL> seen_nodes [ rfile ] = <NUM_LIT:1> <EOL> for node in nodes : <EOL> walker = SCons . Node . Walker ( node , <EOL> kids_func = get_unseen_children , <EOL> eval_func = add_to_seen_nodes ) <EOL> n = walker . get_next ( ) <EOL> while n : <EOL> n = walker . get_next ( ) <EOL> for node in seen_nodes . keys ( ) : <EOL> node . clear ( ) <EOL> node . set_state ( SCons . Node . no_state ) <EOL> node . implicit = None <EOL> SCons . SConsign . Reset ( ) <EOL> SCons . Script . Main . progress_display ( "<STR_LIT>" ) <EOL> def do_clean ( self , argv ) : <EOL> """<STR_LIT>""" <EOL> return self . do_build ( [ '<STR_LIT>' , '<STR_LIT>' ] + argv [ <NUM_LIT:1> : ] ) <EOL> def do_EOF ( self , argv ) : <EOL> print <EOL> self . do_exit ( argv ) <EOL> def _do_one_help ( self , arg ) : <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + arg ) <EOL> except AttributeError : <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + arg ) <EOL> except AttributeError : <EOL> doc = None <EOL> else : <EOL> doc = self . _doc_to_help ( func ) <EOL> if doc : <EOL> sys . stdout . write ( doc + '<STR_LIT:\n>' ) <EOL> sys . stdout . flush ( ) <EOL> else : <EOL> doc = self . strip_initial_spaces ( func ( ) ) <EOL> if doc : <EOL> sys . stdout . write ( doc + '<STR_LIT:\n>' ) <EOL> sys . stdout . flush ( ) <EOL> def _doc_to_help ( self , obj ) : <EOL> doc = obj . __doc__ <EOL> if doc is None : <EOL> return '<STR_LIT>' <EOL> return self . _strip_initial_spaces ( doc ) <EOL> def _strip_initial_spaces ( self , s ) : <EOL> lines = s . split ( '<STR_LIT:\n>' ) <EOL> spaces = re . match ( '<STR_LIT>' , lines [ <NUM_LIT:0> ] ) . group ( <NUM_LIT:0> ) <EOL> def strip_spaces ( l , spaces = spaces ) : <EOL> if l [ : len ( spaces ) ] == spaces : <EOL> l = l [ len ( spaces ) : ] <EOL> return l <EOL> lines = list ( map ( strip_spaces , lines ) ) <EOL> return '<STR_LIT:\n>' . join ( lines ) <EOL> def do_exit ( self , argv ) : <EOL> """<STR_LIT>""" <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def do_help ( self , argv ) : <EOL> """<STR_LIT>""" <EOL> if argv [ <NUM_LIT:1> : ] : <EOL> for arg in argv [ <NUM_LIT:1> : ] : <EOL> if self . _do_one_help ( arg ) : <EOL> break <EOL> else : <EOL> doc = self . _doc_to_help ( self . __class__ ) <EOL> if doc : <EOL> sys . stdout . write ( doc + '<STR_LIT:\n>' ) <EOL> sys . stdout . flush ( ) <EOL> def do_shell ( self , argv ) : <EOL> """<STR_LIT>""" <EOL> import subprocess <EOL> argv = argv [ <NUM_LIT:1> : ] <EOL> if not argv : <EOL> argv = os . environ [ self . shell_variable ] <EOL> try : <EOL> p = subprocess . Popen ( argv , shell = ( sys . platform == '<STR_LIT:win32>' ) ) <EOL> except EnvironmentError , e : <EOL> sys . stderr . write ( '<STR_LIT>' % ( argv [ <NUM_LIT:0> ] , e . strerror ) ) <EOL> else : <EOL> p . wait ( ) <EOL> def do_version ( self , argv ) : <EOL> """<STR_LIT>""" <EOL> sys . stdout . write ( self . parser . version + '<STR_LIT:\n>' ) <EOL> def interact ( fs , parser , options , targets , target_top ) : <EOL> c = SConsInteractiveCmd ( prompt = '<STR_LIT>' , <EOL> fs = fs , <EOL> parser = parser , <EOL> options = options , <EOL> targets = targets , <EOL> target_top = target_top ) <EOL> c . cmdloop ( ) </s>
