hyprconf2lua 1.3.2__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {hyprconf2lua-1.3.2/src/hyprconf2lua.egg-info → hyprconf2lua-1.4.0}/PKG-INFO +3 -1
  2. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/pyproject.toml +4 -1
  3. hyprconf2lua-1.4.0/src/hyprconf2lua/__init__.py +1 -0
  4. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/codegen.py +11 -18
  5. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/mappings.py +0 -3
  6. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/parser.py +17 -0
  7. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0/src/hyprconf2lua.egg-info}/PKG-INFO +3 -1
  8. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua.egg-info/SOURCES.txt +1 -0
  9. hyprconf2lua-1.4.0/src/hyprconf2lua.egg-info/requires.txt +3 -0
  10. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/tests/test_converter.py +66 -63
  11. hyprconf2lua-1.3.2/src/hyprconf2lua/__init__.py +0 -1
  12. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/LICENSE +0 -0
  13. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/README.md +0 -0
  14. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/setup.cfg +0 -0
  15. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/__main__.py +0 -0
  16. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/ast.py +0 -0
  17. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/cli.py +0 -0
  18. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/converter.py +0 -0
  19. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua/lexer.py +0 -0
  20. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua.egg-info/dependency_links.txt +0 -0
  21. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua.egg-info/entry_points.txt +0 -0
  22. {hyprconf2lua-1.3.2 → hyprconf2lua-1.4.0}/src/hyprconf2lua.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyprconf2lua
3
- Version: 1.3.2
3
+ Version: 1.4.0
4
4
  Summary: Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)
5
5
  Author: hyprconf2lua contributors
6
6
  License: MIT
@@ -17,6 +17,8 @@ Classifier: Topic :: Utilities
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest; extra == "dev"
20
22
  Dynamic: license-file
21
23
 
22
24
  # hyprconf2lua
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyprconf2lua"
7
- version = "1.3.2"
7
+ version = "1.4.0"
8
8
  description = "Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -23,6 +23,9 @@ classifiers = [
23
23
  "Topic :: Utilities",
24
24
  ]
25
25
 
26
+ [project.optional-dependencies]
27
+ dev = ["pytest"]
28
+
26
29
  [project.urls]
27
30
  Homepage = "https://github.com/Prateek-squadron/hyprconf2lua"
28
31
  Repository = "https://github.com/Prateek-squadron/hyprconf2lua"
@@ -0,0 +1 @@
1
+ __version__ = "1.4.0"
@@ -51,7 +51,7 @@ class Codegen:
51
51
 
52
52
  def generate(self, config: ConfigFile) -> str:
53
53
  self.lines = []
54
- self.emit("-- Generated by hyprconf2lua v1.3.2")
54
+ self.emit("-- Generated by hyprconf2lua v1.4.0")
55
55
  self.emit("-- https://github.com/Prateek-squadron/hyprconf2lua")
56
56
  self.emit("-- Manual review may be needed for complex directives")
57
57
  self.emit("")
@@ -550,6 +550,16 @@ class Codegen:
550
550
  return f'{func}({{ forward = false }})'
551
551
  return f'{func}({{ forward = true }})'
552
552
 
553
+ if dispatcher == "moveintogroup":
554
+ if params:
555
+ dir_map = {"l": "left", "r": "right", "u": "up", "d": "down"}
556
+ d = dir_map.get(params[0], params[0])
557
+ return f'{func}({{ into_group = "{d}" }})'
558
+ return None
559
+
560
+ if dispatcher == "moveoutofgroup":
561
+ return f'{func}({{ out_of_group = true }})'
562
+
553
563
  if dispatcher == "workspace":
554
564
  return self.build_workspace_dispatcher(func, params)
555
565
 
@@ -565,12 +575,6 @@ class Codegen:
565
575
  if dispatcher == "focusonemonitor":
566
576
  return f'{func}({{ on_monitor = true }})'
567
577
 
568
- if dispatcher == "mouse":
569
- mouse_actions = {"272": "drag", "273": "resize"}
570
- if params and params[0] in mouse_actions:
571
- return f'hl.dsp.window.{mouse_actions[params[0]]}()'
572
- return None
573
-
574
578
  if dispatcher in ("exec", "execr"):
575
579
  resolved = self.resolve_val(params[0]) if params else ""
576
580
  return f'{func}({self.quote(resolved)})'
@@ -584,16 +588,6 @@ class Codegen:
584
588
  return f'hl.dsp.window.{mouse_actions[params[0]]}()'
585
589
  return None
586
590
 
