Code Duplication    Length = 17-19 lines in 2 locations

opcua/common/xmlimporter.py 2 locations

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