File: __main__.py

package info (click to toggle)
python-pgpdump 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 244 kB
  • ctags: 145
  • sloc: python: 1,305; makefile: 21
file content (27 lines) | stat: -rw-r--r-- 596 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys

from . import AsciiData, BinaryData


def parsefile(name):
    with open(name, 'rb') as infile:
        if name.endswith('.asc'):
            data = AsciiData(infile.read())
        else:
            data = BinaryData(infile.read())
    counter = length = 0
    for packet in data.packets():
        counter += 1
        length += packet.length
    print('%d packets, length %d' % (counter, length))


def main():
    for filename in sys.argv[1:]:
        parsefile(filename)


if __name__ == '__main__':
    #import cProfile
    #cProfile.run('main()', 'pgpdump.profile')
    main()