]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Object / Parser / InfUserExtensionObject.py
CommitLineData
4234283c 1## @file\r
f7496d71
LG
2# This file is used to define class objects of INF file [UserExtension] section.\r
3# It will consumed by InfParser.\r
4234283c 4#\r
f7496d71 5# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
4234283c 6#\r
f7496d71
LG
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
4234283c
LG
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
f7496d71 22from Library import GlobalData\r
4234283c
LG
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
f7496d71 35\r
4234283c
LG
36 def SetContent(self, Content):\r
37 self.Content = Content\r
38 def GetContent(self):\r
39 return self.Content\r
f7496d71 40\r
4234283c
LG
41 def SetUserId(self, UserId):\r
42 self.UserId = UserId\r
43 def GetUserId(self):\r
44 return self.UserId\r
f7496d71 45\r
4234283c
LG
46 def SetIdString(self, IdString):\r
47 self.IdString = IdString\r
48 def GetIdString(self):\r
49 return self.IdString\r
f7496d71 50\r
4234283c
LG
51 def SetSupArchList(self, SupArchList):\r
52 self.SupArchList = SupArchList\r
53 def GetSupArchList(self):\r
54 return self.SupArchList\r
f7496d71 55\r
4234283c
LG
56##\r
57#\r
58#\r
59#\r
60class InfUserExtensionObject():\r
61 def __init__(self):\r
62 self.UserExtension = Sdict()\r
f7496d71 63\r
4234283c
LG
64 def SetUserExtension(self, UserExtensionCont, IdContent=None, LineNo=None):\r
65 if not UserExtensionCont or UserExtensionCont == '':\r
66 return True\r
67 #\r
f7496d71 68 # IdContent is a list contain UserId and IdString\r
4234283c
LG
69 # For this call the general section header parser, if no definition of\r
70 # IdString/UserId, it will return 'COMMON'\r
71 #\r
f7496d71 72 for IdContentItem in IdContent:\r
4234283c
LG
73 InfUserExtensionItemObj = InfUserExtensionItem()\r
74 if IdContentItem[0] == 'COMMON':\r
75 UserId = ''\r
76 else:\r
77 UserId = IdContentItem[0]\r
f7496d71 78\r
4234283c
LG
79 if IdContentItem[1] == 'COMMON':\r
80 IdString = ''\r
81 else:\r
f7496d71
LG
82 IdString = IdContentItem[1]\r
83\r
4234283c
LG
84 #\r
85 # Fill UserExtensionObj members.\r
f7496d71 86 #\r
4234283c
LG
87 InfUserExtensionItemObj.SetUserId(UserId)\r
88 InfUserExtensionItemObj.SetIdString(IdString)\r
89 InfUserExtensionItemObj.SetContent(UserExtensionCont)\r
f7496d71
LG
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
f7496d71 98# Logger.Error('InfParser',\r
4afd3d04
LG
99# ToolError.FORMAT_INVALID,\r
100# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\\r
101# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),\r
f7496d71 102# File=GlobalData.gINF_MODULE_NAME,\r
4afd3d04
LG
103# Line=LineNo,\r
104# ExtraData=None)\r
f7496d71 105\r
27c4ceb4 106 if IdContentItem in self.UserExtension:\r
4234283c 107 #\r
f7496d71 108 # Each UserExtensions section header must have a unique set\r
4234283c 109 # of UserId, IdString and Arch values.\r
f7496d71
LG
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
4234283c
LG
116 # of the section headers.\r
117 #\r
f7496d71 118 Logger.Error('InfParser',\r
4234283c
LG
119 ToolError.FORMAT_INVALID,\r
120 ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\\r
121 (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),\r
f7496d71 122 File=GlobalData.gINF_MODULE_NAME,\r
4234283c
LG
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
f7496d71 129\r
4234283c 130 return True\r
f7496d71 131\r
4234283c 132 def GetUserExtension(self):\r
27c4ceb4 133 return self.UserExtension\r