diff options
-rwxr-xr-x | scripts/generate_phase_snippets.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/scripts/generate_phase_snippets.py b/scripts/generate_phase_snippets.py index 5d769dc..231f6eb 100755 --- a/scripts/generate_phase_snippets.py +++ b/scripts/generate_phase_snippets.py @@ -25,7 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. # See Gentoo Developer Manual for a reference: # https://devmanual.gentoo.org/ebuild-writing/functions/index.html#contents -EBUILD_PHASES=[ +EBUILD_PHASES = [ "pkg_pretend", "pkg_nofetch", "pkg_setup", @@ -43,7 +43,7 @@ EBUILD_PHASES=[ "pkg_info", ] -YASNIPPET_BODY="""# -*- mode: snippet; indent-tabs-mode: t; -*- +YASNIPPET_BODY = """# -*- mode: snippet; indent-tabs-mode: t; -*- # Copyright 2023 Gentoo Authors @@ -63,15 +63,15 @@ YASNIPPET_BODY="""# -*- mode: snippet; indent-tabs-mode: t; -*- # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. -# name: %s -# key: %s +# name: {ebuild_phase} +# key: {ebuild_phase} # -- -%s() { -\t${1:default} +{ebuild_phase}() {{ +\t${{1:default}} \t$2 -} +}} """ @@ -79,14 +79,12 @@ def main(): """Main.""" for ebuild_phase in EBUILD_PHASES: - yas_file_path = f"./snippets/ebuild-mode/{ebuild_phase}.yas" + yas_path = f"./snippets/ebuild-mode/{ebuild_phase}.yas" - print(f"Generating: \"{yas_file_path}\"...") + print(f'Generating: "{yas_path}"...') - with open(yas_file_path, "w", encoding="utf-8") as yas_file_buffer: - yas_file_buffer.write( - YASNIPPET_BODY % (ebuild_phase, ebuild_phase, ebuild_phase) - ) + with open(yas_path, "w", encoding="utf-8") as yas_buffer: + yas_buffer.write(YASNIPPET_BODY.format(ebuild_phase=ebuild_phase)) if __name__ == "__main__": |