From 5094e1f712b2fb4ee974d80db480b9d753a193f6 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Fri, 18 Mar 2016 15:09:25 -0400 Subject: [PATCH] move slash_join to prevent local imports --- util/__init__.py | 15 +++++++++++++++ util/config/oauth.py | 2 +- util/string.py | 13 ------------- util/validation.py | 3 +-- 4 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 util/string.py diff --git a/util/__init__.py b/util/__init__.py index cbabb8fbe..c45aad78f 100644 --- a/util/__init__.py +++ b/util/__init__.py @@ -1,3 +1,18 @@ def get_app_url(config): """ Returns the application's URL, based on the given config. """ 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) diff --git a/util/config/oauth.py b/util/config/oauth.py index 35b4b02fb..4e01f713e 100644 --- a/util/config/oauth.py +++ b/util/config/oauth.py @@ -5,7 +5,7 @@ import time from cachetools import TTLCache from jwkest.jwk import KEYS -from util.string import slash_join +from util import slash_join logger = logging.getLogger(__name__) diff --git a/util/string.py b/util/string.py deleted file mode 100644 index c47907817..000000000 --- a/util/string.py +++ /dev/null @@ -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) diff --git a/util/validation.py b/util/validation.py index 085fb0190..535c75f38 100644 --- a/util/validation.py +++ b/util/validation.py @@ -1,6 +1,5 @@ -import re import string -import anunidecode +import re INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \