Move metadata to dedicated module
This commit is contained in:
parent
b9fd0b014b
commit
ff24d7e424
59
src/rosbags/rosbag2/metadata.py
Normal file
59
src/rosbags/rosbag2/metadata.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2020-2022 Ternaris.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""Rosbag2 metadata."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
class StartingTime(TypedDict):
|
||||
"""Bag starting time."""
|
||||
|
||||
nanoseconds_since_epoch: int
|
||||
|
||||
|
||||
class Duration(TypedDict):
|
||||
"""Bag starting time."""
|
||||
|
||||
nanoseconds: int
|
||||
|
||||
|
||||
class TopicMetadata(TypedDict):
|
||||
"""Topic metadata."""
|
||||
|
||||
name: str
|
||||
type: str
|
||||
serialization_format: str
|
||||
offered_qos_profiles: str
|
||||
|
||||
|
||||
class TopicWithMessageCount(TypedDict):
|
||||
"""Topic with message count."""
|
||||
|
||||
message_count: int
|
||||
topic_metadata: TopicMetadata
|
||||
|
||||
|
||||
class FileInformation(TypedDict):
|
||||
"""Per file metadata."""
|
||||
|
||||
path: str
|
||||
starting_time: StartingTime
|
||||
duration: Duration
|
||||
message_count: int
|
||||
|
||||
|
||||
class Metadata(TypedDict):
|
||||
"""Rosbag2 metadata file."""
|
||||
|
||||
version: int
|
||||
storage_identifier: str
|
||||
relative_file_paths: list[str]
|
||||
starting_time: StartingTime
|
||||
duration: Duration
|
||||
message_count: int
|
||||
compression_format: str
|
||||
compression_mode: str
|
||||
topics_with_message_count: list[TopicWithMessageCount]
|
||||
files: list[FileInformation]
|
||||
@ -18,53 +18,9 @@ from rosbags.interfaces import Connection, ConnectionExtRosbag2, TopicInfo
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import TracebackType
|
||||
from typing import Any, Generator, Iterable, Literal, Optional, Type, TypedDict, Union
|
||||
from typing import Any, Generator, Iterable, Literal, Optional, Type, Union
|
||||
|
||||
class StartingTime(TypedDict):
|
||||
"""Bag starting time."""
|
||||
|
||||
nanoseconds_since_epoch: int
|
||||
|
||||
class Duration(TypedDict):
|
||||
"""Bag starting time."""
|
||||
|
||||
nanoseconds: int
|
||||
|
||||
class TopicMetadata(TypedDict):
|
||||
"""Topic metadata."""
|
||||
|
||||
name: str
|
||||
type: str
|
||||
serialization_format: str
|
||||
offered_qos_profiles: str
|
||||
|
||||
class TopicWithMessageCount(TypedDict):
|
||||
"""Topic with message count."""
|
||||
|
||||
message_count: int
|
||||
topic_metadata: TopicMetadata
|
||||
|
||||
class FileInformation(TypedDict):
|
||||
"""Per file metadata."""
|
||||
|
||||
path: str
|
||||
starting_time: StartingTime
|
||||
duration: Duration
|
||||
message_count: int
|
||||
|
||||
class Metadata(TypedDict):
|
||||
"""Rosbag2 metadata file."""
|
||||
|
||||
version: int
|
||||
storage_identifier: str
|
||||
relative_file_paths: list[str]
|
||||
starting_time: StartingTime
|
||||
duration: Duration
|
||||
message_count: int
|
||||
compression_format: str
|
||||
compression_mode: str
|
||||
topics_with_message_count: list[TopicWithMessageCount]
|
||||
files: list[FileInformation]
|
||||
from .metadata import FileInformation, Metadata
|
||||
|
||||
|
||||
class ReaderError(Exception):
|
||||
|
||||
@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
||||
from types import TracebackType
|
||||
from typing import Any, Literal, Optional, Type, Union
|
||||
|
||||
from .reader import Metadata
|
||||
from .metadata import Metadata
|
||||
|
||||
|
||||
class WriterError(Exception):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user