From 5d1953a807333c6e013d6be818f2e7c7133201df Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 24 May 2011 20:33:37 +0200 Subject: fixes #2187 (import/export) --- src/roster.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/roster.py') diff --git a/src/roster.py b/src/roster.py index 79de1868..aed5f5a0 100644 --- a/src/roster.py +++ b/src/roster.py @@ -22,6 +22,7 @@ import logging log = logging.getLogger(__name__) from config import config +from os import path as p from contact import Contact, Resource from sleekxmpp.xmlstream.stanzabase import JID @@ -33,6 +34,17 @@ class Roster(object): self._contacts = {} # key = bare jid; value = Contact() self._roster_groups = [] + def export(self, path): + if p.isfile(path): + return + try: + f = open(path, 'w+') + f.writelines([i + "\n" for i in self._contacts]) + f.close() + return True + except IOError: + return + def add_contact(self, contact, jid): """ Add a contact to the contact list -- cgit v1.2.3