Пример #1
0
 def __init__(self):
     self.machine_file = esm_parser.determine_computer_from_hostname()
     self.config = esm_parser.yaml_file_to_dict(self.machine_file)
     esm_parser.basic_choose_blocks(self.config, self.config)
     esm_parser.recursive_run_function([], self.config, "atomic",
                                       esm_parser.find_variable,
                                       self.config, [], True)
Пример #2
0
 def test_mappings(self):
     tree = []
     test_dict = {"echam": {1: 1, 2: [1, 2]}, "general": {"d": 1}}
     esm_parser.recursive_run_function(tree, test_dict, "mappings",
                                       replace_with_str_recursive_func,
                                       test_dict)
     r_dict = {
         "echam": "Went through recursion",
         "general": "Went through recursion",
     }
     self.assertEqual(r_dict, test_dict)
Пример #3
0
    def __init__(self, vcs, general):
        blacklist = [
            re.compile(entry)
            for entry in [".*version", ".*_dir", ".*grid", ".*archfile"]
        ]
        self.config = esm_parser.yaml_file_to_dict(components_yaml)
        self.model_kinds = list(self.config.keys())
        self.meta_todos = general.meta_todos
        self.meta_command_order = general.meta_command_order
        self.display_kinds = general.display_kinds

        self.model_todos = []
        for kind in self.model_kinds:
            for model in self.config[kind].keys():
                version = None
                if "choose_versions" in self.config[kind][model]:
                    for version in self.config[kind][model]["choose_versions"]:
                        for entry in self.config[kind][model]["choose_version"][
                            version
                        ]:
                            if entry.endswith("_command"):
                                todo = entry.replace("_command", "")
                                if todo not in self.model_todos:
                                    self.model_todos.append(todo)
                for entry in self.config[kind][model]:
                    if entry.endswith("_command"):
                        todo = entry.replace("_command", "")
                        if todo not in self.model_todos:
                            self.model_todos.append(todo)

        self.known_todos = self.model_todos + vcs.known_todos + general.meta_todos
        self.all_packages = self.list_all_packages(vcs, general)
        self.update_packages(vcs, general)
        esm_parser.recursive_run_function(
            [],
            self.config,
            "atomic",
            esm_parser.find_variable,
            self.config,
            blacklist,
            True,
        )
        #        self.output()

        if verbose > 1:
            self.output()
Пример #4
0
 def test_atomic(self):
     tree = []
     test_dict = {"echam": {1: 1, 2: [1, [1, 2]]}, "general": {"d": 1}}
     esm_parser.recursive_run_function(tree, test_dict, "atomic",
                                       replace_with_str_recursive_func,
                                       test_dict)
     r_dict = {
         "echam": {
             1:
             "Went through recursion",
             2: [
                 "Went through recursion",
                 ["Went through recursion", "Went through recursion"],
             ],
         },
         "general": {
             "d": "Went through recursion"
         },
     }
     self.assertEqual(r_dict, test_dict)
Пример #5
0
 def test_always(self):
     tree = []
     test_dict = {
         "echam": {
             "a": 1,
             "b": [1, 2, "str"]
         },
         "general": {
             "d": 1
         }
     }
     esm_parser.recursive_run_function(tree, test_dict, "always",
                                       recursive_always_tester, test_dict)
     r_dict = {
         "echam": {
             "a": 2,
             "b": ["newstr", 3, 2]
         },
         "general": {
             "d": 2
         }
     }
     self.assertEqual(r_dict, test_dict)