Parses a string and returns a pin-num.

def parse_pin(name_str):
    """Parses a string and returns a pin-num."""
    if len(name_str) < 1:
        raise ValueError("Expecting pin name to be at least 4 charcters.")
    if name_str[0] != 'P':
        raise ValueError("Expecting pin name to start with P")
    pin_str = name_str[1:].split('/')[0]
    if not pin_str.isdigit():
        raise ValueError("Expecting numeric pin number.")
    return int(pin_str)