import re


def parse_portpin(name):
    """Finds the port name and number of a pin in a string. If found
    returns a tuple in the form of ('port_name', port_number).
    Otherwise returns `None`.
    """
    m = re.search("P([A-Z])(\d+)", name)
    if m:
        port_name, port_number = m.groups()
        return (port_name, int(port_number))