class LinkedMarkMail: def __init__(self, base="http://linkedmarkmail.wikier.org", log="linkedmarkmail.log"): self.base = base self.api = MarkMail("http://markmail.org") self.cache = Cache() self.cache.register(Post, "message-%s.rdf") self.cache.register(Thread, "thread-%s.rdf") logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s: %(message)s", filename=log) logging.info("Created a new instance of LinkedMarkMail at %s" % datetime.now().strftime("%Y-%m-%d %H:%M:%S")) def search(self, query): search = self.api.search(query) return "" #FIXME def get_message(self, key): if (self.cache.is_cached(key, Post)): logging.info("Recovering message %s from cache..." % key) return self.cache.read(key, Post) else: logging.info("Trying to get message %s from MarkMail..." % key) message = self.api.get_message(key) if (message != None): url = "%s/message/%s" % (self.base, key) post = Post(url, key, message["title"], message["content"]) triples = len(post) #if (not self.cache.is_cached(post.get_key(), post.__class__)): # self.cache.write(post) # logging.info("Updated cache of post %s (%d triples)" % (key, triples)) logging.info("Returning %d triples of post %s" % (triples, key)) return post.get_data_xml() else: logging.error("Post %s not found" % key) return None def get_thread(self, key): logging.info("Trying to get thread %s" % key) thread = self.api.get_thread(key) if (thread != None): siocThread = Thread(self.base, key, thread["subject"], thread["permalink"], thread["atomlink"], thread["messages"]["message"]) triples = len(siocThread) if (self.cache.is_dirty(siocThread)): self.cache.update(siocThread) logging.info("Updated cache of thread %s (%d triples)" % (key, triples)) logging.info("Returning %d triples of thread %s" % (triples, key)) return siocThread.get_data_xml() else: logging.error("Thread %s not found" % key) return None
def __init__(self, base="http://linkedmarkmail.wikier.org", log="linkedmarkmail.log"): self.base = base self.api = MarkMail("http://markmail.org") self.cache = Cache() self.cache.register(Post, "message-%s.rdf") self.cache.register(Thread, "thread-%s.rdf") logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s: %(message)s", filename=log) logging.info("Created a new instance of LinkedMarkMail at %s" % datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
if (info != None): # parsing successful if (info.group('count') == None or int(info.group('count')) == 0): print(info.group('type') + " " + info.group('topic')) print(data) self.topic = None else: if (data == "Subject:"): self.topic = 'subject' #else: #print(data) if __name__ == '__main__': markmail = MarkMail() parser = MyHTMLParser() page = 1 thread_list = [] if (sys.argv[1] == None): exit(1) msg = 'subject:/"' + urllib.parse.quote( sys.argv[1] ) + '/"%20list:com.xensource.lists.xen-devel%20order:date-forward' while True: messages = markmail.search(msg, page) print(json.dumps(messages, indent=4, sort_keys=True))
''' Created on Jul 4, 2013 @author: kinow ''' from markmail import MarkMail if __name__ == '__main__': markmail = MarkMail() messages = markmail.search('list%3Aorg.apache.announce+order%3Adate-backward') print messages