parameters: (self, url)
return_statement: return ''.join([parts.netloc, parts.path])
docstring: extract host and port from an URL string
docstring_summary: extract host and port from an URL string
docstring_tokens: extract host and port from an URL string
function: def from_url(self, url):
          """extract host and port from an URL string"""
          parts = urlparse.urlsplit(url)
          if parts.scheme != 'spy':
              raise serial.SerialException(
                  'expected a string in the form '
                  '"spy://port[?option[=value][&option[=value]]]": '
                  'not starting with spy:// ({!r})'.format(parts.scheme))
          # process options now, directly altering self
          formatter = FormatHexdump
          color = False
          output = sys.stderr
          try:
              for option, values in urlparse.parse_qs(parts.query, True).items():
                  if option == 'file':
                      output = open(values[0], 'w')
                  elif option == 'color':
                      color = True
                  elif option == 'raw':
                      formatter = FormatRaw
                  elif option == 'all':
                      self.show_all = True
                  else:
                      raise ValueError('unknown option: {!r}'.format(option))
          except ValueError as e:
              raise serial.SerialException(
                  'expected a string in the form '
                  '"spy://port[?option[=value][&option[=value]]]": {}'.format(e))
          self.formatter = formatter(output, color)
          return ''.join([parts.netloc, parts.path])
function_tokens: def from_url ( self , url ) : parts = urlparse . urlsplit ( url ) if parts . scheme != 'spy' : raise serial . SerialException ( 'expected a string in the form ' '"spy://port[?option[=value][&option[=value]]]": ' 'not starting with spy:// ({!r})' . format ( parts . scheme ) ) # process options now, directly altering self formatter = FormatHexdump color = False output = sys . stderr try : for option , values in urlparse . parse_qs ( parts . query , True ) . items ( ) : if option == 'file' : output = open ( values [ 0 ] , 'w' ) elif option == 'color' : color = True elif option == 'raw' : formatter = FormatRaw elif option == 'all' : self . show_all = True else : raise ValueError ( 'unknown option: {!r}' . format ( option ) ) except ValueError as e : raise serial . SerialException ( 'expected a string in the form ' '"spy://port[?option[=value][&option[=value]]]": {}' . format ( e ) ) self . formatter = formatter ( output , color ) return '' . join ( [ parts . netloc , parts . path ] )