<commit_before>import os
import re
import datetime

from trovebox import Trovebox

def main():
    try:
        client = Trovebox()
        client.configure(api_version=2)

    except IOError, e:
        print
        print '!! Could not initialize Trovebox connection.'
        print '!! Check that ~/.config/trovebox/default exists and contains proper information.'
        print
        raise e

    starttime = datetime.datetime.now()

    for root, folders, files in os.walk(os.getcwd()):
        folder_name = album = None

        for filename in files:
            if not re.match(r'^.+\.jpg$', filename, flags=re.IGNORECASE):
                continue

            if not folder_name:
                folder_name = root.split('/')[-1]
                album = client.album.create(folder_name)
                print 'Entering folder %s' % root

            print 'Uploading %s...' % filename<commit_msg>Use full path as album name fallback. Support all Trovebox file types.<commit_after>import os
import re
import datetime

from trovebox import Trovebox
from trovebox.errors import TroveboxError

def main():
    try:
        client = Trovebox()
        client.configure(api_version=2)

    except IOError, e:
        print
        print '!! Could not initialize Trovebox connection.'
        print '!! Check that ~/.config/trovebox/default exists and contains proper information.'
        print
        raise e

    starttime = datetime.datetime.now()

    for root, folders, files in os.walk(os.getcwd()):
        folder_name = album = None

        for filename in files:
            # Trovebox supports .jpg, .gif, and .png files
            if not re.search(r'\.(jpg|jpeg|gif|png)$', filename, flags=re.IGNORECASE):
                continue

            if not folder_name:
                folder_name = root.split('/')[-1]

                try:
                    album = client.album.create(folder_name)
                except TroveboxError, e:
                    print e.message
                    print 'Using full path as album name as fallback'

                print 'Entering folder %s' % root

            print 'Uploading %s...' % filename
{'fraction_non_alphanumeric': 0.09200184928340269, 'fraction_numerical': 0.0018492834026814608, 'mean_word_length': 1.9125168236877523, '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': '1481652', 'n_tokens_mistral': 603, 'n_tokens_neox': 570, 'n_words': 186}