Code Duplication    Length = 39-43 lines in 4 locations

opcua/ua/uaprotocol_auto.py 4 locations

@@ 3228-3270 (lines=43) @@
3225
    __repr__ = __str__
3226
3227
3228
class IssuedIdentityToken(FrozenClass):
3229
    '''
3230
    A token representing a user identified by a WS-Security XML token.
3231
3232
    :ivar PolicyId:
3233
    :vartype PolicyId: String
3234
    :ivar TokenData:
3235
    :vartype TokenData: ByteString
3236
    :ivar EncryptionAlgorithm:
3237
    :vartype EncryptionAlgorithm: String
3238
    '''
3239
    def __init__(self, binary=None):
3240
        if binary is not None:
3241
            self._binary_init(binary)
3242
            self._freeze = True
3243
            return
3244
        self.PolicyId = ''
3245
        self.TokenData = b''
3246
        self.EncryptionAlgorithm = ''
3247
        self._freeze = True
3248
3249
    def to_binary(self):
3250
        packet = []
3251
        packet.append(pack_string(self.PolicyId))
3252
        packet.append(pack_bytes(self.TokenData))
3253
        packet.append(pack_string(self.EncryptionAlgorithm))
3254
        return b''.join(packet)
3255
3256
    @staticmethod
3257
    def from_binary(data):
3258
        return IssuedIdentityToken(data)
3259
3260
    def _binary_init(self, data):
3261
        self.PolicyId = unpack_string(data)
3262
        self.TokenData = unpack_bytes(data)
3263
        self.EncryptionAlgorithm = unpack_string(data)
3264
3265
    def __str__(self):
3266
        return 'IssuedIdentityToken(' + 'PolicyId:' + str(self.PolicyId) + ', ' + \
3267
               'TokenData:' + str(self.TokenData) + ', ' + \
3268
               'EncryptionAlgorithm:' + str(self.EncryptionAlgorithm) + ')'
3269
3270
    __repr__ = __str__
3271
3272
3273
class ActivateSessionParameters(FrozenClass):
@@ 14041-14081 (lines=41) @@
14038
    __repr__ = __str__
14039
14040
14041
class Annotation(FrozenClass):
14042
    '''
14043
    :ivar Message:
14044
    :vartype Message: String
14045
    :ivar UserName:
14046
    :vartype UserName: String
14047
    :ivar AnnotationTime:
14048
    :vartype AnnotationTime: DateTime
14049
    '''
14050
    def __init__(self, binary=None):
14051
        if binary is not None:
14052
            self._binary_init(binary)
14053
            self._freeze = True
14054
            return
14055
        self.Message = ''
14056
        self.UserName = ''
14057
        self.AnnotationTime = datetime.now()
14058
        self._freeze = True
14059
14060
    def to_binary(self):
14061
        packet = []
14062
        packet.append(pack_string(self.Message))
14063
        packet.append(pack_string(self.UserName))
14064
        packet.append(pack_datetime(self.AnnotationTime))
14065
        return b''.join(packet)
14066
14067
    @staticmethod
14068
    def from_binary(data):
14069
        return Annotation(data)
14070
14071
    def _binary_init(self, data):
14072
        self.Message = unpack_string(data)
14073
        self.UserName = unpack_string(data)
14074
        self.AnnotationTime = unpack_datetime(data)
14075
14076
    def __str__(self):
14077
        return 'Annotation(' + 'Message:' + str(self.Message) + ', ' + \
14078
               'UserName:' + str(self.UserName) + ', ' + \
14079
               'AnnotationTime:' + str(self.AnnotationTime) + ')'
14080
14081
    __repr__ = __str__
14082
14083
14084
ExtensionClasses = {
@@ 8265-8305 (lines=41) @@
8262
    __repr__ = __str__
8263
8264
8265
class ModificationInfo(FrozenClass):
8266
    '''
8267
    :ivar ModificationTime:
8268
    :vartype ModificationTime: DateTime
8269
    :ivar UpdateType:
8270
    :vartype UpdateType: HistoryUpdateType
8271
    :ivar UserName:
8272
    :vartype UserName: String
8273
    '''
8274
    def __init__(self, binary=None):
8275
        if binary is not None:
8276
            self._binary_init(binary)
8277
            self._freeze = True
8278
            return
8279
        self.ModificationTime = datetime.now()
8280
        self.UpdateType = HistoryUpdateType(0)
8281
        self.UserName = ''
8282
        self._freeze = True
8283
8284
    def to_binary(self):
8285
        packet = []
8286
        packet.append(pack_datetime(self.ModificationTime))
8287
        packet.append(uatype_UInt32.pack(self.UpdateType.value))
8288
        packet.append(pack_string(self.UserName))
8289
        return b''.join(packet)
8290
8291
    @staticmethod
8292
    def from_binary(data):
8293
        return ModificationInfo(data)
8294
8295
    def _binary_init(self, data):
8296
        self.ModificationTime = unpack_datetime(data)
8297
        self.UpdateType = HistoryUpdateType(uatype_UInt32.unpack(data.read(4))[0])
8298
        self.UserName = unpack_string(data)
8299
8300
    def __str__(self):
8301
        return 'ModificationInfo(' + 'ModificationTime:' + str(self.ModificationTime) + ', ' + \
8302
               'UpdateType:' + str(self.UpdateType) + ', ' + \
8303
               'UserName:' + str(self.UserName) + ')'
8304
8305
    __repr__ = __str__
8306
8307
8308
class HistoryModifiedData(FrozenClass):
@@ 2193-2231 (lines=39) @@
2190
    __repr__ = __str__
2191
2192
2193
class MdnsDiscoveryConfiguration(FrozenClass):
2194
    '''
2195
    The discovery information needed for mDNS registration.
2196
2197
    :ivar MdnsServerName:
2198
    :vartype MdnsServerName: String
2199
    :ivar ServerCapabilities:
2200
    :vartype ServerCapabilities: String
2201
    '''
2202
    def __init__(self, binary=None):
2203
        if binary is not None:
2204
            self._binary_init(binary)
2205
            self._freeze = True
2206
            return
2207
        self.MdnsServerName = ''
2208
        self.ServerCapabilities = []
2209
        self._freeze = True
2210
2211
    def to_binary(self):
2212
        packet = []
2213
        packet.append(pack_string(self.MdnsServerName))
2214
        packet.append(uatype_Int32.pack(len(self.ServerCapabilities)))
2215
        for fieldname in self.ServerCapabilities:
2216
            packet.append(pack_string(fieldname))
2217
        return b''.join(packet)
2218
2219
    @staticmethod
2220
    def from_binary(data):
2221
        return MdnsDiscoveryConfiguration(data)
2222
2223
    def _binary_init(self, data):
2224
        self.MdnsServerName = unpack_string(data)
2225
        self.ServerCapabilities = unpack_uatype_array('String', data)
2226
2227
    def __str__(self):
2228
        return 'MdnsDiscoveryConfiguration(' + 'MdnsServerName:' + str(self.MdnsServerName) + ', ' + \
2229
               'ServerCapabilities:' + str(self.ServerCapabilities) + ')'
2230
2231
    __repr__ = __str__
2232
2233
2234
class RegisterServer2Parameters(FrozenClass):