anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: gdsfactory/gdsfactory
Issue: `Component.add_ports` should allow `Route.ports`

**Describe the bug**
`Component.add_ports` does not allow `Route.ports`, because `Route.ports` returns a tuple and `add_ports` accepts only lists or dicts.

```
  File ".../gdsfactory/component.py", line 976, in add_ports
    ports = ports if isinstance(ports, list) else ports.values()
                                                  ^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'values'
```

**To Reproduce**
the following in some approriate environment
```python
c = Component()
route = gf.routing.get_route(
    port,
    port2,
)
c.add_ports(route.ports)
```

**Expected behavior**
Ports to be added

**Suggested fix**
Extend `Component.add_ports` to allow a Sequence of Ports.

Changed files:
gdsfactory/component.py

diff --git a/gdsfactory/component.py b/gdsfactory/component.py
index 5de62d65d..4651a182a 100644
--- a/gdsfactory/component.py
+++ b/gdsfactory/component.py
@@ -12,7 +12,7 @@ import pathlib
 import uuid
 import warnings
 from collections import Counter
-from collections.abc import Iterable
+from collections.abc import Iterable, Mapping
 from copy import deepcopy
 from pathlib import Path
 from typing import Any, Dict, List, Optional, Set, Tuple, Union, TYPE_CHECKING
@@ -959,7 +959,7 @@ class Component(_GeometryHelper):
 
     def add_ports(
         self,
-        ports: Union[List[Port], Dict[str, Port]],
+        ports: Union[Iterable[Port], Dict[str, Port]],
         prefix: str = "",
         suffix: str = "",
         **kwargs,
@@ -973,8 +973,8 @@ class Component(_GeometryHelper):
             prefix: to prepend to each port name.
             suffix: to append to each port name.
         """
-        ports = ports if isinstance(ports, list) else ports.values()
-        for port in list(ports):
+        ports = ports.values() if isinstance(ports, Mapping) else ports
+        for port in ports:
             name = f"{prefix}{port.name}{suffix}"
             self.add_port(name=name, port=port, **kwargs)