def extract_strings_from_c_files(with_paths=False): strings = [] for f in C_FILES_TO_PROCESS: file_content = open(f, "r").read() file_strings = re.findall(TRANSLATION_PATTERN, file_content) if with_paths: strings += [(s, os.path.basename(os.path.dirname(f))) for s in file_strings] else: strings += file_strings return util2.uniquify(strings)
def extractIncludes(file): content = open(file, "r").read() content = content.replace("\r\n", "\n") # filter out multi-line comments (could contain #include lines as examples) content = re.sub(r'(?s)/\*.*?\*/', '/* */', content) # try to filter out "#if 0 ... #endif" sections (hacky) content = re.sub(r'(?sm)^#if 0$.*?^#endif$', '', content) includes = re.findall(r'(?m)^#include ["<]([^">]+)[">]', content) includes = prependPath(includes, file) for inc in includes: includes += extractIncludes(inc) return util2.uniquify(includes)
def get_untranslated_as_list(untranslated_dict): return util2.uniquify(sum(untranslated_dict.values(), []))