<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setup(path_config="~/.config/scalar/config.yaml", configuration_name=None):
 """ Load a configuration from a default or specified configuration file, accessing a default or specified configuration name. """

    global config
    global client
    global token
    global room
    # config file
    path_config = Path(path_config).expanduser()
    log.debug("load config {path}".format(path = path_config))
    if not path_config.exists():
        log.error("no config {path} found".format(path = path_config))
        sys.exit()
    else:
        with open(str(path_config), "r") as _file:
            config = yaml.load(_file)
    if not configuration_name:
        for configuration in list(config["configurations"].items()):
            if configuration[1]["default"]:
                config = configuration[1]
    else:
        config["configurations"][configuration_name]
    # connect to homeserver and room
    log.debug("Matrix username: " + config["username"])
    log.debug("connect to homeserver " + config["homeserver"])
    client = MatrixClient(config["homeserver"])
    token = client.login_with_password(username = config["username"], password = config["passcode"])
    log.debug("connect to room " + config["room_alias"])
    room = client.join_room(config["room_alias"])