From 176c35545e3c91d6244bee9f1fa67a2a0fa02af1 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Wed, 6 Oct 2021 17:53:50 +0100 Subject: [PATCH 1/2] CI: Run black CI on pull requests Otherwise we will have succeeding CI on PRs that fails when pushed to next or master. --- .github/workflows/black.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 078ab2f0..07fab727 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -1,6 +1,6 @@ name: Black formatter check -on: [push] +on: [push, pull_request] jobs: black: From f7a562723c858404ef2fc57a475727f11c9f5680 Mon Sep 17 00:00:00 2001 From: falkecarlsen <11318702+falkecarlsen@users.noreply.github.com> Date: Thu, 7 Oct 2021 16:40:31 +0200 Subject: [PATCH 2/2] Fix additional emoji MobilePay ingest bugs --- stregsystem/tests.py | 9 ++++++++- stregsystem/utils.py | 22 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/stregsystem/tests.py b/stregsystem/tests.py index 249b9a7b..3f6b52cd 100644 --- a/stregsystem/tests.py +++ b/stregsystem/tests.py @@ -1408,7 +1408,14 @@ def test_exact_guess(self): self.assertEqual(Member.objects.get(username__exact="marx"), mobile_payment_exact_match_member("marx")) def test_emoji_strip(self): - self.assertEqual(strip_emoji("Tilmeld Lichi 😎"), "Tilmeld Lichi ") + self.assertEqual(strip_emoji("Tilmeld Lichi 😎"), "Tilmeld Lichi") + + def test_emoji_strip_electric_boogaloo(self): + # Laurits bør få næse for at fremprovokoere dette case + self.assertEqual(strip_emoji("♂️Laurits♂️"), "Laurits") + + def test_emoji_retain_nordic(self): + self.assertEqual(strip_emoji("æøåäëö"), "æøåäëö") def test_emoji_retain(self): self.assertEqual(strip_emoji("Tilmeld Lichi"), "Tilmeld Lichi") diff --git a/stregsystem/utils.py b/stregsystem/utils.py index fc31b244..288ab84b 100644 --- a/stregsystem/utils.py +++ b/stregsystem/utils.py @@ -178,16 +178,30 @@ def mobile_payment_exact_match_member(comment): def strip_emoji(text): # yoinked from https://stackoverflow.com/questions/33404752/removing-emojis-from-a-string-in-python - regrex_pattern = re.compile( - pattern="[" + emoj = re.compile( + "[" u"\U0001F600-\U0001F64F" # emoticons u"\U0001F300-\U0001F5FF" # symbols & pictographs u"\U0001F680-\U0001F6FF" # transport & map symbols u"\U0001F1E0-\U0001F1FF" # flags (iOS) + u"\U00002500-\U00002BEF" # chinese char + u"\U00002702-\U000027B0" + u"\U00002702-\U000027B0" + u"\U000024C2-\U0001F251" + u"\U0001f926-\U0001f937" + u"\U00010000-\U0010ffff" + u"\u2640-\u2642" + u"\u2600-\u2B55" + u"\u200d" + u"\u23cf" + u"\u23e9" + u"\u231a" + u"\ufe0f" # dingbats + u"\u3030" "]+", - flags=re.UNICODE, + re.UNICODE, ) - return regrex_pattern.sub(r'', text) + return re.sub(emoj, '', text).strip() def qr_code(data):