2019-07-05 14:26:25 +00:00
|
|
|
from core.prototypes.AbstractStorage import AbstractStorage
|
|
|
|
import json
|
|
|
|
class GDocsStorage(AbstractStorage):
|
2019-11-13 16:15:54 +00:00
|
|
|
def __init__(self, path:"path"):
|
2019-07-05 14:26:25 +00:00
|
|
|
self.path = path
|
|
|
|
self.urls = dict()
|
2019-11-13 16:15:54 +00:00
|
|
|
def put_responce(self, url:'url', status:'status', title:'gdoc_title',
|
|
|
|
info:'gdoc_info'):
|
2019-07-05 14:26:25 +00:00
|
|
|
if str(status) not in self.urls.keys():
|
2019-11-13 16:15:54 +00:00
|
|
|
self.urls[str(status)] = dict()
|
|
|
|
print(int(status))
|
|
|
|
url_object = dict()
|
|
|
|
if status == 200:
|
|
|
|
url_object = info
|
|
|
|
url_object["title"] = title
|
|
|
|
self.urls[str(status)][url] = url_object
|
2019-07-05 14:26:25 +00:00
|
|
|
def save(self):
|
|
|
|
print("saving")
|
|
|
|
with open(self.path, "w") as f:
|
|
|
|
json.dump(self.urls, f)
|
|
|
|
self.urls = dict()
|