Lines Matching refs:data
27 def find_first_not_restricted_character(restricted: str, data: str, pos: int = 0, pos_end: int = MAX_LEN) -> int:
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) -> int:
36 if pos > len(data):
37 pos = len(data) - 1
39 if data[pos] not in restricted:
42 return len(data)
45 def find_first_of_characters(characters: str, data: str, pos: int = 0, pos_end: int = MAX_LEN) -> int:
46 for i in range(pos, min(len(data), pos_end)):
47 if data[i] in characters:
49 return len(data)
52 def rfind_first_of_characters(characters: str, data: str, pos: int, pos_end: int = 0) -> int:
54 if pos > len(data):
55 pos = len(data) - 1
57 if data[pos] in characters:
60 return len(data)
63 def find_scope_borders(data: str, start: int = 0, opening: str = "{") -> Tuple[int, int]:
65 Returns pos of opening and closing brackets in 'data'.
76 opening_pos = find_first_of_characters("({<[", data, start)
77 if opening_pos == len(data):
79 opening = data[opening_pos]
82 start_of_scope = data.find(opening, start)
90 openings = data[start_of_scope : end_of_scope + 1].count(opening)
91 closings = data[start_of_scope : end_of_scope + 1].count(closing)
95 end_of_scope = data.find(closing, end_of_scope + 1)
103 def smart_split_by(data: str, delim: str = ",") -> list:
104 data = data.strip(" \n")
109 while segment_start < len(data):
111 next_delim = smart_find_first_of_characters(delim, data, segment_start)
113 segment = data[segment_start:next_delim].strip(" \n")
119 segment_start = find_first_not_restricted_character(f"{delim} \n", data, next_delim)
124 def smart_find_first_of_characters(characters: str, data: str, pos: int) -> int:
126 while i < len(data):
127 if data[i] in characters:
130 if data[i] in "<({[":
131 _, close_bracket = find_scope_borders(data, i, "")
134 elif data[i] == '"':
135 i = data.find('"', i + 1)
136 while i != -1 and data[i] == '"' and i != 0 and data[i - 1] == "\\":
137 i = data.find('"', i + 1)
139 elif data[i] == "'":
140 i = data.find("'", i + 1)
144 return len(data)
147 def check_cpp_name(data: str) -> bool:
148 data = data.lower()
150 return find_first_of_characters(forbidden_chars, data) == len(data)