示例#1
0
def handle_moban_file(moban_file, options):
    """
    act upon default moban file
    """
    moban_file_configurations = open_yaml(None, moban_file)
    if moban_file_configurations is None:
        raise exceptions.MobanfileGrammarException(
            constants.ERROR_INVALID_MOBAN_FILE % moban_file
        )
    if (
        constants.LABEL_TARGETS not in moban_file_configurations
        and constants.LABEL_COPY not in moban_file_configurations
    ):
        raise exceptions.MobanfileGrammarException(
            constants.ERROR_NO_TARGETS % moban_file
        )
    version = moban_file_configurations.get(
        constants.MOBAN_VERSION, constants.DEFAULT_MOBAN_VERSION
    )
    if version == constants.DEFAULT_MOBAN_VERSION:
        mobanfile.handle_moban_file_v1(moban_file_configurations, options)
    else:
        raise exceptions.MobanfileGrammarException(
            constants.MESSAGE_FILE_VERSION_NOT_SUPPORTED % version
        )
    HASH_STORE.save_hashes()
示例#2
0
文件: main.py 项目: jayvdb/moban
def handle_moban_file(options):
    """
    act upon default moban file
    """
    moban_file_configurations = open_yaml(
        None,
        constants.DEFAULT_MOBAN_FILE)
    if moban_file_configurations is None:
        print(ERROR_INVALID_MOBAN_FILE % constants.DEFAULT_MOBAN_FILE)
        sys.exit(-1)
    if constants.LABEL_TARGETS not in moban_file_configurations:
        print(ERROR_NO_TARGETS % constants.DEFAULT_MOBAN_FILE)
        sys.exit(0)
    version = moban_file_configurations.get(
        constants.MOBAN_VERSION,
        constants.DEFAULT_MOBAN_VERSION
    )
    if version == constants.DEFAULT_MOBAN_VERSION:
        handle_moban_file_v1(moban_file_configurations, options)
    else:
        raise NotImplementedError(
            "moban file version %d is not supported" % version)