replace.ReplaceRobot always needs a site argument. This is due to the ReplaceRobot's constructor in replace.py is called positional and not as keywords argument. This leads to template.TemplateRobot resets bot.site to None when the constructor calls the ReplaceRobot.init.
Samples:
>>> import pwb, pywikibot as py >>> site = py.Site() >>> from scripts.template import TemplateRobot >>> bot = TemplateRobot(iter([]), {}, **{}) # call the bot without site argument WARNING: Bot.site was not set before being retrieved. WARNING: Using the default site: wikipedia:de # the bot._site has been set >>> bot.site WARNING: Bot.site was not set before being retrieved. WARNING: Using the default site: wikipedia:de # but it was lost immediately
try it with site argument:
>>> del bot >>> bot = TemplateRobot(iter([]), {}, site=site, **{}) # looks good here >>> bot.site WARNING: Bot.site was not set before being retrieved. WARNING: Using the default site: wikipedia:de # but it fails again