Load data from ``rule_file`` which has both the text and the data (as YAML forntmatter). Check presence of text file to determine if this is a special synthetic rule.
(self, rule_file)
| 2285 | return python_safe_name(self.license_expression) |
| 2286 | |
| 2287 | def load_data(self, rule_file): |
| 2288 | """ |
| 2289 | Load data from ``rule_file`` which has both the text and the data (as YAML forntmatter). |
| 2290 | Check presence of text file to determine if this is a special synthetic rule. |
| 2291 | """ |
| 2292 | if self.is_synthetic: |
| 2293 | if not self.text: |
| 2294 | raise InvalidRule( |
| 2295 | f'Invalid synthetic rule without text: {self}: {self.text!r}') |
| 2296 | return self |
| 2297 | |
| 2298 | if not rule_file: |
| 2299 | raise InvalidRule( |
| 2300 | f'Cannot load rule without its corresponding rule_file: ' |
| 2301 | f'{self}: file://{rule_file}') |
| 2302 | |
| 2303 | self.identifier = file_name(rule_file) |
| 2304 | |
| 2305 | try: |
| 2306 | self.load(rule_file=rule_file) |
| 2307 | except Exception: |
| 2308 | trace = traceback.format_exc() |
| 2309 | raise InvalidRule(f'While loading: file://{rule_file}\n{trace}') |
| 2310 | |
| 2311 | return self |
| 2312 | |
| 2313 | def tokens(self): |
| 2314 | """ |
no test coverage detected