You've already forked edk2-upstream
mirror of
https://github.com/Dasharo/edk2-upstream.git
synced 2026-03-06 15:03:57 -08:00
Running the vulture tool on the UPT/Library folder gave the following report. Remove the unnecessary code. - UPT/Library/CommentGenerating.py:50: unused function 'GenGenericComment' (60% confidence) - UPT/Library/CommentGenerating.py:172: unused function 'GenInfPcdTailComment' (60% confidence) - UPT/Library/CommentGenerating.py:185: unused function 'GenInfProtocolPPITailComment' (60% confidence) - UPT/Library/CommentGenerating.py:203: unused function 'GenInfGuidTailComment' (60% confidence) - UPT/Library/Misc.py:504: unused class 'MergeCommentDict' (60% confidence) - UPT/Library/Misc.py:527: unused function 'GenDummyHelpTextObj' (60% confidence) - UPT/Library/ParserValidate.py:110: unused function 'IsValidInfComponentType' (60% confidence) - UPT/Library/ParserValidate.py:122: unused function 'IsValidToolFamily' (60% confidence) - UPT/Library/ParserValidate.py:134: unused function 'IsValidToolTagName' (60% confidence) - UPT/Library/ParserValidate.py:465: unused function 'IsValidBuildNumber' (60% confidence) - UPT/Library/ParserValidate.py:478: unused function 'IsValidDepex' (60% confidence) - UPT/Library/ParserValidate.py:546: unused function 'IsValidVersionString' (60% confidence) - UPT/Library/ParserValidate.py:721: unused function 'CheckUTF16FileHeader' (60% confidence) - UPT/Library/Parsing.py:52: unused function 'GetBuildOption' (60% confidence) - UPT/Library/Parsing.py💯 unused function 'GetLibraryClassOfInf' (60% confidence) - UPT/Library/Parsing.py:150: unused function 'GetPcd' (60% confidence) - UPT/Library/Parsing.py:177: unused function 'GetFeatureFlagPcd' (60% confidence) - UPT/Library/Parsing.py:201: unused function 'GetDynamicDefaultPcd' (60% confidence) - UPT/Library/Parsing.py:227: unused function 'GetDynamicHiiPcd' (60% confidence) - UPT/Library/Parsing.py:254: unused function 'GetDynamicVpdPcd' (60% confidence) - UPT/Library/Parsing.py:277: unused function 'GetComponent' (60% confidence) - UPT/Library/Parsing.py:392: unused function 'GetExec' (60% confidence) - UPT/Library/Parsing.py:416: unused function 'GetComponents' (60% confidence) - UPT/Library/Parsing.py:532: unused function 'GetSource' (60% confidence) - UPT/Library/Parsing.py:581: unused function 'GetGuidsProtocolsPpisOfInf' (60% confidence) - UPT/Library/Parsing.py:595: unused function 'GetGuidsProtocolsPpisOfDec' (60% confidence) - UPT/Library/Parsing.py:645: unused function 'GetPcdOfInf' (60% confidence) - UPT/Library/Parsing.py:682: unused function 'GetPcdOfDec' (60% confidence) - UPT/Library/Parsing.py:739: unused function 'InsertSectionItems' (60% confidence) - UPT/Library/Parsing.py:776: unused function 'GenMetaDatSectionItem' (60% confidence) - UPT/Library/StringUtils.py:87: unused function 'GetLibraryClassesWithModuleType' (60% confidence) - UPT/Library/StringUtils.py:107: unused function 'GetDynamics' (60% confidence) - UPT/Library/StringUtils.py:350: unused function 'GetMultipleValuesOfKeyFromLines' (60% confidence) - UPT/Library/StringUtils.py:396: unused function 'GetSingleValueOfKeyFromLines' (60% confidence) - UPT/Library/StringUtils.py:463: unused function 'PreCheck' (60% confidence) - UPT/Library/StringUtils.py:675: unused function 'StringArrayLength' (60% confidence) - UPT/Library/StringUtils.py:718: unused function 'IsHexDigit' (60% confidence) - UPT/Library/UniClassObject.py:86: unused function 'UniToStr' (60% confidence) - UPT/Library/UniClassObject.py:227: unused attribute 'StringNameByteList' (60% confidence) - UPT/Library/UniClassObject.py:237: unused attribute 'StringNameByteList' (60% confidence) - UPT/Library/UniClassObject.py:377: unused method 'GetIncludeFile' (60% confidence) - UPT/Library/UniClassObject.py:947: unused method 'FindStringValue' (60% confidence) - UPT/Library/UniClassObject.py:957: unused method 'FindByToken' (60% confidence) - UPT/Library/UniClassObject.py:1022: unused method 'ReadIncludeUNIfile' (60% confidence) - UPT/Library/StringUtils.py:718: unused function 'IsHexDigit' (60% confidence) - UPT/Library/Xml/XmlRoutines.py:176: unused function 'XmlElementList' (60% confidence) - UPT/Library/Xml/XmlRoutines.py:202: unused function 'XmlNodeName' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
175 lines
6.8 KiB
Python
175 lines
6.8 KiB
Python
## @file
|
|
# This file is used to define comment generating interface
|
|
#
|
|
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
#
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
#
|
|
|
|
'''
|
|
CommentGenerating
|
|
'''
|
|
|
|
##
|
|
# Import Modules
|
|
#
|
|
from Library.StringUtils import GetSplitValueList
|
|
from Library.DataType import TAB_SPACE_SPLIT
|
|
from Library.DataType import TAB_INF_GUIDTYPE_VAR
|
|
from Library.DataType import ITEM_UNDEFINED
|
|
from Library.DataType import TAB_HEADER_COMMENT
|
|
from Library.DataType import TAB_BINARY_HEADER_COMMENT
|
|
from Library.DataType import TAB_COMMENT_SPLIT
|
|
from Library.DataType import TAB_SPECIAL_COMMENT
|
|
from Library.DataType import END_OF_LINE
|
|
from Library.DataType import TAB_COMMENT_EDK1_SPLIT
|
|
from Library.DataType import TAB_COMMENT_EDK1_START
|
|
from Library.DataType import TAB_COMMENT_EDK1_END
|
|
from Library.DataType import TAB_STAR
|
|
from Library.DataType import TAB_PCD_PROMPT
|
|
from Library.UniClassObject import ConvertSpecialUnicodes
|
|
from Library.Misc import GetLocalValue
|
|
## GenTailCommentLines
|
|
#
|
|
# @param TailCommentLines: the tail comment lines that need to be generated
|
|
# @param LeadingSpaceNum: the number of leading space needed for non-first
|
|
# line tail comment
|
|
#
|
|
def GenTailCommentLines (TailCommentLines, LeadingSpaceNum = 0):
|
|
TailCommentLines = TailCommentLines.rstrip(END_OF_LINE)
|
|
CommentStr = TAB_SPACE_SPLIT*2 + TAB_SPECIAL_COMMENT + TAB_SPACE_SPLIT + \
|
|
(END_OF_LINE + LeadingSpaceNum * TAB_SPACE_SPLIT + TAB_SPACE_SPLIT*2 + TAB_SPECIAL_COMMENT + \
|
|
TAB_SPACE_SPLIT).join(GetSplitValueList(TailCommentLines, END_OF_LINE))
|
|
|
|
return CommentStr
|
|
|
|
## GenGenericCommentF
|
|
#
|
|
# similar to GenGenericComment but will remove <EOL> at end of comment once,
|
|
# and for line with only <EOL>, '#\n' will be generated instead of '# \n'
|
|
#
|
|
# @param CommentLines: Generic comment Text, maybe Multiple Lines
|
|
# @return CommentStr: Generated comment line
|
|
#
|
|
def GenGenericCommentF (CommentLines, NumOfPound=1, IsPrompt=False, IsInfLibraryClass=False):
|
|
if not CommentLines:
|
|
return ''
|
|
#
|
|
# if comment end with '\n', then remove it to prevent one extra line
|
|
# generate later on
|
|
#
|
|
if CommentLines.endswith(END_OF_LINE):
|
|
CommentLines = CommentLines[:-1]
|
|
CommentStr = ''
|
|
if IsPrompt:
|
|
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT + TAB_PCD_PROMPT + TAB_SPACE_SPLIT + \
|
|
CommentLines.replace(END_OF_LINE, '') + END_OF_LINE
|
|
else:
|
|
CommentLineList = GetSplitValueList(CommentLines, END_OF_LINE)
|
|
FindLibraryClass = False
|
|
for Line in CommentLineList:
|
|
# If this comment is for @libraryclass and it has multiple lines
|
|
# make sure the second lines align to the first line after @libraryclass as below
|
|
#
|
|
# ## @libraryclass XYZ FIRST_LINE
|
|
# ## ABC SECOND_LINE
|
|
#
|
|
if IsInfLibraryClass and Line.find(u'@libraryclass ') > -1:
|
|
FindLibraryClass = True
|
|
if Line == '':
|
|
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + END_OF_LINE
|
|
else:
|
|
if FindLibraryClass and Line.find(u'@libraryclass ') > -1:
|
|
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT + Line + END_OF_LINE
|
|
elif FindLibraryClass:
|
|
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT * 16 + Line + END_OF_LINE
|
|
else:
|
|
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT + Line + END_OF_LINE
|
|
|
|
return CommentStr
|
|
|
|
|
|
## GenHeaderCommentSection
|
|
#
|
|
# Generate Header comment sections
|
|
#
|
|
# @param Abstract One line of abstract
|
|
# @param Description multiple lines of Description
|
|
# @param Copyright possible multiple copyright lines
|
|
# @param License possible multiple license lines
|
|
#
|
|
def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsBinaryHeader=False, \
|
|
CommChar=TAB_COMMENT_SPLIT):
|
|
Content = ''
|
|
|
|
#
|
|
# Convert special character to (c), (r) and (tm).
|
|
#
|
|
Abstract = ConvertSpecialUnicodes(Abstract)
|
|
Description = ConvertSpecialUnicodes(Description)
|
|
if IsBinaryHeader:
|
|
Content += CommChar * 2 + TAB_SPACE_SPLIT + TAB_BINARY_HEADER_COMMENT + '\r\n'
|
|
elif CommChar == TAB_COMMENT_EDK1_SPLIT:
|
|
Content += CommChar + TAB_SPACE_SPLIT + TAB_COMMENT_EDK1_START + TAB_STAR + TAB_SPACE_SPLIT +\
|
|
TAB_HEADER_COMMENT + '\r\n'
|
|
else:
|
|
Content += CommChar * 2 + TAB_SPACE_SPLIT + TAB_HEADER_COMMENT + '\r\n'
|
|
if Abstract:
|
|
Abstract = Abstract.rstrip('\r\n')
|
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
|
(Abstract, '\n'))
|
|
Content += '\r\n' + CommChar + '\r\n'
|
|
else:
|
|
Content += CommChar + '\r\n'
|
|
|
|
if Description:
|
|
Description = Description.rstrip('\r\n')
|
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
|
(Description, '\n'))
|
|
Content += '\r\n' + CommChar + '\r\n'
|
|
|
|
#
|
|
# There is no '#\n' line to separate multiple copyright lines in code base
|
|
#
|
|
if Copyright:
|
|
Copyright = Copyright.rstrip('\r\n')
|
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join\
|
|
(GetSplitValueList(Copyright, '\n'))
|
|
Content += '\r\n' + CommChar + '\r\n'
|
|
|
|
if License:
|
|
License = License.rstrip('\r\n')
|
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
|
(License, '\n'))
|
|
Content += '\r\n' + CommChar + '\r\n'
|
|
|
|
if CommChar == TAB_COMMENT_EDK1_SPLIT:
|
|
Content += CommChar + TAB_SPACE_SPLIT + TAB_STAR + TAB_COMMENT_EDK1_END + '\r\n'
|
|
else:
|
|
Content += CommChar * 2 + '\r\n'
|
|
|
|
return Content
|
|
|
|
## GenDecGuidTailComment
|
|
#
|
|
# @param SupModuleList: Supported module type list
|
|
#
|
|
def GenDecTailComment (SupModuleList):
|
|
CommentLine = TAB_SPACE_SPLIT.join(SupModuleList)
|
|
return GenTailCommentLines(CommentLine)
|
|
|
|
|
|
## _GetHelpStr
|
|
# get HelpString from a list of HelpTextObject, the priority refer to
|
|
# related HLD
|
|
#
|
|
# @param HelpTextObjList: List of HelpTextObject
|
|
#
|
|
# @return HelpStr: the help text string found, '' means no help text found
|
|
#
|
|
def _GetHelpStr(HelpTextObjList):
|
|
ValueList = []
|
|
for HelpObj in HelpTextObjList:
|
|
ValueList.append((HelpObj.GetLang(), HelpObj.GetString()))
|
|
return GetLocalValue(ValueList, True)
|