From 82a64851cc7ff7c21bf30750668d7e55e2e58747 Mon Sep 17 00:00:00 2001 From: Edoardo Putti Date: Sat, 29 Oct 2016 19:49:55 +0200 Subject: [PATCH] add iteration overt cas --- lookup.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lookup.py b/lookup.py index 1bfb484..701b528 100755 --- a/lookup.py +++ b/lookup.py @@ -6,6 +6,7 @@ import hashlib import json import os import os.path +import pickle import shutil import sqlite3 import tempfile @@ -33,8 +34,19 @@ class CALookup(object): self.path = MANAGER_PATH - """ - """ + def __iter__(self): + authorities_path = os.path.join(self.path, 'pickled_cas') + + auth = [] + + for authority in os.listdir(authorities_path): + + pickle_path = os.path.join(self.path, 'pickled_cas', authority) + + with open(pickle_path, 'rb') as stream: + auth.append(pickle.load(stream)) + + return iter(auth) def __getitem__(self, ca_id):