MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / IniToXml

Function IniToXml

BaseTools/Source/Python/UPT/Xml/IniToXml.py:288–419  ·  view source on GitHub ↗
(IniFile)

Source from the content-addressed store, hash-verified

286# @param IniFile
287#
288def IniToXml(IniFile):
289 if not os.path.exists(IniFile):
290 Logger.Error("UPT", FILE_NOT_FOUND, ST.ERR_TEMPLATE_NOTFOUND % IniFile)
291
292 DistMap = {'ReadOnly' : '', 'RePackage' : '', 'Name' : '',
293 'BaseName' : '', 'GUID' : '', 'Version' : '', 'Vendor' : '',
294 'Date' : '', 'Copyright' : '', 'License' : '', 'Abstract' : '',
295 'Description' : '', 'Signature' : '', 'XmlSpecification' : ''
296 }
297
298 ToolsMap = {'Name' : '', 'Copyright' : '', 'License' : '',
299 'Abstract' : '', 'Description' : '', 'FileList' : []}
300 #
301 # Only FileList is a list: [['file1', {}], ['file2', {}], ...]
302 #
303 MiscMap = {'Name' : '', 'Copyright' : '', 'License' : '',
304 'Abstract' : '', 'Description' : '', 'FileList' : []}
305
306 SectionMap = {
307 'DistributionHeader' : DistMap,
308 'ToolsHeader' : ToolsMap,
309 'MiscellaneousFilesHeader' : MiscMap
310 }
311
312 PathValidator = {
313 'ToolsHeader' : ValidateToolsFile,
314 'MiscellaneousFilesHeader' : ValidateMiscFile
315 }
316
317 ParsedSection = []
318
319 SectionName = ''
320 CurrentKey = ''
321 PreMap = None
322 Map = None
323 FileContent = ConvertSpecialChar(open(IniFile, 'r').readlines())
324 LastIndex = 0
325 for Index in range(0, len(FileContent)):
326 LastIndex = Index
327 Line = FileContent[Index].strip()
328 if Line == '' or Line.startswith(';'):
329 continue
330 if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END:
331 CurrentKey = ''
332 SectionName = Line[1:-1].strip()
333 if SectionName not in SectionMap:
334 IniParseError(ST.ERR_SECTION_NAME_INVALID % SectionName,
335 IniFile, Index+1)
336
337 if SectionName in ParsedSection:
338 IniParseError(ST.ERR_SECTION_REDEFINE % SectionName,
339 IniFile, Index+1)
340 else:
341 ParsedSection.append(SectionName)
342
343 Map = SectionMap[SectionName]
344 continue
345 if not Map:

Callers 1

MainFunction · 0.90

Calls 8

ConvertSpecialCharFunction · 0.90
lenFunction · 0.85
IniParseErrorFunction · 0.85
ParseFileListFunction · 0.85
ValidateValuesFunction · 0.85
CheckMdtKeysFunction · 0.85
CreateXmlFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected