Code Duplication    Length = 17-19 lines in 2 locations

opcua/common/xmlimporter.py 2 locations

@@ 339-357 (lines=19) @@
336
            attrs.ArrayDimensions = obj.dimensions
337
        node.NodeAttributes = attrs
338
        res = self._add_node(node)
339
        self._add_refs(obj)
340
        res[0].StatusCode.check()
341
        return res[0].AddedNodeId
342
343
    def add_method(self, obj):
344
        node = self._get_node(obj)
345
        attrs = ua.MethodAttributes()
346
        if obj.desc:
347
            attrs.Description = ua.LocalizedText(obj.desc)
348
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
349
        if obj.accesslevel:
350
            attrs.AccessLevel = obj.accesslevel
351
        if obj.useraccesslevel:
352
            attrs.UserAccessLevel = obj.useraccesslevel
353
        if obj.minsample:
354
            attrs.MinimumSamplingInterval = obj.minsample
355
        if obj.dimensions:
356
            attrs.ArrayDimensions = obj.dimensions
357
        node.NodeAttributes = attrs
358
        res = self._add_node(node)
359
        self._add_refs(obj)
360
        res[0].StatusCode.check()
@@ 359-375 (lines=17) @@
356
            attrs.ArrayDimensions = obj.dimensions
357
        node.NodeAttributes = attrs
358
        res = self._add_node(node)
359
        self._add_refs(obj)
360
        res[0].StatusCode.check()
361
        return res[0].AddedNodeId
362
363
    def add_reference_type(self, obj):
364
        node = self._get_node(obj)
365
        attrs = ua.ReferenceTypeAttributes()
366
        if obj.desc:
367
            attrs.Description = ua.LocalizedText(obj.desc)
368
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
369
        if obj. inversename:
370
            attrs.InverseName = ua.LocalizedText(obj.inversename)
371
        if obj.abstract:
372
            attrs.IsAbstract = obj.abstract
373
        if obj.symmetric:
374
            attrs.Symmetric = obj.symmetric
375
        node.NodeAttributes = attrs
376
        res = self._add_node(node)
377
        self._add_refs(obj)
378
        res[0].StatusCode.check()