Skip to content

Commit

Permalink
Merge pull request #504 from gdsfactory/add_ports_suffix
Browse files Browse the repository at this point in the history
add suffix
  • Loading branch information
sebastian-goeldi authored Oct 23, 2024
2 parents dbbb6d9 + 6f6166e commit 8eb8a8d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/kfactory/kcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,12 +947,16 @@ def add_port(
return _port

def add_ports(
self, ports: Iterable[Port], prefix: str = "", keep_mirror: bool = False
self,
ports: Iterable[Port],
prefix: str = "",
keep_mirror: bool = False,
suffix: str = "",
) -> None:
"""Append a list of ports."""
for p in ports:
name = p.name or ""
self.add_port(port=p, name=prefix + name, keep_mirror=keep_mirror)
self.add_port(port=p, name=prefix + name + suffix, keep_mirror=keep_mirror)

@overload
def create_port(
Expand Down Expand Up @@ -1672,7 +1676,11 @@ def add_port(
return self.ports.add_port(port=port, name=name, keep_mirror=keep_mirror)

def add_ports(
self, ports: Iterable[Port], prefix: str = "", keep_mirror: bool = False
self,
ports: Iterable[Port],
prefix: str = "",
suffix: str = "",
keep_mirror: bool = False,
) -> None:
"""Add a sequence of ports to the cells.
Expand All @@ -1681,12 +1689,15 @@ def add_ports(
Args:
ports: list/tuple (anything iterable) of ports.
prefix: string to add in front of all the port names
suffix: string to add the end of all the port names.
keep_mirror: Keep the mirror part of the transformation of a port if
`True`, else set the mirror flag to `False`.
"""
if self._locked:
raise LockedError(self)
self.ports.add_ports(ports=ports, prefix=prefix, keep_mirror=keep_mirror)
self.ports.add_ports(
ports=ports, prefix=prefix, suffix=suffix, keep_mirror=keep_mirror
)

@classmethod
def from_yaml(
Expand Down

0 comments on commit 8eb8a8d

Please sign in to comment.