sonar/base_types.py
def _get_ports(
        self,
        attribute: str,
        directions: Union[str, tuple, list],
        collapse: bool,
    ) -> Union[list, dict]:
        """
        Return some subset of the ports of the module based on the attribute and
        directions.

        Args:
            attribute (str): Type of port to get
            directions (Union[str, tuple, list]): Direction(s) of the port type
                to get
            collapse (bool): Collapse all ports into a list if true or return as
                a dict where the direction is the key

        Raises:
            SonarInvalidArgError: Raised if a direction is passed as a string and
                the port type or direction does not exist.

        Returns:
            Union[list, dict]: The retrieved ports of the module
        """
        if isinstance(directions, str):
            try:
                ports = getattr(getattr(self, attribute), directions)
            except KeyError as ex:
                raise SonarInvalidArgError from ex
            return ports
        if collapse:
            ports = []
        else:
            ports = {}
        for direction in directions:
            try:
                ports_subset = getattr(getattr(self, attribute), direction)
            except KeyError:
                logger.warning(
                    "Direction %s not found in %s, skipping.",
                    direction,
                    attribute,
                )
            else:
                if collapse:
                    ports.extend(ports_subset)
                else:
                    ports[direction] = ports_subset
        return ports

        Return some subset of the ports of the module based on the attribute and
        directions.

        Args:
            attribute (str): Type of port to get
            directions (Union[str, tuple, list]): Direction(s) of the port type
                to get
            collapse (bool): Collapse all ports into a list if true or return as
                a dict where the direction is the key

        Raises:
            SonarInvalidArgError: Raised if a direction is passed as a string and
                the port type or direction does not exist.

        Returns:
            Union[list, dict]: The retrieved ports of the module
        
Return some subset of the ports of the module based on the attribute and
directions.
Return some subset of the ports of the module based on the attribute and directions .
def _get_ports(
        self,
        attribute: str,
        directions: Union[str, tuple, list],
        collapse: bool,
    ) -> Union[list, dict]:
        if isinstance(directions, str):
            try:
                ports = getattr(getattr(self, attribute), directions)
            except KeyError as ex:
                raise SonarInvalidArgError from ex
            return ports
        if collapse:
            ports = []
        else:
            ports = {}
        for direction in directions:
            try:
                ports_subset = getattr(getattr(self, attribute), direction)
            except KeyError:
                logger.warning(
                    "Direction %s not found in %s, skipping.",
                    direction,
                    attribute,
                )
            else:
                if collapse:
                    ports.extend(ports_subset)
                else:
                    ports[direction] = ports_subset
        return ports
def _get_ports ( self , attribute : str , directions : Union [ str , tuple , list ] , collapse : bool , ) -> Union [ list , dict ] : if isinstance ( directions , str ) : try : ports = getattr ( getattr ( self , attribute ) , directions ) except KeyError as ex : raise SonarInvalidArgError from ex return ports if collapse : ports = [ ] else : ports = { } for direction in directions : try : ports_subset = getattr ( getattr ( self , attribute ) , direction ) except KeyError : logger . warning ( "Direction %s not found in %s, skipping." , direction , attribute , ) else : if collapse : ports . extend ( ports_subset ) else : ports [ direction ] = ports_subset return ports
Return some subset of the ports of the module based on the attribute and
directions.
Return some subset of the ports of the module based on the attribute and directions .
"""
        Return some subset of the ports of the module based on the attribute and
        directions.

        Args:
            attribute (str): Type of port to get
            directions (Union[str, tuple, list]): Direction(s) of the port type
                to get
            collapse (bool): Collapse all ports into a list if true or return as
                a dict where the direction is the key

        Raises:
            SonarInvalidArgError: Raised if a direction is passed as a string and
                the port type or direction does not exist.

        Returns:
            Union[list, dict]: The retrieved ports of the module
        """
The retrieved ports of the module
The retrieved ports of the module
Union[list, dict]
Raised if a direction is passed as a string and
the port type or direction does not exist.
Raised if a direction is passed as a string and the port type or direction does not exist .
SonarInvalidArgError
self
attribute
str
Type of port to get
Type of port to get
directions
Union[str, tuple, list]
Direction(s) of the port type
to get
Direction ( s ) of the port type to get
collapse
bool
Collapse all ports into a list if true or return as
a dict where the direction is the key
Collapse all ports into a list if true or return as a dict where the direction is the key