Code Duplication    Length = 11-14 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 locations

@@ 15154-15167 (lines=14) @@
15151
        self.ClientCertificate = None
15152
        self._freeze = True
15153
15154
    def to_binary(self):
15155
        packet = []
15156
        packet.append(self.SessionId.to_binary())
15157
        packet.append(uabin.Primitives.String.pack(self.ClientUserIdOfSession))
15158
        packet.append(uabin.Primitives.Int32.pack(len(self.ClientUserIdHistory)))
15159
        for fieldname in self.ClientUserIdHistory:
15160
            packet.append(uabin.Primitives.String.pack(fieldname))
15161
        packet.append(uabin.Primitives.String.pack(self.AuthenticationMechanism))
15162
        packet.append(uabin.Primitives.String.pack(self.Encoding))
15163
        packet.append(uabin.Primitives.String.pack(self.TransportProtocol))
15164
        packet.append(uabin.Primitives.UInt32.pack(self.SecurityMode.value))
15165
        packet.append(uabin.Primitives.String.pack(self.SecurityPolicyUri))
15166
        packet.append(uabin.Primitives.ByteString.pack(self.ClientCertificate))
15167
        return b''.join(packet)
15168
15169
    @staticmethod
15170
    def from_binary(data):
@@ 1975-1987 (lines=13) @@
1972
        self.SecurityLevel = 0
1973
        self._freeze = True
1974
1975
    def to_binary(self):
1976
        packet = []
1977
        packet.append(uabin.Primitives.String.pack(self.EndpointUrl))
1978
        packet.append(self.Server.to_binary())
1979
        packet.append(uabin.Primitives.ByteString.pack(self.ServerCertificate))
1980
        packet.append(uabin.Primitives.UInt32.pack(self.SecurityMode.value))
1981
        packet.append(uabin.Primitives.String.pack(self.SecurityPolicyUri))
1982
        packet.append(uabin.Primitives.Int32.pack(len(self.UserIdentityTokens)))
1983
        for fieldname in self.UserIdentityTokens:
1984
            packet.append(fieldname.to_binary())
1985
        packet.append(uabin.Primitives.String.pack(self.TransportProfileUri))
1986
        packet.append(uabin.Primitives.Byte.pack(self.SecurityLevel))
1987
        return b''.join(packet)
1988
1989
    @staticmethod
1990
    def from_binary(data):
@@ 3133-3143 (lines=11) @@
3130
        self.MaxResponseMessageSize = 0
3131
        self._freeze = True
3132
3133
    def to_binary(self):
3134
        packet = []
3135
        packet.append(self.ClientDescription.to_binary())
3136
        packet.append(uabin.Primitives.String.pack(self.ServerUri))
3137
        packet.append(uabin.Primitives.String.pack(self.EndpointUrl))
3138
        packet.append(uabin.Primitives.String.pack(self.SessionName))
3139
        packet.append(uabin.Primitives.ByteString.pack(self.ClientNonce))
3140
        packet.append(uabin.Primitives.ByteString.pack(self.ClientCertificate))
3141
        packet.append(uabin.Primitives.Double.pack(self.RequestedSessionTimeout))
3142
        packet.append(uabin.Primitives.UInt32.pack(self.MaxResponseMessageSize))
3143
        return b''.join(packet)
3144
3145
    @staticmethod
3146
    def from_binary(data):