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.
This commit is contained in:
parent
161d24e238
commit
86d7958489
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user