Coverage for pyEDAA/IPXACT/DesignConfiguration.py: 38%

53 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-17 01:13 +0000

1# ==================================================================================================================== # 

2# _____ ____ _ _ ___ ______ __ _ ____ _____ # 

3# _ __ _ _| ____| _ \ / \ / \ |_ _| _ \ \/ / / \ / ___|_ _| # 

4# | '_ \| | | | _| | | | |/ _ \ / _ \ | || |_) \ / / _ \| | | | # 

5# | |_) | |_| | |___| |_| / ___ \ / ___ \ _ | || __// \ / ___ \ |___ | | # 

6# | .__/ \__, |_____|____/_/ \_\/_/ \_(_)___|_| /_/\_\/_/ \_\____| |_| # 

7# |_| |___/ # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2017-2024 Patrick Lehmann - Bötzingen, Germany # 

15# Copyright 2016-2016 Patrick Lehmann - Dresden, 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# 

32from textwrap import dedent 

33 

34from pyTooling.Decorators import export 

35 

36from pyEDAA.IPXACT import RootElement, __DEFAULT_SCHEMA__, Vlnv 

37 

38 

39@export 

40class DesignConfiguration(RootElement): 

41 """Represents an IP-XACT design configuration.""" 

42 

43 def __init__(self, vlnv: Vlnv, description: str): 

44 super().__init__(vlnv) 

45 

46 self._description = description 

47 self._generatorChainConfiguration = None 

48 self._interconnectionConfiguration = None 

49 self._viewConfiguration = None 

50 

51 def SetItem(self, item): 

52 if isinstance(item, GeneratorChainConfiguration): 

53 self._generatorChainConfiguration = item 

54 elif isinstance(item, InterconnectionConfiguration): 

55 self._interconnectionConfiguration = item 

56 elif isinstance(item, ViewConfiguration): 

57 self._viewConfiguration = item 

58 else: 

59 raise ValueError() 

60 

61 def ToXml(self) -> str: 

62 """Converts the object's data into XML format.""" 

63 

64 buffer = dedent("""\ 

65 <?xml version="1.0" encoding="UTF-8"?> 

66 <{xmlns}:designConfiguration 

67 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

68 xmlns:{xmlns}="{schemaUri}" 

69 xsi:schemaLocation="{schemaUri} {schemaUrl}"> 

70 {versionedIdentifier} 

71 <{xmlns}:description>{description}</{xmlns}:description> 

72 """).format( 

73 xmlns=__DEFAULT_SCHEMA__.NamespacePrefix, 

74 schemaUri=__DEFAULT_SCHEMA__.SchemaUri, 

75 schemaUrl=__DEFAULT_SCHEMA__.SchemaUrl, 

76 versionedIdentifier=self._vlnv.ToXml(isVersionedIdentifier=True), 

77 description=self._description 

78 ) 

79 

80 if self._generatorChainConfiguration: 

81 buffer += "\t<{xmlns}:componentInstances>\n" 

82 buffer += self._generatorChainConfiguration.ToXml(2) 

83 buffer += "\t</{xmlns}:componentInstances>\n" 

84 

85 if self._interconnectionConfiguration: 

86 buffer += "\t<{xmlns}:interconnectionConfiguration>\n" 

87 buffer += self._interconnectionConfiguration.ToXml(2) 

88 buffer += "\t</{xmlns}:interconnectionConfiguration>\n" 

89 

90 if self._viewConfiguration: 

91 buffer += "\t<{xmlns}:viewConfiguration>\n" 

92 buffer += self._viewConfiguration.ToXml(2) 

93 buffer += "\t</{xmlns}:viewConfiguration>\n" 

94 

95 buffer += dedent("""\ 

96 </{xmlns}:designConfiguration> 

97 """) 

98 

99 return buffer.format(xmlns=__DEFAULT_SCHEMA__.NamespacePrefix) 

100 

101 

102@export 

103class GeneratorChainConfiguration: 

104 """Represents an IP-XACT generator chain configuration.""" 

105 

106 def __init__(self) -> None: 

107 pass 

108 

109 def ToXml(self, indent=0): 

110 """Converts the object's data into XML format.""" 

111 

112 return "" 

113 

114 

115@export 

116class InterconnectionConfiguration: 

117 """Represents an IP-XACT interconnection configuration.""" 

118 

119 def __init__(self) -> None: 

120 pass 

121 

122 def ToXml(self, indent=0): 

123 """Converts the object's data into XML format.""" 

124 

125 return "" 

126 

127 

128@export 

129class ViewConfiguration: 

130 """Represents an IP-XACT view configuration.""" 

131 

132 def __init__(self) -> None: 

133 pass 

134 

135 def ToXml(self, indent=0): 

136 """Converts the object's data into XML format.""" 

137 

138 return ""