BaseTools: Use absolute import in Eot
[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
40d841f6 6# This program and the accompanying materials\r
52302d4d
LG
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18\r
64429fbd 19from __future__ import absolute_import\r
52302d4d 20import re\r
1be2ed90 21import Common.LongFilePathOs as os\r
64429fbd 22from .ParserWarning import Warning\r
1be2ed90 23from Common.LongFilePathSupport import OpenLongFilePath as open\r
52302d4d
LG
24\r
25# Profile contents of a file\r
26PPDirectiveList = []\r
27AssignmentExpressionList = []\r
28PredicateExpressionList = []\r
29FunctionDefinitionList = []\r
30VariableDeclarationList = []\r
31EnumerationDefinitionList = []\r
32StructUnionDefinitionList = []\r
33TypedefDefinitionList = []\r
34FunctionCallingList = []\r
35\r
36## Class FileProfile\r
37#\r
38# record file data when parsing source\r
39#\r
40# May raise Exception when opening file.\r
41#\r
42class FileProfile :\r
43\r
44 ## The constructor\r
45 #\r
46 # @param self: The object pointer\r
47 # @param FileName: The file that to be parsed\r
48 #\r
49 def __init__(self, FileName):\r
50 self.FileLinesList = []\r
51 self.FileLinesListFromFile = []\r
52 try:\r
53 fsock = open(FileName, "rb", 0)\r
54 try:\r
55 self.FileLinesListFromFile = fsock.readlines()\r
56 finally:\r
57 fsock.close()\r
58\r
59 except IOError:\r
60 raise Warning("Error when opening file %s" % FileName)\r