<commit_before># Copyright 2017-2019 TensorHub, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division

import functools
import logging

import click
import six

from guild import config

log = logging.getLogger("guild")

TABLE_COL_SPACING = 2

try:
    input = raw_input
except NameError:
    input = input

_noted = set()

def error(msg=None, exit_status=1):
    raise SystemExit(msg, exit_status)

def out(s="", wrap=False, **kw):
    if wrap:
        s = _wrap(s)
    _echo(s, **kw)

def _wrap(s):
    terminal_width = click.get_terminal_size()[0]
    width = max(min(terminal_width, 78), 40)
    return click.wrap_text(s, width)

def _echo(s, err=False, **kw):
    if config.log_output():
        if err:
            log.warning(s)
        else:
            log.info(s)
    else:
        click.echo(s, err=err, **kw)

def note(msg):
    _echo(click.style(msg, dim=True), err=True)
    _noted.add(msg)

def note_once(msg):
    if msg not in _noted:
        note(msg)

def table(data, cols, sort=None, detail=None, indent=0, err=False):
    data = sorted(data, key=_table_row_sort_key(sort))
    formatted = _format_data(data, cols + (detail or []))
    col_info = _col_info(formatted, cols)
    width, _ = click.get_terminal_size()
    for item in formatted:
        _item_out(item, cols, col_info, detail, indent, width, err)

def _table_row_sort_key(sort):
    if not sort:
        return lambda _: 0
    else:
        return functools.cmp_to_key(lambda x, y: _item_cmp(x, y, sort))

def _item_cmp(x, y, sort):
    if isinstance(sort, str):
        return _val_cmp(x, y, sort)
    else:
        for part in sort:
            part_cmp = _val_cmp(x, y, part)
            if part_cmp != 0:
                return part_cmp
        return 0

def _val_cmp(x, y, sort):
    if sort.startswith("-"):
        sort = sort[1:]
        rev = -1<commit_msg>Don't cut off table output - let wrap<commit_after># Copyright 2017-2019 TensorHub, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division

import functools
import logging

import click
import six

from guild import config

log = logging.getLogger("guild")

TABLE_COL_SPACING = 2
MAX_WIDTH = 999

try:
    input = raw_input
except NameError:
    input = input

_noted = set()

def error(msg=None, exit_status=1):
    raise SystemExit(msg, exit_status)

def out(s="", wrap=False, **kw):
    if wrap:
        s = _wrap(s)
    _echo(s, **kw)

def _wrap(s):
    terminal_width = click.get_terminal_size()[0]
    width = max(min(terminal_width, 78), 40)
    return click.wrap_text(s, width)

def _echo(s, err=False, **kw):
    if config.log_output():
        if err:
            log.warning(s)
        else:
            log.info(s)
    else:
        click.echo(s, err=err, **kw)

def note(msg):
    _echo(click.style(msg, dim=True), err=True)
    _noted.add(msg)

def note_once(msg):
    if msg not in _noted:
        note(msg)

def table(data, cols, sort=None, detail=None, indent=0, err=False):
    data = sorted(data, key=_table_row_sort_key(sort))
    formatted = _format_data(data, cols + (detail or []))
    col_info = _col_info(formatted, cols)
    for item in formatted:
        _item_out(item, cols, col_info, detail, indent, MAX_WIDTH, err)

def _table_row_sort_key(sort):
    if not sort:
        return lambda _: 0
    else:
        return functools.cmp_to_key(lambda x, y: _item_cmp(x, y, sort))

def _item_cmp(x, y, sort):
    if isinstance(sort, str):
        return _val_cmp(x, y, sort)
    else:
        for part in sort:
            part_cmp = _val_cmp(x, y, part)
            if part_cmp != 0:
                return part_cmp
        return 0

def _val_cmp(x, y, sort):
    if sort.startswith("-"):
        sort = sort[1:]
        rev = -1
{'fraction_non_alphanumeric': 0.1063961912647485, 'fraction_numerical': 0.010970813496170566, 'mean_word_length': 3.0639192598822538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1397654', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1600, 'n_words': 517}