hyprconf2lua 1.3.2__tar.gz → 1.5.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.
- {hyprconf2lua-1.3.2/src/hyprconf2lua.egg-info → hyprconf2lua-1.5.0}/PKG-INFO +3 -1
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/pyproject.toml +4 -1
- hyprconf2lua-1.5.0/src/hyprconf2lua/__init__.py +1 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/codegen.py +67 -44
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/mappings.py +0 -3
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/parser.py +17 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0/src/hyprconf2lua.egg-info}/PKG-INFO +3 -1
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua.egg-info/SOURCES.txt +1 -0
- hyprconf2lua-1.5.0/src/hyprconf2lua.egg-info/requires.txt +3 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/tests/test_converter.py +87 -63
- hyprconf2lua-1.3.2/src/hyprconf2lua/__init__.py +0 -1
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/LICENSE +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/README.md +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/setup.cfg +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/__main__.py +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/ast.py +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/cli.py +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/converter.py +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua/lexer.py +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua.egg-info/dependency_links.txt +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.0}/src/hyprconf2lua.egg-info/entry_points.txt +0 -0
- {hyprconf2lua-1.3.2 → hyprconf2lua-1.5.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
|
+
Version: 1.5.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.
|
|
7
|
+
version = "1.5.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.5.0"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
import os
|
|
2
3
|
import re
|
|
3
4
|
from typing import Dict, List, Optional
|
|
4
5
|
|
|
@@ -51,7 +52,7 @@ class Codegen:
|
|
|
51
52
|
|
|
52
53
|
def generate(self, config: ConfigFile) -> str:
|
|
53
54
|
self.lines = []
|
|
54
|
-
self.emit("-- Generated by hyprconf2lua v1.
|
|
55
|
+
self.emit("-- Generated by hyprconf2lua v1.4.0")
|
|
55
56
|
self.emit("-- https://github.com/Prateek-squadron/hyprconf2lua")
|
|
56
57
|
self.emit("-- Manual review may be needed for complex directives")
|
|
57
58
|
self.emit("")
|
|
@@ -118,6 +119,28 @@ class Codegen:
|
|
|
118
119
|
return "local_var_" + var_name
|
|
119
120
|
return re.sub(r'\$(\w+)', _repl, val)
|
|
120
121
|
|
|
122
|
+
def resolve_val_with_env(self, val: str) -> str:
|
|
123
|
+
def _repl(m: re.Match) -> str:
|
|
124
|
+
var_name = m.group(1)
|
|
125
|
+
if var_name in self.variables:
|
|
126
|
+
return self.variables[var_name]
|
|
127
|
+
if var_name in os.environ:
|
|
128
|
+
return f'os.getenv("{var_name}")'
|
|
129
|
+
return "local_var_" + var_name
|
|
130
|
+
return re.sub(r'\$(\w+)', _repl, val)
|
|
131
|
+
|
|
132
|
+
def _build_concat_expr(self, val: str) -> str:
|
|
133
|
+
parts = re.split(r'(os\.getenv\([^)]+\))', val)
|
|
134
|
+
expr_parts = []
|
|
135
|
+
for part in parts:
|
|
136
|
+
if part.startswith("os.getenv("):
|
|
137
|
+
expr_parts.append(part)
|
|
138
|
+
elif part:
|
|
139
|
+
expr_parts.append(self.quote(part))
|
|
140
|
+
if not expr_parts:
|
|
141
|
+
return '""'
|
|
142
|
+
return " .. ".join(expr_parts)
|
|
143
|
+
|
|
121
144
|
def needs_quotes(self, val: str) -> bool:
|
|
122
145
|
if not val:
|
|
123
146
|
return True
|
|
@@ -139,10 +162,16 @@ class Codegen:
|
|
|
139
162
|
return f'"{escaped}"'
|
|
140
163
|
return val
|
|
141
164
|
|
|
165
|
+
@staticmethod
|
|
166
|
+
def _normalize_key(key: str) -> str:
|
|
167
|
+
return key.replace("-", "_")
|
|
168
|
+
|
|
142
169
|
def to_lua_val(self, val: str):
|
|
143
|
-
val = self.
|
|
170
|
+
val = self.resolve_val_with_env(val)
|
|
144
171
|
if val.startswith("local_var_"):
|
|
145
172
|
return val[len("local_var_"):]
|
|
173
|
+
if "os.getenv(" in val:
|
|
174
|
+
return self._build_concat_expr(val)
|
|
146
175
|
if val.lower() in ("true", "on", "yes"):
|
|
147
176
|
return "true"
|
|
148
177
|
if val.lower() in ("false", "off", "no"):
|
|
@@ -160,7 +189,7 @@ class Codegen:
|
|
|
160
189
|
return self.quote(val)
|
|
161
190
|
|
|
162
191
|
def visit_variable(self, stmt: VariableDef):
|
|
163
|
-
val = self.
|
|
192
|
+
val = self.resolve_val_with_env(stmt.value)
|
|
164
193
|
self.variables[stmt.name] = val
|
|
165
194
|
self.translated_count += 1
|
|
166
195
|
if stmt.name.upper() == "MAINMOD" or stmt.name == "mainMod":
|
|
@@ -179,17 +208,21 @@ class Codegen:
|
|
|
179
208
|
self.main_mod_var = name
|
|
180
209
|
break
|
|
181
210
|
|
|
211
|
+
def _exec_lua_expr(self, cmd: str) -> str:
|
|
212
|
+
resolved = self.resolve_val_with_env(cmd)
|
|
213
|
+
if resolved.startswith("$") and resolved[1:] in self.variables:
|
|
214
|
+
return resolved[1:]
|
|
215
|
+
if "os.getenv(" in resolved:
|
|
216
|
+
return self._build_concat_expr(resolved)
|
|
217
|
+
return self.quote(resolved)
|
|
218
|
+
|
|
182
219
|
def emit_pending_execs(self):
|
|
183
220
|
if self.pending_exec_ones:
|
|
184
221
|
self.emit("-- Autostart")
|
|
185
222
|
self.emit('hl.on("hyprland.start", function()')
|
|
186
223
|
self.indent()
|
|
187
224
|
for cmd in self.pending_exec_ones:
|
|
188
|
-
|
|
189
|
-
if resolved.startswith("$") and resolved[1:] in self.variables:
|
|
190
|
-
self.emit(f"hl.exec_cmd({resolved[1:]})")
|
|
191
|
-
else:
|
|
192
|
-
self.emit(f"hl.exec_cmd({self.quote(resolved)})")
|
|
225
|
+
self.emit(f"hl.exec_cmd({self._exec_lua_expr(cmd)})")
|
|
193
226
|
self.dedent()
|
|
194
227
|
self.emit("end)")
|
|
195
228
|
self.emit("")
|
|
@@ -199,11 +232,7 @@ class Codegen:
|
|
|
199
232
|
self.emit('hl.on("config.reloaded", function()')
|
|
200
233
|
self.indent()
|
|
201
234
|
for cmd in self.pending_execs:
|
|
202
|
-
|
|
203
|
-
if resolved.startswith("$") and resolved[1:] in self.variables:
|
|
204
|
-
self.emit(f"hl.exec_cmd({resolved[1:]})")
|
|
205
|
-
else:
|
|
206
|
-
self.emit(f"hl.exec_cmd({self.quote(resolved)})")
|
|
235
|
+
self.emit(f"hl.exec_cmd({self._exec_lua_expr(cmd)})")
|
|
207
236
|
self.dedent()
|
|
208
237
|
self.emit("end)")
|
|
209
238
|
self.emit("")
|
|
@@ -213,11 +242,7 @@ class Codegen:
|
|
|
213
242
|
self.emit('hl.on("hyprland.shutdown", function()')
|
|
214
243
|
self.indent()
|
|
215
244
|
for cmd in self.pending_exec_shutdowns:
|
|
216
|
-
|
|
217
|
-
if resolved.startswith("$") and resolved[1:] in self.variables:
|
|
218
|
-
self.emit(f"hl.exec_cmd({resolved[1:]})")
|
|
219
|
-
else:
|
|
220
|
-
self.emit(f"hl.exec_cmd({self.quote(resolved)})")
|
|
245
|
+
self.emit(f"hl.exec_cmd({self._exec_lua_expr(cmd)})")
|
|
221
246
|
self.dedent()
|
|
222
247
|
self.emit("end)")
|
|
223
248
|
self.emit("")
|
|
@@ -242,6 +267,7 @@ class Codegen:
|
|
|
242
267
|
return f"{{ colors = {{ {', '.join(colors)} }}, angle = {angle} }}"
|
|
243
268
|
|
|
244
269
|
def _emit_directive(self, key: str, values: List[str]):
|
|
270
|
+
key = self._normalize_key(key)
|
|
245
271
|
if len(values) == 1 and self._is_gradient(values[0]):
|
|
246
272
|
self.translated_count += 1
|
|
247
273
|
self.emit(f"{key} = {self._format_gradient(values[0])},")
|
|
@@ -295,7 +321,7 @@ class Codegen:
|
|
|
295
321
|
self.emit(f"-- Nested subsection {sd.name}:")
|
|
296
322
|
for ssd in sd.body:
|
|
297
323
|
if isinstance(ssd, Directive):
|
|
298
|
-
k = ssd.key
|
|
324
|
+
k = self._normalize_key(ssd.key)
|
|
299
325
|
vv = self.to_lua_val(ssd.value[0]) if ssd.value else "true"
|
|
300
326
|
self.emit(f"{k} = {vv},")
|
|
301
327
|
self.dedent()
|
|
@@ -314,7 +340,7 @@ class Codegen:
|
|
|
314
340
|
self.emit(f"{name} = {{")
|
|
315
341
|
self.indent()
|
|
316
342
|
for d in directives:
|
|
317
|
-
key = d.key
|
|
343
|
+
key = self._normalize_key(d.key)
|
|
318
344
|
if len(d.value) == 1:
|
|
319
345
|
val = self.to_lua_val(d.value[0])
|
|
320
346
|
self.emit(f"{key} = {val},")
|
|
@@ -550,6 +576,16 @@ class Codegen:
|
|
|
550
576
|
return f'{func}({{ forward = false }})'
|
|
551
577
|
return f'{func}({{ forward = true }})'
|
|
552
578
|
|
|
579
|
+
if dispatcher == "moveintogroup":
|
|
580
|
+
if params:
|
|
581
|
+
dir_map = {"l": "left", "r": "right", "u": "up", "d": "down"}
|
|
582
|
+
d = dir_map.get(params[0], params[0])
|
|
583
|
+
return f'{func}({{ into_group = "{d}" }})'
|
|
584
|
+
return None
|
|
585
|
+
|
|
586
|
+
if dispatcher == "moveoutofgroup":
|
|
587
|
+
return f'{func}({{ out_of_group = true }})'
|
|
588
|
+
|
|
553
589
|
if dispatcher == "workspace":
|
|
554
590
|
return self.build_workspace_dispatcher(func, params)
|
|
555
591
|
|
|
@@ -565,14 +601,11 @@ class Codegen:
|
|
|
565
601
|
if dispatcher == "focusonemonitor":
|
|
566
602
|
return f'{func}({{ on_monitor = true }})'
|
|
567
603
|
|
|
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
604
|
if dispatcher in ("exec", "execr"):
|
|
575
|
-
|
|
605
|
+
raw = params[0] if params else ""
|
|
606
|
+
resolved = self.resolve_val_with_env(raw)
|
|
607
|
+
if "os.getenv(" in resolved:
|
|
608
|
+
return f'{func}({self._build_concat_expr(resolved)})'
|
|
576
609
|
return f'{func}({self.quote(resolved)})'
|
|
577
610
|
|
|
578
611
|
args = self.build_dispatcher_args(params, needs_args, func)
|
|
@@ -584,16 +617,6 @@ class Codegen:
|
|
|
584
617
|
return f'hl.dsp.window.{mouse_actions[params[0]]}()'
|
|
585
618
|
return None
|
|
586
619
|
|
|
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
620
|
return None
|
|
598
621
|
|
|
599
622
|
def build_workspace_dispatcher(self, func: str, params: List[str]) -> str:
|
|
@@ -737,11 +760,12 @@ class Codegen:
|
|
|
737
760
|
self.emit("match = {")
|
|
738
761
|
self.indent()
|
|
739
762
|
for k, v in stmt.match.items():
|
|
740
|
-
self.emit(f"{k} = {self.quote(v)},")
|
|
763
|
+
self.emit(f"{self._normalize_key(k)} = {self.quote(v)},")
|
|
741
764
|
self.dedent()
|
|
742
765
|
self.emit("},")
|
|
743
766
|
|
|
744
767
|
for key, vals in stmt.effects.items():
|
|
768
|
+
key = self._normalize_key(key)
|
|
745
769
|
if len(vals) == 1:
|
|
746
770
|
parts = vals[0].split()
|
|
747
771
|
if len(parts) == 1:
|
|
@@ -815,10 +839,9 @@ class Codegen:
|
|
|
815
839
|
def visit_env(self, stmt: EnvDirective):
|
|
816
840
|
self.translated_count += 1
|
|
817
841
|
resolved_name = self.resolve_val(stmt.name)
|
|
818
|
-
resolved_val = self.resolve_val(stmt.value)
|
|
819
842
|
name_q = self.quote(resolved_name)
|
|
820
|
-
|
|
821
|
-
self.emit(f"hl.env({name_q}, {
|
|
843
|
+
val_expr = self.to_lua_val(stmt.value)
|
|
844
|
+
self.emit(f"hl.env({name_q}, {val_expr})")
|
|
822
845
|
|
|
823
846
|
def visit_source(self, stmt: SourceDirective):
|
|
824
847
|
self.passthrough_count += 1
|
|
@@ -835,7 +858,6 @@ class Codegen:
|
|
|
835
858
|
return
|
|
836
859
|
|
|
837
860
|
self.emit(f'-- source = {path} -> requires manual conversion')
|
|
838
|
-
home_relative = path.replace("~", "").replace(os_path := "", ".hypr/")
|
|
839
861
|
|
|
840
862
|
import os as _os
|
|
841
863
|
just_name = _os.path.splitext(_os.path.basename(path))[0]
|
|
@@ -849,7 +871,7 @@ class Codegen:
|
|
|
849
871
|
self.emit(f'name = {self.quote(stmt.name)},')
|
|
850
872
|
for d in stmt.body:
|
|
851
873
|
if isinstance(d, Directive):
|
|
852
|
-
key = d.key
|
|
874
|
+
key = self._normalize_key(d.key)
|
|
853
875
|
val = self.to_lua_val(d.value[0]) if d.value else "true"
|
|
854
876
|
self.emit(f"{key} = {val},")
|
|
855
877
|
self.dedent()
|
|
@@ -944,11 +966,12 @@ class Codegen:
|
|
|
944
966
|
self.emit("match = {")
|
|
945
967
|
self.indent()
|
|
946
968
|
for k, v in stmt.match.items():
|
|
947
|
-
self.emit(f"{k} = {self.quote(v)},")
|
|
969
|
+
self.emit(f"{self._normalize_key(k)} = {self.quote(v)},")
|
|
948
970
|
self.dedent()
|
|
949
971
|
self.emit("},")
|
|
950
972
|
|
|
951
973
|
for key, vals in stmt.effects.items():
|
|
974
|
+
key = self._normalize_key(key)
|
|
952
975
|
if len(vals) == 1:
|
|
953
976
|
parts = vals[0].split()
|
|
954
977
|
if len(parts) == 1:
|
|
@@ -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
|
+
Version: 1.5.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
|
|
@@ -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
|
|
95
|
+
tokenize("key = value !bad")
|
|
99
96
|
|
|
100
97
|
|
|
101
98
|
def test_parse_variable():
|
|
@@ -599,61 +596,88 @@ def test_movetoworkspacesilent_conversion():
|
|
|
599
596
|
assert "workspace = 1" in result.lua
|
|
600
597
|
|
|
601
598
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def test_env_var_resolution():
|
|
666
|
+
result = convert('env = AQ_DRM_DEVICES,$HOME/.config/hypr/cards/intelcard:$HOME/.config/hypr/cards/nvidiacard\n')
|
|
667
|
+
assert result.success
|
|
668
|
+
assert 'os.getenv("HOME")' in result.lua
|
|
669
|
+
assert "local_var_HOME" not in result.lua
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def test_hyphen_to_underscore_in_device():
|
|
673
|
+
result = convert('device {\n name = touchpad\n tap-to-click = true\n}\n')
|
|
674
|
+
assert result.success
|
|
675
|
+
assert "tap_to_click" in result.lua
|
|
676
|
+
assert "tap-to-click" not in result.lua
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
def test_hyphen_to_underscore_in_general():
|
|
680
|
+
result = convert('general {\n no-cursor = true\n}\n')
|
|
681
|
+
assert result.success
|
|
682
|
+
assert "no_cursor" in result.lua
|
|
683
|
+
assert "no-cursor" not in result.lua
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.3.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|