Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improved contract of running imports to always result in a dictionary…

… (with other clean-ups as well)
  • Loading branch information...
commit c329eb131a8cbf3c8aa64cc6f2c5b0c279a7caba 1 parent a26adb8
@brosner brosner authored
View
5 contacts_import/backends/importers.py
@@ -18,7 +18,10 @@
class BaseImporter(Task):
def run(self, credentials, persistance):
- status = None
+ status = {
+ "imported": 0,
+ "total": 0,
+ }
for contact in self.get_contacts(credentials):
status = persistance.persist(contact, status, credentials)
return status
View
16 contacts_import/backends/persistance.py
@@ -7,19 +7,11 @@ def persist(self, contact, status, credentials):
status = self.default_status()
return self.persist_contact(contact, status, credentials)
- def default_status(self):
- return None
-
def persist_contact(self, contact, status, credentials):
- return None
+ return status
class ModelPersistance(BasePersistance):
- def default_status(self):
- return {
- "imported": 0,
- "total": 0,
- }
def persist_contact(self, contact, status, credentials):
obj, created = TransientContact.objects.get_or_create(
@@ -34,9 +26,9 @@ def persist_contact(self, contact, status, credentials):
class InMemoryPersistance(BasePersistance):
- def default_status(self):
- return []
def persist_contact(self, contact, status, credentials):
- status.append(contact)
+ # @@@ no longer works (need to conform to status contract which could
+ # be done by adding a new key or emulating a dict and store contacts
+ # that way)
return status
View
2  setup.py
@@ -3,7 +3,7 @@
setup(
name = "django-contacts-import",
- version = "0.1.dev3",
+ version = "0.1.dev4",
author = "Eldarion",
author_email = "development@eldarion.com",
description = "contact importing for Django",
Please sign in to comment.
Something went wrong with that request. Please try again.