<jupyter_start><jupyter_text>`switch` in python<jupyter_code>def _format_time(hh, mm, ss, us, timespec='auto'):
    specs = {
        'hours': '{:02d}',
        'minutes': '{:02d}:{:02d}',
        'seconds': '{:02d}:{:02d}:{:02d}',
        'milliseconds': '{:02d}:{:02d}:{:02d}.{:03d}',
        'microseconds': '{:02d}:{:02d}:{:02d}.{:06d}'
    }

    if timespec == 'auto':
        # Skip trailing microseconds when us==0.
        timespec = 'microseconds' if us else 'seconds'
    elif timespec == 'milliseconds':
        us //= 1000
    try:
        fmt = specs[timespec]
    except KeyError:
        raise ValueError('Unknown timespec value')
    else:
        return fmt.format(hh, mm, ss, us)

_format_time(10, 35, 15, 185150)
import datetime as dt

dt.datetime.now()
import logging
logger = logging.getLogger('remoto')

log_map = {
        'debug': logger.debug,
        'error': logger.error,
        'warning': logger.warning
}

logger.info('falling back to')

level_received = 'debug'
message = 'HELLO'
log_map[level_received](message.strip('\r\n'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18089990817263543, 'fraction_numerical': 0.04132231404958678, 'mean_word_length': 3.2248062015503876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '655803', 'license': 'MIT', 'n_tokens_mistral': 425, 'n_tokens_neox': 397, 'n_words': 81, 'path': 'switch.ipynb', 'repo_name': 'loosak/pysnippets', 'size': '1089'}