-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copyright date in yaml and nxdl files. #46
base: main
Are you sure you want to change the base?
Conversation
is_comment_start = False | ||
is_comment_end = False | ||
|
||
if os.path.isfile(nxdl_file): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful! This function gets the copyright section from a given file. Note that during the conversion
- nxdl->nyaml: we just copy the whole nxdl file to the end of the yaml file
- nyaml->nxdl: we need to generate the copyright from the content of the original nxdl(!) (which is actually appended to the end of the nyaml file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is exactly what is happening. The nxdl_file
is coming the copied/stored ( in yaml file) nxdl content from yaml
file. In function generate_nxdl_or_retrieve_nxdl
cli.py
that returns the copied/stored nxdl
part as a output file if there is no changes in the yaml
part. Otherwise it send the copied/stored nxdl
content to the nyaml2nxdl
, that is overwriten later on.
So, in all cases copyright license
content is coming from stored
nxdl in yaml file.
You can check this function https://github.com/FAIRmat-NFDI/nyaml/blob/copyright_year/src/nyaml/cli.py#L46.
@@ -1155,6 +1175,8 @@ def nyaml2nxdl(input_file: str, out_file, verbose: bool): | |||
schema, definitions then evaluates a nested dictionary of groups recursively and | |||
fields or (their) attributes as children of the groups | |||
""" | |||
nxdl_copyright_license = get_nxdl_copyright_license(nxdl_file=out_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is calling the function with the name of output file, which may not even exists.
In case of nxdl->nyaml conversion one could call this function with the input file name. In case of nyaml->nxdl conversion the copyright should be in the nyaml file as part of the preserved nxdl conent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two possibility:
- File exists (coming from stored
nxdl
in yaml):
It would returns thecopyright license
from previous version of nxdl. - File does not exist (For new yaml file that does not have any nxdl):
The function would return an empty string "".
tests/data/ref_dim_keyword.nxdl.xml
Outdated
@@ -3,7 +3,7 @@ | |||
<!-- | |||
# NeXus - Neutron and X-ray Common Data Format | |||
# | |||
# Copyright (C) 2014-2024 NeXus International Advisory Committee (NIAC) | |||
# Copyright (C) 2025-2025 NeXus International Advisory Committee (NIAC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this test will only work in 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, every year it should be updated.
The is the test for conversion from new yaml
to nxdl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now copyright year is independent of the year of test.
Current test will check if the <current_year>-<current_year>
it correct (if there are no nxdl file stored in the yaml file as comment.), then the years will be replaced according to the test/nxdl file which is 2010-2020
hard coded in all nxdl file.
do we test this use cases?
|
I wrote a separate test for that. |
No description provided.