def _fix_port_assignment(self):
port_name = '<STR_LIT>'<EOL>port_number = None<EOL>if self._port:<EOL><INDENT>if isinstance(self._port, int):<EOL><INDENT>port_number = self._port<EOL>port_name = get_port_name(port_number)<EOL><DEDENT>elif isinstance(self._port, string_types):<EOL><INDENT>port_name = self._port<EOL>port_number = get_port_number(port_name)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % self._port)<EOL><DEDENT>self._port = port_number<EOL>self._portname = port_name or '<STR_LIT>'<EOL><DEDENT>
The :attr:`port` attribute can be set either by name or by its numeric
value. This method attempt to fix the semantics of name/number as its
extremely convenient.