示例#1
0
def test_inheritance_yaml():
    test_file = os.path.join("tests", "fixtures", "child.yaml")
    data = open_yaml(os.path.join("tests", "fixtures", "config"), test_file)
    eq_(data, {
        "key": "hello world",
        "pass": "******"
    })
示例#2
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()
示例#3
0
 def get_data(self, file_name):
     file_extension = os.path.splitext(file_name)[1]
     if file_extension == ".json":
         data = utils.open_json(self.context_dirs, file_name)
     elif file_extension in [".yml", ".yaml"]:
         data = utils.open_yaml(self.context_dirs, file_name)
         utils.merge(data, self.__cached_environ_variables)
     else:
         raise exceptions.IncorrectDataInput
     return data
示例#4
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)
示例#5
0
文件: engine.py 项目: SerekKiri/moban
 def get_data(self, file_name):
     data = utils.open_yaml(self.context_dirs, file_name)
     utils.merge(data, self.__cached_environ_variables)
     return data
示例#6
0
文件: engine.py 项目: chfw/moban
 def get_data(self, file_name):
     return open_yaml(self.context_dirs, file_name)
示例#7
0
def test_simple_yaml():
    test_file = os.path.join("tests", "fixtures", "simple.yaml")
    data = open_yaml(os.path.join("tests", "fixtures"), test_file)
    eq_(data, {"simple": "yaml"})
示例#8
0
def test_exception_3():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(None, test_file)
示例#9
0
def test_exception_2():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(os.path.join("tests", "fixtures", "config"), test_file)
示例#10
0
def test_inheritance_yaml():
    test_file = os.path.join("tests", "fixtures", "child.yaml")
    data = open_yaml(os.path.join("tests", "fixtures", "config"), test_file)
    eq_(data, {"key": "hello world", "pass": "******"})
示例#11
0
def test_simple_yaml():
    test_file = os.path.join("tests", "fixtures", "simple.yaml")
    data = open_yaml(os.path.join("tests", "fixtures"), test_file)
    eq_(data, {
        "simple": "yaml"
    })
示例#12
0
def test_exception_3():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(None, test_file)
示例#13
0
def test_exception_2():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(os.path.join("tests", "fixtures", "config"), test_file)