#NEWLINE# def main( argv = sys . argv ) : #NEWLINE# #INDENT# logging . basicConfig ( format = '%(message)s' ) #NEWLINE# usage = 'usage: %prog [OPTIONS...] [DIRS]' #NEWLINE# version = ( '%prog ' + __version__ ) #NEWLINE# parser = optparse . OptionParser ( prog = 'sources' , usage = usage , version = version , description = __doc__ , formatter = _NoReflowFormatter ( ) ) #NEWLINE# parser . add_option ( '-q' , '--quiet' , dest = 'log_level' , action = 'store_const' , const = logging . WARNING , help = 'quieter output' ) #NEWLINE# parser . add_option ( '-v' , '--verbose' , dest = 'log_level' , action = 'store_const' , const = logging . DEBUG , help = 'more verbose output' ) #NEWLINE# parser . add_option ( '-n' , '--dry-run' , action = 'store_true' , help = 'dry-run' ) #NEWLINE# parser . add_option ( '-l' , '--list' , dest = 'action' , action = 'store_const' , const = 'list' , help = 'list sources' ) #NEWLINE# parser . add_option ( '-d' , '--dir' , help = "directory from which '.sources' config file is sought; default is cwd" ) #NEWLINE# parser . add_option ( '-x' , '--exclude-submodules' , action = 'store_true' , help = 'do not pull submodules/checkout externals when cloning/getting' ) #NEWLINE# parser . set_defaults ( log_level = logging . INFO , action = 'get' , dry_run = False , dir = None , exclude_submodules = False ) #NEWLINE# ( opts , args ) = parser . parse_args ( ) #NEWLINE# log . setLevel ( opts . log_level ) #NEWLINE# config = find_config ( dir = opts . dir ) #NEWLINE# if ( opts . action == 'list' ) : #NEWLINE# #INDENT# verbose = ( opts . log_level <= logging . DEBUG ) #NEWLINE# if args : #NEWLINE# #INDENT# for base_dir in args : #NEWLINE# #INDENT# list_sources ( config , base_dir , verbose = verbose ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# list_sources ( config , ( opts . dir or os . getcwd ( ) ) , verbose = verbose ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( opts . action == 'get' ) : #NEWLINE# #INDENT# if args : #NEWLINE# #INDENT# for base_dir in args : #NEWLINE# #INDENT# get_sources ( config , base_dir , opts . exclude_submodules ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# get_sources ( config , ( opts . dir or os . getcwd ( ) ) , opts . exclude_submodules ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'unexpected action: %r' % opts . action ) )