Use precompiled regex for yaql expression detection

Change-Id: I5a50c9519e7fbb936f863b64f68884d59de695cd
This commit is contained in:
Stan Lagun 2016-02-28 19:59:49 +03:00
parent 4d82e2f4c2
commit 53fe1ee1b7
1 changed files with 4 additions and 1 deletions

View File

@ -23,6 +23,9 @@ from murano.dsl import dsl_types
from murano.dsl import yaql_integration
EXPRESSION_REGEX = re.compile('^[\s\w\d.]*$')
class YaqlExpression(dsl_types.YaqlExpression):
def __init__(self, expression, version):
self._version = version
@ -68,7 +71,7 @@ class YaqlExpression(dsl_types.YaqlExpression):
def is_expression(expression, version):
if not isinstance(expression, six.string_types):
return False
if re.match('^[\s\w\d.]*$', expression):
if EXPRESSION_REGEX.match(expression):
return False
try:
yaql_integration.parse(expression, version)