<commit_before>#!/usr/bin/env python

from epiphan import EpiphanRecorder
from time import sleep, strftime
from os.path import exists
from os import makedirs
from random import choice
from string import ascii_uppercase
from epiphan_config import parse_config, write_config
import pygiftgrab


def session_folder():
    attempts = 0
    while attempts < 5:
        attempts += 1
        unique_suffix = ''.join(choice(ascii_uppercase) for _ in range(5))
        folder = strftime('%Y-%m-%d-%H-%M-%S') + '-' +\
                 unique_suffix + '/'

        if not exists(folder):
            makedirs(folder)
            return True, folder
        else:
            print 'Folder ' + folder + \
                  ' exists, will make a ' + \
                  str(attempts) + '. attempt'
    print 'Made ' + str(attempts) + \
          ' unsuccessful attempts to create ' + \
          'a uniquely-named folder'
    return False, folder

if __name__ == '__main__':<commit_msg>Issue #35: renamed folder => folder_name to avoid shadowing folder from outer scope<commit_after>#!/usr/bin/env python

from epiphan import EpiphanRecorder
from time import sleep, strftime
from os.path import exists
from os import makedirs
from random import choice
from string import ascii_uppercase
from epiphan_config import parse_config, write_config
import pygiftgrab


def session_folder():
    attempts = 0
    while attempts < 5:
        attempts += 1
        unique_suffix = ''.join(choice(ascii_uppercase) for _ in range(5))
        folder_name = strftime('%Y-%m-%d-%H-%M-%S') + '-' +\
            unique_suffix + '/'

        if not exists(folder_name):
            makedirs(folder_name)
            return True, folder_name
        else:
            print 'Folder ' + folder_name + \
                  ' exists, will make a ' + \
                  str(attempts) + '. attempt'
    print 'Made ' + str(attempts) + \
          ' unsuccessful attempts to create ' + \
          'a uniquely-named folder'
    return False, folder_name

if __name__ == '__main__':
{'fraction_non_alphanumeric': 0.09789525208027411, 'fraction_numerical': 0.004894762604013705, 'mean_word_length': 2.3398692810457518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4305495', 'n_tokens_mistral': 620, 'n_tokens_neox': 583, 'n_words': 178}