1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4# Copyright (c) 2021-2024 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 18from pathlib import Path 19from typing import Tuple 20 21from runner.plugins.ets.utils.constants import NEGATIVE_PREFIX, NEGATIVE_EXECUTION_PREFIX, SKIP_PREFIX 22 23 24def is_negative(path: Path) -> bool: 25 return path.name.startswith(NEGATIVE_PREFIX) or path.name.startswith(NEGATIVE_EXECUTION_PREFIX) 26 27 28def should_be_skipped(path: Path) -> bool: 29 return path.name.startswith(SKIP_PREFIX) 30 31 32def strip_template(path: Path) -> Tuple[str, int]: 33 stem = path.stem 34 i = path.stem.rfind("_") 35 if i == -1: 36 return stem, 0 37 template_name = stem[:i] 38 test_index = stem[i + 1:] 39 if not test_index.isdigit(): 40 return stem, 0 41 return template_name, int(test_index) 42