| 1 |
|
| 2 |
|
| 3 |
import ais |
| 4 |
import sys |
| 5 |
import ais.compatibility.gpsd |
| 6 |
import ais.stream |
| 7 |
|
| 8 |
args = {} |
| 9 |
files = [] |
| 10 |
for arg in sys.argv[1:]: |
| 11 |
if arg.startswith("--"): |
| 12 |
arg = arg[2:] |
| 13 |
if '=' in arg: |
| 14 |
arg, value = arg.split("=", 1) |
| 15 |
args[arg] = value |
| 16 |
else: |
| 17 |
args[arg] = True |
| 18 |
else: |
| 19 |
files.append(arg) |
| 20 |
|
| 21 |
if "help" in args: |
| 22 |
print """Usage: collecttypes.py < INFILE.nmea > OUTFILE.nmea |
| 23 |
|
| 24 |
Collects one message of each type. |
| 25 |
""" |
| 26 |
sys.exit(0) |
| 27 |
|
| 28 |
types = set() |
| 29 |
for msg in ais.stream.decode(sys.stdin, keep_nmea=True, allowUnknown=True, allow_missing_timestamps=True): |
| 30 |
if msg['id'] in types: continue |
| 31 |
types.add(msg['id']) |
| 32 |
sys.stdout.write(msg['nmea']) |