From 310743a49861a66fa6240ed4a262efe56722e32c Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Sun, 21 Nov 2021 14:07:17 -0300 Subject: [PATCH] Fix --stdout --- README.md | 3 +-- src/fsub/__init__.py | 2 +- src/fsub/fsub.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e19b7cf..8fdda06 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,7 @@ An example of calling the program from Python: ``` import fsub -# Pass the arguments here -fsub.run(['-c', 'test.srt']) +fsub.run('-c', 'test.srt') ``` # Features diff --git a/src/fsub/__init__.py b/src/fsub/__init__.py index a59b82e..a6d4679 100644 --- a/src/fsub/__init__.py +++ b/src/fsub/__init__.py @@ -2,5 +2,5 @@ import fsub.fsub as fsub # External interface -def run(args): +def run(*args): fsub.run(args) diff --git a/src/fsub/fsub.py b/src/fsub/fsub.py index c9c9b77..c1156cf 100755 --- a/src/fsub/fsub.py +++ b/src/fsub/fsub.py @@ -303,7 +303,7 @@ class SubripFile: self.subs = new_subs - self.write_file(args.replace) + self.write_file(in_place=args.replace, stdout=args.stdout) def write_file(self, in_place=False, stdout=False): self.renumber() @@ -456,16 +456,18 @@ def parse_args(args): # Flags that require section if args.cut_out: if not args.begin and not args.end: - panic('You must specify a section to work with', 64) + parser.print_usage(file=sys.stderr) + panic('fsub: error: You must specify a section to work with', 64) + + # Validate options + if not args.clean and args.config: + parser.print_usage(file=sys.stderr) + panic('fsub: error: --config requires --clean', 64) # Make sure --clean is the default if not any((args.shift, args.no_html, args.join, args.cut_out)): args.clean = True - # Validate options - if not args.clean and args.config: - panic('-f requires -c', 64) - if args.begin: args.begin = SectionMarker(args.begin)