def __init__(self, **kwargs): """Initializer.""" self.available_options.update({ 'nouserwarning': False, # do not warn uploader 'filetemplate': '', 'usertemplate': '', }) super().__init__(**kwargs) # handle the custom templates if not self.opt.filetemplate: self.opt.filetemplate = i18n.translate(self.site, template_to_the_image) elif not re.fullmatch('{{.+}}', self.opt.filetemplate): self.opt.filetemplate = '{{%s}}' % self.opt.filetemplate if not self.opt.usertemplate: self.opt.usertemplate = i18n.translate(self.site, template_to_the_user) elif not re.fullmatch('{{.+}}', self.opt.usertemplate): self.opt.usertemplate = '{{%s}}' % self.opt.usertemplate if not (self.opt.filetemplate and (self.opt.usertemplate or self.opt.nouserwarning)): # if no templates are given raise i18n.TranslationError( 'This script is not localized for {} site;\n' 'try using -filetemplate:<template name>.'.format(self.site))
def __init__(self, **kwargs): """Initializer.""" self.availableOptions.update({ 'nouserwarning': False # do not warn uploader }) super(UnusedFilesBot, self).__init__(**kwargs) self.template_image = i18n.translate(self.site, template_to_the_image) self.template_user = i18n.translate(self.site, template_to_the_user) if not (self.template_image and (self.template_user or self.getOption('nouserwarning'))): raise i18n.TranslationError('This script is not localized for {0} ' 'site.'.format(self.site))