-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathosi2read.py
More file actions
66 lines (51 loc) · 1.59 KB
/
Copy pathosi2read.py
File metadata and controls
66 lines (51 loc) · 1.59 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
This program converts serialized osi trace files into a human readable txth file.
Example usage:
python3 osi2read.py -d trace.osi -o myreadableosifile
"""
from OSITrace import OSITrace
import struct
import lzma
import argparse
import os
def command_line_arguments():
"""Define and handle command line interface"""
dir_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
parser = argparse.ArgumentParser(
description="Convert a serialized osi trace file to a readable txth output.",
prog="osi2read converter",
)
parser.add_argument(
"--data", "-d", help="Path to the file with serialized data.", type=str
)
parser.add_argument(
"--type",
"-t",
help="Name of the type used to serialize data.",
choices=["SensorView", "GroundTruth", "SensorData"],
default="SensorView",
type=str,
required=False,
)
parser.add_argument(
"--output",
"-o",
help="Output name of the file.",
default="converted.txth",
type=str,
required=False,
)
return parser.parse_args()
def main():
# Handling of command line arguments
args = command_line_arguments()
# Initialize the OSI trace class
trace = OSITrace()
trace.from_file(path=args.data, type_name=args.type)
args.output = args.output.split(".", 1)[0] + ".txth"
if args.output == "converted.txth":
args.output = args.data.split(".", 1)[0] + ".txth"
trace.make_readable(args.output)
trace.scenario_file.close()
if __name__ == "__main__":
main()