MCPcopy Create free account
hub / github.com/CLIUtils/CLI11 / read_header

Method read_header

scripts/MakeSingleHeader.py:52–75  ·  view source on GitHub ↗

Read a header file in and add items to the dict, based on the item's action.

(self, filename)

Source from the content-addressed store, hash-verified

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 """

Callers 1

make_headerFunction · 0.95

Calls 2

RuntimeErrorClass · 0.85
getMethod · 0.80

Tested by

no test coverage detected