# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/00_core.ipynb (unless otherwise specified). __all__ = ['format_time', 'html_progress_bar', 'html_progress_bar_styles', 'text2html_table', 'in_colab', 'IN_COLAB', 'in_notebook', 'IN_NOTEBOOK'] # Cell def format_time(t): "Format `t` (in seconds) to (h):mm:ss" t = int(t) h,m,s = t//3600, (t//60)%60, t%60 if h!= 0: return f'{h}:{m:02d}:{s:02d}' else: return f'{m:02d}:{s:02d}' # Cell # the styles are static so we'll keep the browser from recalculating # them every time we update the progress bar widget html_progress_bar_styles = """ """ def html_progress_bar(value, total, label, interrupted=False): "Html code for a progress bar `value`/`total` with `label`" bar_style = 'progress-bar-interrupted' if interrupted else '' val = '' if total is None else f"value='{value}'" return f"""
{label}
""" # Cell def text2html_table(items): "Put the texts in `items` in an HTML table." html_code = f"""\n""" html_code += f""" \n \n""" for i in items[0]: html_code += f" \n" html_code += f" \n \n \n" for line in items[1:]: html_code += " \n" for i in line: html_code += f" \n" html_code += " \n" html_code += " \n
{i}
{i}

" return html_code # Cell def in_colab(): "Check if the code is running in Google Colaboratory" try: from google import colab return True except: return False IN_COLAB = in_colab() # Cell def in_notebook(): "Check if the code is running in a jupyter notebook" if in_colab(): return True try: shell = get_ipython().__class__.__name__ if shell == 'ZMQInteractiveShell': # Jupyter notebook, Spyder or qtconsole import IPython #IPython version lower then 6.0.0 don't work with output you update return IPython.__version__ >= '6.0.0' elif shell == 'TerminalInteractiveShell': return False # Terminal running IPython else: return False # Other type (?) except NameError: return False # Probably standard Python interpreter IN_NOTEBOOK = in_notebook()