19 from .splitter
import VariableIterator
22 def is_var(string, identifiers='$@&'):
23 if not string
or not is_string(string)
or len(string.strip(
'${}')) < 1:
25 if string[0]
not in identifiers
or (string[0] !=
'$' and string[1] !=
'{' and string[-1] !=
'}'):
29 if string[0] ==
'$' and string[1] ==
'{' and string[-1] ==
'}':
31 return '{' not in body
and '}' not in body
and body == string.strip(f
"{identifiers}"+
'{}')
35 return is_var(string, identifiers=
'$')
39 return is_var(string, identifiers=
'@')
43 return is_var(string, identifiers=
'&')
48 any(i
in string
for i
in identifiers)
and
49 '{' in string
and '}' in string
and
54 if not is_var(string, identifiers):
55 raise DataError(
"Invalid variable name '%s'." % string)
Used when variable does not exist.
def validate_var(string, identifiers='$@&')
def is_var(string, identifiers='$@&')
def is_scalar_var(string)
def contains_var(string, identifiers='$@&')