hyprconf2lua 1.8.1__tar.gz → 1.8.2__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 (23) hide show
  1. {hyprconf2lua-1.8.1/src/hyprconf2lua.egg-info → hyprconf2lua-1.8.2}/PKG-INFO +1 -1
  2. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/pyproject.toml +1 -1
  3. hyprconf2lua-1.8.2/src/hyprconf2lua/__init__.py +1 -0
  4. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/cli.py +10 -9
  5. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/codegen.py +11 -2
  6. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2/src/hyprconf2lua.egg-info}/PKG-INFO +1 -1
  7. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/tests/test_converter.py +52 -0
  8. hyprconf2lua-1.8.1/src/hyprconf2lua/__init__.py +0 -1
  9. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/LICENSE +0 -0
  10. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/README.md +0 -0
  11. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/setup.cfg +0 -0
  12. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/__main__.py +0 -0
  13. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/ast.py +0 -0
  14. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/converter.py +0 -0
  15. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/lexer.py +0 -0
  16. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/mappings.py +0 -0
  17. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua/parser.py +0 -0
  18. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua.egg-info/SOURCES.txt +0 -0
  19. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua.egg-info/dependency_links.txt +0 -0
  20. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua.egg-info/entry_points.txt +0 -0
  21. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua.egg-info/requires.txt +0 -0
  22. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/src/hyprconf2lua.egg-info/top_level.txt +0 -0
  23. {hyprconf2lua-1.8.1 → hyprconf2lua-1.8.2}/tests/test_issue54.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyprconf2lua
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)
5
5
  Author: hyprconf2lua contributors
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyprconf2lua"
7
- version = "1.8.1"
7
+ version = "1.8.2"
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"}
@@ -0,0 +1 @@
1
+ __version__ = "1.8.2"
@@ -48,7 +48,9 @@ def process_dir(dir_path: str, in_place: bool = False, check: bool = False,
48
48
  fpath = os.path.join(root, fname)
49
49
  lua_path = os.path.splitext(fpath)[0] + ".lua"
50
50
 
51
- if not check and not in_place:
51
+ if not check and not in_place and os.path.exists(lua_path):
52
+ print(f" SKIP: {lua_path} exists (use --in-place to overwrite)",
53
+ file=sys.stderr)
52
54
  continue
53
55
 
54
56
  lua_output = convert_file(fpath, check=check, report=report)
@@ -62,14 +64,13 @@ def process_dir(dir_path: str, in_place: bool = False, check: bool = False,
62
64
  if check:
63
65
  print(f" PASS: {fpath}")
64
66
  continue
65
- if in_place:
66
- try:
67
- with open(lua_path, "w") as f:
68
- f.write(lua_output)
69
- print(f" WROTE: {lua_path}")
70
- except IOError as e:
71
- print(f" ERROR writing {lua_path}: {e}", file=sys.stderr)
72
- failed += 1
67
+ try:
68
+ with open(lua_path, "w") as f:
69
+ f.write(lua_output)
70
+ print(f" WROTE: {lua_path}")
71
+ except IOError as e:
72
+ print(f" ERROR writing {lua_path}: {e}", file=sys.stderr)
73
+ failed += 1
73
74
 
74
75
  return failed
75
76
 
@@ -518,7 +518,7 @@ class Codegen:
518
518
  params = rest
519
519
 
520
520
  if dsp_code is None:
521
- self.flag_count += 1
521
+ self._reclassify_as_flagged()
522
522
  self.emit(f'-- TODO: manual review (unknown dispatcher: {stmt.dispatcher})')
523
523
  pstr = ", ".join(self.quote(self.resolve_val(p)) for p in stmt.params)
524
524
  self.emit(f'-- hl.bind({combo_expr}, hl.dsp.{stmt.dispatcher}({pstr}))')
@@ -864,10 +864,13 @@ class Codegen:
864
864
  self.dedent()
865
865
  self.emit("},")
866
866
 
867
+ flagged = False
867
868
  for prop in props:
868
869
  if not self._emit_rule_effect(prop):
869
- self.flag_count += 1
870
+ flagged = True
870
871
  self.emit(f'-- TODO: review rule: {self.quote(prop)}')
872
+ if flagged:
873
+ self._reclassify_as_flagged()
871
874
 
872
875
  self.dedent()
873
876
  self.emit("})")
@@ -1138,6 +1141,12 @@ class Codegen:
1138
1141
  self.dedent()
1139
1142
  self.emit("})")
1140
1143
 
1144
+ def _reclassify_as_flagged(self):
1145
+ # The visitor counted this directive as translated on entry; a
1146
+ # directive is reported in exactly one bucket, so move it to flagged.
1147
+ self.translated_count -= 1
1148
+ self.flag_count += 1
1149
+
1141
1150
  def get_report(self) -> dict:
1142
1151
  return {
1143
1152
  "translated": self.translated_count,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyprconf2lua
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)
5
5
  Author: hyprconf2lua contributors
6
6
  License: MIT
@@ -875,3 +875,55 @@ def test_rgba_color_values():
875
875
  assert result.success
876
876
  assert '"rgba(0,0,0,0.85)"' in result.lua
877
877
  assert "shadow = { color =" in result.lua
878
+
879
+
880
+ def test_report_counts_flagged_windowrule_once():
881
+ result = convert(
882
+ "windowrule = float, class:foo\n"
883
+ "windowrule = bogus, class:foo\n"
884
+ "windowrule = bogus, other, class:bar\n"
885
+ )
886
+ assert result.success
887
+ assert result.report == {"translated": 1, "passthrough": 0, "flagged": 2}
888
+
889
+
890
+ def test_report_counts_unknown_dispatcher_bind_once():
891
+ result = convert("bind = SUPER, Q, notadispatcher, arg\n")
892
+ assert result.success
893
+ assert result.report == {"translated": 0, "passthrough": 0, "flagged": 1}
894
+
895
+
896
+ def test_directory_conversion_writes_missing_lua():
897
+ from hyprconf2lua.cli import process_dir
898
+ with tempfile.TemporaryDirectory() as tmpdir:
899
+ with open(os.path.join(tmpdir, "new.conf"), "w") as f:
900
+ f.write("bind = SUPER, Q, exec, kitty\n")
901
+ with open(os.path.join(tmpdir, "old.conf"), "w") as f:
902
+ f.write("bind = SUPER, Q, exec, kitty\n")
903
+ old_lua = os.path.join(tmpdir, "old.lua")
904
+ with open(old_lua, "w") as f:
905
+ f.write("-- hand-edited\n")
906
+
907
+ failed = process_dir(tmpdir)
908
+
909
+ assert failed == 0
910
+ with open(os.path.join(tmpdir, "new.lua")) as f:
911
+ assert "hl.bind" in f.read()
912
+ with open(old_lua) as f:
913
+ assert f.read() == "-- hand-edited\n"
914
+
915
+
916
+ def test_directory_conversion_in_place_overwrites_lua():
917
+ from hyprconf2lua.cli import process_dir
918
+ with tempfile.TemporaryDirectory() as tmpdir:
919
+ with open(os.path.join(tmpdir, "old.conf"), "w") as f:
920
+ f.write("bind = SUPER, Q, exec, kitty\n")
921
+ old_lua = os.path.join(tmpdir, "old.lua")
922
+ with open(old_lua, "w") as f:
923
+ f.write("-- hand-edited\n")
924
+
925
+ failed = process_dir(tmpdir, in_place=True)
926
+
927
+ assert failed == 0
928
+ with open(old_lua) as f:
929
+ assert "hl.bind" in f.read()
@@ -1 +0,0 @@
1
- __version__ = "1.8.1"
File without changes
File without changes
File without changes