bids-validator-deno 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bids_validator_deno/__init__.py +54 -0
- bids_validator_deno/bids-validator.js +282168 -0
- bids_validator_deno/bids-validator.js.map +7 -0
- bids_validator_deno-3.0.0.dist-info/METADATA +120 -0
- bids_validator_deno-3.0.0.dist-info/RECORD +8 -0
- bids_validator_deno-3.0.0.dist-info/WHEEL +4 -0
- bids_validator_deno-3.0.0.dist-info/entry_points.txt +5 -0
- bids_validator_deno-3.0.0.dist-info/licenses/LICENSE +20 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# This module was generated at build time by pdm_build.py.
|
|
2
|
+
#
|
|
3
|
+
# This module was adapted from git-annex-wheel/src/git_annex/__init__.py @ commit 9a059be:
|
|
4
|
+
#
|
|
5
|
+
# https://github.com/psychoinformatics-de/git-annex-wheel/blob/9a059be12db8b90cb1ecf71e498d3a2135366b6f/src/git_annex/__init__.py
|
|
6
|
+
# https://hub.datalad.org/git-annex/git-annex-wheel/src/commit/9a059be12db8b90cb1ecf71e498d3a2135366b6f/src/git_annex/__init__.py
|
|
7
|
+
#
|
|
8
|
+
# By agreement of the authors of that module, releasing this derivative work under MIT is
|
|
9
|
+
# authorized. See https://github.com/bids-standard/bids-validator/pull/425.
|
|
10
|
+
#
|
|
11
|
+
# Changes:
|
|
12
|
+
# * Adapted cli() to find Deno bundled in a separate package and exec the local bundle.
|
|
13
|
+
#
|
|
14
|
+
"""Find the deno runtime and exec the bundled BIDS validator."""
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
|
|
18
|
+
def cli():
|
|
19
|
+
from deno import find_deno_bin
|
|
20
|
+
|
|
21
|
+
deno = os.fsdecode(find_deno_bin())
|
|
22
|
+
windows = sys.platform.startswith('win')
|
|
23
|
+
bundle = os.path.join(os.path.dirname(__file__), 'bids-validator.js')
|
|
24
|
+
|
|
25
|
+
permissions = ['--allow-read', '--allow-env', '--allow-net', '--allow-write', '--allow-run=git']
|
|
26
|
+
if windows:
|
|
27
|
+
permissions.extend(['--allow-sys=osRelease'])
|
|
28
|
+
|
|
29
|
+
argv = [deno, *permissions, bundle, *sys.argv[1:]]
|
|
30
|
+
|
|
31
|
+
if windows:
|
|
32
|
+
exec_subproc(deno, argv)
|
|
33
|
+
else:
|
|
34
|
+
os.execv(deno, argv)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def exec_subproc(executable, argv):
|
|
38
|
+
import subprocess
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
subprocess.run(
|
|
42
|
+
argv,
|
|
43
|
+
executable=executable,
|
|
44
|
+
shell=False,
|
|
45
|
+
check=True,
|
|
46
|
+
)
|
|
47
|
+
# try flush here to trigger a BrokenPipeError within the try-except block
|
|
48
|
+
# (happens if the calling process closed stdout already)
|
|
49
|
+
sys.stdout.flush()
|
|
50
|
+
except BrokenPipeError:
|
|
51
|
+
# setting to None prevents Python from trying to flush again
|
|
52
|
+
sys.stdout = None
|
|
53
|
+
except subprocess.CalledProcessError as e:
|
|
54
|
+
sys.exit(e.returncode)
|