__foo__ global variables. Are they mandatory/needed?
#1
Hi all,

Several years ago I adopted a subtitles add-on and its service.py file included lines like this at the top:

Code:

__addon__ = xbmcaddon.Addon()
__author__ = __addon__.getAddonInfo("author")
__scriptid__ = __addon__.getAddonInfo("id")
__scriptname__ = __addon__.getAddonInfo("name")
__version__ = "x.y.z"
__language__ = __addon__.getLocalizedString

__cwd__ = xbmcvfs.translatePath(__addon__.getAddonInfo("path"))
__profile__ = xbmcvfs.translatePath(__addon__.getAddonInfo("profile"))


A GitHub [1]search finds many occurrences of them in different Kodi addon repositories.

But e.g. I don't find them in Kodi's own codebase (searched for [2]__scriptid__).
Also, in the https://kodi.wiki site add-ons documentation section there is no formal mention of them as something that needs to be present, although an [3]article there that teaches how to create a minimal GUI add-on has a couple of them.

Are these actually mandated for an add-on to work correctly? Is it a[n old] convention of some sort?

Thanks,

1. https://github.com/search?q=path%3Aservi...&type=code
2. https://github.com/search?q=repo%3Axbmc%...&type=code
3. https://kodi.wiki/view/GUI_tutorial
Reply
#2
I can't answer you question/s as I do nothing with addons, but maybe these wiki pages might help

https://kodi.wiki/view/Add-on_structure
https://kodi.wiki/view/About_Add-ons
Reply
#3
Those are just "aliases" you are defining yourself. If you don't use them, you don't need them.
Reply
#4
It's just an old naming convention that has no special meaning. I usually use ALL_CAPS naming for globals but it's just a matter of a preferred code style.
Reply

Logout Mark Read Team Forum Stats Members Help
__foo__ global variables. Are they mandatory/needed?0