def unparse_netloc(user, password, hostname, port):
    """
    We expect the arguments to be strings, empty if not present.
    """
    netloc = ''
    up = user + ':' + password + '@'
    if len(up) > 2:
        netloc = up
    netloc += hostname
    if len(port) > 0:
        netloc += ':' + port
    return netloc