587
- if dispatcher in ("moveintogroup",):
588
- if params:
589
- dir_map = {"l": "left", "r": "right", "u": "up", "d": "down"}
590
- d = dir_map.get(params[0], params[0])
591
- return f'hl.dsp.window.move({{ into_group = "{d}" }})'
592
- return None
593
-
594
- elif dispatcher in ("moveoutofgroup",):
595
- return f'hl.dsp.window.move({{ out_of_group = true }})'
596
-
597
591
  return None
598
592
 
599
593
  def build_workspace_dispatcher(self, func: str, params: List[str]) -> str:
@@ -835,7 +829,6 @@ class Codegen:
835
829
  return
836
830
 
837
831
  self.emit(f'-- source = {path} -> requires manual conversion')
838
- home_relative = path.replace("~", "").replace(os_path := "", ".hypr/")
839
832
 
840
833
  import os as _os
841
834
  just_name = _os.path.splitext(_os.path.basename(path))[0]
@@ -75,8 +75,6 @@ WINDOW_RULE_MAP = {
75
75
  "noshadow": ("shadow", "false"),
76
76
  "noanim": ("no_anim", "true"),
77
77
  "dimaround": ("dim_around", "true"),
78
- "noblur": ("blur", "false"),
79
- "noshadow": ("shadow", "false"),
80
78
  "nomaxsize": ("max_size", "false"),
81
79
  "fakefullscreen": ("fake_fullscreen", "true"),
82
80
  "noinitialfocus": ("no_initial_focus", "true"),
@@ -96,7 +94,6 @@ WINDOW_RULE_PARAM_MAP = {
96
94
  "size": ("size", True),
97
95
  "minsize": ("min_size", True),
98
96
  "maxsize": ("max_size", True),
99
- "maxsize": ("max_size", True),
100
97
  "idleinhibit": ("idle_inhibit", True),
101
98
  "xray": ("xray", True),
102
99
  "center": ("center", True),
@@ -172,6 +172,23 @@ class Parser:
172
172
  current = []
173
173
  while self.peek().type not in ("NEWLINE", "EOF") and \
174
174
  self.peek().type != "COMMENT":
175
+ if self.peek().type == "BLOCK_CLOSE":
176
+ break
177
+ if self.peek().type == "BLOCK_OPEN":
178
+ self.advance()
179
+ current.append("{")
180
+ depth = 1
181
+ while depth > 0 and self.peek().type not in ("EOF", "NEWLINE"):
182
+ t = self.advance()
183
+ if t.type == "BLOCK_OPEN":
184
+ depth += 1
185
+ elif t.type == "BLOCK_CLOSE":
186
+ depth -= 1
187
+ if depth > 0:
188
+ current.append(t.value)
189
+ if depth == 0:
190
+ current.append("}")
191
+ continue
175
192
  if self.peek().type == "COMMA":
176
193
  self.advance()
177
194
  values.append(self._join_tokens(current))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyprconf2lua
3
- Version: 1.3.2
3
+ Version: 1.4.0
4
4
  Summary: Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)
5
5
  Author: hyprconf2lua contributors
6
6
  License: MIT
@@ -17,6 +17,8 @@ Classifier: Topic :: Utilities
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest; extra == "dev"
20
22
  Dynamic: license-file
21
23
 
22
24
  # hyprconf2lua
@@ -14,5 +14,6 @@ src/hyprconf2lua.egg-info/PKG-INFO
14
14
  src/hyprconf2lua.egg-info/SOURCES.txt
15
15
  src/hyprconf2lua.egg-info/dependency_links.txt
16
16
  src/hyprconf2lua.egg-info/entry_points.txt
17
+ src/hyprconf2lua.egg-info/requires.txt
17
18
  src/hyprconf2lua.egg-info/top_level.txt
18
19
  tests/test_converter.py
@@ -0,0 +1,3 @@
1
+
2
+ [dev]
3
+ pytest
@@ -88,14 +88,11 @@ def test_lexer_variable():
88
88
 
89
89
 
90
90
  def test_lexer_error():
91
+ from hyprconf2lua.lexer import LexerError
91
92
  import pytest
92
- try:
93
- from hyprconf2lua.lexer import LexerError
94
- except ImportError:
95
- pytest.skip("need pytest")
96
93
 
97
94
  with pytest.raises(LexerError):
98
- tokenize("key = value `bad`")
95
+ tokenize("key = value !bad")
99
96
 
100
97
 
101
98
  def test_parse_variable():
@@ -599,61 +596,67 @@ def test_movetoworkspacesilent_conversion():
599
596
  assert "workspace = 1" in result.lua
600
597
 
601
598
 
602
- if __name__ == "__main__":
603
- test_lexer_basic()
604
- test_lexer_comment()
605
- test_lexer_section()
606
- test_lexer_variable()
607
- test_parse_variable()
608
- test_parse_section()
609
- test_parse_bind()
610
- test_parse_monitor()
611
- test_parse_windowrule()
612
- test_parse_windowrulev2()
613
- test_parse_env()
614
- test_parse_exec()
615
- test_parse_device()
616
- test_full_conversion()
617
- test_conversion_report()
618
- test_empty_config()
619
- test_comment_only()
620
- test_variable_reference()
621
- test_multiple_monitors()
622
- test_bezier_conversion()
623
- test_bind_with_flags()
624
- test_bindm_conversion()
625
- test_layerrule_conversion()
626
- test_workspace_conversion()
627
- test_exec_ordering()
628
- test_env_with_comma_value()
629
- test_mouse_bind_movewindow()
630
- test_mouse_bind_resizewindow()
631
- test_windowrule_with_at_sign()
632
- test_submap_conversion()
633
- test_plugin_section()
634
- test_plugin_subsections()
635
- test_unbind_conversion()
636
- test_unknown_section_autoconvert()
637
- test_colon_separated_nested_key()
638
- test_colon_two_level_key()
639
- test_monitor_extra_fields()
640
- test_hl_annotation()
641
- test_no_todo_on_unknown_section()
642
- test_backslash_in_regex()
643
- test_backslash_in_windowrule_class()
644
- test_bracket_in_windowrule()
645
- test_bracket_in_workspace()
646
- test_bracket_in_exec_on()
647
- test_bracket_in_windowrule_params()
648
- test_forcekillactive_dispatcher()
649
- test_ampersand_in_bind_mods()
650
- test_ampersand_in_bind_mods_nospace()
651
- test_device_without_prefix()
652
- test_gradient_conversion()
653
- test_col_dot_prefix_grouped()
654
- test_match_block_in_windowrule()
655
- test_match_block_in_windowrulev2()
656
- test_match_block_in_layerrule()
657
- test_movetoworkspace_conversion()
658
- test_movetoworkspacesilent_conversion()
659
- print("All tests passed!")
599
+ def test_single_line_section():
600
+ result = convert('general { gaps_in = 5 }\n')
601
+ assert result.success
602
+ assert "hl.config" in result.lua
603
+ assert "gaps_in = 5" in result.lua
604
+
605
+
606
+ def test_empty_file():
607
+ result = convert("")
608
+ assert result.success
609
+
610
+
611
+ def test_whitespace_only():
612
+ result = convert(" \n \n \n")
613
+ assert result.success
614
+
615
+
616
+ def test_tab_indentation():
617
+ result = convert("general {\n\tgaps_in = 5\n}\n")
618
+ assert result.success
619
+ assert "gaps_in = 5" in result.lua
620
+
621
+
622
+ def test_bind_no_params():
623
+ result = convert("bind = SUPER, Q, exec\n")
624
+ assert result.success
625
+
626
+
627
+ def test_unbind_no_args():
628
+ result = convert("unbind = ,\n")
629
+ assert result.success
630
+
631
+
632
+ def test_exec_shutdown():
633
+ result = convert("exec-shutdown = killall waybar\n")
634
+ assert result.success
635
+ assert "hl.on" in result.lua or "exec_shutdown" in result.lua
636
+
637
+
638
+ def test_gesture_multiple():
639
+ result = convert("gesture {\n workspace_swipe = true\n workspace_swipe_fingers = 3\n}\n")
640
+ assert result.success
641
+ assert "hl.gesture" in result.lua
642
+ assert "swipe fingers" in result.lua
643
+
644
+
645
+ def test_moveintogroup_dispatcher():
646
+ result = convert("bind = SUPER, T, moveintogroup, l\n")
647
+ assert result.success
648
+ assert "into_group" in result.lua
649
+ assert '"left"' in result.lua
650
+
651
+
652
+ def test_moveoutofgroup_dispatcher():
653
+ result = convert("bind = SUPER, T, moveoutofgroup\n")
654
+ assert result.success
655
+ assert "out_of_group" in result.lua
656
+
657
+
658
+ def test_nested_subsection_in_decoration():
659
+ result = convert("decoration {\n blur {\n size = 3\n passes = 2\n }\n}\n")
660
+ assert result.success
661
+ assert "blur" in result.lua
662
+ assert "size = 3" in result.lua
@@ -1 +0,0 @@
1
- __version__ = "1.3.2"
File without changes
File without changes
File without changes