Add a generated comment in *_generated.go in the style used by go generate

This commit is contained in:
Kovid Goyal
2022-09-15 14:10:57 +05:30
parent 21b572d69a
commit 833e9625f9

View File

@@ -3,16 +3,16 @@
import io
import json
import os
import sys
from functools import lru_cache
from contextlib import contextmanager, suppress
from functools import lru_cache
from typing import Dict, Iterator, List, Set, Tuple, Union
import kitty.constants as kc
from kittens.tui.operations import Mode
from kitty.cli import (
GoOption, go_options_for_seq, parse_option_spec,
serialize_as_go_string
GoOption, go_options_for_seq, parse_option_spec, serialize_as_go_string
)
from kitty.key_encoding import config_mod_map
from kitty.key_names import (
@@ -220,8 +220,6 @@ def generate_constants() -> str:
ref_map = load_ref_map()
dp = ", ".join(map(lambda x: f'"{serialize_as_go_string(x)}"', kc.default_pager_for_help))
return f'''\
// auto-generated by {__file__} do no edit
package kitty
type VersionType struct {{
@@ -253,6 +251,7 @@ def replace_if_needed(path: str) -> Iterator[io.StringIO]:
with suppress(FileNotFoundError), open(path, 'r') as f:
orig = f.read()
new = buf.getvalue()
new = f'// Code generated by {os.path.basename(__file__)}; DO NOT EDIT.\n\n' + new
if orig != new:
changed.append(path)
with open(path, 'w') as f: