#NEWLINE# def __appendPlugPromotionMenuItems( menuDefinition , plug , readOnly = False ) : #NEWLINE# #INDENT# node = plug . node ( ) #NEWLINE# if ( node is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# box = node . ancestor ( Gaffer . Box ) #NEWLINE# if ( box is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if box . canPromotePlug ( plug ) : #NEWLINE# #INDENT# if len ( menuDefinition . items ( ) ) : #NEWLINE# #INDENT# menuDefinition . append ( '/BoxDivider' , { #NEWLINE# #INDENT# 'divider' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# menuDefinition . append ( ( '/Promote to %s' % box . getName ( ) ) , { #NEWLINE# #INDENT# 'command' : IECore . curry ( __promoteToBox , box , plug ) , #NEWLINE# 'active' : ( not readOnly ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( isinstance ( plug . parent ( ) , Gaffer . ArrayPlug ) and box . canPromotePlug ( plug . parent ( ) ) ) : #NEWLINE# #INDENT# menuDefinition . append ( ( '/Promote %s array to %s' % ( plug . parent ( ) . getName ( ) , box . getName ( ) ) ) , { #NEWLINE# #INDENT# 'command' : IECore . curry ( __promoteToBox , box , plug . parent ( ) ) , #NEWLINE# 'active' : ( not readOnly ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if isinstance ( node , Gaffer . DependencyNode ) : #NEWLINE# #INDENT# if plug . isSame ( node . enabledPlug ( ) ) : #NEWLINE# #INDENT# menuDefinition . append ( ( '/Promote to %s.enabled' % box . getName ( ) ) , { #NEWLINE# #INDENT# 'command' : IECore . curry ( __promoteToBoxEnabledPlug , box , plug ) , #NEWLINE# 'active' : ( not readOnly ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if box . plugIsPromoted ( plug ) : #NEWLINE# #INDENT# if len ( menuDefinition . items ( ) ) : #NEWLINE# #INDENT# menuDefinition . append ( '/BoxDivider' , { #NEWLINE# #INDENT# 'divider' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( isinstance ( plug . parent ( ) , Gaffer . ArrayPlug ) and box . plugIsPromoted ( plug . parent ( ) ) ) : #NEWLINE# #INDENT# menuDefinition . append ( ( '/Unpromote %s array from %s' % ( plug . parent ( ) . getName ( ) , box . getName ( ) ) ) , { #NEWLINE# #INDENT# 'command' : IECore . curry ( __unpromoteFromBox , box , plug . parent ( ) ) , #NEWLINE# 'active' : ( not readOnly ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# menuDefinition . append ( ( '/Unpromote from %s' % box . getName ( ) ) , { #NEWLINE# #INDENT# 'command' : IECore . curry ( __unpromoteFromBox , box , plug ) , #NEWLINE# 'active' : ( not readOnly ) , #NEWLINE# #UNINDENT# } )