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,
)
| 160 | |
| 161 | |
| 162 | def 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 | |
| 195 | def scancode_license_data(path): |