Skip to content

Commit

Permalink
the line number of the yaml file is displayed in the error message (#34)
Browse files Browse the repository at this point in the history
* lineloader class

* Line Tags in Error Messages!

* pylint

* support extends keyword in root level of yaml file

* cleaning yaml2nxdl folder

* pylint

* tests implemented and PR comments solved

* test_yaml2nxdl updated

* test yaml2nxdl failing

* python version changed in pylint.yml
  • Loading branch information
aalbino2 authored Sep 7, 2022
1 parent 04701c8 commit 8c2a839
Show file tree
Hide file tree
Showing 13 changed files with 338 additions and 1,472 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8
- name: Install dependencies
run: |
git submodule sync --recursive
Expand Down
588 changes: 0 additions & 588 deletions nexusparser/tools/yaml2nxdl/NXellipsometry-docCheck.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions nexusparser/tools/yaml2nxdl/NXtest_links.nxdl.xml

This file was deleted.

8 changes: 0 additions & 8 deletions nexusparser/tools/yaml2nxdl/NXtest_links.yml

This file was deleted.

755 changes: 0 additions & 755 deletions nexusparser/tools/yaml2nxdl/Ref_NXellipsometry-docCheck.nxdl.xml

This file was deleted.

25 changes: 19 additions & 6 deletions nexusparser/tools/yaml2nxdl/yaml2nxdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,25 @@ def yaml2nxdl(input_file: str, verbose: bool):
application and base are valid categories!'
assert 'doc' in yml_appdef.keys(), 'Required root-level keyword doc is missing!'

xml_root.set('extends', 'NXobject')
xml_root.set('type', 'group')

if 'extends' in yml_appdef.keys():
xml_root.set('extends', yml_appdef['extends'])
del yml_appdef['extends']
else:
xml_root.set('extends', 'NXobject')

if yml_appdef['category'] == 'application':
xml_root.set('category', 'application')
del yml_appdef['category']
else:
xml_root.set('category', 'base')
del yml_appdef['category']
del yml_appdef['category']

if 'symbols' in yml_appdef.keys():
yaml2nxdl_forward_tools.xml_handle_symbols(xml_root, yml_appdef['symbols'])
yaml2nxdl_forward_tools.xml_handle_symbols(yml_appdef,
xml_root,
'symbols',
yml_appdef['symbols'])
del yml_appdef['symbols']

assert isinstance(yml_appdef['doc'], str) and yml_appdef['doc'] != '', 'Doc \
Expand All @@ -119,9 +127,14 @@ def yaml2nxdl(input_file: str, verbose: bool):

del yml_appdef['doc']

assert len(yml_appdef.keys()) == 1, 'Accepting at most keywords: category, \
root_keys = 0
for key in yml_appdef.keys():
if '__line__' not in key:
root_keys += 1

assert root_keys == 1, 'Accepting at most keywords: category, \
doc, symbols, and NX... at root-level!'
keyword = list(yml_appdef.keys())[0] # which is the only one
keyword = list(yml_appdef.keys())[0]
assert (keyword[0:3] == '(NX' and keyword[-1:] == ')' and len(keyword) > 4), 'NX \
keyword has an invalid pattern, or is too short!'
xml_root.set('name', keyword[1:-1])
Expand Down
Loading

0 comments on commit 8c2a839

Please sign in to comment.