def test_hypnen_at_the_end(self): words = [ TextPunctuation('сло-', [None, None, None, constants.HYPHEN]), End() ] result = run_through_module(words) self.assertEqual(result, [End()])
def test_union_with_foll_upper(self): words = [ TextPunctuation('З', [None]), TextPunctuation('собою', [None, None, None, None, None]), End() ] result = run_through_module(words) self.assertEqual(result, [Text('зсобою'), End()])
def test_non_alphabet(self): words = [ TextPunctuation('foreign', [None, None, None, None, None, None, None]), End() ] result = run_through_module(words) self.assertEqual(result, [End()])
def test_punctuation_within(self): words = [ TextPunctuation('сло!во', [None, None, None, constants.PUNCT, None, None]), End() ] result = run_through_module(words) self.assertEqual(result, [End()])
def test_hyphen(self): words = [ TextPunctuation('сло-во', [None, None, None, constants.HYPHEN, None, None]), End() ] result = run_through_module(words) self.assertEqual(result, [Text('слово'), End()])
def main(): choose_word = Word() word = choose_word.getWord() words_without_spaces = list(word) for i in word: if i == 'space': words_without_spaces.remove(i) win = GraphWin('Hangman', 600, 300) hang = Hang(win) slots_display = Format(word, win) letters_slots = slots_display.position_letters(150) end = hang.end_game() letters_class = Letters(win, letters_slots, words_without_spaces) all_letters = [] while end: letter = win.getKey().lower() if len(letter) != 1 or letter.isalpha() == False: continue elif letter in all_letters: print('You already tried that letter') continue all_letters.append(letter) errors = hang.draw_hangman(letter, words_without_spaces) letters_class.display_letter(letter) complete = all(i in all_letters for i in words_without_spaces) end = hang.end_game(errors, complete) if complete == True: Text(Point(325, 40), 'You got it! Amazing!').draw(win) elif complete == False: lost = Lost(win, letters_slots, words_without_spaces) lost.display_result() Text(Point(325, 40), 'You lost...try again').draw(win) quit_button = End(win, 570, 280, 40, 20, 'Quit') restart_button = End(win, 515, 280, 60, 20, 'Restart') while True: click = win.getMouse() if quit_button.interact(click): break elif restart_button.interact(click): win.close() main() break win.close()
def test_quotation(self): words = [ TextPunctuation('«слово»', [ constants.PUNCT, None, None, None, None, None, constants.PUNCT ]), End() ] result = run_through_module(words) self.assertEqual(result, [Text('слово'), End()])
def test_union_with_prec_upper(self): words = [ TextPunctuation('українського', [ None, None, None, None, None, None, None, None, None, None, None, None ]), TextPunctuation('Ж', [None]), End() ] result = run_through_module(words) self.assertEqual(result, [Text('українськогож'), End()])
def run(self): pipe_out = self._pipes[0] words = self.read() for word in words: send_word(word, pipe_out) send_word(End(), pipe_out)
def end(status): """ End Scene :param status: (bool) Ready to capture User Event :return: Updated Status Param """ current = End() if current.status: status = current.status return status
def start(self): self.music.play_game_start() self.score, self.scoreP1, self.scoreP2 = 0, 0, 0 while self.game_state == State.Ok: self.clock.tick(Clock_frequency) self.tank_factory.create() gf.check_events(self.tank_factory, self.music) self.turnScore = gf.update_screen(self.screen, self.game_map, self.tank_factory, self.music, self.board) self.score += self.turnScore gf.draw_screen(self.screen, self.game_map, self.tank_factory, self.board) self.game_state = gf.check_win(self.game_map, self.tank_factory) if self.game_state == State.Success: self.game_level += 1 if self.game_level > Max_level: self.game_level = 1 break else: if self.game_level >= 2: if self.is_2p: self.draw_score_p2() else: self.draw_score_p1() self.initialize() self.game_state = State.Ok self.game_level = 1 self.music.play_game_over() score1, score2, count = 0, 0, 0 while count <= 3: score1 += self.tank_factory.tot_tank_type1[ count] * self.enemy_score[count] score2 += self.tank_factory.tot_tank_type2[ count] * self.enemy_score[count] count += 1 self.scoreP1 += score1 self.scoreP2 += score2 self.end_menu = End(self.screen, self.tank_factory) if self.is_2p: self.end_menu.draw2p(self.scoreP1, self.scoreP2) else: self.end_menu.draw(self.score)
def test_punctuation_only(self): words = [TextPunctuation('—', [constants.PUNCT]), End()] result = run_through_module(words) self.assertEqual(result, [End()])
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/belarusian/test_belarusian.txt' encoding = 'utf-8' data = ConfigData('../../configs/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('стык'), Text('марфем'), Text('пераважная'), Text('колькасць'), Text('гукаў'), Text('утвараюццаў'), Text('цэнтры'), Text('ротавай'), Text('поласці'), Text('пры'), Text('высокім'), Text('агульным'), Text('пад’ёме'), Text('языка'), Text('вялікае'), Text('знаходзіласяў'), Text('дынастычнай'), Text('уніі'), Text('зпольскім'), Text('каралеўствам'), End()] def get_from_module(pipe_out): read_module = ReadModule([read_clean_pipe], file_path, encoding, data) read_module.run() result = [] while True: pipe_out.acquire() if pipe_out.empty(): pipe_out.wait() cleaned_word = pipe_out.get() result.append(cleaned_word) pipe_out.release()
def test_capital(self): words = [TextPunctuation('Київ', [None, None, None, None]), End()] result = run_through_module(words) self.assertEqual(result, [Text('київ'), End()])
def test_end(self): words = [End()] result = run_through_module(words) self.assertEqual(result, [End()])
def test_apostrophe_U02BC(self): words = [TextPunctuation('вʼю', [None, None, None]), End()] result = run_through_module(words) self.assertEqual(result, [Text('вʼю'), End()])
ins4p2 = Instruction.Instruction(False, "resultado ins4p2", 5) instructionsP2 = [ins1p2, ins2p2, ins3p2, ins4p2] p2 = Process.Process(2, instructionsP2) memory = Memory.Memory() memory.putProcess(p1) memory.putProcess(p2) pcbP1 = PCB.PCB(1, len(p1.getInstructions())) pcbP2 = PCB.PCB(2, len(p2.getInstructions())) #pcbP1 = PCBPriority.PCBPriority(pcbP1, 10) #pcbP2 = PCBPriority.PCBPriority(pcbP2, 3) cpu = Cpu.Cpu(memory) policy = Simple.Simple() #policy = RoundRobin.RoundRobin(1) scheduler = ReadyFIFO.ReadyFIFO(cpu, policy) #scheduler = ReadyPriority.ReadyPriority(cpu, policy) scheduler.put(pcbP1) scheduler.put(pcbP2) io = IO.IO(memory) end = End.End() clock = Clock.Clock() clock.addObserver(cpu) clock.addObserver(scheduler) kernel = Kernel.Kernel(scheduler, cpu, memory, io, end, clock) kernel.turnOn()
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/serbian/test_serbian.txt' encoding = 'utf-8-sig' data = ConfigData('../../configs/conf_sr_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('је'), Text('и'), Text('настао'), Text('панонски'), Text('басен'), Text('повлачењем'), Text('тетис'), Text('је'), Text('иза'), Text('себе'), Text('оставио'), Text('веома'), Text('плодно'), Text('тло'), Text('па'), Text('се'), Text('због'), Text('тога'), Text('панонски'), Text('басен'), Text('назива'), Text('још'), Text('и'), Text('житницом'), Text('србије'), Text('за'), Text('просторе'), Text('ове'), Text('регије'), Text('особена'), Text('је'), Text('црница'), Text('или'), Text('чернозем'), Text('као'), Text('врста'), Text('земљишта'), Text('међутим'), Text('јавља'), Text('се'), Text('и'), Text('деградирани'), Text('чернозем'), Text('као'), Text('и'), Text('плодно'), Text('алувијално'), Text('тло'), Text('и'), Text('гајњаче'), End()] def get_from_module(pipe_out): read_module = ReadModule([read_clean_pipe], file_path, encoding, data) read_module.run() result = [] while True: pipe_out.acquire() if pipe_out.empty(): pipe_out.wait() cleaned_word = pipe_out.get() result.append(cleaned_word) pipe_out.release()
from pipe import Pipe from queue import Queue from threading import Condition from write_module import WriteModule from word import SyllablesLengths from end import End import unittest import time import os.path words_to_do = [[End()], [ SyllablesLengths(["pou", "ze"], [2, 2]), SyllablesLengths(["fa", "rma", "ceu", "ti", "cký"], [2, 3, 2, 2, 3]), End() ], [SyllablesLengths(["sněh"], [3])] * 1000] syllables = ["pou-ze fa-rma-ceu-ti-cký", "sněh " * 999 + "sněh"] lengths = ["2-2 2-3-2-2-3", "3 " * 999 + "3"] file_path = "blabla/" file_syllables = file_path + "syllable_text.txt" file_lengths = file_path + "syllable_lengths_text.txt" class TestStringMethods(unittest.TestCase): @classmethod
import pygame import sys from head import Head from end import End from body import Body pygame.init() FPS = 60 screen = pygame.display.set_mode((1200, 600)) pygame.display.set_caption('贪吃蛇') body = Body(screen) head = Head(screen, body) end = End(screen, body) while True: for event in pygame.event.get(): # 判断事件是否为退出事件 if event.type == pygame.QUIT: # 退出pygame pygame.quit() # 退出系统 sys.exit() #写控制蛇移动的一些标记 if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: head.moving_left = True body.moving_left = True end.moving_left = True
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'), End() ] def get_from_module(pipe_out): read_module = ReadModule([read_clean_pipe], file_path, encoding, data) read_module.run() result = [] while True: pipe_out.acquire() if pipe_out.empty(): pipe_out.wait() cleaned_word = pipe_out.get() result.append(cleaned_word) pipe_out.release()
import constants from config_data import ConfigData from end import End from pipe import * from read_module import ReadModule from word import TextPunctuation file_path = '../test_files/belarusian/test_belarusian.txt' encoding = 'utf-8-sig' data = ConfigData('../../../py_scripts/configs/conf_be_cyr.json') pipe_out = Pipe(queue.Queue(), threading.Condition()) module = ReadModule([pipe_out], file_path, encoding, data) expected_result = [TextPunctuation('У', [None]), TextPunctuation('беларускай', [None, None, None, None, None, None, None, None, None, None]), TextPunctuation('мове', [None, None, None, None]), TextPunctuation('зычныя', [None, None, None, None, None, None]), TextPunctuation('могуць', [None, None, None, None, None, None]), TextPunctuation('адрознівацца', [None, None, None, None, None, None, None, None, None, None, None, None]), TextPunctuation('даўжынёй', [None, None, None, None, None, None, None, None]), TextPunctuation('гучання,', [None, None, None, None, None, None, None, constants.PUNCT]), TextPunctuation('якая', [None, None, None, None]), TextPunctuation('пака-звае', [None, None, None, None, constants.HYPHEN, None, None, None, None]), TextPunctuation('на', [None, None]), TextPunctuation('стык', [None, None, None, None]), TextPunctuation('марфем...', [None, None, None, None, None, None, constants.PUNCT, constants.PUNCT, constants.PUNCT]), TextPunctuation('Пераважная', [None, None, None, None, None, None, None, None, None, None]), TextPunctuation('‚колькасць‘', [constants.PUNCT, None, None, None, None, None, None, None, None, None, constants.PUNCT]), TextPunctuation('гукаў', [None, None, None, None, None]), TextPunctuation('утвараюцца', [None, None, None, None, None, None, None, None, None, None]), TextPunctuation('ў', [None]), TextPunctuation('цэнтры', [None, None, None, None, None, None]), TextPunctuation('ротавай', [None, None, None, None, None, None, None]), TextPunctuation('поласці', [None, None, None, None, None, None, None]), TextPunctuation('пры', [None, None, None]), TextPunctuation('высокім', [None, None, None, None, None, None, None]), TextPunctuation('агульным', [None, None, None, None, None, None, None, None]), TextPunctuation('пад’ёме', [None, None, None, None, None, None, None]), TextPunctuation('языка.', [None, None, None, None, None, constants.PUNCT]), TextPunctuation('Вялікае', [None, None, None, None, None, None, None]), TextPunctuation('Ducatus', [None, None, None, None, None, None, None]), TextPunctuation('Lithuaniae', [None, None, None, None, None, None, None, None, None, None]), TextPunctuation('знаходзілася', [None, None, None, None, None, None, None, None, None, None, None, None]), TextPunctuation('ў', [None]), TextPunctuation('дынастычнай', [None, None, None, None, None, None, None, None, None, None, None]), TextPunctuation('уніі', [None, None, None, None]), TextPunctuation('—', [constants.PUNCT]), TextPunctuation('з', [None]), TextPunctuation('Польскім', [None, None, None, None, None, None, None, None]), TextPunctuation('кара-леўствам!', [None, None, None, None, constants.HYPHEN, None, None, None, None, None, None, None, None, constants.PUNCT]), End()] def get_from_module(): module.run() result = [] while True: pipe_out.acquire() if pipe_out.empty(): pipe_out.wait() cleaned_word = pipe_out.get() result.append(cleaned_word) pipe_out.release()
if play == 1: play = rules(0) # if rules scene returns true => game : level 1 if play == 1: # Play with music preferences ( "on" by default, only for the first time ) play, music_status = levels(0, 1, "on") # Level one returns true => Check for the others if play == 1: for level_id in range(2, 4): # Current level returns true : Play another one if play == 1: play, music_status = levels(0, level_id, music_status) # Quit if play == 0: state_id = End() run = False else: run = False else: run = False else: run = False pygame.quit()
def test_union_with_foll_last(self): words = [TextPunctuation('з', [None]), End()] result = run_through_module(words) self.assertEqual(result, [Text('з'), End()])
def tearDownClass(cls): run_through_module(End())
open_door = pygame.image.load("images/open_door.png") closed_door = pygame.image.load("images/closed_door.png") dynamite_sound = pygame.mixer.Sound("sounds/bomb.wav") key_sound = pygame.mixer.Sound("sounds/key.ogg") door_sound = pygame.mixer.Sound("sounds/door_creak_closing.wav") pygame.mixer.music.load("sounds/zombie_theme.wav") pygame.mixer.music.play(-1) level = Level1() surface = Surface(SURFACE_SIZE, TILE_SIZE, level) end_tile = Surface.get_tile_by_number(173) level.end = End(end_tile.x, end_tile.y) player_position = Surface.get_tile_by_number(level.player_position) player = Player(player_position.x, player_position.y, TILE_SIZE) bg = pygame.image.load("images/bg.png") game_screen = pygame.display.set_mode(SURFACE_SIZE) pygame.display.set_caption("Zombie") clock = pygame.time.Clock() total_frames = 0