0

docs: fix chestFilter example

Fixes #1509
This commit is contained in:
Nicolas F
2019-02-21 16:34:28 +01:00
parent 03a8697866
commit b0921972ba

View File

@@ -45,7 +45,7 @@ A more complicated filter function can construct a more customized display text:
def chestFilter(poi): def chestFilter(poi):
if poi['id'] == "Chest": if poi['id'] == "Chest":
return "Chest with %d items" % len(poi['Items']) return "Chest with %d items" % len(poi.get('Items'))
It is also possible to return a tuple from the filter function to specify a hovertext It is also possible to return a tuple from the filter function to specify a hovertext
different from the text displayed in the info window. The first entry of the tuple will different from the text displayed in the info window. The first entry of the tuple will
@@ -53,7 +53,7 @@ be used as the hover text, the second will be used as the info window content::
def chestFilter(poi): def chestFilter(poi):
if poi['id'] == "Chest": if poi['id'] == "Chest":
return ("Chest", "Chest with %d items" % len(poi['Items'])) return ("Chest", "Chest with %d items" % len(poi.get('Items')))
Because of the way the config file is loaded, if you need to import a function or module Because of the way the config file is loaded, if you need to import a function or module
for use in your filter function, you need to explicitly load it into the global namespace:: for use in your filter function, you need to explicitly load it into the global namespace::