def test_get_availability_matches_one_match_gender_compatible_shared_courses( self): matches = c.student.get_availability_matches(c.tutor, 1) correct_matches = [ Match(c.student, c.tutor, WeeklyTime(0, 5, 0), datetime(2018, 1, 1, 5), 1) ] self.assertEqual(matches, correct_matches)
def playMatch(gs): for i in range(1): m = Match(gs) m.begin() while not m.isComplete(): m.nextTurn() gs = m.end(gs) return gs
def get_bracket_matches(season_title, team_dict, bracket_tuples, matches): header_ct = 0 for bracket, bracket_header in bracket_tuples: games = bracket.find_elements_by_class_name("bracket-game") for game in games: playing_teams = game.find_elements_by_class_name("team-template-text") scores = game.find_elements_by_class_name("bracket-score") team1 = team_dict[playing_teams[0].wrapped_element.text] team2 = team_dict[playing_teams[3].wrapped_element.text] if not scores[0].wrapped_element.text == "W" and not scores[0].wrapped_element.text == "FF": for num in range(int(scores[0].wrapped_element.text)): matches.append(Match(team1=team1, team2=team2, victor=team2, season_title=season_title, event=bracket_header)) for num in range(int(scores[1].wrapped_element.text)): matches.append(Match(team1=team1, team2=team2, victor=team2, season_title=season_title, event=bracket_header)) header_ct += 1
def simulate(self): match_day = self.calendar[self.week] results = [] for match in match_day: if "" not in match: m = Match(match[0], match[1]) results.append( ((match[0].name, match[1].name), m.simulation())) return results
def scan(self, optionstring): # option-name or None x = Match() if optionstring & x(r"^--?(\w+)=(.*)"): self.var[x[1]] = x[2] ; return x[1] if optionstring & x(r"^--?no-(\w+)$"): self.var[x[1]] = "" ; return x[1] if optionstring & x(r"^--?(\w+)$"): self.var[x[1]] = "*"; return x[1] return None
def match_list_request(): response = requests.get(Match_List_Url) responseJson = json.loads(response.text) matchList = list() for matchJson in responseJson['list']: if matchJson['type'] == 'basketball' and matchJson['period_cn'] != '完赛': match = Match(**matchJson) matchList.append(match) return matchList
def find_match_ids_odota(self): with open(self.query_file) as f: data = json.load(f) for match_info in data: if match_info["match_id"] not in self.matches_by_id: new_match = Match(match_info["match_id"]) self.matches.add(new_match) self.matches_by_id[new_match.id] = new_match new_match.add_hero(match_info["hero_id"])
def play(self): all_pairs = itertools.combinations(self.population, 2) for pair in all_pairs: # Total matches is purely for data pair[0].total_matches += 1 pair[1].total_matches += 1 match = Match([pair[0], pair[1]]) match.play()
def html_header(self, text): navi = self.navigation() if not navi: T = "<html><head>" title = self.get_title(text) if title: T += "<title>" + title + "</title>" T += "\n" for style in self.style: T += self._html_style(style) T += "\n" return T + "</head><body>" else: title = self.get_title(text) return navi & (Match(r"((?:src|href)=\"(?!http:))") >> "\\1../" ) & (Match(r"<!--title-->") >> " - " + title) & ( Match(r"<!--VERSION-->") >> self.o.version) & ( Match(r"(?m).*</body></html>") >> "")
def _filename(self, filename): if filename is not None: self.filename = filename filename = self.filename if not filename & Match(r"\.\w+$"): ext = self.o.docbook if not ext: ext = "docbook" filename += "." + ext return filename
def test_game_result_should_be_forty_to_love_when_player1_scores_three_times(): # Arrange m = Match() # Act m.player1.score() m.player1.score() m.player1.score() # Assert assert m.result() == "forty to love"
def get_ended_matches(): today = datetime.now().strftime('%Y-%m-%d') response = requests.get(Ending_Matches_Url % today) result = json.loads(response.text) matches = [ Match(**match) for match in result['list'] if match['type'] == 'basketball' ] return matches
def create_match(self): """Creates a match when button pressed""" player1 = Player(self.ids.entry1.text) player2 = Player(self.ids.entry2.text) self.app.root.ids.game_screen.match = Match(player1, player2, self.ids.entry3.text) self.app.root.ids.game_screen.ids.score_line1.ids.server.opacity = 0 # Fixes small graphic bug self.app.root.ids.game_screen.ids.score_line2.ids.server.opacity = 0
def resolve_external(self, func, sect): x = Match() if func & x("^zlib(.*)"): return ('<a href="' + self.http_zlib + x[1] + '">' + "<code>" + func + sect + "</code>" + '</a>') if sect & x("[23]"): return ('<a href="' + self.http_opengroup + func + '.html">' + "<code>" + func + sect + "</code>" + '</a>') return "<code>" + func + "<em>" + sect + "</em></sect>"
def here(text): has_function = Match("<function>(\w*)</function>") if text & has_function: func = has_function[1] self.anchors += [func] return (text & has_function >> '<a name="' + "\\1" + '">' + "\\1" + '</a>') else: return text
def get_living_matches(): response = requests.get(Living_Matches_Url) result = json.loads(response.text) matches = [ Match(**match) for match in result['list'] if match['type'] == 'basketball' and match['period_cn'] != '完赛' ] # matches = [Match(**match) for match in result['list'] if match['period_cn'] != '完赛'] return matches
def reset_round(self): """Set points, penalties, and time to zero.""" self.match = Match() self.time_left = self.round_length if self.timer_running is True: self.timer_thread.terminate() # self.updateUI() self.timer_running = False self.match_running = False
def setUp(self): cats = [0, 1] self.player1 = Player("Moosey", None, cats) self.player2 = Player("Bruce", None, cats) self.match = Match() self.match.player1 = self.player1 self.match.player2 = self.player2
def _zipfilename(self, filename): if filename is not None: self.filename = filename filename = self.filename if not filename & Match(r"\.\w+$"): ext = self.o.odt if not ext: ext = "odt" filename += "." + ext return filename
def parse(self, header=None): if header is not None: self.header = header if self.header is None: return False comment = self.header.comment try: comment = self.header.get_otherlines() except Exception as e: pass mode = "" text = "" for line in comment.split("\n"): check = Match() if line & check(r"^\s?\s?\s?[*]\s+[*]\s(.*)"): if mode != "ul": if mode: text += "</" + mode + ">" mode = "ul" text += "<" + mode + ">" line = check.group(1) text += "<li><p> " + self.markup_para_line( line) + " </p></li>\n" elif line & check(r"^\s?\s?\s?[*](.*)"): if mode != "para": if mode: text += "</" + mode + ">" mode = "para" text += "<" + mode + ">" line = check.group(1) if line.strip() == "": text += "</para><para>" + "\n" else: text += " " + self.markup_para_line(line) + "\n" else: if mode != "screen": if mode: text += "</" + mode + ">" mode = "screen" text += "<" + mode + ">" text += " " + self.markup_screen_line(line) + "\n" if mode: text += "</" + mode + ">" + "\n" self.text = (text & Match(r"(<para>)(\s*[R]eturns)") >> r"\1This function\2" & Match(r"(?s)<para>\s*</para><para>") >> "<para>" & Match(r"(?s)<screen>\s*</screen>") >> "") return True
def test_game_result_should_be_game_when_player1_scores_four_times(): # Arrange m = Match() # Act m.player1.score() m.player1.score() m.player1.score() m.player1.score() # Assert assert m.result() == "player1 wins game"
def recordMatch(self, **kwargs): match = Match( player1_id=kwargs.get("player1_id"), player2_id=kwargs.get("player2_id"), games=kwargs.get("games"), ) # 2 to preserve headers self.match_sheet.insert_row(match.toRow(), 2) self.settleScore(match) return match.toDict()
def test_involved_pages(): m = Match(1, 'Eva', 'db.csv') query = m.involved_pages(1) assert type(query) == dict assert query['actual_page']['page'] == 1 assert query['childs'][0]['page'] == 2 query = m.involved_pages(2) assert query['actual_page']['page'] == 2 assert query['childs'][2]['page'] == 9
def test_game_result_should_be_thirty_all_when_both_players_score_twice(): # Arrange m = Match() # Act m.player1.score() m.player2.score() m.player1.score() m.player2.score() # Assert assert m.result() == "thirty all"
def CallMatch(output_prefix1, output_prefix2, output_path, keywords1, keywords2, species, cwd, _inputEmail): result_dfs = Match(output_prefix1, output_prefix2, output_path, keywords1, keywords2, species, cwd, _inputEmail) output_names = [ output_prefix1 + '.csv', output_prefix2 + '.csv', output_prefix1 + "_" + output_prefix2 + '.csv' ] send_email(_inputEmail, result_dfs, output_path, output_names) return
def _get_match_basic_data(self, match): date_time_str = match.find_element_by_class_name('date').text date_time = DateTime.from_marathon_str(date_time_str) url = match.find_element_by_class_name('member-link').get_attribute( 'href') teams = [ el.text for el in match.find_elements_by_tag_name('span') if el.get_attribute('data-member-link') ] return Match(MatchTitle(teams), url, date_time, self)
def seed_manual(track, matches): """Creates a round of empty matches, for the user to manually fill in. :param track: The track that should be played for this round. :param matches: The matches collection to load in. """ match_count = int(math.pow(2, MAX_ROUNDS - track.round)) for i in range(0, match_count): match = Match(track) matches.append(match)
def testMatchPlay(self): for _ in range(10): m = Match() m.play() self.assertNotEqual(m.player1score, m.player2score) self.assertTrue(2 <= len(m.sets) <= 3) for tennis_set in m.sets: self.assertIsInstance(tennis_set, TennisSet) if len(m.sets) == 2: self.assertTrue(m.player1score == 0 or m.player2score == 0)
def find_combos(board: [[str]]): '''returns a list of lists of tuples: board -> matches -> coordinates''' all_combos = [] # first go horizontal for i, row in enumerate(board): counter = 1 prev_letter = '*' for j in range(columns): if prev_letter == row[j]: counter += 1 else: if counter >= 3 and prev_letter != ' ': all_combos.append( Match((i, j - counter), counter, 'h', prev_letter)) prev_letter = row[j] counter = 1 if j == columns - 1 and counter >= 3 and prev_letter != ' ': all_combos.append( Match((i, j - counter + 1), counter, 'h', prev_letter)) # then go vertical for j in range(columns): counter = 1 prev_letter = '*' for i in range(rows): if prev_letter == board[i][j]: counter += 1 else: if counter >= 3 and prev_letter != ' ': all_combos.append( Match((i - counter, j), counter, 'v', prev_letter)) prev_letter = board[i][j] counter = 1 if i == rows - 1 and counter >= 3 and prev_letter != ' ': all_combos.append( Match((i - counter + 1, j), counter, 'v', prev_letter)) all_combos = remove_overlapping(all_combos) # coordinates should never overlap return [combo.get_coord() for combo in all_combos]
def test_process_input(self): m = Match() process = m.process_pattern_on_input('Puppies belong to Elizabeth II', [{ 'TEXT': 'Elizabeth' }, { 'TEXT': 'II' }]) expect = 'Elizabeth II' assert process == expect