Code Duplication    Length = 17-19 lines in 2 locations

opcua/common/xmlimporter.py 2 locations

@@ 297-315 (lines=19) @@
294
        if obj.dimensions:
295
            attrs.ArrayDimensions = obj.dimensions
296
        node.NodeAttributes = attrs
297
        res = self._add_node(node)
298
        self._add_refs(obj)
299
        res[0].StatusCode.check()
300
        return res[0].AddedNodeId
301
302
    def add_method(self, obj):
303
        node = self._get_node(obj)
304
        attrs = ua.MethodAttributes()
305
        if obj.desc:
306
            attrs.Description = ua.LocalizedText(obj.desc)
307
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
308
        if obj.accesslevel:
309
            attrs.AccessLevel = obj.accesslevel
310
        if obj.useraccesslevel:
311
            attrs.UserAccessLevel = obj.useraccesslevel
312
        if obj.minsample:
313
            attrs.MinimumSamplingInterval = obj.minsample
314
        if obj.dimensions:
315
            attrs.ArrayDimensions = obj.dimensions
316
        node.NodeAttributes = attrs
317
        res = self._add_node(node)
318
        self._add_refs(obj)
@@ 317-333 (lines=17) @@
314
        if obj.dimensions:
315
            attrs.ArrayDimensions = obj.dimensions
316
        node.NodeAttributes = attrs
317
        res = self._add_node(node)
318
        self._add_refs(obj)
319
        res[0].StatusCode.check()
320
        return res[0].AddedNodeId
321
322
    def add_reference_type(self, obj):
323
        node = self._get_node(obj)
324
        attrs = ua.ReferenceTypeAttributes()
325
        if obj.desc:
326
            attrs.Description = ua.LocalizedText(obj.desc)
327
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
328
        if obj. inversename:
329
            attrs.InverseName = ua.LocalizedText(obj.inversename)
330
        if obj.abstract:
331
            attrs.IsAbstract = obj.abstract
332
        if obj.symmetric:
333
            attrs.Symmetric = obj.symmetric
334
        node.NodeAttributes = attrs
335
        res = self._add_node(node)
336
        self._add_refs(obj)