1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4# Copyright (c) 2021-2023 Huawei Device Co., Ltd. 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17# This file does only contain a selection of the most common options. For a 18# full list see the documentation: 19# http://www.sphinx-doc.org/en/master/config 20 21from functools import cached_property 22from pathlib import Path 23from runner.options.options_general import GeneralOptions 24from runner.code_coverage.coverage_dir import CoverageDir 25 26 27class WorkDir: 28 def __init__(self, general: GeneralOptions, default_work_dir: Path): 29 self.__general = general 30 self.__default_work_dir = default_work_dir 31 32 @cached_property 33 def root(self) -> Path: 34 root = Path(self.__general.work_dir) if self.__general.work_dir else self.__default_work_dir 35 root.mkdir(parents=True, exist_ok=True) 36 return root 37 38 @property 39 def report(self) -> Path: 40 return self.root / "report" 41 42 @property 43 def gen(self) -> Path: 44 return self.root / "gen" 45 46 @property 47 def intermediate(self) -> Path: 48 return self.root / "intermediate" 49 50 @cached_property 51 def coverage_dir(self) -> CoverageDir: 52 return CoverageDir(self.__general, self.root) 53