MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / dump

Method dump

src/licensedcode/models.py:2398–2423  ·  view source on GitHub ↗

Dump a representation of this rule as a .RULE file stored in ``rules_data_dir`` as a UTF-8 file having: - the rule data as YAML frontmatter - the rule text And this is a ``rule_file``. Also writes any kwargs as extra data in the rule metadata.

(self, rules_data_dir, **kwargs)

Source from the content-addressed store, hash-verified

2396 self.is_tiny = self.length < tiny_rule
2397
2398 def dump(self, rules_data_dir, **kwargs):
2399 """
2400 Dump a representation of this rule as a .RULE file stored in ``rules_data_dir`` as a UTF-8
2401 file having:
2402 - the rule data as YAML frontmatter
2403 - the rule text
2404 And this is a ``rule_file``.
2405
2406 Also writes any kwargs as extra data in the rule metadata.
2407
2408 Does nothing if this rule was created from a License (e.g., `is_from_license` is True)
2409 """
2410 if self.is_from_license or self.is_synthetic:
2411 return
2412
2413 rule_file = self.rule_file(rules_data_dir=rules_data_dir)
2414
2415 metadata = self.to_dict()
2416 # This can be used to pass objects to dump on the rule file with
2417 # other rule metadata, like debugging collection of required phrases
2418 if kwargs:
2419 metadata.update(kwargs)
2420 content = self.text
2421 output = dumps_frontmatter(content=content, metadata=metadata)
2422 with open(rule_file, 'w') as of:
2423 of.write(output)
2424
2425 def load(self, rule_file, with_checks=True):
2426 """

Callers 15

create_ruleMethod · 0.95
cleanMethod · 0.45
get_licensesMethod · 0.45
synchronize_licensesFunction · 0.45
cliFunction · 0.45
write_yamlFunction · 0.45
prettyFunction · 0.45
create_html_appFunction · 0.45

Calls 5

dumps_frontmatterFunction · 0.90
rule_fileMethod · 0.45
to_dictMethod · 0.45
updateMethod · 0.45
writeMethod · 0.45

Tested by 5

check_json_scanFunction · 0.36
check_jsonlines_scanFunction · 0.36
check_jsonFunction · 0.36
load_both_and_check_jsonFunction · 0.36