1
0
Fork 0

Fix syntax and imports

master
LEdoian 5 years ago
parent e1c15d3664
commit ed3cf574a8

@ -3,6 +3,8 @@
import pandoc import pandoc
import pandoc.types as t import pandoc.types as t
import sys import sys
from dataclasses import dataclass
from typing import *
# There are three parts: # There are three parts:
# - Parse a given markdown and extract the commands # - Parse a given markdown and extract the commands
@ -28,7 +30,7 @@ def main():
@dataclass @dataclass
class Command: class Command:
user: str user: str
directory: Any[str, None] directory: Union[str, None]
command: str command: str
context: str context: str
@ -139,7 +141,7 @@ def user_action(hunk: Sequence[Command], context=None) -> Sequence[Command]:
new_hunk = [] new_hunk = []
for line in tmpfile.file.readlines(): for line in tmpfile.file.readlines():
parts = line.split('\t', maxsplit=3) parts = line.split('\t', maxsplit=3)
new_hunk.append(Command(user=parts[0],directory=parts[1],command=parts[2],context=None) new_hunk.append(Command(user=parts[0],directory=parts[1],command=parts[2],context=None))
# Python has no goto for restarting, but we can recurse # Python has no goto for restarting, but we can recurse
return user_action(new_hunk, context) return user_action(new_hunk, context)
elif answer.startswith(('y', 'Y')): elif answer.startswith(('y', 'Y')):
@ -174,7 +176,7 @@ def process_file(fn: str):
""" """
To be called upon each file on the command line. This function should perform all the steps needed in order to remotely run a parsed markdown, id est the three parts above. To be called upon each file on the command line. This function should perform all the steps needed in order to remotely run a parsed markdown, id est the three parts above.
""" """
pd = pandoc.read(open(fn)) pd = pandoc.read(file=fn)
snippets = extract_snippets(pd) snippets = extract_snippets(pd)
for snip in snippets: for snip in snippets:
cmds = parse_snippet(snip) cmds = parse_snippet(snip)

Loading…
Cancel
Save