Split parsing of options and getting input/output
The latter rarely makes sense when Scour is not called from command line
This commit is contained in:
parent
c8eb29f54c
commit
4adacd6978
1 changed files with 11 additions and 4 deletions
|
|
@ -3290,6 +3290,11 @@ def parse_args(args=None, ignore_additional_args=False):
|
||||||
if options.infilename and options.outfilename and options.infilename == options.outfilename:
|
if options.infilename and options.outfilename and options.infilename == options.outfilename:
|
||||||
_options_parser.error("Input filename is the same as output filename")
|
_options_parser.error("Input filename is the same as output filename")
|
||||||
|
|
||||||
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def getInOut(options):
|
||||||
if options.infilename:
|
if options.infilename:
|
||||||
infile = maybe_gziped_file(options.infilename, "rb")
|
infile = maybe_gziped_file(options.infilename, "rb")
|
||||||
# GZ: could catch a raised IOError here and report
|
# GZ: could catch a raised IOError here and report
|
||||||
|
|
@ -3304,6 +3309,7 @@ def parse_args(args=None, ignore_additional_args=False):
|
||||||
# the user probably does not want to manually enter SVG code into the terminal...
|
# the user probably does not want to manually enter SVG code into the terminal...
|
||||||
if sys.stdin.isatty():
|
if sys.stdin.isatty():
|
||||||
_options_parser.error("No input file specified, see --help for detailed usage information")
|
_options_parser.error("No input file specified, see --help for detailed usage information")
|
||||||
|
|
||||||
if options.outfilename:
|
if options.outfilename:
|
||||||
outfile = maybe_gziped_file(options.outfilename, "wb")
|
outfile = maybe_gziped_file(options.outfilename, "wb")
|
||||||
else:
|
else:
|
||||||
|
|
@ -3313,7 +3319,7 @@ def parse_args(args=None, ignore_additional_args=False):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
outfile = sys.stdout
|
outfile = sys.stdout
|
||||||
|
|
||||||
return options, [infile, outfile]
|
return [infile, outfile]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3391,7 +3397,8 @@ def start(options, input, output):
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
options, (input, output) = parse_args()
|
options = parse_args()
|
||||||
|
(input, output) = getInOut(options)
|
||||||
start(options, input, output)
|
start(options, input, output)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue