Code Duplication    Length = 11-12 lines in 2 locations

asyncua/client/client.py 1 location

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

asyncua/server/server.py 1 location

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