Category talk:Pages using RFC magic links

Pywikibot Code

edit

Pywikibot code to replace RFC magic links with calls to this template.

def categorymembers(category):
    category = pywikibot.Category(site, category)
    pages = pywikibot.site.APISite.categorymembers(
        site,
        category=category
    )
    return pages

site = pywikibot.Site("en", "wikiversity")
pages = categorymembers("Pages using RFC magic links")
   
regex = re.compile("RFC \d+")
for page in pages:
   title = page.title()
   text = page.text
   
   print(title)
   list = regex.findall(text)
   for item in list:
       item = item.strip()
       text = text.replace(item, "{{RFC|" + item.replace("RFC", "").strip() + "}}")

   if page.text != text:
       page.text = text
       page.save(summary="Replacing RFC magic links with RFC template per mw:Help:Magic links.", minor=True, botflag=True)
Return to "Pages using RFC magic links" page.