<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import os

"""emoticry.emoticry

This file contains the bulk of logic for the emoticry library.
"""


def emojify(directory='.', recursive=False):
    """
    For the given directory, iterate over all files and folders within it
    (optionally recursively) and translate the file name characters to emoji.
    """
    if recursive:
        for files in os.walk(directory, topdown=True):
            path = files[0]
            directories = files[1]
            filenames = files[2]
            print('Directories in {0}:'.format(path))
            for d in directories:
                print(d)
            for f in filenames:
                print(f)
    else:
        for files in os.listdir(directory):
            print(files)<commit_msg>added initial file renaming<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import os

"""emoticry.emoticry

This file contains the bulk of logic for the emoticry library.
"""


class Translation(object):
    """
    A generic Translation class for translating filenames.
    """
    def __init__(self, table=[hex(_)[2:] for _ in range(256)]):
        self.table = table

    def translate(self, name):
        new_name = ''
        for c in name:
            if len(c) == 1:
                new_name += self.table[ord(c)]
            else:
                new_name += c
        return new_name

 
def emojify(directory='.', recursive=False, translation=Translation()):
    """
    For the given directory, iterate over all files and folders within it
    (optionally recursively) and translate the file name characters to emoji.
    """
    if recursive:
        for files in os.walk(directory, topdown=True):
            path = files[0]
            directories = files[1]
            filenames = files[2]
            print('Directories in {0}:'.format(path))
            for d in directories:
                print(d)
            for f in filenames:
                print(f)
    else:
        for f in os.listdir(directory):
            os.rename(os.path.join(directory, f), os.path.join(directory, translation.translate(f)))
{'fraction_non_alphanumeric': 0.10949929808142256, 'fraction_numerical': 0.0070191857744501636, 'mean_word_length': 2.1030478955007257, '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': '2183829', 'n_tokens_mistral': 627, 'n_tokens_neox': 598, 'n_words': 189}