Code Duplication    Length = 65-67 lines in 2 locations

opcua/ua/uaprotocol_auto.py 2 locations

@@ 3677-3743 (lines=67) @@
3674
    __repr__ = __str__
3675
3676
3677
class ActivateSessionParameters(FrozenClass):
3678
    '''
3679
    :ivar ClientSignature:
3680
    :vartype ClientSignature: SignatureData
3681
    :ivar ClientSoftwareCertificates:
3682
    :vartype ClientSoftwareCertificates: SignedSoftwareCertificate
3683
    :ivar LocaleIds:
3684
    :vartype LocaleIds: String
3685
    :ivar UserIdentityToken:
3686
    :vartype UserIdentityToken: ExtensionObject
3687
    :ivar UserTokenSignature:
3688
    :vartype UserTokenSignature: SignatureData
3689
    '''
3690
3691
    ua_types = [
3692
3693
        ('ClientSignature', 'SignatureData'),
3694
        ('ClientSoftwareCertificates', 'ListOfSignedSoftwareCertificate'),
3695
        ('LocaleIds', 'ListOfString'),
3696
        ('UserIdentityToken', 'ExtensionObject'),
3697
        ('UserTokenSignature', 'SignatureData'),
3698
               ]
3699
3700
    def __init__(self):
3701
        self.ClientSignature = SignatureData()
3702
        self.ClientSoftwareCertificates = []
3703
        self.LocaleIds = []
3704
        self.UserIdentityToken = ExtensionObject()
3705
        self.UserTokenSignature = SignatureData()
3706
        self._freeze = True
3707
3708
    def to_binary(self):
3709
        packet = []
3710
        packet.append(self.ClientSignature.to_binary())
3711
        packet.append(uabin.Primitives.Int32.pack(len(self.ClientSoftwareCertificates)))
3712
        for fieldname in self.ClientSoftwareCertificates:
3713
            packet.append(fieldname.to_binary())
3714
        packet.append(uabin.Primitives.Int32.pack(len(self.LocaleIds)))
3715
        for fieldname in self.LocaleIds:
3716
            packet.append(uabin.Primitives.String.pack(fieldname))
3717
        packet.append(uabin.extensionobject_to_binary(self.UserIdentityToken))
3718
        packet.append(self.UserTokenSignature.to_binary())
3719
        return b''.join(packet)
3720
3721
    @staticmethod
3722
    def from_binary(data):
3723
        obj = ActivateSessionParameters()
3724
        obj.ClientSignature = SignatureData.from_binary(data)
3725
        length = uabin.Primitives.Int32.unpack(data)
3726
        array = []
3727
        if length != -1:
3728
            for _ in range(0, length):
3729
                array.append(SignedSoftwareCertificate.from_binary(data))
3730
        obj.ClientSoftwareCertificates = array
3731
        obj.LocaleIds = uabin.Primitives.String.unpack_array(data)
3732
        obj.UserIdentityToken = uabin.extensionobject_from_binary(data)
3733
        obj.UserTokenSignature = SignatureData.from_binary(data)
3734
        return obj
3735
3736
    def __str__(self):
3737
        return 'ActivateSessionParameters(' + 'ClientSignature:' + str(self.ClientSignature) + ', ' + \
3738
               'ClientSoftwareCertificates:' + str(self.ClientSoftwareCertificates) + ', ' + \
3739
               'LocaleIds:' + str(self.LocaleIds) + ', ' + \
3740
               'UserIdentityToken:' + str(self.UserIdentityToken) + ', ' + \
3741
               'UserTokenSignature:' + str(self.UserTokenSignature) + ')'
3742
3743
    __repr__ = __str__
3744
3745
3746
class ActivateSessionRequest(FrozenClass):
@@ 8024-8088 (lines=65) @@
8021
    __repr__ = __str__
8022
8023
8024
class QueryFirstParameters(FrozenClass):
8025
    '''
8026
    :ivar View:
8027
    :vartype View: ViewDescription
8028
    :ivar NodeTypes:
8029
    :vartype NodeTypes: NodeTypeDescription
8030
    :ivar Filter:
8031
    :vartype Filter: ContentFilter
8032
    :ivar MaxDataSetsToReturn:
8033
    :vartype MaxDataSetsToReturn: UInt32
8034
    :ivar MaxReferencesToReturn:
8035
    :vartype MaxReferencesToReturn: UInt32
8036
    '''
8037
8038
    ua_types = [
8039
8040
        ('View', 'ViewDescription'),
8041
        ('NodeTypes', 'ListOfNodeTypeDescription'),
8042
        ('Filter', 'ContentFilter'),
8043
        ('MaxDataSetsToReturn', 'UInt32'),
8044
        ('MaxReferencesToReturn', 'UInt32'),
8045
               ]
8046
8047
    def __init__(self):
8048
        self.View = ViewDescription()
8049
        self.NodeTypes = []
8050
        self.Filter = ContentFilter()
8051
        self.MaxDataSetsToReturn = 0
8052
        self.MaxReferencesToReturn = 0
8053
        self._freeze = True
8054
8055
    def to_binary(self):
8056
        packet = []
8057
        packet.append(self.View.to_binary())
8058
        packet.append(uabin.Primitives.Int32.pack(len(self.NodeTypes)))
8059
        for fieldname in self.NodeTypes:
8060
            packet.append(fieldname.to_binary())
8061
        packet.append(self.Filter.to_binary())
8062
        packet.append(uabin.Primitives.UInt32.pack(self.MaxDataSetsToReturn))
8063
        packet.append(uabin.Primitives.UInt32.pack(self.MaxReferencesToReturn))
8064
        return b''.join(packet)
8065
8066
    @staticmethod
8067
    def from_binary(data):
8068
        obj = QueryFirstParameters()
8069
        obj.View = ViewDescription.from_binary(data)
8070
        length = uabin.Primitives.Int32.unpack(data)
8071
        array = []
8072
        if length != -1:
8073
            for _ in range(0, length):
8074
                array.append(NodeTypeDescription.from_binary(data))
8075
        obj.NodeTypes = array
8076
        obj.Filter = ContentFilter.from_binary(data)
8077
        self.MaxDataSetsToReturn = uabin.Primitives.UInt32.unpack(data)
8078
        self.MaxReferencesToReturn = uabin.Primitives.UInt32.unpack(data)
8079
        return obj
8080
8081
    def __str__(self):
8082
        return 'QueryFirstParameters(' + 'View:' + str(self.View) + ', ' + \
8083
               'NodeTypes:' + str(self.NodeTypes) + ', ' + \
8084
               'Filter:' + str(self.Filter) + ', ' + \
8085
               'MaxDataSetsToReturn:' + str(self.MaxDataSetsToReturn) + ', ' + \
8086
               'MaxReferencesToReturn:' + str(self.MaxReferencesToReturn) + ')'
8087
8088
    __repr__ = __str__
8089
8090
8091
class QueryFirstRequest(FrozenClass):