#NEWLINE# def add_git_remotes( self , git_remote_name ) : #NEWLINE# #INDENT# 'Add the git remotes for this package.\n\n    Adds the upstream and local remote names to the\n    git_remote_upstream and git_remote_local attributes.\n\n    Args:\n      git_remote_name: Local remote to use from each package.  This is only\n        required if more than one remote is present in each package.  If this\n        remote is not present and only *one* remote is present the sole remote\n        is used instead.\n\n    Raises:\n      subprocess.CalledProcessError: If git encounters an error.\n      GitError: If there is a configuration problem the git working copies.\n    ' #NEWLINE# assert self . url #NEWLINE# assert self . path #NEWLINE# local_remotes = [ ] #NEWLINE# for ( remote , url ) in Package . get_git_remotes ( self . path , self . subprocess_runner ) : #NEWLINE# #INDENT# if ( not remote . startswith ( GIT_GENERATED_PREFIX ) ) : #NEWLINE# #INDENT# local_remotes . append ( ( remote , url ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not local_remotes ) : #NEWLINE# #INDENT# raise GitError ( ( 'No remotes in package %s (%s).' % ( self . name , self . path ) ) ) #NEWLINE# #UNINDENT# if git_remote_name : #NEWLINE# #INDENT# local_remotes_dict = dict ( local_remotes ) #NEWLINE# if ( git_remote_name in local_remotes_dict ) : #NEWLINE# #INDENT# local_remotes = [ ( git_remote_name , local_remotes_dict [ git_remote_name ] ) ] #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( local_remotes ) > 1 ) : #NEWLINE# #INDENT# raise GitError ( ( 'Too many remotes (%s) in package %s.  This script can only support one remote per package.' % ( str ( local_remotes ) , url . name ) ) ) #NEWLINE# #UNINDENT# self . git_remote_upstream = Package . add_git_remote ( ( GIT_REMOTE_PREFIX_UPSTREAM + self . name ) , self . url , self . working_copy , self . subprocess_runner ) #NEWLINE# ( _ , local_url ) = local_remotes [ 0 ] #NEWLINE# self . git_remote_local = Package . add_git_remote ( ( GIT_REMOTE_PREFIX_LOCAL + self . name ) , local_url , self . working_copy , self . subprocess_runner )