From 86d7958489ff22107cf2529d6ea54b303b189105 Mon Sep 17 00:00:00 2001 From: Thomas Wade Date: Thu, 27 Sep 2018 00:15:29 +0930 Subject: [PATCH] Use default flag for shelving Avoids an issue when running the script for the first time where Shelve would freak out and die because the shelf doesn't exist. --- scrape.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrape.py b/scrape.py index 2fa06c2..32a5ef3 100755 --- a/scrape.py +++ b/scrape.py @@ -267,7 +267,7 @@ def Get_Follows(url, limit = 100): user_dict = {} track_dict = {} -with shelve.open('shelf.db', 'r') as shelf: +with shelve.open('shelf.db') as shelf: if 'user_dict' in shelf.keys(): user_dict = shelf['user_dict'] if 'track_dict' in shelf.keys(): @@ -327,7 +327,7 @@ for i in range(MAX_DEGREE + 1): user_dict[user.url_username] = user # Update the shelf with the new dictionaries - with shelve.open('shelf.db', 'c') as shelf: + with shelve.open('shelf.db') as shelf: shelf['user_dict'] = user_dict shelf['track_dict'] = track_dict