def handle_moban_file(moban_file, options): """ act upon default moban file """ moban_file_configurations = load_data(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 ) check_none(moban_file_configurations, 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()
def get_data(self, file_name): try: data = load_data(self.context_dirs, file_name) utils.merge(data, self.__cached_environ_variables) return data except (IOError, exceptions.IncorrectDataInput) as exception: # If data file doesn't exist: # 1. Alert the user of their (potential) mistake # 2. Attempt to use environment vars as data reporter.report_warning_message(str(exception)) reporter.report_using_env_vars() return self.__cached_environ_variables
def test_exception_3(): test_file = os.path.join("tests", "fixtures", "dragon.yaml") load_data(None, test_file)
def test_exception_2(): test_file = os.path.join("tests", "fixtures", "dragon.yaml") load_data(os.path.join("tests", "fixtures", "config"), test_file)
def test_inheritance_yaml(): test_file = os.path.join("tests", "fixtures", "child.yaml") data = load_data(os.path.join("tests", "fixtures", "config"), test_file) eq_(data, {"key": "hello world", "pass": "******"})