def do_test(self): filename = self.value.strip() allowed = filter_filename(map(compile_rule, self.rules), filename) if allowed is None: self.result.setText(_('The filename %s did not match any rules') % filename) else: self.result.setText(_('The filename {0} will be {1}').format(filename, _('added' if allowed else 'ignored')))
def is_filename_allowed(self, filename): allowed = filter_filename(self.compiled_rules, filename) if allowed is None: ext = os.path.splitext(filename)[1][1:].lower() allowed = ext in self.allowed return allowed