Switch from python-slugify to self hosted (Taken from Django 2.2.1 django.utils.text.slugify)
This commit is contained in:
parent
bb8634fe56
commit
3aa305ea74
@ -9,7 +9,6 @@ from json import JSONDecodeError, loads, JSONEncoder
|
||||
from typing import Any, Dict, List, Union
|
||||
|
||||
from requests import Response, Session
|
||||
from slugify import slugify
|
||||
|
||||
from erepublik import utils
|
||||
|
||||
@ -239,7 +238,7 @@ class SlowRequests(Session):
|
||||
file_data = {
|
||||
"path": 'debug/requests',
|
||||
"time": self.last_time.strftime('%Y-%m-%d_%H-%M-%S'),
|
||||
"name": slugify(url[len(Citizen.url):]),
|
||||
"name": utils.slugify(url[len(Citizen.url):]),
|
||||
"extra": "_REDIRECT" if redirect else ""
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import unicodedata
|
||||
from collections import deque
|
||||
from decimal import Decimal
|
||||
from json import JSONEncoder
|
||||
@ -15,7 +16,6 @@ from typing import Union
|
||||
import pytz
|
||||
import requests
|
||||
from requests import Response
|
||||
from slugify import slugify
|
||||
|
||||
|
||||
__all__ = ["FOOD_ENERGY", "COMMIT_ID", "COUNTRIES", "erep_tz",
|
||||
@ -317,3 +317,19 @@ def process_error(log_info: str, name: str, exc_info: tuple, citizen=None, commi
|
||||
else:
|
||||
trace = dict()
|
||||
send_email(name, bugtrace, citizen, local_vars=trace)
|
||||
|
||||
|
||||
def slugify(value, allow_unicode=False):
|
||||
"""
|
||||
Function copied from Django2.2.1 django.utils.text.slugify
|
||||
Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens.
|
||||
Remove characters that aren't alphanumerics, underscores, or hyphens.
|
||||
Convert to lowercase. Also strip leading and trailing whitespace.
|
||||
"""
|
||||
value = str(value)
|
||||
if allow_unicode:
|
||||
value = unicodedata.normalize('NFKC', value)
|
||||
else:
|
||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
|
||||
value = re.sub(r'[^\w\s-]', '', value).strip().lower()
|
||||
return re.sub(r'[-\s]+', '-', value)
|
||||
|
4
setup.py
4
setup.py
@ -11,7 +11,7 @@ with open('README.rst') as readme_file:
|
||||
with open('HISTORY.rst') as history_file:
|
||||
history = history_file.read()
|
||||
|
||||
requirements = ['pytz==2019.1', 'requests==2.22.0', 'python-slugify<3.0.0']
|
||||
requirements = ['pytz==2019.1', 'requests==2.22.0']
|
||||
|
||||
setup_requirements = [ ]
|
||||
|
||||
@ -41,6 +41,6 @@ setup(
|
||||
test_suite='tests',
|
||||
tests_require=test_requirements,
|
||||
url='https://github.com/eeriks/erepublik_script',
|
||||
version='0.14.5.1',
|
||||
version='0.14.5',
|
||||
zip_safe=False,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user