diff options
author | Maciej Barć <xgqt@gentoo.org> | 2023-02-28 18:27:45 +0100 |
---|---|---|
committer | Maciej Barć <xgqt@gentoo.org> | 2023-02-28 18:27:45 +0100 |
commit | fc9ace2c35411861b316666b79e18d8a6293fae8 (patch) | |
tree | 7a3e48dd7dab6b92c33b16d82721b0a7aa227d65 | |
parent | Makefile: split compile-snippets into own rule (diff) | |
download | emacs-ebuild-snippets-fc9ace2c35411861b316666b79e18d8a6293fae8.tar.gz emacs-ebuild-snippets-fc9ace2c35411861b316666b79e18d8a6293fae8.tar.bz2 emacs-ebuild-snippets-fc9ace2c35411861b316666b79e18d8a6293fae8.zip |
scripts/generate_phase_snippets.py: use format method
Signed-off-by: Maciej Barć <xgqt@gentoo.org>
-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__": |