Try to get a function to provide frontend assets. Returns: Either (a) a callable that takes no arguments and returns an open file handle to a Zip archive of frontend assets, or (b) `None`, if the frontend assets cannot be found.
()
| 22 | |
| 23 | |
| 24 | def get_default_assets_zip_provider(): |
| 25 | """Try to get a function to provide frontend assets. |
| 26 | |
| 27 | Returns: |
| 28 | Either (a) a callable that takes no arguments and returns an open |
| 29 | file handle to a Zip archive of frontend assets, or (b) `None`, if |
| 30 | the frontend assets cannot be found. |
| 31 | """ |
| 32 | path = os.path.join(os.path.dirname(__file__), "webfiles.zip") |
| 33 | if not os.path.exists(path): |
| 34 | logger.warning("webfiles.zip static assets not found: %s", path) |
| 35 | return None |
| 36 | return lambda: open(path, "rb") |