本文整理汇总了Python中Library.CommentGenerating.GenGenericCommentF类的典型用法代码示例。如果您正苦于以下问题:Python GenGenericCommentF类的具体用法?Python GenGenericCommentF怎么用?Python GenGenericCommentF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GenGenericCommentF类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GenSpecialSections
def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
#
# generate section
#
Content = ''
NewSectionDict = {}
for Obj in ObjectList:
#
# Generate comment
#
CommentStr = ''
HelpTextList = Obj.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CommentStr = GenGenericCommentF(HelpStr)
if SectionName == 'Hob':
Type = Obj.GetHobType()
elif SectionName == 'Event':
Type = Obj.GetEventType()
elif SectionName == 'BootMode':
Type = Obj.GetSupportedBootModes()
else:
assert(SectionName)
Usage = Obj.GetUsage()
# If the content already in UserExtensionsContent then ignore
if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent:
return ''
Statement = ' ' + Type + ' ## ' + Usage
if CommentStr in ['#\n', '#\n#\n']:
CommentStr = '#\n#\n#\n'
#
# the first head comment line should start with '##\n', if it starts with '#\n', then add one '#'
# else add '##\n' to meet the format defined in INF spec
#
if CommentStr.startswith('#\n'):
CommentStr = '#' + CommentStr
elif CommentStr:
CommentStr = '##\n' + CommentStr
if CommentStr and not CommentStr.endswith('\n#\n'):
CommentStr = CommentStr + '#\n'
NewStateMent = CommentStr + Statement
SupArch = Obj.GetSupArchList()
SupArch.sort()
SortedArch = ' '.join(SupArch)
if SortedArch in NewSectionDict:
NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]
else:
NewSectionDict[SortedArch] = [NewStateMent]
SectionContent = GenSection(SectionName, NewSectionDict)
SectionContent = SectionContent.strip()
if SectionContent:
Content = '# ' + ('\n' + '# ').join(GetSplitValueList(SectionContent, '\n'))
Content = Content.lstrip()
#
# add a return to differentiate it between other possible sections
#
if Content:
Content += '\n'
return Content
示例2: GenGuidSections
def GenGuidSections(GuidObjList):
#
# generate [Guids] section
#
Content = ''
GuidDict = Sdict()
for Guid in GuidObjList:
HelpTextList = Guid.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CName = Guid.GetCName()
FFE = Guid.GetFeatureFlag()
Statement = CName
if FFE:
Statement += '|' + FFE
Usage = Guid.GetUsage()
GuidType = Guid.GetGuidTypeList()[0]
VariableName = Guid.GetVariableName()
#
# Differentiate the generic comment and usage comment as multiple generic comment need to be put at first
#
if Usage == DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
# generate list of generic comment
Comment = GenGenericCommentF(HelpStr)
else:
# generate list of other comment
Comment = HelpStr.replace('\n', ' ')
Comment = Comment.strip()
if Comment:
Comment = ' # ' + Comment
else:
Comment = ''
if Usage != DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
Comment = '## ' + Usage + Comment
elif GuidType == 'Variable':
Comment = '## ' + Usage + ' ## ' + GuidType + ':' + VariableName + Comment
else:
Comment = '## ' + Usage + ' ## ' + GuidType + Comment
if Comment:
Comment += '\n'
#
# merge duplicate items
#
ArchList = Guid.GetSupArchList()
ArchList.sort()
SortedArch = ' '.join(ArchList)
if (Statement, SortedArch) in GuidDict:
PreviousComment = GuidDict[Statement, SortedArch]
Comment = PreviousComment + Comment
GuidDict[Statement, SortedArch] = Comment
NewSectionDict = GenMetaFileMisc.TransferDict(GuidDict, 'INF_GUID')
#
# generate the section contents
#
if NewSectionDict:
Content = GenSection('Guids', NewSectionDict)
return Content
示例3: GenProtocolPPiSections
def GenProtocolPPiSections(ObjList, IsProtocol):
Content = ''
Dict = Sdict()
for Object in ObjList:
HelpTextList = Object.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CName = Object.GetCName()
FFE = Object.GetFeatureFlag()
Statement = CName
if FFE:
Statement += '|' + FFE
Usage = Object.GetUsage()
Notify = Object.GetNotify()
#
# Differentiate the generic comment and usage comment as consecutive generic comment need to be put together
#
if Usage == DT.ITEM_UNDEFINED and Notify == '':
# generate list of generic comment
Comment = GenGenericCommentF(HelpStr)
else:
# generate list of other comment
Comment = HelpStr.replace('\n', ' ')
Comment = Comment.strip()
if Comment:
Comment = ' # ' + Comment
else:
Comment = ''
if Usage == DT.ITEM_UNDEFINED and not Comment and Notify == '':
Comment = ''
else:
if Notify:
Comment = '## ' + Usage + ' ## ' + 'NOTIFY' + Comment
else:
Comment = '## ' + Usage + Comment
if Comment:
Comment += '\n'
#
# merge duplicate items
#
ArchList = Object.GetSupArchList()
ArchList.sort()
SortedArch = ' '.join(ArchList)
if (Statement, SortedArch) in Dict:
PreviousComment = Dict[Statement, SortedArch]
Comment = PreviousComment + Comment
Dict[Statement, SortedArch] = Comment
NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PPI_PROTOCOL')
#
# generate the section contents
#
if NewSectionDict:
if IsProtocol:
Content = GenSection('Protocols', NewSectionDict)
else:
Content = GenSection('Ppis', NewSectionDict)
return Content
示例4: GenPcdSections
def GenPcdSections(ModuleObject):
Content = ''
if not GlobalData.gIS_BINARY_INF:
#
# for each Pcd Itemtype, maintain a dict so the same type will be grouped
# together
#
ItemTypeDict = {}
for Pcd in ModuleObject.GetPcdList():
HelpTextList = Pcd.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
Statement = ''
CName = Pcd.GetCName()
TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName()
DefaultValue = Pcd.GetDefaultValue()
ItemType = Pcd.GetItemType()
if ItemType in ItemTypeDict:
Dict = ItemTypeDict[ItemType]
else:
Dict = Sdict()
ItemTypeDict[ItemType] = Dict
FFE = Pcd.GetFeatureFlag()
Statement += TokenSpaceGuidCName + '.' + CName
if DefaultValue:
Statement += '|' + DefaultValue
if FFE:
Statement += '|' + FFE
elif FFE:
Statement += '||' + FFE
#
# Generate comment
#
Usage = Pcd.GetValidUsage()
# if FeatureFlag Pcd, then assume all Usage is CONSUMES
if ItemType == DT.TAB_INF_FEATURE_PCD:
Usage = DT.USAGE_ITEM_CONSUMES
if Usage == DT.ITEM_UNDEFINED:
# generate list of generic comment
Comment = GenGenericCommentF(HelpStr)
else:
# generate list of other comment
Comment = HelpStr.replace('\n', ' ')
Comment = Comment.strip()
if Comment:
Comment = ' # ' + Comment
else:
Comment = ''
Comment = '## ' + Usage + Comment
if Comment:
Comment += '\n'
#
# Merge duplicate entries
#
ArchList = Pcd.GetSupArchList()
ArchList.sort()
SortedArch = ' '.join(ArchList)
if (Statement, SortedArch) in Dict:
PreviousComment = Dict[Statement, SortedArch]
Comment = PreviousComment + Comment
Dict[Statement, SortedArch] = Comment
for ItemType in ItemTypeDict:
# First we need to transfer the Dict to use SortedArch as key
Dict = ItemTypeDict[ItemType]
NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PCD')
if NewSectionDict:
Content += GenSection(ItemType, NewSectionDict)
#
# For AsBuild INF files
#
else:
Content += GenAsBuiltPacthPcdSections(ModuleObject)
Content += GenAsBuiltPcdExSections(ModuleObject)
return Content
示例5: GenProtocolPPiSections
def GenProtocolPPiSections(ObjList, IsProtocol):
Content = ""
Dict = Sdict()
for Object in ObjList:
HelpTextList = Object.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CName = Object.GetCName()
FFE = Object.GetFeatureFlag()
Statement = CName
if FFE:
Statement += "|" + FFE
Usage = Object.GetUsage()
Notify = Object.GetNotify()
#
# we need to differentiate the generic comment and usage comment
# as consecutive generic comment need to be put together
#
if Usage == DT.ITEM_UNDEFINED and Notify == "":
# generate list of generic comment
Comment = GenGenericCommentF(HelpStr)
else:
# generate list of other comment
Comment = HelpStr.replace("\n", " ")
Comment = Comment.strip()
if Comment:
Comment = " # " + Comment
else:
Comment = ""
if Usage == DT.ITEM_UNDEFINED and not Comment and Notify == "":
Comment = ""
else:
if Notify:
Comment = "## " + Usage + " ## " + "NOTIFY" + Comment
else:
Comment = "## " + Usage + Comment
if Comment:
Comment += "\n"
#
# merge duplicate items
#
ArchList = Object.GetSupArchList()
ArchList.sort()
SortedArch = " ".join(ArchList)
if (Statement, SortedArch) in Dict:
PreviousComment = Dict[Statement, SortedArch]
Comment = PreviousComment + Comment
Dict[Statement, SortedArch] = Comment
NewSectionDict = GenMetaFileMisc.TransferDict(Dict)
#
# generate the section contents
#
if NewSectionDict:
if IsProtocol:
Content = GenSection("Protocols", NewSectionDict)
else:
Content = GenSection("Ppis", NewSectionDict)
return Content
示例6: GenGuidSections
def GenGuidSections(GuidObjList):
#
# generate [Guids] section
#
Content = ""
GuidDict = Sdict()
for Guid in GuidObjList:
HelpTextList = Guid.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CName = Guid.GetCName()
FFE = Guid.GetFeatureFlag()
Statement = CName
if FFE:
Statement += "|" + FFE
Usage = Guid.GetUsage()
GuidType = Guid.GetGuidTypeList()[0]
VariableName = Guid.GetVariableName()
#
# we need to differentiate the generic comment and usage comment
# as multiple generic comment need to be put at first
#
if Usage == DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
# generate list of generic comment
Comment = GenGenericCommentF(HelpStr)
else:
# generate list of other comment
Comment = HelpStr.replace("\n", " ")
Comment = Comment.strip()
if Comment:
Comment = " # " + Comment
else:
Comment = ""
if Usage != DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
Comment = "## " + Usage + Comment
elif GuidType == "Variable":
Comment = "## " + Usage + " ## " + GuidType + ":" + VariableName + Comment
else:
Comment = "## " + Usage + " ## " + GuidType + Comment
if Comment:
Comment += "\n"
#
# merge duplicate items
#
ArchList = Guid.GetSupArchList()
ArchList.sort()
SortedArch = " ".join(ArchList)
if (Statement, SortedArch) in GuidDict:
PreviousComment = GuidDict[Statement, SortedArch]
Comment = PreviousComment + Comment
GuidDict[Statement, SortedArch] = Comment
NewSectionDict = GenMetaFileMisc.TransferDict(GuidDict)
#
# generate the section contents
#
if NewSectionDict:
Content = GenSection("Guids", NewSectionDict)
return Content