Source code for launch.substitutions.launch_log_dir

# Copyright 2022 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Module for the LaunchLogDir substitution."""

from typing import Any
from typing import Dict
from typing import Sequence
from typing import Text
from typing import Tuple
from typing import Type

from .path_join_substitution import PathSubstitution
from ..frontend.expose import expose_substitution
from ..launch_context import LaunchContext
from ..logging import launch_config as launch_logging_config
from ..some_substitutions_type import SomeSubstitutionsType


[docs] @expose_substitution('launch_log_dir') @expose_substitution('log_dir') class LaunchLogDir(PathSubstitution): """Substitution that returns the absolute path to the current launch log directory."""
[docs] def __init__(self) -> None: """Create a LaunchLogDir substitution.""" super().__init__(path=self)
[docs] @classmethod def parse(cls, data: Sequence[SomeSubstitutionsType] ) -> Tuple[Type['LaunchLogDir'], Dict[Any, Any]]: """Parse `LaunchLogDir` substitution.""" if len(data) != 0: raise TypeError("launch_log_dir/log_dir substitution doesn't expect arguments") return cls, {}
[docs] def describe(self) -> Text: """Return a description of this substitution as a string.""" return 'LaunchLogDir()'
[docs] def perform(self, context: LaunchContext) -> Text: """Perform the substitution by returning the path to the current launch log directory.""" return launch_logging_config.log_dir