import pywikibot
from pywikibot import pagegenerators as pg

site=pywikibot.Site('nl','wikipedia')
printtype=['Q5']

def all_templates_with(search4template):
  refPage = pywikibot.Page(pywikibot.Link(search4template,site))
  gen = pg.ReferringPageGenerator(refPage)
  for page in gen:
    if (page.namespace()==0):
      yield page

def all_links_on(this_template):
  page=pywikibot.Page(site,this_template)
  for p in page.linkedPages():
     if (p.exists()):   
        yield p

def check_one_template(which_template):    
 #print(which_template)   
 for page in all_links_on(which_template): #get all pages with this template
   templatefound=False
   #print('--------------------------------------')
   #print(page.title())
   for t in page.templates():
     templatefound= templatefound or (t.title().lower()==which_template.lower())
     #print(f'{t.title().lower()}--{templatefound}')   
   if (not templatefound):
     if ('wikibase_item' in page.properties()):
       wd=page.data_item()
       wd.get(get_redirect=True)
       if ('P31' in wd.claims):
        for claim in wd.claims['P31']:
          if claim.getTarget().title() in printtype:
            print(f'{page.title()}--{which_template}')
          #else:
          #  print(claim.getTarget())

def all_from_cat(thisCat):        
   cat=pywikibot.Category(site,thisCat)     
   gen=pg.CategorizedPageGenerator(cat,99)
   for x in gen:
      ns=x.namespace()
      if (ns==10):
       if (x.text.lower().find('{{navigatie')>=0): 
        check_one_template(x.title())
        
print('Start')   
#all_from_cat('Categorie:Wikipedia:Sjablonen voetbalelftal Nederland')
#all_from_cat('Categorie:Wikipedia:Sjablonen Olympische Spelen')
all_from_cat('Categorie:Wikipedia:Sjablonen sport')
#check_one_template('sjabloon:Navigatie selectie Ajax (vrouwen)')
print('Klaar')
Start
Carlo Azeglio Ciampi--Sjabloon:Infobox Olympische Spelen
Giorgio Rocca--Sjabloon:Infobox Olympische Spelen
Stefania Belmondo--Sjabloon:Infobox Olympische Spelen