Return a LicenseCache loaded from ``cache_file``.
(cache_file)
| 436 | |
| 437 | |
| 438 | def load_cache_file(cache_file): |
| 439 | """ |
| 440 | Return a LicenseCache loaded from ``cache_file``. |
| 441 | """ |
| 442 | with open(cache_file, 'rb') as lfc: |
| 443 | # Note: weird but read() + loads() is much (twice++???) faster than load() |
| 444 | try: |
| 445 | return pickle.load(lfc) |
| 446 | except Exception as e: |
| 447 | msg = ( |
| 448 | 'ERROR: Failed to load license cache (the file may be corrupted ?).\n' |
| 449 | f'Please delete "{cache_file}" and retry.\n' |
| 450 | 'If the problem persists, copy this error message ' |
| 451 | 'and submit a bug report at https://github.com/nexB/scancode-toolkit/issues/' |
| 452 | ) |
| 453 | raise Exception(msg) from e |
| 454 | |
| 455 | |
| 456 | def get_index( |