Skip to content

Commit 956c6ec

Browse files
authored
Merge pull request #40 from rayosborn:refine-output
Refine-output
2 parents 5167ad4 + f13f0a5 commit 956c6ec

File tree

4 files changed

+136
-97
lines changed

4 files changed

+136
-97
lines changed

src/nxvalidate/definitions/base_classes/NXroot.nxdl.xml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,35 @@
4545
<attribute name="file_update_time" type="NX_DATE_TIME">
4646
<doc>Date and time of last file change at close</doc>
4747
</attribute>
48-
<attribute name="NeXus_version">
48+
<attribute name="NeXus_version" deprecated="NAPI is frozen.">
4949
<doc>
5050
Version of NeXus API used in writing the file.
5151

52-
Only used when the NAPI has written the file.
5352
Note that this is different from the version of the
54-
base class or application definition version number.
53+
base class or application definition version number.
54+
</doc>
55+
</attribute>
56+
<attribute name="NeXus_repository">
57+
<doc>
58+
A repository containing the application definitions
59+
used for creating this file.
60+
If the ``NeXus_release`` attribute contains a commit distance and hash,
61+
this should refer to this repository.
62+
</doc>
63+
</attribute>
64+
<attribute name="NeXus_release">
65+
<doc>
66+
The version of NeXus definitions used in writing the file. This can either be a date-based
67+
NeXus release (e.g., YYYY.MM), see https://github.com/nexusformat/definitions/releases or
68+
a version tag that includes additional development information, such as a commit distance and
69+
a Git hash. This is typically formatted as `vYYYY.MM.post1.dev&lt;commit-distance&gt;-g&lt;git-hash&gt;`,
70+
where `YYYY.MM` refers to the base version of the NeXus definitions. `post1.dev&lt;commit-distance&gt;`
71+
indicates that the definitions are based on a commit after the base version (post1), with
72+
`&lt;commit-distance&gt;` being the number of commits since that version. `g&lt;git-hash&gt;` is the
73+
abbreviated Git hash that identifies the specific commit of the definitions being used.
74+
75+
If the version includes both a commit distance and a Git hash, the ``NeXus_repository``
76+
attribute must be included, specifying the URL of the repository containing that version.
5577
</doc>
5678
</attribute>
5779
<attribute name="HDF_version">
@@ -101,4 +123,3 @@
101123
</doc>
102124
</attribute>
103125
</definition>
104-

src/nxvalidate/scripts/nxinspect.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import argparse
1111
import logging
1212

13-
from nexusformat.nexus import NeXusError
14-
1513
import nxvalidate
1614
from nxvalidate.validate import (logger, inspect_base_class,
1715
validate_application, validate_file)
@@ -74,7 +72,7 @@ def main():
7472
else:
7573
validate_file(filename, path=path, definitions=definitions)
7674
else:
77-
raise NeXusError('A file or base class must be specified')
75+
logger.error('A file or base class must be specified')
7876

7977

8078
if __name__ == "__main__":

src/nxvalidate/utils.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import re
1111
import sys
12+
from pathlib import Path
1213

1314
if sys.version_info < (3, 10):
1415
from importlib_resources import files as package_files
@@ -19,7 +20,6 @@
1920
from dateutil.parser import parse
2021
from nexusformat.nexus.tree import string_dtype
2122

22-
2323
name_pattern = re.compile('^[a-zA-Z0-9_]([a-zA-Z0-9_.]*[a-zA-Z0-9_])?$')
2424

2525

@@ -405,6 +405,27 @@ def match_strings(pattern_string, target_string):
405405
return False
406406

407407

408+
def definitions_path(path):
409+
"""
410+
Return the path to the NeXus definitions directory.
411+
412+
The path is derived from a given path, which may be a string or a
413+
MultiplexedPath object. If the given path is a MultiplexedPath
414+
object, extract the path from it and return it as a string.
415+
416+
Parameters
417+
----------
418+
path : str or MultiplexedPath
419+
The path to the NeXus definitions directory.
420+
421+
Returns
422+
-------
423+
Path
424+
The path to the NeXus definitions directory.
425+
"""
426+
return Path(re.sub(r"MultiplexedPath\('(.*)'\)", r"\1", str(path)))
427+
428+
408429
def check_nametype(item_value):
409430
"""
410431
Return the value of the 'nameType' attribute for a given item.

0 commit comments

Comments
 (0)