1 # Copyright (c) 2019 Collabora Ltd
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the "Software"),
5 # to deal in the Software without restriction, including without limitation
6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 # and/or sell copies of the Software, and to permit persons to whom the
8 # Software is furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included
11 # in all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19 # OTHER DEALINGS IN THE SOFTWARE.
21 # SPDX-License-Identifier: MIT
24 from pathlib
import Path
25 from enum
import Enum
, auto
27 class TraceType(Enum
):
33 _trace_type_info_map
= {
34 TraceType
.APITRACE
: ("apitrace", ".trace"),
35 TraceType
.RENDERDOC
: ("renderdoc", ".rdc"),
36 TraceType
.TESTTRACE
: ("testtrace", ".testtrace")
39 def all_trace_type_names():
41 for t
,(name
, ext
) in _trace_type_info_map
.items():
42 if t
!= TraceType
.UNKNOWN
:
46 def trace_type_from_name(tt_name
):
47 for t
,(name
, ext
) in _trace_type_info_map
.items():
51 return TraceType
.UNKNOWN
53 def trace_type_from_filename(trace_file
):
54 for t
,(name
, ext
) in _trace_type_info_map
.items():
55 if trace_file
.endswith(ext
):
58 return TraceType
.UNKNOWN