restage 0.5.0__py3-none-any.whl → 0.5.1__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.
- restage/mcpl.py +20 -23
- {restage-0.5.0.dist-info → restage-0.5.1.dist-info}/METADATA +2 -2
- {restage-0.5.0.dist-info → restage-0.5.1.dist-info}/RECORD +6 -6
- {restage-0.5.0.dist-info → restage-0.5.1.dist-info}/WHEEL +0 -0
- {restage-0.5.0.dist-info → restage-0.5.1.dist-info}/entry_points.txt +0 -0
- {restage-0.5.0.dist-info → restage-0.5.1.dist-info}/top_level.txt +0 -0
restage/mcpl.py
CHANGED
|
@@ -4,20 +4,26 @@ from pathlib import Path
|
|
|
4
4
|
def mcpl_real_filename(filename: Path) -> Path:
|
|
5
5
|
"""MCPL_output from McCode instruments has the bad habit of changing the output file name silently.
|
|
6
6
|
Find the _real_ output file name by looking for the expected variants"""
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
base, ext = filename.parent / filename.stem, filename.suffix
|
|
8
|
+
if ext in ('.gz',):
|
|
9
|
+
ext = base.suffix + ext
|
|
10
|
+
base = base.parent / base.stem
|
|
11
|
+
extensions = {'.mcpl.gz', '.mcpl', ''}
|
|
12
|
+
if ext not in extensions:
|
|
13
|
+
ValueError(f'Unsupported file extension: {ext}')
|
|
14
|
+
for ext in extensions:
|
|
15
|
+
check = base.with_suffix(ext)
|
|
16
|
+
if check.exists() and check.is_file():
|
|
17
|
+
return check
|
|
18
|
+
print(f'{base} -> {check} not found')
|
|
13
19
|
raise FileNotFoundError(f'Could not find MCPL file {filename}')
|
|
14
20
|
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
def mcpl_real_extension(filename: Path) -> str:
|
|
23
|
+
for ext in ('.mcpl.gz', '.mcpl'):
|
|
24
|
+
if str(filename).endswith(ext):
|
|
25
|
+
return ext
|
|
26
|
+
return ''
|
|
21
27
|
|
|
22
28
|
|
|
23
29
|
def mcpl_particle_count(filename):
|
|
@@ -52,11 +58,7 @@ def mcpl_merge_files(files: list[Path], filepath: Path, keep_originals: bool = F
|
|
|
52
58
|
from subprocess import run
|
|
53
59
|
real_filenames = [mcpl_real_filename(f) for f in files]
|
|
54
60
|
# if the real filenames have .mcpl or .mcpl.gz, the merged filename should too
|
|
55
|
-
ext =
|
|
56
|
-
if real_filenames[0].name.endswith('.mcpl.gz'):
|
|
57
|
-
ext = '.mcpl.gz'
|
|
58
|
-
elif real_filenames[0].name.endswith('.mcpl'):
|
|
59
|
-
ext = '.mcpl'
|
|
61
|
+
ext = mcpl_real_extension(real_filenames[0])
|
|
60
62
|
filename = filepath.with_suffix(ext).as_posix()
|
|
61
63
|
|
|
62
64
|
command = ['mcpltool', '--merge', filename] + [str(f) for f in real_filenames]
|
|
@@ -69,13 +71,8 @@ def mcpl_merge_files(files: list[Path], filepath: Path, keep_originals: bool = F
|
|
|
69
71
|
|
|
70
72
|
|
|
71
73
|
def mcpl_rename_file(source: Path, dest: Path, strict: bool = False):
|
|
72
|
-
filepath = mcpl_real_filename(source)
|
|
73
|
-
|
|
74
|
-
ext = ''
|
|
75
|
-
if filepath.name.endswith('.mcpl.gz'):
|
|
76
|
-
ext = '.mcpl.gz'
|
|
77
|
-
elif filepath.name.endswith('.mcpl'):
|
|
78
|
-
ext = '.mcpl'
|
|
74
|
+
filepath = mcpl_real_filename(source) # this could be '{name}', '{name}.mcpl', or '{name}.mcpl.gz'
|
|
75
|
+
ext = mcpl_real_extension(filepath)
|
|
79
76
|
|
|
80
77
|
if not dest.name.endswith(ext):
|
|
81
78
|
if strict:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: restage
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Author-email: Gregory Tucker <gregory.tucker@ess.eu>
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
Classifier: License :: OSI Approved :: BSD License
|
|
@@ -17,7 +17,7 @@ Requires-Dist: zenlog>=1.1
|
|
|
17
17
|
Requires-Dist: platformdirs>=3.11
|
|
18
18
|
Requires-Dist: confuse
|
|
19
19
|
Requires-Dist: psutil>=5.9.6
|
|
20
|
-
Requires-Dist: mccode-antlr[hdf5]>=0.
|
|
20
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.12.0
|
|
21
21
|
Provides-Extra: test
|
|
22
22
|
Requires-Dist: pytest; extra == "test"
|
|
23
23
|
Requires-Dist: chopcal; extra == "test"
|
|
@@ -6,7 +6,7 @@ restage/database.py,sha256=anyOby31fUN7rGAVNsnWDUhAISV0vQ7en8aQwVS5ZwA,11051
|
|
|
6
6
|
restage/emulate.py,sha256=VrhfZJIbECdbDS-MHklqRuAIy9cRkjZkwPBTKQSQoe0,6164
|
|
7
7
|
restage/energy.py,sha256=w78GUIWcHxANvBl2DTu73FQFawCXfzlK6L32TBQNt4g,3371
|
|
8
8
|
restage/instr.py,sha256=A0ShtXkswt_f7o-cIDtsVbG03_tGELe1aS3WzLxzkJM,2494
|
|
9
|
-
restage/mcpl.py,sha256=
|
|
9
|
+
restage/mcpl.py,sha256=MKVY-2TYk5p8hW1lXJib5mxdbnILq4GoYiyAUgOBJmA,3269
|
|
10
10
|
restage/range.py,sha256=TjOf4DSKfgoAIcrWQvv6MrtksQpnGJHdsEjVI5K-UfI,8116
|
|
11
11
|
restage/run.py,sha256=nk8d7cIyIqSt-5pyGm68Zak5H1a-fbo_z2_36eN-08E,1481
|
|
12
12
|
restage/scan.py,sha256=Yx8OQSBG6I2_64sW0LIDb0glVKwWoxUQQznASXgDZFQ,1432
|
|
@@ -14,8 +14,8 @@ restage/splitrun.py,sha256=W_pTeiMjc9hhu-zaE6fdetVLG6MGEpnaTOdgmgVkS1g,26061
|
|
|
14
14
|
restage/tables.py,sha256=mL1SrCbgwfWzG-ezd_R3CxOSIZLNZRoC2r7ht59jGMA,16371
|
|
15
15
|
restage/config/__init__.py,sha256=zFRT9QXgpUJpBncELCQ6by1-kjYp8Li1yJDfqxkHxAA,965
|
|
16
16
|
restage/config/default.yaml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
restage-0.5.
|
|
18
|
-
restage-0.5.
|
|
19
|
-
restage-0.5.
|
|
20
|
-
restage-0.5.
|
|
21
|
-
restage-0.5.
|
|
17
|
+
restage-0.5.1.dist-info/METADATA,sha256=r51j8rWD3Iwc9y8D-ZWZL46JERjcgEkch-88CYeOt4w,6769
|
|
18
|
+
restage-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
restage-0.5.1.dist-info/entry_points.txt,sha256=gghocSxC2gHHxUCalAibCN1mtkh3trNmAfH5Qwx0KYg,149
|
|
20
|
+
restage-0.5.1.dist-info/top_level.txt,sha256=iM_pb-taTZ0S2WMoDnt_qDMZoNMjmM19z3tTCuVm1IE,8
|
|
21
|
+
restage-0.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|