mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
build: make macros.py py3.5 compatible
This commit is contained in:
parent
8897d8929b
commit
41aa893cd9
2 changed files with 9 additions and 11 deletions
|
@ -1,8 +1,6 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- node
|
- node
|
||||||
python:
|
|
||||||
- "3.6"
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
|
|
|
@ -50,9 +50,9 @@ class Signature:
|
||||||
elif default[0] == default[-1] and default[0] in ('"', "'"):
|
elif default[0] == default[-1] and default[0] in ('"', "'"):
|
||||||
typ = "string"
|
typ = "string"
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Edit me! Only number, string and boolean defaults supported at the mo!\n\t{raw}")
|
raise Exception("Edit me! Only number, string and boolean defaults supported at the mo!\n\t{raw}".format(**locals()))
|
||||||
else:
|
else:
|
||||||
raise Exception(f"All parameters must be typed!\n\t{raw}")
|
raise Exception("All parameters must be typed!\n\t{raw}".format(**locals()))
|
||||||
|
|
||||||
if name.endswith('?'): name = name[:-1]
|
if name.endswith('?'): name = name[:-1]
|
||||||
self.params[name] = typ
|
self.params[name] = typ
|
||||||
|
@ -86,14 +86,14 @@ def content(lines, context):
|
||||||
# Consume and replace this block.
|
# Consume and replace this block.
|
||||||
block = get_block(lines)
|
block = get_block(lines)
|
||||||
sig = Signature(block.split('\n')[0])
|
sig = Signature(block.split('\n')[0])
|
||||||
return f"""cmd_params.set('{sig.name}', {dict_to_js(sig.params)})
|
return "cmd_params.set('{sig.name}', ".format(**locals()) + dict_to_js(sig.params) + """)
|
||||||
{sig.raw}
|
{sig.raw}
|
||||||
message(
|
message(
|
||||||
"excmd_content",
|
"excmd_content",
|
||||||
"{sig.name}",
|
"{sig.name}",
|
||||||
{str(list(sig.params.keys())).replace("'","")},
|
""".format(**locals()) + str(list(sig.params.keys())).replace("'","") + """,
|
||||||
)
|
)
|
||||||
}}\n"""
|
}\n"""
|
||||||
else:
|
else:
|
||||||
# Do nothing
|
# Do nothing
|
||||||
return ""
|
return ""
|
||||||
|
@ -103,8 +103,8 @@ def background(lines, context):
|
||||||
"Extract params if context is background, else omit"
|
"Extract params if context is background, else omit"
|
||||||
if context == "background":
|
if context == "background":
|
||||||
sig = Signature(next(lines))
|
sig = Signature(next(lines))
|
||||||
return f"""cmd_params.set('{sig.name}', {dict_to_js(sig.params)})
|
return "cmd_params.set('{sig.name}', ".format(**locals()) + dict_to_js(sig.params) + """)
|
||||||
{sig.raw}"""
|
{sig.raw}""".format(**locals())
|
||||||
else:
|
else:
|
||||||
# Omit
|
# Omit
|
||||||
get_block(lines)
|
get_block(lines)
|
||||||
|
@ -158,11 +158,11 @@ def main():
|
||||||
if macrocmd in macros:
|
if macrocmd in macros:
|
||||||
output += macros[macrocmd](lines, context)
|
output += macros[macrocmd](lines, context)
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Unknown macrocmd! {macrocmd}")
|
raise Exception("Unknown macrocmd! {macrocmd}".format(**locals()))
|
||||||
else:
|
else:
|
||||||
output += line
|
output += line
|
||||||
# print(output.rstrip())
|
# print(output.rstrip())
|
||||||
with open(f"excmds_{context}.ts", "w") as sink:
|
with open("excmds_{context}.ts".format(**locals()), "w") as sink:
|
||||||
print(output.rstrip(), file=sink)
|
print(output.rstrip(), file=sink)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue