Code Duplication    Length = 20-25 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 locations

@@ 7457-7477 (lines=21) @@
7454
        self.OrganizationUri = uabin.Primitives.String.unpack(data)
7455
        self.ProfileId = uabin.Primitives.String.unpack(data)
7456
        self.ComplianceTool = uabin.Primitives.String.unpack(data)
7457
        self.ComplianceDate = uabin.Primitives.DateTime.unpack(data)
7458
        self.ComplianceLevel = ComplianceLevel(uabin.Primitives.UInt32.unpack(data))
7459
        self.UnsupportedUnitIds = uabin.Primitives.String.unpack_array(data)
7460
7461
    def __str__(self):
7462
        return 'SupportedProfile(' + 'OrganizationUri:' + str(self.OrganizationUri) + ', ' + \
7463
               'ProfileId:' + str(self.ProfileId) + ', ' + \
7464
               'ComplianceTool:' + str(self.ComplianceTool) + ', ' + \
7465
               'ComplianceDate:' + str(self.ComplianceDate) + ', ' + \
7466
               'ComplianceLevel:' + str(self.ComplianceLevel) + ', ' + \
7467
               'UnsupportedUnitIds:' + str(self.UnsupportedUnitIds) + ')'
7468
7469
    __repr__ = __str__
7470
7471
7472
class SoftwareCertificate(FrozenClass):
7473
    '''
7474
    :ivar ProductName:
7475
    :vartype ProductName: String
7476
    :ivar ProductUri:
7477
    :vartype ProductUri: String
7478
    :ivar VendorName:
7479
    :vartype VendorName: String
7480
    :ivar VendorProductCertificate:
@@ 10748-10772 (lines=25) @@
10745
10746
    def _binary_init(self, data):
10747
        self.TypeId = NodeId.from_binary(data)
10748
        self.RequestHeader = RequestHeader.from_binary(data)
10749
        self.Parameters = CallParameters.from_binary(data)
10750
10751
    def __str__(self):
10752
        return 'CallRequest(' + 'TypeId:' + str(self.TypeId) + ', ' + \
10753
               'RequestHeader:' + str(self.RequestHeader) + ', ' + \
10754
               'Parameters:' + str(self.Parameters) + ')'
10755
10756
    __repr__ = __str__
10757
10758
10759
class CallResponse(FrozenClass):
10760
    '''
10761
    :ivar TypeId:
10762
    :vartype TypeId: NodeId
10763
    :ivar ResponseHeader:
10764
    :vartype ResponseHeader: ResponseHeader
10765
    :ivar Results:
10766
    :vartype Results: CallMethodResult
10767
    :ivar DiagnosticInfos:
10768
    :vartype DiagnosticInfos: DiagnosticInfo
10769
    '''
10770
10771
    ua_types = {
10772
        'TypeId': 'NodeId',
10773
        'ResponseHeader': 'ResponseHeader',
10774
        'Results': 'CallMethodResult',
10775
        'DiagnosticInfos': 'DiagnosticInfo',
@@ 9358-9377 (lines=20) @@
9355
            self._binary_init(binary)
9356
            self._freeze = True
9357
            return
9358
        self.DataValues = []
9359
        self._freeze = True
9360
9361
    def to_binary(self):
9362
        packet = []
9363
        packet.append(uabin.Primitives.Int32.pack(len(self.DataValues)))
9364
        for fieldname in self.DataValues:
9365
            packet.append(fieldname.to_binary())
9366
        return b''.join(packet)
9367
9368
    @staticmethod
9369
    def from_binary(data):
9370
        return HistoryData(data)
9371
9372
    def _binary_init(self, data):
9373
        length = uabin.Primitives.Int32.unpack(data)
9374
        array = []
9375
        if length != -1:
9376
            for _ in range(0, length):
9377
                array.append(DataValue.from_binary(data))
9378
        self.DataValues = array
9379
9380
    def __str__(self):