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

Function generate

src/licensedcode/license_db.py:162–192  ·  view source on GitHub ↗

Generate a licenseDB static website and dump license data at ``build_location`` given a license directory ``licenses_data_dir`` using templates from ``template_dir``. ``test`` is to generate a stable output for testing only

(
    build_location,
    template_dir=TEMPLATES_DIR,
    licenses_data_dir=licenses_data_dir,
    test=False,
)

Source from the content-addressed store, hash-verified

160
161
162def generate(
163 build_location,
164 template_dir=TEMPLATES_DIR,
165 licenses_data_dir=licenses_data_dir,
166 test=False,
167):
168 """
169 Generate a licenseDB static website and dump license data at
170 ``build_location`` given a license directory ``licenses_data_dir`` using
171 templates from ``template_dir``. ``test`` is to generate a stable output for
172 testing only
173 """
174
175 if not os.path.exists(build_location):
176 os.makedirs(build_location)
177
178 env = Environment(
179 loader=FileSystemLoader(template_dir),
180 autoescape=True,
181 )
182 licenses = dict(sorted(
183 load_licenses(licenses_data_dir=licenses_data_dir, with_deprecated=True).items()
184 ))
185
186 root_path = pathlib.Path(build_location)
187 root_path.mkdir(parents=False, exist_ok=True)
188
189 count = generate_indexes(output_path=root_path, environment=env, licenses=licenses, test=test)
190 generate_details(output_path=root_path, environment=env, licenses=licenses, test=test)
191 generate_help(output_path=root_path, environment=env, test=test)
192 return count
193
194
195def scancode_license_data(path):

Calls 6

load_licensesFunction · 0.90
EnvironmentClass · 0.85
generate_indexesFunction · 0.85
generate_detailsFunction · 0.85
generate_helpFunction · 0.85
existsMethod · 0.45