Skip to content

Instantly share code, notes, and snippets.

@danmichaelo
Last active August 29, 2015 14:08
Show Gist options
  • Save danmichaelo/34db732874a8536fe53a to your computer and use it in GitHub Desktop.
Save danmichaelo/34db732874a8536fe53a to your computer and use it in GitHub Desktop.
Sjekk for blanke parametre med mwtemplates
from mwtemplates import TemplateEditor
from mwclient import Site
no = Site('no.wikipedia.org')
tpl = no.pages['Mal:Infoboks kunstverk']
for x in tpl.embeddedin():
te = TemplateEditor(x.text())
if len(te.templates['Infoboks kunstverk']) != 0:
ib = te.templates['Infoboks kunstverk'][0]
elif len(te.templates['Infoboks maleri']) != 0:
ib = te.templates['Infoboks maleri'][0]
else:
print 'No template found', x
continue
if u'år' in ib.parameters:
if ib.parameters[u'år'] == '':
print u'"år" er blank', x
elif u'year' in ib.parameters:
if ib.parameters[u'year'] == '':
print u'"year" er blank', x
else:
print u'Verken "år" eller "year" spesifisert', x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment