<jupyter_start><jupyter_text>📚 For more information please visit our [GitHub](https://github.com/MinorMole/instant_woff2otf/).<jupyter_code>#@markdown <h3>📌 Run this cell to start.</h3>

import os, time; from google.colab import files; from IPython.display import HTML, clear_output

if os.path.isfile("/root/.woff2otf/woff2otf.py") == False:
  !rm -rf /content/sample_data/ && mkdir -p -m 666 /root/.woff2otf/ && wget -q https://raw.githubusercontent.com/MinorMole/instant_woff2otf/master/res/woff2otf.py -O /root/.woff2otf/woff2otf.py
try:
  display(HTML("<h2 style=\"font-family:Trebuchet MS;color:#446785;\">Please upload 'woff' font from your computer.</h2><br>"))
  UploadConfig = files.upload().keys()
  clear_output()
  if len(UploadConfig) == 0:
    display(HTML("<center><h2 style=\"font-family:Trebuchet MS;color:#ce2121;\">File upload has been cancelled during upload file.</h2><br></center>"))
  else:
    Count = 0
    Total = str(len(UploadConfig))
    !rm -f /root/.woff2otf/converted_font.zip && rm -rf /root/.woff2otf/cache/ && mkdir -p -m 666 /root/.woff2otf/cache/
    for filename in os.listdir("/content/"):
      if filename.endswith(".woff"):
        get_ipython().system_raw("python /root/.woff2otf/woff2otf.py" + " " + os.path.join('/content/', filename) + " " + os.path.join('/root/.woff2otf/cache/', filename.replace('.woff', '.otf')) + " && rm -f " + os.path.join('/content/', filename))
        Count += 1
        clear_output(wait=True)
        print("Completed " + str(Count) + " out of " + Total)
        continue
    ### Compressing File.
    !zip -r -q -j -9 /root/.woff2otf/converted_font.zip /root/.woff2otf/cache/
    ### Send Zip File
    try:
      files.download("/root/.woff2otf/converted_font.zip")
      clear_output()
      display(HTML("<center><h2 style=\"font-family:Trebuchet MS;color:#446785;\">Sending font to your computer...</h2><br></center>"))
    except:
      !mv /root/.woff2otf/converted_font.zip /content/converted_font_$(date +%Y-%m-%d_%H.%M.%S).zip
      clear_output()
      display(HTML("<center><h2 style=\"font-family:Trebuchet MS;color:#446785;\">You can use file explorer to download the font file.</h2><br><img src=\"https://github.com/MinorMole/instant_woff2otf/raw/master/img/01.png\"><br></center>"))
except:
  clear_output()
  display(HTML("<center><h2 style=\"font-family:Trebuchet MS;color:#ce2121;\">Error occurred during upload file.</h2><br></center>"))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1877285656237302, 'fraction_numerical': 0.028037383177570093, 'mean_word_length': 3.8946322067594434, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '616580', 'license': 'MIT', 'n_tokens_mistral': 942, 'n_tokens_neox': 901, 'n_words': 160, 'path': 'Instant_woff2otf.ipynb', 'repo_name': 'MinorMole/instant_woff2otf', 'size': '2461'}