Code Duplication    Length = 12-13 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

@@ 380-392 (lines=13) @@
377
        self._add_refs(obj)
378
        res[0].StatusCode.check()
379
        return res[0].AddedNodeId
380
381
    def add_datatype(self, obj):
382
        node = self._get_node(obj)
383
        attrs = ua.DataTypeAttributes()
384
        if obj.desc:
385
            attrs.Description = ua.LocalizedText(obj.desc)
386
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
387
        if obj.abstract:
388
            attrs.IsAbstract = obj.abstract
389
        node.NodeAttributes = attrs
390
        res = self._add_node(node)
391
        self._add_refs(obj)
392
        res[0].StatusCode.check()
393
        return res[0].AddedNodeId
394
395
    def _add_refs(self, obj):
@@ 185-196 (lines=12) @@
182
        self._add_refs(obj)
183
        res[0].StatusCode.check()
184
        return res[0].AddedNodeId
185
186
    def add_object_type(self, obj):
187
        node = self._get_node(obj)
188
        attrs = ua.ObjectTypeAttributes()
189
        if obj.desc:
190
            attrs.Description = ua.LocalizedText(obj.desc)
191
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
192
        attrs.IsAbstract = obj.abstract
193
        node.NodeAttributes = attrs
194
        res = self._add_node(node)
195
        self._add_refs(obj)
196
        res[0].StatusCode.check()
197
        return res[0].AddedNodeId
198
199
    def add_variable(self, obj):
@@ 172-183 (lines=12) @@
169
170
    def to_nodeid(self, nodeid):
171
        return self._migrate_ns(self._to_nodeid(nodeid))
172
173
    def add_object(self, obj):
174
        node = self._get_node(obj)
175
        attrs = ua.ObjectAttributes()
176
        if obj.desc:
177
            attrs.Description = ua.LocalizedText(obj.desc)
178
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
179
        attrs.EventNotifier = obj.eventnotifier
180
        node.NodeAttributes = attrs
181
        res = self._add_node(node)
182
        self._add_refs(obj)
183
        res[0].StatusCode.check()
184
        return res[0].AddedNodeId
185
186
    def add_object_type(self, obj):