diff options
author | Pierre Gondois <pierre.gondois@arm.com> | 2025-04-30 14:40:15 +0200 |
---|---|---|
committer | Liming Gao <gaoliming@byosoft.com.cn> | 2025-07-01 09:51:38 +0800 |
commit | 3c2f04a3c7e2058f7f0b784f365aa39e52237b44 (patch) | |
tree | 5a5274db946e34291bb503139e74ff8c056d4722 /BaseTools/Source/Python/Eot | |
parent | 7402bd06cfa88a93a416a1edff7e7f9283ee18ed (diff) | |
download | edk2-3c2f04a3c7e2058f7f0b784f365aa39e52237b44.zip edk2-3c2f04a3c7e2058f7f0b784f365aa39e52237b44.tar.gz edk2-3c2f04a3c7e2058f7f0b784f365aa39e52237b44.tar.bz2 |
BaseTools: Eot: Remove unnecessary code
Running the vulture tool on the Eot folder gave the following
report. Remove the unnecessary code.
- Eot/CodeFragment.py:47:
unused class 'AssignmentExpression' (60% confidence)
- Eot/CodeFragmentCollector.py:75:
unused attribute '__Token' (60% confidence)
- Eot/CodeFragmentCollector.py:76:
unused attribute '__SkippedChars' (60% confidence)
- Eot/CodeFragmentCollector.py:104:
unused method '__EndOfLine' (60% confidence)
- Eot/CodeFragmentCollector.py:129:
unused method '__UndoOneChar' (60% confidence)
- Eot/CodeFragmentCollector.py:215:
unused method '__InsertComma' (60% confidence)
- Eot/Database.py:81:
unused attribute 'text_factory' (60% confidence)
- Eot/EotMain.py:1012:
unused method 'SetFreeSpace' (60% confidence)
- Eot/Identification.py:36:
unused method 'GetFileFullPath' (60% confidence)
- Eot/Identification.py:43:
unused method 'GetFileRelativePath' (60% confidence)
- Eot/Parser.py:119:
unused function 'AddToGlobalMacro' (60% confidence)
- Eot/Parser.py:238:
unused function 'GetAllSourceFiles' (60% confidence)
- Eot/Parser.py:257:
unused function 'ParseConditionalStatementMacros' (60% confidence)
- Eot/Parser.py:267:
unused function 'GetAllFiles' (60% confidence)
- Eot/Parser.py:291:
unused function 'ParseConditionalStatement' (60% confidence)
- Eot/Parser.py:367:
unused function 'GetConditionalStatementStatus' (60% confidence)
- Eot/Parser.py:722:
unused function 'ConvertGuid' (60% confidence)
- Eot/Parser.py:857:
unused function 'ConvertGuid2' (60% confidence)
- Eot/Report.py:161:
unused method 'GeneratePpi' (60% confidence)
- Eot/Report.py:173:
unused method 'GenerateProtocol' (60% confidence)
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Diffstat (limited to 'BaseTools/Source/Python/Eot')
-rw-r--r-- | BaseTools/Source/Python/Eot/CodeFragment.py | 18 | ||||
-rw-r--r-- | BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 63 | ||||
-rw-r--r-- | BaseTools/Source/Python/Eot/Database.py | 1 | ||||
-rw-r--r-- | BaseTools/Source/Python/Eot/EotMain.py | 3 | ||||
-rw-r--r-- | BaseTools/Source/Python/Eot/Identification.py | 14 | ||||
-rw-r--r-- | BaseTools/Source/Python/Eot/Parser.py | 185 | ||||
-rw-r--r-- | BaseTools/Source/Python/Eot/Report.py | 24 |
7 files changed, 0 insertions, 308 deletions
diff --git a/BaseTools/Source/Python/Eot/CodeFragment.py b/BaseTools/Source/Python/Eot/CodeFragment.py index 94c3f52..ec73fc4 100644 --- a/BaseTools/Source/Python/Eot/CodeFragment.py +++ b/BaseTools/Source/Python/Eot/CodeFragment.py @@ -41,24 +41,6 @@ class PP_Directive : self.StartPos = Begin
self.EndPos = End
-## The description of assignment expression and start & end position
-#
-#
-class AssignmentExpression :
- ## The constructor
- #
- # @param self The object pointer
- # @param Str The message to record
- # @param Begin The start position tuple.
- # @param End The end position tuple.
- #
- def __init__(self, Lvalue, Op, Exp, Begin, End):
- self.Name = Lvalue
- self.Operator = Op
- self.Value = Exp
- self.StartPos = Begin
- self.EndPos = End
-
## The description of predicate expression and start & end position
#
#
diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py index a5c1cee..a6827c0 100644 --- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py @@ -72,9 +72,6 @@ class CodeFragmentCollector: self.CurrentLineNumber = 1
self.CurrentOffsetWithinLine = 0
- self.__Token = ""
- self.__SkippedChars = ""
-
## __EndOfFile() method
#
# Judge current buffer pos is at file end
@@ -93,21 +90,6 @@ class CodeFragmentCollector: else:
return False
- ## __EndOfLine() method
- #
- # Judge current buffer pos is at line end
- #
- # @param self The object pointer
- # @retval True Current File buffer position is at line end
- # @retval False Current File buffer position is NOT at line end
- #
- def __EndOfLine(self):
- SizeOfCurrentLine = len(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
- if self.CurrentOffsetWithinLine >= SizeOfCurrentLine - 1:
- return True
- else:
- return False
-
## Rewind() method
#
# Reset file data buffer to the initial state
@@ -118,25 +100,6 @@ class CodeFragmentCollector: self.CurrentLineNumber = 1
self.CurrentOffsetWithinLine = 0
- ## __UndoOneChar() method
- #
- # Go back one char in the file buffer
- #
- # @param self The object pointer
- # @retval True Successfully go back one char
- # @retval False Not able to go back one char as file beginning reached
- #
- def __UndoOneChar(self):
-
- if self.CurrentLineNumber == 1 and self.CurrentOffsetWithinLine == 0:
- return False
- elif self.CurrentOffsetWithinLine == 0:
- self.CurrentLineNumber -= 1
- self.CurrentOffsetWithinLine = len(self.__CurrentLine()) - 1
- else:
- self.CurrentOffsetWithinLine -= 1
- return True
-
## __GetOneChar() method
#
# Move forward one char in the file buffer
@@ -205,32 +168,6 @@ class CodeFragmentCollector: def __CurrentLine(self):
return self.Profile.FileLinesList[self.CurrentLineNumber - 1]
- ## __InsertComma() method
- #
- # Insert ',' to replace PP
- #
- # @param self The object pointer
- # @retval List current line contents
- #
- def __InsertComma(self, Line):
-
-
- if self.Profile.FileLinesList[Line - 1][0] != T_CHAR_HASH:
- BeforeHashPart = str(self.Profile.FileLinesList[Line - 1]).split(T_CHAR_HASH)[0]
- if BeforeHashPart.rstrip().endswith(T_CHAR_COMMA) or BeforeHashPart.rstrip().endswith(';'):
- return
-
- if Line - 2 >= 0 and str(self.Profile.FileLinesList[Line - 2]).rstrip().endswith(','):
- return
-
- if Line - 2 >= 0 and str(self.Profile.FileLinesList[Line - 2]).rstrip().endswith(';'):
- return
-
- if str(self.Profile.FileLinesList[Line]).lstrip().startswith(',') or str(self.Profile.FileLinesList[Line]).lstrip().startswith(';'):
- return
-
- self.Profile.FileLinesList[Line - 1].insert(self.CurrentOffsetWithinLine, ',')
-
## PreprocessFileWithClear() method
#
# Run a preprocess for the file to clean all comments
diff --git a/BaseTools/Source/Python/Eot/Database.py b/BaseTools/Source/Python/Eot/Database.py index fca08b9..64a7228 100644 --- a/BaseTools/Source/Python/Eot/Database.py +++ b/BaseTools/Source/Python/Eot/Database.py @@ -78,7 +78,6 @@ class Database(object): self.Conn.execute("PRAGMA page_size=8192")
self.Conn.execute("PRAGMA synchronous=OFF")
# to avoid non-ascii character conversion error
- self.Conn.text_factory = str
self.Cur = self.Conn.cursor()
self.TblDataModel = TableDataModel(self.Cur)
diff --git a/BaseTools/Source/Python/Eot/EotMain.py b/BaseTools/Source/Python/Eot/EotMain.py index a506378..e0b2ed2 100644 --- a/BaseTools/Source/Python/Eot/EotMain.py +++ b/BaseTools/Source/Python/Eot/EotMain.py @@ -1009,9 +1009,6 @@ class Ffs(Image): def Pack(self):
pass
- def SetFreeSpace(self, Size):
- self.FreeSpace = Size
-
def _GetGuid(self):
return gGuidStringFormat % self.Name
diff --git a/BaseTools/Source/Python/Eot/Identification.py b/BaseTools/Source/Python/Eot/Identification.py index 31d4760..168a886 100644 --- a/BaseTools/Source/Python/Eot/Identification.py +++ b/BaseTools/Source/Python/Eot/Identification.py @@ -29,20 +29,6 @@ class Identification(object): def GetFileName(self, FileFullPath, FileRelativePath):
pass
- ## GetFileName
- #
- # Reserved
- #
- def GetFileFullPath(self, FileName, FileRelativePath):
- pass
-
- ## GetFileName
- #
- # Reserved
- #
- def GetFileRelativePath(self, FileName, FileFullPath):
- pass
-
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Python/Eot/Parser.py index f204051..b0b3d0b 100644 --- a/BaseTools/Source/Python/Eot/Parser.py +++ b/BaseTools/Source/Python/Eot/Parser.py @@ -109,17 +109,6 @@ def PreProcess(Filename, MergeMultipleLines = True, LineNo = -1): return Lines
-## AddToGlobalMacro() method
-#
-# Add a macro to EotGlobalData.gMACRO
-#
-# @param Name: Name of the macro
-# @param Value: Value of the macro
-#
-def AddToGlobalMacro(Name, Value):
- Value = ReplaceMacro(Value, EotGlobalData.gMACRO, True)
- EotGlobalData.gMACRO[Name] = Value
-
## AddToSelfMacro() method
#
# Parse a line of macro definition and add it to a macro set
@@ -238,139 +227,6 @@ def GetAllIncludeFiles(Db): return IncludeFileList
-## GetAllSourceFiles() method
-#
-# Find all source files
-#
-# @param Db: Eot database
-#
-# @return SourceFileList: A list of source files
-#
-def GetAllSourceFiles(Db):
- SourceFileList = []
- SqlCommand = """select distinct Value1 from Inf where Model = %s order by Value1""" % MODEL_EFI_SOURCE_FILE
- RecordSet = Db.TblInf.Exec(SqlCommand)
-
- for Record in RecordSet:
- SourceFileList.append(Record[0])
-
- return SourceFileList
-
-## GetAllFiles() method
-#
-# Find all files, both source files and include files
-#
-# @param Db: Eot database
-#
-# @return FileList: A list of files
-#
-def GetAllFiles(Db):
- FileList = []
- IncludeFileList = GetAllIncludeFiles(Db)
- SourceFileList = GetAllSourceFiles(Db)
- for Item in IncludeFileList:
- if os.path.isfile(Item) and Item not in FileList:
- FileList.append(Item)
- for Item in SourceFileList:
- if os.path.isfile(Item) and Item not in FileList:
- FileList.append(Item)
-
- return FileList
-
-## ParseConditionalStatement() method
-#
-# Parse conditional statement
-#
-# @param Line: One line to be parsed
-# @param Macros: A set of all macro
-# @param StatusSet: A set of all status
-#
-# @retval True: Find keyword of conditional statement
-# @retval False: Not find keyword of conditional statement
-#
-def ParseConditionalStatement(Line, Macros, StatusSet):
- NewLine = Line.upper()
- if NewLine.find(TAB_IF_EXIST.upper()) > -1:
- IfLine = Line[NewLine.find(TAB_IF_EXIST) + len(TAB_IF_EXIST) + 1:].strip()
- IfLine = ReplaceMacro(IfLine, EotGlobalData.gMACRO, True)
- IfLine = ReplaceMacro(IfLine, Macros, True)
- IfLine = IfLine.replace("\"", '')
- IfLine = IfLine.replace("(", '')
- IfLine = IfLine.replace(")", '')
- Status = os.path.exists(os.path.normpath(IfLine))
- StatusSet.append([Status])
- return True
- if NewLine.find(TAB_IF_DEF.upper()) > -1:
- IfLine = Line[NewLine.find(TAB_IF_DEF) + len(TAB_IF_DEF) + 1:].strip()
- Status = False
- if IfLine in Macros or IfLine in EotGlobalData.gMACRO:
- Status = True
- StatusSet.append([Status])
- return True
- if NewLine.find(TAB_IF_N_DEF.upper()) > -1:
- IfLine = Line[NewLine.find(TAB_IF_N_DEF) + len(TAB_IF_N_DEF) + 1:].strip()
- Status = False
- if IfLine not in Macros and IfLine not in EotGlobalData.gMACRO:
- Status = True
- StatusSet.append([Status])
- return True
- if NewLine.find(TAB_IF.upper()) > -1:
- IfLine = Line[NewLine.find(TAB_IF) + len(TAB_IF) + 1:].strip()
- Status = ParseConditionalStatementMacros(IfLine, Macros)
- StatusSet.append([Status])
- return True
- if NewLine.find(TAB_ELSE_IF.upper()) > -1:
- IfLine = Line[NewLine.find(TAB_ELSE_IF) + len(TAB_ELSE_IF) + 1:].strip()
- Status = ParseConditionalStatementMacros(IfLine, Macros)
- StatusSet[-1].append(Status)
- return True
- if NewLine.find(TAB_ELSE.upper()) > -1:
- Status = False
- for Item in StatusSet[-1]:
- Status = Status or Item
- StatusSet[-1].append(not Status)
- return True
- if NewLine.find(TAB_END_IF.upper()) > -1:
- StatusSet.pop()
- return True
-
- return False
-
-## ParseConditionalStatement() method
-#
-# Parse conditional statement with Macros
-#
-# @param Line: One line to be parsed
-# @param Macros: A set of macros
-#
-# @return Line: New line after replacing macros
-#
-def ParseConditionalStatementMacros(Line, Macros):
- if Line.upper().find('DEFINED(') > -1 or Line.upper().find('EXIST') > -1:
- return False
- Line = ReplaceMacro(Line, EotGlobalData.gMACRO, True)
- Line = ReplaceMacro(Line, Macros, True)
- Line = Line.replace("&&", "and")
- Line = Line.replace("||", "or")
- return eval(Line)
-
-## GetConditionalStatementStatus() method
-#
-# 1. Assume the latest status as True
-# 2. Pop the top status of status set, previous status
-# 3. Compare the latest one and the previous one and get new status
-#
-# @param StatusSet: A set of all status
-#
-# @return Status: The final status
-#
-def GetConditionalStatementStatus(StatusSet):
- Status = True
- for Item in StatusSet:
- Status = Status and Item[-1]
-
- return Status
-
## SearchBelongsToFunction() method
#
# Search all functions belong to the file
@@ -819,47 +675,6 @@ def ParseMapFile(Files): return AllMaps
-## ConvertGuid
-#
-# Convert a GUID to a GUID with all upper letters
-#
-# @param guid: The GUID to be converted
-#
-# @param newGuid: The GUID with all upper letters.
-#
-def ConvertGuid(guid):
- numList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
- newGuid = ''
- if guid.startswith('g'):
- guid = guid[1:]
- for i in guid:
- if i.upper() == i and i not in numList:
- newGuid = newGuid + ('_' + i)
- else:
- newGuid = newGuid + i.upper()
- if newGuid.startswith('_'):
- newGuid = newGuid[1:]
- if newGuid.endswith('_'):
- newGuid = newGuid[:-1]
-
- return newGuid
-
-## ConvertGuid2() method
-#
-# Convert a GUID to a GUID with new string instead of old string
-#
-# @param guid: The GUID to be converted
-# @param old: Old string to be replaced
-# @param new: New string to replace the old one
-#
-# @param newGuid: The GUID after replacement
-#
-def ConvertGuid2(guid, old, new):
- newGuid = ConvertGuid(guid)
- newGuid = newGuid.replace(old, new)
-
- return newGuid
-
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
diff --git a/BaseTools/Source/Python/Eot/Report.py b/BaseTools/Source/Python/Eot/Report.py index 9d99fe2..32af504 100644 --- a/BaseTools/Source/Python/Eot/Report.py +++ b/BaseTools/Source/Python/Eot/Report.py @@ -149,30 +149,6 @@ class Report(object): </tr>""" % (DepexString)
self.WriteLn(Content)
- ## GeneratePpi() method
- #
- # Generate PPI information
- #
- # @param self: The object pointer
- # @param Name: CName of a GUID
- # @param Guid: Value of a GUID
- # @param Type: Type of a GUID
- #
- def GeneratePpi(self, Name, Guid, Type):
- self.GeneratePpiProtocol('Ppi', Name, Guid, Type, self.PpiIndex)
-
- ## GenerateProtocol() method
- #
- # Generate PROTOCOL information
- #
- # @param self: The object pointer
- # @param Name: CName of a GUID
- # @param Guid: Value of a GUID
- # @param Type: Type of a GUID
- #
- def GenerateProtocol(self, Name, Guid, Type):
- self.GeneratePpiProtocol('Protocol', Name, Guid, Type, self.ProtocolIndex)
-
## GeneratePpiProtocol() method
#
# Generate PPI/PROTOCOL information
|