Coverage for test\test_juicy.py: 100%
38 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-14 11:07 +0000
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-14 11:07 +0000
1import re
4substitutions = {
5 "LEGAL_ISO": "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
6 "LS": r"\$|€|", # legal currency symbols - Euro(cp1252, utf-8)
7 "PLYR": r"(?P<PNAME>.+?)",
8 "CUR": r"(\$|€|)",
9 "NUM": r".(,|\s)\d\xa0",
10 "NUM2": r"\b((?:\d{1,3}(?:\s\d{3})*)|(?:\d+))\b", # Regex pattern for matching numbers with spaces
11}
13re_PlayerInfo = re.compile(
14 r"""
15 ^Seat\s(?P<SEAT>[0-9]+):\s
16 (?P<PNAME>.+?)\s
17 \((%(LS)s)?(?P<CASH>[%(NUM)s]+)\sin\schips\)
18 (\s\s\(EUR\s(%(CUR)s)?(?P<EUROVALUE>[%(NUM)s]+)\))?"""
19 % substitutions,
20 re.MULTILINE | re.VERBOSE,
21)
23re_PlayerInfo2 = re.compile(
24 r"""
25 ^Seat\s(?P<SEAT>[0-9]+):\s
26 (?P<PNAME>.+?)\s
27 \((%(LS)s)?(?P<CASH>[%(NUM2)s]+)\sin\schips\)
28 (\s\s\(EUR\s(%(CUR)s)?(?P<EUROVALUE>[%(NUM)s]+)\))?"""
29 % substitutions,
30 re.MULTILINE | re.VERBOSE,
31)
34def test_re_PlayerInfo2():
35 text = "Seat 1: joker7 (1 200 in chips) "
36 match = re_PlayerInfo.search(text)
37 assert match is not None
38 assert match.group("SEAT") == "1"
39 assert match.group("PNAME") == "joker7"
40 assert match.group("CASH") == "1 200"
43def test_re_PlayerInfo3():
44 text = "Seat 1: joker7 (1 200 in chips) "
45 match = re_PlayerInfo2.search(text)
46 assert match is not None
47 assert match.group("SEAT") == "1"
48 assert match.group("PNAME") == "joker7"
49 assert match.group("CASH") == "1 200"
52table_text = "Tournament: 17106061 Buy-In Freeroll : Table 10 - No Limit Holdem - 15/30"
53hand_text = "Hand#710910543B500014 - Freeroll to GOLD CHIPS T17122229 -- FREEROLL -- $0 + $0 -- 9 Max -- Table 4 -- 0/10/20 NL Hold'em -- 2023/09/22 - 17:35:27"
55re_GameInfo = re.compile(
56 r"""
57 Hand\#(?P<HID>[A-Z0-9]+)\s+\-\s+(?P<TABLE>(?P<BUYIN1>(?P<BIAMT1>(%(LS)s)[%(NUM)s]+)\sNLH\s(?P<MAX1>\d+)\smax)?.+?)\s(\((Turbo,\s)?(?P<MAX>\d+)\-+[Mm]ax\)\s)?((?P<TOURNO>T\d+)|\d+)\s(\-\-\s(TICKET|CASH|TICKETCASH|FREEROLL)\s\-\-\s(?P<BUYIN>(?P<BIAMT>\$\d+)\s\+\s(?P<BIRAKE>\$\d+))\s\-\-\s(?P<TMAX>\d+)\sMax\s)?(\-\-\sTable\s(?P<TABLENO>\d+)\s)?\-\-\s(?P<CURRENCY>%(LS)s|)?(?P<ANTESB>(\-)?\d)/(%(LS)s)?(?P<SBBB>\d+)(/(%(LS)s)?(?P<BB>\d+))?\s(?P<LIMIT>NL|FL||PL)\s(?P<GAME>Hold\'em|Omaha|Omaha\sHi/Lo|OmahaHiLo)\s-\-\s(?P<DATETIME>.*$)
58 """
59 % substitutions,
60 re.MULTILINE | re.VERBOSE,
61)
64def test_re_GameInfo3():
65 text = "Hand#710910543B500014 - Freeroll to GOLD CHIPS T17122229 -- FREEROLL -- $0 + $0 -- 9 Max -- Table 4 -- 0/10/20 NL Hold'em -- 2023/09/22 - 17:35:27"
66 match = re_GameInfo.search(text)
67 assert match is not None
68 assert match.group("HID") == "710910543B500014"
69 assert match.group("TABLE") == "Freeroll to GOLD CHIPS"
70 assert match.group("DATETIME") == "2023/09/22 - 17:35:27"
71 assert match.group("TABLENO") == "4"
72 assert match.group("BUYIN") == "$0 + $0"
73 assert match.group("TMAX") == "9"
74 assert match.group("BIAMT") == "$0"
75 assert match.group("BIRAKE") == "$0"
76 assert match.group("ANTESB") == "0"
77 assert match.group("SBBB") == "10"
78 assert match.group("BB") == "20"
79 assert match.group("LIMIT") == "NL"
80 assert match.group("GAME") == "Hold'em"