Skip to content

Add library, resource file and variable file import related methods to listener version 3 #5008

Closed

Description

@pekkaklarck

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.

Activity

  1. added this to the v7.1 milestone on Jan 10, 2024
  2. Snooz82 commented on Mar 26, 2024

    @Snooz82
    Member

    When this is implemented we should probably fix the following situation:

    https://robotframework.slack.com/archives/C0K0240NL/p1708297275219929?thread_ts=1708253100.376219&cid=C0K0240NL

            resources = BuiltIn()._namespace._kw_store.resources._items
            kws = [ KeywordDocBuilder().build_keywords(resource) for resource in resources]

    When calling that on a resource object, KeywordDocBuilder does somehow replace the actual default value variables with its name as strings.

    image

  3. pekkaklarck commented on Apr 17, 2024

    @pekkaklarck
    MemberAuthor

    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?

  4. pekkaklarck commented on Apr 17, 2024

    @pekkaklarck
    MemberAuthor

    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.

  5. pekkaklarck commented on Apr 17, 2024

    @pekkaklarck
    MemberAuthor

    Adding the variable file import method is covered by #5116.

  6. 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
  7. self-assigned this
    on Jul 5, 2024
  8. pekkaklarck commented on Jul 6, 2024

    @pekkaklarck
    MemberAuthor

    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.

  9. 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
  10. pekkaklarck commented on Jul 6, 2024

    @pekkaklarck
    MemberAuthor

    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.

  11. added a commit that references this issue on Jul 6, 2024
    15ef749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions