Code Duplication    Length = 11-12 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

@@ 331-342 (lines=12) @@
328
329
    def add_datatype(self, obj):
330
        node = self._get_node(obj)
331
        attrs = ua.DataTypeAttributes()
332
        if obj.desc:
333
            attrs.Description = ua.LocalizedText(obj.desc)
334
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
335
        if obj.abstract:
336
            attrs.IsAbstract = obj.abstract
337
        node.NodeAttributes = attrs
338
        res = self.server.add_nodes([node])
339
        self._add_refs(obj)
340
        return res[0].AddedNodeId
341
342
    def _add_refs(self, obj):
343
        if not obj.refs:
344
            return
345
        refs = []
@@ 186-196 (lines=11) @@
183
184
    def add_object_type(self, obj):
185
        node = self._get_node(obj)
186
        attrs = ua.ObjectTypeAttributes()
187
        if obj.desc:
188
            attrs.Description = ua.LocalizedText(obj.desc)
189
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
190
        attrs.IsAbstract = obj.abstract
191
        node.NodeAttributes = attrs
192
        res = self.server.add_nodes([node])
193
        self._add_refs(obj)
194
        return res[0].AddedNodeId
195
196
    def add_variable(self, obj):
197
        node = self._get_node(obj)
198
        attrs = ua.VariableAttributes()
199
        if obj.desc:
@@ 174-184 (lines=11) @@
171
172
    def add_object(self, obj):
173
        node = self._get_node(obj)
174
        attrs = ua.ObjectAttributes()
175
        if obj.desc:
176
            attrs.Description = ua.LocalizedText(obj.desc)
177
        attrs.DisplayName = ua.LocalizedText(obj.displayname)
178
        attrs.EventNotifier = obj.eventnotifier
179
        node.NodeAttributes = attrs
180
        res = self.server.add_nodes([node])
181
        self._add_refs(obj)
182
        return res[0].AddedNodeId
183
184
    def add_object_type(self, obj):
185
        node = self._get_node(obj)
186
        attrs = ua.ObjectTypeAttributes()
187
        if obj.desc: