Code Duplication    Length = 11-12 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

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