Lines Matching full:data
27 def find_first_not_restricted_character(restricted: str, data: str, pos: int = 0, pos_end: int = MA…
28 for i in range(pos, min(len(data), pos_end)):
29 if data[i] not in restricted:
31 return len(data)
34 def rfind_first_not_restricted_character(restricted: str, data: str, pos: int, pos_end: int = 0) ->…
36 if pos > len(data):
37 pos = len(data) - 1
39 if data[pos] not in restricted:
42 return len(data)
45 def skip_rstring(data: str, pos: int = 0, pos_end: int = MAX_LEN) -> int:
47 if data[pos] != '"' or pos < 1:
50 if data[pos - 1 : pos + 1] == 'R"':
51 start_of_string_data = data.find("(", pos)
55 delimeter = f"{data[pos + 1 : start_of_string_data]}"
56 end_of_string_data = data.find(f'){delimeter}"', start_of_string_data)
58 if end_of_string_data == -1 or end_of_string_data >= min(len(data), pos_end):
66 def skip_string(data: str, pos: int = 0, pos_end: int = MAX_LEN) -> int:
68 if data[pos] not in "'\"":
71 current_quote = data[pos]
72 pos = data.find(current_quote, pos + 1)
75 …while pos > 0 and pos < min(len(data), pos_end) and data[pos - 1] == "\\" and (pos == 1 or data[po…
76 pos = data.find(current_quote, pos + 1)
78 if pos == -1 or pos >= min(len(data), pos_end):
83 def find_first_of_characters(characters: str, data: str, pos: int = 0, pos_end: int = MAX_LEN) -> i…
84 while pos < min(len(data), pos_end) and pos != -1:
86 if "'" not in characters and '"' not in characters and data[pos] in "'\"":
87 pos = skip_rstring(data, pos)
88 pos = skip_string(data, pos)
90 if data[pos] in characters:
93 return len(data)
96 def rfind_first_of_characters(characters: str, data: str, pos: int, pos_end: int = 0) -> int:
98 if pos > len(data):
99 pos = len(data) - 1
101 if data[pos] in characters:
104 return len(data)
107 def is_operator(data: str, current_pos: int) -> bool:
108 if current_pos < len("operator") + 1 or data[current_pos - len("operator") - 1].isalpha():
110 return data[current_pos - len("operator") : current_pos] == "operator"
113 def find_scope_borders(data: str, start: int = 0, opening_bracket: str = "{") -> Tuple[int, int]:
115 Returns tuple of positions of opening and closing brackets in 'data'.
123 start_of_scope = find_first_of_characters("({<[", data, start_of_scope)
124 if start_of_scope == len(data):
126 if is_operator(data, start_of_scope):
127 …start_of_scope = find_first_not_restricted_character(data[start_of_scope], data, start_of_scope + …
129 opening = data[start_of_scope]
131 start_of_scope = data.find(opening, start)
133 while is_operator(data, start_of_scope):
134 start_of_scope = find_first_not_restricted_character(opening, data, start_of_scope + 1)
135 start_of_scope = find_first_of_characters(opening, data, start_of_scope)
145 current_pos = find_first_of_characters(f"{opening}{closing}", data, current_pos + 1)
146 if current_pos == len(data):
148 if data[current_pos] == opening:
150 elif data[current_pos] == closing:
156 def smart_split_by(data: str, delim: str = ",") -> list:
157 data = data.strip(" \n")
162 while segment_start < len(data):
164 next_delim = smart_find_first_of_characters(delim, data, segment_start)
166 segment = data[segment_start:next_delim].strip(" \n")
172 segment_start = find_first_not_restricted_character(f"{delim} \n", data, next_delim)
177 def smart_find_first_of_characters(characters: str, data: str, pos: int) -> int:
179 while i < len(data):
180 if data[i] in characters:
183 if data[i] in "<({[":
184 _, close_bracket = find_scope_borders(data, i, "")
187 elif data[i] == '"':
188 i = data.find('"', i + 1)
189 while i != -1 and data[i] == '"' and i != 0 and data[i - 1] == "\\":
190 i = data.find('"', i + 1)
192 elif data[i] == "'":
193 i = data.find("'", i + 1)
197 return len(data)
200 def check_cpp_name(data: str) -> bool:
201 data = data.lower()
203 return find_first_of_characters(forbidden_chars, data) == len(data)