From 823667cbc792a4f1a82c9a7873318dfc2a8906ac Mon Sep 17 00:00:00 2001 From: Galen Wright-Watson Date: Sun, 10 Nov 2024 14:31:49 -0800 Subject: [PATCH] update main loops so command line utilities can be debugged from the command line --- pdftocgen/app.py | 4 +++- pdftocio/app.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pdftocgen/app.py b/pdftocgen/app.py index 2859d7b..68998b4 100644 --- a/pdftocgen/app.py +++ b/pdftocgen/app.py @@ -90,7 +90,7 @@ def main(): print(usage_s, file=sys.stderr) sys.exit(2) - recipe_file: TextIO = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore') + recipe_file: TextIO = None readable: bool = False vpos: bool = False out: TextIO = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='ignore') @@ -129,6 +129,8 @@ def main(): print(usage_s, file=sys.stderr) sys.exit(1) + if not toc_file: + toc_file = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore') path_in: str = args[0] # done parsing arguments diff --git a/pdftocio/app.py b/pdftocio/app.py index 484b44f..6fcc22f 100644 --- a/pdftocio/app.py +++ b/pdftocio/app.py @@ -94,7 +94,7 @@ def main(): print(usage_s, file=sys.stderr) sys.exit(2) - toc_file: TextIO = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore') + toc_file: TextIO = None print_toc: bool = False readable: bool = False out: Optional[str] = None @@ -131,6 +131,8 @@ def main(): print(usage_s, file=sys.stderr) sys.exit(1) + if not toc_file: + toc_file = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore') path_in: str = args[0] # done parsing arguments