RED icon indicating copy to clipboard operation
RED copied to clipboard

While importing python library can we avoid to specify argument values

Open ilesh32 opened this issue 5 years ago • 3 comments
trafficstars

I am able to use the python library keyword if I specify the argument value in red.xml.

But I have so many python libraries in the existing project and wanted to import all python files as a library. while importing it is giving error for the expected arguments.

I don't want to give argument values there. Because development is in progress and every day so many changes are coming in for the library. So, want to avoid every time to update and add an argument part

Please find below the error sample screenshot. Also, suggest if there is any other way or workaround. Screenshot 2020-08-21 at 4 24 34 PM Is there a way to import python library without specifying a value for the argument.

ilesh32 avatar Aug 21 '20 11:08 ilesh32

Hmn, I'm no expert here but seems to me that the way you are declaring your custom library's constructor means you need 2 arguments, a host parameter and a port parameter. So maybe changing your constructor and declaring a default host argument will help get you where you want to go. If I am understanding your problem correctly.

humbienri avatar Aug 21 '20 17:08 humbienri

@humbienri ,

You are right. If I change constructor it will solve my problem. But the issue is I have so many library files and if I change the constructor in some file need to handle for default arg case check also. So, here, do not want to change existing code which is running fine. Also, if I change, it will affect multiple people also and frankly telling don't want to convince all people to prepare library with construction to have a default value in args.

ilesh32 avatar Aug 22 '20 05:08 ilesh32

Hi,

yes, if your library constructor has arguments and you want RED to recognize this library and provide all the features then you either need to:

  1. modify the constructor to be able to instantiate library via 0-arg call
  2. provide all the required arguments by setting them in red.xml file

This is actually not something that RED itself requires, but this is inherited from Robot libdoc tool (https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#library-documentation-tool-libdoc) which is used by RED to generate list of keywords with their signatures and documentations. When generating those files libdoc creates an instance of a library so the arguments has to be provided once they are required.

michalanglart avatar Aug 31 '20 09:08 michalanglart