def METHOD_NAME(flow_graph, direction, domain=None):
    """
    Get a list of io ports for this flow graph.
    Returns a list of dicts with: type, label, vlen, size, optional
    """
    pads = flow_graph.get_pad_sources(
    ) if direction == 'inputs' else flow_graph.get_pad_sinks()
    for pad in pads:
        for port in (pad.sources if direction == 'inputs' else pad.sinks):
            if domain and port.domain != domain:
                continue
            yield port