mqttwarn icon indicating copy to clipboard operation
mqttwarn copied to clipboard

Templates can only be loaded from `templates/` folder in working directory?

Open amotl opened this issue 3 years ago • 3 comments

Hi there,

we are apparently not using that feature too much, that is why we are asking the community about it.

Is it possible that mqttwarn can only load templates from the templates/ folder in current working directory? According to the implementation, it looks like it is - please correct me if I'm wrong.

https://github.com/jpmens/mqttwarn/blob/b8e61e224b3d6cbad6605870d6e518be7f815133/mqttwarn/core.py#L37-L45

Do you think it should be improved?

With kind regards, Andreas.

amotl avatar Sep 22 '22 23:09 amotl

It's never been reported as a problem, and I can't really imagine it is. I selected the name templates/ because it sounded reasonable, (and because that's the default in Ansible :-) ).

jpmens avatar Sep 23 '22 06:09 jpmens

Hi JP,

I selected the name templates/ because it sounded reasonable.

The name is perfectly reasonable. I was just wondering if the location of the folder should be made more flexible. When it never has been a problem, then I will back off.

I am just remembering the time when mqttwarn would mostly load an mqttwarn.ini file from the current working directory. In this scenario it would be perfectly fine to assume the templates/ folder is right side-by-side.

However, I think we made some adjustments to improve the location resolvement for the function file, for example. And I think we may want to apply the same logic to the location resolvement of the Jinja2 template folder.

I am not completely sure about current the state (will have to investigate), but just wanted to take a note about it while I came across the corresponding lines of code while writing more tests yesterday, and listen to what you think about it.

With kind regards, Andreas.

amotl avatar Sep 23 '22 07:09 amotl

Maybe templates/ could be a default if the path to the template file is not absolute.

I don't think changing the behaviour would break very much.

jpmens avatar Sep 23 '22 08:09 jpmens