Пример #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