You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add library, resource file and variable file import related methods to listener version 3 #5008
Listener version 3 was initially implemented in RF 3.0 (#1208). It didn't have start/end_keyword methods nor methods related to library, resource file and variable file imports because implementing them would have been too big task. It finally got keyword and control structure related methods in RF 7.0 (#3296), but it still lacks methods related to library, resource file and variable file imports.
Listener version 2 has methods library_import, resource_import and variables_import, and we probably should use same name with listener version 3 as well. With listener version 2 all these methods the name of the imported thing and a dictionary containing other information as arguments. With listener version 3 we want to pass the real model objects instead similarly as we do with start/end methods. Listeners should be able to modify at least resource files but preferably also libraries and variable files.
The good news is that implementing start/end_keyword methods required refactoring also library and resource file related model objects and they both ought to be in good enough shape to be used directly. With variable files we don't have such a good model object yet, but creating one shouldn't be too complicated. If it turns out to be hard, just adding methods for libraries and resource files and delaying adding methods for variable files is fine as well.
I consider this pretty high priority because after that listener version 3 can handle everything that listener version 2 can.
UPDATE: We won't create model objects representing variable files in RF 7.1, but the variable file related method will be added anyway. It will simply get a dictionary with same information as the listener v2 method, and the dictionary will be replaced with a proper object later when such an object is available. That change is covered by #5116.
The issue you @Snooz82 reported doesn't seem to be too much related to the possible new listener methods. Could you submit a separate issue with some more information and a bit more detailed explanation how to reproduce the problem?
We won't have time to add suitable model object representing variable files in RF 7.1. I believe it's better to do that later when we are also otherwise making bigger changes to variable namespaces. Adding methods for libraries and resource files ought to be easy because the new model objects introduced in RF 7.0 ought to be usable as-is. Let's add those methods now and add the variable file method later. I'll submit a separate issue about that.
changed the title [-]Add library, resource file and variable file import related methods to listener version 3[/-][+]Add library and resource file import related methods to listener version 3[/+]on Apr 17, 2024
Adding the variables_import method itself at the same time as library_import and resource_import is trivial. As mentioned above, we don't have suitable objects representing variable files at the moment, and creating them is out of the scope of RF 7.1, but it's probably better to add the method anyway. We can simply pass a dictionary with the same information as the v2 listener method gets now and replace the dict with a proper object later. That change will then be backwards incompatible, but I believe that's a smaller problem than not having this method at all at the moment. The fact that the method will be changed in the future obviously needs to be documented in the User Guide and in the API docs. Updating the method is covered by #5116.
changed the title [-]Add library and resource file import related methods to listener version 3[/-][+]Add library, resource file and variable file import related methods to listener version 3[/+]on Jul 6, 2024
All three methods accept two arguments so that the first argument is the imported thing and the latter is the importer.
As discussed above, with libraries and resource files the imported thing is the model object representing the imported library or resource. With variable files it's currently just a dictionary, but it will be changed to a proper model object later when such an object is available (#5116).
The importer is a robot.running.Import object which contains thinks like name and arguments used for importing, source and line number information, and access to the resource file or suite that contains the import.
Activity
Snooz82 commentedon Mar 26, 2024
When this is implemented we should probably fix the following situation:
https://robotframework.slack.com/archives/C0K0240NL/p1708297275219929?thread_ts=1708253100.376219&cid=C0K0240NL
When calling that on a resource object, KeywordDocBuilder does somehow replace the actual default value variables with its name as strings.
pekkaklarck commentedon Apr 17, 2024
The issue you @Snooz82 reported doesn't seem to be too much related to the possible new listener methods. Could you submit a separate issue with some more information and a bit more detailed explanation how to reproduce the problem?
pekkaklarck commentedon Apr 17, 2024
We won't have time to add suitable model object representing variable files in RF 7.1. I believe it's better to do that later when we are also otherwise making bigger changes to variable namespaces. Adding methods for libraries and resource files ought to be easy because the new model objects introduced in RF 7.0 ought to be usable as-is. Let's add those methods now and add the variable file method later. I'll submit a separate issue about that.
pekkaklarck commentedon Apr 17, 2024
Adding the variable file import method is covered by #5116.
[-]Add library, resource file and variable file import related methods to listener version 3[/-][+]Add library and resource file import related methods to listener version 3[/+]pekkaklarck commentedon Jul 6, 2024
Adding the
variables_importmethod itself at the same time aslibrary_importandresource_importis trivial. As mentioned above, we don't have suitable objects representing variable files at the moment, and creating them is out of the scope of RF 7.1, but it's probably better to add the method anyway. We can simply pass a dictionary with the same information as the v2 listener method gets now and replace the dict with a proper object later. That change will then be backwards incompatible, but I believe that's a smaller problem than not having this method at all at the moment. The fact that the method will be changed in the future obviously needs to be documented in the User Guide and in the API docs. Updating the method is covered by #5116.[-]Add library and resource file import related methods to listener version 3[/-][+]Add library, resource file and variable file import related methods to listener version 3[/+]pekkaklarck commentedon Jul 6, 2024
All three methods accept two arguments so that the first argument is the imported thing and the latter is the importer.
As discussed above, with libraries and resource files the imported thing is the model object representing the imported library or resource. With variable files it's currently just a dictionary, but it will be changed to a proper model object later when such an object is available (#5116).
The importer is a robot.running.Import object which contains thinks like name and arguments used for importing, source and line number information, and access to the resource file or suite that contains the import.
Add resource and variables imports to generic test data file.
Add library, resource and variable file methods to listener v3