Ejemplo n.º 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]
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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