Code Duplication    Length = 17-19 lines in 2 locations

opcua/common/xmlimporter.py 2 locations

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