From 5bcf1d5671061bbcc3ee752fdf9b9d7bcce84665 Mon Sep 17 00:00:00 2001 From: "Carsey, Jaben" Date: Fri, 30 Mar 2018 08:19:32 +0800 Subject: [PATCH] BaseTools: make static functions when self is not needed remove self, and add @staticmethod to functions Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu --- .../Source/Python/Common/FdfParserLite.py | 22 ++++++++-------- BaseTools/Source/Python/GenFds/FdfParser.py | 25 +++++++++---------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py index 692e8aeb3f..dd822505d3 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -2130,13 +2130,12 @@ class FdfParser(object): # # Check whether reloc strip flag can be set for a file type. # - # @param self The object pointer # @param FileType The file type to check with # @retval True This type could have relocation strip flag # @retval False No way to have it # - - def __FileCouldHaveRelocFlag (self, FileType): + @staticmethod + def __FileCouldHaveRelocFlag (FileType): if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'): return True else: @@ -2146,13 +2145,12 @@ class FdfParser(object): # # Check whether reloc strip flag can be set for a section type. # - # @param self The object pointer # @param SectionType The section type to check with # @retval True This type could have relocation strip flag # @retval False No way to have it # - - def __SectionCouldHaveRelocFlag (self, SectionType): + @staticmethod + def __SectionCouldHaveRelocFlag (SectionType): if SectionType in ('TE', 'PE32'): return True else: @@ -3152,12 +3150,12 @@ class FdfParser(object): # # Get whether a section could be optional # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could be optional # @retval False section never optional # - def __RuleSectionCouldBeOptional(self, SectionType): + @staticmethod + def __RuleSectionCouldBeOptional(SectionType): if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"): return True else: @@ -3167,12 +3165,12 @@ class FdfParser(object): # # Get whether a section could have build number information # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could have build number information # @retval False section never have build number information # - def __RuleSectionCouldHaveBuildNum(self, SectionType): + @staticmethod + def __RuleSectionCouldHaveBuildNum(SectionType): if SectionType in ("VERSION"): return True else: @@ -3182,12 +3180,12 @@ class FdfParser(object): # # Get whether a section could have string # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could have string # @retval False section never have string # - def __RuleSectionCouldHaveString(self, SectionType): + @staticmethod + def __RuleSectionCouldHaveString(SectionType): if SectionType in ("UI", "VERSION"): return True else: diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 5dbcb96bbd..9b7e898570 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -704,7 +704,8 @@ class FdfParser: # Preprocess done. self.Rewind() - def __GetIfListCurrentItemStat(self, IfList): + @staticmethod + def __GetIfListCurrentItemStat(IfList): if len(IfList) == 0: return True @@ -2625,13 +2626,12 @@ class FdfParser: # # Check whether reloc strip flag can be set for a file type. # - # @param self The object pointer # @param FileType The file type to check with # @retval True This type could have relocation strip flag # @retval False No way to have it # - - def __FileCouldHaveRelocFlag (self, FileType): + @staticmethod + def __FileCouldHaveRelocFlag (FileType): if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'): return True else: @@ -2641,13 +2641,12 @@ class FdfParser: # # Check whether reloc strip flag can be set for a section type. # - # @param self The object pointer # @param SectionType The section type to check with # @retval True This type could have relocation strip flag # @retval False No way to have it # - - def __SectionCouldHaveRelocFlag (self, SectionType): + @staticmethod + def __SectionCouldHaveRelocFlag (SectionType): if SectionType in ('TE', 'PE32'): return True else: @@ -3986,12 +3985,12 @@ class FdfParser: # # Get whether a section could be optional # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could be optional # @retval False section never optional # - def __RuleSectionCouldBeOptional(self, SectionType): + @staticmethod + def __RuleSectionCouldBeOptional(SectionType): if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"): return True else: @@ -4001,12 +4000,12 @@ class FdfParser: # # Get whether a section could have build number information # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could have build number information # @retval False section never have build number information # - def __RuleSectionCouldHaveBuildNum(self, SectionType): + @staticmethod + def __RuleSectionCouldHaveBuildNum(SectionType): if SectionType in ("VERSION"): return True else: @@ -4016,12 +4015,12 @@ class FdfParser: # # Get whether a section could have string # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could have string # @retval False section never have string # - def __RuleSectionCouldHaveString(self, SectionType): + @staticmethod + def __RuleSectionCouldHaveString(SectionType): if SectionType in ("UI", "VERSION"): return True else: -- 2.39.2