Start the CSS modification.
()
| 29 | |
| 30 | |
| 31 | def main(): |
| 32 | """Start the CSS modification.""" |
| 33 | css_in = css_path_in.read_text(encoding="utf-8") |
| 34 | font_binary = font_path.read_bytes() |
| 35 | font_b64 = base64.b64encode(font_binary).decode("utf-8") |
| 36 | |
| 37 | css_out = [] |
| 38 | for css in css_in.split("\n"): |
| 39 | if "src: url(" in css: |
| 40 | css = ( |
| 41 | f" src: url(data:font/woff2;charset=utf-8;" |
| 42 | f'base64,{font_b64}) format("woff2");' |
| 43 | ) |
| 44 | elif "url(" in css: |
| 45 | continue |
| 46 | |
| 47 | css_out.append(css) |
| 48 | |
| 49 | css_out = "\n".join(css_out) |
| 50 | css_minified_out = rcssmin.cssmin(style=css_out) |
| 51 | |
| 52 | css_path_out.write_text(data=css_out, encoding="utf-8") |
| 53 | css_minified_path_out.write_text(data=css_minified_out, encoding="utf-8") |
| 54 | |
| 55 | |
| 56 | if __name__ == "__main__": |
no test coverage detected