Category talk:Pages using RFC magic links

From Wikiversity
Jump to navigation Jump to search

Pywikibot Code[edit]

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

def categorymembers(category):
    category = pywikibot.Category(site, category)
    pages =
    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
   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"Replacing RFC magic links with RFC template per mw:Help:Magic links.", minor=True, botflag=True)