From 71cac3f791c2469468838ded6519b624d32345bb Mon Sep 17 00:00:00 2001 From: "Carsey, Jaben" Date: Tue, 11 Sep 2018 06:18:05 +0800 Subject: BaseTools: Workspace classes refactor properties 1) use decorators 2) also change some private functions to public when all callers are external 3) change external callers to use functions instead of directly accessing private data. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/Workspace/MetaFileParser.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py') diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 79e3180d5e..f1707c06fe 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -213,11 +213,13 @@ class MetaFileParser(object): self._PostProcessed = True ## Get the parse complete flag - def _GetFinished(self): + @property + def Finished(self): return self._Finished ## Set the complete flag - def _SetFinished(self, Value): + @Finished.setter + def Finished(self, Value): self._Finished = Value ## Remove records that do not match given Filter Arch @@ -416,7 +418,9 @@ class MetaFileParser(object): ) def GetValidExpression(self, TokenSpaceGuid, PcdCName): return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName) - def _GetMacros(self): + + @property + def _Macros(self): Macros = {} Macros.update(self._FileLocalMacros) Macros.update(self._GetApplicableSectionMacro()) @@ -478,9 +482,6 @@ class MetaFileParser(object): return Macros _SectionParser = {} - Finished = property(_GetFinished, _SetFinished) - _Macros = property(_GetMacros) - ## INF file parser class # @@ -1252,7 +1253,8 @@ class DscParser(MetaFileParser): ) ## Override parent's method since we'll do all macro replacements in parser - def _GetMacros(self): + @property + def _Macros(self): Macros = {} Macros.update(self._FileLocalMacros) Macros.update(self._GetApplicableSectionMacro()) @@ -1673,8 +1675,6 @@ class DscParser(MetaFileParser): MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHeaderParser, } - _Macros = property(_GetMacros) - ## DEC file parser class # # @param FilePath The path of platform description file -- cgit v1.2.3