<commit_before>#!/usr/bin/env python3
"""Open Mutt and synchronize mailboxes."""

import subprocess
import threading
import os

# seconds to wait between syncs
WAIT_TIME = 60

# sync accounts once asynchronously, and wait for all syncs to finish
def offlineimap(aaulog, aulog):
    """Synchronize accounts."""
    aausync = subprocess.Popen(['offlineimap', '-a AAU'], stderr=aaulog)
    ausync = subprocess.Popen(['offlineimap', '-a AU'], stderr=aulog)
    aausync.communicate()
    ausync.communicate()

# sync every wait_time seconds and once after mutt closes
def autosync(mutt_has_closed, aaulog, aulog):
    """Resynchronize every WAIT_TIME seconds."""
    while not mutt_has_closed.is_set():
        offlineimap(aaulog, aulog)
        mutt_has_closed.wait(timeout=WAIT_TIME)
    offlineimap(aaulog, aulog)

def main():
    """Open Mutt and synchronize mail."""
    # prepare thread
    aaulogfile = os.path.expanduser('~/.config/offlineimap/AAU.log')
    aulogfile = os.path.expanduser('~/.config/offlineimap/AU.log')
    mutt_has_closed = threading.Event()
    with open(aaulogfile, 'w') as aaulog, open(aulogfile, 'w') as aulog:
        imap_thread = threading.Thread(target=autosync, args=(mutt_has_closed, aaulog, aulog,))
        # open log files, start thread, start mutt. When Mutt closes, kill thread gracefully.
        imap_thread.start()
        subprocess.call('mutt')
        mutt_has_closed.set()
        print('Synchronizing mailboxes. This may take a while.')
        imap_thread.join()

if __name__ == "__main__":
    main()<commit_msg>Reuse variables<commit_after>#!/usr/bin/env python3
"""Open Mutt and synchronize mailboxes."""

import subprocess
import threading
import os

# seconds to wait between syncs
WAIT_TIME = 60

# sync accounts once asynchronously, and wait for all syncs to finish
def offlineimap(aaulog, aulog):
    """Synchronize accounts."""
    aausync = subprocess.Popen(['offlineimap', '-a AAU'], stderr=aaulog)
    ausync = subprocess.Popen(['offlineimap', '-a AU'], stderr=aulog)
    aausync.communicate()
    ausync.communicate()

# sync every wait_time seconds and once after mutt closes
def autosync(mutt_has_closed, aaulog, aulog):
    """Resynchronize every WAIT_TIME seconds."""
    while not mutt_has_closed.is_set():
        offlineimap(aaulog, aulog)
        mutt_has_closed.wait(timeout=WAIT_TIME)
    offlineimap(aaulog, aulog)

def main():
    """Open Mutt and synchronize mail."""
    # prepare thread
    aaulog = os.path.expanduser('~/.config/offlineimap/AAU.log')
    aulog = os.path.expanduser('~/.config/offlineimap/AU.log')
    mutt_has_closed = threading.Event()
    with open(aaulog, 'w') as aaulog, open(aulog, 'w') as aulog:
        imap_thread = threading.Thread(target=autosync, args=(mutt_has_closed, aaulog, aulog,))
        # open log files, start thread, start mutt. When Mutt closes, kill thread gracefully.
        imap_thread.start()
        subprocess.call('mutt')
        mutt_has_closed.set()
        print('Synchronizing mailboxes. This may take a while.')
        imap_thread.join()

if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.12177835051546392, 'fraction_numerical': 0.0019329896907216496, 'mean_word_length': 3.8515625, 'pattern_counts': {'":': 2, '<': 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': '3679005', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1058, 'n_words': 260}