From: Razvan Deaconescu Date: Wed, 24 Aug 2011 15:57:54 +0000 (+0300) Subject: ppf/new: Add top.py. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=4855a691e8828247ef81fe9fad7e761675bd5f02;p=cs-p2p-next.git ppf/new: Add top.py. --- diff --git a/ppf/new/top.py b/ppf/new/top.py new file mode 100644 index 0000000..5c0aa2b --- /dev/null +++ b/ppf/new/top.py @@ -0,0 +1,27 @@ +""" +Top level functions for parsing and storing information. + +2011, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro +""" + +import storage +import parsing + +def parse_store_session(writer, parser, session_id): + """ + Parse and store information for a BitTorrent session. + + writer is an instance of the storage.SwarmWriter class. + parser is an instance of the parsing.LogParser class (may be + LibtorrentLogParser, TriblerLogParser or some other). + session_id is the client session id. + """ + + while True: + msg = parser.get_next_message() + # In case of no more messages, exit loop. + if msg == None: + break + + msg.set_client_session_id(session_id) + writer.add_message(msg)