예제 #1
0
 def parse(self, manager: "CommandManager", t: type, s: str) -> flow.Flow:
     try:
         flows = manager.execute("view.flows.resolve %s" % (s))
     except exceptions.CommandError as e:
         raise exceptions.TypeError(str(e)) from e
     if len(flows) != 1:
         raise exceptions.TypeError(
             "Command requires one flow, specification matched %s." %
             len(flows))
     return flows[0]
예제 #2
0
 def parse(self, manager: "CommandManager", t: type, s: str) -> bool:
     if s == "true":
         return True
     elif s == "false":
         return False
     else:
         raise exceptions.TypeError(
             "Booleans are 'true' or 'false', got %s" % s)
예제 #3
0
 def parse(self, manager: "CommandManager", t: Choice, s: str) -> str:
     opts = manager.execute(t.options_command)
     if s not in opts:
         raise exceptions.TypeError("Invalid choice.")
     return s
예제 #4
0
 def parse(self, manager: "CommandManager", t: type,
           s: str) -> typing.Any:  # pragma: no cover
     raise exceptions.TypeError("data cannot be passed as argument")
예제 #5
0
 def completion(self, manager: "CommandManager", t: type,
                s: str) -> typing.Sequence[str]:  # pragma: no cover
     raise exceptions.TypeError("data cannot be passed as argument")
예제 #6
0
 def parse(self, manager: "CommandManager", t: type,
           s: str) -> typing.Sequence[flow.Flow]:
     try:
         return manager.execute("view.flows.resolve %s" % (s))
     except exceptions.CommandError as e:
         raise exceptions.TypeError(str(e)) from e
예제 #7
0
 def parse(self, manager: "CommandManager", t: type, s: str) -> str:
     if s not in manager.commands:
         raise exceptions.TypeError("Unknown command: %s" % s)
     return s
예제 #8
0
 def parse(self, manager: "CommandManager", t: type, s: str) -> int:
     try:
         return int(s)
     except ValueError as e:
         raise exceptions.TypeError(str(e)) from e