def render(self, match_string, new_string):
current_dir = self.options.dir<EOL>if os.path.expanduser(current_dir) in ['<STR_LIT:/>', os.path.expanduser("<STR_LIT>")]:<EOL><INDENT>self.error("<STR_LIT>", -<NUM_LIT:1>)<EOL>pass<EOL><DEDENT>def match_directory(path):<EOL><INDENT>"""<STR_LIT>"""<EOL>skip = False<EOL>for include_dir in ['<STR_LIT>' % s for s in<EOL>self.exclude_directories]:<EOL><INDENT>if path.find(include_dir) > -<NUM_LIT:1>:<EOL><INDENT>skip = True<EOL>break<EOL><DEDENT>pass<EOL><DEDENT>return skip<EOL><DEDENT>for v in os.walk(current_dir):<EOL><INDENT>if os.path.basename(v[<NUM_LIT:0>]) in self.exclude_directories:<EOL><INDENT>continue<EOL><DEDENT>if match_directory(v[<NUM_LIT:0>]):<EOL><INDENT>continue<EOL><DEDENT>for base_name in v[<NUM_LIT:2>]:<EOL><INDENT>file_name = os.path.join(v[<NUM_LIT:0>], base_name)<EOL>try:<EOL><INDENT>with open(file_name, '<STR_LIT:r>') as fh:<EOL><INDENT>buffer = fh.read()<EOL>buffer = buffer.replace(match_string, new_string)<EOL>pass<EOL><DEDENT>with open(file_name, '<STR_LIT:w>') as fh:<EOL><INDENT>fh.write(buffer)<EOL>pass<EOL><DEDENT><DEDENT>except UnicodeDecodeError:<EOL><INDENT>continue<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>redo_directories = []<EOL>redo_files = []<EOL>for v in os.walk(current_dir):<EOL><INDENT>if os.path.basename(v[<NUM_LIT:0>]) in self.exclude_directories:<EOL><INDENT>continue<EOL><DEDENT>if match_directory(v[<NUM_LIT:0>]):<EOL><INDENT>continue<EOL><DEDENT>for sub_dir in v[<NUM_LIT:1>]:<EOL><INDENT>if match_string in sub_dir:<EOL><INDENT>redo_directories.append(os.path.join(v[<NUM_LIT:0>], sub_dir))<EOL>pass<EOL><DEDENT><DEDENT>for f in v[<NUM_LIT:2>]:<EOL><INDENT>if match_string in f:<EOL><INDENT>redo_files.append(os.path.join(v[<NUM_LIT:0>], f))<EOL>pass<EOL><DEDENT><DEDENT>pass<EOL><DEDENT>redo_directories.reverse()<EOL>redo_files.reverse()<EOL>for v in redo_files:<EOL><INDENT>dir_name = os.path.dirname(v)<EOL>file_name = os.path.basename(v)<EOL>shutil.move(v, os.path.join(<EOL>dir_name,<EOL>file_name.replace(match_string, new_string)))<EOL>pass<EOL><DEDENT>for v in redo_directories:<EOL><INDENT>shutil.move(v, v.replace(match_string, new_string))<EOL>pass<EOL><DEDENT>pass<EOL>
render template string to user string
:param str match_string: template string,syntax: '___VAR___'
:param str new_string: user string
:return: