def send_email(team, usr="", passwrd=""): csp = ", " cnfg = ConfigData() names = [] tolist = [] tostr = "" noerror = True if not valid_config(cnfg): print("Missing or invalid config email entries") return False for student in team.members: names.append(student.name) tolist.append(student.email) parsed = parse_email(cnfg.email['Source'], csp.join(names), cnfg.email['Name']) if (parsed[1] == "" or parsed[0] == ""): return False tostr = csp.join(filter(None, tolist)) msg = MIMEText(parsed[1]) msg['Subject'] = parsed[0] msg['From'] = cnfg.email['From'] msg['To'] = tostr s = smtplib.SMTP(cnfg.email['SMTPServer'], cnfg.email['Port']) try: s.ehlo() s.starttls() if usr == "" or passwrd == "": usr = input('Login: '******'From'], tolist, msg.as_string()) except Exception as e: print("Error: {}".format(e)) noerror = False finally: s.quit() return noerror
def __init__(self, file_name, file_path, encoding, language): super().__init__() self.data = ConfigData(language) self.file_name = file_name self.file_path = file_path self.encoding = encoding self.pipe_read_clean = Pipe(Queue(), Condition()) self.pipe_clean_sound = Pipe(Queue(), Condition()) self.pipe_sound_syll = Pipe(Queue(), Condition()) self.pipe_syll_count = Pipe(Queue(), Condition()) self.pipe_count_txt = Pipe(Queue(), Condition())
def build_from_config(self, config): """ Build dataset from a ConfiParser object generated by Parser's parse_dataset method. """ self._reset() # First pass for images and labels. assert config.has_section('dataset') for name, data in config.items('dataset'): assert config.has_section(data) if '_mask' in data: # Mask will be processed later. continue if 'label' in data: self._data[name] = ConfigLabel(config, data) self._label.append(name) else: self._data[name] = ConfigData(config, data) self._image.append(name) # Second pass for masks. for name, data in config.items('dataset'): if '_mask' in data: if config.has_option(data, 'shape'): # Lazy filling of mask shape. Since the shape of mask should # be the same as the shape of corresponding label, it can be # known only after having processed label in the first pass. label = data.replace('_mask', "") shape = self._data[label].shape() config.set(data, 'shape', shape) self._data[name] = ConfigData(config, data) # Set dataset spec. spec = dict() for name, data in self._data.items(): spec[name] = tuple(data.fov()) self.set_spec(spec)
def run_yanom(command_line_args): if not command_line_args['silent']: interactive_cli.show_app_title() config_data = ConfigData(f"config.ini", 'gfm', allow_no_value=True) config_data.parse_config_file() notes_converter = NotesConvertor(command_line_args, config_data) if not command_line_args['ini']: while True: notes_converter.convert_notes() else: notes_converter.convert_notes()
def tearDownClass(cls): run_through_module(End()) def test_njegov(self): word = run_through_module(Text('njegov')) self.assertEqual(word.get_text(), 'njegov') self.assertEqual(word.get_phonotypes(), [SUBUNIT, NASAL, VOWEL, OBSTR, VOWEL, GLIDE]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData(path_to_scripts + '\configs\conf_sr_lat.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
def startManager(self): ''' This starts the IOManager ''' self.c_data = ConfigData() self.manager = IOManager(self.c_data, self.roster)
def test_знаходзілася(self): word = run_through_module(Text('знаходзілася')) self.assertEqual(word.get_text(), 'знаходзілася') self.assertEqual(word.get_phonotypes(), [ OBSTR, NASAL, VOWEL, OBSTR, VOWEL, SUBUNIT, OBSTR, VOWEL, LIQUID, VOWEL, OBSTR, VOWEL ]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData(path_to_scripts + '\configs\conf_be_cyr.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
mod.start() @classmethod def tearDownClass(cls): run_through_module(End()) def test_maria(self): word = run_through_module(Text('maria')) self.assertEqual(word.get_text(), 'maria') self.assertEqual(word.get_phonotypes(), [SONOR, VOWEL, SONOR, SUBUNIT, VOWEL]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData('../../configs/conf_pl_lat.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
def test_między(self): word = run_through_module( SyllablesPhonotypes( ['mię', 'dzy'], [[SONOR, SUBUNIT, VOWEL], [SUBUNIT, CONS, VOWEL]])) self.assertEqual(word.get_syllables(), ['mię', 'dzy']) self.assertEqual(word.get_lengths(), [2, 2]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("conf_pl_lat.json") mod = CountModule([pin, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
self.assertEqual(word.get_lengths(), [3, 3, 2]) def test_zhorjelc(self): word = run_through_module( SyllablesPhonotypes(['zho', 'rjelc'], [[0, 0, 2], [4, 1, 2, 1, 0]])) self.assertEqual(word.get_syllables(), ['zho', 'rjelc']) self.assertEqual(word.get_lengths(), [2, 4]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("conf_hsb_lat.json") mod = CountModule([pin, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
import queue import threading import unittest import constants from clean_module import CleanModule from config_data import ConfigData from end import End from pipe import * from word import Text, TextPunctuation data = ConfigData('../../../py_scripts/configs/conf_uk_cyr.json') pipe_in = Pipe(queue.Queue(), threading.Condition()) pipe_out = Pipe(queue.Queue(), threading.Condition()) def run_through_module(words): module = CleanModule([pipe_in, pipe_out], data) module.start() result = [] for word in words: pipe_in.acquire() pipe_in.put(word) pipe_in.notify() pipe_in.release() while True: pipe_out.acquire() if pipe_out.empty(): pipe_out.wait()
self.assertEqual(word.get_text(), 'vědomí') self.assertEqual(word.get_phonotypes(), [CONS, VOWEL, CONS, VOWEL, SONOR, VOWEL]) def test_sex(self): word = run_through_module(Text('sex')) self.assertEqual(word.get_text(), 'sex') self.assertEqual(word.get_phonotypes(), [CONS, VOWEL, CONS]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData(str(Path(__file__).parents[2]) + '\config\conf_cs_lat.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
word = run_through_module(SyllablesPhonotypes(['у', 'кра', 'їн', 'сько', 'гож'], [[VOWEL], [CONS, SONOR, VOWEL], [VOWEL, SONOR], [CONS, SPEC, CONS, VOWEL], [CONS, VOWEL, CONS]])) self.assertEqual(word.get_syllables(), ['у', 'кра', 'їн', 'сько', 'гож']) self.assertEqual(word.get_lengths(), [1, 3, 3, 3, 3]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("conf_uk_cyr.json") mod = CountModule([pin, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
self.assertEqual(word.get_lengths(), [3, 3, 2]) def test_zhorjelc(self): word = run_through_module( SyllablesPhonotypes(['zho', 'rjelc'], [[0, 0, 2], [4, 1, 2, 1, 0]])) self.assertEqual(word.get_syllables(), ['zho', 'rjelc']) self.assertEqual(word.get_lengths(), [2, 4]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("../../configs/conf_hsb_lat.json") mod = CountModule([pin, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
self.assertEqual(word.get_text(), 'wrobl') self.assertEqual(word.get_phonotypes(), [SONOR, SONOR, VOWEL, CONS, VOWEL]) def test_sneh(self): word = run_through_module(Text('sněh')) self.assertEqual(word.get_text(), 'sněh') self.assertEqual(word.get_phonotypes(), [CONS, SONOR, VOWEL, CONS]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData('../../configs/conf_hsb_lat.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
word = run_through_module(SyllablesPhonotypes(['у', 'кра', 'їн', 'сько', 'гож'], [[VOWEL], [CONS, SONOR, VOWEL], [VOWEL, SONOR], [CONS, SPEC, CONS, VOWEL], [CONS, VOWEL, CONS]])) self.assertEqual(word.get_syllables(), ['у', 'кра', 'їн', 'сько', 'гож']) self.assertEqual(word.get_lengths(), [1, 3, 3, 3, 3]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("../../configs/conf_uk_cyr.json") mod = CountModule([pin, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
self.assertEqual(word.get_syllables(), ['za', 'hra', 'dě']) self.assertEqual(word.get_lengths(), [2, 3, 2]) def test_ně(self): word = run_through_module(SyllablesPhonotypes(['ně'], [[SONOR, VOWEL]])) self.assertEqual(word.get_syllables(), ['ně']) self.assertEqual(word.get_lengths(), [2]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("conf_cs_lat.json") mod = CountModule([pin, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
def test_українськогож(self): word = run_through_module(Text('українськогож')) self.assertEqual(word.get_text(), 'українськогож') self.assertEqual(word.get_phonotypes(), [ VOWEL, CONS, SONOR, VOWEL, VOWEL, SONOR, CONS, SPEC, CONS, VOWEL, CONS, VOWEL, CONS ]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData(str(Path(__file__).parents[2]) + '\config\conf_uk_cyr.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
def __init__(self): self.con = ConfigData() self.opera = OperaMethods() self.log = LogRecord() self.logger = self.log.get_log()
while not pout.empty(): word = pout.get() self.assertEqual(word.get_syllables(), syllables[index]) self.assertEqual(word.get_lengths(), lengths[index]) index += 1 self.assertEqual(mod_count.lengths_of_syllables, lengths_map) self.assertEqual(mod_count.frequencies_of_syllables, frequency_map) def run_through_module(word, mod): pin = mod.get_pipes()[0] pin.acquire() pin.put(word) pin.notify() pin.release() pin = Pipe(Queue(), Condition()) pipe_syllabify_count = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) cd = ConfigData("../../configs/conf_cs_lat.json") mod_syll = SyllabifyModule([pin, pipe_syllabify_count]) mod_count = CountModule([pipe_syllabify_count, pout], cd, "blabla") if __name__ == '__main__': unittest.main()
import queue import threading import unittest from clean_module import CleanModule from config_data import ConfigData from end import End from pipe import Pipe from read_module import ReadModule from word import Text file_path = '../test_files/slovak/test_slovak.txt' encoding = 'utf-8-sig' data = ConfigData('../../configs/conf_svk_lat.json') read_clean_pipe = Pipe(queue.Queue(), threading.Condition()) clean_out_pipe = Pipe(queue.Queue(), threading.Condition()) expected_result = [ Text('toto'), Text('je'), Text('prvá'), Text('veta'), Text('#tomobil'), Text('ide'), Text('posledné'), Text('slovo'), Text('má'), Text('byť'), Text('vyhodené'), Text('slovo'),
self.assertEqual( word.get_phonotypes(), [NASAL, VOWEL, VOWEL, LIQUID, OBSTR, VOWEL, OBSTR, VOWEL]) def test_metr(self): word = run_through_module(Text('metr')) self.assertEqual(word.get_text(), 'metr') self.assertEqual(word.get_phonotypes(), [NASAL, VOWEL, OBSTR, VOWEL]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData(path_to_scripts + '/configs/conf_cs_lat.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
@classmethod def tearDownClass(cls): run_through_module(End()) def test_українськогож(self): word = run_through_module(Text('українськогож')) self.assertEqual(word.get_text(), 'українськогож') self.assertEqual(word.get_phonotypes(), [VOWEL, CONS, SONOR, VOWEL, VOWEL, SONOR, CONS, SPEC, CONS, VOWEL, CONS, VOWEL, CONS]) def run_through_module(word): pin.acquire() pin.put(word) pin.notify() pin.release() pout.acquire() if pout.empty(): pout.wait() word = pout.get() pout.release() return word data = ConfigData('../../configs/conf_uk_cyr.json') pin = Pipe(Queue(), Condition()) pout = Pipe(Queue(), Condition()) mod = PhonotypeModule([pin, pout], data) if __name__ == '__main__': unittest.main()
import queue import threading import unittest from clean_module import CleanModule from config_data import ConfigData from end import End from pipe import Pipe from read_module import ReadModule from word import Text file_path = '../tests/short_texts/belarussian_short_text.txt' encoding = 'utf-8' data = ConfigData('../../config/conf_be_cyr.json') read_clean_pipe = Pipe(queue.Queue(), threading.Condition()) clean_out_pipe = Pipe(queue.Queue(), threading.Condition()) expected_result = [ Text('у'), Text('беларускай'), Text('мове'), Text('зычныя'), Text('могуць'), Text('адрознівацца'), Text('даўжынёй'), Text('гучання'), Text('якая'), Text('паказвае'), Text('на'), Text('стык'),