Skip to content

Commit

Permalink
use re not regex
Browse files Browse the repository at this point in the history
  • Loading branch information
elichad committed Nov 20, 2023
1 parent 6814b73 commit d27d657
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions amy/extrequests/templatetags/eventbrite.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from django import template
import regex

from extrequests.utils import get_eventbrite_id_from_url

register = template.Library()

# Eventbrite IDs are long strings of digits (~12 characters)
EVENTBRITE_ID_PATTERN = regex.compile(r"\d{10,}")


@register.simple_tag
def eventbrite_id_from_url(url: str) -> str:
Expand Down
8 changes: 4 additions & 4 deletions amy/extrequests/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import date
import re

from django.core.exceptions import ValidationError
import regex

from workshops.models import Membership

# Eventbrite IDs are long strings of digits (~12 characters)
EVENTBRITE_ID_PATTERN = regex.compile(r"\d{10,}")
EVENTBRITE_ID_PATTERN = re.compile(r"\d{10,}")


class MemberCodeValidationError(ValidationError):
Expand Down Expand Up @@ -88,5 +88,5 @@ def get_eventbrite_id_from_url(url: str) -> str:
if not isinstance(url, str):
return url

re = regex.search(EVENTBRITE_ID_PATTERN, url)
return re.group() if re else url
match = re.search(EVENTBRITE_ID_PATTERN, url)
return match.group() if match else url

0 comments on commit d27d657

Please sign in to comment.