Parse a single line.
(self, line: str, line_number: int)
| 115 | return self.options |
| 116 | |
| 117 | def _parse_line(self, line: str, line_number: int) -> None: |
| 118 | """Parse a single line.""" |
| 119 | # Check for #define |
| 120 | match = self.RE_DEFINE.match(line) |
| 121 | if match: |
| 122 | name = match.group(1) |
| 123 | value = match.group(2) if match.group(2) else '1' |
| 124 | |
| 125 | # Parse value |
| 126 | parsed_value, value_type = self._parse_value(value.strip()) |
| 127 | |
| 128 | # Create option |
| 129 | option = ConfigOption( |
| 130 | name=name, |
| 131 | value=parsed_value, |
| 132 | type=value_type, |
| 133 | line_number=line_number |
| 134 | ) |
| 135 | |
| 136 | self.options[name] = option |
| 137 | return |
| 138 | |
| 139 | # Check for #undef |
| 140 | match = self.RE_UNDEF.match(line) |
| 141 | if match: |
| 142 | name = match.group(1) |
| 143 | if name in self.options: |
| 144 | del self.options[name] |
| 145 | return |
| 146 | |
| 147 | def _parse_value(self, value: str) -> tuple: |
| 148 | """ |
no test coverage detected