def __first_filtration(self, code_lines): result = [] FILTER_REGEX = "bool""|int""|vector<""|string""|char" PATTERN = re.compile(FILTER_REGEX) #search_result = PATTERN.search(line) for line in code_lines: # Фильтрация кода # TODO: Может негенерить много ошибок # Можно внутри класса разбить так. # Сперва вытянуть в строку. # Затем разбить ;/:/ и только потом отфильтровать. if '(' not in line \ and ")" not in line \ and ";" in line \ and "{" not in line \ and "}" not in line \ and "#" not in line \ and "public:" not in line \ and "private" not in line \ and "protected" not in line: search_result = PATTERN.search(line) if search_result: line_copy = line line_copy = line_copy.lstrip().rstrip() line_copy = inner_reuse_local.remove_cc_comments(line_copy) line_copy = inner_reuse_local.delete_double_spaces(line_copy) result.append(line_copy) return '\n'.join(result)
def __end_filtration(self, declaration_string): declaration_string = declaration_string \ .replace('\t', " ") \ .replace('\n\t', " ") \ .replace(" ", " ") \ .replace('\n', " ") declaration_string = inner_reuse_local.delete_double_spaces(declaration_string) return declaration_string