Code Duplication    Length = 78-78 lines in 2 locations

opcua/ua/uaprotocol_auto.py 2 locations

@@ 6036-6113 (lines=78) @@
6033
        self.NodeClassMask = 0
6034
        self.ResultMask = 0
6035
        self._freeze = True
6036
6037
    def to_binary(self):
6038
        packet = []
6039
        packet.append(self.NodeId.to_binary())
6040
        packet.append(uabin.Primitives.UInt32.pack(self.BrowseDirection.value))
6041
        packet.append(self.ReferenceTypeId.to_binary())
6042
        packet.append(uabin.Primitives.Boolean.pack(self.IncludeSubtypes))
6043
        packet.append(uabin.Primitives.UInt32.pack(self.NodeClassMask))
6044
        packet.append(uabin.Primitives.UInt32.pack(self.ResultMask))
6045
        return b''.join(packet)
6046
6047
    @staticmethod
6048
    def from_binary(data):
6049
        return BrowseDescription(data)
6050
6051
    def _binary_init(self, data):
6052
        self.NodeId = NodeId.from_binary(data)
6053
        self.BrowseDirection = BrowseDirection(uabin.Primitives.UInt32.unpack(data))
6054
        self.ReferenceTypeId = NodeId.from_binary(data)
6055
        self.IncludeSubtypes = uabin.Primitives.Boolean.unpack(data)
6056
        self.NodeClassMask = uabin.Primitives.UInt32.unpack(data)
6057
        self.ResultMask = uabin.Primitives.UInt32.unpack(data)
6058
6059
    def __str__(self):
6060
        return 'BrowseDescription(' + 'NodeId:' + str(self.NodeId) + ', ' + \
6061
               'BrowseDirection:' + str(self.BrowseDirection) + ', ' + \
6062
               'ReferenceTypeId:' + str(self.ReferenceTypeId) + ', ' + \
6063
               'IncludeSubtypes:' + str(self.IncludeSubtypes) + ', ' + \
6064
               'NodeClassMask:' + str(self.NodeClassMask) + ', ' + \
6065
               'ResultMask:' + str(self.ResultMask) + ')'
6066
6067
    __repr__ = __str__
6068
6069
6070
class ReferenceDescription(FrozenClass):
6071
    '''
6072
    The description of a reference.
6073
6074
    :ivar ReferenceTypeId:
6075
    :vartype ReferenceTypeId: NodeId
6076
    :ivar IsForward:
6077
    :vartype IsForward: Boolean
6078
    :ivar NodeId:
6079
    :vartype NodeId: ExpandedNodeId
6080
    :ivar BrowseName:
6081
    :vartype BrowseName: QualifiedName
6082
    :ivar DisplayName:
6083
    :vartype DisplayName: LocalizedText
6084
    :ivar NodeClass:
6085
    :vartype NodeClass: NodeClass
6086
    :ivar TypeDefinition:
6087
    :vartype TypeDefinition: ExpandedNodeId
6088
    '''
6089
6090
    ua_types = {
6091
        'ReferenceTypeId': 'NodeId',
6092
        'IsForward': 'Boolean',
6093
        'NodeId': 'ExpandedNodeId',
6094
        'BrowseName': 'QualifiedName',
6095
        'DisplayName': 'LocalizedText',
6096
        'NodeClass': 'NodeClass',
6097
        'TypeDefinition': 'ExpandedNodeId',
6098
               }
6099
6100
    def __init__(self, binary=None):
6101
        if binary is not None:
6102
            self._binary_init(binary)
6103
            self._freeze = True
6104
            return
6105
        self.ReferenceTypeId = NodeId()
6106
        self.IsForward = True
6107
        self.NodeId = ExpandedNodeId()
6108
        self.BrowseName = QualifiedName()
6109
        self.DisplayName = LocalizedText()
6110
        self.NodeClass = NodeClass(0)
6111
        self.TypeDefinition = ExpandedNodeId()
6112
        self._freeze = True
6113
6114
    def to_binary(self):
6115
        packet = []
6116
        packet.append(self.ReferenceTypeId.to_binary())
