def set_pin_type(self, pin, ptype):
if type(pin) is list:<EOL><INDENT>for p in pin:<EOL><INDENT>self.set_pin_type(p, ptype)<EOL><DEDENT>return<EOL><DEDENT>pin_id = self._pin_mapping.get(pin, None)<EOL>if type(ptype) is not ahio.PortType:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>elif pin_id:<EOL><INDENT>self._set_pin_type(pin_id, ptype)<EOL><DEDENT>else:<EOL><INDENT>raise KeyError('<STR_LIT>' % pin)<EOL><DEDENT>
Sets pin `pin` to `type`.

        The pin should support the requested mode. Calling this function
        on a unmapped pin does nothing. Calling it with a unsupported mode
        throws RuntimeError.

        If you're developing a driver, you should implement
        _set_pin_type(self, pin, ptype) where `pin` will be one of your
        internal IDs. If a pin is set to OUTPUT, put it on LOW state.

        @arg pin pin id you've set using `AbstractDriver.map_pin`
        @arg mode a value from `AbstractDriver.PortType`

        @throw KeyError if pin isn't mapped.
        @throw RuntimeError if type is not supported by pin.