Skip to content

sort globs according to POSIX #587

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

Merged
merged 4 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mypy2: ${PYSOURCES}
rm -Rf typeshed/2and3/schema_salad
ln -s $(shell python -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
typeshed/2and3/schema_salad
MYPYPATH=$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
MYPYPATH=$$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
--warn-redundant-casts \
cwltool

Expand All @@ -171,7 +171,7 @@ mypy3: ${PYSOURCES}
rm -Rf typeshed/2and3/schema_salad
ln -s $(shell python3 -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
typeshed/2and3/schema_salad
MYPYPATH=$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
MYPYPATH=$$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
--warn-redundant-casts \
cwltool

Expand Down
33 changes: 22 additions & 11 deletions cwltool/draft2tool.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from __future__ import absolute_import
import copy
import hashlib
import locale
import json
import logging
import os
import re
import shutil
import tempfile
from functools import partial
from typing import Any, Callable, Dict, Generator, List, Optional, Set, Text, Union, cast
from functools import partial, cmp_to_key
from typing import (Any, Callable, Dict, Generator, List, Optional, Set, Text,
Union, cast)

from six import string_types, u

Expand Down Expand Up @@ -208,7 +210,7 @@ def makeJobRunner(self, use_container=True, **kwargs): # type: (Optional[bool],
})
dockerReq = self.requirements[0]
if default_container == windows_default_container_id and use_container and onWindows():
_logger.warning(DEFAULT_CONTAINER_MSG%(windows_default_container_id, windows_default_container_id))
_logger.warning(DEFAULT_CONTAINER_MSG % (windows_default_container_id, windows_default_container_id))

if dockerReq and use_container:
return DockerCommandLineJob()
Expand Down Expand Up @@ -523,8 +525,8 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo
for i, port in enumerate(ports):
def makeWorkflowException(msg):
return WorkflowException(
u"Error collecting output for parameter '%s':\n%s"
% (shortname(port["id"]), msg))
u"Error collecting output for parameter '%s':\n%s"
% (shortname(port["id"]), msg))
with SourceLine(ports, i, makeWorkflowException, debug):
fragment = shortname(port["id"])
ret[fragment] = self.collect_output(port, builder, outdir, fs_access,
Expand Down Expand Up @@ -575,16 +577,25 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
elif gb == ".":
gb = outdir
elif gb.startswith("/"):
raise WorkflowException("glob patterns must not start with '/'")
raise WorkflowException(
"glob patterns must not start with '/'")
try:
prefix = fs_access.glob(outdir)
r.extend([{"location": g,
"path": fs_access.join(builder.outdir, g[len(prefix[0])+1:]),
"path": fs_access.join(builder.outdir,
g[len(prefix[0])+1:]),
"basename": os.path.basename(g),
"nameroot": os.path.splitext(os.path.basename(g))[0],
"nameext": os.path.splitext(os.path.basename(g))[1],
"class": "File" if fs_access.isfile(g) else "Directory"}
for g in fs_access.glob(fs_access.join(outdir, gb))])
"nameroot": os.path.splitext(
os.path.basename(g))[0],
"nameext": os.path.splitext(
os.path.basename(g))[1],
"class": "File" if fs_access.isfile(g)
else "Directory"}
for g in sorted(fs_access.glob(
fs_access.join(outdir, gb)),
key=cmp_to_key(cast(
Callable[[Text, Text],
int], locale.strcoll)))])
except (OSError, IOError) as e:
_logger.warning(Text(e))
except:
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[mypy]

[mypy-ruamel.*]
ignore_errors = True
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ whitelist_externals =
commands = make mypy2
whitelist_externals = make
deps =
mypy==0.520
mypy==0.560
-rrequirements.txt

[testenv:py35-mypy3]
commands = make mypy3
whitelist_externals = make
deps =
mypy==0.520
mypy==0.560
-rrequirements.txt

[testenv:py27-pipconflictchecker]
Expand Down