<commit_before>import io
import os
import sys

from PyPDF2 import PdfFileReader

from PyQt5.QtCore import QThread
from PyQt5.QtCore import QObject
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QTextEdit
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtWidgets import QFileDialog
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtWidgets import QVBoxLayout
from PyQt5.QtWidgets import QHBoxLayout
from PyQt5.QtWidgets import QProgressBar
from PyQt5.QtWidgets import QApplication

import ttm


class Communicate(QObject):
    mailed = pyqtSignal(['QString'])
    finished = pyqtSignal()


class MainWindow(QMainWindow):

    communicate = Communicate()

    def __init__(self):
        QMainWindow.__init__(self)
        self.init_ui()

    def init_ui(self):
        self.setWindowTitle('Email Maplewood Timetables to UGCloud')
        self.setMinimumWidth(800)
        main_widget = QWidget()
        self.layout = QVBoxLayout()
        main_widget.setLayout(self.layout)

        self.file_row = QHBoxLayout()
        file_input_label = QLabel('Timetable File: ')
        self.file_input = QLineEdit()
        file_browser_button = QPushButton('Choose File...')
        file_browser_button.clicked.connect(lambda: self.open_file_browser(
                                            self.file_input))
        self.file_row.addWidget(file_input_label)
        self.file_row.addWidget(self.file_input)
        self.file_row.addWidget(file_browser_button)
        self.layout.addLayout(self.file_row)

        self.mail_row = QHBoxLayout()
        email_input_label = QLabel('Your UGCloud Email: ')
        self.email_input = QLineEdit()
        self.email_input.setText('<EMAIL>')
        self.mail_row.addWidget(email_input_label)
        self.mail_row.addWidget(self.email_input)
        self.layout.addLayout(self.mail_row)

        self.password_row = QHBoxLayout()
        password_input_label = QLabel('Your UGCloud Password: ')
        self.password_input = QLineEdit()
        self.password_input.setEchoMode(QLineEdit.Password)
        self.password_row.addWidget(password_input_label)
        self.password_row.addWidget(self.password_input)
        self.layout.addLayout(self.password_row)

        self.subject_row = QHBoxLayout()
        subject_input_label = QLabel('Subject for Emails: ')
        self.subject_input = QLineEdit()
        self.subject_input.setText('Enjoy your new timetable!')
        self.subject_row.addWidget(subject_input_label)
        self.subject_row.addWidget(self.subject_input)
        self.layout.addLayout(self.subject_row)

        self.go_row = QHBoxLayout()
        go_button = QPushButton('Send Timetables')
        go_button.clicked.connect(self.mail_timetables)
        self.go_row.addWidget(go_button)
        self.layout.addLayout(self.go_row)

        self.setCentralWidget(main_widget)

    def open_file_browser(self, input_to_change):
        self.file_dialog = QFileDialog()
        file_name = self.file_dialog.getOpenFileName(self,
                                                     'Choose Timetables',
                                                     os.path.expanduser('~'),
                                                     'PDF Files (*.pdf)')
        if file_name:
            input_to_change.setText(file_name[0])

    def init_output_display(self, pdf_page_count):
        output_window = QDialog()
        output_window.setWindowTitle('Mail Progress')
        layout = QVBoxLayout()

        self.progress_bar = QProgressBar()
        self.progress_bar.setMinimum(0)
        self.progress_bar.setMaximum(pdf_page_count)
        self.progress_bar.setValue(0)
        layout.addWidget(self.progress_bar)

        self.output_text = QTextEdit()
        self.output_text.setMinimumHeight(300)
        layout.addWidget(self.output_text)

        output_window.setLayout(layout)
        self.layout.addWidget(output_window)

    def update_output(self, address):
        self.output_text.insertPlainText('Sent email to {0}\n'.format(address))
        self.progress_bar.setValue(self.progress_bar.value() + 1)

    def finished(self):
        self.output_text.insertPlainText(' '.join(['Finished sending all',
                                                   'emails successfully\n']))<commit_msg>making output textedit read-only<commit_after>import io
import os
import sys

from PyPDF2 import PdfFileReader

