raise
-def all_bugs(bz: Bugzilla) -> Iterator[Bug]:
- chunk_start = 1
- chunk_size = 100
+@contextmanager
+def tty_out():
try:
if hasattr(os, "ctermid"):
term = open(os.ctermid(), "wt", encoding="utf-8")
# no terminal available
term = None
try: # can't use `with` since it doesn't work with None
+ yield term
+ finally:
+ if term is not None:
+ term.close()
+
+
+def all_bugs(bz: Bugzilla) -> Iterator[Bug]:
+ chunk_start = 1
+ chunk_size = 100
+ with tty_out() as term:
while True:
bugs = list(range(chunk_start, chunk_start + chunk_size))
bugs = bz.getbugs(bugs)
if len(bugs) == 0:
return
yield from bugs
- finally:
- if term is not None:
- term.close()
class SequencePrettyPrinter: