Attributes.py

Summary

Lines:

13 of 13 covered (100.0%)

Coverage:

100.0%

Directory:

ProjectModel

Source

pyEDAA/ProjectModel/Attributes.pycoveredpartialuncoveredexcludednot executable
1# ==================================================================================================================== #
2#               _____ ____    _        _      ____            _           _   __  __           _      _                #
3#   _ __  _   _| ____|  _ \  / \      / \    |  _ \ _ __ ___ (_) ___  ___| |_|  \/  | ___   __| | ___| |               #
4#  | '_ \| | | |  _| | | | |/ _ \    / _ \   | |_) | '__/ _ \| |/ _ \/ __| __| |\/| |/ _ \ / _` |/ _ \ |               #
5#  | |_) | |_| | |___| |_| / ___ \  / ___ \ _|  __/| | | (_) | |  __/ (__| |_| |  | | (_) | (_| |  __/ |               #
6#  | .__/ \__, |_____|____/_/   \_\/_/   \_(_)_|   |_|  \___// |\___|\___|\__|_|  |_|\___/ \__,_|\___|_|               #
7#  |_|    |___/                                            |__/                                                        #
8# ==================================================================================================================== #
9# Authors:                                                                                                             #
10#   Patrick Lehmann                                                                                                    #
11#                                                                                                                      #
12# License:                                                                                                             #
13# ==================================================================================================================== #
14# Copyright 2021-2026 Electronic Design Automation Abstraction (EDA²)                                                  #
15# Copyright 2017-2020 Patrick Lehmann - Boetzingen, Germany                                                            #
16#                                                                                                                      #
17# Licensed under the Apache License, Version 2.0 (the "License");                                                      #
18# you may not use this file except in compliance with the License.                                                     #
19# You may obtain a copy of the License at                                                                              #
20#                                                                                                                      #
21#   http://www.apache.org/licenses/LICENSE-2.0                                                                         #
22#                                                                                                                      #
23# Unless required by applicable law or agreed to in writing, software                                                  #
24# distributed under the License is distributed on an "AS IS" BASIS,                                                    #
25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                                             #
26# See the License for the specific language governing permissions and                                                  #
27# limitations under the License.                                                                                       #
28#                                                                                                                      #
29# SPDX-License-Identifier: Apache-2.0                                                                                  #
30# ==================================================================================================================== #
31#
32"""A set of common attributes to store meta information on ProjectModel entities (project, design, fileset, file, ...)."""
33from typing               import Dict
34from pyTooling.Decorators import export
35
36from pyEDAA.ProjectModel  import Attribute
37
38
39@export
40class KeyValueAttribute(Attribute):
41	KEY = "ID"
42
43	_keyValuePairs: Dict[str, str]
44
45	def __init__(self) -> None:
46		super().__init__()
47
48		self._keyValuePairs = {}
49
50	def __getitem__(self, item: str) -> str:
51		return self._keyValuePairs[item]
52
53	def __setitem__(self, key: str, value: str) -> None:
54		self._keyValuePairs[key] = value