Skip to content

Commit

Permalink
Removing select.select when reading stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
OleJoik committed Jun 12, 2024
1 parent d1efa4b commit 731c97e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions htpy/html2htpy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
import re
import argparse
import select
from dataclasses import dataclass
from typing import Self
from html.parser import HTMLParser
Expand Down Expand Up @@ -268,16 +267,22 @@ def main():

args = parser.parse_args()

if args.input == sys.stdin and select.select([sys.stdin], [], [], 0.1)[0]:
input = args.input.read()
elif args.input != sys.stdin:
input = args.input.read()
else:
try:
if args.input == sys.stdin:
input = args.input.read()
elif args.input != sys.stdin:
input = args.input.read()
else:
_printerr(
"No input provided. Please supply an input file or stream.",
)
_printerr("Example usage: `cat index.html | html2htpy`")
_printerr("`html2htpy -h` for help")
sys.exit(1)
except KeyboardInterrupt:
_printerr(
"No input provided. Please supply an input file or stream.",
"\nInterrupted",
)
_printerr("Example usage: `cat index.html | html2htpy`")
_printerr("`html2htpy -h` for help")
sys.exit(1)

shorthand: bool = args.shorthand
Expand Down

0 comments on commit 731c97e

Please sign in to comment.