ppf/new: Add top.py.
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Wed, 24 Aug 2011 15:57:54 +0000 (18:57 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Wed, 24 Aug 2011 15:57:54 +0000 (18:57 +0300)
ppf/new/top.py [new file with mode: 0644]

diff --git a/ppf/new/top.py b/ppf/new/top.py
new file mode 100644 (file)
index 0000000..5c0aa2b
--- /dev/null
@@ -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)