regex fix, thanks Paolo
This commit is contained in:
+2
-2
@@ -116,8 +116,8 @@ load_routes()
|
|||||||
HTTPS_SCHEMES = set(('https', 'HTTPS'))
|
HTTPS_SCHEMES = set(('https', 'HTTPS'))
|
||||||
|
|
||||||
|
|
||||||
# pattern used to validate client address
|
# pattern used to match client IP address
|
||||||
REGEX_CLIENT = re.compile(r'[\w:-]+(\.[\w-]+)*\.?') # ## to account for IPV6
|
REGEX_CLIENT = re.compile(r'[\w:]+(\.\w+)*')
|
||||||
|
|
||||||
def get_client(env):
|
def get_client(env):
|
||||||
"""
|
"""
|
||||||
|
|||||||
+6
-4
@@ -59,6 +59,8 @@ def enable_autocomplete_and_history(adir, env):
|
|||||||
readline.set_completer(rlcompleter.Completer(env).complete)
|
readline.set_completer(rlcompleter.Completer(env).complete)
|
||||||
|
|
||||||
|
|
||||||
|
REGEX_APP_PATH = '(?:.*/)?applications/(?P<a>[^/]+)'
|
||||||
|
|
||||||
def exec_environment(
|
def exec_environment(
|
||||||
pyfile='',
|
pyfile='',
|
||||||
request=None,
|
request=None,
|
||||||
@@ -83,10 +85,10 @@ def exec_environment(
|
|||||||
session = Session()
|
session = Session()
|
||||||
|
|
||||||
if request.folder is None:
|
if request.folder is None:
|
||||||
mo = re.match(r'(|.*/)applications/(?P<appname>[^/]+)', pyfile)
|
mo = re.match(REGEX_APP_PATH, pyfile)
|
||||||
if mo:
|
if mo:
|
||||||
appname = mo.group('appname')
|
a = mo.group('a')
|
||||||
request.folder = os.path.abspath(os.path.join('applications', appname))
|
request.folder = os.path.abspath(os.path.join('applications', a))
|
||||||
else:
|
else:
|
||||||
request.folder = ''
|
request.folder = ''
|
||||||
env = build_environment(request, response, session, store_current=False)
|
env = build_environment(request, response, session, store_current=False)
|
||||||
@@ -380,7 +382,7 @@ def test(testpath, import_models=True, verbose=False):
|
|||||||
|
|
||||||
import doctest
|
import doctest
|
||||||
if os.path.isfile(testpath):
|
if os.path.isfile(testpath):
|
||||||
mo = re.search('/?applications/(?P<a>[^/]+)', testpath)
|
mo = re.match(REGEX_APP_PATH, testpath)
|
||||||
if not mo:
|
if not mo:
|
||||||
die('test file is not in application directory: %s'
|
die('test file is not in application directory: %s'
|
||||||
% testpath)
|
% testpath)
|
||||||
|
|||||||
Reference in New Issue
Block a user