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:
parent
71caf69975
commit
8efffbe86f
1 changed files with 12 additions and 1 deletions
|
@ -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 = ["."]
|
||||
|
|
Loading…
Add table
Reference in a new issue