def hand_header(request): """Parse hand history header only defined in hand_text and returns a PokerStarsHandHistory instance. """ hh = PokerStarsHandHistory(request.instance.hand_text) hh.parse_header() return hh
def hand(request): """Parse handhistory defined in hand_text class attribute and returns a PokerStarsHandHistory instance. """ hh = PokerStarsHandHistory(request.instance.hand_text) hh.parse() return hh
def test_parse_all_hands(): for idx, hand in enumerate( {k: v for k, v in stars_hands.__dict__.items() if 'HAND' in k}.values()): print('HAND%s' % (idx + 1)) hh = PokerStarsHandHistory(hand) hh.parse()
def test_file_and_string_same(testdir): file_path = str(testdir.joinpath('handhistory/hand8.txt')) hh_file = PokerStarsHandHistory.from_file(file_path) hh_str = PokerStarsHandHistory(stars_hands.HAND8) print(bytes(hh_file.raw, encoding='utf-8'), '\n', bytes(hh_str.raw, encoding='utf-8')) #assert len(hh_file.raw) == len(hh_str.raw) #assert hh_file.raw == hh_str.raw hh_file._split_raw() hh_str._split_raw() print(hh_file._splitted, '\n', hh_str._splitted) assert hh_file._splitted == hh_str._splitted
a = list(Hand) len(a) #169 Hands Combo('7s6s') > Combo('6d5d') #Ranges from poker import Range Range('XX').to_ascii() print(Range('22+ A2+ KT+ QJs+ 32 42 52 62 72').to_ascii()) #Hand history parsing from poker.room.pokerstars import PokerStarsHandHistory # First step, only raw hand history is saved, no parsing will happen yet hh = PokerStarsHandHistory(HAND1) #hh = PokerStarsHandHistory.from_file('C:\\Users\\Robin\\Desktop\\pkr2\\poker-1\\tests\handhistory\\2hand.txt') # You need to explicitly parse. This will parse the whole hh at once. hh.parse() #date in type: datetime a = hh.date #identification number of the hand b = hh.ident #what type was the game c = hh.game_type
def get_parsed_flop_hand14(): hand_text = stars_hands.HAND14 hh = PokerStarsHandHistory(hand_text) hh.parse() return hh
def get_parsed_hand(): hand_text = stars_hands.HAND12 hh = PokerStarsHandHistory(hand_text) hh.parse() return hh
def test_open_from_file(testdir): bbb_path = str(testdir.joinpath('handhistory/bbb.txt')) hh = PokerStarsHandHistory.from_file(bbb_path) hh.parse() assert hh.ident == '138364355489' assert type(hh.raw) is unicode
def all_stars_hands(request): """Parse all hands from test_data and returns a PokerStarsHandHistory instance.""" hh = PokerStarsHandHistory(request.param) hh.parse() return hh
def test_open_from_bb_file(test_dir): bbb_path = str(test_dir.joinpath("handhistory/bbb.txt")) hh = PokerStarsHandHistory.from_file(bbb_path) hh.parse() assert hh.ident == "138364355489" assert type(hh.raw) is str
def test_no_hero(): hh = PokerStarsHandHistory(stars_hands.HAND6) hh.parse()
def hand(hand_text): hh = PokerStarsHandHistory(hand_text) hh.parse() return hh