18 from .robottypes
import is_string
24 _CONTROL_WORDS = frozenset((
'ELSE',
'ELSE IF',
'AND',
'WITH NAME',
'AS'))
28 _SEQUENCES_TO_BE_ESCAPED = (
'\\',
'${',
'@{',
'%{',
'&{',
'*{',
'=')
34 if item
in _CONTROL_WORDS:
36 for seq
in _SEQUENCES_TO_BE_ESCAPED:
38 item = item.replace(seq,
'\\' + seq)
47 item = item.replace(char,
'[%s]' % char)
55 _escape_sequences = re.compile(
r'''
58 |x[0-9a-fA-F]{2} # x+HH
59 |u[0-9a-fA-F]{4} # u+HHHH
60 |U[0-9a-fA-F]{8} # U+HHHHHHHH
66 '':
lambda value: value,
67 'n':
lambda value:
'\n',
68 'r':
lambda value:
'\r',
69 't':
lambda value:
'\t',
76 ordinal = int(value, 16)
78 if ordinal > 0x10FFFF:
83 return eval(
r"'\U%08x'" % ordinal)
87 if not (
is_string(item)
and '\\' in item):
92 escapes, text = match.groups()
93 half, is_escaped = divmod(len(escapes), 2)
94 escapes = escapes[:half]
97 marker, value = text[:1], text[1:]
107 if not is_string(string)
or '=' not in string:
109 variables = VariableIterator(string, ignore_errors=
True)
110 if not variables
and '\\' not in string:
111 return tuple(string.split(
'=', 1))
116 return string[:index], string[index+1:]
121 for before, match, string
in variables:
125 relative_index += len(before) + len(match)
131 while '=' in string[index:]:
132 index += string[index:].index(
'=')
140 backslashes = len(name) - len(name.rstrip(
'\\'))
141 return backslashes % 2 == 0
def _hex_to_unichr(self, value)
def _handle_escapes(self, match)
def split_from_equals(string)
def _find_split_index_from_part(string)
def _find_split_index(string, variables)