|
1 | 1 | from __future__ import absolute_import
|
2 | 2 | import copy
|
3 | 3 | import hashlib
|
| 4 | +import locale |
4 | 5 | import json
|
5 | 6 | import logging
|
6 | 7 | import os
|
7 | 8 | import re
|
8 | 9 | import shutil
|
9 | 10 | import tempfile
|
10 |
| -from functools import partial |
11 |
| -from typing import Any, Callable, Dict, Generator, List, Optional, Set, Text, Union, cast |
| 11 | +from functools import partial, cmp_to_key |
| 12 | +from typing import (Any, Callable, Dict, Generator, List, Optional, Set, Text, |
| 13 | + Union, cast) |
12 | 14 |
|
13 | 15 | from six import string_types, u
|
14 | 16 |
|
@@ -208,7 +210,7 @@ def makeJobRunner(self, use_container=True, **kwargs): # type: (Optional[bool],
|
208 | 210 | })
|
209 | 211 | dockerReq = self.requirements[0]
|
210 | 212 | if default_container == windows_default_container_id and use_container and onWindows():
|
211 |
| - _logger.warning(DEFAULT_CONTAINER_MSG%(windows_default_container_id, windows_default_container_id)) |
| 213 | + _logger.warning(DEFAULT_CONTAINER_MSG % (windows_default_container_id, windows_default_container_id)) |
212 | 214 |
|
213 | 215 | if dockerReq and use_container:
|
214 | 216 | return DockerCommandLineJob()
|
@@ -523,8 +525,8 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo
|
523 | 525 | for i, port in enumerate(ports):
|
524 | 526 | def makeWorkflowException(msg):
|
525 | 527 | return WorkflowException(
|
526 |
| - u"Error collecting output for parameter '%s':\n%s" |
527 |
| - % (shortname(port["id"]), msg)) |
| 528 | + u"Error collecting output for parameter '%s':\n%s" |
| 529 | + % (shortname(port["id"]), msg)) |
528 | 530 | with SourceLine(ports, i, makeWorkflowException, debug):
|
529 | 531 | fragment = shortname(port["id"])
|
530 | 532 | ret[fragment] = self.collect_output(port, builder, outdir, fs_access,
|
@@ -575,16 +577,25 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
|
575 | 577 | elif gb == ".":
|
576 | 578 | gb = outdir
|
577 | 579 | elif gb.startswith("/"):
|
578 |
| - raise WorkflowException("glob patterns must not start with '/'") |
| 580 | + raise WorkflowException( |
| 581 | + "glob patterns must not start with '/'") |
579 | 582 | try:
|
580 | 583 | prefix = fs_access.glob(outdir)
|
581 | 584 | r.extend([{"location": g,
|
582 |
| - "path": fs_access.join(builder.outdir, g[len(prefix[0])+1:]), |
| 585 | + "path": fs_access.join(builder.outdir, |
| 586 | + g[len(prefix[0])+1:]), |
583 | 587 | "basename": os.path.basename(g),
|
584 |
| - "nameroot": os.path.splitext(os.path.basename(g))[0], |
585 |
| - "nameext": os.path.splitext(os.path.basename(g))[1], |
586 |
| - "class": "File" if fs_access.isfile(g) else "Directory"} |
587 |
| - for g in fs_access.glob(fs_access.join(outdir, gb))]) |
| 588 | + "nameroot": os.path.splitext( |
| 589 | + os.path.basename(g))[0], |
| 590 | + "nameext": os.path.splitext( |
| 591 | + os.path.basename(g))[1], |
| 592 | + "class": "File" if fs_access.isfile(g) |
| 593 | + else "Directory"} |
| 594 | + for g in sorted(fs_access.glob( |
| 595 | + fs_access.join(outdir, gb)), |
| 596 | + key=cmp_to_key(cast( |
| 597 | + Callable[[Text, Text], |
| 598 | + int], locale.strcoll)))]) |
588 | 599 | except (OSError, IOError) as e:
|
589 | 600 | _logger.warning(Text(e))
|
590 | 601 | except:
|
|
0 commit comments