File size: 943 Bytes
a4ba047
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""List the files of one QSIPrep run that the M0 package needs, relative to the run dir.

Usage: python -I file_list.py RUN_DIR > list.txt
"""

import json
import sys
from pathlib import Path

run = Path(sys.argv[1]).resolve()
paths = set()


def walk(node):
    if isinstance(node, dict):
        for k, v in node.items():
            if k == "path" and isinstance(v, str):
                paths.add(Path(v))
            else:
                walk(v)
    elif isinstance(node, list):
        for v in node:
            walk(v)


walk(json.loads((run / "collected/manifest.json").read_text()))
for top in ("collected", "out"):
    paths.update(p for p in (run / top).rglob("*") if p.is_file())
for name in ("command.txt", "timing.txt", "qsiprep.log"):
    paths.add(run / name)
paths.update(run.glob("work/*/config.toml"))
for p in sorted(paths):
    p = p if p.is_absolute() else run / p
    if p.is_file():
        print(p.relative_to(run))