Code Duplication    Length = 13-14 lines in 2 locations

uawidgets/refs_widget.py 2 locations

@@ 102-115 (lines=14) @@
99
        self.do_remove_ref(ref)
100
        self.reload()
101
    
102
    def do_remove_ref(self, ref, check=True):
103
        logger.info("Removing: %s", ref)
104
        it = ua.DeleteReferencesItem()
105
        it.SourceNodeId = self.node.nodeid
106
        it.ReferenceTypeId = ref.ReferenceTypeId
107
        it.IsForward = ref.IsForward
108
        it.TargetNodeId = ref.NodeId
109
        it.DeleteBidirectional = False
110
        #param = ua.DeleteReferencesParameters()
111
        #param.ReferencesToDelete.append(it)
112
        results = self.node.server.delete_references([it])
113
        logger.info("Remove result: %s", results[0]) 
114
        if check:
115
            results[0].check()
116
117
    def save_state(self):
118
        self.settings.setValue("refs_widget", self.view.horizontalHeader().saveState())
@@ 200-212 (lines=13) @@
197
            return
198
        self._write_ref(ref)
199
200
    def _write_ref(self, ref):
201
        logger.info("Writing ref %s", ref)
202
        it = ua.AddReferencesItem()
203
        it.SourceNodeId = self._widget.node.nodeid
204
        it.ReferenceTypeId = ref.ReferenceTypeId
205
        it.IsForward = ref.IsForward
206
        it.TargetNodeId = ref.NodeId
207
        it.TargetNodeClass = ref.NodeClass
208
209
        results = self._widget.node.server.add_references([it])
210
        results[0].check()
211
212
        self._widget.reload()
213
214
215