Code Duplication    Length = 11-12 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

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