]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py
BaseTools: Remove the deprecated hash_key()
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Object / Parser / InfUserExtensionObject.py
CommitLineData
4234283c
LG
1## @file\r
2# This file is used to define class objects of INF file [UserExtension] section. \r
3# It will consumed by InfParser. \r
4#\r
5# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
6#\r
7# This program and the accompanying materials are licensed and made available \r
8# under the terms and conditions of the BSD License which accompanies this \r
9# distribution. The full text of the license may be found at \r
10# http://opensource.org/licenses/bsd-license.php\r
11#\r
12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15'''\r
16InfUserExtensionsObject\r
17'''\r
18\r
19from Logger import StringTable as ST\r
20from Logger import ToolError\r
21import Logger.Log as Logger\r
22from Library import GlobalData \r
23\r
24from Library.Misc import Sdict\r
25\r
26class InfUserExtensionItem():\r
27 def __init__(self,\r
28 Content = '',\r
29 UserId = '',\r
30 IdString = ''):\r
31 self.Content = Content\r
32 self.UserId = UserId\r
33 self.IdString = IdString\r
34 self.SupArchList = []\r
35 \r
36 def SetContent(self, Content):\r
37 self.Content = Content\r
38 def GetContent(self):\r
39 return self.Content\r
40 \r
41 def SetUserId(self, UserId):\r
42 self.UserId = UserId\r
43 def GetUserId(self):\r
44 return self.UserId\r
45 \r
46 def SetIdString(self, IdString):\r
47 self.IdString = IdString\r
48 def GetIdString(self):\r
49 return self.IdString\r
50 \r
51 def SetSupArchList(self, SupArchList):\r
52 self.SupArchList = SupArchList\r
53 def GetSupArchList(self):\r
54 return self.SupArchList\r
55 \r
56##\r
57#\r
58#\r
59#\r
60class InfUserExtensionObject():\r
61 def __init__(self):\r
62 self.UserExtension = Sdict()\r
63 \r
64 def SetUserExtension(self, UserExtensionCont, IdContent=None, LineNo=None):\r
65 if not UserExtensionCont or UserExtensionCont == '':\r
66 return True\r
67 #\r
68 # IdContent is a list contain UserId and IdString \r
69 # For this call the general section header parser, if no definition of\r
70 # IdString/UserId, it will return 'COMMON'\r
71 #\r
72 for IdContentItem in IdContent: \r
73 InfUserExtensionItemObj = InfUserExtensionItem()\r
74 if IdContentItem[0] == 'COMMON':\r
75 UserId = ''\r
76 else:\r
77 UserId = IdContentItem[0]\r
78 \r
79 if IdContentItem[1] == 'COMMON':\r
80 IdString = ''\r
81 else:\r
82 IdString = IdContentItem[1] \r
83 \r
84 #\r
85 # Fill UserExtensionObj members.\r
86 # \r
87 InfUserExtensionItemObj.SetUserId(UserId)\r
88 InfUserExtensionItemObj.SetIdString(IdString)\r
89 InfUserExtensionItemObj.SetContent(UserExtensionCont)\r
90 InfUserExtensionItemObj.SetSupArchList(IdContentItem[2]) \r
91 \r
4afd3d04
LG
92# for CheckItem in self.UserExtension:\r
93# if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:\r
94# if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':\r
95# #\r
96# # For COMMON ARCH type, do special check.\r
97# #\r
98# Logger.Error('InfParser', \r
99# ToolError.FORMAT_INVALID,\r
100# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\\r
101# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),\r
102# File=GlobalData.gINF_MODULE_NAME, \r
103# Line=LineNo,\r
104# ExtraData=None)\r
4234283c 105 \r
27c4ceb4 106 if IdContentItem in self.UserExtension:\r
4234283c
LG
107 #\r
108 # Each UserExtensions section header must have a unique set \r
109 # of UserId, IdString and Arch values.\r
110 # This means that the same UserId can be used in more than one \r
111 # section header, provided the IdString or Arch values are \r
112 # different. The same IdString values can be used in more than \r
113 # one section header if the UserId or Arch values are \r
114 # different. The same UserId and the same IdString can be used \r
115 # in a section header if the Arch values are different in each \r
116 # of the section headers.\r
117 #\r
118 Logger.Error('InfParser', \r
119 ToolError.FORMAT_INVALID,\r
120 ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\\r
121 (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),\r
122 File=GlobalData.gINF_MODULE_NAME, \r
123 Line=LineNo,\r
124 ExtraData=None)\r
125 else:\r
126 UserExtensionList = []\r
127 UserExtensionList.append(InfUserExtensionItemObj)\r
128 self.UserExtension[IdContentItem] = UserExtensionList\r
129 \r
130 return True\r
131 \r
132 def GetUserExtension(self):\r
27c4ceb4 133 return self.UserExtension\r