If your PLC project repo is missing a file (any file, even one not related to the ioc build), the pytmc template command fails with a confusing error:
```
Traceback (most recent call last):
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/bin/pytmc", line 10, in
sys.exit(main())
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/bin/pytmc.py", line 106, in main
func(**kwargs)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/bin/template.py", line 830, in main
raise stashed_exception
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/bin/template.py", line 821, in main
template_args.update(projects_to_dict(*projects))
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/bin/template.py", line 268, in projects_to_dict
for key, value in project_to_dict(path).items():
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/bin/template.py", line 219, in project_to_dict
projects = {fn: parser.parse(fn) for fn in project_files}
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/bin/template.py", line 219, in
projects = {fn: parser.parse(fn) for fn in project_files}
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 51, in parse
return TwincatItem.parse(root, filename=fn, parent=parent)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 407, in parse
return cls(element, parent=parent, filename=filename, name=name)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 224, in __init__
self._add_children(element)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 300, in _add_children
self._add_child(child_element)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 309, in _add_child
child = self.parse(element, parent=self, filename=self.filename)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 407, in parse
return cls(element, parent=parent, filename=filename, name=name)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 224, in __init__
self._add_children(element)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 300, in _add_children
self._add_child(child_element)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 309, in _add_child
child = self.parse(element, parent=self, filename=self.filename)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 407, in parse
return cls(element, parent=parent, filename=filename, name=name)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 224, in __init__
self._add_children(element)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 2134, in _add_children
self._finish_lazy_loading(self._xti_files)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 347, in _finish_lazy_loading
self._children[idx] = child.load(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 455, in load
obj._finish_lazy_loading(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 349, in _finish_lazy_loading
child._finish_lazy_loading(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 347, in _finish_lazy_loading
self._children[idx] = child.load(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 455, in load
obj._finish_lazy_loading(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 349, in _finish_lazy_loading
child._finish_lazy_loading(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 347, in _finish_lazy_loading
self._children[idx] = child.load(file_map)
File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.1/lib/python3.9/site-packages/pytmc/parser.py", line 453, in load
info = file_map[self.key]
KeyError: (, ‘15’, ‘ffo.xti’)
```
It's good that this gets caught in some capacity, but the error should be made more clear, e.g. something like:
"RuntimeError: file named {filename} missing from the repo!"
If your PLC project repo is missing a file (any file, even one not related to the ioc build), the
pytmc template
command fails with a confusing error:It's good that this gets caught in some capacity, but the error should be made more clear, e.g. something like:
"RuntimeError: file named {filename} missing from the repo!"
We can probably handle this by catching a
KeyError
in this line: https://github.com/pcdshub/pytmc/blob/2c4f4121cd109d2d2cee9bdcc357d792ddca01f7/pytmc/parser.py#L453