public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Bob Feng <bob.c.feng@intel.com>,
	Yonghong Zhu <yonghong.zhu@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH v2 7/7] BaseTools/GenFds: create and use new variable in FdfParser
Date: Fri, 28 Sep 2018 14:54:32 -0700	[thread overview]
Message-ID: <03f6c740aa3f0237d30c500339a3eacaa7417a06.1538171557.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1538171557.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1538171557.git.jaben.carsey@intel.com>

replace lots of '}' and "}" with a shared new consistent variable.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 45 ++++++++++----------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 5a59a0a0d854..3645b4f0fff6 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -65,8 +65,9 @@ T_CHAR_TAB = '\t'
 T_CHAR_DOUBLE_QUOTE = '\"'
 T_CHAR_SINGLE_QUOTE = '\''
 T_CHAR_STAR = '*'
+T_CHAR_BRACE_R = '}'
 
-SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', '}'}
+SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', T_CHAR_BRACE_R}
 ALIGNMENTS = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", "64K", "128K",
                                     "256K", "512K", "1M", "2M", "4M", "8M", "16M"}
 ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
@@ -2021,7 +2022,7 @@ class FdfParser:
                 DataString += self._Token
                 DataString += TAB_COMMA_SPLIT
 
-        if not self._IsToken("}"):
+        if not self._IsToken(T_CHAR_BRACE_R):
             raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
         DataString = DataString.rstrip(TAB_COMMA_SPLIT)
@@ -2061,7 +2062,7 @@ class FdfParser:
                     DataString += self._Token
                     DataString += TAB_COMMA_SPLIT
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
             DataString = DataString.rstrip(TAB_COMMA_SPLIT)
@@ -2329,10 +2330,10 @@ class FdfParser:
                 DataString += self._Token
                 DataString += TAB_COMMA_SPLIT
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
             DataString = DataString.rstrip(TAB_COMMA_SPLIT)
@@ -2347,7 +2348,7 @@ class FdfParser:
 
             FvObj.FvExtEntryData.append(self._Token)
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
         return True
@@ -2383,7 +2384,7 @@ class FdfParser:
             if not IsInf and not IsFile:
                 break
 
-        if not self._IsToken("}"):
+        if not self._IsToken(T_CHAR_BRACE_R):
             raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
         FvObj.AprioriSectionList.append(AprSectionObj)
@@ -2658,7 +2659,7 @@ class FdfParser:
             FfsFileObj.FileName = self._Token.replace('$(SPACE)', ' ')
             self._VerifyFile(FfsFileObj.FileName)
 
-        if not self._IsToken("}"):
+        if not self._IsToken(T_CHAR_BRACE_R):
             raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
     ## _GetRAWData() method
@@ -2683,7 +2684,7 @@ class FdfParser:
                 raise Warning.Expected("Filename value", self.FileName, self.CurrentLineNumber)
 
             FileName = self._Token.replace('$(SPACE)', ' ')
-            if FileName == '}':
+            if FileName == T_CHAR_BRACE_R:
                 self._UndoToken()
                 raise Warning.Expected("Filename value", self.FileName, self.CurrentLineNumber)
 
@@ -2692,7 +2693,7 @@ class FdfParser:
             FfsFileObj.FileName.append(File.Path)
             FfsFileObj.SubAlignment.append(AlignValue)
 
-            if self._IsToken("}"):
+            if self._IsToken(T_CHAR_BRACE_R):
                 self._UndoToken()
                 break
 
@@ -2864,7 +2865,7 @@ class FdfParser:
                     if not IsInf and not IsFile:
                         break
 
-                if not self._IsToken("}"):
+                if not self._IsToken(T_CHAR_BRACE_R):
                     raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
             FvImageSectionObj = FvImageSection()
@@ -2889,10 +2890,10 @@ class FdfParser:
                 raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
             if not self._IsToken("{"):
                 raise Warning.ExpectedCurlyOpen(self.FileName, self.CurrentLineNumber)
-            if not self._SkipToToken("}"):
+            if not self._SkipToToken(T_CHAR_BRACE_R):
                 raise Warning.Expected("Depex expression ending '}'", self.FileName, self.CurrentLineNumber)
 
