Code Duplication    Length = 12-13 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

@@ 335-347 (lines=13) @@
332
            attrs.IsAbstract = obj.abstract
333
        if obj.symmetric:
334
            attrs.Symmetric = obj.symmetric
335
        node.NodeAttributes = attrs
336
        res = self._add_node(node)
337
        self._add_refs(obj)
338
        res[0].StatusCode.check()
339
        return res[0].AddedNodeId
340
341
    def add_datatype(self, obj):
342
        node = self._get_node(obj)
343
        attrs = ua.DataTypeAttributes()
344
        if obj.desc:
345
            attrs.Description = ua.LocalizedText(obj.desc)
346
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
347
        if obj.abstract:
348
            attrs.IsAbstract = obj.abstract
349
        node.NodeAttributes = attrs
350
        res = self._add_node(node)
@@ 162-173 (lines=12) @@
159
            attrs.Description = ua.LocalizedText(obj.desc)
160
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
161
        attrs.EventNotifier = obj.eventnotifier
162
        node.NodeAttributes = attrs
163
        res = self._add_node(node)
164
        self._add_refs(obj)
165
        res[0].StatusCode.check()
166
        return res[0].AddedNodeId
167
168
    def add_object_type(self, obj):
169
        node = self._get_node(obj)
170
        attrs = ua.ObjectTypeAttributes()
171
        if obj.desc:
172
            attrs.Description = ua.LocalizedText(obj.desc)
173
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
174
        attrs.IsAbstract = obj.abstract
175
        node.NodeAttributes = attrs
176
        res = self._add_node(node)
@@ 149-160 (lines=12) @@
146
            return ua.NodeId.from_string(nodeid)
147
        elif hasattr(ua.ObjectIds, nodeid):
148
            return ua.NodeId(getattr(ua.ObjectIds, nodeid))
149
        else:
150
            if nodeid in self.aliases:
151
                return self.aliases[nodeid]
152
            else:
153
                return ua.NodeId(getattr(ua.ObjectIds, nodeid))
154
155
    def add_object(self, obj):
156
        node = self._get_node(obj)
157
        attrs = ua.ObjectAttributes()
158
        if obj.desc:
159
            attrs.Description = ua.LocalizedText(obj.desc)
160
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
161
        attrs.EventNotifier = obj.eventnotifier
162
        node.NodeAttributes = attrs
163
        res = self._add_node(node)