Skip to content
Browse files

add EasyParsePcap function to handle boilerplate.

  • Loading branch information...
1 parent 951b728 commit 36232651e9309969375a25217e4fdc504955fa74 Andrew Fleenor committed Jul 17, 2012
Showing with 11 additions and 3 deletions.
  1. +1 −3 main.py
  2. +10 −0 pcap2har/pcap.py
View
4 main.py
@@ -56,9 +56,7 @@
logging.info("Processing %s", inputfile)
# parse pcap file
-dispatcher = PacketDispatcher()
-pcap.ParsePcap(dispatcher, filename=inputfile)
-dispatcher.finish()
+dispatcher = pcap.EasyParsePcap(filename=inputfile)
# parse HAR stuff
session = httpsession.HttpSession(dispatcher)
View
10 pcap2har/pcap.py
@@ -68,3 +68,13 @@ def ParsePcap(dispatcher, filename=None, reader=None):
log.warning('A packet in the pcap file was too short, '
'packet_count=%d' % packet_count)
errors.append((None, error))
+
+
+def EasyParsePcap(filename=None, reader=None):
+ '''
+ Like ParsePcap, but makes and returns a PacketDispatcher for you.
+ '''
+ dispatcher = PacketDispatcher()
+ ParsePcap(dispatcher, filename=filename, reader=reader)
+ dispatcher.finish()
+ return dispatcher

0 comments on commit 3623265

Please sign in to comment.
Something went wrong with that request. Please try again.