Code Duplication    Length = 7-10 lines in 3 locations

opcua/common/subscription.py 1 location

@@ 315-324 (lines=10) @@
312
311
310
309
308
307
306
305
304
303
302
301
300
299
298
297
296
295
294
293
292
291
290
289
288
287
286
285
284
283
282
281
280
279
278
277
276

opcua/server/event.py 1 location

@@ 111-117 (lines=7) @@
108
109
            def __init__(self):
110
                super(CustomEvent, self).__init__(extended=True)
111
                self.EventType = node.nodeid
112
                curr_node = node
113
114
                while curr_node.nodeid.Identifier != parent_identifier:
115
                    for prop in curr_node.get_properties():
116
                        setattr(self, prop.get_browse_name().Name, prop.get_value())
117
                    parents = curr_node.get_referenced_nodes(refs=ua.ObjectIds.HasSubtype, direction=ua.BrowseDirection.Inverse, includesubtypes=False)
118
                    if len(parents) != 1: # Something went wrong
119
                        return None
120
                    curr_node = parents[0]

opcua/common/events.py 1 location

@@ 137-146 (lines=10) @@
134
    properties = []
135
    curr_node = node
136
137
    while True:
138
        properties.extend(curr_node.get_properties())
139
140
        if curr_node.nodeid.Identifier == ua.ObjectIds.BaseEventType:
141
            break
142
143
        parents = curr_node.get_referenced_nodes(refs=ua.ObjectIds.HasSubtype, direction=ua.BrowseDirection.Inverse, includesubtypes=False)
144
        if len(parents) != 1:  # Something went wrong
145
            return None
146
        curr_node = parents[0]
147
148
    return properties
149