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

Class RuleData

etc/scripts/licenses/buildrules.py:55–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54@attr.attrs(slots=True)
55class RuleData(object):
56 data_lines = attr.ib()
57 text_lines = attr.ib()
58 raw_data = attr.ib(default=None)
59 data = attr.ib(default=None)
60 text = attr.ib(default=None)
61
62 def __attrs_post_init__(self, *args, **kwargs):
63 self.raw_data = rdat = "\n".join(self.data_lines).strip()
64 self.text = "\n".join(self.text_lines).strip() + "\n"
65
66 # validate YAML syntax
67 try:
68 self.data = saneyaml.load(rdat)
69 except:
70 print("########################################################")
71 print("Invalid YAML:")
72 print(rdat)
73 print("########################################################")
74 raise
75 if "referenced_filenames" in self.data and not self.data["referenced_filenames"]:
76 self.data.pop("referenced_filenames")
77 self.data = {
78 k: v for k, v in self.data.items()
79 if v is not None
80 or (v is None and k == "license_expression")
81 }
82
83
84def load_data(location="00-new-licenses.txt"):

Callers 1

load_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected