check that there are actually arguments before running Windows block on arguments

I realized that there was no need to glob Windows arguments if there were no arguments. This meant moving my previous code block above the "if not arguments" statement, which actually creates an argument. And it meant moving Elvish Hunter's code, since the double quote issue will stop my block from working. Once this decision was made, it made sense to put both code blocks under the same "if" conditions, and to check if there were actually any wildcards during EH's block, before running the arguments through glob.
This commit is contained in:
Groggy Dice 2013-07-10 00:31:17 -04:00
parent 7bee47a956
commit 79b8a85a5e

View file

@ -2142,24 +2142,27 @@ if __name__ == '__main__':
else:
maptransforms = [maptransform1, maptransform2]
# In certain situations, Windows' command prompt appends a double quote
# to the command line parameters. The first block takes care of this issue.
# Also, Windows does not expand wildcards. The second turns on globbing.
if arguments and sys.platform == 'win32':
wildcard = False
for i,arg in enumerate(arguments):
if arg.endswith('"'):
arguments[i] = arg[:-1]
if '*' in arg:
wildcard = True
if wildcard:
from glob import glob
for arg in arguments:
wildarg = glob(arg)
arguments.remove(arg)
for newarg in wildarg:
arguments.append(newarg)
if not arguments:
arguments = ["."]
# in certain situations, Windows' command prompt appends a double quote
# to the command line parameters. This block takes care of this issue.
for i,arg in enumerate(arguments):
if arg.endswith('"'):
arguments[i] = arg[:-1]
# Also, Windows does not expand wildcards. This turns on globbing.
if sys.platform == 'win32':
from glob import glob
for arg in arguments:
wildarg = glob(arg)
arguments.remove(arg)
for newarg in wildarg:
arguments.append(newarg)
for dir in arguments:
ofp = None
if "older" in versions: