<commit_before>#!/usr/bin/env python
import os


def get_terminal_width():
    "Borrowed from the py lib."
    try:
        import termios
        import fcntl
        import struct
        call = fcntl.ioctl(0, termios.TIOCGWINSZ,
                           struct.pack('hhhh', 0, 0, 0, 0))
        _, width = struct.upack('hhhh', call)[:2]
        return width
    except (SystemExit, KeyboardInterrupt):
        raise
    except:
        # Fallback
        return int(os.environ.get('COLUMNS', 80))


class Progress(object):
    def __init__(self, marker='#', left='', right='', fill=' '):
        self.marker = marker
        self.left = left
        self.right = right
        if len(fill) == 0:
            raise ValueError('You must fill something.')
        self.fill = fill
        self.width = get_terminal_width()

    def __call__(self, current, total, blank='', status=''):
        if current > total:
            raise ValueError("current can't be larger than total.")
        marker = int(self.width / float(total)) * current * self.marker
        marker = self.left + marker + self.right
        count = len(blank) + len(status)
        if len(marker) >= self.width - count:
            split = self.width - count - len(self.right)
            marker = marker[:split] + self.right
        to_fill = self.width - len(marker) - count
        fill = ((to_fill - 1) / len(self.fill) + 1) * self.fill
        fill = fill[:to_fill]
        return blank + marker + fill + status<commit_msg>make progress works well<commit_after>#!/usr/bin/env python
import os


def get_terminal_width():
    """Borrowed from the py lib."""
    try:
        import termios
        import fcntl
        import struct
        call = fcntl.ioctl(0, termios.TIOCGWINSZ,
                           struct.pack('hhhh', 0, 0, 0, 0))
        height, width = struct.unpack('hhhh', call)[:2]
        terminal_width = width
    except (SystemExit, KeyboardInterrupt):
        raise
    except:
        # FALLBACK
        terminal_width = int(os.environ.get('COLUMNS', 80)) - 1
    return terminal_width


class Progress(object):
    def __init__(self, marker='#', left='', right='', fill=' '):
        self.marker = marker
        self.left = left
        self.right = right
        if len(fill) != 1:
            raise ValueError('You must a char.')
        self.fill = fill
        self.width = get_terminal_width()

    def __call__(self, current, total, blank='', status=''):
        if current > total:
            raise ValueError("current can't be larger than total.")
        count = len(blank) + len(status) + len(self.left) + len(self.right)

        marker = int((self.width - count) / float(total) * current) * \
                self.marker
        if len(marker) >= self.width - count:
            marker = marker[:self.width - count]

        bar = blank + self.left + marker + self.right
        text = status.rjust(self.width, self.fill)
        text = text.replace(self.fill * len(bar), bar, 1)
        return text
{'fraction_non_alphanumeric': 0.12749003984063745, 'fraction_numerical': 0.0073041168658698535, 'mean_word_length': 2.061991869918699, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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}}
{'dir': 'git-commits-cleaned', 'id': '5070624', 'n_tokens_mistral': 918, 'n_tokens_neox': 882, 'n_words': 243}