<commit_before># -*- coding: utf8 -*-

import sys

from behave.formatter.ansi_escapes import escapes, up
from behave.formatter.base import Formatter


def escape_cell(cell):
    cell = cell.replace(u'\\', u'\\\\')
    cell = cell.replace(u'\n', u'\\n')
    cell = cell.replace(u'|', u'\\|')
    return cell


class MonochromeFormat(object):
    def text(self, text):
        assert isinstance(text, unicode)
        return text


class ColorFormat(object):
    def __init__(self, status):
        self.status = status

    def text(self, text):
        assert isinstance(text, unicode)
        return escapes[self.status] + text + escapes['reset']


def get_terminal_size():
    if sys.platform == 'windows':
        # Autodetecting the size of a Windows command window is left as an
        # exercise for the reader. Prizes may be awarded for the best answer.
        return (80, 24)

    try:
        import fcntl
        import termios
        import struct

        zero_struct = struct.pack('HHHH', 0, 0, 0, 0)
        result = fcntl.ioctl(0, termios.TIOCGWINSZ, zero_struct)
        h, w, hp, wp = struct.unpack('HHHH', result)

        return w or 80, h or 24
    except:
        return (80, 24)


class PrettyFormatter(Formatter):
    name = 'pretty'
    description = 'Standard colourised pretty formatter'

    def __init__(self, stream, config):
        super(PrettyFormatter, self).__init__(stream, config)<commit_msg>Replace some magic numbers with constants.<commit_after># -*- coding: utf8 -*-

import sys

from behave.formatter.ansi_escapes import escapes, up
from behave.formatter.base import Formatter

DEFAULT_WIDTH = 80
DEFAULT_HEIGHT = 24

def escape_cell(cell):
    cell = cell.replace(u'\\', u'\\\\')
    cell = cell.replace(u'\n', u'\\n')
    cell = cell.replace(u'|', u'\\|')
    return cell


class MonochromeFormat(object):
    def text(self, text):
        assert isinstance(text, unicode)
        return text


class ColorFormat(object):
    def __init__(self, status):
        self.status = status

    def text(self, text):
        assert isinstance(text, unicode)
        return escapes[self.status] + text + escapes['reset']


def get_terminal_size():
    if sys.platform == 'windows':
        # Autodetecting the size of a Windows command window is left as an
        # exercise for the reader. Prizes may be awarded for the best answer.
        return (DEFAULT_WIDTH, DEFAULT_HEIGHT)

    try:
        import fcntl
        import termios
        import struct

        zero_struct = struct.pack('HHHH', 0, 0, 0, 0)
        result = fcntl.ioctl(0, termios.TIOCGWINSZ, zero_struct)
        h, w, hp, wp = struct.unpack('HHHH', result)

        return w or DEFAULT_WIDTH, h or DEFAULT_HEIGHT
    except:
        return (DEFAULT_WIDTH, DEFAULT_HEIGHT)


class PrettyFormatter(Formatter):
    name = 'pretty'
    description = 'Standard colourised pretty formatter'

    def __init__(self, stream, config):
        super(PrettyFormatter, self).__init__(stream, config)
{'fraction_non_alphanumeric': 0.11037012337445816, 'fraction_numerical': 0.009336445481827277, 'mean_word_length': 2.802281368821293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '348827', 'n_tokens_mistral': 956, 'n_tokens_neox': 883, 'n_words': 280}