Skip to content

Commit

Permalink
Merge branch 'container' of github.com:ScumbagDog/stregsystemet into …
Browse files Browse the repository at this point in the history
…container
  • Loading branch information
ScumbagDog committed Oct 8, 2021
2 parents 02dc1dd + 539c43e commit d52ded1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Black formatter check

on: [push]
on: [push, pull_request]

jobs:
black:
Expand Down
9 changes: 8 additions & 1 deletion stregsystem/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
22 changes: 18 additions & 4 deletions stregsystem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d52ded1

Please sign in to comment.