return o.getvalue()
+def ppc(headline, capture, limit=10):
+ """ Return string containing ppp() printout for a capture.
+
+ :param headline: printed as first line of output
+ :param capture: packets to print
+ :param limit: limit the print to # of packets
+ """
+ if not capture:
+ return headline
+ tail = ""
+ if limit < len(capture):
+ tail = "\nPrint limit reached, %s out of %s packets printed" % (
+ len(capture), limit)
+ limit = len(capture)
+ body = "".join([ppp("Packet #%s:" % count, p)
+ for count, p in zip(range(0, limit), capture)])
+ return "%s\n%s%s" % (headline, body, tail)
+
+
class NumericConstant(object):
__metaclass__ = ABCMeta