move slash_join to prevent local imports
This commit is contained in:
parent
e5d8a431f4
commit
5094e1f712
4 changed files with 17 additions and 16 deletions
|
@ -1,3 +1,18 @@
|
||||||
def get_app_url(config):
|
def get_app_url(config):
|
||||||
""" Returns the application's URL, based on the given config. """
|
""" Returns the application's URL, based on the given config. """
|
||||||
return '%s://%s' % (config['PREFERRED_URL_SCHEME'], config['SERVER_HOSTNAME'])
|
return '%s://%s' % (config['PREFERRED_URL_SCHEME'], config['SERVER_HOSTNAME'])
|
||||||
|
|
||||||
|
|
||||||
|
def slash_join(*args):
|
||||||
|
"""
|
||||||
|
Joins together strings and guarantees there is only one '/' in between the
|
||||||
|
each string joined. Double slashes ('//') are assumed to be intentional and
|
||||||
|
are not deduplicated.
|
||||||
|
"""
|
||||||
|
def rmslash(path):
|
||||||
|
path = path[1:] if path[0] == '/' else path
|
||||||
|
path = path[:-1] if path[-1] == '/' else path
|
||||||
|
return path
|
||||||
|
|
||||||
|
args = [rmslash(path) for path in args]
|
||||||
|
return '/'.join(args)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import time
|
||||||
|
|
||||||
from cachetools import TTLCache
|
from cachetools import TTLCache
|
||||||
from jwkest.jwk import KEYS
|
from jwkest.jwk import KEYS
|
||||||
from util.string import slash_join
|
from util import slash_join
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
def slash_join(*args):
|
|
||||||
"""
|
|
||||||
Joins together strings and guarantees there is only one '/' in between the
|
|
||||||
each string joined. Double slashes ('//') are assumed to be intentional and
|
|
||||||
are not deduplicated.
|
|
||||||
"""
|
|
||||||
def rmslash(path):
|
|
||||||
path = path[1:] if path[0] == '/' else path
|
|
||||||
path = path[:-1] if path[-1] == '/' else path
|
|
||||||
return path
|
|
||||||
|
|
||||||
args = [rmslash(path) for path in args]
|
|
||||||
return '/'.join(args)
|
|
|
@ -1,6 +1,5 @@
|
||||||
import re
|
|
||||||
import string
|
import string
|
||||||
import anunidecode
|
import re
|
||||||
|
|
||||||
|
|
||||||
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
|
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
|
||||||
|
|
Reference in a new issue