Re: [edk2] [Patch] BaseTools: Correct the error message for UPT

2019-02-14 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Feng, Bob C
> Sent: Saturday, February 2, 2019 9:36 AM
> To: edk2-devel@lists.01.org
> Cc: Chen, Hess ; Gao, Liming 
> Subject: [Patch] BaseTools: Correct the error message for UPT
> 
> This patch is going to correct the error message
> for UPT.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hess Chen 
> Cc: Liming Gao 
> ---
>  .../Python/UPT/Library/UniClassObject.py   | 18 ++
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py 
> b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
> index cd575d5a34..7a056b349f 100644
> --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
> +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
> @@ -1,9 +1,9 @@
>  ## @file
>  # Collect all defined strings in multiple uni files.
>  #
> -# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
> +# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
>  #
>  # This program and the accompanying materials are licensed and made available
>  # under the terms and conditions of the BSD License which accompanies this
>  # distribution. The full text of the license may be found at
>  # http://opensource.org/licenses/bsd-license.php
> @@ -593,10 +593,19 @@ class UniFileClassObject(object):
>  StringEntryExistsFlag = 1
>  if not Line.endswith('"'):
>  EdkLogger.Error("Unicode File Parser", 
> ToolError.FORMAT_INVALID,
>  ExtraData='''The line %s misses '"' at 
> the end of it in file %s'''
>% (LineCount, File.Path))
> +
> +#
> +# Check the situation that there has more than 2 '"' for the 
> language entry
> +#
> +if Line.strip() and Line.replace(u'\\"', '').count(u'"') > 2:
> +EdkLogger.Error("Unicode File Parser", 
> ToolError.FORMAT_INVALID,
> +ExtraData='''The line %s has more than 2 
> '"' for language entry in file %s'''
> +% (LineCount, File.Path))
> +
>  elif Line.startswith(u'#language'):
>  if StringEntryExistsFlag == 2:
>  EdkLogger.Error("Unicode File Parser", 
> ToolError.FORMAT_INVALID,
>  Message=ST.ERR_UNI_MISS_STRING_ENTRY % 
> Line, ExtraData=File.Path)
>  StringEntryExistsFlag = 0
> @@ -741,17 +750,10 @@ class UniFileClassObject(object):
>  NewLines.append((Line[:Line.find(u'"')]).strip())
>  NewLines.append((Line[Line.find(u'"'):]).strip())
>  else:
>  EdkLogger.Error("Unicode File Parser", 
> ToolError.FORMAT_INVALID, ExtraData=File.Path)
>  elif Line.startswith(u'"'):
> -#
> -# Check the situation that there has more than 2 '"' for the 
> language entry
> -#
> -if Line.replace(u'\\"', '').count(u'"') > 2:
> -EdkLogger.Error("Unicode File Parser", 
> ToolError.FORMAT_INVALID,
> -ExtraData='''The line %s has more than 2 
> '"' for language entry in file %s'''
> -% (LineCount, File.Path))
>  if u'#string' in Line  or u'#language' in Line:
>  EdkLogger.Error("Unicode File Parser", 
> ToolError.FORMAT_INVALID, ExtraData=File.Path)
>  NewLines.append(Line)
>  else:
>  print(Line)
> --
> 2.19.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Correct the error message for UPT

2019-02-01 Thread Feng, Bob C
This patch is going to correct the error message
for UPT.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hess Chen 
Cc: Liming Gao 
---
 .../Python/UPT/Library/UniClassObject.py   | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py 
b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index cd575d5a34..7a056b349f 100644
--- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
+++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
@@ -1,9 +1,9 @@
 ## @file
 # Collect all defined strings in multiple uni files.
 #
-# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
 #
 # This program and the accompanying materials are licensed and made available
 # under the terms and conditions of the BSD License which accompanies this
 # distribution. The full text of the license may be found at
 # http://opensource.org/licenses/bsd-license.php
@@ -593,10 +593,19 @@ class UniFileClassObject(object):
 StringEntryExistsFlag = 1
 if not Line.endswith('"'):
 EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID,
 ExtraData='''The line %s misses '"' at the 
end of it in file %s'''
   % (LineCount, File.Path))
+
+#
+# Check the situation that there has more than 2 '"' for the 
language entry
+#
+if Line.strip() and Line.replace(u'\\"', '').count(u'"') > 2:
+EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID,
+ExtraData='''The line %s has more than 2 
'"' for language entry in file %s'''
+% (LineCount, File.Path))
+
 elif Line.startswith(u'#language'):
 if StringEntryExistsFlag == 2:
 EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID,
 Message=ST.ERR_UNI_MISS_STRING_ENTRY % 
Line, ExtraData=File.Path)
 StringEntryExistsFlag = 0
@@ -741,17 +750,10 @@ class UniFileClassObject(object):
 NewLines.append((Line[:Line.find(u'"')]).strip())
 NewLines.append((Line[Line.find(u'"'):]).strip())
 else:
 EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID, ExtraData=File.Path)
 elif Line.startswith(u'"'):
-#
-# Check the situation that there has more than 2 '"' for the 
language entry
-#
-if Line.replace(u'\\"', '').count(u'"') > 2:
-EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID,
-ExtraData='''The line %s has more than 2 
'"' for language entry in file %s'''
-% (LineCount, File.Path))
 if u'#string' in Line  or u'#language' in Line:
 EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID, ExtraData=File.Path)
 NewLines.append(Line)
 else:
 print(Line)
-- 
2.19.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel