Code Duplication    Length = 11-12 lines in 2 locations

asyncua/server/server.py 1 location

@@ 389-399 (lines=11) @@
386
        ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
387
        return ns_node.get_value()
388
389
    async def register_namespace(self, uri) -> int:
390
        """
391
        Register a new namespace. Nodes should in custom namespace, not 0.
392
        """
393
        ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
394
        uries = await ns_node.get_value()
395
        if uri in uries:
396
            return uries.index(uri)
397
        uries.append(uri)
398
        await ns_node.set_value(uries)
399
        return len(uries) - 1
400
401
    async def get_namespace_index(self, uri):
402
        """

asyncua/client/client.py 1 location

@@ 532-543 (lines=12) @@
529
        await exp.build_etree(nodes)
530
        await exp.write_xml(path)
531
532
    async def register_namespace(self, uri):
533
        """
534
        Register a new namespace. Nodes should in custom namespace, not 0.
535
        This method is mainly implemented for symetry with server
536
        """
537
        ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
538
        uries = await ns_node.get_value()
539
        if uri in uries:
540
            return uries.index(uri)
541
        uries.append(uri)
542
        await ns_node.set_value(uries)
543
        return len(uries) - 1
544
545
    def load_type_definitions(self, nodes=None) -> Coroutine:
546
        """