Code Duplication    Length = 12-13 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

@@ 335-347 (lines=13) @@
332
        return res[0].AddedNodeId
333
334
    def add_datatype(self, obj):
335
        node = self._get_node(obj)
336
        attrs = ua.DataTypeAttributes()
337
        if obj.desc:
338
            attrs.Description = ua.LocalizedText(obj.desc)
339
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
340
        if obj.abstract:
341
            attrs.IsAbstract = obj.abstract
342
        node.NodeAttributes = attrs
343
        res = self._add_node(node)
344
        self._add_refs(obj)
345
        res[0].StatusCode.check()
346
        return res[0].AddedNodeId
347
348
    def _add_refs(self, obj):
349
        if not obj.refs:
350
            return
@@ 162-173 (lines=12) @@
159
        return res[0].AddedNodeId
160
161
    def add_object_type(self, obj):
162
        node = self._get_node(obj)
163
        attrs = ua.ObjectTypeAttributes()
164
        if obj.desc:
165
            attrs.Description = ua.LocalizedText(obj.desc)
166
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
167
        attrs.IsAbstract = obj.abstract
168
        node.NodeAttributes = attrs
169
        res = self._add_node(node)
170
        self._add_refs(obj)
171
        res[0].StatusCode.check()
172
        return res[0].AddedNodeId
173
174
    def add_variable(self, obj):
175
        node = self._get_node(obj)
176
        attrs = ua.VariableAttributes()
@@ 149-160 (lines=12) @@
146
                return ua.NodeId(getattr(ua.ObjectIds, nodeid))
147
148
    def add_object(self, obj):
149
        node = self._get_node(obj)
150
        attrs = ua.ObjectAttributes()
151
        if obj.desc:
152
            attrs.Description = ua.LocalizedText(obj.desc)
153
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
154
        attrs.EventNotifier = obj.eventnotifier
155
        node.NodeAttributes = attrs
156
        res = self._add_node(node)
157
        self._add_refs(obj)
158
        res[0].StatusCode.check()
159
        return res[0].AddedNodeId
160
161
    def add_object_type(self, obj):
162
        node = self._get_node(obj)
163
        attrs = ua.ObjectTypeAttributes()