From b85cfb83201be5a3d48fd5c914242fa687d9209b Mon Sep 17 00:00:00 2001 From: jejellyroll-fr <47847785+jejellyroll-fr@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:48:32 +0200 Subject: [PATCH] correct bug when win format has a space on iPoker correct bug when win format has a space on iPoker --- pyfpdb/iPokerToFpdb.py | 4 +- ...-EUR-SNG-1.00.Twister_non_standard_win.xml | 61 +++++++++++++++++++ pyfpdb/test_ipokertofpdb.py | 15 ++++- 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 pyfpdb/regression-test-files/tour/iPoker/Flop/NLHE-3max-EUR-SNG-1.00.Twister_non_standard_win.xml diff --git a/pyfpdb/iPokerToFpdb.py b/pyfpdb/iPokerToFpdb.py index 89e73613..f2fb9a62 100644 --- a/pyfpdb/iPokerToFpdb.py +++ b/pyfpdb/iPokerToFpdb.py @@ -61,7 +61,7 @@ class iPoker(HandHistoryConverter): summaryInFile = True substitutions = { - 'LS': u"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|", # Used to remove currency symbols from the hand history + 'LS': r"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|", # Used to remove currency symbols from the hand history 'PLYR': r'(?P[^\"]+)', # Regex pattern for matching player names 'NUM': r'(.,\d+)|(\d+)', # Regex pattern for matching numbers 'NUM2': r'\b((?:\d{1,3}(?:\s\d{3})*)|(?:\d+))\b', # Regex pattern for matching numbers with spaces @@ -173,7 +173,7 @@ class iPoker(HandHistoryConverter): re_Buyin = re.compile(r"""(?P[%(NUM)s]+)""" % substitutions, re.MULTILINE|re.VERBOSE) re_TotalBuyin = re.compile(r"""(?P(?P[%(LS)s%(NUM)s]+)\s\+\s?(?P[%(LS)s%(NUM)s]+)?)""" % substitutions, re.MULTILINE|re.VERBOSE) re_HandInfo = re.compile(r'code="(?P[0-9]+)">\s*?\s*?(?P[\.a-zA-Z-/: 0-9]+)', re.MULTILINE) - re_PlayerInfo = re.compile(r'' % substitutions, re.MULTILINE) + re_PlayerInfo = re.compile(r'' % substitutions, re.MULTILINE) re_Board = re.compile(r'(?P.+?)', re.MULTILINE) re_EndOfHand = re.compile(r'(?P.+)', re.MULTILINE) diff --git a/pyfpdb/regression-test-files/tour/iPoker/Flop/NLHE-3max-EUR-SNG-1.00.Twister_non_standard_win.xml b/pyfpdb/regression-test-files/tour/iPoker/Flop/NLHE-3max-EUR-SNG-1.00.Twister_non_standard_win.xml new file mode 100644 index 00000000..a485a934 --- /dev/null +++ b/pyfpdb/regression-test-files/tour/iPoker/Flop/NLHE-3max-EUR-SNG-1.00.Twister_non_standard_win.xml @@ -0,0 +1,61 @@ + + + + 23.3.1.4 + real + Holdem NL + Sit’n’Go Twister 1€, 786601687 + EUR + 00:07:47 + 37 + 2023-04-28 10:38:18 + EUR + Hero + 5 760 + 2 280 + 480 + 0 + 0,56PB + 0PB + 0,56PB + 3 + 786601686 + Sit’n’Go Twister 1€ + 3€ + 2 + 0€ + 0,07€ + 0,93€ + 1€ + 0 + + + + 2023-04-28 10:45:35 + 40 + 80 + + + + + + + + + + + DQ C8 + + DA D7 + + + + + HQ S5 D10 + + + S10 + + + D3 + + + diff --git a/pyfpdb/test_ipokertofpdb.py b/pyfpdb/test_ipokertofpdb.py index 52a5a5b5..042dfe8e 100644 --- a/pyfpdb/test_ipokertofpdb.py +++ b/pyfpdb/test_ipokertofpdb.py @@ -3,7 +3,7 @@ substitutions = { - 'LS': u"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|", + 'LS': r"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|", 'PLYR': r'(?P[^\"]+)', 'NUM': r'(?:\d+)|(\d+\s\d+)', @@ -39,4 +39,15 @@ def test_re_PlayerInfo3(): plist[a.group('PNAME')] = [int(a.group('SEAT')), (a.group('CASH')), (a.group('WIN')), False] assert len(plist) == 2 - \ No newline at end of file + + +def test_re_PlayerInfo8(): + text = '' + match = re_PlayerInfo.search(text) + assert match is not None + assert match.group('SEAT') == '3' + assert match.group('PNAME') == 'pergerd' + assert match.group('CASH') == '740' + assert match.group('BUTTONPOS') == '1' + assert match.group('WIN') == '1 480' + assert match.group('BET') == '740'