<commit_before>import os
import shutil

from rtcFunctions import ImportHandler
from rtcFunctions import WorkspaceHandler
from rtcFunctions import RTCInitializer
from gitFunctions import Initializer
from gitFunctions import Commiter
import configuration
import shouter


def initialize(config):
    directory = config.workDirectory
    if os.path.exists(directory):
        shutil.rmtree(directory)
    os.mkdir(directory)
    os.chdir(directory)
    git = Initializer(config)
    git.initalize()
    RTCInitializer.initialize(config)
    git.initialcommitandpush()


def resume(config):
    os.chdir(config.workDirectory)
    os.chdir(config.clonedGitRepoName)
    RTCInitializer.loginandcollectstreams(config)


def startmigration():
    config = configuration.readconfig()
    rtc = ImportHandler(config)
    rtcworkspace = WorkspaceHandler(config)
    git = Commiter

    initialize(config)
    streamuuids = config.streamuuids
    for streamuuid in streamuuids:
        streamname = config.streamnames[streamuuids.index(streamuuid)]
        git.branch(streamname)
        componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(streamuuid)
        rtc.acceptchangesintoworkspace(rtc.getchangeentriesofstreamcomponents(componentbaselineentries))
        shouter.shout("All changes of components of stream '%s' accepted" % streamname)
        git.pushbranch(streamname)

        rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
        rtcworkspace.load()
        rtc.acceptchangesintoworkspace(rtc.getchangeentriesofstream(streamuuid))
        git.pushbranch(streamname)
        shouter.shout("All changes of stream '%s' accepted - Migration of stream completed" % streamname)
        rtcworkspace.recreateoldestworkspace()

startmigration()<commit_msg>don't (unnecessary) recreate workspace if last stream of list is migrated<commit_after>import os
import shutil

from rtcFunctions import ImportHandler
from rtcFunctions import WorkspaceHandler
from rtcFunctions import RTCInitializer
from gitFunctions import Initializer
from gitFunctions import Commiter
import configuration
import shouter


def initialize(config):
    directory = config.workDirectory
    if os.path.exists(directory):
        shutil.rmtree(directory)
    os.mkdir(directory)
    os.chdir(directory)
    git = Initializer(config)
    git.initalize()
    RTCInitializer.initialize(config)
    git.initialcommitandpush()


def resume(config):
    os.chdir(config.workDirectory)
    os.chdir(config.clonedGitRepoName)
    RTCInitializer.loginandcollectstreams(config)


def startmigration():
    config = configuration.readconfig()
    rtc = ImportHandler(config)
    rtcworkspace = WorkspaceHandler(config)
    git = Commiter

    initialize(config)
    streamuuids = config.streamuuids
    for streamuuid in streamuuids:
        streamname = config.streamnames[streamuuids.index(streamuuid)]
        git.branch(streamname)
        componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(streamuuid)
        rtc.acceptchangesintoworkspace(rtc.getchangeentriesofstreamcomponents(componentbaselineentries))
        shouter.shout("All changes of components of stream '%s' accepted" % streamname)
        git.pushbranch(streamname)

        rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
        rtcworkspace.load()
        rtc.acceptchangesintoworkspace(rtc.getchangeentriesofstream(streamuuid))
        git.pushbranch(streamname)
        shouter.shout("All changes of stream '%s' accepted - Migration of stream completed" % streamname)

        morestreamstomigrate = streamuuids.index(streamuuid) + 1 is not len(streamuuids)
        if morestreamstomigrate:
            rtcworkspace.recreateoldestworkspace()

startmigration()
{'fraction_non_alphanumeric': 0.07175006619009797, 'fraction_numerical': 0.00026476039184537993, 'mean_word_length': 4.420373027259684, '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': '7266388', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1010, 'n_words': 213}