]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Eot/FileProfile.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / Eot / FileProfile.py
CommitLineData
52302d4d
LG
1## @file\r
2# fragments of source file\r
3#\r
1be2ed90 4# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
52302d4d 5#\r
2e351cbe 6# SPDX-License-Identifier: BSD-2-Clause-Patent\r
52302d4d
LG
7#\r
8\r
9##\r
10# Import Modules\r
11#\r
12\r
64429fbd 13from __future__ import absolute_import\r
52302d4d 14import re\r
1be2ed90 15import Common.LongFilePathOs as os\r
64429fbd 16from .ParserWarning import Warning\r
1be2ed90 17from Common.LongFilePathSupport import OpenLongFilePath as open\r
52302d4d
LG
18\r
19# Profile contents of a file\r
20PPDirectiveList = []\r
21AssignmentExpressionList = []\r
22PredicateExpressionList = []\r
23FunctionDefinitionList = []\r
24VariableDeclarationList = []\r
25EnumerationDefinitionList = []\r
26StructUnionDefinitionList = []\r
27TypedefDefinitionList = []\r
28FunctionCallingList = []\r
29\r
30## Class FileProfile\r
31#\r
32# record file data when parsing source\r
33#\r
34# May raise Exception when opening file.\r
35#\r
36class FileProfile :\r
37\r
38 ## The constructor\r
39 #\r
40 # @param self: The object pointer\r
41 # @param FileName: The file that to be parsed\r
42 #\r
43 def __init__(self, FileName):\r
44 self.FileLinesList = []\r
45 self.FileLinesListFromFile = []\r
46 try:\r
47 fsock = open(FileName, "rb", 0)\r
48 try:\r
49 self.FileLinesListFromFile = fsock.readlines()\r
50 finally:\r
51 fsock.close()\r
52\r
53 except IOError:\r
54 raise Warning("Error when opening file %s" % FileName)\r