Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix argparse handling of quoted filenames #2080

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions overviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def main():
parser.add_argument("--rendermodes", dest="rendermodes", action="store",
help="If you're not using a config file, specify which rendermodes to "
"render with this option. This is a comma-separated list.")
parser.add_argument("world", nargs='?',
parser.add_argument("world",
help="Path or name of the world you want to render.")
parser.add_argument("output", nargs='?',
parser.add_argument("output", nargs='+',
help="Output directory for the rendered map.")

# Useful one-time render modifiers:
Expand Down Expand Up @@ -150,8 +150,8 @@ def main():
if len(unknowns) > 0 and args.world and args.output:
possible_mistakes = []
for i in range(len(unknowns) + 1):
possible_mistakes.append(" ".join([args.world, args.output] + unknowns[:i]))
possible_mistakes.append(" ".join([args.output] + unknowns[:i]))
possible_mistakes.append(" ".join([args.world, " ".join(args.output)] + unknowns[:i]))
possible_mistakes.append(" ".join([" ".join(args.output)] + unknowns[:i]))
for mistake in possible_mistakes:
if os.path.exists(mistake):
logging.warning("Looks like you tried to make me use {0} as an argument, but "
Expand Down Expand Up @@ -298,7 +298,9 @@ def main():

if not args.config:
# No config file mode.
worldpath, destdir = map(os.path.expanduser, [args.world, args.output])
worldpath, destdir = map(os.path.expanduser, [args.world, " ".join(args.output)])
worldpath = worldpath.replace('"', '')
destdir = destdir.replace('"', '')
logging.debug("Using %r as the world directory", worldpath)
logging.debug("Using %r as the output directory", destdir)

Expand Down