#NEWLINE# def _translate2v2( ip , community , pdu ) : #NEWLINE# #INDENT# 'Translate an SNMPv1 trap to an SNMPv2 trap per RFC2576. This is\n    done so that the rest of the API only has to deal with V2 traps.\n    ' #NEWLINE# varbinds = pdu . varbinds #NEWLINE# varbinds . insert ( 0 , sysUpTime ( pdu . time_stamp ) . varbind ) #NEWLINE# if ( pdu . generic == 6 ) : #NEWLINE# #INDENT# trapoid = ObjectIdentifier ( ( pdu . enterprise + [ 0 , pdu . specific ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# trapoid = _TRAPMAP [ pdu . generic ] #NEWLINE# #UNINDENT# varbinds . insert ( 1 , snmpTrapOID ( trapoid ) . varbind ) #NEWLINE# try : #NEWLINE# #INDENT# varbinds . append ( snmpTrapAddress ( pdu . agent ) . varbind ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# varbinds . append ( snmpTrapAddress ( trapoid ) . varbind ) #NEWLINE# #UNINDENT# varbinds . append ( snmpTrapCommunity ( community ) . varbind ) #NEWLINE# varbinds . append ( snmpTrapEnterprise ( pdu . enterprise ) . varbind ) #NEWLINE# return SNMPv2TrapPDU ( varbinds = varbinds )