Read a header file in and add items to the dict, based on the item's action.
(self, filename)
| 50 | super(HeaderGroups, self).__init__() |
| 51 | |
| 52 | def read_header(self, filename): |
| 53 | """ |
| 54 | Read a header file in and add items to the dict, based on the item's action. |
| 55 | """ |
| 56 | with open(filename) as f: |
| 57 | inner = f.read() |
| 58 | |
| 59 | matches = self.re_matcher.findall(inner) |
| 60 | |
| 61 | if not matches: |
| 62 | warnings.warn( |
| 63 | "Failed to find any matches in {filename}".format(filename=filename) |
| 64 | ) |
| 65 | |
| 66 | for name, action, content in matches: |
| 67 | if action == "verbatim": |
| 68 | assert ( |
| 69 | name not in self |
| 70 | ), "{name} read in more than once! Quitting.".format(name=name) |
| 71 | self[name] = content |
| 72 | elif action == "set": |
| 73 | self[name] = self.get(name, set()) | set(content.strip().splitlines()) |
| 74 | else: |
| 75 | raise RuntimeError("Action not understood, must be verbatim or set") |
| 76 | |
| 77 | def post_process(self): |
| 78 | """ |
no test coverage detected