from PyQt5.QtCore import QThread
from PyQt5.QtCore import QObject
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QTextEdit
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtWidgets import QFileDialog
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtWidgets import QVBoxLayout
from PyQt5.QtWidgets import QHBoxLayout
from PyQt5.QtWidgets import QProgressBar
from PyQt5.QtWidgets import QApplication

import ttm


class Communicate(QObject):
    mailed = pyqtSignal(['QString'])
    finished = pyqtSignal()


class MainWindow(QMainWindow):

    communicate = Communicate()

    def __init__(self):
        QMainWindow.__init__(self)
        self.init_ui()

    def init_ui(self):
        self.setWindowTitle('Email Maplewood Timetables to UGCloud')
        self.setMinimumWidth(800)
        main_widget = QWidget()
        self.layout = QVBoxLayout()
        main_widget.setLayout(self.layout)

        self.file_row = QHBoxLayout()
        file_input_label = QLabel('Timetable File: ')
        self.file_input = QLineEdit()
        file_browser_button = QPushButton('Choose File...')
        file_browser_button.clicked.connect(lambda: self.open_file_browser(
                                            self.file_input))
        self.file_row.addWidget(file_input_label)
        self.file_row.addWidget(self.file_input)
        self.file_row.addWidget(file_browser_button)
        self.layout.addLayout(self.file_row)

        self.mail_row = QHBoxLayout()
        email_input_label = QLabel('Your UGCloud Email: ')
        self.email_input = QLineEdit()
        self.email_input.setText('<EMAIL>')
        self.mail_row.addWidget(email_input_label)
        self.mail_row.addWidget(self.email_input)
        self.layout.addLayout(self.mail_row)

        self.password_row = QHBoxLayout()
        password_input_label = QLabel('Your UGCloud Password: ')
        self.password_input = QLineEdit()
        self.password_input.setEchoMode(QLineEdit.Password)
        self.password_row.addWidget(password_input_label)
        self.password_row.addWidget(self.password_input)
        self.layout.addLayout(self.password_row)

        self.subject_row = QHBoxLayout()
        subject_input_label = QLabel('Subject for Emails: ')
        self.subject_input = QLineEdit()
        self.subject_input.setText('Enjoy your new timetable!')
        self.subject_row.addWidget(subject_input_label)
        self.subject_row.addWidget(self.subject_input)
        self.layout.addLayout(self.subject_row)

        self.go_row = QHBoxLayout()
        go_button = QPushButton('Send Timetables')
        go_button.clicked.connect(self.mail_timetables)
        self.go_row.addWidget(go_button)
        self.layout.addLayout(self.go_row)

        self.setCentralWidget(main_widget)

    def open_file_browser(self, input_to_change):
        self.file_dialog = QFileDialog()
        file_name = self.file_dialog.getOpenFileName(self,
                                                     'Choose Timetables',
                                                     os.path.expanduser('~'),
                                                     'PDF Files (*.pdf)')
        if file_name:
            input_to_change.setText(file_name[0])

    def init_output_display(self, pdf_page_count):
        output_window = QDialog()
        output_window.setWindowTitle('Mail Progress')
        layout = QVBoxLayout()

        self.progress_bar = QProgressBar()
        self.progress_bar.setMinimum(0)
        self.progress_bar.setMaximum(pdf_page_count)
        self.progress_bar.setValue(0)
        layout.addWidget(self.progress_bar)

        self.output_text = QTextEdit()
        self.output_text.setMinimumHeight(300)
        self.output_text.setReadOnly(True)
        layout.addWidget(self.output_text)

        output_window.setLayout(layout)
        self.layout.addWidget(output_window)

    def update_output(self, address):
        self.output_text.insertPlainText('Sent email to {0}\n'.format(address))
        self.progress_bar.setValue(self.progress_bar.value() + 1)

    def finished(self):
        self.output_text.insertPlainText(' '.join(['Finished sending all',
                                                   'emails successfully\n']))
{'fraction_non_alphanumeric': 0.08573646850044365, 'fraction_numerical': 0.006211180124223602, 'mean_word_length': 2.735294117647059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3147889', 'n_tokens_mistral': 2712, 'n_tokens_neox': 2648, 'n_words': 447}