def replace_raw(raw_text, regex=True): for i, v in gdraw.items(): if len(i) == 2 and isinstance(i, tuple): if not regex: continue if i[0] in raw_text: raw_text = T.regexReplace(raw_text, i[1], str(v)) else: if py.istr(i): raw_text = raw_text.replace(str(i), str(v)) else: U.log(['unknow gdraw', i, v]) return raw_text