## @file\r
# This file is used to define common parser functions for meta-data\r
#\r
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
# @param FileName: FileName of the comment\r
#\r
def ParseHeaderCommentSection(CommentList, FileName = None):\r
- \r
+\r
Abstract = ''\r
Description = ''\r
Copyright = ''\r
License = ''\r
EndOfLine = "\n"\r
STR_HEADER_COMMENT_START = "@file"\r
- \r
+\r
#\r
- # used to indicate the state of processing header comment section of dec, \r
+ # used to indicate the state of processing header comment section of dec,\r
# inf files\r
#\r
HEADER_COMMENT_NOT_STARTED = -1\r
if _IsCopyrightLine(Line):\r
Last = Index\r
break\r
- \r
+\r
for Item in CommentList:\r
Line = Item[0]\r
LineNo = Item[1]\r
- \r
+\r
if not Line.startswith('#') and Line:\r
SqlStatement = """ select ID from File where FullPath like '%s'""" % FileName\r
ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
Comment = CleanString2(Line)[1]\r
Comment = Comment.strip()\r
#\r
- # if there are blank lines between License or Description, keep them as they would be \r
+ # if there are blank lines between License or Description, keep them as they would be\r
# indication of different block; or in the position that Abstract should be, also keep it\r
# as it indicates that no abstract\r
#\r
if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICENSE, \\r
HEADER_COMMENT_DESCRIPTION, HEADER_COMMENT_ABSTRACT]:\r
continue\r
- \r
+\r
if HeaderCommentStage == HEADER_COMMENT_NOT_STARTED:\r
if Comment.startswith(STR_HEADER_COMMENT_START):\r
HeaderCommentStage = HEADER_COMMENT_ABSTRACT\r
if not Comment:\r
Abstract = ''\r
HeaderCommentStage = HEADER_COMMENT_DESCRIPTION\r
- elif _IsCopyrightLine(Comment): \r
+ elif _IsCopyrightLine(Comment):\r
Copyright += Comment + EndOfLine\r
HeaderCommentStage = HEADER_COMMENT_COPYRIGHT\r
- else: \r
+ else:\r
Abstract += Comment + EndOfLine\r
HeaderCommentStage = HEADER_COMMENT_DESCRIPTION\r
elif HeaderCommentStage == HEADER_COMMENT_DESCRIPTION:\r
#\r
# in case there is no description\r
- # \r
- if _IsCopyrightLine(Comment): \r
+ #\r
+ if _IsCopyrightLine(Comment):\r
Copyright += Comment + EndOfLine\r
HeaderCommentStage = HEADER_COMMENT_COPYRIGHT\r
else:\r
- Description += Comment + EndOfLine \r
+ Description += Comment + EndOfLine\r
elif HeaderCommentStage == HEADER_COMMENT_COPYRIGHT:\r
- if _IsCopyrightLine(Comment): \r
+ if _IsCopyrightLine(Comment):\r
Copyright += Comment + EndOfLine\r
else:\r
#\r
# Contents after copyright line are license, those non-copyright lines in between\r
- # copyright line will be discarded \r
+ # copyright line will be discarded\r
#\r
if LineNo > Last:\r
if License:\r
License += EndOfLine\r
License += Comment + EndOfLine\r
- HeaderCommentStage = HEADER_COMMENT_LICENSE \r
+ HeaderCommentStage = HEADER_COMMENT_LICENSE\r
else:\r
if not Comment and not License:\r
continue\r
License += Comment + EndOfLine\r
- \r
+\r
if not Copyright.strip():\r
SqlStatement = """ select ID from File where FullPath like '%s'""" % FileName\r
ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
for Result in ResultSet:\r
Msg = 'Header comment section must have license information'\r
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
- \r
+\r
if not Abstract.strip() or Abstract.find('Component description file') > -1:\r
SqlStatement = """ select ID from File where FullPath like '%s'""" % FileName\r
ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
for Result in ResultSet:\r
Msg = 'Header comment section must have Abstract information.'\r
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
- \r
+\r
return Abstract.strip(), Description.strip(), Copyright.strip(), License.strip()\r
\r
## _IsCopyrightLine\r
-# check whether current line is copyright line, the criteria is whether there is case insensitive keyword "Copyright" \r
-# followed by zero or more white space characters followed by a "(" character \r
+# check whether current line is copyright line, the criteria is whether there is case insensitive keyword "Copyright"\r
+# followed by zero or more white space characters followed by a "(" character\r
#\r
# @param LineContent: the line need to be checked\r
# @return: True if current line is copyright line, False else\r
def _IsCopyrightLine (LineContent):\r
LineContent = LineContent.upper()\r
Result = False\r
- \r
+\r
ReIsCopyrightRe = re.compile(r"""(^|\s)COPYRIGHT *\(""", re.DOTALL)\r
if ReIsCopyrightRe.search(LineContent):\r
Result = True\r
- \r
+\r
return Result\r
\r
\r
# Remove spaces\r
#\r
# @param Line: The string to be cleaned\r
-# @param CommentCharacter: Comment char, used to ignore comment content, \r
+# @param CommentCharacter: Comment char, used to ignore comment content,\r
# default is DataType.TAB_COMMENT_SPLIT\r
#\r
def CleanString2(Line, CommentCharacter='#', AllowCppStyleComment=False):\r