Find the .tagcube config file in the current directory, or in the
    user's home and parse it. The one in the current directory has precedence.
    
    :return: A tuple with:
                - email
                - api_token

def parse_config_file():
    """
    Find the .tagcube config file in the current directory, or in the
    user's home and parse it. The one in the current directory has precedence.
    
    :return: A tuple with:
                - email
                - api_token
    """
    for filename in ('.tagcube', os.path.expanduser('~/.tagcube')):

        filename = os.path.abspath(filename)

        if not os.path.exists(filename):
            msg = 'TagCube configuration file "%s" does not exist'
            cli_logger.debug(msg % filename)
            continue

        msg = 'Parsing tagcube configuration file "%s"'
        cli_logger.debug(msg % filename)

        email, api_key = _parse_config_file_impl(filename)
        if email is not None and api_key is not None:
            msg = ('Found authentication credentials:\n'
                   '    email: %s\n'
                   '    api_key: %s')
            tokenized_api_key = '%s...%s' % (api_key[:3], api_key[-3:])
            args = (email, tokenized_api_key)
            cli_logger.debug(msg % args)

            return email, api_key
        else:
            msg = 'Configuration file does not contain credentials'
            cli_logger.debug(msg)
    else:
        return None, None