Add newslines at end of generated files and do imports in sorted order
This commit is contained in:
parent
c1324da3fc
commit
8f491e7dbb
@ -288,8 +288,8 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
|
||||
mmap: Dict[str, List[str]] = {}
|
||||
for mod, name in imports:
|
||||
mmap.setdefault(mod, []).append(name)
|
||||
for mod, names in mmap.items():
|
||||
names = sorted(names)
|
||||
for mod in sorted(mmap):
|
||||
names = sorted(mmap[mod])
|
||||
lines = textwrap.wrap(', '.join(names), 100)
|
||||
if len(lines) == 1:
|
||||
s = lines[0]
|
||||
@ -326,9 +326,9 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
|
||||
def write_output(loc: str, defn: Definition) -> None:
|
||||
cls, tc = generate_class(defn, loc)
|
||||
with open(os.path.join(*loc.split('.'), 'options', 'types.py'), 'w') as f:
|
||||
f.write(cls)
|
||||
f.write(cls + '\n')
|
||||
with open(os.path.join(*loc.split('.'), 'options', 'parse.py'), 'w') as f:
|
||||
f.write(tc)
|
||||
f.write(tc + '\n')
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
4
kittens/diff/options/parse.py
generated
4
kittens/diff/options/parse.py
generated
@ -2,8 +2,8 @@
|
||||
# vim:fileencoding=utf-8
|
||||
|
||||
import typing
|
||||
from kitty.conf.utils import merge_dicts, positive_int, python_string, to_color, to_color_or_none
|
||||
from kittens.diff.options.utils import parse_map, syntax_aliases
|
||||
from kitty.conf.utils import merge_dicts, positive_int, python_string, to_color, to_color_or_none
|
||||
|
||||
|
||||
class Parser:
|
||||
@ -117,4 +117,4 @@ def parse_conf_item(key: str, val: str, ans: typing.Dict[str, typing.Any]) -> bo
|
||||
if func is not None:
|
||||
func(val, ans)
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
6
kittens/diff/options/types.py
generated
6
kittens/diff/options/types.py
generated
@ -2,12 +2,12 @@
|
||||
# vim:fileencoding=utf-8
|
||||
|
||||
import typing
|
||||
from kitty.types import ParsedShortcut
|
||||
import kitty.types
|
||||
from kitty.conf.utils import KeyAction, KittensKeyMap
|
||||
import kitty.conf.utils
|
||||
from kitty.rgb import Color
|
||||
import kitty.rgb
|
||||
from kitty.types import ParsedShortcut
|
||||
import kitty.types
|
||||
|
||||
|
||||
option_names = ( # {{{
|
||||
@ -138,4 +138,4 @@ defaults.map = [
|
||||
(ParsedShortcut(mods=0, key_name='<'), KeyAction('scroll_to', ('prev-match',))),
|
||||
(ParsedShortcut(mods=0, key_name='f'), KeyAction('start_search', (False, False))),
|
||||
(ParsedShortcut(mods=0, key_name='b'), KeyAction('start_search', (False, True))),
|
||||
]
|
||||
]
|
||||
|
||||
10
kitty/options/parse.py
generated
10
kitty/options/parse.py
generated
@ -2,6 +2,10 @@
|
||||
# vim:fileencoding=utf-8
|
||||
|
||||
import typing
|
||||
from kitty.conf.utils import (
|
||||
merge_dicts, positive_float, positive_int, to_bool, to_cmdline, to_color, to_color_or_none,
|
||||
unit_float
|
||||
)
|
||||
from kitty.options.utils import (
|
||||
active_tab_title_template, adjust_line_height, allow_hyperlinks, allow_remote_control,
|
||||
box_drawing_scale, clear_all_shortcuts, clipboard_control, config_or_absolute_path, copy_on_select,
|
||||
@ -14,10 +18,6 @@ from kitty.options.utils import (
|
||||
to_font_size, to_layout_names, to_modifiers, url_prefixes, url_style, window_border_width,
|
||||
window_size
|
||||
)
|
||||
from kitty.conf.utils import (
|
||||
merge_dicts, positive_float, positive_int, to_bool, to_cmdline, to_color, to_color_or_none,
|
||||
unit_float
|
||||
)
|
||||
|
||||
|
||||
class Parser:
|
||||
@ -1288,4 +1288,4 @@ def parse_conf_item(key: str, val: str, ans: typing.Dict[str, typing.Any]) -> bo
|
||||
if func is not None:
|
||||
func(val, ans)
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
12
kitty/options/types.py
generated
12
kitty/options/types.py
generated
@ -2,16 +2,16 @@
|
||||
# vim:fileencoding=utf-8
|
||||
|
||||
import typing
|
||||
from kitty.options.utils import KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap
|
||||
import kitty.options.utils
|
||||
from kitty.conf.utils import KeyAction
|
||||
import kitty.conf.utils
|
||||
from kitty.types import FloatEdges, SingleKey
|
||||
import kitty.types
|
||||
from kitty.constants import is_macos
|
||||
import kitty.constants
|
||||
from kitty.options.utils import KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap
|
||||
import kitty.options.utils
|
||||
from kitty.rgb import Color
|
||||
import kitty.rgb
|
||||
from kitty.types import FloatEdges, SingleKey
|
||||
import kitty.types
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
choices_for_background_image_layout = typing.Literal['mirror-tiled', 'scaled', 'tiled']
|
||||
@ -875,9 +875,9 @@ defaults.map = [
|
||||
KeyDefinition(False, KeyAction('paste_from_selection'), 1, False, 57348, ()),
|
||||
KeyDefinition(False, KeyAction('pass_selection_to_program'), 1024, False, 111, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 57352, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 107, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_up'), 10, False, 57354, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_up'), 8, False, 57352, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 107, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_down'), 1024, False, 57353, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_down'), 1024, False, 106, ()),
|
||||
KeyDefinition(False, KeyAction('scroll_line_down'), 10, False, 57355, ()),
|
||||
@ -1037,4 +1037,4 @@ defaults.mouse_map = [
|
||||
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))),
|
||||
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))),
|
||||
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))),
|
||||
]
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user