“`python def _try_get_inputs(self) -> Tuple[bool, list[str], Optional[IO[bytes]]]: ”’returns (is_ok, args_input, stream or stdin input) or defaults”’ assert self._input ERR_RET: Tuple[bool, list[str], Optional[IO[bytes]]] = (False, [], None)
cinput: InputTool = self._input if cinput.support_stdin: if cinput.is_stream: stream: Optional[IO[bytes]] = cinput.consume_as_stream() if stream is None: return ERR_RET else: return (True, [], stream) else: args: Optional[list[str]] = cinput.consume_as_args() if args is None: return ERR_RET else: return (True, args, None) else: args: Optional[list[str]] = cinput.consume_as_args() if args is None: return ERR_RET else: return (True, args, None)
“`
I say it mainly for all the nested if and else statement, the logic is pretty simple in fact. If you bother to fix it, how would you do it?
For context
InputTool saved internally a file or a list of args that is to spawn a process for example gzip.
that is to generate a cmd like gzip some_file
or pass as stdin Popen(args, stdin=stream)
but the class InputTool when consume_[anything] try to convert to bring that correct value for example, if initially was passed a list of str and consume_as_stream()
is called it will read those files to pass a stream viceversa if a stream was passed instead and consume_as_args()
was called it will to create temporary files to disk and pass those names as a list[str]
This explanation I guess is no necessary but anyways
Sorry for the english!
submitted by /u/J_Aguasviva
[link] [comments]
r/learnpython “`python def _try_get_inputs(self) -> Tuple[bool, list[str], Optional[IO[bytes]]]: ”’returns (is_ok, args_input, stream or stdin input) or defaults”’ assert self._input ERR_RET: Tuple[bool, list[str], Optional[IO[bytes]]] = (False, [], None) cinput: InputTool = self._input if cinput.support_stdin: if cinput.is_stream: stream: Optional[IO[bytes]] = cinput.consume_as_stream() if stream is None: return ERR_RET else: return (True, [], stream) else: args: Optional[list[str]] = cinput.consume_as_args() if args is None: return ERR_RET else: return (True, args, None) else: args: Optional[list[str]] = cinput.consume_as_args() if args is None: return ERR_RET else: return (True, args, None) “` I say it mainly for all the nested if and else statement, the logic is pretty simple in fact. If you bother to fix it, how would you do it? For context InputTool saved internally a file or a list of args that is to spawn a process for example gzip. that is to generate a cmd like gzip some_file or pass as stdin Popen(args, stdin=stream) but the class InputTool when consume_[anything] try to convert to bring that correct value for example, if initially was passed a list of str and consume_as_stream() is called it will read those files to pass a stream viceversa if a stream was passed instead and consume_as_args() was called it will to create temporary files to disk and pass those names as a list[str] This explanation I guess is no necessary but anyways Sorry for the english! submitted by /u/J_Aguasviva [link] [comments]
“`python def _try_get_inputs(self) -> Tuple[bool, list[str], Optional[IO[bytes]]]: ”’returns (is_ok, args_input, stream or stdin input) or defaults”’ assert self._input ERR_RET: Tuple[bool, list[str], Optional[IO[bytes]]] = (False, [], None)
cinput: InputTool = self._input if cinput.support_stdin: if cinput.is_stream: stream: Optional[IO[bytes]] = cinput.consume_as_stream() if stream is None: return ERR_RET else: return (True, [], stream) else: args: Optional[list[str]] = cinput.consume_as_args() if args is None: return ERR_RET else: return (True, args, None) else: args: Optional[list[str]] = cinput.consume_as_args() if args is None: return ERR_RET else: return (True, args, None)
“`
I say it mainly for all the nested if and else statement, the logic is pretty simple in fact. If you bother to fix it, how would you do it?
For context
InputTool saved internally a file or a list of args that is to spawn a process for example gzip.
that is to generate a cmd like gzip some_file
or pass as stdin Popen(args, stdin=stream)
but the class InputTool when consume_[anything] try to convert to bring that correct value for example, if initially was passed a list of str and consume_as_stream()
is called it will read those files to pass a stream viceversa if a stream was passed instead and consume_as_args()
was called it will to create temporary files to disk and pass those names as a list[str]
This explanation I guess is no necessary but anyways
Sorry for the english!
submitted by /u/J_Aguasviva
[link] [comments]