@@ 4930-5007 (lines=78) @@
4927
4928
class AddNodesItem(FrozenClass):
4929
    '''
4930
    A request to add a node to the server address space.
4931
4932
    :ivar ParentNodeId:
4933
    :vartype ParentNodeId: ExpandedNodeId
4934
    :ivar ReferenceTypeId:
4935
    :vartype ReferenceTypeId: NodeId
4936
    :ivar RequestedNewNodeId:
4937
    :vartype RequestedNewNodeId: ExpandedNodeId
4938
    :ivar BrowseName:
4939
    :vartype BrowseName: QualifiedName
4940
    :ivar NodeClass:
4941
    :vartype NodeClass: NodeClass
4942
    :ivar NodeAttributes:
4943
    :vartype NodeAttributes: ExtensionObject
4944
    :ivar TypeDefinition:
4945
    :vartype TypeDefinition: ExpandedNodeId
4946
    '''
4947
4948
    ua_types = {
4949
        'ParentNodeId': 'ExpandedNodeId',
4950
        'ReferenceTypeId': 'NodeId',
4951
        'RequestedNewNodeId': 'ExpandedNodeId',
4952
        'BrowseName': 'QualifiedName',
4953
        'NodeClass': 'NodeClass',
4954
        'NodeAttributes': 'ExtensionObject',
4955
        'TypeDefinition': 'ExpandedNodeId',
4956
               }
4957
4958
    def __init__(self, binary=None):
4959
        if binary is not None:
4960
            self._binary_init(binary)
4961
            self._freeze = True
4962
            return
4963
        self.ParentNodeId = ExpandedNodeId()
4964
        self.ReferenceTypeId = NodeId()
4965
        self.RequestedNewNodeId = ExpandedNodeId()
4966
        self.BrowseName = QualifiedName()
4967
        self.NodeClass = NodeClass(0)
4968
        self.NodeAttributes = None
4969
        self.TypeDefinition = ExpandedNodeId()
4970
        self._freeze = True
4971
4972
    def to_binary(self):
4973
        packet = []
4974
        packet.append(self.ParentNodeId.to_binary())
4975
        packet.append(self.ReferenceTypeId.to_binary())
4976
        packet.append(self.RequestedNewNodeId.to_binary())
4977
        packet.append(self.BrowseName.to_binary())
4978
        packet.append(uabin.Primitives.UInt32.pack(self.NodeClass.value))
4979
        packet.append(extensionobject_to_binary(self.NodeAttributes))
4980
        packet.append(self.TypeDefinition.to_binary())
4981
        return b''.join(packet)
4982
4983
    @staticmethod
4984
    def from_binary(data):
4985
        return AddNodesItem(data)
4986
4987
    def _binary_init(self, data):
4988
        self.ParentNodeId = ExpandedNodeId.from_binary(data)
4989
        self.ReferenceTypeId = NodeId.from_binary(data)
4990
        self.RequestedNewNodeId = ExpandedNodeId.from_binary(data)
4991
        self.BrowseName = QualifiedName.from_binary(data)
4992
        self.NodeClass = NodeClass(uabin.Primitives.UInt32.unpack(data))
4993
        self.NodeAttributes = extensionobject_from_binary(data)
4994
        self.TypeDefinition = ExpandedNodeId.from_binary(data)
4995
4996
    def __str__(self):
4997
        return 'AddNodesItem(' + 'ParentNodeId:' + str(self.ParentNodeId) + ', ' + \
4998
               'ReferenceTypeId:' + str(self.ReferenceTypeId) + ', ' + \
4999
               'RequestedNewNodeId:' + str(self.RequestedNewNodeId) + ', ' + \
5000
               'BrowseName:' + str(self.BrowseName) + ', ' + \
5001
               'NodeClass:' + str(self.NodeClass) + ', ' + \
5002
               'NodeAttributes:' + str(self.NodeAttributes) + ', ' + \
5003
               'TypeDefinition:' + str(self.TypeDefinition) + ')'
5004
5005
    __repr__ = __str__
5006
5007
5008
class AddNodesResult(FrozenClass):
5009
    '''
5010
    A result of an add node operation.