Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def file_load(self, filename='archive.pkl'):
d = super(GroupArchive, self).file_load(filename)
if not d:
return False
if 'obj' in d:
self.obj = d['obj']
self.ingest_obj()
if 'links' in d:
for l in d['links']:
self.links[l.url] = l
if 'posts' in d:
for p in d['posts']:
post = PostArchive(self.graph, None, obj=p)
for k in post.links:
if k in self.links:
post.links[k] = self.links[k]
self.add_post(post)
self.isLoaded = True
def __init__(self, graph, id, *args, **kwargs):
super(PostArchive, self).__init__(args, kwargs)
self.graph = graph
self.id = id
self.obj = None
self.users = {}
self.links = {}
self.comments = []
if 'obj' in kwargs:
self.obj = kwargs['obj']
self.ingest_obj()
if not self.obj:
print "Initiating post archive: ",id
filename = kwargs['filename'] if 'filename' in kwargs else 'archive.pkl'
self.file_load(filename)
if self.graph and not self.obj:
self.graph_load()
def load_data(data):
for d in data:
p = PostArchive(self.graph, d['id'])
self.add_post(p)
# Go!
def archive_post(self, id):
a = PostArchive(self.g, id)
a.save()
a.snaps()
a.markdownify()
a.save()