s+: remove stdin from Behaviour, lint and type fix
This commit is contained in:
parent
c3cb78ff25
commit
ba8ce97951
1 changed files with 5 additions and 8 deletions
|
@ -33,7 +33,7 @@ from argparse import ArgumentParser
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from sys import stderr, stdout, stdin
|
from sys import stderr, stdin, stdout
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Callable,
|
Callable,
|
||||||
|
@ -548,8 +548,6 @@ class Behaviour(NamedTuple):
|
||||||
TextIO-like object representing a writeable file. defaults to sys.stderr
|
TextIO-like object representing a writeable file. defaults to sys.stderr
|
||||||
stdout: TextIO = sys.stdout
|
stdout: TextIO = sys.stdout
|
||||||
TextIO-like object representing a writeable file. defaults to sys.stdout
|
TextIO-like object representing a writeable file. defaults to sys.stdout
|
||||||
stderr: TextIO = sys.stdin
|
|
||||||
TextIO-like object representing a readable file. defaults to sts.stdin
|
|
||||||
debug: bool = False
|
debug: bool = False
|
||||||
whether to print debug information to stderr
|
whether to print debug information to stderr
|
||||||
version_header: bool = False
|
version_header: bool = False
|
||||||
|
@ -563,7 +561,6 @@ class Behaviour(NamedTuple):
|
||||||
reverser: Callable[[Latlong], dict[str, Any]] = default_reverser
|
reverser: Callable[[Latlong], dict[str, Any]] = default_reverser
|
||||||
stderr: TextIO = stderr
|
stderr: TextIO = stderr
|
||||||
stdout: TextIO = stdout
|
stdout: TextIO = stdout
|
||||||
stdin: TextIO = stdin
|
|
||||||
debug: bool = False
|
debug: bool = False
|
||||||
version_header: bool = False
|
version_header: bool = False
|
||||||
convert_to_type: ConversionResultTypeEnum = ConversionResultTypeEnum.SHAREABLE_TEXT
|
convert_to_type: ConversionResultTypeEnum = ConversionResultTypeEnum.SHAREABLE_TEXT
|
||||||
|
@ -809,19 +806,19 @@ def handle_args() -> Behaviour:
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
query: str | list[str] = ""
|
query: str | list[str] = ""
|
||||||
|
|
||||||
if args.query == ["-"]:
|
if args.query == ["-"]:
|
||||||
stdin_query: list[str] = []
|
stdin_query: list[str] = []
|
||||||
|
|
||||||
for line in stdin:
|
for line in stdin:
|
||||||
stdin_query.append(line.strip())
|
stdin_query.append(line.strip())
|
||||||
|
|
||||||
query = "\n".join(stdin_query)
|
query = "\n".join(stdin_query)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
query: list[str] = args.query
|
query = args.query
|
||||||
|
|
||||||
behaviour = Behaviour(
|
behaviour = Behaviour(
|
||||||
query=query,
|
query=query,
|
||||||
|
|
Loading…
Add table
Reference in a new issue