From ebb41734d56770202735acb8f0f5b4f50a4280a6 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Fri, 16 Apr 2010 19:27:19 +0200 Subject: [PATCH] remove unused cap --- weboob/capabilities/updatable.py | 47 -------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 weboob/capabilities/updatable.py diff --git a/weboob/capabilities/updatable.py b/weboob/capabilities/updatable.py deleted file mode 100644 index e06e136b..00000000 --- a/weboob/capabilities/updatable.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -Copyright(C) 2010 Romain Bignon - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -""" - -from .cap import ICap - -class ICapUpdatable(ICap): - snapshots = {} - - def take_snapshot(self, name, collection): - if name not in self.snapshots: - self.snapshots[name] = dict(original=set(collection)) - elif 'original' in self.snapshots[name]: - if 'updated' in self.snapshots[name]: - self.snapshots[name]['original'] = self.snapshots[name]['updated'] - self.snapshots[name]['updated'] = set(collection) - - def iter_new_items(self, name): - """ - Iterates on new items from last time this function has been called. - - @param name [str] name of the collection to iter - @return [iter] new items - """ - if name not in self.snapshots: - raise ValueError('"%s" has not been snapshot previously' % name) - elif 'original' not in self.snapshots[name] or 'updated' not in self.snapshots[name]: - raise ValueError('At least two snapshots are required to detect new items') - diff = self.snapshots[name]['updated'] - self.snapshots[name]['original'] - for item in diff: - yield item