#NEWLINE# def update( self , feed , branch = None , name = None ) : #NEWLINE# #INDENT# ' Update a toolchain given a feed\n\n        ``feed`` can be:\n\n        * a path\n        * a url\n        * a git url (in this case branch and name cannot be None,\n          and ``feeds/<name>.xml`` must exist on the given branch)\n\n        ' #NEWLINE# ui . info ( ui . green , 'Updating from' , ui . reset , ui . blue , feed ) #NEWLINE# feed_parser = qitoolchain . feed . ToolchainFeedParser ( self . name ) #NEWLINE# feed_parser . parse ( feed , branch = branch , name = name ) #NEWLINE# self . strict_feed = feed_parser . strict_feed #NEWLINE# remote_packages = feed_parser . get_packages ( ) #NEWLINE# local_packages = self . packages . values ( ) #NEWLINE# to_add = list ( ) #NEWLINE# to_remove = list ( ) #NEWLINE# to_update = list ( ) #NEWLINE# svn_packages = [ x for x in remote_packages if isinstance ( x , qitoolchain . svn_package . SvnPackage ) ] #NEWLINE# other_packages = [ x for x in remote_packages if ( x not in svn_packages ) ] #NEWLINE# for remote_package in other_packages : #NEWLINE# #INDENT# if ( remote_package . name in ( x . name for x in local_packages ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# to_add . append ( remote_package ) #NEWLINE# #UNINDENT# for local_package in local_packages : #NEWLINE# #INDENT# if ( local_package . name not in ( x . name for x in remote_packages ) ) : #NEWLINE# #INDENT# to_remove . append ( local_package ) #NEWLINE# #UNINDENT# #UNINDENT# remote_names = [ x . name for x in remote_packages ] #NEWLINE# for local_package in local_packages : #NEWLINE# #INDENT# if ( ( local_package not in remote_packages ) and ( local_package . name in remote_names ) ) : #NEWLINE# #INDENT# remote_package = [ x for x in remote_packages if ( x . name == local_package . name ) ] [ 0 ] #NEWLINE# to_update . append ( remote_package ) #NEWLINE# #UNINDENT# #UNINDENT# to_update = [ x for x in to_update if ( not isinstance ( x , qitoolchain . svn_package . SvnPackage ) ) ] #NEWLINE# if to_update : #NEWLINE# #INDENT# ui . info ( ui . red , 'Updating packages' ) #NEWLINE# #UNINDENT# for ( i , package ) in enumerate ( to_update ) : #NEWLINE# #INDENT# remote_package = [ x for x in remote_packages if ( x . name == package . name ) ] [ 0 ] #NEWLINE# local_package = [ x for x in local_packages if ( x . name == package . name ) ] [ 0 ] #NEWLINE# if isinstance ( local_package , qitoolchain . svn_package . SvnPackage ) : #NEWLINE# #INDENT# ui . info_count ( i , len ( to_update ) , ui . blue , package . name , 'from subversion to' , remote_package . version ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ui . info_count ( i , len ( to_update ) , ui . blue , package . name , 'from' , local_package . version , 'to' , remote_package . version ) #NEWLINE# #UNINDENT# self . remove_package ( package . name ) #NEWLINE# self . handle_package ( package , feed ) #NEWLINE# self . add_package ( package ) #NEWLINE# #UNINDENT# if to_remove : #NEWLINE# #INDENT# ui . info ( ui . red , 'Removing packages' ) #NEWLINE# #UNINDENT# for ( i , package ) in enumerate ( to_remove ) : #NEWLINE# #INDENT# ui . info_count ( i , len ( to_remove ) , ui . blue , package . name ) #NEWLINE# self . remove_package ( package . name ) #NEWLINE# #UNINDENT# if to_add : #NEWLINE# #INDENT# ui . info ( ui . green , 'Adding packages' ) #NEWLINE# #UNINDENT# for ( i , package ) in enumerate ( to_add ) : #NEWLINE# #INDENT# ui . info_count ( i , len ( to_add ) , ui . blue , package . name ) #NEWLINE# self . handle_package ( package , feed ) #NEWLINE# self . add_package ( package ) #NEWLINE# #UNINDENT# if svn_packages : #NEWLINE# #INDENT# ui . info ( ui . green , 'Updating svn packages' ) #NEWLINE# #UNINDENT# for ( i , svn_package ) in enumerate ( svn_packages ) : #NEWLINE# #INDENT# ui . info_count ( i , len ( svn_packages ) , ui . blue , svn_package . name ) #NEWLINE# self . handle_svn_package ( svn_package ) #NEWLINE# self . add_package ( svn_package ) #NEWLINE# #UNINDENT# ui . info ( ui . green , 'Done' ) #NEWLINE# self . save ( )