<commit_before>#!/usr/bin/env python
# encoding: utf8

# Copyright (C) 2015 by <NAME>.
# This file is part of crypto-enigma, an Enigma Machine simulator.
# released under the BSD-3 License (see LICENSE.txt).

"""
Description

.. note::
    Any additional note.
"""

from __future__ import (absolute_import, print_function, division, unicode_literals)

import time
import sys


# TBD - Generalize to other platforms; test?
def print_over(s, delay=0.2):
    print(s, end='\r')
    print("\033[F" * (s.count('\n')+1))
    sys.stdout.flush()
    time.sleep(delay)


def num_A0(c):
    return ord(c) - ord('A')


def chr_A0(n):
    return chr(n + ord('A'))


def ordering(items):
    return [i[1] for i in sorted(zip(items, range(0, len(items))))]


# standard simple-substitution cypher encoding
def encode_char(mapping, ch):
    if ch == ' ':
        return ' '
    else:
        return mapping[num_A0(ch)]


def encode_string(mapping, string):
    return ''.join([encode_char(mapping, ch) for ch in string])


# scan, because it's missing from Python; implemented to anticipate Python 3
def accumulate(l, f):
    it = iter(l)
    total = next(it)
    yield total
    for element in it:
        total = f(total, element)
        yield total


# also missing from Python
def chunk_of(it, n):
    return [it[i:i+n] for i in range(0, len(it), n)]


# require unicode strings (see unicode_literal in enigma.py) - http://stackoverflow.com/a/33743668/656912
def require_unicode(*given_arg_names):
    def check_types(_func_, *args):
        def modified(*args):
            arg_names = list(_func_.func_code.co_varnames[:_func_.func_code.co_argcount])
            if len(given_arg_names) == 0:
                unicode_arg_names = arg_names
            else:
                unicode_arg_names = given_arg_names
            for unicode_arg_name in unicode_arg_names:
                try:
                    arg_index = arg_names.index(unicode_arg_name)
                except ValueError:
                    raise NameError(unicode_arg_name)
                arg = args[arg_index]
                if not isinstance(arg, unicode):
                    raise TypeError("Parameter '{}' should be a Unicode literal".format(unicode_arg_name))
            return _func_(*args)
        return modified
    return check_types<commit_msg>Clarify message for Unicode argument requrement<commit_after>#!/usr/bin/env python
# encoding: utf8

# Copyright (C) 2015 by <NAME>.
# This file is part of crypto-enigma, an Enigma Machine simulator.
# released under the BSD-3 License (see LICENSE.txt).

"""
Description

.. note::
    Any additional note.
"""

from __future__ import (absolute_import, print_function, division, unicode_literals)

import time
import sys


# TBD - Generalize to other platforms; test?
def print_over(s, delay=0.2):
    print(s, end='\r')
    print("\033[F" * (s.count('\n')+1))
    sys.stdout.flush()
    time.sleep(delay)


def num_A0(c):
    return ord(c) - ord('A')


def chr_A0(n):
    return chr(n + ord('A'))


def ordering(items):
    return [i[1] for i in sorted(zip(items, range(0, len(items))))]


# standard simple-substitution cypher encoding
def encode_char(mapping, ch):
    if ch == ' ':
        return ' '
    else:
        return mapping[num_A0(ch)]


def encode_string(mapping, string):
    return ''.join([encode_char(mapping, ch) for ch in string])


# scan, because it's missing from Python; implemented to anticipate Python 3
def accumulate(l, f):
    it = iter(l)
    total = next(it)
    yield total
    for element in it:
        total = f(total, element)
        yield total


# also missing from Python
def chunk_of(it, n):
    return [it[i:i+n] for i in range(0, len(it), n)]


# require unicode strings (see unicode_literal in enigma.py) - http://stackoverflow.com/a/33743668/656912
def require_unicode(*given_arg_names):
    def check_types(_func_, *args):
        def modified(*args):
            arg_names = list(_func_.func_code.co_varnames[:_func_.func_code.co_argcount])
            if len(given_arg_names) == 0:
                unicode_arg_names = arg_names
            else:
                unicode_arg_names = given_arg_names
            for unicode_arg_name in unicode_arg_names:
                try:
                    arg_index = arg_names.index(unicode_arg_name)
                except ValueError:
                    raise NameError(unicode_arg_name)
                arg = args[arg_index]
                if not isinstance(arg, unicode):
                    raise TypeError("Parameter '{}' should be Unicode".format(unicode_arg_name))
            return _func_(*args)
        return modified
    return check_types
{'fraction_non_alphanumeric': 0.11163589523400601, 'fraction_numerical': 0.014598540145985401, 'mean_word_length': 2.703497615262321, '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}}
{'dir': 'git-commits-cleaned', 'id': '2093580', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1429, 'n_words': 400}