def update_robot_key(login_method, robot, key=None):
    """
    Utility to update the robot key store.
    @param login_method: the login_method name as per L{CFG_EXTERNAL_AUTHENTICATION}.
        It should correspond to a robot-enable login method.
    @type: string
    @param robot: the robot identifier
    @type robot: string
    @param key: the secret
    @type key: string
    @note: if the secret is empty the corresponding key will be removed.
    """
    from invenio.websearch_webcoll import mymkdir
    robot_keys = load_robot_keys()
    if key is None and login_method in robot_keys and robot in robot_keys[login_method]:
        del robot_keys[login_method][robot]
        if not robot_keys[login_method]:
            del robot_keys[login_method]
    else:
        if login_method not in robot_keys:
            robot_keys[login_method] = {}
        robot_keys[login_method][robot] = key
    mymkdir(os.path.join(CFG_ETCDIR, 'webaccess'))
    open(CFG_ROBOT_KEYS_PATH, 'w').write(compress(dumps(robot_keys, -1)))
def update_robot_key(login_method, robot, key=None):
    """
    Utility to update the robot key store.
    @param login_method: the login_method name as per L{CFG_EXTERNAL_AUTHENTICATION}.
        It should correspond to a robot-enable login method.
    @type: string
    @param robot: the robot identifier
    @type robot: string
    @param key: the secret
    @type key: string
    @note: if the secret is empty the corresponding key will be removed.
    """
    from invenio.websearch_webcoll import mymkdir
    robot_keys = load_robot_keys()
    if key is None and login_method in robot_keys and robot in robot_keys[login_method]:
        del robot_keys[login_method][robot]
        if not robot_keys[login_method]:
            del robot_keys[login_method]
    else:
        if login_method not in robot_keys:
            robot_keys[login_method] = {}
        robot_keys[login_method][robot] = key
    mymkdir(os.path.join(CFG_ETCDIR, 'webaccess'))
    open(CFG_ROBOT_KEYS_PATH, 'w').write(compress(dumps(robot_keys, -1)))