From 8ebb667976bee4bb403a7a44b71c908bbae74b9f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 22 Jun 2016 19:14:20 -0500 Subject: [PATCH] Add `Importer.fields_active()` convenience method --- rattail/importing/importers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rattail/importing/importers.py b/rattail/importing/importers.py index 33fd928b..9003116d 100644 --- a/rattail/importing/importers.py +++ b/rattail/importing/importers.py @@ -94,6 +94,16 @@ class Importer(object): self.model_name = self.model_class.__name__ self._setup(**kwargs) + def fields_active(self, fields): + """ + Convenience method to check if any of the given fields are currently + "active" for the importer. Returns ``True`` or ``False``. + """ + for field in fields: + if field in self.fields: + return True + return False + def _setup(self, **kwargs): self.create = kwargs.pop('create', self.allow_create) and self.allow_create self.update = kwargs.pop('update', self.allow_update) and self.allow_update