more args cleanup
This commit is contained in:
parent
155ce6fc1f
commit
49d384bfd8
@ -39,8 +39,6 @@ parser = argparse.ArgumentParser(
|
||||
description='get a url from google ee api based on supplied region',
|
||||
epilog='Good luck')
|
||||
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--logging",
|
||||
@ -72,8 +70,6 @@ parser.add_argument(
|
||||
"--region",
|
||||
dest='region',
|
||||
metavar='region',
|
||||
dest='region',
|
||||
metavar='region',
|
||||
default='None',
|
||||
action='store',
|
||||
help="subregion to get, default is to get entire country")
|
||||
@ -100,44 +96,3 @@ if args.logging or args.verbose:
|
||||
if args.verbose:
|
||||
logging.debug('logging to stderr requested')
|
||||
|
||||
if args.dump:
|
||||
print(open(sys.argv[0]).read())
|
||||
exit(0)
|
||||
|
||||
if args.filename:
|
||||
with open(args.filename, "w") as fd:
|
||||
fd.write(open(sys.argv[0]).read())
|
||||
mode = os.fstat(fd.fileno()).st_mode
|
||||
mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||
os.fchmod(fd.fileno(), stat.S_IMODE(mode))
|
||||
exit(0)
|
||||
|
||||
if args.binary:
|
||||
args.utf8 = False
|
||||
input_file = sys.stdin.buffer
|
||||
if args.input_file != 'stdin':
|
||||
input_file = open(args.input_file, "rb")
|
||||
|
||||
output_file = sys.stdout.buffer
|
||||
if args.output_file != 'stdout':
|
||||
output_file = open(args.output_file, "wb")
|
||||
|
||||
output_file.write(input_file.read())
|
||||
exit(0)
|
||||
|
||||
if args.utf8:
|
||||
input_file = sys.stdin
|
||||
if args.input_file != 'stdin':
|
||||
input_file = open(args.input_file, "r")
|
||||
|
||||
output_file = sys.stdout
|
||||
if args.output_file != 'stdout':
|
||||
output_file = open(args.output_file, "w")
|
||||
|
||||
try:
|
||||
output_file.write(input_file.read())
|
||||
except UnicodeDecodeError as e:
|
||||
print("Error: input data is not Unicode.\nTry again with the -b option to force binary mode",
|
||||
file=sys.stderr)
|
||||
exit(1)
|
||||
exit(0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user