Code Duplication    Length = 12-13 lines in 3 locations

opcua/common/xmlimporter.py 3 locations

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