From d27d65762c6077d1a498f65436d81fa580b4cb47 Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Fri, 10 Nov 2023 13:10:26 +0000 Subject: [PATCH] use re not regex --- amy/extrequests/templatetags/eventbrite.py | 4 ---- amy/extrequests/utils.py | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/amy/extrequests/templatetags/eventbrite.py b/amy/extrequests/templatetags/eventbrite.py index f8ce6409f..dd5f42d97 100644 --- a/amy/extrequests/templatetags/eventbrite.py +++ b/amy/extrequests/templatetags/eventbrite.py @@ -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: diff --git a/amy/extrequests/utils.py b/amy/extrequests/utils.py index 39d201adf..45badbbfb 100644 --- a/amy/extrequests/utils.py +++ b/amy/extrequests/utils.py @@ -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): @@ -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