wmllint: activate wildcard globbing on Windows

The Windows cmd shell does not expand wildcards by default, unlike UNIX shells. This imports glob.glob and runs arguments through it on Windows.

Frontported (in modified form) from my 1.4 work!
This commit is contained in:
Groggy Dice 2013-07-22 20:59:36 -04:00
parent 71caf69975
commit 8efffbe86f

View file

@ -2405,15 +2405,26 @@ if __name__ == '__main__':
# escape to a literal quote rather than a Windows directory delimiter,
# causing Windows to find "no such file or directory". This block deals
# with this issue, but it is impossible to handle all cases if multiple
# (intended) arguments are involved.
# (intended) arguments are involved. We also activate globbing on
# Windows, if there is a wildcard.
if arguments and sys.platform == 'win32':
wildcard = False
newargs = []
for i,arg in enumerate(arguments):
if not wildcard and '*' in arg:
wildcard = True
from glob import glob
if '"' in arg:
arguments.remove(arg)
arg = re.sub(r'([^ ])"([^ ])', r'\1\\\2', arg)
for new in arg.rstrip('"').split('"'):
arguments.insert(i, new.strip())
i += 1
if wildcard:
for arg in arguments:
for wild in glob(arg):
newargs.append(wild)
arguments = newargs
if not arguments:
arguments = ["."]