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

Function generate_details

src/licensedcode/license_db.py:107–144  ·  view source on GitHub ↗

Dumps data at ``output_path`` in JSON, YAML and HTML formats and also dumps the .LICENSE file with the license text and the data as YAML frontmatter. ``environment`` is a jinja Environment object used to generate the webpage and ``licenses`` is a mapping with scancode license data.

(output_path, environment, licenses, test=False)

Source from the content-addressed store, hash-verified

105
106
107def generate_details(output_path, environment, licenses, test=False):
108 """
109 Dumps data at ``output_path`` in JSON, YAML and HTML formats and also dumps
110 the .LICENSE file with the license text and the data as YAML frontmatter.
111
112 ``environment`` is a jinja Environment object used to generate the webpage
113 and ``licenses`` is a mapping with scancode license data.
114
115 ``test`` is to generate a stable output for testing only
116 """
117 from licensedcode.cache import get_cache
118 include_builtin = get_cache().has_additional_licenses
119
120 if test:
121 base_context_mapping = base_context_test
122 else:
123 base_context_mapping = base_context
124 license_details_template = environment.get_template("license_details.html")
125 for lic in licenses.values():
126 license_data = lic.to_dict(include_text=False, include_builtin=include_builtin)
127 license_data_with_text = lic.to_dict(include_text=True, include_builtin=include_builtin)
128 html = license_details_template.render(
129 **base_context_mapping,
130 license=lic,
131 license_data=license_data,
132 )
133 write_file(output_path, f"{lic.key}.html", html)
134 write_file(
135 output_path,
136 f"{lic.key}.yml",
137 saneyaml.dump(license_data_with_text, indent=2)
138 )
139 write_file(
140 output_path,
141 f"{lic.key}.json",
142 json.dumps(license_data_with_text, indent=2, sort_keys=False)
143 )
144 lic.dump(output_path)
145
146
147def generate_help(output_path, environment, test=False):

Callers 1

generateFunction · 0.85

Calls 7

get_cacheFunction · 0.90
write_fileFunction · 0.70
valuesMethod · 0.45
to_dictMethod · 0.45
renderMethod · 0.45
dumpMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected