Code Duplication    Length = 16-18 lines in 2 locations

opcua/common/xmlimporter.py 2 locations

@@ 219-236 (lines=18) @@
216
            attrs.UserAccessLevel = obj.useraccesslevel
217
        if obj.minsample:
218
            attrs.MinimumSamplingInterval = obj.minsample
219
        if obj.dimensions:
220
            attrs.ArrayDimensions = obj.dimensions
221
        node.NodeAttributes = attrs
222
        res = self.server.add_nodes([node])
223
        self._add_refs(obj)
224
        return res[0].AddedNodeId
225
226
    def add_reference_type(self, obj):
227
        node = self._get_node(obj)
228
        attrs = ua.ReferenceTypeAttributes()
229
        if obj.desc:
230
            attrs.Description = ua.LocalizedText(obj.desc)
231
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
232
        if obj. inversename:
233
            attrs.InverseName = ua.LocalizedText(obj.inversename)
234
        if obj.abstract:
235
            attrs.IsAbstract = obj.abstract
236
        if obj.symmetric:
237
            attrs.Symmetric = obj.symmetric
238
        node.NodeAttributes = attrs
239
        res = self.server.add_nodes([node])
@@ 238-253 (lines=16) @@
235
            attrs.IsAbstract = obj.abstract
236
        if obj.symmetric:
237
            attrs.Symmetric = obj.symmetric
238
        node.NodeAttributes = attrs
239
        res = self.server.add_nodes([node])
240
        self._add_refs(obj)
241
        return res[0].AddedNodeId
242
243
    def add_datatype(self, obj):
244
        node = self._get_node(obj)
245
        attrs = ua.DataTypeAttributes()
246
        if obj.desc:
247
            attrs.Description = ua.LocalizedText(obj.desc)
248
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
249
        if obj.abstract:
250
            attrs.IsAbstract = obj.abstract
251
        node.NodeAttributes = attrs
252
        res = self.server.add_nodes([node])
253
        self._add_refs(obj)
254
        return res[0].AddedNodeId
255
256
    def _add_refs(self, obj):