<commit_before># coding: utf8
from __future__ import unicode_literals
import unittest
from tempfile import mkdtemp

from clldutils.path import Path, rmtree


class WithTempDir(unittest.TestCase):
    def setUp(self):
        self.tmp = Path(mkdtemp())

    def tearDown(self):
        rmtree(self.tmp, ignore_errors=True)

    def tmp_path(self, *comps):
        return self.tmp.joinpath(*comps)<commit_msg>closes #2<commit_after># coding: utf8
from __future__ import unicode_literals
import unittest
from tempfile import mkdtemp
import sys
from contextlib import contextmanager

from six import StringIO

from clldutils.path import Path, rmtree


class WithTempDir(unittest.TestCase):
    def setUp(self):
        self.tmp = Path(mkdtemp())

    def tearDown(self):
        rmtree(self.tmp, ignore_errors=True)

    def tmp_path(self, *comps):
        return self.tmp.joinpath(*comps)


@contextmanager
def capture(func, *args, **kw):
    out, sys.stdout = sys.stdout, StringIO()
    func(*args, **kw)
    sys.stdout.seek(0)
    yield sys.stdout.read()
    sys.stdout = out
{'fraction_non_alphanumeric': 0.10148975791433892, 'fraction_numerical': 0.0037243947858473, 'mean_word_length': 3.8863636363636362, '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': '3057572', 'n_tokens_mistral': 359, 'n_tokens_neox': 346, 'n_words': 92}