def add_formatted_flags(flags_name, format):
            """Print CMake flags using macros_printer.

            Arguments:
            flags_name - Name to search for in config_compilers.
            format - Function that takes a build type and flag match, and
            returns the string to print out.
            """

            paths = ["compiler/"+flags_name, "compiler/ADD_"+flags_name]

            # This creates an iterable over elements in config_compilers
            # that match in non-debug mode.
            normal_matches = chain.from_iterable(
                all_matches(self.compiler_xml_tree, path, normal_dict)
                for path in paths
                )
            for match in normal_matches:
                macros_printer.print(format(model, match.text))

            # Now the same for debug mode.
            debug_matches = chain.from_iterable(
                all_matches(self.compiler_xml_tree, path, debug_dict)
                for path in paths
                )
            for match in debug_matches:
                macros_printer.print(format(model+"_DEBUG", match.text))
예제 #2
0
        def add_formatted_flags(flags_name, format):
            """Print CMake flags using macros_printer.

            Arguments:
            flags_name - Name to search for in config_compilers.
            format - Function that takes a build type and flag match, and
            returns the string to print out.
            """

            paths = ["compiler/" + flags_name, "compiler/ADD_" + flags_name]

            # This creates an iterable over elements in config_compilers
            # that match in non-debug mode.
            normal_matches = chain.from_iterable(
                all_matches(self.compiler_xml_tree, path, normal_dict)
                for path in paths)
            for match in normal_matches:
                macros_printer.print(format("CESM", match.text))

            # Now the same for debug mode.
            debug_matches = chain.from_iterable(
                all_matches(self.compiler_xml_tree, path, debug_dict)
                for path in paths)
            for match in debug_matches:
                macros_printer.print(format("CESM_DEBUG", match.text))
예제 #3
0
 def test_no_attr_matches(self):
     """all_matches returns no elements if none match attributes."""
     self.assertEqual(
         [e.text for e in all_matches(self.xml_tree, "test4/data",
                                      {"valid": "true"})],
         [],
         )
예제 #4
0
 def test_ignore_attribute(self):
     """all_matches can ignore "extra" attributes."""
     self.assertEqual(
         [e.text for e in
          all_matches(self.xml_tree, "test6/data",
                      ignore=["ignore"])],
         ["the_text"]
         )
예제 #5
0
 def test_attr_matches(self):
     """all_matches returns elements that match attributes."""
     self.assertEqual(
         [e.text for e in
          all_matches(self.xml_tree, "test5/data",
                      {"valid": "true", "invalid": "false"})],
         ["first_text", "second_text", "third_text", "fourth_text"],
         )
예제 #6
0
    def test_multiple_matches(self):
        """all_matches returns many elements successfully.

        Elements must be returned in the right order as well.
        """
        self.assertEqual(
            [e.text for e in all_matches(self.xml_tree, "test2/data")],
            ["first_text", "second_text"],
            )
예제 #7
0
 def test_no_attr_matches(self):
     """all_matches returns no elements if none match attributes."""
     self.assertEqual(
         [
             e.text for e in all_matches(self.xml_tree, "test4/data",
                                         {"valid": "true"})
         ],
         [],
     )
예제 #8
0
    def test_multiple_matches(self):
        """all_matches returns many elements successfully.

        Elements must be returned in the right order as well.
        """
        self.assertEqual(
            [e.text for e in all_matches(self.xml_tree, "test2/data")],
            ["first_text", "second_text"],
        )
예제 #9
0
 def test_attr_matches(self):
     """all_matches returns elements that match attributes."""
     self.assertEqual(
         [
             e.text for e in all_matches(self.xml_tree, "test5/data", {
                 "valid": "true",
                 "invalid": "false"
             })
         ],
         ["first_text", "second_text", "third_text", "fourth_text"],
     )
예제 #10
0
 def string_to_elements(xml_str, ignore="key"):
     """Converts an XML string to a list of its "ENV" elements."""
     return all_matches(ElementTree(XML(xml_str)), "ENV",
                        ignore=ignore)
예제 #11
0
 def test_no_matches(self):
     """all_matches returns no elements if none are found."""
     self.assertEqual(
         [e.text for e in all_matches(self.xml_tree, "test3/data")],
         [],
         )
예제 #12
0
 def test_one_match(self):
     """all_matches returns one element successfully."""
     self.assertEqual(
         [e.text for e in all_matches(self.xml_tree, "test1/data")],
         ["the_text"],
         )
예제 #13
0
 def string_to_elements(xml_str, ignore="key"):
     """Converts an XML string to a list of its "ENV" elements."""
     return all_matches(ElementTree(XML(xml_str)), "ENV", ignore=ignore)
예제 #14
0
 def test_ignore_attribute(self):
     """all_matches can ignore "extra" attributes."""
     self.assertEqual([
         e.text for e in all_matches(
             self.xml_tree, "test6/data", ignore=["ignore"])
     ], ["the_text"])
예제 #15
0
 def test_no_matches(self):
     """all_matches returns no elements if none are found."""
     self.assertEqual(
         [e.text for e in all_matches(self.xml_tree, "test3/data")],
         [],
     )
예제 #16
0
 def test_one_match(self):
     """all_matches returns one element successfully."""
     self.assertEqual(
         [e.text for e in all_matches(self.xml_tree, "test1/data")],
         ["the_text"],
     )