Code Duplication    Length = 11-12 lines in 2 locations

asyncua/server/server.py 1 location

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

asyncua/client/client.py 1 location

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