File: __main__.py

package info (click to toggle)
python-pgpdump 1.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 284 kB
  • sloc: python: 1,360; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (4)
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
28
29
30
import sys

from . import AsciiData, BinaryData


def parsefile(name):
    with open(name, 'rb') as infile:
        if name.endswith('.asc') or name.endswith('.txt'):
            data = AsciiData(infile.read())
        else:
            data = BinaryData(infile.read())

    for packet in data.packets():
        yield packet


def main():
    counter = length = 0
    for filename in sys.argv[1:]:
        for packet in parsefile(filename):
            counter += 1
            length += packet.length

    print('%d packets, length %d' % (counter, length))


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