code: def uri_to_kwargs(uri):
      
      parsed = urlparse(uri)
      default_user = get_current_user()
      password = unquote(parsed.password) if parsed.password else None
      kwargs = {'host': parsed.hostname,
                'port': parsed.port,
                'dbname': parsed.path[1:] or default_user,
                'user': parsed.username or default_user,
                'password': password}
      values = parse_qs(parsed.query)
      if 'host' in values:
          kwargs['host'] = values['host'][0]
      for k in [k for k in values if k in KEYWORDS]:
          kwargs[k] = values[k][0] if len(values[k]) == 1 else values[k]
          try:
              if kwargs[k].isdigit():
                  kwargs[k] = int(kwargs[k])
          except AttributeError:
              pass
      return kwargs
docs: Return a URI as kwargs for connecting to PostgreSQL with psycopg2,
      applying default values for non-specified areas of the URI.
  
      :param str uri: The connection URI
      :rtype: dict