-            DepexSectionObj.Expression = self._SkippedChars.rstrip('}')
+            DepexSectionObj.Expression = self._SkippedChars.rstrip(T_CHAR_BRACE_R)
             Obj.SectionList.append(DepexSectionObj)
 
         else:
@@ -2983,7 +2984,7 @@ class FdfParser:
                     break
 
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
             Obj.SectionList.append(CompressSectionObj)
             return True
@@ -3010,7 +3011,7 @@ class FdfParser:
                 if not IsLeafSection and not IsEncapSection:
                     break
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
             Obj.SectionList.append(GuidSectionObj)
 
@@ -3688,7 +3689,7 @@ class FdfParser:
                 if not IsEncapsulate and not IsLeaf:
                     break
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
 
             return NewRule
@@ -3787,7 +3788,7 @@ class FdfParser:
                     if not IsInf and not IsFile:
                         break
 
-                if not self._IsToken("}"):
+                if not self._IsToken(T_CHAR_BRACE_R):
                     raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
                 FvImageSectionObj.Fv = FvObj
                 FvImageSectionObj.FvName = None
@@ -3806,7 +3807,7 @@ class FdfParser:
                     FvImageSectionObj.FvFileExtension = self._GetFileExtension()
                 elif self._GetNextToken():
                     if self._Token not in {
-                            "}", "COMPAT16", BINARY_FILE_TYPE_PE32,
+                            T_CHAR_BRACE_R, "COMPAT16", BINARY_FILE_TYPE_PE32,
                             BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
                             "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,
                             BINARY_FILE_TYPE_UI, "VERSION",
@@ -3892,7 +3893,7 @@ class FdfParser:
             EfiSectionObj.FileExtension = self._GetFileExtension()
         elif self._GetNextToken():
             if self._Token not in {
-                    "}", "COMPAT16", BINARY_FILE_TYPE_PE32,
+                    T_CHAR_BRACE_R, "COMPAT16", BINARY_FILE_TYPE_PE32,
                     BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
                     "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,
                     BINARY_FILE_TYPE_UI, "VERSION",
@@ -4035,7 +4036,7 @@ class FdfParser:
                 if not IsEncapsulate and not IsLeaf:
                     break
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
             theRule.SectionList.append(CompressSectionObj)
 
@@ -4067,7 +4068,7 @@ class FdfParser:
                 if not IsEncapsulate and not IsLeaf:
                     break
 
-            if not self._IsToken("}"):
+            if not self._IsToken(T_CHAR_BRACE_R):
                 raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
             theRule.SectionList.append(GuidSectionObj)
 
@@ -4413,7 +4414,7 @@ class FdfParser:
                     Overrides.NeedCompress = self._Token.upper() == 'TRUE'
                     continue
 
-                if self._IsToken("}"):
+                if self._IsToken(T_CHAR_BRACE_R):
                     break
                 else:
                     EdkLogger.error("FdfParser", FORMAT_INVALID, File=self.FileName, Line=self.CurrentLineNumber)
-- 
2.16.2.windows.1



      parent reply	other threads:[~2018-09-28 21:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 21:54 [PATCH v2 0/7] BaseTools/GenFds: cleanup GenFds Jaben Carsey
2018-09-28 21:54 ` [PATCH v2 1/7] " Jaben Carsey
2018-09-28 21:54 ` [PATCH v2 2/7] BaseTools/GenFds: change objects to sets Jaben Carsey
2018-09-28 21:54 ` [PATCH v2 3/7] Basetools/GenFds: refactor class FV Jaben Carsey
2018-09-28 21:54 ` [PATCH v2 4/7] BaseTools/GenFds: remove MacroDict parameter Jaben Carsey
2018-09-28 21:54 ` [PATCH v2 5/7] BaseTools/GenFds: refactor FdfParser warnings Jaben Carsey
2018-09-28 21:54 ` [PATCH v2 6/7] BaseTools/GenFds: Remove duplicate function calls Jaben Carsey
2018-09-28 21:54 ` Jaben Carsey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03f6c740aa3f0237d30c500339a3eacaa7417a06.1538171557.git.jaben.carsey@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox