def __init__(self, router, nodeDict): OneToOneNode.__init__(self, router, nodeDict) self.snoc = SocNOC() self.snoc.send = make_send(self) if '_categories' in self.node: with open('backend/affect.pickle') as affect_file: self.snoc.categories = dict(self.node['_categories'], affect=pickle.load(affect_file))
class TwitterProcess(OneToOneNode): def __init__(self, router, nodeDict): OneToOneNode.__init__(self, router, nodeDict) self.snoc = SocNOC() self.snoc.send = make_send(self) if '_categories' in self.node: with open('backend/affect.pickle') as affect_file: self.snoc.categories = dict(self.node['_categories'], affect=pickle.load(affect_file)) def compute(self, data): self.snoc.receive_tweet(**data)
class BlogProcess(OneToOneNode): def __init__(self, router, nodeDict): OneToOneNode.__init__(self, router, nodeDict) self.snoc = SocNOC(k=10, spicefreq=0, cnetfreq=0) self.snoc.send = make_send(self) if '_categories' in self.node: with open('backend/affect.pickle') as affect_file: self.snoc.categories = dict(self.node['_categories'], affect=pickle.load(affect_file)) def compute(self, data): self.snoc.process_post(**data)
def read(feed, url, tag): try: item = next(feed) except StopIteration: reactor.callLater(random(), get, url, tag) else: post = SocNOC.process_feed_item(item) if isinstance(post, basestring): send(dict(post=post, word=tag)) reactor.callLater(random(), read, feed, url, tag)