How to pass variable values to another config parameters?

1.9k Views Asked by At
[plugin_jira]
maxuser=
finduser=
endpoint="https://nepallink.atlassian.net/rest/api/latest/user/search?startAt=0&maxResults={maxi}&username={manche}%".format(maxi=maxresult,manche=user_find)

This is my config file , in the endpoints item why I am using the format is so that I can pass a variable to it in my script.The script where it is running is below ,my main.py

maxresult = config.get('plugin_jira', 'maxuser')
user_find = config.get('plugin_jira', 'finduser')
endpoint = config.get('plugin_jira', 'endpoint')

Now what I am confused is when I call the endpoints values in the script it just fetching what is in the config without the variable values that got defined just above it.

How can I make the variable value of maxresult and user_find added to endpoints which is defined to access it.

1

There are 1 best solutions below

1
abhinav On

In your config file, import the variables from main.py as following.

Config file:


from main import maxresult, user_find
[plugin_jira]
endpoint="https://nepallink.atlassian.net/rest/api/latest/user/search?startAt=0&maxResults={maxi}&username={manche}%".format(maxi=maxresult,manche=user_find)

This will allow you to access the required variables to your endpoints.

Hope it helps!