Code Duplication    Length = 11-12 lines in 2 locations

asyncua/server/server.py 1 location

@@ 426-436 (lines=11) @@
423
        ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
424
        return ns_node.read_value()
425
426
    async def register_namespace(self, uri) -> int:
427
        """
428
        Register a new namespace. Nodes should in custom namespace, not 0.
429
        """
430
        ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
431
        uries = await ns_node.read_value()
432
        if uri in uries:
433
            return uries.index(uri)
434
        uries.append(uri)
435
        await ns_node.write_value(uries)
436
        return len(uries) - 1
437
438
    async def get_namespace_index(self, uri):
439
        """

asyncua/client/client.py 1 location

@@ 567-578 (lines=12) @@
564
        await exp.build_etree(nodes)
565
        await exp.write_xml(path)
566
567
    async def register_namespace(self, uri):
568
        """
569
        Register a new namespace. Nodes should in custom namespace, not 0.
570
        This method is mainly implemented for symetry with server
571
        """
572
        ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
573
        uries = await ns_node.read_value()
574
        if uri in uries:
575
            return uries.index(uri)
576
        uries.append(uri)
577
        await ns_node.write_value(uries)
578
        return len(uries) - 1
579
580
    def load_type_definitions(self, nodes=None) -> Coroutine:
581
        """