import re html_file = "/home/x79/sisvietnamvn_01/sisvietnamvn_main/html_snippets/content_main_blocks/temp" plugin_file = "/home/x79/sisvietnamvn_01/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/plugins/tabbedlivestream/TabbedLivestreamPlugin.java" with open(html_file, "r") as f: html_content = f.read() with open(plugin_file, "r") as f: plugin_content = f.read() target = """ // TODO: Dán mã HTML thật của tabbed-livestream vào đây t.setHtmlTemplate( "\\n" + "
\\n" + " {{#each livestream_posts}}\\n" + "
\\n" + " {{title}}\\n" + "
\\n" + " {{/each}}\\n" + "
" );""" replacement = ' t.setHtmlTemplate("""\n' + html_content + '""");' if target in plugin_content: new_content = plugin_content.replace(target, replacement) with open(plugin_file, "w") as f: f.write(new_content) print("Success") else: print("Target not found")